Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] AspectJ Refactoring APIs

Hi Irum,

On 20/11/05, Irum Godil <softwarengineer2004@xxxxxxxxx> wrote:
> Hi,
> I am trying to understand APIs in AJDT code to create AspectJ code
> programmatically. I have looked at these bugs: 111317, 110465, 88861.
> However, I still have a lot of questions. I will really appreciate if
> someone can help me.
>
> 1) First of all, bug 110465 mentions tests in org.aspectj.ajdt.core in class
> ASTVisitorTest. I am unable to locate this test class in the above package.
> I checked the project: org.aspectj.ajde, but I cannot find this class.

The test code is in the AspectJ module org.aspectj.ajdt.core - not in
AJDT, tests don't make it into org.aspectj.ajde so you wont find it in
there.  The tests are very very simple.

> 2) I was looking at the class AjASTRewriteAnalyzer. This class only has
> public "visit" APIs and I am not too sure how can I use these to create
> AspectJ code. Unlike the jdt OldASTRewrite it does not have APIs like
> markAsInserted etc.

The AjASTRewriteAnalyzer is very basic - it needs all sorts of
development before it can be useful.  Ideally it should allow all the
same options as the JDT variant and the extra requirements needed for
working with pointcuts/etc.  I was hoping that whoever goes into the
brave new world of playing with the AJ AST could do some of that for
us ....

> 3) I looked at the example given in bug: 88861. The example takes a string
> representing an aspect and creates a compilation unit from it.
>
> I am thinking that is that the best way to create my aspects, i.e. I should
> put everything (all pointcuts/advices) in a string format and then call the
> AjNaiveASTFlattener.visit?

You should do whatever you'd do with the JDT and if there is
functionality missing the AJ case then it should be added.  Again,
only the very basics are in place, waiting for some helpful user to
fill in the gaps.

>
> Even in this case, I created the string:
>
> String source = "public aspect X {" +
>     "pointcut p(): call(* *(..));" +
>     "before():p() { c();}" +
>     "}";
> and passed it on, but the print out is only:
>
>
> public aspect X {
>  pointcut p():call(* *(..));
>  p{
>   c();
>  }
> }
> It did not print the advice signature at all.

It is called the Naive flattener because it isn't very smart, it is
only very basically working to support some very simple testcases.  A
smarter visitor would print out more.

I only put in the very very very basics of the AST for 1.5.0 - we
don't have any time to work on the AST support but I wanted it to be
enough that a user could contribute back enhancements to fill in the
details.  I'm sorry you are the first to find the limitations of its
current form...

Andy.


Back to the top