This page is intended to aid anyone developing tools to extend or work with AJDT/AspectJ. Please contribute to this page with any relevant information, such as example code using the AJDT and/or AspectJ APIs.

This page is intended to aid anyone developing tools to extend or work with AJDT/AspectJ. Please contribute to this page with any relevant information, such as example code using the AJDT and/or AspectJ APIs.

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

+

Compile the above and run it:

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

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

Line 99:

Line 99:

Limitation: There is currently no AST support for resolving type bindings:

Limitation: There is currently no AST support for resolving type bindings:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=146528

https://bugs.eclipse.org/bugs/show_bug.cgi?id=146528

+

----

----

Line 105:

Line 106:

----

----

+

----

----

Revision as of 12:06, 4 January 2007

This page is intended to aid anyone developing tools to extend or work with AJDT/AspectJ. Please contribute to this page with any relevant information, such as example code using the AJDT and/or AspectJ APIs.

Contents

Obtaining crosscutting relationship information from AJDT

(the following is derived from a post to the AJDT newsgroup on 26/10/2006)

If you're developing an eclipse plugin and require access to crosscutting information whenever a project is built, you can register a listener with AJDT.
Your plug-in will need to depend on org.eclipse.ajdt.core, org.eclipse.core.resources and org.eclipse.jdt.core. In the org.eclipse.ajdt.core plug-in there is an IAdviceChangedListener interface with a single adviceChanged() method.

Register this with the AJBuilder class like this (in your plug-in's start() method for example):

AJBuilder.addAdviceListener(new MyAdviceListener());

Currently (AJDT 1.4) this is called after every build of an AspectJ project (i.e. every *potential* advice change). In a future release this may be optimized to be only called if the advice has actually changed. AJDT/UI uses this mechanism to update the orange arrow image decorator.

Crosscutting information can then be obtained from the AJModel class. Here's an example:

build detected for project: P/TJP Example
Relationship: around advises main
Relationship: around advises foo
Relationship: around advises bar
Relationship: bar advised by around
Relationship: foo advised by around
Relationship: main advised by around

As you can see, you get the relationship in both directions. See AJRelationshipManager for the full list of relationships, so you can just ask for the relationship types you're interested in.

AJRelationship.getSource() and getTarget() return instances of IJavaElement so you can obtain further information from that, such as the parent or underlying resource.