Bug 111317 - Move the AST rewrite analyzer to AJDT so we can remove the horrible jface text dependency.
Summary: Move the AST rewrite analyzer to AJDT so we can remove the horrible jface tex...
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: DEVELOPMENT   Edit
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: 1.5.0RC1   Edit
Assignee: Andrew Clement CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-03 04:04 EDT by Andrew Clement CLA
Modified: 2005-11-30 07:02 EST (History)
1 user (show)

See Also:


Attachments
factory/rewriter/testprogram (22.64 KB, application/zip)
2005-11-28 05:51 EST, Andrew Clement CLA
no flags Details
zip containing patches for ajdt core and ajdt core.test projects (37.12 KB, application/zip)
2005-11-30 06:34 EST, Helen Beeken CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Clement CLA 2005-10-03 04:04:53 EDT
 
Comment 1 Andrew Clement CLA 2005-11-28 04:45:08 EST
Hard stuff ...  the first step is that I've removed the class from being packaged with AspectJ (and removed the jface being built into AspectJ).  The next step is to build an AspectJ, plug it into AJDT - move the rewriteanalyzer into AJDT and get it working with the testcase we have.

I'm going to attach the testcase to this bug, together with the rewrite analyzer itself.

(I think the problem will be the expected package names ... and that may require a further change in AJ)

Comment 2 Andrew Clement CLA 2005-11-28 05:51:42 EST
Created attachment 30699 [details]
factory/rewriter/testprogram
Comment 3 Helen Beeken CLA 2005-11-30 05:15:31 EST
There were several steps that had to be taken to get this to work...........

Firstly, to get the tests to run I needed to supply a compiler options map to the ASTParser (parser.setCompilerOptions(...)). Similarly, when calling the rewriteAST method on an ASTRewrite the same options map needed to be passed through.

Secondly, to get the tests to pass I couldn't just apply the two supplied classes to the ajdt.core plugin (AjASTRewriteAnalyzer and AjASTRewriteAnalyzerFactory) because within org.aspectj.org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer (in ajde.jar) the AspectJ Extension was looking for the org.aspectj.ajdt.core.dom.rewrite.AjASTRewriteAnalyzerFactory class which it couldn't find because it now lives in the ajdt.core plugin. Therefore the AJ version of the ASTRewriteAnalyzer wasn't being used so pointcuts etc. weren't being understood and the tests were failing because nothing was being rewritten. 

To fix this I replaced the contents of the supplied AjASTRewriteAnalyzer class with the contents of org.aspectj.org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer in ajde.jar which meant it could now find the factory class. However, the problem was still that the AJ versions weren't being called. This was because the call

rewriter.rewriteAST(doc, compilerOptions);

in the tests was called on an ASTRewrite (in ajde.jar) which has an AspectJ Extension to use the factory:

ASTVisitor visitor= ASTRewriteAnalyzer.getAnalyzerVisitor(.....);

However, because this was in ajde, it was using the ASTRewriteAnalyzer which still couldn't find the factory class and consequently was using the non-aj version. To fix this I created an AjASTRewrite class in ajdt.core whose contents is the same as ASTRewrite except that it uses AjASTRewriteAnalyzer rather than ASTRewriteAnalyzer.

Moving this accross required also creating an AjListRewrite class in ajdt.core whose contents is the same as ListRewrite (in ajde.jar) except for the fact that it works with the ajdt.core "aj" versions of the classes. The final step was to create an AjASTRewriteFormatter class whose contents is the same as ASTRewriteAnalyzer (in ajde.jar), except again when works with the "aj" versions of the classes.

The 5 new classes have been created within org.eclispe.ajdt.core.dom.rewrite:

* AjASTRewrite
* AjASTRewriteAnalyzer
* AjASTRewriteAnalyzerFactory
* AjASTRewriteFormatter
* AjListRewrite

and all, where necessary, use these "aj" versions. All changes have been marked with "// AspectJ Change".

The final step in getting the tests to pass was to use the "aj" versions of the classes in ajdt.core within the testcases.
Comment 4 Helen Beeken CLA 2005-11-30 05:19:08 EST
Oh yes.....and this required one further change to aspectj...

In org.aspectj.org.eclipse.jdt.internal.core.dom.rewrite.NodeInfoStore, the two inner classes CopyPlaceholderData and StringPlaceholderData needed their visibility changed from protected to public so that they can be used in org.eclipse.ajdt.core.dom.rewrite.AjASTRewriteAnalyzer.
Comment 5 Helen Beeken CLA 2005-11-30 06:34:02 EST
Created attachment 30848 [details]
zip containing patches for ajdt core and ajdt core.test projects

As a record of the changes made to AJDT for this bug I'm attaching a zip containing two patches, one to be applied to the org.eclipse.ajdt.core project and the other to be applied to the org.eclipse.ajdt.core.tests project, both against the AJDT 1.2 (Eclipse 3.0) codebase.

These patches have been applied to both the AJDT 1.2 and 1.3 streams and will be available in the next clean build.
Comment 6 Andrew Clement CLA 2005-11-30 07:02:49 EST
Ok ... all finished.  AspectJ builds have shrunk a little now that extraneous stuff has been removed and anyone wanting to work on the rewriter can do so in the comfort of AJDT rather than hacking in AJDE.

thanks for getting it working like I hoped it would Helen :)