title: What is the correct way to parse variables using JavaParser?
body: <p>Using JavaParser I can get a list of my methods and fields using:</p>
  
  <pre><code>//List of all methods
  System.out.println("Methods: " + this.toString());
  List&lt;TypeDeclaration&gt; types = n.getTypes();
  for (TypeDeclaration type : types)
  {
      List&lt;BodyDeclaration&gt; members = type.getMembers();
      for (BodyDeclaration member : members)
      {
          if (member instanceof MethodDeclaration)
          {
              MethodDeclaration method = (MethodDeclaration) member;
              System.out.println("Methods: " + method.getName());
          }
      }
  }
  
  //List all field variables.
  System.out.println("Field Variables: " + this.toString());
  List&lt;TypeDeclaration&gt; f_vars = n.getTypes();
  for (TypeDeclaration type : f_vars)
  {
      List&lt;BodyDeclaration&gt; members = type.getMembers();
      for (BodyDeclaration member : members)
      {
          if (member instanceof FieldDeclaration)
          {
              FieldDeclaration myType = (FieldDeclaration) member;
              List &lt;VariableDeclarator&gt; myFields = myType.getVariables();
              System.out.println("Fields: " + myType.getType() + ":" + myFields.toString());
          }
      }
  }
  </code></pre>
  
  <p>But I can't figure out how to get a list of my variables. I simply want a list of all variables from a java source, regardless of scope. </p>