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 83558 Details for
Bug 210691
[search] Type references position invalid in import references when using "*" pattern
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
v00.txt (text/plain), 4.79 KB, created by
Frederic Fusier
on 2007-11-22 13:15:21 EST
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2007-11-22 13:15:21 EST
Size:
4.79 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >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.297 >diff -u -r1.297 MatchLocator.java >--- search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java 21 Nov 2007 09:48:46 -0000 1.297 >+++ search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java 22 Nov 2007 18:11:57 -0000 >@@ -1685,31 +1685,33 @@ > protected void reportAccurateTypeReference(SearchMatch match, ASTNode typeRef, char[] name) throws CoreException { > if (match.getRule() == 0) return; > if (!encloses((IJavaElement)match.getElement())) return; >- >- // Compute source positions of the qualified reference > int sourceStart = typeRef.sourceStart; > int sourceEnd = typeRef.sourceEnd; >- Scanner scanner = this.parser.scanner; >- scanner.setSource(this.currentPossibleMatch.getContents()); >- scanner.resetTo(sourceStart, sourceEnd); >+ >+ // Compute source positions of the qualified reference >+ if (name != null) { >+ Scanner scanner = this.parser.scanner; >+ scanner.setSource(this.currentPossibleMatch.getContents()); >+ scanner.resetTo(sourceStart, sourceEnd); > >- int token = -1; >- int currentPosition; >- do { >- currentPosition = scanner.currentPosition; >- try { >- token = scanner.getNextToken(); >- } catch (InvalidInputException e) { >- // ignore >- } >- if (token == TerminalTokens.TokenNameIdentifier && this.pattern.matchesName(name, scanner.getCurrentTokenSource())) { >- int length = scanner.currentPosition-currentPosition; >- match.setOffset(currentPosition); >- match.setLength(length); >- report(match); >- return; >- } >- } while (token != TerminalTokens.TokenNameEOF); >+ int token = -1; >+ int currentPosition; >+ do { >+ currentPosition = scanner.currentPosition; >+ try { >+ token = scanner.getNextToken(); >+ } catch (InvalidInputException e) { >+ // ignore >+ } >+ if (token == TerminalTokens.TokenNameIdentifier && this.pattern.matchesName(name, scanner.getCurrentTokenSource())) { >+ int length = scanner.currentPosition-currentPosition; >+ match.setOffset(currentPosition); >+ match.setLength(length); >+ report(match); >+ return; >+ } >+ } while (token != TerminalTokens.TokenNameEOF); >+ } > > // Report match > match.setOffset(sourceStart); >#P org.eclipse.jdt.core.tests.model >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.129 >diff -u -r1.129 JavaSearchBugsTests.java >--- src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 8 Nov 2007 16:03:53 -0000 1.129 >+++ src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 22 Nov 2007 18:12:02 -0000 >@@ -6263,8 +6263,7 @@ > IType type = workingCopies[0].getType("I123679"); > search(type, REFERENCES); > assertSearchResults( >- // import reference is not found because package fragment and CU do not exist on disk >- // So, PackageReferenceLocator.isDeclaringPackageFragment(...) returns false and S.E. misses this match >+ "src/test/Test.java [pack.I123679] EXACT_MATCH\n" + > "src/test/Test.java test.Test$StaticClass$Member.parent [I123679] EXACT_MATCH\n" + > "src/test/Test.java test.Test$StaticClass$Member(Object):<anonymous>#1 [I123679] EXACT_MATCH\n" + > "src/test/Test.java test.Test$StaticClass$Member(Object) [I123679] EXACT_MATCH\n" + >@@ -9166,4 +9165,30 @@ > search(method, REFERENCES); > assertSearchResults(""); > } >+ >+/** >+ * @bug 210691: [search] Type references position invalid in import references when using "*" pattern >+ * @test Ensure that all qualified type reference in import references is selected when using "*" pattern >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=210691" >+ */ >+public void testBug210691() throws CoreException { >+ workingCopies = new ICompilationUnit[2]; >+ workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/pack/Test.java", >+ "package pack;\n" + >+ "public class Test {}\n" >+ ); >+ workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/test/Ref.java", >+ "package test;\n" + >+ "import pack.Test;\n" + >+ "public class Ref {\n" + >+ " Test test;\n" + >+ "}\n" >+ ); >+ this.resultCollector.showContext = true; >+ search("*", TYPE, REFERENCES, getJavaSearchWorkingCopiesScope(), this.resultCollector); >+ assertSearchResults( >+ "src/test/Ref.java [import <pack.Test>;] EXACT_MATCH\n" + >+ "src/test/Ref.java test.Ref.test [ <Test> test;] EXACT_MATCH" >+ ); >+} > } >\ No newline at end of file
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 210691
: 83558