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 StringBuffer sb = new StringBuffer (depth); 29 for (int i=0; i<depth; i++) sb.append(' '); 30 return sb.toString(); 31 } 32 33 100 101 } 102 | Popular Tags |