0

I have to count all the methods in JDK, for each class, count the method calls it received; for each method, count the number of times this method is called;

Hint: Use Eclipse JDT to create Abstract Syntax tree.

Can any body please explain how should I approach this problem. A brief algorithm would be great help. Thanks

Ambidextrous
  • 882
  • 2
  • 12
  • 26

1 Answers1

2

You can approach your problem using the below steps:

  1. First convert your java class to a CompilationUnit so that it can be traversed.
  2. Then use the ASTVisitor pattern to visit the MethodDeclaration node (method call)
  3. Do a reference search for the MethodDeclaration using JDT SearchEngine capabilities

Refer the below posts:

Community
  • 1
  • 1
Unni Kris
  • 3,081
  • 4
  • 35
  • 57