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 154621 Details for
Bug 293861
Problem with refactoring when existing jar with invalid package names
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
patch.txt (text/plain), 7.42 KB, created by
Satyam Kandula
on 2009-12-16 21:57:56 EST
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Satyam Kandula
Created:
2009-12-16 21:57:56 EST
Size:
7.42 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: model/org/eclipse/jdt/internal/core/PackageFragment.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragment.java,v >retrieving revision 1.85 >diff -u -r1.85 PackageFragment.java >--- model/org/eclipse/jdt/internal/core/PackageFragment.java 22 Oct 2009 12:29:08 -0000 1.85 >+++ model/org/eclipse/jdt/internal/core/PackageFragment.java 17 Dec 2009 02:05:19 -0000 >@@ -57,9 +57,16 @@ > > public String[] names; > >+ private static final short NOT_INITIALIZED = -1; >+ private static final short VALID = 0; >+ private static final short INVALID = 1; >+ >+ private short packageValid; >+ > protected PackageFragment(PackageFragmentRoot root, String[] names) { > super(root); > this.names = names; >+ this.packageValid = NOT_INITIALIZED; > } > /** > * @see Openable >@@ -390,14 +397,19 @@ > public boolean isDefaultPackage() { > return this.names.length == 0; > } >-private boolean isValidPackageName() { >+public boolean isValidPackageName() { >+ if (this.packageValid != NOT_INITIALIZED) >+ return (this.packageValid == VALID); > JavaProject javaProject = (JavaProject) getJavaProject(); > String sourceLevel = javaProject.getOption(JavaCore.COMPILER_SOURCE, true); > String complianceLevel = javaProject.getOption(JavaCore.COMPILER_COMPLIANCE, true); > for (int i = 0, length = this.names.length; i < length; i++) { >- if (!Util.isValidFolderNameForPackage(this.names[i], sourceLevel, complianceLevel)) >+ if (!Util.isValidFolderNameForPackage(this.names[i], sourceLevel, complianceLevel)) { >+ this.packageValid = INVALID; > return false; >+ } > } >+ this.packageValid = VALID; > return true; > } > /** >Index: search/org/eclipse/jdt/internal/core/search/TypeNameMatchRequestorWrapper.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/TypeNameMatchRequestorWrapper.java,v >retrieving revision 1.15 >diff -u -r1.15 TypeNameMatchRequestorWrapper.java >--- search/org/eclipse/jdt/internal/core/search/TypeNameMatchRequestorWrapper.java 4 Dec 2009 09:12:10 -0000 1.15 >+++ search/org/eclipse/jdt/internal/core/search/TypeNameMatchRequestorWrapper.java 17 Dec 2009 02:05:20 -0000 >@@ -27,6 +27,7 @@ > import org.eclipse.jdt.core.search.TypeNameRequestor; > import org.eclipse.jdt.internal.compiler.env.AccessRestriction; > import org.eclipse.jdt.internal.core.Openable; >+import org.eclipse.jdt.internal.core.PackageFragment; > import org.eclipse.jdt.internal.core.PackageFragmentRoot; > import org.eclipse.jdt.internal.core.util.HandleFactory; > import org.eclipse.jdt.internal.core.util.HashtableOfArrayToObject; >@@ -116,7 +117,8 @@ > // Accept match if the type has been found > if (type != null) { > // hierarchy scopes require one more check: >- if (!(this.scope instanceof HierarchyScope) || ((HierarchyScope)this.scope).enclosesFineGrained(type)) { >+ if ((!(this.scope instanceof HierarchyScope) || ((HierarchyScope) this.scope).enclosesFineGrained(type)) >+ && ((PackageFragment) type.getPackageFragment()).isValidPackageName()) { > > // Create the match > final JavaSearchTypeNameMatch match = new JavaSearchTypeNameMatch(type, modifiers); >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.329 >diff -u -r1.329 MatchLocator.java >--- search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java 1 Dec 2009 10:45:48 -0000 1.329 >+++ search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java 17 Dec 2009 02:05:21 -0000 >@@ -1689,6 +1689,22 @@ > return this.currentPossibleMatch.document.getParticipant(); > } > >+protected boolean filterMatch(SearchMatch match) { >+ >+ // should not look for classes with invalid package names >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=293861 >+ IJavaElement element = (IJavaElement)match.getElement(); >+ if (! (element instanceof PackageFragment)) >+ element = this.currentPossibleMatch.openable.getParent(); >+ if (element != null && !((PackageFragment)element).isValidPackageName()) { >+ if (BasicSearchEngine.VERBOSE) { >+ System.out.println("Filtering out the match " + match.getResource() + " as the packageName is not valid"); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ return true; >+ } >+ return false; >+} >+ > protected void report(SearchMatch match) throws CoreException { > if (match == null) { > if (BasicSearchEngine.VERBOSE) { >@@ -1696,6 +1712,9 @@ > } > return; > } >+ if (filterMatch(match)) { >+ return; >+ } > long start = -1; > if (BasicSearchEngine.VERBOSE) { > start = System.currentTimeMillis(); >#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.184 >diff -u -r1.184 JavaSearchBugsTests.java >--- src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 8 Dec 2009 11:34:01 -0000 1.184 >+++ src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 17 Dec 2009 02:05:31 -0000 >@@ -11070,4 +11070,48 @@ > removeClasspathEntry(JAVA_PROJECT, new Path(libPath)); > } > } >+/** >+ * @bug 293861: Problem with refactoring when existing jar with invalid package names >+ * @test Ensure that the search doesn't return classes with invalid package names >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=293861" >+ */ >+public void testBug293861a() throws CoreException { >+ try >+ { >+ IJavaProject project = createJavaProject("P"); >+ addClasspathEntry(project, JavaCore.newLibraryEntry(new Path("/JavaSearchBugs/lib/b293861.jar"), null, null)); >+ int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES | IJavaSearchScope.REFERENCED_PROJECTS; >+ IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, mask); >+ >+ search("b293861TestFunc", IJavaSearchConstants.METHOD, IJavaSearchConstants.DECLARATIONS, scope); >+ assertSearchResults("No search results expected", "", this.resultCollector); >+ } finally { >+ deleteProject("P"); >+ } >+} >+ >+/* >+ * SearchEngine#searchAllTypeNames should also not return classes with invalid package names >+ */ >+public void testBug293861b() throws CoreException { >+ try >+ { >+ IJavaProject project = createJavaProject("P"); >+ addClasspathEntry(project, JavaCore.newLibraryEntry(new Path("/JavaSearchBugs/lib/b293861.jar"), null, null)); >+ int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES | IJavaSearchScope.REFERENCED_PROJECTS; >+ IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, mask); >+ >+ TypeNameMatchCollector collector = new TypeNameMatchCollector(); >+ new SearchEngine().searchAllTypeNames( >+ null, >+ new char[][] {"b293861Test".toCharArray()}, >+ scope, >+ collector, >+ IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, >+ null); >+ assertSearchResults("No search results expected", "", collector); >+ } finally { >+ deleteProject("P"); >+ } >+} > } >\ 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 293861
:
151012
|
151013
|
151410
|
152146
|
153222
|
153223
|
154621
|
154622
|
154957
|
155298
|
155299
|
155300
|
158473
|
158478
|
159164
|
180736
|
180737
|
180738
|
180739