-
Notifications
You must be signed in to change notification settings - Fork 202
Completion for keyword arguments #3397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
How to use the Graphite Merge QueueAdd the label graphite-merge to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
de0b146
to
011ef16
Compare
if ["(", ","].include?(@trigger_character) | ||
complete_keyword_arguments(node) | ||
return | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of checking on call nodes if the trigger character matches, we should start handling the event for Prism::ParametersNode
, so that completion is triggered for parameters.
This should be a matter of
- Registering the event
- Adding the node as a possible target
- Creating an
on_parameters_node_enter
handler - Doing the work to provide keyword completion inside that method
if @node_context.parent.is_a?(Prism::CallNode) && method_name | ||
call_node = T.cast(@node_context.parent, Prism::CallNode) | ||
candidates = keyword_argument_completion_candidates(call_node, method_name) | ||
candidates.each do |param| | ||
build_keyword_argument_completion_item(param, range) | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You won't need this check after registering for parameter node events.
type = @type_inferrer.send(:infer_receiver_for_call_node, node, @node_context) | ||
return unless type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not rely on a private API. We can just call @type_inferrer.infer_receiver_type(@node_context)
and make any necessary modifications to handle the new scenario in the type inferrer.
Motivation
Closes #2913.
Implementation
(
,,
Automated Tests
Added.
Manual Tests