1 7 8 package com.sun.mirror.util; 9 10 import com.sun.mirror.declaration.*; 11 12 29 30 class DeclarationScanner implements DeclarationVisitor { 31 protected DeclarationVisitor pre; 32 protected DeclarationVisitor post; 33 34 DeclarationScanner(DeclarationVisitor pre, DeclarationVisitor post) { 35 this.pre = pre; 36 this.post = post; 37 } 38 39 44 public void visitDeclaration(Declaration d) { 45 d.accept(pre); 46 d.accept(post); 47 } 48 49 54 public void visitPackageDeclaration(PackageDeclaration d) { 55 d.accept(pre); 56 57 for(ClassDeclaration classDecl: d.getClasses()) { 58 classDecl.accept(this); 59 } 60 61 for(InterfaceDeclaration interfaceDecl: d.getInterfaces()) { 62 interfaceDecl.accept(this); 63 } 64 65 d.accept(post); 66 } 67 68 73 public void visitMemberDeclaration(MemberDeclaration d) { 74 visitDeclaration(d); 75 } 76 77 82 public void visitTypeDeclaration(TypeDeclaration d) { 83 d.accept(pre); 84 85 for(TypeParameterDeclaration tpDecl: d.getFormalTypeParameters()) { 86 tpDecl.accept(this); 87 } 88 89 for(FieldDeclaration fieldDecl: d.getFields()) { 90 fieldDecl.accept(this); 91 } 92 93 for(MethodDeclaration methodDecl: d.getMethods()) { 94 methodDecl.accept(this); 95 } 96 97 for(TypeDeclaration typeDecl: d.getNestedTypes()) { 98 typeDecl.accept(this); 99 } 100 101 d.accept(post); 102 } 103 104 109 public void visitClassDeclaration(ClassDeclaration d) { 110 d.accept(pre); 111 112 for(TypeParameterDeclaration tpDecl: d.getFormalTypeParameters()) { 113 tpDecl.accept(this); 114 } 115 116 for(FieldDeclaration fieldDecl: d.getFields()) { 117 fieldDecl.accept(this); 118 } 119 120 for(MethodDeclaration methodDecl: d.getMethods()) { 121 methodDecl.accept(this); 122 } 123 124 for(TypeDeclaration typeDecl: d.getNestedTypes()) { 125 typeDecl.accept(this); 126 } 127 128 for(ConstructorDeclaration ctorDecl: d.getConstructors()) { 129 ctorDecl.accept(this); 130 } 131 132 d.accept(post); 133 } 134 135 140 public void visitEnumDeclaration(EnumDeclaration d) { 141 visitClassDeclaration(d); 142 } 143 144 149 public void visitInterfaceDeclaration(InterfaceDeclaration d) { 150 visitTypeDeclaration(d); 151 } 152 153 158 public void visitAnnotationTypeDeclaration(AnnotationTypeDeclaration d) { 159 visitInterfaceDeclaration(d); 160 } 161 162 167 public void visitFieldDeclaration(FieldDeclaration d) { 168 visitMemberDeclaration(d); 169 } 170 171 176 public void visitEnumConstantDeclaration(EnumConstantDeclaration d) { 177 visitFieldDeclaration(d); 178 } 179 180 185 public void visitExecutableDeclaration(ExecutableDeclaration d) { 186 d.accept(pre); 187 188 for(TypeParameterDeclaration tpDecl: d.getFormalTypeParameters()) { 189 tpDecl.accept(this); 190 } 191 192 for(ParameterDeclaration pDecl: d.getParameters()) { 193 pDecl.accept(this); 194 } 195 196 d.accept(post); 197 } 198 199 204 public void visitConstructorDeclaration(ConstructorDeclaration d) { 205 visitExecutableDeclaration(d); 206 } 207 208 213 public void visitMethodDeclaration(MethodDeclaration d) { 214 visitExecutableDeclaration(d); 215 } 216 217 222 public void visitAnnotationTypeElementDeclaration( 223 AnnotationTypeElementDeclaration d) { 224 visitMethodDeclaration(d); 225 } 226 227 232 public void visitParameterDeclaration(ParameterDeclaration d) { 233 visitDeclaration(d); 234 } 235 236 241 public void visitTypeParameterDeclaration(TypeParameterDeclaration d) { 242 visitDeclaration(d); 243 } 244 } 245 | Popular Tags |