### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java,v retrieving revision 1.163 diff -u -r1.163 JavaSearchTests.java --- src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java 6 Jul 2007 12:25:35 -0000 1.163 +++ src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java 18 Jul 2007 12:57:51 -0000 @@ -1948,19 +1948,13 @@ project.setRawClasspath(newClasspath, null); // potential match for a field declaration - - resultCollector.showAccuracy = true; - search( - "MissingFieldType.*", - FIELD, - DECLARATIONS, - getJavaSearchScope(), - this.resultCollector); + this.resultCollector.showAccuracy = true; + search("MissingFieldType.*", FIELD, DECLARATIONS, getJavaSearchScope()); assertSearchResults( - "AbortCompilation.jar AbortCompilation.MissingFieldType.field [No source] POTENTIAL_MATCH\n" + - "AbortCompilation.jar AbortCompilation.MissingFieldType.missing [No source] POTENTIAL_MATCH\n" + - "AbortCompilation.jar AbortCompilation.MissingFieldType.otherField [No source] POTENTIAL_MATCH", - this.resultCollector); + "AbortCompilation.jar AbortCompilation.MissingFieldType.field [No source] EXACT_MATCH\n" + + "AbortCompilation.jar AbortCompilation.MissingFieldType.otherField [No source] EXACT_MATCH\n" + + "AbortCompilation.jar AbortCompilation.MissingFieldType.missing [No source] POTENTIAL_MATCH" + ); } finally { // reset classpath project.setRawClasspath(classpath, null); @@ -1983,19 +1977,13 @@ project.setRawClasspath(newClasspath, null); // potential match for a method declaration - - resultCollector.showAccuracy = true; - search( - "MissingArgumentType.foo*", - METHOD, - DECLARATIONS, - getJavaSearchScope(), - this.resultCollector); + this.resultCollector.showAccuracy = true; + search("MissingArgumentType.foo*", METHOD, DECLARATIONS, getJavaSearchScope()); assertSearchResults( - "AbortCompilation.jar void AbortCompilation.MissingArgumentType.foo() [No source] POTENTIAL_MATCH\n" + - "AbortCompilation.jar void AbortCompilation.MissingArgumentType.foo(java.util.EventListener) [No source] POTENTIAL_MATCH\n" + - "AbortCompilation.jar void AbortCompilation.MissingArgumentType.foo2() [No source] POTENTIAL_MATCH", - this.resultCollector); + "AbortCompilation.jar void AbortCompilation.MissingArgumentType.foo() [No source] EXACT_MATCH\n" + + "AbortCompilation.jar void AbortCompilation.MissingArgumentType.foo2() [No source] EXACT_MATCH\n" + + "AbortCompilation.jar void AbortCompilation.MissingArgumentType.foo(java.util.EventListener) [No source] POTENTIAL_MATCH" + ); } finally { // reset classpath project.setRawClasspath(classpath, null); #P org.eclipse.jdt.core Index: search/org/eclipse/jdt/internal/core/search/matching/ClassFileMatchLocator.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ClassFileMatchLocator.java,v retrieving revision 1.33 diff -u -r1.33 ClassFileMatchLocator.java --- search/org/eclipse/jdt/internal/core/search/matching/ClassFileMatchLocator.java 10 May 2007 15:10:41 -0000 1.33 +++ search/org/eclipse/jdt/internal/core/search/matching/ClassFileMatchLocator.java 18 Jul 2007 12:57:52 -0000 @@ -17,7 +17,6 @@ import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; import org.eclipse.jdt.internal.compiler.env.*; import org.eclipse.jdt.internal.compiler.lookup.*; -import org.eclipse.jdt.internal.compiler.problem.AbortCompilation; import org.eclipse.jdt.internal.core.*; import org.eclipse.jdt.internal.core.search.indexing.IIndexConstants; @@ -61,79 +60,134 @@ locator.reportBinaryMemberDeclaration(null, binaryType, null, info, SearchMatch.A_ACCURATE); } - int accuracy = SearchMatch.A_ACCURATE; + // Get methods from binary type info + IBinaryMethod[] binaryMethods = info.getMethods(); + int bMethodsLength = binaryMethods == null ? 0 : binaryMethods.length; + IBinaryMethod[] inaccurateMethods = new IBinaryMethod[bMethodsLength]; + char[][] binaryMethodSignatures = null; + if (bMethodsLength > 0) { + System.arraycopy(binaryMethods, 0, inaccurateMethods, 0, bMethodsLength); + } + + // Get fields from binary type info + IBinaryField[] binaryFields = info.getFields(); + int bFieldsLength = binaryFields == null ? 0 : binaryFields.length; + IBinaryField[] inaccurateFields = new IBinaryField[bFieldsLength]; + if (bFieldsLength > 0) { + System.arraycopy(binaryFields, 0, inaccurateFields, 0, bFieldsLength); + } + + // Report as many accurate matches as possible if (((InternalSearchPattern)pattern).mustResolve) { - try { - BinaryTypeBinding binding = locator.cacheBinaryType(binaryType, info); - if (binding != null) { - // filter out element not in hierarchy scope - if (!locator.typeInHierarchy(binding)) return; - - MethodBinding[] methods = binding.methods(); - for (int i = 0, l = methods.length; i < l; i++) { - MethodBinding method = methods[i]; - if (locator.patternLocator.resolveLevel(method) == PatternLocator.ACCURATE_MATCH) { - char[] methodSignature = method.genericSignature(); - if (methodSignature == null) methodSignature = method.signature(); + BinaryTypeBinding binding = locator.cacheBinaryType(binaryType, info); + if (binding != null) { + // filter out element not in hierarchy scope + if (!locator.typeInHierarchy(binding)) return; + + // Report accurate methods + MethodBinding[] availableMethods = binding.availableMethods(); + int aMethodsLength = availableMethods == null ? 0 : availableMethods.length; + for (int i = 0; i < aMethodsLength; i++) { + MethodBinding method = availableMethods[i]; + int level = locator.patternLocator.resolveLevel(method); + char[] methodSignature = method.genericSignature(); + if (methodSignature == null) methodSignature = method.signature(); + switch (level) { + case PatternLocator.ACCURATE_MATCH: IMethod methodHandle = binaryType.getMethod( new String(method.isConstructor() ? binding.compoundName[binding.compoundName.length-1] : method.selector), CharOperation.toStrings(Signature.getParameterTypes(convertClassFileFormat(methodSignature)))); locator.reportBinaryMemberDeclaration(null, methodHandle, method, info, SearchMatch.A_ACCURATE); - } + // fall through impossible match case to remove the reported method + case PatternLocator.IMPOSSIBLE_MATCH: + // Store binary method signatures to avoid multiple computation + if (binaryMethodSignatures == null) { + binaryMethodSignatures = new char[bMethodsLength][]; + for (int j=0; j