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

Anonymous inner class: wrong "override method" result when a space is present #695

Closed
mauromol opened this issue Aug 29, 2018 · 3 comments
Closed
Assignees
Milestone

Comments

@mauromol
Copy link

Followup to #395 (where the mentioned I interface is defined).

Consider the following (watch carefully the whitespace characters!):

immagine

When you hit Ctrl+Space to add the unimplemented method mymethod you get:

immagine

When you have this, instead (please note the missing space after the last-but-one closed bracket):

immagine

Then you get the correct result:

immagine

Please note, however, that, even in the correct result, I would expect the cursor to be placed inside the implemented method body, not after its closing bracket.

@eric-milles
Copy link
Member

The transfer of Groovy class members to the JDT model, especially method statements is very sensitive to the source position information. I needed to subtract 1 from the bodyEnd property of a MethodDeclaration for the body parsing to start succeeding. JDT is expecting that the body ends at the offset of the closing brace. Groovy has an end position for the closing brace or probably more correctly the next newline minus 1.

Your example with an extra space after the closing brace of a method body will need to be corrected for. The Antlr2 grammar has a bad tendency of sucking in those whitespaces as part of the token.

@eric-milles
Copy link
Member

Ready to test

@mauromol
Copy link
Author

This use case works well in 3.1.0.xx-201808311121-e47, thank you! 👍

@eric-milles eric-milles self-assigned this Sep 16, 2018
@eric-milles eric-milles added this to the v3.1.0 milestone Sep 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants