Creator’s guide to building resources over AJDT and AspectJ

Creator’s guide to building resources over AJDT and AspectJ

This site is intended to aid anyone developing gear to increase or assist AJDT/AspectJ. Kindly subscribe to this site with any pertinent ideas, eg example rule using the AJDT and/or AspectJ APIs.

These pages is beyond big date. Our intent would be to modify these pages for AJDT 1.6.1, but there is perhaps not got opportunity for this yet. Be sure to understand that the what exactly is on this page may no longer be correct. For those who have questions, kindly deliver them to the subscriber list ajdt-dev.

Information

  • 1 buying crosscutting partnership suggestions from AJDT
  • 2 Compilation Units in AJDT
    • 2.1 Getting the items in an AJCompilationUnit
  • 3 Using the AspectJ AST parser
  • 4 recognized limits, insects, and outstanding issues
  • 5 The interface hardware are expected to use to get the AspectJ compiler

Getting crosscutting commitment information from AJDT

If you should be establishing an eclipse plug-in and call for the means to access crosscutting suggestions whenever a task is built, you’ll be able to sign up a listener with AJDT. Your own plug-in should depend on org.eclipse.ajdt.core, org.eclipse.core.resources and org.eclipse.jdt.core, and org.aspectj.weaver. During the org.eclipse.ajdt.core plug-in there is an IAdviceChangedListener software with an individual adviceChanged() process.

Join this because of the AJBuilder course like this (in your plug-in’s start() way of example):

At this time (AJDT 1.6) this will be known as after each and every build of an AspectJ job (for example. every *potential* information modification). In a future launch this can be optimized getting merely called if the information provides really altered. AJDT/UI makes use of this apparatus to revise the lime arrow picture decorator.

Crosscutting suggestions may then become extracted from the AJProjectModelFacade lessons. Discover an example which includes pseudo-code you can adjust:

Several notes about this:

  1. The API possess some lesser alterations in the long run. Kindly send a message to your ajdt-dev subscriber list if everything with this web page is out of big date.
  2. The AJProjectModelFacade object is a lightweight access into the AspectJ community. It can be good up until the further develop. Thus, don’t save all of them. Use them and dispose as needed.
  3. AJProjectModelFacade stuff merely contain information following very first profitable develop. It is possible to name the possessModel() method to see if an AspectJ model exists for all the venture.
  4. Clearly, you obtain the partnership in both directions. Read AJRelationshipManager for your full a number of interactions, so you can simply ask for the connection sort you have in mind.
  5. IRelationship.getSourceHandle() and IRelationship.getTargets() return chain that express AspectJ aspect handles. You are able to the subsequent AJProjectModelFacade techniques to convert to model areas:
    • toProgramElement(String) — returns IProgramElement. From this point you’ll acquire information about the pointcut, intertype component, or declare factor.
    • programElementToJavaElement(String) or programElementToJavaElement(IProgramElement) — profits IJavaElement. From here you can easily connect into JDT tooling.
  6. There’s no criteria to register a recommendations altered listener. You will get the means to access the crosscutting product whenever you want (if your panels has had an effective acquire) making use of the following laws:

Compilation Units in AJDT

JDT creates compilation devices (instances of ICompilationUnit) for .java data. AJDT brings collection models for .aj data files, that are cases of AJCompilationUnit (which implements ICompilationUnit). The category AJCompilationUnitManager (when you look at the org.eclipse.ajdt.core plug-in) includes some of good use practices with this, such as for instance:

From an AJCompilationUnit it is possible to get numerous structural info such getAllTypes(). The main type for “.aj” documents is usually an aspect, which can be displayed by the AspectElement lessons, which contains aspect-specific means such as for example getPointcuts() and getAdvice(). These return further aspect-specific items such as PointcutElement and AdviceElement.

Since AJDT 1.6.2 for Eclispe 3.4, we make use of the Eclipse weaving services to incorporate into JDT. One group of join points which can be instructed are those related to the production of CompilationUnit things. If the file enjoys are *.aj document, AJCompilationUnit is done in the place of a standard coffee collectiondevice.

Acquiring the items in an AJCompilationUnit

Because JDT expects that datingranking.net sugar daddy in usa all provider it functions with holds true coffee code, JDT doesn’t work well with AspectJ. To get around this, AJCompilationUnits manage two buffers which contain resource contents. The very first is a java appropriate buffer while the second may be the earliest content material buffer. The java suitable buffer could be the buffer that’s came back automagically when AJCompilationUnit.getContents() is named. This buffer offers the AspectJ laws along with aspect-specific syntax stripped aside. The first information buffer contains (whenever would expect) the first material with the document.

As an example in the event that initial contents buffer seems like:

the Java appropriate buffer becomes

Realize that the source places on the identifiers are exactly the same in both buffers. This makes sure that resource getting and hyperlinking work not surprisingly.

Any time you require dealing with the original content material of an AspectJ CompilationUnit ajUnit, can be done the following:

Just what this process does requests for the AJCU to briefly turn the buffer on the AJ buffer from the coffee buffer. It’s always best to repeat this in a synchronized block so that you will you should not chance more threads coming by and inadvertently making use of the wrong buffer (AJDT by itself doesn’t incorporate a synchronized block because of this, nonetheless it should).

Utilizing the AspectJ AST parser

Simple instance, taken from insect 88861

Compile the above mentioned and manage it:

Recognized restrictions, insects, and outstanding problem

Restriction: There is currently no AST service for solving kind bindings: bug 146528