Skip to content

Conversation

@aaron-ang
Copy link
Contributor

@aaron-ang aaron-ang commented Nov 3, 2025

Close #1417.

We need to save the keyword identifier during signature range search to find the correct position when creating signature information.

I added some test cases to signature_help.rs, and manually verified the fix by building and running LSP locally:
Screenshot 2025-11-02 at 10 51 53 PM

There is also a bug in positional arguments, as the newly-added positional_arguments_test fails on the main branch. To fix this, we need to count the number of separators (commas) and adjust the index accordingly.

@meta-cla meta-cla bot added the cla signed label Nov 3, 2025
@aaron-ang aaron-ang marked this pull request as ready for review November 3, 2025 07:09
@stroxler stroxler requested a review from kinto0 November 5, 2025 02:14
@stroxler
Copy link
Contributor

stroxler commented Nov 5, 2025

Thanks for the PR!

This looks pretty good to me but we should get a review from @kinto0 as well

@aaron-ang
Copy link
Contributor Author

rebased

@meta-codesync
Copy link

meta-codesync bot commented Nov 6, 2025

@stroxler has imported this pull request. If you are a Meta employee, you can view this in D86417276.

Copy link
Contributor

@ndmitchell ndmitchell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

Copy link
Contributor

@stroxler stroxler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you rebased past a change in the hover result, hence the test failures

Copy link
Contributor

@kinto0 kinto0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the contribution! I'm a little unclear as to why we need Next and why we need to count the separators now. could you add more information to the PR?

&& call.arguments.range.contains_inclusive(find)
{
// Check positional arguments
for (i, arg) in call.arguments.args.as_ref().iter().enumerate() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: if this was extracted into a helper function, we wouldn't need the comments since the function name would explain it. it also makes visit_finding_signature_range a lot easier to read

}
}
// Check keyword arguments
let kwarg_start_idx = call.arguments.args.len();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same nit: another helper function? this function is getting big

enum ActiveArgument {
Positional(usize),
Keyword(Name),
Next(usize),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could you add a doc-comment to these? it's unclear what Next is

| Param::VarArg(Some(name), ..)
| Param::KwOnly(name, ..)
| Param::Kwargs(Some(name), ..) => Some(name),
_ => None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like this covers all cases so please exclude this wildcard (makes it less bug-prone when we add a new Param)

}
}

fn parameter_name(param: &Param) -> Option<&Name> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function should probably go in pyrefly_types/src/callable.rs as an impl for Param. maybe fmt_with_type should use it?

mod_module.visit(&mut |x| Self::visit_finding_signature_range(x, position, &mut res));
let (callee_range, call_args_range, arg_index) = res?;
let (callee_range, call_args_range, mut active_argument) = res?;
if let ActiveArgument::Next(index) = &mut active_argument
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a comment here for what this part does and why it's necessary

Copy link
Contributor

@stroxler stroxler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

input suggestion will jump to another parameter

4 participants