This page is intended to support anybody establishing methods to give or utilize AJDT/AspectJ. Please subscribe to these pages with any related suggestions, eg example code making use of the AJDT and/or AspectJ APIs.
These pages is out of time. All of our intention should revise this site for AJDT 1.6.1, but we’ve maybe not have times because of this yet. Please keep in mind that a number of understanding about this web page might no longer getting appropriate. When you yourself have any questions, kindly deliver them to the mailing list ajdt-dev.
Contents
- 1 getting crosscutting connection details from AJDT
- 2 Collection Models in AJDT
- 2.1 having the items in an AJCompilationUnit
- 3 by using the AspectJ AST parser
- 4 Known limitations, insects, and exceptional issues
- 5 The program hardware are anticipated to use to push the AspectJ compiler
Acquiring crosscutting relationship info from AJDT
If you find yourself building an eclipse plugin and call for accessibility crosscutting details whenever a job is made, it is possible to enroll a listener with AJDT. Their plug-in will need to rely on org.eclipse.ajdt.core, org.eclipse.core.resources and org.eclipse.jdt.core, and org.aspectj.weaver. Within the org.eclipse.ajdt.core plug-in there can be an IAdviceChangedListener software with a single adviceChanged() process.
Enroll this because of the AJBuilder class like this (in your plug-in’s start() means for example):
Presently (AJDT 1.6) this is also known as after each develop of an AspectJ job (i.e. every *potential* guidance changes). In another launch this may be optimized become only labeled as if the information keeps actually altered. AJDT/UI makes use of this process to modify the lime arrow image decorator.
Crosscutting suggestions may then getting obtained from the AJProjectModelFacade course. Here is a good example with many pseudo code you are able to adapt:
A few notes about that:
- The API could have some lesser alterations in the near future. Please deliver an email on the ajdt-dev mailing list if such a thing on this web page may be out of big date.
- The AJProjectModelFacade object was a light access inside AspectJ community. It can be good before the after that develop. So, you should not save them. Use them and dispose as required.
- AJProjectModelFacade objects just contain information following first profitable develop. You can call the possessModel() method to find out if an AspectJ unit exists when it comes down to task.
- As you can tell, you can get the partnership both in information. Discover AJRelationshipManager when it comes to complete set of affairs, so you’re able to only require the relationship types you’re interested in.
- IRelationship.getSourceHandle() and IRelationship.getTargets() return Strings that portray AspectJ component handles. You can utilize listed here AJProjectModelFacade methods to convert to model characteristics:
- toProgramElement(String) — returns IProgramElement. From this point you’ll acquire details about the pointcut, intertype element, or declare component.
- programElementToJavaElement(String) or programElementToJavaElement(IProgramElement) — comes back IJavaElement. From here you can hook into JDT tooling.
- There’s absolutely no necessity to register an information changed listener. You may get usage of the crosscutting design whenever you want (provided that your panels has experienced a fruitful build) utilizing the following rule:
Collection Devices in AJDT
JDT creates compilation models (cases of ICompilationproduct) for .java data files. AJDT creates collection products for .aj data, which have been cases of AJCompilationUnit (which implements ICompilationproduct). The class AJCompilationUnitManager (when you look at the org.eclipse.ajdt.core plug-in) contains some useful methods with this, instance:
From an AJCompilationUnit you can easily acquire numerous structural ideas such as for example getAllTypes(). The principal means for “.aj” files is usually an aspect, which will be symbolized by AspectElement lessons, which contains aspect-specific strategies particularly getPointcuts() and getAdvice(). These return more aspect-specific details eg PointcutElement and AdviceElement.
Since AJDT 1.6.2 for Eclispe 3.4, we utilize the Eclipse weaving provider to weave into JDT. One group of join guidelines being instructed are those related to the development of CompilationUnit objects. If file keeps try *.aj document, AJCompilationUnit is created instead of a general coffee Compilationdevice.
Obtaining the contents of an AJCompilationUnit
Because JDT anticipates that supply it really works with does work coffee signal, JDT can not work well with AspectJ. To get around this, AJCompilationUnits keep two buffers that contain provider materials. The very first is a java compatible buffer together with second could be the original material buffer. The java appropriate buffer will be the buffer which returned automatically whenever AJCompilationUnit.getContents() is called. This buffer provides the AspectJ signal with aspect-specific syntax stripped down. The initial contents buffer consists of (as you would anticipate) the original content material regarding the file.
Including if the initial content buffer looks like:
the coffee appropriate buffer becomes
Observe that the origin locations in the identifiers are the same in both buffers. This ensures that resource finding and hyperlinking really works as expected.
If you require using the services of the original material of an AspectJ CompilationUnit ajproduct, you are able to do the following:
Just what this technique really does requests for the AJCU to briefly turn the buffer on the AJ buffer from the coffee buffer. It is best to try this in a synchronized block so that you will do not chance more posts coming by and accidentally by using the wrong buffer (AJDT alone doesn’t incorporate a synchronized block with this
, however it should).
Using the AspectJ AST parser
Standard instance, taken from bug 88861
Make the above mentioned and work they:
Understood restrictions, insects, and exceptional issues
Restriction: there’s currently no AST service for solving means bindings: bug 146528