Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Fwd: [ajdt-dev] AJModel - Getting details about PointcutElement, AdviceElement and DeclareElements

Meant to send this to the whole mailing list:

Also, updated http://wiki.eclipse.org/Developer%27s_guide_to_building_tools_on_top_of_AJDT_and_AspectJ#Compilation_Units_in_AJDT
to reflect the comment below.

I am considering adding a method in AJCU that will return the original
contents when asked (rather than requiring the use of the code below).



---------- Forwarded message ----------
From: Andrew Eisenberg <andrew@xxxxxxxxxxxx>
Date: Sun, Apr 5, 2009 at 8:36 AM
Subject: Re: [ajdt-dev] AJModel - Getting details about
PointcutElement, AdviceElement and DeclareElements
To: André Fonseca <deco.af@xxxxxxxxx>


Actually, this is the expected behavior.  In order for JDT to not barf
when it sees AspectJ code, we have to trick it into thinking it is
some kind of Java code.  This means stripping out all non-Java syntax.

You can temporarily request the original AspectJ content if you can
get a handle on the AJCompilationUnit object:

char[] contents;
synchronized(ajUnit) {
   ajUnit.requestOriginalContentMode();
   contents = ajUnit.getContents();
   ajUnit.discardOriginalContentMode();  // be sure to call this
method as soon as you are done.
}

What this method does asks for the AJCU to temporarily switch its
buffer to the AJ buffer from the Java buffer.  Best to do this in a
synchronized block so that you don't risk other threads coming by and
accidentally using the wrong buffer (AJDT itself doesn't use a
synchronized block for this, but it should).

If you can tell me exactly what you want to do, I might be able to
give you some advice on how to go about it.  And you are welcome to
submit a patch for any implementation that you come up with.

--a


On Sun, Apr 5, 2009 at 8:22 AM, André Fonseca <deco.af@xxxxxxxxx> wrote:
> Ex: If I cast pointcutElement to ISourceElement and try to call the method
> getSource of the pointcut:
>
> pointcut goCut(): cflow(this(Demo) && execution(void go()));
>
> i will receive the string:
>
> pointcut
> goCut()                                                              ;
>


Back to the top