Community
Participate
Working Groups
The following refactorings are broken to varying degrees inside of AJ compilation units. After a little bit of exploration, many of the problems stem from creating a dom CompilationUnit AST that is built off of translated source code that includes text outside of the range of the original source code. The refactoring processors then attempt to insert code into a location that is at an invalid range. This causes all sorts of exceptions to be thrown. We should look at a way of addressing as many of these refactoring problems as we can, and then disable the remaining refactorings that still do not work. ** Doesn't work at all Extract super class --- problem with preview. Can't find element Infer generic arguments where possible --- compile error shown Introduce Parameter (inside advice) --- exception thrown when producing preview page Introduce Parameter Object --- Cannot analyze selected method Convert Local variable to a field --- Error (null argument) Encapsulate field --- Error (null argument) ** Works, but complains about bad syntax in preview pane Change method signature --- uses original source code, but will eventually work Introduce Parameter Object (inside regular method) --- uses original source code, but will eventually work
It looks like most refactorings grab their dom AST through the RefactoringASTProvider. JDT Weaving can capture calls to that class and ensure that a proper AST is created when the target compilation unit is an AJCU.
Convert local variable to field is now working. As described in c1, I now weave around RefactoringASTParser.parseWithASTProvider() (the previous comment used the wrong class name). I am about to commit the fix as well as regression tests.
Unfortunately, the other broken refactorings are not affected by this change. The best solution for these may be to simply disable them in AJ editors.