This site is meant to help people developing gear to increase or assist AJDT/AspectJ. Please subscribe to this site with any related information, like sample rule making use of the AJDT and/or AspectJ APIs.
This site is beyond big date. Our intention would be to revise this site for AJDT 1.6.1, but there is perhaps not had opportunity with this yet. Be sure to recognize that a few of what’s about this web page may no much longer getting proper. When you yourself have any questions, kindly deliver them to the mailing list ajdt-dev.
Information
- 1 buying crosscutting relationship facts from AJDT
- 2 Collection Products in AJDT
- 2.1 Getting the belongings in an AJCompilationUnit
- 3 by using the AspectJ AST parser
- 4 Known limitations, insects, and outstanding issues
- 5 The interface gear are expected to utilize to get the AspectJ compiler
Acquiring crosscutting connection records from AJDT
If you are creating an eclipse plugin and call for the means to access crosscutting details whenever a project is created, you can easily sign up a listener with AJDT. Their plug-in should depend on org.eclipse.ajdt.core, org.eclipse.core.resources and org.eclipse.jdt.core, and org.aspectj.weaver. For the org.eclipse.ajdt.core plug-in there is an IAdviceChangedListener screen with one adviceChanged() means.
Enroll this making use of the AJBuilder lessons like this (in your plug-in’s start() way of sample):
Presently (AJDT 1.6) this is certainly known as after every create of an AspectJ job (i.e. every *potential* recommendations changes). In another launch this may be optimized as best labeled as when the suggestions have in fact altered. AJDT/UI uses this procedure to modify the orange arrow image decorator.
Crosscutting suggestions may then getting extracted from the AJProjectModelFacade lessons. Here’s an illustration which includes pseudo code you’ll adjust:
A few notes about any of it:
- The API could have some lesser changes in the long term. Kindly submit a message into ajdt-dev email list if anything about this webpage is beyond go out.
- The AJProjectModelFacade object try a lightweight entrances inside AspectJ globe. It can be good until the further acquire. Therefore, don’t shop all of them. Use them and dispose as required.
- AJProjectModelFacade stuff merely include information following basic effective acquire. You’ll be able to call the hasModel() approach to find out if an AspectJ design exists for task.
- Perhaps you have realized, you obtain the connection in both information. Read AJRelationshipManager when it comes to complete selection of relations, so you’re able to just inquire about the relationship sort you find attractive.
- IRelationship.getSourceHandle() and IRelationship.getTargets() return Strings that signify AspectJ element handles. You can utilize the subsequent AJProjectModelFacade ways to become model items:
- toProgramElement(String) — profits IProgramElement. From here it is possible to obtain information regarding the pointcut, intertype element, or declare factor.
- programElementToJavaElement(sequence) or programElementToJavaElement(IProgramElement) — returns IJavaElement. From this point you’ll connect into JDT tooling.
- There’s no needs to join up a pointers altered listener. You could get accessibility the crosscutting product whenever you want (provided that the project has already established a successful create) with the next code:
Collection Units in AJDT
JDT creates compilation devices (instances of ICompilationdevice) for .java data. AJDT creates compilation units for .aj data, which are instances of AJCompilationUnit (which implements ICompilationproduct). The category AJCompilationUnitManager (during the org.eclipse.ajdt.core plug-in) contains some helpful techniques concerning this, such:
From an AJCompilationUnit you’ll acquire different structural details eg getAllTypes(). The primary means for “.aj” records is normally an aspect, in fact it is symbolized because of the AspectElement course, which contains aspect-specific means instance getPointcuts() and getAdvice(). These return further aspect-specific items like PointcutElement and AdviceElement.
Since AJDT 1.6.2 for Eclispe 3.4, we make use of the Eclipse weaving solution to weave into JDT. One pair of join points that are urged are those connected with the production of CompilationUnit objects. When the document enjoys is actually *.aj file, AJCompilationUnit is made versus a regular Java Compilationdevice.
Obtaining the contents of an AJCompilationUnit
Because JDT wants that all resource it works with does work Java rule, JDT does not work well with AspectJ. To get around this, AJCompilationUnits manage two buffers that have resource items. The very first is a java suitable buffer and also the second could be the original content material buffer. The coffee appropriate buffer is the buffer that is came back automagically whenever AJCompilationUnit.getContents() is known as. This buffer contains the AspectJ code along with aspect-specific syntax stripped out. The original information buffer consists of (whilst would expect) the original content of file.
As an example in the event the initial information buffer appears to be:
the coffee suitable buffer becomes
Realize that the origin locations associated with the identifiers are identical in buffers. This ensures that guide researching and hyperlinking performs not surprisingly.
Should you decide need working with the original contents of an AspectJ CompilationUnit ajdevice, can be done the following:
What this method does wants the AJCU to briefly change their buffer to your AJ buffer from Java buffer. It’s always best to do that in a synchronized block to make sure you you should not risk other threads coming by and inadvertently making use of the incorrect buffer (AJDT alone doesn’t need a synchronized block with this, however it should).
Utilizing the AspectJ AST parser
Important sample, taken from bug 88861
Gather the above and operate they:
Identified limits, insects, and exceptional issues
Restriction: there’s presently no AST help beetalk for solving means bindings: bug 146528