Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] [ajdt core] !!!


Hi Alex,

You say you're interested in AspectJ elements from an open editor, so I assume you're doing all this from an eclipse plugin. In which case you can use the AJDT structures instead of the AspectJ compiler ones. AJDT defines a number of classes which implement IJavaElement, such as AdviceElement, PointcutElement, DeclareElement etc. Here is a CVS link to AspectElement:

http://dev.eclipse.org/viewcvs/indextech.cgi/org.eclipse.ajdt/AJDT1.2src/org.eclipse.ajdt.core/src/org/eclipse/ajdt/core/javaelements/AspectElement.java?rev=HEAD&content-type=text/vnd.viewcvs-markup

These elements are contained in AJCompilationUnits instead of JDT CompilationUnits, and it's very important to note that they are only created when AspectJ syntax is contained in .aj files (as JDT handles .java files and we don't get a look-in).

You should able to get hold of the AJCompilationUnit in the same way as for CompilationUnits, or you can get one directly from an IFile using AJCompilationUnitManager.getAJCompilationUnit(file).

Hope that helps,

Matt.

--
Matt Chapman, mchapman@xxxxxxxxxx
AJDT Development, http://www.eclipse.org/ajdt

Alex Vasc <altvex@xxxxxxxxx> wrote on 27/05/2005 16:43:06:

> Thanks everybody for the patience, but I´m still having problems
> with ajdt core.
> I´ve got a strange exception:
>
> //-----------------------
> Unhandled event loop exception
> Reason: org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration
> //-----------------------
>
> I´ve tried to get an aspect inside a .java using something like this:
>
> //-----------------------
> Iterator itTypes = cu.types().iterator();
> while(itTypes.hasNext()) {
>    Object o = itTypes.next();
>    if(o instanceof AspectDeclaration) {
>       MessageDialog.openInformation(null, null,"OK!");
>    }
> }
> //-----------------------
>
> where cu is a CompilationUnit and the .java where the plugin runs is:
>
> //-----------------------
> public class HelloChild {
>    public void print(int x) {
>       System.out.println("Hello! I´m a child! My number is: "+ x);      
>    }
> }
>
> aspect World1 {
> }
> //-----------------------
>
> I did it because the AspectDeclaration extends the TypeDeclaration
> from jdt.core.dom. So, I supposed that I could get this element from a
> .java file. Is this correct? Any thoughts?! Please, tell me if I´m
> doing something stupid! My only itention is to get aspectj elements
> from an open file editor.
>
> Best regards!
>
> Alexandre Vasconcelos
> _______________________________________________
> aspectj-dev mailing list
> aspectj-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-dev

Back to the top