This page is intended to help anyone developing resources to increase or assist AJDT/AspectJ. Please contribute to these pages with any appropriate information, instance sample code using the AJDT and/or AspectJ APIs.
These pages is beyond time. The purpose is update this page for AJDT 1.6.1, but we maybe not got times because of this yet. Be sure to realize that a few of understanding about webpage may no much longer end up being appropriate. For those who have questions, please send them to the email list ajdt-dev.
- 1 buying crosscutting union details from AJDT
- 2 Compilation Products in AJDT
- 2.1 Getting the contents of an AJCompilationUnit
- 3 by using the AspectJ AST parser
- 4 recognized limitations, pests, and outstanding problems
- 5 The user interface hardware are required to use to drive the AspectJ compiler
Obtaining crosscutting commitment details from AJDT
If you should be establishing an eclipse plug-in and require usage of crosscutting suggestions whenever a task is made, you are able to subscribe a listener with AJDT. Their plug-in will need to depend 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 there was an IAdviceChangedListener software with just one adviceChanged() method.
Enter this because of the AJBuilder class along these lines (inside plug-in’s start() means for sample):
Currently (AJDT 1 wellhello telefonnÃ ÄÃslo.6) it is known as after every acquire of an AspectJ job (in other words. every *potential* recommendations change). In another production this might be enhanced getting only labeled as if the information have really altered. AJDT/UI uses this mechanism to update the orange arrow picture decorator.
Crosscutting information are able to getting obtained from the AJProjectModelFacade lessons. Here is an illustration with many pseudo code it is possible to adapt:
Several notes about any of it:
- The API may have some small changes in the long run. Be sure to submit a message with the ajdt-dev mailing list if nothing about this web page is out of go out.
- The AJProjectModelFacade item is a light entry into the AspectJ industry. It can be valid through to the next acquire. Therefore, don’t shop them. Make use of them and dispose as required.
- AJProjectModelFacade stuff merely have information following the basic effective build. You are able to name the hasModel() approach to see if an AspectJ unit is out there for your project.
- Perhaps you have realized, you receive the partnership in directions. Discover AJRelationshipManager for the full set of relationships, in order to simply require the partnership sort you find attractive.
- IRelationship.getSourceHandle() and IRelationship.getobjectives() return Strings that represent AspectJ factor handles. You need to use the next AJProjectModelFacade strategies to convert to model characteristics:
- toProgramElement(String) — comes back IProgramElement. From this point you are able to get information about the pointcut, intertype component, or declare aspect.
- programElementToJavaElement(sequence) or programElementToJavaElement(IProgramElement) — profits IJavaElement. From this point you can connect into JDT tooling.
- There is absolutely no need to register a guidance altered listener. You can acquire entry to the crosscutting design anytime (if your panels has had an effective create) by using the preceding code:
Compilation Products in AJDT
JDT produces compilation models (cases of ICompilationdevice) for .java files. AJDT brings collection units for .aj data files, which have been cases of AJCompilationUnit (which implements ICompilationproduct). The course AJCompilationUnitManager (for the org.eclipse.ajdt.core plug-in) has some useful means relating to this, including:
From an AJCompilationUnit you can receive numerous architectural facts instance getAllTypes(). The primary means for “.aj” documents is normally a piece, that’s symbolized by AspectElement course, containing aspect-specific techniques eg getPointcuts() and getAdvice(). These return furthermore aspect-specific elements such PointcutElement and AdviceElement.
Since AJDT 1.6.2 for Eclispe 3.4, we make use of the Eclipse weaving provider to incorporate into JDT. One pair of join points being recommended are those associated with the development of CompilationUnit objects. If the document keeps is *.aj document, AJCompilationUnit is established instead of a general Java collectionproduct.
Obtaining the belongings in an AJCompilationUnit
Because JDT wants that all supply it really works with does work Java code, JDT does not work well with AspectJ. In order to get surrounding this, AJCompilationUnits maintain two buffers which contain provider articles. The very first is a java appropriate buffer and also the second may be the earliest articles buffer. The coffee appropriate buffer will be the buffer that is came back automagically whenever AJCompilationUnit.getContents() is named. This buffer offers the AspectJ signal with aspect-specific syntax stripped away. The first information buffer includes (as you would expect) the original material in the document.
For example if the original contents buffer appears to be:
the Java compatible buffer becomes
Observe that the foundation stores for the identifiers are the same both in buffers. This ensures that research acquiring and hyperlinking work as expected.
If you call for dealing with the first information of an AspectJ CompilationUnit ajproduct, can help you the following:
Just what this method does requests the AJCU to briefly turn their buffer toward AJ buffer through the Java buffer. It’s always best to do this in a synchronized block to make sure you you should not exposure different posts coming by and accidentally using the incorrect buffer (AJDT by itself does not make use of a synchronized block because of this, it should).
Making use of the AspectJ AST parser
Practical sample, extracted from bug 88861
Make these and run they:
Recognized restrictions, pests, and outstanding problem
Restriction: there was presently no AST assistance for solving sort bindings: bug 146528