These pages is meant to help anybody creating knowledge to increase or deal with AJDT/AspectJ. Be sure to contribute to this site with any related records, such as for instance sample code with the AJDT and/or AspectJ APIs.
This page may be out of go out. The objective will be update this site for AJDT 1.6.1, but we not got times because of this yet. Be sure to recognize that a few of what’s about web page might no much longer become proper. When you have any queries, be sure to submit them to the mailing list ajdt-dev.
- 1 getting crosscutting relationship facts from AJDT
- 2 Compilation Products in AJDT
- 2.1 having the belongings in an AJCompilationUnit
- 3 with the AspectJ AST parser
- 4 Known limitations, pests, and exceptional dilemmas
- 5 The screen hardware are expected to use to push the AspectJ compiler
Acquiring crosscutting connection facts from AJDT
If you should be creating an eclipse plug-in and need the means to access crosscutting info whenever a job is created, possible subscribe a listener with AJDT. The plug-in will dating sites free need to rely on org.eclipse.ajdt.core, org.eclipse.core.resources and org.eclipse.jdt.core, and org.aspectj.weaver. In org.eclipse.ajdt.core plug-in there is certainly an IAdviceChangedListener user interface with an individual adviceChanged() means.
Register this using AJBuilder class in this way (inside plug-in’s start() method for example):
At this time (AJDT 1.6) it is labeled as after each acquire of an AspectJ task (for example. every *potential* pointers changes). In the next production this may be enhanced as only called when the advice features in fact altered. AJDT/UI uses this device to upgrade the tangerine arrow picture decorator.
Crosscutting ideas are able to feel obtained from the AJProjectModelFacade class. Listed here is a good example with a few pseudo-code you’ll adapt:
Several notes about it:
- The API might have some minor alterations in the near future. Kindly send an email into ajdt-dev email list if things about web page is out of date.
- The AJProjectModelFacade object try a lightweight entrances inside AspectJ globe. It is simply appropriate until the subsequent build. So, never keep them. Make use of them and dispose as required.
- AJProjectModelFacade objects best include information following the earliest winning develop. It is possible to phone the possessModel() method to see if an AspectJ unit is out there when it comes to task.
- As you care able to see, you will get the connection both in instructions. Read AJRelationshipManager when it comes down to complete list of relations, so you can merely require the relationship sort you have in mind.
- IRelationship.getSourceHandle() and IRelationship.getobjectives() return Strings that signify AspectJ component manages. You can use this amazing AJProjectModelFacade ways to become model aspects:
- toProgramElement(sequence) — profits IProgramElement. From here you can easily get details about the pointcut, intertype element, or declare component.
- programElementToJavaElement(sequence) or programElementToJavaElement(IProgramElement) — profits IJavaElement. From here you’ll be able to connect into JDT tooling.
- There is no needs to join up a guidance changed listener. You can acquire accessibility the crosscutting unit anytime (so long as your panels has received an effective build) utilizing the preceding laws:
Compilation Units in AJDT
JDT brings compilation units (instances of ICompilationdevice) for .java data. AJDT brings collection units for .aj data, that are cases of AJCompilationUnit (which implements ICompilationUnit). The category AJCompilationUnitManager (into the org.eclipse.ajdt.core plug-in) consists of some beneficial practices with this, such as for example:
From an AJCompilationUnit it is possible to receive numerous structural details instance getAllTypes(). The primary type for “.aj” data is normally an element, basically represented because of the AspectElement course, which contains aspect-specific means particularly getPointcuts() and getAdvice(). These return more aspect-specific characteristics for example PointcutElement and AdviceElement.
Since AJDT 1.6.2 for Eclispe 3.4, we use the Eclipse weaving solution to incorporate into JDT. One collection of join information which happen to be informed are those connected with the production of CompilationUnit objects. If the document enjoys is *.aj document, AJCompilationUnit is created in the place of a regular Java collectiondevice.
Having the belongings in an AJCompilationUnit
Because JDT anticipates that most provider it truly does work with is true coffee code, JDT does not work really with AspectJ. To get around this, AJCompilationUnits manage two buffers that have supply information. The very first is a java appropriate buffer plus the 2nd may be the initial material buffer. The coffee suitable buffer will be the buffer that will be came back automatically whenever AJCompilationUnit.getContents() is named. This buffer offers the AspectJ laws with aspect-specific syntax removed completely. The original material buffer has (while you would expect) the first material for the file.
As an example in the event the original contents buffer appears like:
the coffee compatible buffer is
Realize that the foundation areas in the identifiers are exactly the same in both buffers. This means that research researching and hyperlinking functions not surprisingly.
If you require dealing with the initial content of an AspectJ CompilationUnit ajdevice, you are able to do the annotated following:
Exactly what this technique really does requests for the AJCU to temporarily change their buffer to your AJ buffer from the Java buffer. It is best to do that in a synchronized block to make sure you cannot exposure other posts coming by and unintentionally using the wrong buffer (AJDT alone does not incorporate a synchronized block for this, nonetheless it should).
By using the AspectJ AST parser
Basic sample, extracted from insect 88861
Compile the above mentioned and work they:
Identified restrictions, bugs, and outstanding problem
Limitation: there is certainly at this time no AST help for resolving sort bindings: bug 146528