Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] State of AjAST

As Matt says - the AJ ast support is not all there .. we only put the
very basic shape in and as users need it, they/we can add more.  We
have some contributions from another user that should go in soon to
extend it for a system they were building.  Issues relating to it can
be discussed under the bug you found (110465) - that's where to post
what you've found or patches that extend its functionality...

Andy.

On 09/05/06, Matt Chapman <mpchapman@xxxxxxxxx> wrote:
Hi Simon,

The current AST support is not fully formed, but you should be able to
get further by creating a PointcutDeclaration instead of a
DefaultPointcut. This is because a DefaultPointcut is a type of
PointcutDesignator, which cannot be added directly to a
BodyDeclaration.

Regards,

Matt.

On 09/05/06, Simon Walter <simon.walter@xxxxxxxxxxxxx> wrote:
>
> Hello,
>
> i fought my way through the current AST of AspectJ and tried to add
> pointcuts to aspects by selecting methods in the outline-view. My main
> source for this was
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=110465 and
> org.aspectj.ajdt.core CVS sourcecode and the junit-tests.
>
> I got all the way down from the selected method to my sample .aj file,
> its aspectj sourcecode and the corresponding ast-object. So i can
> create the dummy DefaultPointcut, but i can't add it to the
> bodyDeclaration of the type. By doing this I get a ClassCastException.
>
> I modified AjASTTest to show the problem. here is what i got:
>
> --------------------------------------
>
> // helper method
> private AjAST createAjAST(int astlevel) {
>         AST ast = createCU(AST.JLS3).getAST();
>         assertTrue("the ast should be an instance of AjAST",ast instanceof AjAST);
>         return (AjAST)ast;
> }
>
> // helper method
> private CompilationUnit createCU(int astlevel) {
>         if (astlevel != AST.JLS2 && astlevel != AST.JLS3) {
>                 fail("need to pass AST.JLS2 or AST.JLS3 as an argument");
>         }
>         String source = "";
>         ASTParser parser = ASTParser.newParser(astlevel);
>         parser.setSource(source.toCharArray());
>         parser.setCompilerOptions(new HashMap());
>         CompilationUnit cu = (CompilationUnit) parser.createAST(null);
>
>         return cu;
> }
>
> public void testAddToAST() {
>         CompilationUnit cu = createCU(AST.JLS3);
>         AjAST ajast = (AjAST) cu.getAST();
>
>         // aspect
>         AspectDeclaration ad = ajast.newAspectDeclaration();
>         ad.setName(ajast.newSimpleName("pctest"));
>         cu.types().add(ad);
>
>         // method
>         MethodDeclaration md = ajast.newMethodDeclaration();
>         md.setName(ajast.newSimpleName("methodtest"));
>         ad.bodyDeclarations().add(md);
>
>         // pc
>         DefaultPointcut p = ajast.newDefaultPointcut();
>         p.setDetail("testads");
>         ad.bodyDeclarations().add(p); // classcastexception
> }
>
> ---------------------------------------------------------
>
> Am i doing something wrong or is this as far as i can get with the
> current state of AST for AspectJ?
>
> thanks for any help on this.
>
> --
> Simon
> _______________________________________________
> aspectj-dev mailing list
> aspectj-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-dev
>
_______________________________________________
aspectj-dev mailing list
aspectj-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-dev



Back to the top