Lines 21-27
Link Here
|
21 |
import org.eclipse.jdt.internal.compiler.env.IBinaryType; |
21 |
import org.eclipse.jdt.internal.compiler.env.IBinaryType; |
22 |
import org.eclipse.jdt.internal.compiler.lookup.*; |
22 |
import org.eclipse.jdt.internal.compiler.lookup.*; |
23 |
import org.eclipse.jdt.internal.compiler.util.SimpleSet; |
23 |
import org.eclipse.jdt.internal.compiler.util.SimpleSet; |
24 |
import org.eclipse.jdt.internal.core.JavaElement; |
|
|
25 |
import org.eclipse.jdt.internal.core.search.BasicSearchEngine; |
24 |
import org.eclipse.jdt.internal.core.search.BasicSearchEngine; |
26 |
|
25 |
|
27 |
public class MethodLocator extends PatternLocator { |
26 |
public class MethodLocator extends PatternLocator { |
Lines 498-509
Link Here
|
498 |
IType type = locator.lookupType(declaringClass); |
497 |
IType type = locator.lookupType(declaringClass); |
499 |
if (type == null) return; // case of a secondary type |
498 |
if (type == null) return; // case of a secondary type |
500 |
|
499 |
|
501 |
char[] bindingSelector = methodBinding.selector; |
500 |
// Report match for binary |
502 |
boolean isBinary = type.isBinary(); |
501 |
if (type.isBinary()) { |
503 |
IMethod method = null; |
502 |
IMethod method = null; |
504 |
TypeBinding[] parameters = methodBinding.original().parameters; |
503 |
TypeBinding[] parameters = methodBinding.original().parameters; |
505 |
int parameterLength = parameters.length; |
504 |
int parameterLength = parameters.length; |
506 |
if (isBinary) { |
|
|
507 |
char[][] parameterTypes = new char[parameterLength][]; |
505 |
char[][] parameterTypes = new char[parameterLength][]; |
508 |
for (int i = 0; i<parameterLength; i++) { |
506 |
for (int i = 0; i<parameterLength; i++) { |
509 |
char[] typeName = parameters[i].qualifiedSourceName(); |
507 |
char[] typeName = parameters[i].qualifiedSourceName(); |
Lines 513-560
Link Here
|
513 |
parameterTypes[i] = typeName; |
511 |
parameterTypes[i] = typeName; |
514 |
} |
512 |
} |
515 |
method = locator.createBinaryMethodHandle(type, methodBinding.selector, parameterTypes); |
513 |
method = locator.createBinaryMethodHandle(type, methodBinding.selector, parameterTypes); |
516 |
} else { |
514 |
if (method == null || knownMethods.addIfNotIncluded(method) == null) return; |
517 |
String[] parameterTypes = new String[parameterLength]; |
515 |
|
518 |
for (int i = 0; i < parameterLength; i++) { |
516 |
IResource resource = type.getResource(); |
519 |
char[] typeName = parameters[i].shortReadableName(); |
|
|
520 |
if (parameters[i].isMemberType()) { |
521 |
typeName = CharOperation.subarray(typeName, CharOperation.indexOf('.', typeName)+1, typeName.length); |
522 |
} |
523 |
parameterTypes[i] = Signature.createTypeSignature(typeName, false); |
524 |
} |
525 |
method = type.getMethod(new String(bindingSelector), parameterTypes); |
526 |
} |
527 |
if (method == null || knownMethods.addIfNotIncluded(method) == null) return; |
528 |
|
529 |
IResource resource = type.getResource(); |
530 |
IBinaryType info = null; |
531 |
if (isBinary) { |
532 |
if (resource == null) |
517 |
if (resource == null) |
533 |
resource = type.getJavaProject().getProject(); |
518 |
resource = type.getJavaProject().getProject(); |
534 |
info = locator.getBinaryInfo((org.eclipse.jdt.internal.core.ClassFile)type.getClassFile(), resource); |
519 |
IBinaryType info = locator.getBinaryInfo((org.eclipse.jdt.internal.core.ClassFile)type.getClassFile(), resource); |
535 |
locator.reportBinaryMemberDeclaration(resource, method, methodBinding, info, SearchMatch.A_ACCURATE); |
520 |
locator.reportBinaryMemberDeclaration(resource, method, methodBinding, info, SearchMatch.A_ACCURATE); |
536 |
} else { |
521 |
return; |
537 |
if (declaringClass instanceof ParameterizedTypeBinding) |
522 |
} |
538 |
declaringClass = ((ParameterizedTypeBinding) declaringClass).genericType(); |
523 |
|
539 |
ClassScope scope = ((SourceTypeBinding) declaringClass).scope; |
524 |
// When source is available, report match if method is found in the declaring type |
540 |
if (scope != null) { |
525 |
IResource resource = type.getResource(); |
541 |
TypeDeclaration typeDecl = scope.referenceContext; |
526 |
if (declaringClass instanceof ParameterizedTypeBinding) |
542 |
AbstractMethodDeclaration methodDecl = null; |
527 |
declaringClass = ((ParameterizedTypeBinding) declaringClass).genericType(); |
543 |
AbstractMethodDeclaration[] methodDecls = typeDecl.methods; |
528 |
ClassScope scope = ((SourceTypeBinding) declaringClass).scope; |
544 |
for (int i = 0, length = methodDecls.length; i < length; i++) { |
529 |
if (scope != null) { |
545 |
if (CharOperation.equals(bindingSelector, methodDecls[i].selector)) { |
530 |
TypeDeclaration typeDecl = scope.referenceContext; |
546 |
methodDecl = methodDecls[i]; |
531 |
AbstractMethodDeclaration methodDecl = typeDecl.declarationOf(methodBinding.original()); |
547 |
break; |
532 |
if (methodDecl != null) { |
548 |
} |
533 |
// Create method handle from method declaration |
549 |
} |
534 |
String methodName = new String(methodBinding.selector); |
550 |
if (methodDecl != null) { |
535 |
Argument[] arguments = methodDecl.arguments; |
551 |
int offset = methodDecl.sourceStart; |
536 |
int length = arguments == null ? 0 : arguments.length; |
552 |
Binding binding = methodDecl.binding; |
537 |
String[] parameterTypes = new String[length]; |
553 |
if (binding != null) |
538 |
for (int i = 0; i < length; i++) { |
554 |
method = (IMethod) ((JavaElement) method).resolved(binding); |
539 |
char[][] typeName = arguments[i].type.getParameterizedTypeName(); |
555 |
this.match = new MethodDeclarationMatch(method, SearchMatch.A_ACCURATE, offset, methodDecl.sourceEnd-offset+1, locator.getParticipant(), resource); |
540 |
parameterTypes[i] = Signature.createTypeSignature(CharOperation.concatWith(typeName, '.'), false); |
556 |
locator.report(this.match); |
541 |
} |
557 |
} |
542 |
IMethod method = type.getMethod(methodName, parameterTypes); |
|
|
543 |
if (method == null || knownMethods.addIfNotIncluded(method) == null) return; |
544 |
|
545 |
// Create and report corresponding match |
546 |
int offset = methodDecl.sourceStart; |
547 |
this.match = new MethodDeclarationMatch(method, SearchMatch.A_ACCURATE, offset, methodDecl.sourceEnd-offset+1, locator.getParticipant(), resource); |
548 |
locator.report(this.match); |
558 |
} |
549 |
} |
559 |
} |
550 |
} |
560 |
} |
551 |
} |