Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-dev] Fwd: Creating AspectJ AST nodes

Forwarding from aspectj-users, since I didn't get any response there, may this would be a better place to try.

---------- Forwarded message ----------
From: Fernando Calheiros <xfernando@xxxxxxxxx>
Date: Dec 12, 2006 2:25 PM
Subject: Creating AspectJ AST nodes
To: aspectj-users@xxxxxxxxxxx

Hi all, I'm trying to create an AspectJ AST using the API from org.aspectj.org.eclipse.jdt.core.dom.

When I try to modify the "aspect" property of an AjTypeDeclaration I'm getting the following exception:

java.lang.IllegalArgumentException: AjTypeDeclaration has no property aspect
    at org.aspectj.org.eclipse.jdt.internal.core.dom.rewrite.RewriteEventStore.validateHasChildProperty(RewriteEventStore.java:813)
    at org.aspectj.org.eclipse.jdt.internal.core.dom.rewrite.RewriteEventStore.getEvent(RewriteEventStore.java:362)
    at org.aspectj.org.eclipse.jdt.internal.core.dom.rewrite.RewriteEventStore.getNodeEvent(RewriteEventStore.java :380)
    at org.aspectj.org.eclipse.jdt.core.dom.InternalASTRewrite.getNodeEvent(InternalASTRewrite.java:230)
    at org.aspectj.org.eclipse.jdt.core.dom.InternalASTRewrite.preValueChangeEvent(InternalASTRewrite.java :132)
    at org.aspectj.org.eclipse.jdt.core.dom.AST.preValueChangeEvent(AST.java:639)
    at org.aspectj.org.eclipse.jdt.core.dom.ASTNode.preValueChange(ASTNode.java:1995)
    at org.aspectj.org.eclipse.jdt.core.dom.AjTypeDeclaration.setAspect (AjTypeDeclaration.java:166)
    at org.aspectj.org.eclipse.jdt.core.dom.AjTypeDeclaration.internalGetSetBooleanProperty(AjTypeDeclaration.java:119)
    at org.aspectj.org.eclipse.jdt.core.dom.ASTNode.setStructuralProperty (ASTNode.java:1545)

The code that raises this exception is the following

    //after creating the parser and getting the CompilationUnit...
            AjAST ast = (AjAST) aspectAST.getAST();

            AjTypeDeclaration aspectDeclaration = ast.newAjTypeDeclaration();
            aspectDeclaration.setStructuralProperty(
                    AjTypeDeclaration.ASPECT_PROPERTY, true);

I tried changing to AspectDeclaration, but it raises the same exception, and I also tried using the setAspect() method, but with no success.

Any thoughts?

Back to the top