[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [cdt-dev] Sample code for acessing the ast
|
Hello,
yes thanks a lot. I know this two talks. And yes, i am able to acess the
ast via visitor.
But i am not able to do any node insertion oder deletion.
There is a ASTRewrite at org.eclipse.cdt.core.dom.rewrite, but i get
some IllegalArgumentException.
I tried the following:
MyAstVisitor visitor = new MyAstVisitor();
ast.accept(visitor);
System.out.println("The RawSignature is: " +
visitor.node.getRawSignature());
System.out.println("This AST contains node: "
+ast.contains(visitor.node));
ASTRewrite rewrite = ASTRewrite.create(ast);
rewrite.remove(visitor.node, null); // here the
Exception occures
Change change = rewrite.rewriteAST();
An I get:
The rawSignature is: f
This AST contains node: true
java.lang.IllegalArgumentException
at
org.eclipse.cdt.core.dom.rewrite.ASTRewrite.checkBelongsToAST(ASTRewrite.java:188)
at
org.eclipse.cdt.core.dom.rewrite.ASTRewrite.remove(ASTRewrite.java:90)
Thanks
Wolfgang
Do you know about the "DOM AST View" that's part of the CDT testing
plugin?
It's an optional feature in the full update site.
The PLDT analysis features do alot of work with the CDT's AST.
There are some examples here:
http://www.eclipsecon.org/2008/?page=sub/&id=373
<http://www.eclipsecon.org/2008/?page=sub/&id=373>
http://www.eclipsecon.org/2007/index.php?page=sub/&id=3903
<http://www.eclipsecon.org/2007/index.php?page=sub/&id=3903>
The more complex features referred to in the first talk concentrate on
C, not C++.
However the basic analysis in PLDT utilizes some of the APIs for C++ -
there's a Cpp visitor in there too.
In the org.eclipse.ptp.pldt.mpi.core project, see the
org.eclipse.ptp.pldt.mpi.core.analysis.MpiCPPASTVisitor class
I don't think we do any node insertion or deletion, but hopefully this
helps.
...Beth
Beth Tibbitts
Eclipse Parallel Tools Platform http://eclipse.org/ptp
IBM STG Communications Protocols and Tools
Mailing Address: IBM Corp., Coldstream Research Campus, 745 West New
Circle Road, Lexington, KY 40511
Inactive hide details for Wolfgang Kaifler ---03/18/2010 05:30:35
PM---Hallo, i want do do a little bit code analysis in c++. TWolfgang
Kaifler ---03/18/2010 05:30:35 PM---Hallo, i want do do a little bit
code analysis in c++. Therefore i use the
From:
Wolfgang Kaifler <kaiflerw@xxxxxx>
To:
cdt-dev@xxxxxxxxxxx
Date:
03/18/2010 05:30 PM
Subject:
[cdt-dev] Sample code for acessing the ast
Sent by:
cdt-dev-bounces@xxxxxxxxxxx
------------------------------------------------------------------------
Hallo,
i want do do a little bit code analysis in c++. Therefore i use the
eclipse cdt parser which works fine for me :-) I wrote a few visitor
patterns, so i am able to find some nodes on the AST.
Now i want to to delete or insert new Nodes.
This ist not for a PlugIn, I only want to transform the AST.
Is there any sample Code to do this? Or is there any site to start with?
Thanks
Wolfgang
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev
------------------------------------------------------------------------
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev