HI @KevinJin
There is probably a better way for you to design your check without checking all statements manually:
- Make your check stop on method declarations
- In method declarations, look for method invocations and count them
To do the second part of this check, you can implement a BaseTreeVisitor
that stops on method invocations and increment a counter.
class MyCheck extends BaseTreeVisitor {
@Override
void visitMethod(MethodTree tree) {
InvocationVisitor iv = new InvocationVisitor();
tree.accept(iv);
// Recover the counter from iv
}
static class InvocationVisitor extends BaseTreeVisitor {
@Override
void visitMethodInvocation(MethodInvocationTree tree) {
// Increment my counter here
}
}
}
This should help a lot.
Dorian