Bug 88861 - Finish the AST for AJ code
Summary: Finish the AST for AJ code
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: DEVELOPMENT   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: 1.5.0 M4   Edit
Assignee: Andrew Clement CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-23 09:46 EST by Andrew Clement CLA
Modified: 2011-12-06 12:37 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Clement CLA 2005-03-23 09:46:11 EST
 
Comment 1 Matt Chapman CLA 2005-06-03 11:04:57 EDT
I'm assuming this means extending the AspectJ ASTVisitor class with visit
methods for things like PointcutDeclaration etc (with appropriate definitions of
PointcutDeclaration etc in the org.aspectj.org.eclipse.jdt.core.dom package).

Comment 2 Thierry Monney CLA 2005-07-27 10:08:03 EDT
It would be nice to have some API to manipulate an aspect's AST like the JDT DOM
AST does. This would indeed involve adding AST classes for aspects (Aspect,
PointcutDeclaration, Advice, ...) and classes to create and modifiy them,
something like AJAST.createAspect(...) or AJASTRewrite.rewrite(...)

This could be quite useful for code generation tools or more simply aspects
refactoring.
Comment 3 Andrew Clement CLA 2005-09-23 12:02:01 EDT
Infrastructure (not the entire feature...) is complete on this, thanks to a
patch from Andrew Huff.  Here is a program:

import java.util.*;
import org.aspectj.org.eclipse.jdt.core.dom.*;

public class Program {

  public static void main(String []argv) {
    ASTParser parser = ASTParser.newParser(AST.JLS2);
    parser.setCompilerOptions(new HashMap());
    parser.setSource(argv[0].toCharArray());
    CompilationUnit cu2 = (CompilationUnit) parser.createAST(null);
    AjNaiveASTFlattener visitor = new AjNaiveASTFlattener();
    cu2.accept(visitor);
    System.err.println(visitor.getResult());
  }
}

I can now compile that program (outside of eclipse..) and if I run it:

java Program "public aspect X { pointcut p(): call(* *(..));}"

then it prints:

public aspect X {
   pointcut p():call(* *(..));
}

hurray!

Now, the infrastructure is in place and quite a bit of the AST, but not all of
it.  In particular within pointcut expressions it isnt quite finished.

In terms of rewriting pointcuts, the initial support is there for rewriting
pointcut declarations (you could programmatically change p() above to be q()) -
but beyond that nothing else has been implemented for aspects yet.

We have no more cycles to put more in for AspectJ1.5.0 final, but there is more
than enough there for some keen developer out there in open source land to help
us complete it.

I'm going to close this request because the infrastructure is complete, and open
a new one for future work on the AST.
Comment 4 S Kotrappa CLA 2011-12-06 11:50:32 EST
 Hello,
Please some one help me, How to extend AST AJDT Eclipse plugin for code smells detection in AOP/AspectJ applications.
If this features in already present in the latest AJDT, tell me ,how to use it.
Comment 5 Andrew Eisenberg CLA 2011-12-06 12:37:31 EST
(In reply to comment #4)
>  Hello,
> Please some one help me, How to extend AST AJDT Eclipse plugin for code smells
> detection in AOP/AspectJ applications.
> If this features in already present in the latest AJDT, tell me ,how to use it.


Have a look at this page http://wiki.eclipse.org/Developer%27s_guide_to_building_tools_on_top_of_AJDT_and_AspectJ
And then send any questions to the ajdt-dev mailing list.
https://dev.eclipse.org/mailman/listinfo/ajdt-dev