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 178133 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]
Proposed patch
v07.txt (text/plain), 18.67 KB, created by
Frederic Fusier
on 2010-09-03 07:29:35 EDT
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2010-09-03 07:29:35 EDT
Size:
18.67 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: search/org/eclipse/jdt/internal/core/search/matching/AndLocator.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/AndLocator.java,v >retrieving revision 1.4 >diff -u -r1.4 AndLocator.java >--- search/org/eclipse/jdt/internal/core/search/matching/AndLocator.java 24 Jun 2008 15:23:48 -0000 1.4 >+++ search/org/eclipse/jdt/internal/core/search/matching/AndLocator.java 3 Sep 2010 11:27:51 -0000 >@@ -255,4 +255,13 @@ > } > return level; > } >+/* (non-Javadoc) >+ * @see org.eclipse.jdt.internal.core.search.matching.PatternLocator#setFlavors(int) >+ */ >+void setFlavors(int flavors) { >+ for (int i = 0, length = this.patternLocators.length; i < length; i++) { >+ this.patternLocators[i].setFlavors(flavors); >+ } >+} >+ > } >Index: search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java,v >retrieving revision 1.87 >diff -u -r1.87 MatchLocatorParser.java >--- search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java 11 May 2010 18:47:10 -0000 1.87 >+++ search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java 3 Sep 2010 11:27:51 -0000 >@@ -256,11 +256,13 @@ > } > > protected void consumeClassHeaderExtends() { >+ this.patternLocator.setFlavors(PatternLocator.SUPERTYPE_REF_FLAVOR); > super.consumeClassHeaderExtends(); > if ((this.patternFineGrain & IJavaSearchConstants.SUPERTYPE_TYPE_REFERENCE) != 0) { > TypeDeclaration typeDeclaration = (TypeDeclaration) this.astStack[this.astPtr]; > this.patternLocator.match(typeDeclaration.superclass, this.nodeSet); > } >+ this.patternLocator.setFlavors(PatternLocator.NO_FLAVOR); > } > > protected void consumeClassInstanceCreationExpressionQualifiedWithTypeArguments() { >@@ -283,6 +285,12 @@ > } > } > >+protected void consumeEnterAnonymousClassBody(boolean qualified) { >+ this.patternLocator.setFlavors(PatternLocator.SUPERTYPE_REF_FLAVOR); >+ super.consumeEnterAnonymousClassBody(qualified); >+ this.patternLocator.setFlavors(PatternLocator.NO_FLAVOR); >+} >+ > protected void consumeEnterVariable() { > boolean isLocalDeclaration = this.nestedMethod[this.nestedType] != 0; > super.consumeEnterVariable(); >@@ -337,11 +345,13 @@ > } > } > protected void consumeInterfaceType() { >+ this.patternLocator.setFlavors(PatternLocator.SUPERTYPE_REF_FLAVOR); > super.consumeInterfaceType(); > if ((this.patternFineGrain & IJavaSearchConstants.SUPERTYPE_TYPE_REFERENCE) != 0) { > TypeReference typeReference = (TypeReference) this.astStack[this.astPtr]; > this.patternLocator.match(typeReference, this.nodeSet); > } >+ this.patternLocator.setFlavors(PatternLocator.NO_FLAVOR); > } > > protected void consumeLocalVariableDeclaration() { >Index: search/org/eclipse/jdt/internal/core/search/matching/OrLocator.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/OrLocator.java,v >retrieving revision 1.23 >diff -u -r1.23 OrLocator.java >--- search/org/eclipse/jdt/internal/core/search/matching/OrLocator.java 24 Jun 2008 15:23:48 -0000 1.23 >+++ search/org/eclipse/jdt/internal/core/search/matching/OrLocator.java 3 Sep 2010 11:27:51 -0000 >@@ -307,4 +307,13 @@ > } > return level; > } >+/* (non-Javadoc) >+ * @see org.eclipse.jdt.internal.core.search.matching.PatternLocator#setFlavors(int) >+ */ >+void setFlavors(int flavors) { >+ for (int i = 0, length = this.patternLocators.length; i < length; i++) { >+ this.patternLocators[i].setFlavors(flavors); >+ } >+} >+ > } >Index: search/org/eclipse/jdt/internal/core/search/matching/PatternLocator.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PatternLocator.java,v >retrieving revision 1.78 >diff -u -r1.78 PatternLocator.java >--- search/org/eclipse/jdt/internal/core/search/matching/PatternLocator.java 20 May 2010 14:12:00 -0000 1.78 >+++ search/org/eclipse/jdt/internal/core/search/matching/PatternLocator.java 3 Sep 2010 11:27:51 -0000 >@@ -39,7 +39,9 @@ > public static final int ERASURE_MATCH = 4; > > // Possible rule match flavors >+int flavors = 0; > // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=79866 >+public static final int NO_FLAVOR = 0x0000; > public static final int EXACT_FLAVOR = 0x0010; > public static final int PREFIX_FLAVOR = 0x0020; > public static final int PATTERN_FLAVOR = 0x0040; >@@ -48,6 +50,7 @@ > public static final int SUPER_INVOCATION_FLAVOR = 0x0200; > public static final int SUB_INVOCATION_FLAVOR = 0x0400; > public static final int OVERRIDDEN_METHOD_FLAVOR = 0x0800; >+public static final int SUPERTYPE_REF_FLAVOR = 0x1000; > public static final int MATCH_LEVEL_MASK = 0x0F; > public static final int FLAVORS_MASK = ~MATCH_LEVEL_MASK; > >@@ -436,6 +439,17 @@ > // need to do instance of checks to find out exact type of ASTNode > return IMPOSSIBLE_MATCH; > } >+/** >+ * Set the flavors for which the locator has to be focused on. >+ * If not set, the locator will accept all matches with or without flavors. >+ * When set, the locator will only accept match having the corresponding flavors. >+ * >+ * @param flavors Bits mask specifying the flavors to be accepted or >+ * <code>0</code> to ignore the flavors while accepting matches. >+ */ >+void setFlavors(int flavors) { >+ this.flavors = flavors; >+} > /* > * Update pattern locator match for parameterized top level types. > * Set match raw flag and recurse to enclosing types if any... >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 3 Sep 2010 11:27:51 -0000 >@@ -34,6 +34,7 @@ > //public int match(Reference node, MatchingNodeSet nodeSet) - SKIP IT > //public int match(TypeDeclaration node, MatchingNodeSet nodeSet) - SKIP IT > public int match(TypeReference node, MatchingNodeSet nodeSet) { >+ if (this.flavors != SUPERTYPE_REF_FLAVOR) return IMPOSSIBLE_MATCH; > if (this.pattern.superSimpleName == null) > return nodeSet.addMatch(node, this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_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 3 Sep 2010 11:27:53 -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 3 Sep 2010 11:27:54 -0000 >@@ -12073,6 +12073,246 @@ > } > > /** >+ * @bug 322979: [search] use of IJavaSearchConstants.IMPLEMENTORS yields surprising results >+ * @test search of implementors does no longer report matches in type arguments >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=322979" >+ */ >+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"); >+ } >+} >+public void testBug322979h() 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 I1<String>, I2<Object>{\n"+ >+ "}\n"+ >+ "Interface I1<T> {}\n"+ >+ "Interface I2<T> {}\n"); >+ waitUntilIndexesReady(); >+ int mask = IJavaSearchScope.SOURCES ; >+ IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, mask); >+ this.resultCollector.showAccuracy(true); >+ this.resultCollector.showSelection(); >+ SearchPattern leftPattern = SearchPattern.createPattern( >+ "Object", >+ TYPE, >+ IMPLEMENTORS, >+ EXACT_RULE); >+ SearchPattern rightPattern = SearchPattern.createPattern( >+ "String", >+ TYPE, >+ REFERENCES, >+ EXACT_RULE); >+ search(SearchPattern.createOrPattern(leftPattern, rightPattern), scope, this.resultCollector); >+ assertSearchResults( >+ "Test.java Test [public class Test extends !|Object|! implements I1<String>, I2<Object>{] EXACT_MATCH\n" + >+ "Test.java Test [public class Test extends Object implements I1<!|String|!>, I2<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. > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=324109"
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