Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 178046 Details for
Bug 322979
[search] use of IJavaSearchConstants.IMPLEMENTORS yields surprising results
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Other experimental patch
v05.txt (text/plain), 13.26 KB, created by
Frederic Fusier
on 2010-09-02 10:48:25 EDT
(
hide
)
Description:
Other experimental patch
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2010-09-02 10:48:25 EDT
Size:
13.26 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: search/org/eclipse/jdt/internal/core/search/matching/SuperTypeReferenceLocator.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperTypeReferenceLocator.java,v >retrieving revision 1.18 >diff -u -r1.18 SuperTypeReferenceLocator.java >--- search/org/eclipse/jdt/internal/core/search/matching/SuperTypeReferenceLocator.java 18 Sep 2008 15:24:57 -0000 1.18 >+++ search/org/eclipse/jdt/internal/core/search/matching/SuperTypeReferenceLocator.java 2 Sep 2010 14:42:47 -0000 >@@ -38,6 +38,7 @@ > return nodeSet.addMatch(node, this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH); > > char[] typeRefSimpleName = null; >+ removeTypeArgumentsMatches(node, nodeSet); > if (node instanceof SingleTypeReference) { > typeRefSimpleName = ((SingleTypeReference) node).token; > } else { // QualifiedTypeReference >@@ -73,6 +74,45 @@ > protected int referenceType() { > return IJavaElement.TYPE; > } >+/* >+ * When the type reference is a type argument it cannot be a super type >+ * reference as well. Hence, this method seek through type arguments of >+ * the given type reference if any to remove any corresponding matches already >+ * stored in the node set... >+ * >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=322979" >+ */ >+private void removeTypeArgumentsMatches(TypeReference typeReference, MatchingNodeSet nodeSet) { >+ if (typeReference instanceof ParameterizedSingleTypeReference) { >+ ParameterizedSingleTypeReference parameterizedTypeReference = (ParameterizedSingleTypeReference) typeReference; >+ if (parameterizedTypeReference.typeArguments != null) { >+ removeTypeArgumentsMatches(parameterizedTypeReference.typeArguments, nodeSet); >+ } >+ } >+ if (typeReference instanceof ParameterizedQualifiedTypeReference) { >+ ParameterizedQualifiedTypeReference parameterizedTypeReference = (ParameterizedQualifiedTypeReference) typeReference; >+ if (parameterizedTypeReference.typeArguments != null) { >+ TypeReference[][] typesArguments = parameterizedTypeReference.typeArguments; >+ int length = typesArguments.length; >+ for (int i=0; i<length; i++) { >+ removeTypeArgumentsMatches(typesArguments[i], nodeSet); >+ } >+ } >+ } >+} >+/* >+ * Remove any of the given type arguments from the possible or accurate >+ * matches as they cannot be super type references... >+ */ >+private void removeTypeArgumentsMatches(TypeReference[] typeArguments, MatchingNodeSet nodeSet) { >+ int l = typeArguments == null ? 0 : typeArguments.length; >+ for (int a=0; a<l; a++) { >+ TypeReference typeArgument = typeArguments[a]; >+ if (nodeSet.removePossibleMatch(typeArgument) == null) { >+ nodeSet.removeTrustedMatch(typeArgument); >+ } >+ } >+} > public int resolveLevel(ASTNode node) { > if (!(node instanceof TypeReference)) return IMPOSSIBLE_MATCH; > >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java,v >retrieving revision 1.40 >diff -u -r1.40 AbstractJavaSearchTests.java >--- src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java 25 Nov 2009 12:26:50 -0000 1.40 >+++ src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java 2 Sep 2010 14:42:51 -0000 >@@ -42,10 +42,10 @@ > public static List JAVA_SEARCH_SUITES = null; > protected static IJavaProject JAVA_PROJECT; > protected static boolean COPY_DIRS = true; >- protected static int EXACT_RULE = SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE; >- protected static int EQUIVALENT_RULE = EXACT_RULE | SearchPattern.R_EQUIVALENT_MATCH; >- protected static int ERASURE_RULE = EXACT_RULE | SearchPattern.R_ERASURE_MATCH; >- protected static int RAW_RULE = EXACT_RULE | SearchPattern.R_ERASURE_MATCH | SearchPattern.R_EQUIVALENT_MATCH; >+ protected final static int EXACT_RULE = SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE; >+ protected final static int EQUIVALENT_RULE = EXACT_RULE | SearchPattern.R_EQUIVALENT_MATCH; >+ protected final static int ERASURE_RULE = EXACT_RULE | SearchPattern.R_ERASURE_MATCH; >+ protected final static int RAW_RULE = EXACT_RULE | SearchPattern.R_ERASURE_MATCH | SearchPattern.R_EQUIVALENT_MATCH; > > // ICompilationUnit[] workingCopies; > // boolean discard; >Index: src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java,v >retrieving revision 1.205 >diff -u -r1.205 JavaSearchBugsTests.java >--- src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 2 Sep 2010 09:00:25 -0000 1.205 >+++ src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 2 Sep 2010 14:42:54 -0000 >@@ -12072,6 +12072,209 @@ > } > } > >+static { TESTS_PREFIX = "testBug322979"; } >+public void testBug322979a() throws CoreException { >+ try >+ { >+ IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "", "1.5"); >+ createFile("/P/Test.java", >+ "public class Test extends Object implements Comparable<Object>{\n"+ >+ "public int compareTo(Object o) {\n"+ >+ "return 0;\n"+ >+ "}\n"+ >+ "}\n"); >+ waitUntilIndexesReady(); >+ int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES ; >+ IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, mask); >+ this.resultCollector.showAccuracy(true); >+ this.resultCollector.showSelection(); >+ search("Object", TYPE, IMPLEMENTORS, scope); >+ assertSearchResults( >+ "Test.java Test [public class Test extends !|Object|! implements Comparable<Object>{] EXACT_MATCH" >+ ); >+ } finally { >+ deleteProject("P"); >+ } >+} >+ >+public void testBug322979b() throws CoreException { >+ try >+ { >+ IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "", "1.5"); >+ createFile("/P/Test.java", >+ "public class Test extends java.lang.Object implements Comparable<Object>{\n"+ >+ "public int compareTo(Object o) {\n"+ >+ "return 0;\n"+ >+ "}\n"+ >+ "}\n"); >+ waitUntilIndexesReady(); >+ int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES ; >+ IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, mask); >+ IType type = getClassFile("P", getExternalJCLPathString("1.5"), "java.lang", "Object.class").getType(); >+ this.resultCollector.showAccuracy(true); >+ this.resultCollector.showSelection(); >+ search(type, IMPLEMENTORS, scope); >+ assertSearchResults( >+ "Test.java Test [public class Test extends !|java.lang.Object|! implements Comparable<Object>{] EXACT_MATCH" >+ ); >+ } finally { >+ deleteProject("P"); >+ } >+} >+ >+public void testBug322979c() throws CoreException { >+ try >+ { >+ IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "", "1.5"); >+ createFile("/P/Test.java", >+ "public class Test extends Object implements I01a<Object>, I01b<String>, I01c<Object> {\n" + >+ "}\n" + >+ "interface I01a<T> {}\n" + >+ "interface I01b<T> {}\n" + >+ "interface I01c<T> {}\n" >+ ); >+ waitUntilIndexesReady(); >+ int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES ; >+ IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, mask); >+ this.resultCollector.showSelection(); >+ search("java.lang.Object", TYPE, IMPLEMENTORS, scope); >+ assertSearchResults( >+ "Test.java Test [public class Test extends !|Object|! implements I01a<Object>, I01b<String>, I01c<Object> {] EXACT_MATCH" >+ ); >+ } finally { >+ deleteProject("P"); >+ } >+} >+ >+public void testBug322979d() throws CoreException { >+ try >+ { >+ IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "", "1.5"); >+ createFile("/P/Test.java", >+ "public class Test extends Object implements I01<\n" + >+ " I02<\n" + >+ " I03<Object,\n" + >+ " I02<Object, I01<Object>>,\n" + >+ " I03<Object, I01<Object>, I02<Object, I01<Object>>>\n" + >+ " >,\n" + >+ " I01<Object>>> {\n" + >+ "}\n" + >+ "interface I01<T> {}\n" + >+ "interface I02<T, U> {}\n" + >+ "interface I03<T, U, V> {}\n" >+ ); >+ waitUntilIndexesReady(); >+ int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES ; >+ IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, mask); >+ this.resultCollector.showSelection(); >+ search("Object", TYPE, IMPLEMENTORS, scope); >+ assertSearchResults( >+ "Test.java Test [public class Test extends !|Object|! implements I01<] EXACT_MATCH" >+ ); >+ } finally { >+ deleteProject("P"); >+ } >+} >+ >+public void testBug322979e() throws CoreException { >+ try >+ { >+ IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "", "1.5"); >+ createFile("/P/Test.java", >+ "public class Test extends Object implements I01<\n" + >+ " I02<\n" + >+ " I03<Object,\n" + >+ " I02<Object, I01<Object>>,\n" + >+ " I03<Object, I01<Object>, I02<Object, I01<Object>>>\n" + >+ " >,\n" + >+ " I01<Object>>> {\n" + >+ "}\n" + >+ "interface I01<T> {}\n" + >+ "interface I02<T, U> {}\n" + >+ "interface I03<T, U, V> {}\n" >+ ); >+ waitUntilIndexesReady(); >+ int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES ; >+ IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, mask); >+ this.resultCollector.showSelection(); >+ search("Object", TYPE, REFERENCES, scope); >+ assertSearchResults( >+ "Test.java Test [public class Test extends !|Object|! implements I01<] EXACT_MATCH\n" + >+ "Test.java Test [ I03<!|Object|!,] EXACT_MATCH\n" + >+ "Test.java Test [ I02<!|Object|!, I01<Object>>,] EXACT_MATCH\n" + >+ "Test.java Test [ I02<Object, I01<!|Object|!>>,] EXACT_MATCH\n" + >+ "Test.java Test [ I03<!|Object|!, I01<Object>, I02<Object, I01<Object>>>] EXACT_MATCH\n" + >+ "Test.java Test [ I03<Object, I01<!|Object|!>, I02<Object, I01<Object>>>] EXACT_MATCH\n" + >+ "Test.java Test [ I03<Object, I01<Object>, I02<!|Object|!, I01<Object>>>] EXACT_MATCH\n" + >+ "Test.java Test [ I03<Object, I01<Object>, I02<Object, I01<!|Object|!>>>] EXACT_MATCH\n" + >+ "Test.java Test [ I01<!|Object|!>>> {] EXACT_MATCH\n" + >+ ""+ getExternalJCLPathString("1.5") + " java.lang.Object java.lang.Object.clone() EXACT_MATCH\n" + >+ ""+ getExternalJCLPathString("1.5") + " boolean java.lang.Object.equals(java.lang.Object) EXACT_MATCH\n" + >+ ""+ getExternalJCLPathString("1.5") + " java.lang.Class<? extends java.lang.Object> java.lang.Object.getClass() EXACT_MATCH" >+ ); >+ } finally { >+ deleteProject("P"); >+ } >+} >+ >+public void testBug322979f() throws CoreException { >+ try >+ { >+ IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "", "1.5"); >+ createFile("/P/Test.java", >+ "public class Test extends Object implements I01<\n" + >+ " I02<\n" + >+ " I03<Object,\n" + >+ " I02<Object, I01<Object>>,\n" + >+ " I03<Object, I01<Object>, I02<Object, I01<Object>>>\n" + >+ " >,\n" + >+ " I01<Object>>> {\n" + >+ "}\n" + >+ "interface I01<T> {}\n" + >+ "interface I02<T, U> {}\n" + >+ "interface I03<T, U, V> {}\n" >+ ); >+ waitUntilIndexesReady(); >+ int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES ; >+ IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, mask); >+ this.resultCollector.showSelection(); >+ search("Object", TYPE, REFERENCES | SUPERTYPE_TYPE_REFERENCE, scope); >+ assertSearchResults( >+ "Test.java Test [public class Test extends !|Object|! implements I01<] EXACT_MATCH" >+ ); >+ } finally { >+ deleteProject("P"); >+ } >+} >+ >+public void testBug322979g() throws CoreException { >+ try >+ { >+ IJavaProject project = createJavaProject("P", new String[] {""}, new String[] {"JCL15_LIB"}, "", "1.5"); >+ createFile("/P/Test.java", >+ "public class Test extends Object implements I<A<Object>.B<I<Object>>.C<I<A<Object>.B<Object>.C<Object>>>> {\n" + >+ "}\n" + >+ "interface I<T> {\n" + >+ "}\n" + >+ "class A<T> {\n" + >+ " class B<U> {\n" + >+ " class C<V> {}\n" + >+ " }\n" + >+ "}\n" >+ ); >+ waitUntilIndexesReady(); >+ int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES ; >+ IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, mask); >+ this.resultCollector.showSelection(); >+ search("Object", TYPE, IMPLEMENTORS, scope); >+ assertSearchResults( >+ "Test.java Test [public class Test extends !|Object|! implements I<A<Object>.B<I<Object>>.C<I<A<Object>.B<Object>.C<Object>>>> {] EXACT_MATCH" >+ ); >+ } finally { >+ deleteProject("P"); >+ } >+} >+ > /** > * @bug 324109: [search] Java search shows incorrect results as accurate matches > * @test search of method declaration off missing types should report potential matches and not accurate.
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 322979
:
177717
|
178046
|
178120
|
178133