Join GitHub today
@SneakyThrows prevents some Eclipse refactorings #668
What steps will reproduce the problem?
Also reproducible with @ Synchronized, I guess this is related to inserting code at the start and end of the method.
What is the expected output? What do you see instead?
What version of the product are you using? On what operating system?
Please provide any additional information below.
Stack trace from error log:
I added a commit to master branch that adds a new build target called 'eclipseForDebugging'. It's like 'eclipse', except it adds the eclipse deps straight from your eclipse install instead of the default (fairly ancient) eclipse, and adds a couple of non-deps which are nevertheless useful (to set breakpoints and such).
It's step one to fixing this and a couple of other places where eclipse integration is less than perfect.
During debugging we noticed that ASTRewrite﹟internalRewriteAST gets passed a Block in normal cases and a LocalVariableDeclaration when it fails. It might make sense that it's always supposed to get a Block since it needs to generate a local variable in some scope.
Therefore it looks like this bug can more specifically be stated as: "Why is an LVD passed to internalRewriteAST instead of a Block?"
Refactors run on the org.eclipse.dom variant of the AST, and not the one lombok primarily works with (the internal). The dom variant has a flag called 'ORIGINAL', set on almost every node (in the 'typeAndFlags' field). The refactor scripts won't consider non-ORIGINAL nodes as places to generate code for / into.
The relevant block when using @ SneakyThrows is the (generated) braces that go with the generated 'try' statement. This block IS in the org.eclipse.dom variant, but does NOT have the ORIGINAL flag set. That seems to be the problem (it's possible that further problems will ensue when we fix this).
This bug has now been reduced to: Why is that ORIGINAL flag not set? Should we use patches to force-set it, or is there something simpler we can do to set this flag? Should we even set this flag (in many ways, it is enticing to treat generated code as not original), in which case we should patch org.eclipse.jdt.internal.core.dom.RewriteEventStore﹟isNewNode(ASTNode node) to always return 'false' is ASTNode is generated. That is a dom-style ASTNode, which has a generated $isGenerated field).