These pages is meant to aid people building hardware to extend or work with AJDT/AspectJ. Be sure to donate to this page with any pertinent info, such as for instance example rule making use of the AJDT and/or AspectJ APIs.
These pages is beyond time. Our intention would be to update these pages for AJDT 1.6.1, but we’ve not got energy because of this yet. Please recognize that the what is on this subject webpage might no lengthier end up being appropriate. If you have questions, please send them to the subscriber list ajdt-dev.
Articles
- 1 buying crosscutting connection suggestions from AJDT
- 2 Compilation Models in AJDT
- 2.1 having the belongings in an AJCompilationUnit
- 3 utilising the AspectJ AST parser
- 4 recognized limits, bugs, and exceptional issues
- 5 The screen gear are required to utilize to get the AspectJ compiler
Getting crosscutting commitment info from AJDT
If you should be creating an eclipse plug-in and require usage of crosscutting information whenever a venture is built, you can register 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. Inside the org.eclipse.ajdt.core plug-in you will find an IAdviceChangedListener program with an individual adviceChanged() means.
Register this using the AJBuilder class such as this (in your plug-in’s start() means for sample):
Currently (AJDT 1.6) this might be labeled as after each build of an AspectJ task (in other words. every *potential* suggestions change). In a future production this may be enhanced to-be merely called in the event that suggestions possess actually changed. AJDT/UI uses this process to update the tangerine arrow image decorator.
Crosscutting suggestions can then be obtained from the AJProjectModelFacade course. Here is an illustration with a few pseudo code you are able to adapt:
A few notes about it:
- The API might have some minor alterations in the future. Kindly deliver an email on ajdt-dev email list if nothing about this webpage is out of time.
- The AJProjectModelFacade item is a lightweight entry to the AspectJ business. It is simply appropriate before next create. Therefore, do not keep all of them. Use them and dispose as needed.
- AJProjectModelFacade objects merely contain facts after the first effective create. You’ll be able to name the hasModel() way to see if an AspectJ unit is out there for your task.
- Perhaps you have realized, you receive the partnership in directions. See AJRelationshipManager for your complete variety of connections, to help you merely ask for the connection types you have in mind.
- IRelationship.getSourceHandle() and IRelationship.getgoals() return Strings that express AspectJ component manages. You are able to this amazing AJProjectModelFacade strategies to become model elements:
- dating for seniors
- toProgramElement(sequence) — comes back IProgramElement. From here you can get information on the pointcut, intertype element, or declare element.
- programElementToJavaElement(sequence) or programElementToJavaElement(IProgramElement) — comes back IJavaElement. From here it is possible to connect into JDT tooling.
- There isn’t any criteria to register a suggestions changed listener. You can acquire use of the crosscutting model whenever you want (if the project has experienced an effective build) utilising the next laws:
Compilation Units in AJDT
JDT brings compilation models (cases of ICompilationproduct) for .java documents. AJDT produces collection units for .aj files, that are cases of AJCompilationUnit (which implements ICompilationUnit). The course AJCompilationUnitManager (inside org.eclipse.ajdt.core plug-in) contains some helpful strategies relating to this, like:
From an AJCompilationUnit you can easily receive different architectural facts such as getAllTypes(). The primary sort for “.aj” data files is typically an element, basically represented because of the AspectElement lessons, containing aspect-specific means such getPointcuts() and getAdvice(). These return more aspect-specific elements such PointcutElement and AdviceElement.
Since AJDT 1.6.2 for Eclispe 3.4, we use the Eclipse weaving solution to incorporate into JDT. One group of join things being guided are the ones related to the development of CompilationUnit objects. If document provides is actually *.aj file, AJCompilationUnit is established rather than a regular Java collectionUnit.
Acquiring the belongings in an AJCompilationUnit
Because JDT wants that most provider it really works with holds true Java code, JDT can not work well with AspectJ. In order to get surrounding this, AJCompilationUnits preserve two buffers that have origin items. The first is a java suitable buffer and 2nd could be the initial content buffer. The java compatible buffer will be the buffer that will be returned automagically whenever AJCompilationUnit.getContents() is named. This buffer offers the AspectJ signal with all of aspect-specific syntax stripped on. The first material buffer includes (because would count on) the original content from the document.
Including when the original content buffer looks like:
the coffee appropriate buffer becomes
Observe that the source areas regarding the identifiers are the same in buffers. This makes sure that reference finding and hyperlinking work as expected.
Should you call for using the first contents of an AspectJ CompilationUnit ajproduct, can help you the following:
Just what this technique do requests the AJCU to temporarily turn the buffer to your AJ buffer from Java buffer. It is best to repeat this in a synchronized block so that you don’t chance more posts coming by and inadvertently using the incorrect buffer (AJDT itself does not make use of a synchronized block because of this, but it should).
Utilising the AspectJ AST parser
Simple sample, obtained from insect 88861
Make the above mentioned and work it:
Understood limitations, insects, and exceptional issues
Limitation: Discover presently no AST service for solving type bindings: bug 146528