-
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
Code assist completion with "{" and method with Closure as last argument #410
Comments
|
Indeed, the "closure as last argument" is a very special case for Groovy, because it supports a special syntax (i.e.: outside the round parenthesis used for standard parameter passing to method calls). Perhaps it may deserve some special handling. |
If you have "Place trailing closure arguments after closing parenthesis" checked, I would expect |
The call to set cursor position was removed. So at least now the |
[].sort| sort(Closure) proposal -> [].sort { it } -- "it" selected sort(boolean) proposal -> [].sort(mutate) { -- "mutate" selected sort(boolean, Closure) proposal -> [].sort(mutate) { it } -- ditto sort(Comparator) proposal -> [].sort { o1, o2 -> } -- 1st param select NOTE: Named parameters supported but parameter guessing not supported
I've got something workable for you to try out. It does not support the parameter guessing mode yet, but should give a good completions with any of the other Content Assist preferences in checked or unchecked. There are more details in the comment of the commit above. |
Updated to 3.0.0.xx-201801312125-e47, this is what I see:
|
And, as a further improvement: could "{" be considered a trigger character for just method calls accepting closures, with special handling to avoid a duplicate open curly bracket insertion? |
I'm not sure if you caught my proviso. Changes so far are only available when "Use guessed arguments for method calls" is unchecked. There is a separate code path for the guess handling and I still need to deal with that. |
Hi Eric, |
I'm working to bring together the handling of guessed arguments and the other mode. It will take some time to unwind some complicated code but I wanted to give a taste of what the behavior would be in the end. |
- use Java Content Assist preferences for parameter insert and guessing - fix constructor and method context display (parameter list above text)
Here is a little summary of where I'm at. I removed the Groovy preference for enabling guessing. The Java one is used now for consistent behavior between Java and Groovy editors. For constructor completion, I'm almost done. 2 of the 3 possibilities for argument insertion are fully supported and the guessing case just requires some missing context information. Also, the 2 possibilities for import insertion are fully supported -- "Add import instead of qualified name" checked or unchecked. WRT generics, Java tries to fill in the For method completion, I don't have a table worked up yet, but will soon. All 3 possibilities for argument insertion are fully supported. I have a couple edge cases for Using Also, I want to illustrate the differences when the 3 Groovy Content Assist preference are on or off. All should work fine, but testing them all out is time consuming. I did my best with the 3 x 3 x 2^3 different combinations. |
Also the Java Formatter preferences for spaces before and after colons, commas, curly braces and parentheses should be respected. I used the array initializer prefs for inside closure literals. |
Also, the context display (completion just inside |
- fixes '{' trigger w/o argument insertion: "new T({|)" -> "new T() {|"
Hi Eric, great work here! I upgraded to 3.0.0.xx-201802052313-e47 and I concentrate now on this bug report. This is what I see when trying to use
|
For the cases where you end up with a trailing For the cases where the entire closure is highlighted, I'm aware of that and have it as something to look at outside of this issue. |
Regarding the closing bracket: ok, I just find it inconsistent with the other cases, where the closing bracket is always inserted beforehand. |
Ensure the option Window | Preferences | Groovy | Editor | Content Assist | Use closure literals for closure arguments is UNCHECKED.
Try the following:
Invoke code assist at "|", ensure
with(Closure)
is highlighted and hit "{".Result:
new Object().with({closure)
(with strange selection:{closur
).Expected result:
or at least:
new Object().with { | }
(with cursor at "|").
If Window | Preferences | Groovy | Editor | Content Assist | Use closure literals for closure arguments is CHECKED, the result is different, but still arguable:
new Object().with({{ it })
(with selection:i
). Please note the double "{" and the strange selection.The text was updated successfully, but these errors were encountered: