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 66891 Details for
Bug 186415
[search] Search for package declarations should not return duplicate elements
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
New proposed patch
v04.txt (text/plain), 13.04 KB, created by
Frederic Fusier
on 2007-05-11 12:05:24 EDT
(
hide
)
Description:
New proposed patch
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2007-05-11 12:05:24 EDT
Size:
13.04 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.performance >Index: src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceSearchTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceSearchTests.java,v >retrieving revision 1.33 >diff -u -r1.33 FullSourceWorkspaceSearchTests.java >--- src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceSearchTests.java 24 Apr 2007 11:00:43 -0000 1.33 >+++ src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceSearchTests.java 11 May 2007 14:52:33 -0000 >@@ -12,6 +12,8 @@ > > import java.io.PrintStream; > import java.text.NumberFormat; >+import java.util.ArrayList; >+import java.util.List; > > import junit.framework.Test; > >@@ -19,6 +21,7 @@ > import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.core.runtime.Path; > import org.eclipse.jdt.core.IJavaElement; >+import org.eclipse.jdt.core.IPackageFragment; > import org.eclipse.jdt.core.search.*; > import org.eclipse.jdt.core.tests.model.AbstractJavaModelTests; > import org.eclipse.jdt.internal.core.search.processing.IJob; >@@ -161,7 +164,7 @@ > } > } > >- protected void search(String patternString, int searchFor, int limitTo, IJavaSearchScope scope, JavaSearchResultCollector resultCollector) throws CoreException { >+ protected void search(String patternString, int searchFor, int limitTo, IJavaSearchScope scope, SearchRequestor resultCollector) throws CoreException { > int matchMode = patternString.indexOf('*') != -1 || patternString.indexOf('?') != -1 > ? SearchPattern.R_PATTERN_MATCH > : SearchPattern.R_EXACT_MATCH; >@@ -660,4 +663,87 @@ > commitMeasurements(); > assertPerformance(); > } >+ >+ /** >+ * Performance tests for search: Package Declarations on workspace scope. >+ */ >+ public void testSearchPackageDeclarationsWorkspace() throws CoreException { >+ tagAsSummary("Search workspace package declarations", false); // do NOT put in fingerprint >+ >+ // Wait for indexing end >+ AbstractJavaModelTests.waitUntilIndexesReady(); >+ >+ // Warm up >+ IJavaSearchScope scope = SearchEngine.createWorkspaceScope(); >+ String name = "*"; >+ JavaSearchResultCollector resultCollector = new JavaSearchResultCollector(); >+ for (int i=0 ; i<WARMUP_COUNT; i++) { >+ search(name, PACKAGE, DECLARATIONS, scope, resultCollector); >+ if (i==0) { >+ System.out.println(" - "+INT_FORMAT.format(resultCollector.count)+" package declarations in workspace."); >+ } >+ } >+ >+ // Measures >+ for (int i=0; i<MEASURES_COUNT; i++) { >+ cleanCategoryTableCache(false, scope, resultCollector); >+ runGc(); >+ startMeasuring(); >+ for (int j=0; j<10; j++) >+ search(name, PACKAGE, DECLARATIONS, scope, resultCollector); >+ stopMeasuring(); >+ } >+ >+ // Commit >+ commitMeasurements(); >+ assertPerformance(); >+ } >+ >+ /** >+ * Performance tests for search: Simulate a Goto Package action. >+ * This action searches all package declarations on the entire workspace. >+ * Not activated, as this is more a JDT/UI performance tests, but released >+ * to keep a trace in the repository... >+ */ >+ public void _testGotoPackage() throws CoreException { >+ tagAsSummary("Search package declarations", true); // put in fingerprint >+ >+ // Wait for indexing end >+ AbstractJavaModelTests.waitUntilIndexesReady(); >+ >+ // Warm up >+ IJavaSearchScope scope = SearchEngine.createWorkspaceScope(); >+ String name = "*"; >+ final List packageList= new ArrayList(); >+ SearchRequestor requestor = new SearchRequestor() { >+ public void acceptSearchMatch(SearchMatch match) throws CoreException { >+ IJavaElement enclosingElement= (IJavaElement) match.getElement(); >+ enclosingElement.getElementName(); >+ IPackageFragment pkg= (IPackageFragment) enclosingElement; >+ if (pkg.getCompilationUnits().length == 0 && pkg.getClassFiles().length == 0) { >+ return; >+ } >+ packageList.add(enclosingElement); >+ } >+ }; >+ for (int i=0 ; i<WARMUP_COUNT; i++) { >+ search(name, PACKAGE, DECLARATIONS, scope, requestor); >+ if (i==0) { >+ System.out.println(" - "+INT_FORMAT.format(packageList.size())+" package declarations in workspace."); >+ } >+ } >+ >+ // Measures >+ for (int i=0; i<MEASURES_COUNT; i++) { >+ cleanCategoryTableCache(false, scope, new JavaSearchResultCollector()); >+ runGc(); >+ startMeasuring(); >+ search(name, PACKAGE, DECLARATIONS, scope, requestor); >+ stopMeasuring(); >+ } >+ >+ // Commit >+ commitMeasurements(); >+ assertPerformance(); >+ } > } >#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.291 >diff -u -r1.291 MatchLocator.java >--- search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java 25 Apr 2007 16:59:23 -0000 1.291 >+++ search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java 11 May 2007 14:52:36 -0000 >@@ -1235,42 +1235,52 @@ > return; > } > PackageDeclarationPattern pkgPattern = (PackageDeclarationPattern) searchPattern; >- IPath[] scopeProjectsAndJars = this.scope.enclosingProjectsAndJars(); >- int scopeLength = scopeProjectsAndJars.length; >+ boolean isWorkspaceScope = this.scope == JavaModelManager.getJavaModelManager().getWorkspaceScope(); >+ IPath[] scopeProjectsAndJars = isWorkspaceScope ? null : this.scope.enclosingProjectsAndJars(); >+ int scopeLength = isWorkspaceScope ? 0 : scopeProjectsAndJars.length; > IJavaProject[] projects = JavaModelManager.getJavaModelManager().getJavaModel().getJavaProjects(); >+ SimpleSet packages = new SimpleSet(); > for (int i = 0, length = projects.length; i < length; i++) { > IJavaProject javaProject = projects[i]; > // Verify that project belongs to the scope >- boolean found = false; >- for (int j=0; j<scopeLength; j++) { >- if (projects[i].getPath().equals(scopeProjectsAndJars[j])) { >- found = true; >- break; >+ if (!isWorkspaceScope) { >+ boolean found = false; >+ for (int j=0; j<scopeLength; j++) { >+ if (javaProject.getPath().equals(scopeProjectsAndJars[j])) { >+ found = true; >+ break; >+ } > } >+ if (!found) continue; > } >- if (!found) continue; >+ // Get all project package fragment names > this.nameLookup = ((JavaProject) projects[i]).newNameLookup(this.workingCopies); > IPackageFragment[] packageFragments = this.nameLookup.findPackageFragments(new String(pkgPattern.pkgName), true, true); > int pLength = packageFragments == null ? 0 : packageFragments.length; >+ // Report matches avoiding duplicate names > for (int p=0; p<pLength; p++) { > IPackageFragment fragment = packageFragments[p]; >- IResource resource = fragment.getResource(); >- if (resource == null) // case of a file in an external jar >- resource = javaProject.getProject(); >- try { >- if (encloses(fragment)) { >- SearchMatch match = new PackageDeclarationMatch(fragment, SearchMatch.A_ACCURATE, -1, -1, participant, resource); >- report(match); >+ if (packages.addIfNotIncluded(fragment) == null) continue; >+ if (encloses(fragment)) { >+ IResource resource = fragment.getResource(); >+ if (resource == null) // case of a file in an external jar >+ resource = javaProject.getProject(); >+ try { >+ if (encloses(fragment)) { >+ SearchMatch match = new PackageDeclarationMatch(fragment, SearchMatch.A_ACCURATE, -1, -1, participant, resource); >+ report(match); >+ } >+ } catch (JavaModelException e) { >+ throw e; >+ } catch (CoreException e) { >+ throw new JavaModelException(e); > } >- } catch (JavaModelException e) { >- throw e; >- } catch (CoreException e) { >- throw new JavaModelException(e); > } > } > } > } > } >+//*/ > protected IType lookupType(ReferenceBinding typeBinding) { > if (typeBinding == null) return null; > >#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.106 >diff -u -r1.106 JavaSearchBugsTests.java >--- src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 26 Apr 2007 11:27:42 -0000 1.106 >+++ src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 11 May 2007 14:52:43 -0000 >@@ -3784,8 +3784,9 @@ > " }\n" + > "}\n" > ); >- IPath pathDef = new Path("/JavaSearchBugs/src/b97606/pack/def"); >- IPath pathRef = new Path("/JavaSearchBugs/src/b97606/pack/ref"); >+ IPath rootPath = new Path("/JavaSearchBugs/src/b97606"); >+ IPath pathDef = rootPath.append("pack").append("def"); >+ IPath pathRef = rootPath.append("pack").append("ref"); > try { > createFolder(pathDef); > createFolder(pathRef); >@@ -3803,8 +3804,7 @@ > ); > } > finally { >- deleteFolder(pathDef); >- deleteFolder(pathRef); >+ deleteFolder(rootPath); > } > } > public void testBug97606b() throws CoreException { >@@ -3837,8 +3837,9 @@ > " }\n" + > "}\n" > ); >- IPath pathDef = new Path("/JavaSearchBugs/src/b97606/pack/def"); >- IPath pathRef = new Path("/JavaSearchBugs/src/b97606/pack/ref"); >+ IPath rootPath = new Path("/JavaSearchBugs/src/b97606"); >+ IPath pathDef = rootPath.append("pack").append("def"); >+ IPath pathRef = rootPath.append("pack").append("ref"); > try { > createFolder(pathDef); > createFolder(pathRef); >@@ -3856,8 +3857,7 @@ > ); > } > finally { >- deleteFolder(pathDef); >- deleteFolder(pathRef); >+ deleteFolder(rootPath); > } > } > >@@ -7913,4 +7913,87 @@ > } > } > >+/** >+ * @bug 185452 [search] for all packages seems hung >+ * @test Ensure that all package declarations are found only once >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=185452" >+ */ >+public void testBug185452() throws CoreException { >+ JavaSearchResultCollector packageCollector = new JavaSearchResultCollector(true); >+ search( >+ "*", >+ PACKAGE, >+ DECLARATIONS, >+ SearchEngine.createWorkspaceScope(), >+ packageCollector); >+ assertSearchResults( >+ ""+ getExternalJCLPathString("1.5") + " \n" + >+ ""+ getExternalJCLPathString("1.5") + " java\n" + >+ ""+ getExternalJCLPathString("1.5") + " java.io\n" + >+ ""+ getExternalJCLPathString("1.5") + " java.lang\n" + >+ ""+ getExternalJCLPathString("1.5") + " java.lang.annotation\n" + >+ "lib \n" + >+ "lib/JavaSearch15.jar [No source]\n" + >+ "lib/JavaSearch15.jar g1 [No source]\n" + >+ "lib/JavaSearch15.jar g1.t [No source]\n" + >+ "lib/JavaSearch15.jar g1.t.s [No source]\n" + >+ "lib/JavaSearch15.jar g1.t.s.def [No source]\n" + >+ "lib/JavaSearch15.jar g5 [No source]\n" + >+ "lib/JavaSearch15.jar g5.c [No source]\n" + >+ "lib/JavaSearch15.jar g5.c.def [No source]\n" + >+ "lib/JavaSearch15.jar g5.m [No source]\n" + >+ "lib/JavaSearch15.jar g5.m.def [No source]\n" + >+ "lib/b110422.jar [No source]\n" + >+ "lib/b110422.jar b110422 [No source]\n" + >+ "lib/b123679.jar [No source]\n" + >+ "lib/b123679.jar pack [No source]\n" + >+ "lib/b123679.jar test [No source]\n" + >+ "lib/b124469.jar [No source]\n" + >+ "lib/b124469.jar pack [No source]\n" + >+ "lib/b124469.jar test [No source]\n" + >+ "lib/b124645.jar [No source]\n" + >+ "lib/b124645.jar test [No source]\n" + >+ "lib/b124645.jar xy [No source]\n" + >+ "lib/b125178.jar [No source]\n" + >+ "lib/b125178.jar pack [No source]\n" + >+ "lib/b125178.jar pack.age [No source]\n" + >+ "lib/b126330.jar [No source]\n" + >+ "lib/b128877.jar [No source]\n" + >+ "lib/b128877.jar pack [No source]\n" + >+ "lib/b137984.jar [No source]\n" + >+ "lib/b140156.jar [No source]\n" + >+ "lib/b164791.jar [No source]\n" + >+ "lib/b164791.jar pack [No source]\n" + >+ "lib/b164791.jar test [No source]\n" + >+ "lib/b166348.jar [No source]\n" + >+ "lib/b166348.jar pack [No source]\n" + >+ "lib/b166348.jar test [No source]\n" + >+ "lib/b86293.jar [No source]\n" + >+ "lib/b87627.jar [No source]\n" + >+ "lib/b87627.jar b87627 [No source]\n" + >+ "lib/b89848 b89848\n" + >+ "lib/b95152.jar [No source]\n" + >+ "lib/b95152.jar b95152 [No source]\n" + >+ "lib/test75816.jar [No source]\n" + >+ "lib/test81556.jar [No source]\n" + >+ "lib/test81556.jar b81556 [No source]\n" + >+ "lib/test81556.jar b81556.b [No source]\n" + >+ "src \n" + >+ "src/b108088 b108088\n" + >+ "src/b123679 b123679\n" + >+ "src/b123679/pack b123679.pack\n" + >+ "src/b123679/test b123679.test\n" + >+ "src/b124645 b124645\n" + >+ "src/b124645/test b124645.test\n" + >+ "src/b124645/xy b124645.xy\n" + >+ "src/b127628 b127628\n" + >+ "src/b137984 b137984\n" + >+ "src/b163984 b163984\n" + >+ "src/b81556 b81556\n" + >+ "src/b81556/a b81556.a\n" + >+ "src/b86380 b86380\n" + >+ "src/b95794 b95794", >+ packageCollector); >+} >+ > } >\ 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 186415
:
66723
| 66891