View Javadoc

    1   package net.sourceforge.pmd.util;
    2
    3   import net.sourceforge.pmd.ast.ASTClassOrInterfaceDeclaration;
    4   import net.sourceforge.pmd.ast.ASTCompilationUnit;
    5   import net.sourceforge.pmd.ast.JavaParserVisitorAdapter;
    6
    7   public class SymbolTableViewer extends JavaParserVisitorAdapter {
    8
    9       private int depth;
    10
    11      public Object visit(ASTCompilationUnit node, Object data) {
    12          depth++;
    13          System.out.println(spaces() + node.getScope());
    14          super.visit(node, data);
    15          depth--;
    16          return data;
    17      }
    18
    19      public Object visit(ASTClassOrInterfaceDeclaration node, Object data) {
    20          depth++;
    21          System.out.println(spaces() + node.getScope());
    22          super.visit(node, data);
    23          depth--;
    24          return data;
    25      }
    26
    27      private String spaces() {
    28          String s = "";
    29          for (int i = 0; i < depth; i++) {
    30              s += " ";
    31          }
    32          return s;
    33      }
    34
    35  /*
    36      public Object visit(ASTClassOrInterfaceBodyDeclaration node, Object data) {
    37          System.out.println(node.getScope());
    38          node.dump("");
    39          return super.visit(node, data);  //To change body of implemented methods use File | Settings | File Templates.
    40      }
    41
    42      public Object visit(ASTEnumDeclaration node, Object data) {
    43          System.out.println(node.getScope());
    44          node.dump("");
    45          return super.visit(node, data);  //To change body of implemented methods use File | Settings | File Templates.
    46      }
    47
    48      public Object visit(ASTBlock node, Object data) {
    49          System.out.println(node.getScope());
    50          node.dump("");
    51          return super.visit(node, data);  //To change body of implemented methods use File | Settings | File Templates.
    52      }
    53
    54      public Object visit(ASTTryStatement node, Object data) {
    55          System.out.println(node.getScope());
    56          node.dump("");
    57          return super.visit(node, data);  //To change body of implemented methods use File | Settings | File Templates.
    58      }
    59
    60      public Object visit(ASTCatchStatement node, Object data) {
    61          System.out.println(node.getScope());
    62          node.dump("");
    63          return super.visit(node, data);  //To change body of implemented methods use File | Settings | File Templates.
    64      }
    65
    66      public Object visit(ASTFinallyStatement node, Object data) {
    67          System.out.println(node.getScope());
    68          node.dump("");
    69          return super.visit(node, data);  //To change body of implemented methods use File | Settings | File Templates.
    70      }
    71
    72      public Object visit(ASTMethodDeclaration node, Object data) {
    73          System.out.println(node.getScope());
    74          node.dump("");
    75          return super.visit(node, data);  //To change body of implemented methods use File | Settings | File Templates.
    76      }
    77
    78      public Object visit(ASTConstructorDeclaration node, Object data) {
    79          System.out.println(node.getScope());
    80          node.dump("");
    81          return super.visit(node, data);  //To change body of implemented methods use File | Settings | File Templates.
    82      }
    83
    84      public Object visit(ASTSwitchLabel node, Object data) {
    85          System.out.println(node.getScope());
    86          node.dump("");
    87          return super.visit(node, data);  //To change body of implemented methods use File | Settings | File Templates.
    88      }
    89
    90      public Object visit(ASTIfStatement node, Object data) {
    91          System.out.println(node.getScope());
    92          node.dump("");
    93          return super.visit(node, data);  //To change body of implemented methods use File | Settings | File Templates.
    94      }
    95
    96      public Object visit(ASTForStatement node, Object data) {
    97          System.out.println(node.getScope());
    98          node.dump("");
    99          return super.visit(node, data);  //To change body of implemented methods use File | Settings | File Templates.
    100     }
    101 */
    102
    103 }