-
Notifications
You must be signed in to change notification settings - Fork 29
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
Invalid snippet suggested in completion before the Class statement [context] #402
Comments
@datho7561 do you think we could improve java cursor context to cover this Issue? |
@turkeylurkey we know that our java cursor context is not perfect, but it should filter the most common usecases, any contribution are welcome! |
I thought I handled this case correctly. I'll take a quick look at what is happening. |
From my testing, cases B and C seem to work properly, but A doesn't work (either with (I am testing using VS Code, this might be different from Eclipse). |
The reason A doesn't work is that SnippetContextForJava explicitly allows the wrong snippets to be available: Line 101 in e82966d
If you just remove BEFORE_CLASS then you will break B. That fix requires reworking the code that examines the syntax tree. |
@turkeylurkey is there any chance that you provide a PR with your idea? |
Unfortunately I'm having trouble building and running in Eclipse to update |
This issue revolves around the field and method snippets and the context in which the language server suggests them when the user activates completion (e.g. Ctrl-Space).
Consider this sample class:
When you use completion in Position A the language server provides
rest_get
as one of the choices. This snippet represents the insertion of a method but this is not valid in this context. When you use completion in Position C the snippetrest_get
is valid. It looks like method snippets should not be allowed before a class. This requires fix #1.This brings us to Position B. Currently the language server considers this to be "before a class." We must allow a method snippet here. This exposes an ambiguity in the definitions. Position B is both 'In A Class' and 'Before A Class.' The former should dominate the latter and this would allow the language server to suggest a method snippet here. This requires fix #2.
The text was updated successfully, but these errors were encountered: