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

eclipse highlighting issues with @SneakyThrows and @Cleanup #3049

Open
Ranger-118 opened this issue Nov 30, 2021 · 6 comments
Open

eclipse highlighting issues with @SneakyThrows and @Cleanup #3049

Ranger-118 opened this issue Nov 30, 2021 · 6 comments
Labels
accepted The issue/enhancement is valid, sensible, and explained in sufficient detail bug eclipse

Comments

@Ranger-118
Copy link

I still get highlighting issues with @SneakyThrows and @Cleanup since they are mentioned on methods and variables, maybe that's the difference

Originally posted by @rzwitserloot in #2950 (comment)

@Rawi01
Copy link
Collaborator

Rawi01 commented Dec 1, 2021

Can you provide a small example with instructions how I can reproduce it? In my short test everything seems to work as expected.

@Rawi01 Rawi01 added the parked Without further feedback this bug cannot be processed. If no feedback is provided, we close these. label Dec 1, 2021
@Ranger-118
Copy link
Author

Can you provide a small example with instructions how I can reproduce it? In my short test everything seems to work as expected.

Please find the @SneakyThrows in the project https://github.com/Ranger-118/lombok-demo.git and try to compare when comment it. I'm using VSCode which is same as Eclipse.

@Rawi01
Copy link
Collaborator

Rawi01 commented Dec 1, 2021

Thanks for this perfect example.

The problme is that lombok hides generated nodes for refactorings, cleanups and the highlighter. In most cases this works flawlessly but @Cleanup and @SneakyThrows create a wrapping try statement and because this one is generated all child elements get hidden. This also affects cleanups in eclipse that will simply not touch the body of such methods. The only real fix I know is to replace the generic hider with specific ones for all refactorings (thats how it was done some time ago) but thats a lot of work...

@Rawi01 Rawi01 added accepted The issue/enhancement is valid, sensible, and explained in sufficient detail bug eclipse and removed parked Without further feedback this bug cannot be processed. If no feedback is provided, we close these. labels Dec 1, 2021
@Ranger-118
Copy link
Author

Ranger-118 commented Dec 2, 2021

@Rawi01 I can understand the workload, not a lifeblood case anyway, you may fix it in proper time.

@Ranger-118
Copy link
Author

@Rawi01 Or maybe you could brief a bit more so that I do it myself?

@Rawi01
Copy link
Collaborator

Rawi01 commented Dec 21, 2021

Lombok marks all generated nodes (classes, methods, statements, etc.) as generated. This information is required to handle some cases for example the cleanup/save action part. If eclipse tries to perform some cleanup for the generated nodes it sometimes simply fails because there is no actual code that can be changed. To handle this lombok used some patches for a handcrafted list of save actions. Eclipse added a bunch of new save actions/cleanups in the latest versions and instead of adding them all by hand I replaced this list with a generic mechanism (ff8af61).

Eclipse uses the visitor pattern to traverse the AST and the new patch intercepts the accept method and simply returns if the node is generated and the visitor should not see the node and all of its children. This obviously also hides the generated try ... catch statement and its children. This was an unintended side effect of the new patch.

The fastest way to fix it is to revert the generic solution and add all new save actions to the list (started that some time ago Rawi01@c8c46af). The downside of this is that we have to adjust the list everytime eclipse (or the language server implementation) changes.

A different approach might be to keep the current idea but not hide the children of a try. I tried that by removing the generated flag for the generated try but this leads to exceptions in some save actions...

To only fix the highlighting you can also remove the SemanticTokensVisitor in PatchFixes#isBlockedVisitorAndGenerated and add custom patches for this class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted The issue/enhancement is valid, sensible, and explained in sufficient detail bug eclipse
Projects
None yet
Development

No branches or pull requests

2 participants