This site is meant to help anybody establishing apparatus to extend or use AJDT/AspectJ. Kindly subscribe to this site with any relevant suggestions, including sample laws utilising the AJDT and/or AspectJ APIs.
This page may be out of go out. Our intention is to revise these pages for AJDT 1.6.1, but we now have maybe not got energy because of this yet. Please recognize that a few of understanding on this page may no lengthier end up being correct. If you have any questions, kindly submit these to the email list ajdt-dev.
Materials
- 1 Obtaining crosscutting union details from AJDT
- 2 Compilation Products in AJDT
- 2.1 Acquiring the belongings in an AJCompilationUnit
- 3 utilizing the AspectJ AST parser
- 4 Known restrictions, insects, and outstanding dilemmas
- 5 The program knowledge are anticipated to utilize to push the AspectJ compiler
Acquiring crosscutting commitment info from AJDT
If you’re building an eclipse plugin and need the means to access crosscutting details whenever a task is created, you’ll be able to register a listener with AJDT. Your plug-in will have to depend on org.eclipse.ajdt.core, org.eclipse.core.resources and org.eclipse.jdt.core, and org.aspectj.weaver. Into the org.eclipse.ajdt.core plug-in there can be an IAdviceChangedListener user interface with just one adviceChanged() technique.
Enroll this making use of AJBuilder class in this feeld way (inside plug-in’s start() way for sample):
Presently (AJDT 1.6) this can be known as after every acquire of an AspectJ task (in other words. every *potential* advice modification). In a future release this might be enhanced as just labeled as if pointers features really altered. AJDT/UI utilizes this mechanism to update the tangerine arrow graphics decorator.
Crosscutting facts may then end up being obtained from the AJProjectModelFacade course. Listed here is an illustration with many pseudo code possible adjust:
A number of records about any of it:
- The API might have some lesser alterations in the long term. Kindly deliver a message towards the ajdt-dev email list if anything with this webpage is out of date.
- The AJProjectModelFacade object is a light entry in to the AspectJ business. It can be legitimate till the then create. So, don’t store all of them. Utilize them and dispose as required.
- AJProjectModelFacade objects merely have information following the basic profitable create. You are able to contact the hasModel() approach to see if an AspectJ unit is out there for all the venture.
- As you can see, you get the connection both in information. Discover AJRelationshipManager for the complete list of relationships, so you can merely request the relationship types you’re interested in.
- IRelationship.getSourceHandle() and IRelationship.getgoals() return Strings that express AspectJ aspect manages. You need the next AJProjectModelFacade methods to become model factors:
- toProgramElement(String) — comes back IProgramElement. From this point you’ll receive information on the pointcut, intertype factor, or declare component.
- programElementToJavaElement(sequence) or programElementToJavaElement(IProgramElement) — profits IJavaElement. From here you can hook into JDT tooling.
- There’s absolutely no prerequisite to join up an information altered listener. You will get use of the crosscutting unit anytime (provided that the project has received an effective develop) utilising the preceding signal:
Collection Devices in AJDT
JDT brings collection models (cases of ICompilationproduct) for .java documents. AJDT produces compilation products for .aj records, which are instances of AJCompilationUnit (which implements ICompilationproduct). The class AJCompilationUnitManager (inside the org.eclipse.ajdt.core plug-in) consists of some helpful methods relating to this, particularly:
From an AJCompilationUnit you can easily receive numerous structural suggestions instance getAllTypes(). The principal kind for «.aj» documents is normally an element, and that’s displayed by AspectElement class, containing aspect-specific techniques such as for instance getPointcuts() and getAdvice(). These return furthermore aspect-specific elements including PointcutElement and AdviceElement.
Since AJDT 1.6.2 for Eclispe 3.4, we use the Eclipse weaving services to weave into JDT. One group of join things which are suggested are the ones about the development of CompilationUnit stuff. If the file keeps is actually *.aj file, AJCompilationUnit is generated versus a standard Java Compilationproduct.
Getting the items in an AJCompilationUnit
Because JDT wants that supply it works with holds true Java rule, JDT does not work well with AspectJ. In order to get surrounding this, AJCompilationUnits maintain two buffers which contain source information. The first is a java suitable buffer and the second is the earliest information buffer. The coffee appropriate buffer is the buffer that will be returned automagically whenever AJCompilationUnit.getContents() is known as. This buffer contains the AspectJ signal with aspect-specific syntax removed
For example if the initial material buffer looks like:
the coffee appropriate buffer becomes
Notice that the foundation places of the identifiers are exactly the same both in buffers. This makes sure that reference receiving and hyperlinking functions not surprisingly.
Any time you call for using the initial material of an AspectJ CompilationUnit ajUnit, you are able to do the following:
What this process really does requests the AJCU to temporarily change their buffer toward AJ buffer from coffee buffer. It is advisable to repeat this in a synchronized block so that you will you should not risk other posts coming by and accidentally utilising the wrong buffer (AJDT alone doesn’t make use of a synchronized block for this, however it should).
Using the AspectJ AST parser
Fundamental example, extracted from bug 88861
Gather the aforementioned and work they:
Identified restrictions, insects, and outstanding dilemmas
Limitation: there is certainly presently no AST support for resolving type bindings: insect 146528