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 73191 Details for
Bug 195489
[search] References not found while using SearchEngine.searchDeclarationsOfReferencedTypes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
v01.txt (text/plain), 16.12 KB, created by
Frederic Fusier
on 2007-07-06 08:24:10 EDT
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2007-07-06 08:24:10 EDT
Size:
16.12 KB
patch
obsolete
>### 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.162 >diff -u -r1.162 JavaSearchTests.java >--- src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java 10 May 2007 12:28:58 -0000 1.162 >+++ src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java 6 Jul 2007 12:20:08 -0000 >@@ -436,13 +436,17 @@ > */ > public void testDeclarationOfReferencedTypes07() throws CoreException { > IPackageFragment pkg = getPackageFragment("JavaSearch", "src", "r7"); >- searchDeclarationsOfReferencedTypes( >- pkg, >- resultCollector >- ); >- assertSearchResults( >- "", >- this.resultCollector); >+ boolean iae = false; >+ try { >+ searchDeclarationsOfReferencedTypes( >+ pkg, >+ resultCollector >+ ); >+ } catch (IllegalArgumentException exception) { >+ assertSearchResults(""); >+ iae = true; >+ } >+ assertTrue("We should get an IAE!", iae); > } > > /** >@@ -450,7 +454,7 @@ > * (Regression test for bug 47787 IJavaSearchResultCollector.aboutToStart() and done() not called) > */ > public void testDeclarationOfReferencedTypes08() throws CoreException { >- IPackageFragment pkg = getPackageFragment("JavaSearch", "src", "r7"); >+ ICompilationUnit unit = getCompilationUnit("JavaSearch", "src", "r7", "A.java"); > JavaSearchResultCollector result = new JavaSearchResultCollector() { > public void beginReporting() { > addLine("Starting search..."); >@@ -459,10 +463,7 @@ > addLine("Done searching."); > } > }; >- searchDeclarationsOfReferencedTypes( >- pkg, >- result >- ); >+ searchDeclarationsOfReferencedTypes(unit, result); > assertSearchResults( > "Starting search...\n"+ > "Done searching.", >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.111 >diff -u -r1.111 JavaSearchBugsTests.java >--- src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 4 Jul 2007 14:47:28 -0000 1.111 >+++ src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 6 Jul 2007 12:20:02 -0000 >@@ -8129,4 +8129,93 @@ > packageCollector); > } > >+/** >+ * @bug 195489: [search] References not found while using SearchEngine.searchDeclarationsOfReferencedTypes >+ * @test Verify that the type declaration match is always outside the javadoc and that the workaround described in bug 108053 works well >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=108053" >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=195489" >+ */ >+public void testBug195489a() throws CoreException { >+ workingCopies = new ICompilationUnit[1]; >+ workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b195489/Test.java", >+ "package b195489;\n" + >+ "/**\n" + >+ " * @see Ref\n" + >+ " */\n" + >+ "public class Test {\n" + >+ " public Ref ref;\n" + >+ " public Ref getRef() {\n" + >+ " return this.ref;\n" + >+ " }\n" + >+ "}\n" + >+ "class Ref {}" >+ ); >+ this.resultCollector.showInsideDoc = true; >+ new SearchEngine(this.workingCopies).searchDeclarationsOfReferencedTypes(workingCopies[0], this.resultCollector, null); >+ assertSearchResults( >+ "src/b195489/Test.java b195489.Ref [Ref] EXACT_MATCH OUTSIDE_JAVADOC" >+ ); >+} >+public void testBug195489b() throws CoreException { >+ workingCopies = new ICompilationUnit[1]; >+ workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b195489/Test.java", >+ "package b195489;\n" + >+ "public class Test {\n" + >+ " public Ref ref;\n" + >+ " /**\n" + >+ " * @see Ref\n" + >+ " */\n" + >+ " public Ref getRef() {\n" + >+ " return this.ref;\n" + >+ " }\n" + >+ "}\n" + >+ "class Ref {}" >+ ); >+ this.resultCollector.showInsideDoc = true; >+ new SearchEngine(this.workingCopies).searchDeclarationsOfReferencedTypes(workingCopies[0], this.resultCollector, null); >+ assertSearchResults( >+ "src/b195489/Test.java b195489.Ref [Ref] EXACT_MATCH OUTSIDE_JAVADOC" >+ ); >+} >+public void testBug195489c() throws CoreException { >+ workingCopies = new ICompilationUnit[1]; >+ workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b195489/Test.java", >+ "package b195489;\n" + >+ "/**\n" + >+ " * @see Ref\n" + >+ " */\n" + >+ "public class Test {\n" + >+ "}\n" + >+ "class Ref {}" >+ ); >+ this.resultCollector.showInsideDoc = true; >+ new SearchEngine(this.workingCopies).searchDeclarationsOfReferencedTypes(workingCopies[0], this.resultCollector, null); >+ assertSearchResults( >+ "src/b195489/Test.java b195489.Ref [Ref] EXACT_MATCH OUTSIDE_JAVADOC" >+ ); >+} >+// test case for bug 108053 workaround >+public void testBug195489d() throws CoreException { >+ workingCopies = new ICompilationUnit[1]; >+ workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b195489/Test.java", >+ "package b195489;\n" + >+ "/**\n" + >+ " * @see Ref\n" + >+ " */\n" + >+ "public class Test {\n" + >+ "}\n" + >+ "class Ref {}" >+ ); >+ this.resultCollector.showInsideDoc = true; >+ String docCommentSupport = JAVA_PROJECT.getOption(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, true); >+ JAVA_PROJECT.setOption(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.DISABLED); >+ try { >+ new SearchEngine(this.workingCopies).searchDeclarationsOfReferencedTypes(workingCopies[0], this.resultCollector, null); >+ assertSearchResults(""); >+ } >+ finally { >+ JAVA_PROJECT.setOption(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, docCommentSupport); >+ } >+} >+ > } >\ No newline at end of file >#P org.eclipse.jdt.core >Index: search/org/eclipse/jdt/internal/core/search/BasicSearchEngine.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/BasicSearchEngine.java,v >retrieving revision 1.46 >diff -u -r1.46 BasicSearchEngine.java >--- search/org/eclipse/jdt/internal/core/search/BasicSearchEngine.java 2 Apr 2007 11:09:48 -0000 1.46 >+++ search/org/eclipse/jdt/internal/core/search/BasicSearchEngine.java 6 Jul 2007 12:20:17 -0000 >@@ -388,24 +388,19 @@ > } > > /* >- * Returns the list of working copies used to do the search on the given Java element. >+ * Returns the working copy to use to do the search on the given Java element. > */ > private ICompilationUnit[] getWorkingCopies(IJavaElement element) { > if (element instanceof IMember) { > ICompilationUnit cu = ((IMember)element).getCompilationUnit(); > if (cu != null && cu.isWorkingCopy()) { >- ICompilationUnit[] copies = getWorkingCopies(); >- int length = copies == null ? 0 : copies.length; >- if (length > 0) { >- ICompilationUnit[] newWorkingCopies = new ICompilationUnit[length+1]; >- System.arraycopy(copies, 0, newWorkingCopies, 0, length); >- newWorkingCopies[length] = cu; >- return newWorkingCopies; >- } >- return new ICompilationUnit[] {cu}; >+ return new ICompilationUnit[] { cu }; > } >+ } else if (element instanceof ICompilationUnit) { >+ return new ICompilationUnit[] { (ICompilationUnit) element }; > } >- return getWorkingCopies(); >+ >+ return null; > } > > boolean match(char patternTypeSuffix, int modifiers) { >@@ -1169,7 +1164,7 @@ > > /** > * Searches for all declarations of the fields accessed in the given element. >- * The element can be a compilation unit, a source type, or a source method. >+ * The element can be a compilation unit or a source type/method/field. > * Reports the field declarations using the given requestor. > * > * @see SearchEngine#searchDeclarationsOfAccessedFields(IJavaElement, SearchRequestor, IProgressMonitor) >@@ -1179,13 +1174,24 @@ > if (VERBOSE) { > Util.verbose("BasicSearchEngine.searchDeclarationsOfAccessedFields(IJavaElement, SearchRequestor, SearchPattern, IProgressMonitor)"); //$NON-NLS-1$ > } >+ // Do not accept other kind of element type than those specified in the spec >+ switch (enclosingElement.getElementType()) { >+ case IJavaElement.FIELD: >+ case IJavaElement.METHOD: >+ case IJavaElement.TYPE: >+ case IJavaElement.COMPILATION_UNIT: >+ // valid element type >+ break; >+ default: >+ throw new IllegalArgumentException(); >+ } > SearchPattern pattern = new DeclarationOfAccessedFieldsPattern(enclosingElement); > searchDeclarations(enclosingElement, requestor, pattern, monitor); > } > > /** > * Searches for all declarations of the types referenced in the given element. >- * The element can be a compilation unit, a source type, or a source method. >+ * The element can be a compilation unit or a source type/method/field. > * Reports the type declarations using the given requestor. > * > * @see SearchEngine#searchDeclarationsOfReferencedTypes(IJavaElement, SearchRequestor, IProgressMonitor) >@@ -1195,13 +1201,24 @@ > if (VERBOSE) { > Util.verbose("BasicSearchEngine.searchDeclarationsOfReferencedTypes(IJavaElement, SearchRequestor, SearchPattern, IProgressMonitor)"); //$NON-NLS-1$ > } >+ // Do not accept other kind of element type than those specified in the spec >+ switch (enclosingElement.getElementType()) { >+ case IJavaElement.FIELD: >+ case IJavaElement.METHOD: >+ case IJavaElement.TYPE: >+ case IJavaElement.COMPILATION_UNIT: >+ // valid element type >+ break; >+ default: >+ throw new IllegalArgumentException(); >+ } > SearchPattern pattern = new DeclarationOfReferencedTypesPattern(enclosingElement); > searchDeclarations(enclosingElement, requestor, pattern, monitor); > } > > /** > * Searches for all declarations of the methods invoked in the given element. >- * The element can be a compilation unit, a source type, or a source method. >+ * The element can be a compilation unit or a source type/method/field. > * Reports the method declarations using the given requestor. > * > * @see SearchEngine#searchDeclarationsOfSentMessages(IJavaElement, SearchRequestor, IProgressMonitor) >@@ -1211,6 +1228,17 @@ > if (VERBOSE) { > Util.verbose("BasicSearchEngine.searchDeclarationsOfSentMessages(IJavaElement, SearchRequestor, SearchPattern, IProgressMonitor)"); //$NON-NLS-1$ > } >+ // Do not accept other kind of element type than those specified in the spec >+ switch (enclosingElement.getElementType()) { >+ case IJavaElement.FIELD: >+ case IJavaElement.METHOD: >+ case IJavaElement.TYPE: >+ case IJavaElement.COMPILATION_UNIT: >+ // valid element type >+ break; >+ default: >+ throw new IllegalArgumentException(); >+ } > SearchPattern pattern = new DeclarationOfReferencedMethodsPattern(enclosingElement); > searchDeclarations(enclosingElement, requestor, pattern, monitor); > } >Index: search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java,v >retrieving revision 1.294 >diff -u -r1.294 MatchLocator.java >--- search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java 4 Jul 2007 13:59:58 -0000 1.294 >+++ search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java 6 Jul 2007 12:20:22 -0000 >@@ -206,8 +206,10 @@ > } > > public static SearchDocument[] addWorkingCopies(InternalSearchPattern pattern, SearchDocument[] indexMatches, org.eclipse.jdt.core.ICompilationUnit[] copies, SearchParticipant participant) { >+ if (copies == null) return indexMatches; > // working copies take precedence over corresponding compilation units > HashMap workingCopyDocuments = workingCopiesThatCanSeeFocus(copies, pattern.focus, pattern.isPolymorphicSearch(), participant); >+ if (workingCopyDocuments.size() == 0) return indexMatches; > SearchDocument[] matches = null; > int length = indexMatches.length; > for (int i = 0; i < length; i++) { >Index: search/org/eclipse/jdt/core/search/SearchEngine.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchEngine.java,v >retrieving revision 1.141 >diff -u -r1.141 SearchEngine.java >--- search/org/eclipse/jdt/core/search/SearchEngine.java 21 Mar 2007 17:45:10 -0000 1.141 >+++ search/org/eclipse/jdt/core/search/SearchEngine.java 6 Jul 2007 12:20:14 -0000 >@@ -1007,7 +1007,7 @@ > > /** > * Searches for all declarations of the fields accessed in the given element. >- * The element can be a compilation unit, a source type, or a source method. >+ * The element can be a compilation unit or a source type/method/field. > * Reports the field declarations using the given requestor. > * <p> > * Consider the following code: >@@ -1032,7 +1032,7 @@ > * <code>B.value</code> and <code>A.field1</code>. > * </p> > * >- * @param enclosingElement the method, type, or compilation unit to be searched in >+ * @param enclosingElement the field, method, type, or compilation unit to be searched in > * @param requestor a callback object to which each match is reported > * @param monitor the progress monitor used to report progress > * @exception JavaModelException if the search failed. Reasons include: >@@ -1040,6 +1040,7 @@ > * <li>the element doesn't exist</li> > * <li>the classpath is incorrectly set</li> > * </ul> >+ *@exception IllegalArgumentException if the given java element has not the right type > * @since 3.0 > */ > public void searchDeclarationsOfAccessedFields(IJavaElement enclosingElement, SearchRequestor requestor, IProgressMonitor monitor) throws JavaModelException { >@@ -1090,7 +1091,7 @@ > > /** > * Searches for all declarations of the types referenced in the given element. >- * The element can be a compilation unit, a source type, or a source method. >+ * The element can be a compilation unit or a source type/method/field. > * Reports the type declarations using the given requestor. > * <p> > * Consider the following code: >@@ -1115,7 +1116,7 @@ > * would collect the class <code>B</code> and the interface <code>I</code>. > * </p> > * >- * @param enclosingElement the method, type, or compilation unit to be searched in >+ * @param enclosingElement the field, method, type, or compilation unit to be searched in > * @param requestor a callback object to which each match is reported > * @param monitor the progress monitor used to report progress > * @exception JavaModelException if the search failed. Reasons include: >@@ -1123,6 +1124,7 @@ > * <li>the element doesn't exist</li> > * <li>the classpath is incorrectly set</li> > * </ul> >+ *@exception IllegalArgumentException if the given java element has not the right type > * @since 3.0 > */ > public void searchDeclarationsOfReferencedTypes(IJavaElement enclosingElement, SearchRequestor requestor, IProgressMonitor monitor) throws JavaModelException { >@@ -1173,7 +1175,7 @@ > > /** > * Searches for all declarations of the methods invoked in the given element. >- * The element can be a compilation unit, a source type, or a source method. >+ * The element can be a compilation unit or a source type/method/field. > * Reports the method declarations using the given requestor. > * <p> > * Consider the following code: >@@ -1201,7 +1203,7 @@ > * <code>A.foo()</code>, <code>B.foo()</code>, and <code>A.bar()</code>. > * </p> > * >- * @param enclosingElement the method, type, or compilation unit to be searched in >+ * @param enclosingElement the field, method, type or compilation unit to be searched in > * @param requestor a callback object to which each match is reported > * @param monitor the progress monitor used to report progress > * @exception JavaModelException if the search failed. Reasons include: >@@ -1209,6 +1211,7 @@ > * <li>the element doesn't exist</li> > * <li>the classpath is incorrectly set</li> > * </ul> >+ *@exception IllegalArgumentException if the given java element has not the right type > * @since 3.0 > */ > public void searchDeclarationsOfSentMessages(IJavaElement enclosingElement, SearchRequestor requestor, IProgressMonitor monitor) throws JavaModelException {
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 195489
:
73088
| 73191