Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 324018 - [refactoring] [plan] More refactorings that do not work in an AJ compilation unit
Summary: [refactoring] [plan] More refactorings that do not work in an AJ compilation ...
Status: NEW
Alias: None
Product: AJDT
Classification: Tools
Component: Core (show other bugs)
Version: 2.1.0   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 2.1.2   Edit
Assignee: AJDT-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-30 15:08 EDT by Andrew Eisenberg CLA
Modified: 2010-12-08 19:59 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Eisenberg CLA 2010-08-30 15:08:31 EDT
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
Comment 1 Andrew Eisenberg CLA 2010-08-30 15:09:52 EDT
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.
Comment 2 Andrew Eisenberg CLA 2010-08-30 16:56:06 EDT
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.
Comment 3 Andrew Eisenberg CLA 2010-08-30 16:58:32 EDT
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.