-
Notifications
You must be signed in to change notification settings - Fork 193
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
DSLD: Context information popup highlights wrong parameter name in case of a trailing closure #613
Comments
PR is coming along with fixes for #603 |
In general, no use of named parameters has highlighting that matches the context information. Please be sure to test non-DSLD cases where Map is first method parameter. |
If you plan on developing PR immediately, issue serves no purpose. All discussion and review can happen as part of PR. |
yes, will make sure non-DSLD cases are not affected. |
@eric-milles The problem seems to be more wide. When mixing named and regular params, DSLD signatures are generated with named params in front, but core Java signatures (based on which context popup is rendered) are other way around (regular params first). Lines 503 to 505 in 02993bf
The resulting behavior of the context popup is similar to the trailing closure issue: |
The above snippet contradicts the following code, where it generates a param list for a method signature: regular params first, following by named params: Lines 44 to 46 in ebd9549
I believe the order should be consistent, so one of the two must be valid, and the other must be wrong.
|
Re issue vs. pull request: I prefer an issue followed by discussion before any coding takes place. If you submit a comment immediately stating you have a PR forthcoming, I assume you are not receptive to discussion of direction and options. So why not just a PR. That said, let me restate that I prefer discussion here or on slack before moving to coding. As I mentioned above, yes the issue of context hover of method call parameters with named parameters is wider than just DSLD. When you have The Map being a faux-positional param and the interleaving makes deciding which parameter to highlight in the hover non-trivial. As for the DSL NamedArgsMethodNode, I don't know why the named params are displayed first. It may have something to do with recognizing that |
Sorry just meant that I started work on a PR to avoid other contributors jump on an the issue. What we currently have is a disagreement in parameter order between NamedArgsMethodNode and GroovyJavaMethodCompletionProposal I believe either is actually bad, and the ideal order should be:
What I propose to fix:
Yes, the changes are not trivial, and I now think this work should be separate from #603 @eric-milles, Does it all make sense ? |
You can assign the issue to yourself. If that option does not sow for you, I can assign it. If you try changing just |
I don't have write access to the repository, so I can't assign it to myself. If NamedArgsMethodNode is not touched, another place where the signature can be altered is here: Lines 158 to 167 in bbb8942
But it does not feel like a right place, it calls getVisibleParams() which is already expected to return final signature order. Are you suggesting to keep named parameters in front? In that case only a signature generation logic needs to be changed and GroovyJavaMethodCompletionProposal would remain as is. |
Just wondering what the minimal change would be. And if you could run an experiment or two to see if an improvement could be made with just one participant altered. Not saying that's the end state, but wanting to see if we can get a look at something quickly. Can you try a couple of your proposed changes and see what you see in terms of trade-offs? |
Also, can you find a good test suite to add some tests to illustrate the issue? Or is it 100% to do with the little context info hover? I agree with the original post that the proposal replacement text and the context information box are not in agreement. What I'm thinking about at the same time is if you typed out I'm a tad worried that the named argument support is not very complete and we are going to end up with a lot of use cases to understand. |
The issue manifests itself in 2 places:
So it is visual inconsistency between what you see and what you get after selection: The signatures in auto-complete popup (as well as params in context popup ) are controlled by concat() helper in NamedArgsMethodNode. |
I can see grouping all the named params first followed by the positional ones for two reasons:
To have proposal, replacement and context list named first followed by positional, what changes are required? |
Do you think it is worth exploring including the named param label in the proposal and context popups? |
I will issue PR soon, I think ended up in minimal changes. |
Consider the following DSLD:
method name: "foo", type: "void", noParens: true, namedParams: [bar: String], params: [block: 'groovy.lang.Closure']
If we select the foo method from the auto-complete menu, 'bar' is initially selected in the editor as expected, but the context popup highlights the 'block' in bold:
After hitting tab, the 'block' gets selected, but 'bar' gets highlighted:
The context popup is rendered deep inside Eclipse/Java logic which is not aware of Groovy nature of a trailing closure parameter.
I would propose to "fix" the order of parameters just in the context popup, so at least switching and highlighting would work consistently with the editor, like this:
The text was updated successfully, but these errors were encountered: