Designer’s guide to building equipment on top of AJDT and AspectJ

Designer’s guide to building equipment on top of AJDT and AspectJ

This site is intended to support people developing methods to give or make use of AJDT/AspectJ. Be sure to play a role in this page with any relevant facts, including instance rule utilising the AJDT and/or AspectJ APIs.

This site may be out of big date. Our very own purpose will be revise this site for AJDT 1.6.1, but there is not have time because of this yet. Kindly recognize that some of what’s on this webpage might no much longer https://datingranking.net/down-dating-review/ become correct. When you have questions, kindly deliver them to the mailing list ajdt-dev.

Articles

  • 1 buying crosscutting connection ideas from AJDT
  • 2 Compilation Devices in AJDT
    • 2.1 having the contents of an AJCompilationUnit
  • 3 with the AspectJ AST parser
  • 4 Known restrictions, bugs, and outstanding problems
  • 5 The user interface hardware are expected to utilize to get the AspectJ compiler

Getting crosscutting relationship info from AJDT

If you’re building an eclipse plug-in and require accessibility crosscutting details whenever a task is built, possible enter a listener with AJDT. Your own plug-in should rely on org.eclipse.ajdt.core, org.eclipse.core.resources and org.eclipse.jdt.core, and org.aspectj.weaver. Inside the org.eclipse.ajdt.core plug-in discover an IAdviceChangedListener user interface with an individual adviceChanged() way.

Join this making use of the AJBuilder class in this way (in your plug-in’s start() means for instance):

Currently (AJDT 1.6) this will be labeled as after each develop of an AspectJ venture (in other words. every *potential* pointers change). In the next launch this might be enhanced to get merely also known as if the suggestions have in fact altered. AJDT/UI makes use of this mechanism to modify the tangerine arrow image decorator.

Crosscutting records may then become obtained from the AJProjectModelFacade course. Discover an illustration with pseudo-code it is possible to adjust:

A number of notes concerning this:

  1. The API have some small changes in the long term. Please deliver an email for the ajdt-dev email list if such a thing on this subject page is beyond big date.
  2. The AJProjectModelFacade item try a light-weight entry inside AspectJ world. It is only legitimate before further acquire. Thus, you shouldn’t store them. Utilize them and dispose as needed.
  3. AJProjectModelFacade things best consist of data following the earliest profitable build. You’ll be able to name the possessModel() solution to find out if an AspectJ product is available your project.
  4. As you can see, you receive the connection in both guidelines. Discover AJRelationshipManager for full a number of relations, in order to just require the partnership types you are interested in.
  5. IRelationship.getSourceHandle() and IRelationship.getgoals() return Strings that express AspectJ aspect manages. You need to use this amazing AJProjectModelFacade solutions to convert to model items:
    • toProgramElement(sequence) — comes back IProgramElement. From here you can easily get information regarding the pointcut, intertype component, or declare aspect.
    • programElementToJavaElement(String) or programElementToJavaElement(IProgramElement) — profits IJavaElement. From here you are able to hook into JDT tooling.
  6. There is absolutely no prerequisite to join up a suggestions changed listener. You can aquire access to the crosscutting design anytime (provided that the project has already established a successful build) making use of the following rule:

Compilation Units in AJDT

JDT brings compilation devices (cases of ICompilationproduct) for .java files. AJDT brings compilation products for .aj data files, which have been instances of AJCompilationUnit (which implements ICompilationproduct). The class AJCompilationUnitManager (in the org.eclipse.ajdt.core plug-in) includes some beneficial means with this, instance:

From an AJCompilationUnit you can easily obtain different structural information including getAllTypes(). The main type for „.aj” data is usually an element, and is displayed of the AspectElement class, containing aspect-specific methods particularly getPointcuts() and getAdvice(). These return furthermore aspect-specific aspects like PointcutElement and AdviceElement.

Since AJDT 1.6.2 for Eclispe 3.4, we make use of the Eclipse weaving services to incorporate into JDT. One pair of join details which are informed are the ones linked to the development of CompilationUnit objects. If document have was *.aj file, AJCompilationUnit is made in the place of a regular coffee collectionproduct.

Obtaining the contents of an AJCompilationUnit

Because JDT needs that resource it truly does work with is true coffee laws, JDT does not work really with AspectJ. In order to get for this, AJCompilationUnits manage two buffers that have resource articles. The first is a java compatible buffer in addition to 2nd is the initial contents buffer. The java suitable buffer will be the buffer that will be came back automatically when AJCompilationUnit.getContents() is known as. This buffer provides the AspectJ signal with all aspect-specific syntax removed away. The original articles buffer consists of (when you would count on) the initial content with the file.

For example if the initial information buffer appears like:

the Java compatible buffer is

Notice that the source places from the identifiers are the same in both buffers. This means that resource researching and hyperlinking work as you expected.

If you need employing the first content material of an AspectJ CompilationUnit ajdevice, can help you the immediate following:

Just what this technique do wants the AJCU to temporarily change the buffer towards AJ buffer through the Java buffer. It is best to do that in a synchronized block to make sure you do not risk some other threads coming by and accidentally by using the completely wrong buffer (AJDT itself doesn’t incorporate a synchronized block for this, however it should).

With the AspectJ AST parser

Important sample, taken from bug 88861

Compile the above and manage they:

Recognized limitations, bugs, and outstanding problems

Constraint: there is certainly at this time no AST service for resolving kind bindings: insect 146528