1 11 package org.eclipse.jdt.internal.debug.core.hcr; 12 13 import org.eclipse.jdt.core.Signature; 14 import org.eclipse.jdt.core.dom.ASTVisitor; 15 import org.eclipse.jdt.core.dom.AnnotationTypeDeclaration; 16 import org.eclipse.jdt.core.dom.AnnotationTypeMemberDeclaration; 17 import org.eclipse.jdt.core.dom.AnonymousClassDeclaration; 18 import org.eclipse.jdt.core.dom.ArrayAccess; 19 import org.eclipse.jdt.core.dom.ArrayCreation; 20 import org.eclipse.jdt.core.dom.ArrayInitializer; 21 import org.eclipse.jdt.core.dom.ArrayType; 22 import org.eclipse.jdt.core.dom.AssertStatement; 23 import org.eclipse.jdt.core.dom.Assignment; 24 import org.eclipse.jdt.core.dom.Block; 25 import org.eclipse.jdt.core.dom.BlockComment; 26 import org.eclipse.jdt.core.dom.BooleanLiteral; 27 import org.eclipse.jdt.core.dom.BreakStatement; 28 import org.eclipse.jdt.core.dom.CastExpression; 29 import org.eclipse.jdt.core.dom.CatchClause; 30 import org.eclipse.jdt.core.dom.CharacterLiteral; 31 import org.eclipse.jdt.core.dom.ClassInstanceCreation; 32 import org.eclipse.jdt.core.dom.CompilationUnit; 33 import org.eclipse.jdt.core.dom.ConditionalExpression; 34 import org.eclipse.jdt.core.dom.ConstructorInvocation; 35 import org.eclipse.jdt.core.dom.ContinueStatement; 36 import org.eclipse.jdt.core.dom.DoStatement; 37 import org.eclipse.jdt.core.dom.EmptyStatement; 38 import org.eclipse.jdt.core.dom.EnhancedForStatement; 39 import org.eclipse.jdt.core.dom.EnumConstantDeclaration; 40 import org.eclipse.jdt.core.dom.EnumDeclaration; 41 import org.eclipse.jdt.core.dom.ExpressionStatement; 42 import org.eclipse.jdt.core.dom.FieldAccess; 43 import org.eclipse.jdt.core.dom.FieldDeclaration; 44 import org.eclipse.jdt.core.dom.ForStatement; 45 import org.eclipse.jdt.core.dom.IMethodBinding; 46 import org.eclipse.jdt.core.dom.ITypeBinding; 47 import org.eclipse.jdt.core.dom.IfStatement; 48 import org.eclipse.jdt.core.dom.ImportDeclaration; 49 import org.eclipse.jdt.core.dom.InfixExpression; 50 import org.eclipse.jdt.core.dom.Initializer; 51 import org.eclipse.jdt.core.dom.InstanceofExpression; 52 import org.eclipse.jdt.core.dom.Javadoc; 53 import org.eclipse.jdt.core.dom.LabeledStatement; 54 import org.eclipse.jdt.core.dom.LineComment; 55 import org.eclipse.jdt.core.dom.MarkerAnnotation; 56 import org.eclipse.jdt.core.dom.MemberRef; 57 import org.eclipse.jdt.core.dom.MemberValuePair; 58 import org.eclipse.jdt.core.dom.MethodDeclaration; 59 import org.eclipse.jdt.core.dom.MethodInvocation; 60 import org.eclipse.jdt.core.dom.MethodRef; 61 import org.eclipse.jdt.core.dom.MethodRefParameter; 62 import org.eclipse.jdt.core.dom.Modifier; 63 import org.eclipse.jdt.core.dom.NormalAnnotation; 64 import org.eclipse.jdt.core.dom.NullLiteral; 65 import org.eclipse.jdt.core.dom.NumberLiteral; 66 import org.eclipse.jdt.core.dom.PackageDeclaration; 67 import org.eclipse.jdt.core.dom.ParameterizedType; 68 import org.eclipse.jdt.core.dom.ParenthesizedExpression; 69 import org.eclipse.jdt.core.dom.PostfixExpression; 70 import org.eclipse.jdt.core.dom.PrefixExpression; 71 import org.eclipse.jdt.core.dom.PrimitiveType; 72 import org.eclipse.jdt.core.dom.QualifiedName; 73 import org.eclipse.jdt.core.dom.QualifiedType; 74 import org.eclipse.jdt.core.dom.ReturnStatement; 75 import org.eclipse.jdt.core.dom.SimpleName; 76 import org.eclipse.jdt.core.dom.SimpleType; 77 import org.eclipse.jdt.core.dom.SingleMemberAnnotation; 78 import org.eclipse.jdt.core.dom.SingleVariableDeclaration; 79 import org.eclipse.jdt.core.dom.StringLiteral; 80 import org.eclipse.jdt.core.dom.SuperConstructorInvocation; 81 import org.eclipse.jdt.core.dom.SuperFieldAccess; 82 import org.eclipse.jdt.core.dom.SuperMethodInvocation; 83 import org.eclipse.jdt.core.dom.SwitchCase; 84 import org.eclipse.jdt.core.dom.SwitchStatement; 85 import org.eclipse.jdt.core.dom.SynchronizedStatement; 86 import org.eclipse.jdt.core.dom.TagElement; 87 import org.eclipse.jdt.core.dom.TextElement; 88 import org.eclipse.jdt.core.dom.ThisExpression; 89 import org.eclipse.jdt.core.dom.ThrowStatement; 90 import org.eclipse.jdt.core.dom.TryStatement; 91 import org.eclipse.jdt.core.dom.TypeDeclaration; 92 import org.eclipse.jdt.core.dom.TypeDeclarationStatement; 93 import org.eclipse.jdt.core.dom.TypeLiteral; 94 import org.eclipse.jdt.core.dom.TypeParameter; 95 import org.eclipse.jdt.core.dom.VariableDeclarationExpression; 96 import org.eclipse.jdt.core.dom.VariableDeclarationFragment; 97 import org.eclipse.jdt.core.dom.VariableDeclarationStatement; 98 import org.eclipse.jdt.core.dom.WhileStatement; 99 import org.eclipse.jdt.core.dom.WildcardType; 100 101 104 public class MethodSearchVisitor extends ASTVisitor { 105 106 109 private String fName; 110 private String [] fParameterTypes; 111 112 115 private MethodDeclaration fMatch; 116 117 123 public void setTargetMethod(String methodName, String methodSignature) { 124 fName = methodName; 125 fParameterTypes = Signature.getParameterTypes(methodSignature); 126 for (int i = 0; i < fParameterTypes.length; i++) { 128 String type = fParameterTypes[i]; 129 type = type.replace('/','.'); 130 fParameterTypes[i] = type; 131 } 132 fMatch = null; 133 } 134 135 140 public MethodDeclaration getMatch() { 141 return fMatch; 142 } 143 144 148 public boolean visit(MethodDeclaration node) { 149 if (node.getName().getIdentifier().equals(fName)) { 150 IMethodBinding methodBinding = node.resolveBinding(); 151 if (methodBinding != null) { 152 ITypeBinding[] typeBindings = methodBinding.getParameterTypes(); 153 if (typeBindings.length == fParameterTypes.length) { 154 for (int i = 0; i < typeBindings.length; i++) { 155 ITypeBinding typeBinding = typeBindings[i]; 156 String typeSignature = Signature.createTypeSignature(typeBinding.getQualifiedName(), true); 157 if (!fParameterTypes[i].equals(typeSignature)) { 158 return true; 159 } 160 } 161 fMatch = node; 162 } 163 } 164 } 165 return isSearching(); 166 } 167 168 173 private boolean isSearching() { 174 return fMatch == null; 175 } 176 public boolean visit(AnnotationTypeDeclaration node) { 177 return isSearching(); 178 } 179 public boolean visit(AnnotationTypeMemberDeclaration node) { 180 return isSearching(); 181 } 182 public boolean visit(AnonymousClassDeclaration node) { 183 return isSearching(); 184 } 185 public boolean visit(ArrayAccess node) { 186 return isSearching(); 187 } 188 public boolean visit(ArrayCreation node) { 189 return isSearching(); 190 } 191 public boolean visit(ArrayInitializer node) { 192 return isSearching(); 193 } 194 public boolean visit(ArrayType node) { 195 return isSearching(); 196 } 197 public boolean visit(AssertStatement node) { 198 return isSearching(); 199 } 200 public boolean visit(Assignment node) { 201 return isSearching(); 202 } 203 public boolean visit(Block node) { 204 return isSearching(); 205 } 206 public boolean visit(BlockComment node) { 207 return isSearching(); 208 } 209 public boolean visit(BooleanLiteral node) { 210 return isSearching(); 211 } 212 public boolean visit(BreakStatement node) { 213 return isSearching(); 214 } 215 public boolean visit(CastExpression node) { 216 return isSearching(); 217 } 218 public boolean visit(CatchClause node) { 219 return isSearching(); 220 } 221 public boolean visit(CharacterLiteral node) { 222 return isSearching(); 223 } 224 public boolean visit(ClassInstanceCreation node) { 225 return isSearching(); 226 } 227 public boolean visit(CompilationUnit node) { 228 return isSearching(); 229 } 230 public boolean visit(ConditionalExpression node) { 231 return isSearching(); 232 } 233 public boolean visit(ConstructorInvocation node) { 234 return isSearching(); 235 } 236 public boolean visit(ContinueStatement node) { 237 return isSearching(); 238 } 239 public boolean visit(DoStatement node) { 240 return isSearching(); 241 } 242 public boolean visit(EmptyStatement node) { 243 return isSearching(); 244 } 245 public boolean visit(EnhancedForStatement node) { 246 return isSearching(); 247 } 248 public boolean visit(EnumConstantDeclaration node) { 249 return isSearching(); 250 } 251 public boolean visit(EnumDeclaration node) { 252 return isSearching(); 253 } 254 public boolean visit(ExpressionStatement node) { 255 return isSearching(); 256 } 257 public boolean visit(FieldAccess node) { 258 return isSearching(); 259 } 260 public boolean visit(FieldDeclaration node) { 261 return isSearching(); 262 } 263 public boolean visit(ForStatement node) { 264 return isSearching(); 265 } 266 public boolean visit(IfStatement node) { 267 return isSearching(); 268 } 269 public boolean visit(ImportDeclaration node) { 270 return isSearching(); 271 } 272 public boolean visit(InfixExpression node) { 273 return isSearching(); 274 } 275 public boolean visit(Initializer node) { 276 return isSearching(); 277 } 278 public boolean visit(InstanceofExpression node) { 279 return isSearching(); 280 } 281 public boolean visit(Javadoc node) { 282 return isSearching(); 283 } 284 public boolean visit(LabeledStatement node) { 285 return isSearching(); 286 } 287 public boolean visit(LineComment node) { 288 return isSearching(); 289 } 290 public boolean visit(MarkerAnnotation node) { 291 return isSearching(); 292 } 293 public boolean visit(MemberRef node) { 294 return isSearching(); 295 } 296 public boolean visit(MemberValuePair node) { 297 return isSearching(); 298 } 299 public boolean visit(MethodInvocation node) { 300 return isSearching(); 301 } 302 public boolean visit(MethodRef node) { 303 return isSearching(); 304 } 305 public boolean visit(MethodRefParameter node) { 306 return isSearching(); 307 } 308 public boolean visit(Modifier node) { 309 return isSearching(); 310 } 311 public boolean visit(NormalAnnotation node) { 312 return isSearching(); 313 } 314 public boolean visit(NullLiteral node) { 315 return isSearching(); 316 } 317 public boolean visit(NumberLiteral node) { 318 return isSearching(); 319 } 320 public boolean visit(PackageDeclaration node) { 321 return isSearching(); 322 } 323 public boolean visit(ParameterizedType node) { 324 return isSearching(); 325 } 326 public boolean visit(ParenthesizedExpression node) { 327 return isSearching(); 328 } 329 public boolean visit(PostfixExpression node) { 330 return isSearching(); 331 } 332 public boolean visit(PrefixExpression node) { 333 return isSearching(); 334 } 335 public boolean visit(PrimitiveType node) { 336 return isSearching(); 337 } 338 public boolean visit(QualifiedName node) { 339 return isSearching(); 340 } 341 public boolean visit(QualifiedType node) { 342 return isSearching(); 343 } 344 public boolean visit(ReturnStatement node) { 345 return isSearching(); 346 } 347 public boolean visit(SimpleName node) { 348 return isSearching(); 349 } 350 public boolean visit(SimpleType node) { 351 return isSearching(); 352 } 353 public boolean visit(SingleMemberAnnotation node) { 354 return isSearching(); 355 } 356 public boolean visit(SingleVariableDeclaration node) { 357 return isSearching(); 358 } 359 public boolean visit(StringLiteral node) { 360 return isSearching(); 361 } 362 public boolean visit(SuperConstructorInvocation node) { 363 return isSearching(); 364 } 365 public boolean visit(SuperFieldAccess node) { 366 return isSearching(); 367 } 368 public boolean visit(SuperMethodInvocation node) { 369 return isSearching(); 370 } 371 public boolean visit(SwitchCase node) { 372 return isSearching(); 373 } 374 public boolean visit(SwitchStatement node) { 375 return isSearching(); 376 } 377 public boolean visit(SynchronizedStatement node) { 378 return isSearching(); 379 } 380 public boolean visit(TagElement node) { 381 return isSearching(); 382 } 383 public boolean visit(TextElement node) { 384 return isSearching(); 385 } 386 public boolean visit(ThisExpression node) { 387 return isSearching(); 388 } 389 public boolean visit(ThrowStatement node) { 390 return isSearching(); 391 } 392 public boolean visit(TryStatement node) { 393 return isSearching(); 394 } 395 public boolean visit(TypeDeclaration node) { 396 return isSearching(); 397 } 398 public boolean visit(TypeDeclarationStatement node) { 399 return isSearching(); 400 } 401 public boolean visit(TypeLiteral node) { 402 return isSearching(); 403 } 404 public boolean visit(TypeParameter node) { 405 return isSearching(); 406 } 407 public boolean visit(VariableDeclarationExpression node) { 408 return isSearching(); 409 } 410 public boolean visit(VariableDeclarationFragment node) { 411 return isSearching(); 412 } 413 public boolean visit(VariableDeclarationStatement node) { 414 return isSearching(); 415 } 416 public boolean visit(WhileStatement node) { 417 return isSearching(); 418 } 419 public boolean visit(WildcardType node) { 420 return isSearching(); 421 } 422 } 423 | Popular Tags |