Skip to content
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

Autocomplete / proposals incorrect when followed by variable declaration #1129

Closed
ssadedin opened this issue Jun 20, 2020 · 7 comments
Closed
Assignees
Milestone

Comments

@ssadedin
Copy link

When the next statement is a variable declaration, autocomplete on the previous statement seems to be generated from the surrounding class context instead of the correct object. It is probably easiest to explain with a screenshot:

image

In this example, I expect to see proposals for the String and GString types, but actually observed behavior is I see proposals for the surrounding class (CompletionProblem).

If instead I change the code to instead use a different statement (eg: assignment) then I see the correct autocomplete proposals:

image

@eric-milles
Copy link
Member

eric-milles commented Jul 30, 2020

Thanks for the submission. In this case, the "hello".\n\tdef forms a complete property expression. Then the parser starts looking at a = 23 and says that can't be part of the command expression (that starts with println) and it can't be the start of a new statement/expression since there is not a sufficient separator (newline or semicolon).

I'll see what I can do with the parser; it's a bit tricky in this case.

@eric-milles
Copy link
Member

Ready to test for Eclipse 4.15+

@ssadedin
Copy link
Author

Thanks @eric-milles! nice work. I will look out for the next snapshot build and try it out.

@ssadedin
Copy link
Author

ssadedin commented Aug 1, 2020

Tested snapshot build and confirmed fix works. Thanks!

@ssadedin
Copy link
Author

ssadedin commented Aug 1, 2020

NB: I'm not sure if it's a regression due to this change or something else, but I've found the snapshot build seems to have a problem with static imports:

image

I'm particularly seeing it where the static import is from a class that is imported by default (because it's in the same package, or a default language import like java.util.*.

Feel free to close if this known / dupe / unlrelated, but thought it worth mentioning in case it's related to this fix.

@eric-milles
Copy link
Member

I disabled that behavior here 70655e8

I'm curious to know how useful it is vs. spelling out the fully-qualified types. It's a real performance hit for files with a large number of import statements and confusing for newcomers that imports can depend on other imports (often hidden ones), which is something Java does not support.

@ssadedin
Copy link
Author

ssadedin commented Aug 2, 2020

Thanks @eric-milles - just to follow up on the static imports. It's not a inconvenient at all in terms of my own code (trival to fix) but I guess the issue will be that if

import static Math.abs

is valid Groovy in general, then you'll have projects from outside groovy-eclipse that use it and they'll show errors inside groovy-eclipse. I'm not sure how common it is use this form of static import. Given that it isn't valid Java it's probably very rare and I'd probably prefer a big performance improvement over supporting it.

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

No branches or pull requests

2 participants