/**
* Method invocation of the form "exp.method()"
*/
public Void visitMethodInvocation(MethodInvocationTree mi, Void _) {
ExpressionTree ms = mi.getMethodSelect(); // PRIMARY.methodName portion
Element e = TreeUtil.getElement(mi);
if (e instanceof ExecutableElement) {// this check is needed in case the source code contains errors
ExecutableElement ee = (ExecutableElement) e;
Name methodName = ee.getSimpleName();
long ep = srcPos.getEndPosition(cu, ms);
if(ep>=0) {
// marker for the method name (and jump to definition)
long sp = ep - methodName.length();
gen.add(new MethodRef(sp, ep, PositionUtils.getLineNumber(lineMap, sp), PositionUtils.getColNumber(lineMap, sp), ee));
}
}
return super.visitMethodInvocation(mi,_);
}
// recursively scan trees
private void scan(List<? extends Tree> list) {
for (Tree t : list)
scan(t);
}
private void scan(Tree t) {
scan(t,null);
}
}.scan(cu,null);
// compilationUnit -> package name consists of member select trees
// but it fails to create an element, so do this manually
ExpressionTree packageName = cu.getPackageName();
if(packageName!=null) {
new TreeScanner<String,Void>() {
/**
* For "a" of "a.b.c"
*/