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 47342 Details for
Bug 124489
[1.5][search] "Find unused dependencies" misses references to generic types
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
v01bugzilla.txt (text/plain), 18.46 KB, created by
Frederic Fusier
on 2006-08-03 12:28:47 EDT
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2006-08-03 12:28:47 EDT
Size:
18.46 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >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.58 >diff -u -r1.58 PatternLocator.java >--- search/org/eclipse/jdt/internal/core/search/matching/PatternLocator.java 18 Apr 2006 16:28:18 -0000 1.58 >+++ search/org/eclipse/jdt/internal/core/search/matching/PatternLocator.java 3 Aug 2006 16:09:32 -0000 >@@ -432,15 +432,32 @@ > > // Set match raw flag > boolean endPattern = patternTypeArguments==null ? true : depth>=patternTypeArguments.length; >- boolean isRaw = parameterizedBinding.isRawType()|| (parameterizedBinding.arguments==null && parameterizedBinding.type.isGenericType()); >+ TypeBinding[] argumentsBindings = parameterizedBinding.arguments; >+ boolean isRaw = parameterizedBinding.isRawType()|| (argumentsBindings==null && parameterizedBinding.type.isGenericType()); > if (isRaw && !match.isRaw()) { > match.setRaw(isRaw); > } > > // Update match > if (!endPattern && patternTypeArguments != null) { >- char[][] patternArguments = patternTypeArguments[depth]; >- updateMatch(parameterizedBinding.arguments, locator, patternArguments, patternHasTypeParameters); >+ // verify if this is a reference to the generic type itself >+ if (!isRaw && patternHasTypeParameters && argumentsBindings != null) { >+ boolean needUpdate = false; >+ TypeVariableBinding[] typeVariables = parameterizedBinding.type.typeVariables(); >+ for (int i=0, l=argumentsBindings.length; i<l; i++) { >+ if (argumentsBindings[i] != typeVariables[i]) { >+ needUpdate = true; >+ break; >+ } >+ } >+ if (needUpdate) { >+ char[][] patternArguments = patternTypeArguments[depth]; >+ updateMatch(argumentsBindings, locator, patternArguments, patternHasTypeParameters); >+ } >+ } else { >+ char[][] patternArguments = patternTypeArguments[depth]; >+ updateMatch(argumentsBindings, locator, patternArguments, patternHasTypeParameters); >+ } > } > > // Recurse >Index: search/org/eclipse/jdt/core/search/SearchPattern.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchPattern.java,v >retrieving revision 1.62 >diff -u -r1.62 SearchPattern.java >--- search/org/eclipse/jdt/core/search/SearchPattern.java 22 Jun 2006 14:12:26 -0000 1.62 >+++ search/org/eclipse/jdt/core/search/SearchPattern.java 3 Aug 2006 16:09:32 -0000 >@@ -1108,7 +1108,14 @@ > > /** > * Returns a search pattern based on a given Java element. >- * The pattern is used to trigger the appropriate search, and can be parameterized as follows: >+ * The pattern is used to trigger the appropriate search. >+ * <br> >+ * Note that for generic searches, the returned pattern consider {@link #R_ERASURE_MATCH} matches. >+ * If other kind of generic matches (ie. {@link #R_EXACT_MATCH} or {@link #R_EQUIVALENT_MATCH}) >+ * are expected, {@link #createPattern(IJavaElement, int, int)} method need to be used instead with >+ * the explicit match rule specified. >+ * <br> >+ * The pattern can be parameterized as follows: > * > * @param element the Java element the search pattern is based on > * @param limitTo determines the nature of the expected matches >@@ -1150,7 +1157,7 @@ > * @return a search pattern for a Java element or <code>null</code> if the given element is ill-formed > */ > public static SearchPattern createPattern(IJavaElement element, int limitTo) { >- return createPattern(element, limitTo, R_EXACT_MATCH | R_CASE_SENSITIVE); >+ return createPattern(element, limitTo, R_EXACT_MATCH | R_CASE_SENSITIVE | R_ERASURE_MATCH); > } > > /** >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/SearchTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SearchTests.java,v >retrieving revision 1.36 >diff -u -r1.36 SearchTests.java >--- src/org/eclipse/jdt/core/tests/model/SearchTests.java 12 May 2006 08:22:04 -0000 1.36 >+++ src/org/eclipse/jdt/core/tests/model/SearchTests.java 3 Aug 2006 16:09:37 -0000 >@@ -647,7 +647,7 @@ > IJavaSearchConstants.REFERENCES); > > assertPattern( >- "FieldReferencePattern: x.y.z.Foo.field --> int, exact match, case sensitive", >+ "FieldReferencePattern: x.y.z.Foo.field --> int, exact match, case sensitive, erasure only", > searchPattern); > } > >@@ -661,7 +661,7 @@ > IJavaSearchConstants.DECLARATIONS); > > assertPattern( >- "FieldDeclarationPattern: x.y.z.Foo.field --> int, exact match, case sensitive", >+ "FieldDeclarationPattern: x.y.z.Foo.field --> int, exact match, case sensitive, erasure only", > searchPattern); > } > >@@ -675,7 +675,7 @@ > IJavaSearchConstants.ALL_OCCURRENCES); > > assertPattern( >- "FieldCombinedPattern: x.y.z.Foo.field --> int, exact match, case sensitive", >+ "FieldCombinedPattern: x.y.z.Foo.field --> int, exact match, case sensitive, erasure only", > searchPattern); > } > >@@ -689,7 +689,7 @@ > IJavaSearchConstants.REFERENCES); > > assertPattern( >- "PackageReferencePattern: <x.y>, exact match, case sensitive", >+ "PackageReferencePattern: <x.y>, exact match, case sensitive, erasure only", > searchPattern); > } > >@@ -703,7 +703,7 @@ > IJavaSearchConstants.DECLARATIONS); > > assertPattern( >- "MethodDeclarationPattern: x.y.z.Foo.bar() --> void, exact match, case sensitive", >+ "MethodDeclarationPattern: x.y.z.Foo.bar() --> void, exact match, case sensitive, erasure only", > searchPattern); > } > >@@ -717,7 +717,7 @@ > IJavaSearchConstants.REFERENCES); > > assertPattern( >- "MethodReferencePattern: x.y.z.Foo.bar() --> void, exact match, case sensitive", >+ "MethodReferencePattern: x.y.z.Foo.bar() --> void, exact match, case sensitive, erasure only", > searchPattern); > } > >@@ -731,7 +731,7 @@ > IJavaSearchConstants.ALL_OCCURRENCES); > > assertPattern( >- "MethodCombinedPattern: x.y.z.Foo.bar() --> void, exact match, case sensitive", >+ "MethodCombinedPattern: x.y.z.Foo.bar() --> void, exact match, case sensitive, erasure only", > searchPattern); > } > >@@ -745,7 +745,7 @@ > IJavaSearchConstants.DECLARATIONS); > > assertPattern( >- "TypeDeclarationPattern: pkg<x.y.z>, enclosing<>, type<Foo>, exact match, case sensitive", >+ "TypeDeclarationPattern: pkg<x.y.z>, enclosing<>, type<Foo>, exact match, case sensitive, erasure only", > searchPattern); > } > >@@ -759,7 +759,7 @@ > IJavaSearchConstants.REFERENCES); > > assertPattern( >- "TypeReferencePattern: qualification<x.y.z>, type<Foo>, exact match, case sensitive", >+ "TypeReferencePattern: qualification<x.y.z>, type<Foo>, exact match, case sensitive, erasure only", > searchPattern); > } > >@@ -773,7 +773,7 @@ > IJavaSearchConstants.IMPLEMENTORS); > > assertPattern( >- "SuperInterfaceReferencePattern: <I>, exact match, case sensitive", >+ "SuperInterfaceReferencePattern: <I>, exact match, case sensitive, erasure only", > searchPattern); > } > >@@ -787,8 +787,8 @@ > IJavaSearchConstants.ALL_OCCURRENCES); > > assertPattern( >- "TypeDeclarationPattern: pkg<x.y.z>, enclosing<>, type<Foo>, exact match, case sensitive\n" + >- "| TypeReferencePattern: qualification<x.y.z>, type<Foo>, exact match, case sensitive", >+ "TypeDeclarationPattern: pkg<x.y.z>, enclosing<>, type<Foo>, exact match, case sensitive, erasure only\n" + >+ "| TypeReferencePattern: qualification<x.y.z>, type<Foo>, exact match, case sensitive, erasure only", > searchPattern); > } > >@@ -802,7 +802,7 @@ > IJavaSearchConstants.REFERENCES); > > assertPattern( >- "PackageReferencePattern: <x.y.z>, exact match, case sensitive", >+ "PackageReferencePattern: <x.y.z>, exact match, case sensitive, erasure only", > searchPattern); > } > >@@ -816,7 +816,7 @@ > IJavaSearchConstants.REFERENCES); > > assertPattern( >- "PackageReferencePattern: <x.y.z>, exact match, case sensitive", >+ "PackageReferencePattern: <x.y.z>, exact match, case sensitive, erasure only", > searchPattern); > } > >@@ -830,7 +830,7 @@ > IJavaSearchConstants.REFERENCES); > > assertPattern( >- "TypeReferencePattern: qualification<java.util>, type<Vector>, exact match, case sensitive", >+ "TypeReferencePattern: qualification<java.util>, type<Vector>, exact match, case sensitive, erasure only", > searchPattern); > } > >@@ -844,7 +844,7 @@ > IJavaSearchConstants.DECLARATIONS); > > assertPattern( >- "PackageDeclarationPattern: <x.y.z>, exact match, case sensitive", >+ "PackageDeclarationPattern: <x.y.z>, exact match, case sensitive, erasure only", > searchPattern); > } > >@@ -858,7 +858,7 @@ > IJavaSearchConstants.DECLARATIONS); > > assertPattern( >- "PackageDeclarationPattern: <x.y.z>, exact match, case sensitive", >+ "PackageDeclarationPattern: <x.y.z>, exact match, case sensitive, erasure only", > searchPattern); > } > >@@ -872,7 +872,7 @@ > IJavaSearchConstants.DECLARATIONS); > > assertPattern( >- "PackageDeclarationPattern: <x.y>, exact match, case sensitive", >+ "PackageDeclarationPattern: <x.y>, exact match, case sensitive, erasure only", > searchPattern); > } > >@@ -886,8 +886,8 @@ > IJavaSearchConstants.ALL_OCCURRENCES); > > assertPattern( >- "PackageDeclarationPattern: <x.y.z>, exact match, case sensitive\n" + >- "| PackageReferencePattern: <x.y.z>, exact match, case sensitive", >+ "PackageDeclarationPattern: <x.y.z>, exact match, case sensitive, erasure only\n" + >+ "| PackageReferencePattern: <x.y.z>, exact match, case sensitive, erasure only", > searchPattern); > } > >@@ -901,7 +901,7 @@ > IJavaSearchConstants.DECLARATIONS); > > assertPattern( >- "LocalVarDeclarationPattern: var [in foo() [in X [in X.java [in <default> [in <project root> [in P]]]]]], exact match, case sensitive", >+ "LocalVarDeclarationPattern: var [in foo() [in X [in X.java [in <default> [in <project root> [in P]]]]]], exact match, case sensitive, erasure only", > searchPattern); > } > >@@ -915,7 +915,7 @@ > IJavaSearchConstants.REFERENCES); > > assertPattern( >- "LocalVarReferencePattern: var [in foo() [in X [in X.java [in <default> [in <project root> [in P]]]]]], exact match, case sensitive", >+ "LocalVarReferencePattern: var [in foo() [in X [in X.java [in <default> [in <project root> [in P]]]]]], exact match, case sensitive, erasure only", > searchPattern); > } > >@@ -929,7 +929,7 @@ > IJavaSearchConstants.ALL_OCCURRENCES); > > assertPattern( >- "LocalVarCombinedPattern: var [in foo() [in X [in X.java [in <default> [in <project root> [in P]]]]]], exact match, case sensitive", >+ "LocalVarCombinedPattern: var [in foo() [in X [in X.java [in <default> [in <project root> [in P]]]]]], exact match, case sensitive, erasure only", > searchPattern); > } > >@@ -943,7 +943,7 @@ > IJavaSearchConstants.DECLARATIONS); > > assertPattern( >- "TypeDeclarationPattern: pkg<>, enclosing<X.*>, type<Y>, exact match, case sensitive", >+ "TypeDeclarationPattern: pkg<>, enclosing<X.*>, type<Y>, exact match, case sensitive, erasure only", > searchPattern); > } > >@@ -957,7 +957,7 @@ > IJavaSearchConstants.REFERENCES); > > assertPattern( >- "TypeReferencePattern: qualification<X.*>, type<Y>, exact match, case sensitive", >+ "TypeReferencePattern: qualification<X.*>, type<Y>, exact match, case sensitive, erasure only", > searchPattern); > } > >@@ -971,7 +971,7 @@ > IJavaSearchConstants.DECLARATIONS); > > assertPattern( >- "TypeDeclarationPattern: pkg<>, enclosing<X.*>, type<Y>, exact match, case sensitive", >+ "TypeDeclarationPattern: pkg<>, enclosing<X.*>, type<Y>, exact match, case sensitive, erasure only", > searchPattern); > } > >@@ -985,7 +985,7 @@ > IJavaSearchConstants.REFERENCES); > > assertPattern( >- "TypeReferencePattern: qualification<X.*>, type<Y>, exact match, case sensitive", >+ "TypeReferencePattern: qualification<X.*>, type<Y>, exact match, case sensitive, erasure only", > searchPattern); > } > /** >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.80 >diff -u -r1.80 JavaSearchBugsTests.java >--- src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 23 Jun 2006 15:38:44 -0000 1.80 >+++ src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 3 Aug 2006 16:09:36 -0000 >@@ -1840,7 +1840,7 @@ > "src/b83304/Types.java b83304.Types.gen_wld [Generic] ERASURE_MATCH\n" + > "src/b83304/Types.java b83304.Types.gen_thr [Generic] ERASURE_MATCH\n" + > "src/b83304/Types.java b83304.Types.gen_run [Generic] ERASURE_MATCH\n" + >- "lib/JavaSearch15.jar g1.t.s.def.Generic<T> g1.t.s.def.Generic.foo() ERASURE_MATCH" >+ "lib/JavaSearch15.jar g1.t.s.def.Generic<T> g1.t.s.def.Generic.foo() EXACT_MATCH" > ); > } > public void testBug83304_TypeStringPattern() throws CoreException { >@@ -5514,48 +5514,6 @@ > } > > /** >- * @test Bug 110422: [search] BasicSearchEngine doesn't find all type declarations >- * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=110422" >- */ >-public void testBug110422a() throws CoreException { >- search("TestP", TYPE, DECLARATIONS, SearchPattern.R_PREFIX_MATCH | SearchPattern.R_CASE_SENSITIVE); >- assertSearchResults( >- "lib/b110422.jar b110422.TestPrefix [No source] EXACT_MATCH" >- ); >-} >-public void testBug110422b() throws CoreException { >- search("TESTP", TYPE, DECLARATIONS, SearchPattern.R_PREFIX_MATCH); >- assertSearchResults( >- "lib/b110422.jar b110422.TestPrefix [No source] EXACT_MATCH" >- ); >-} >- >-/** >- * @test Bug 114539: [search] Internal error when refactoring code with errors >- * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=114539" >- */ >-public void testBug114539() throws CoreException { >- workingCopies = new ICompilationUnit[2]; >- workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b114539/Foo.java", >- "package b114539;\n" + >- "public class Foo {\n" + >- " int bar=Bar.FOO;\n" + >- "}\n" >- ); >- workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b114539/Bar.java", >- "package b114539;\n" + >- "public class Bar {\n" + >- " private static final int FOO=0;\n" + >- "}\n" >- ); >- IField field = this.workingCopies[1].getType("Bar").getField("FOO"); >- search(field, REFERENCES); >- assertSearchResults( >- "src/b114539/Foo.java b114539.Foo.bar [FOO] POTENTIAL_MATCH" >- ); >-} >- >-/** > * @test Bug 110336: [plan][search] Should optionaly return the local variable for type reference > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=110336" > */ >@@ -5761,6 +5719,72 @@ > } > > /** >+ * @test Bug 110422: [search] BasicSearchEngine doesn't find all type declarations >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=110422" >+ */ >+public void testBug110422a() throws CoreException { >+ search("TestP", TYPE, DECLARATIONS, SearchPattern.R_PREFIX_MATCH | SearchPattern.R_CASE_SENSITIVE); >+ assertSearchResults( >+ "lib/b110422.jar b110422.TestPrefix [No source] EXACT_MATCH" >+ ); >+} >+public void testBug110422b() throws CoreException { >+ search("TESTP", TYPE, DECLARATIONS, SearchPattern.R_PREFIX_MATCH); >+ assertSearchResults( >+ "lib/b110422.jar b110422.TestPrefix [No source] EXACT_MATCH" >+ ); >+} >+ >+/** >+ * @test Bug 114539: [search] Internal error when refactoring code with errors >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=114539" >+ */ >+public void testBug114539() throws CoreException { >+ workingCopies = new ICompilationUnit[2]; >+ workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b114539/Foo.java", >+ "package b114539;\n" + >+ "public class Foo {\n" + >+ " int bar=Bar.FOO;\n" + >+ "}\n" >+ ); >+ workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b114539/Bar.java", >+ "package b114539;\n" + >+ "public class Bar {\n" + >+ " private static final int FOO=0;\n" + >+ "}\n" >+ ); >+ IField field = this.workingCopies[1].getType("Bar").getField("FOO"); >+ search(field, REFERENCES); >+ assertSearchResults( >+ "src/b114539/Foo.java b114539.Foo.bar [FOO] POTENTIAL_MATCH" >+ ); >+} >+ >+/** >+ * Bug 116459: [search] correct results are missing in java search >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=116459" >+ */ >+public void testBug116459() throws CoreException { >+ workingCopies = new ICompilationUnit[1]; >+ workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/p1/X.java", >+ "package p1;\n" + >+ "class X<T> {\n" + >+ " X<T> gen;\n" + >+ " X<String> param;\n" + >+ " X raw;\n" + >+ "}" >+ ); >+ IType type = workingCopies[0].getType("X"); >+ this.resultCollector.showRule = true; >+ search(type, REFERENCES, ERASURE_RULE); >+ assertSearchResults( >+ "src/p1/X.java p1.X.gen [X] EXACT_MATCH\n" + >+ "src/p1/X.java p1.X.param [X] ERASURE_MATCH\n" + >+ "src/p1/X.java p1.X.raw [X] ERASURE_RAW_MATCH" >+ ); >+} >+ >+/** > * @test Bug 119545: [search] Binary java method model elements returned by SearchEngine have unresolved parameter types > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=119545" > */ >@@ -6184,6 +6208,39 @@ > "" // expected no result as parameters annotations are not stored in class file > ); > } >+ >+/** >+ * Bug 124489: [search] correct results are missing in java search >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=124489" >+ */ >+public void testBug124489() throws CoreException { >+ workingCopies = new ICompilationUnit[2]; >+ workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Foo.java", >+ "public class Foo<T> {}" >+ ); >+ workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/Bar.java", >+ "public class Bar {\n" + >+ " Foo<String> f = new Foo<String>();\n" + >+ " Foo f2 = new Foo();\n" + >+ "}" >+ ); >+ IType type = workingCopies[0].getType("Foo"); >+ this.resultCollector.showRule = true; >+ new SearchEngine(workingCopies).search( >+ SearchPattern.createPattern(type, REFERENCES), >+ new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, >+ getJavaSearchScopeBugs(), >+ this.resultCollector, >+ null >+ ); >+ assertSearchResults( >+ "src/Bar.java Bar.f [Foo] ERASURE_MATCH\n" + >+ "src/Bar.java Bar.f [Foo] ERASURE_MATCH\n" + >+ "src/Bar.java Bar.f2 [Foo] ERASURE_RAW_MATCH\n" + >+ "src/Bar.java Bar.f2 [Foo] ERASURE_RAW_MATCH" >+ ); >+} >+ > /** > * @test Bug 124645: [search] for implementors does not find subclasses of binary classes > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=124645"
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 124489
:
38116
| 47342