Community
Participate
Working Groups
Code looks like this: ---- System.out.println("blah"); for (int i= ---- Extract local variable for "blah" will fail because of the subsequent syntax error. Non-existent types will not fail. I would like Extract Local Variable to survive this kind of situation anyway since as far as I can tell, there is enough information in this context to determine what the extraction should do. Granted code is broken and it will stay broken, any duplicate "blah"s in the rest of the file should probably be ignored, etc. BUT I find myself attempting to do this sort of thing a lot and it's getting more and more annoying that Eclipse complains.
our AST is can't deal with incorrect syntax by design. I think there are plans to improve error recovery; moving to jdt.core.
Not for 3.0
dup
*** This bug has been marked as a duplicate of 42253 ***
Reopen as there's still something preventing user to extract local variable. Bug 42253 is fixed and I can see now 2 statements: ExpressionStatement and ForStatement. However, when I select "blah" and try to Refactor->Extract local variable... I get an "Extract Local variable" error dialog saying: "The file contains syntax errors. To perform this operation you will need to fix the errors."
Back to JDT/UI to enable user to perform this operation...
BTW, it works if you use quick fix to extract the local. But we should also update the refactoring to use the statement recovery AST. Markus, can you make a pass on all of the 'local' refactoring (refactorings that just work on one file).
Fixed for all one-file-refactorings.