Creator’s help guide to developing apparatus over AJDT and AspectJ

Creator’s help guide to developing apparatus over AJDT and AspectJ

This page is intended to aid individuals building technology to extend or use AJDT/AspectJ. Please subscribe to this site with any relevant information, such sample code utilizing the AJDT and/or AspectJ APIs.

This page is out of big date. All of our goal will be update this site for AJDT 1.6.1, but we’ve got perhaps not have time for this yet. Kindly recognize that the what’s about webpage may no longer be appropriate. When you yourself have questions, be sure to send these to the mailing list ajdt-dev.

Materials

  • 1 getting crosscutting relationship records from AJDT
  • 2 Collection Units in AJDT
    • 2.1 having the belongings in an AJCompilationUnit
  • 3 utilizing the AspectJ AST parser
  • 4 recognized restrictions, insects, and outstanding issues
  • 5 The interface gear are expected to utilize to drive the AspectJ compiler

Obtaining crosscutting connection records from AJDT

In case you are developing an eclipse plug-in and need access to crosscutting facts whenever a project is created, you’ll enter a listener with AJDT. The plug-in should rely on org.eclipse.ajdt.core, org.eclipse.core.resources and org.eclipse.jdt.core, and org.aspectj.weaver. From inside the org.eclipse.ajdt.core plug-in discover an IAdviceChangedListener software with one adviceChanged() strategy.

Register this with the AJBuilder course like this (in your plug-in’s start() method for sample):

Currently (AJDT 1.6) this is certainly known as after each acquire of an AspectJ task (for example. every *potential* recommendations change). In a future production this might be optimized to be only labeled as in the event that advice features really altered. AJDT/UI utilizes this system to revise the tangerine arrow picture decorator.

Crosscutting ideas are able to end up being obtained from the AJProjectModelFacade course. Here’s an illustration with many pseudo code possible adjust:

Several records about any of it:

  1. The API possess some lesser alterations in the long term. Kindly submit an email on the ajdt-dev mailing list if everything on this subject webpage is beyond time.
  2. The AJProjectModelFacade object are a lightweight entry in to the AspectJ community. It is simply appropriate before further acquire. Thus, you shouldn’t put them. Use them and dispose as required.
  3. AJProjectModelFacade items merely incorporate information following basic effective build. You are able to phone the hasModel() solution to find out if an AspectJ product is available for project.
  4. Clearly, you will get the partnership in both guidelines. Discover AJRelationshipManager for full directory of connections, in order to only inquire about the relationship types you are interested in.
  5. IRelationship.getSourceHandle() and IRelationship.getgoals() return Strings that signify AspectJ component handles. You need to use listed here AJProjectModelFacade solutions to convert to model items:
    • toProgramElement(sequence) — returns IProgramElement. From this point it is possible to receive details about the pointcut, intertype component, or declare aspect.
    • programElementToJavaElement(sequence) or programElementToJavaElement(IProgramElement) — comes back IJavaElement. From here it is possible to connect into JDT tooling.
  6. There’s absolutely no requirement to register a suggestions changed listener. You can acquire usage of the crosscutting product anytime (providing the project has already established a successful acquire) utilising the preceding code:

Collection Units in AJDT

JDT creates compilation models (instances of ICompilationdevice) for .java records. AJDT creates compilation models for .aj records, that are cases of AJCompilationUnit (which implements ICompilationdevice). The class AJCompilationUnitManager (during the org.eclipse.ajdt.core plug-in) includes some helpful means with this, instance:

From an AJCompilationUnit you’ll acquire various structural information instance getAllTypes(). The primary kind for «.aj» data files is usually an aspect, that’s displayed because of the AspectElement course, containing aspect-specific strategies eg getPointcuts() and getAdvice(). These return furthermore aspect-specific items eg PointcutElement and AdviceElement.

Since AJDT 1.6.2 for Eclispe 3.4 compatible partners, we make use of the Eclipse weaving solution to weave into JDT. One set of join information which can be recommended are those related to the development of CompilationUnit stuff. In the event the file enjoys is *.aj document, AJCompilationUnit is created in the place of a general coffee collectionproduct.

Getting the belongings in an AJCompilationUnit

Because JDT expects that most supply it functions with does work Java signal, JDT does not work well with AspectJ. To get around this, AJCompilationUnits manage two buffers which contain supply articles. The first is a java appropriate buffer in addition to 2nd could be the initial content material buffer. The coffee suitable buffer will be the buffer this is certainly returned automagically whenever AJCompilationUnit.getContents() is named. This buffer contains the AspectJ laws with all of aspect-specific syntax removed completely. The original content material buffer includes (whenever would count on) the original information in the file.

Eg in the event the original contents buffer appears like:

the coffee compatible buffer is

Notice that the source areas on the identifiers are exactly the same both in buffers. This means that guide searching and hyperlinking functions not surprisingly.

Any time you need using the original material of an AspectJ CompilationUnit ajdevice, can help you the annotated following:

What this technique do wants the AJCU to briefly switch their buffer for the AJ buffer from the coffee buffer. It is advisable to try this in a synchronized block so that you you should not risk various other posts coming by and unintentionally with the wrong buffer (AJDT alone doesn’t use a synchronized block because of this, nevertheless should).

With the AspectJ AST parser

Simple sample, taken from bug 88861

Make the above mentioned and operated they:

Understood limitations, bugs, and exceptional problems

Restriction: there’s presently no AST support for solving kind bindings: insect 146528

Dejar un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *