KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > pmd > util > SymbolTableViewer


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 JavaDoc visit(ASTCompilationUnit node, Object JavaDoc 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 JavaDoc visit(ASTClassOrInterfaceDeclaration node, Object JavaDoc 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 JavaDoc spaces() {
28         StringBuffer JavaDoc sb = new StringBuffer JavaDoc(depth);
29         for (int i=0; i<depth; i++) sb.append(' ');
30         return sb.toString();
31     }
32
33 /*
34     public Object visit(ASTClassOrInterfaceBodyDeclaration node, Object data) {
35         System.out.println(node.getScope());
36         node.dump("");
37         return super.visit(node, data); //To change body of implemented methods use File | Settings | File Templates.
38     }
39
40     public Object visit(ASTEnumDeclaration node, Object data) {
41         System.out.println(node.getScope());
42         node.dump("");
43         return super.visit(node, data); //To change body of implemented methods use File | Settings | File Templates.
44     }
45
46     public Object visit(ASTBlock node, Object data) {
47         System.out.println(node.getScope());
48         node.dump("");
49         return super.visit(node, data); //To change body of implemented methods use File | Settings | File Templates.
50     }
51
52     public Object visit(ASTTryStatement node, Object data) {
53         System.out.println(node.getScope());
54         node.dump("");
55         return super.visit(node, data); //To change body of implemented methods use File | Settings | File Templates.
56     }
57
58     public Object visit(ASTCatchStatement node, Object data) {
59         System.out.println(node.getScope());
60         node.dump("");
61         return super.visit(node, data); //To change body of implemented methods use File | Settings | File Templates.
62     }
63
64     public Object visit(ASTFinallyStatement node, Object data) {
65         System.out.println(node.getScope());
66         node.dump("");
67         return super.visit(node, data); //To change body of implemented methods use File | Settings | File Templates.
68     }
69
70     public Object visit(ASTMethodDeclaration node, Object data) {
71         System.out.println(node.getScope());
72         node.dump("");
73         return super.visit(node, data); //To change body of implemented methods use File | Settings | File Templates.
74     }
75
76     public Object visit(ASTConstructorDeclaration node, Object data) {
77         System.out.println(node.getScope());
78         node.dump("");
79         return super.visit(node, data); //To change body of implemented methods use File | Settings | File Templates.
80     }
81
82     public Object visit(ASTSwitchLabel node, Object data) {
83         System.out.println(node.getScope());
84         node.dump("");
85         return super.visit(node, data); //To change body of implemented methods use File | Settings | File Templates.
86     }
87
88     public Object visit(ASTIfStatement node, Object data) {
89         System.out.println(node.getScope());
90         node.dump("");
91         return super.visit(node, data); //To change body of implemented methods use File | Settings | File Templates.
92     }
93
94     public Object visit(ASTForStatement node, Object data) {
95         System.out.println(node.getScope());
96         node.dump("");
97         return super.visit(node, data); //To change body of implemented methods use File | Settings | File Templates.
98     }
99 */

100
101 }
102
Popular Tags