Getting the type/class of nested method/chained method invocations including static ones [message #1751458] |
Tue, 10 January 2017 14:29 |
Sasha Fonseca Messages: 4 Registered: January 2017 |
Junior Member |
|
|
So I'm new to Eclipse JDT and I'm developing an app where I need to get the types/classes of every method invocation in a given Java source file. I've developed my own ASTVisitor and I can traverse the AST and retrieve pretty much every type used in MethodInvocations. However, nested calls and static method calls do not seem to be retrieved:
@Override
public boolean visit(MethodInvocation node) {
Expression exp = node.getExpression();
ITypeBinding typeBinding = null;
if(exp != null) {
typeBinding = exp.resolveTypeBinding();
}
if(typeBinding != null) {
this.invocationTypes.add(typeBinding.getQualifiedName());
}
return true;
}
For example, in this piece of code below, I believe I should retrieve System, PrintStream, IntStream, List and LinkedList<String>, but I only seem to get PrintStream, IntStream, List and LinkedList<String>, i.e., System does not seem to be retrieved.
System.out.println("Hello");
List<String> list = new LinkedList<String>();
list.add("1");
list.remove(0).codePoints().close();;
I believe the types from the nested list.remove(0).codePoints().close(); are retrieved all correctly, so I'm not sure if it's due to the System invocation being static? I pretty much just want to get all types in all method invocations in a source file, static or not, nested or not.
Thanks!
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03901 seconds