[Help] About ASTNode [message #639255] |
Mon, 15 November 2010 18:34 |
Kam Ng Messages: 13 Registered: November 2010 Location: Hong Kong |
Junior Member |
|
|
Hello,
public void getInvokingMethode(String code) {
ASTParser parser = ASTParser.newParser(AST.JLS3);
parser.setSource(code.toCharArray());
parser.setKind(ASTParser.K_EXPRESSION);
ASTNode node = parser.createAST(null);
if (node.getNodeType() == ASTNode.METHOD_INVOCATION) {
MethodInvocation methodInvocation = (MethodInvocation) node;
System.out.println("Invoking method : "+ methodInvocation.getName());
}
}
I am using the code above and I am tring to get the API usage inside a method.
Since the parameter that I input is a java file, so I can only get the ASTNode.COMPILATION_UNIT.
How can I change the node position? For example, change to ASTNode.METHOD_INVOCATION
or somewhere else.
Kam
[Updated on: Mon, 15 November 2010 18:35] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03584 seconds