title: How to parse java method body?
body: <p>I want to parse java source files (.java) in order to identify methods, in a class, that contain calls to a specific method. </p>
  
  <p>In the below example, I need to know which methods contain a call to xyz(). So, the parser should return method01 and method03</p>
  
  <pre><code>public class A{
      private void method01(){
          //some statements
          xyz();
          //more statements
      }
  
      private void method02(){
          //some statements
          xyz123();
          //more statements
      }
  
      private void method03(){
          //some statements
          xyz();
          //more statements
      }
  }
  </code></pre>
  
  <p>I tried using javaparser (com.github.javaparser). I created a vistor and by overriding  </p>
  
  <pre><code>public void visit(MethodDeclaration n, Void arg) 
  </code></pre>
  
  <p>I am able to “visit” all methods in the class. </p>
  
  <p>But I don't know how to parse the body of the visted method. I’m reluctant to use  n.getBody().toString().contains(“xyz()”)</p>