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 115140 Details for
Bug 12044
[search] Should find constant references in .class files with source attached
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
New patch prototype
v06.txt (text/plain), 152.82 KB, created by
Frederic Fusier
on 2008-10-15 08:44:26 EDT
(
hide
)
Description:
New patch prototype
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2008-10-15 08:44:26 EDT
Size:
152.82 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.performance >Index: src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceTests.java,v >retrieving revision 1.51 >diff -u -r1.51 FullSourceWorkspaceTests.java >--- src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceTests.java 3 Oct 2008 12:36:18 -0000 1.51 >+++ src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceTests.java 15 Oct 2008 12:43:23 -0000 >@@ -643,23 +643,17 @@ > System.out.println("("+(System.currentTimeMillis()-start)+"ms)"); > > // Init JRE_LIB variable >- String[] jdkLibs = Util.getJavaClassLibs(); >- int length = jdkLibs.length; >- String jdkLib = null; >- for (int i=0; i<length; i++) { >- if (jdkLibs[i].endsWith("rt.jar")) { >- jdkLib = jdkLibs[i]; >- break; >- } >- } >- if (jdkLib == null) { >- throw new RuntimeException("Cannot set JRE_LIB classpath variable as the rt.jar lib was not found!!!"); >- } >+ IPath jrePath = getJRE(); >+ IPath srcPath = new Path(Util.getJREDirectory()).removeLastSegments(1).append("src.zip"); >+ JavaCore.setClasspathVariables( >+ new String[] {"JRE_LIB", "JRE_SRC"}, >+ new IPath[] {jrePath, srcPath}, >+ null); > > // Set classpaths (workaround bug 73253 Project references not set on project open) > System.out.print("Set projects classpaths..."); > ALL_PROJECTS = JavaCore.create(workspaceRoot).getJavaProjects(); >- length = ALL_PROJECTS.length; >+ int length = ALL_PROJECTS.length; > for (int i = 0; i < length; i++) { > String projectName = ALL_PROJECTS[i].getElementName(); > if (BIG_PROJECT_NAME.equals(projectName)) continue; // will be set later >@@ -683,6 +677,22 @@ > PARSER_WORKING_COPY = (ICompilationUnit) element.getParent(); > } > >+ protected IPath getJRE() { >+ String jdkLib = null; >+ String[] jdkLibs = Util.getJavaClassLibs(); >+ int length = jdkLibs.length; >+ for (int i=0; i<length; i++) { >+ if (jdkLibs[i].endsWith("rt.jar")) { >+ jdkLib = jdkLibs[i]; >+ break; >+ } >+ } >+ if (jdkLib == null) { >+ throw new RuntimeException("Cannot set JRE_LIB classpath variable as the rt.jar lib was not found!!!"); >+ } >+ return new Path(jdkLib); >+ } >+ > /* > * Create JUnit project and add it to the workspace > * >@@ -873,7 +883,7 @@ > // Add JRE_LIB entry > entries[sourceLength] = JavaCore.newVariableEntry( > new Path("JRE_LIB"), >- null, >+ new Path("JRE_SRC"), > null); > > // create project's output folder >Index: src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceCompleteSearchTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceCompleteSearchTests.java,v >retrieving revision 1.6 >diff -u -r1.6 FullSourceWorkspaceCompleteSearchTests.java >--- src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceCompleteSearchTests.java 9 Sep 2008 13:28:49 -0000 1.6 >+++ src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceCompleteSearchTests.java 15 Oct 2008 12:43:23 -0000 >@@ -13,16 +13,26 @@ > import java.io.PrintStream; > import java.text.NumberFormat; > >-import junit.framework.*; >+import junit.framework.Test; > >+import org.eclipse.core.resources.IProject; > import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; > import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.Path; > import org.eclipse.jdt.core.IClassFile; >+import org.eclipse.jdt.core.IClasspathEntry; > import org.eclipse.jdt.core.IField; > import org.eclipse.jdt.core.IJavaElement; > import org.eclipse.jdt.core.IMethod; > import org.eclipse.jdt.core.IType; >-import org.eclipse.jdt.core.search.*; >+import org.eclipse.jdt.core.JavaCore; >+import org.eclipse.jdt.core.JavaModelException; >+import org.eclipse.jdt.core.search.SearchEngine; >+import org.eclipse.jdt.core.search.SearchMatch; >+import org.eclipse.jdt.core.search.SearchParticipant; >+import org.eclipse.jdt.core.search.SearchPattern; >+import org.eclipse.jdt.core.search.SearchRequestor; > import org.eclipse.jdt.core.tests.model.AbstractJavaModelTests; > import org.eclipse.jdt.internal.core.search.processing.IJob; > >@@ -39,6 +49,7 @@ > // Tests counters > private static int TESTS_COUNT = 0; > private final static int ITERATIONS_COUNT = 0; >+ private final static int WARMUP_COUNT = 4; > > // Log file streams > private static PrintStream[] LOG_STREAMS = new PrintStream[DIM_NAMES.length]; >@@ -209,6 +220,53 @@ > } > > /** >+ * Performance tests for search: Indexing one project (JDT/Core). >+ */ >+public void testONLY_IndexingJdkSources() throws CoreException { >+ tagAsSummary("Indexing JDT/Core project", true); // put in fingerprint >+ >+ // Wait for indexes >+ AbstractJavaModelTests.waitUntilIndexesReady(); >+ IProject jdtCoreProject = setJreSource(); >+ IPath jrePath = getJRE(); >+ >+ // Warm-up >+ for (int i=0 ; i<WARMUP_COUNT; i++) { >+ INDEX_MANAGER.removeIndex(jrePath); >+ INDEX_MANAGER.indexAll(jdtCoreProject); >+ AbstractJavaModelTests.waitUntilIndexesReady(); >+ } >+ >+ // Measures >+ for (int i=0; i<MEASURES_COUNT; i++) { >+ runGc(); >+ INDEX_MANAGER.removeIndex(jrePath); >+ INDEX_MANAGER.request(new Measuring(true/*start measuring*/)); >+ INDEX_MANAGER.indexAll(jdtCoreProject); >+ AbstractJavaModelTests.waitUntilIndexesReady(); >+ INDEX_MANAGER.request(new Measuring(false /*end measuring*/)); >+ AbstractJavaModelTests.waitUntilIndexesReady(); >+ } >+ >+ // Commit >+ commitMeasurements(); >+ assertPerformance(); >+} >+ >+private IProject setJreSource() throws JavaModelException { >+ IProject jdtCoreProject = JDT_CORE_PROJECT.getProject(); >+ IClasspathEntry[] entries = JDT_CORE_PROJECT.getRawClasspath(); >+ for (int i=0; i<entries.length; i++) { >+ IClasspathEntry entry = entries[i]; >+ if (entry.getPath().toString().equals("JRE_LIB")) { >+ entries[i] = JavaCore.newVariableEntry(entry.getPath(), new Path("JRE_SRC"), null); >+ } >+ } >+ JDT_CORE_PROJECT.setRawClasspath(entries, null); >+ return jdtCoreProject; >+} >+ >+/** > * Performance tests for search types in workspace: > * <ul> > * <li>declarations using string pattern</i> >#P org.eclipse.jdt.core >Index: model/org/eclipse/jdt/internal/core/SourceMapper.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMapper.java,v >retrieving revision 1.139 >diff -u -r1.139 SourceMapper.java >--- model/org/eclipse/jdt/internal/core/SourceMapper.java 29 Aug 2008 18:53:24 -0000 1.139 >+++ model/org/eclipse/jdt/internal/core/SourceMapper.java 15 Oct 2008 12:43:25 -0000 >@@ -934,7 +934,6 @@ > } > > >- > /** > * Returns the SourceRange for the name of the given element, or > * {-1, -1} if no source range is known for the name of the element. >@@ -1327,4 +1326,116 @@ > return false; > } > >+ //*************************************************************** >+ >+ /** >+ * Locates and returns source code for the given (binary) type, in this >+ * SourceMapper's ZIP file, or returns <code>null</code> if source >+ * code cannot be found. >+ */ >+ public Object findSourceFile(IType type, IBinaryType info) { >+ if (!type.isBinary()) { >+ return null; >+ } >+ String simpleSourceFileName = ((BinaryType) type).getSourceFileName(info); >+ if (simpleSourceFileName == null) { >+ return null; >+ } >+ return findSourceFile(type, simpleSourceFileName); >+ } >+ >+ /** >+ * Locates and returns source code for the given (binary) type, in this >+ * SourceMapper's ZIP file, or returns <code>null</code> if source >+ * code cannot be found. >+ * The given simpleSourceFileName is the .java file name (without the enclosing >+ * folder) used to create the given type (e.g. "A.java" for x/y/A$Inner.class) >+ */ >+ public Object findSourceFile(IType type, String simpleSourceFileName) { >+ long time = 0; >+ if (VERBOSE) { >+ time = System.currentTimeMillis(); >+ } >+ PackageFragment pkgFrag = (PackageFragment) type.getPackageFragment(); >+ String name = org.eclipse.jdt.internal.core.util.Util.concatWith(pkgFrag.names, simpleSourceFileName, '/'); >+ >+ Object sourceFile = null; >+ >+ if (this.rootPath != null) { >+ sourceFile = getSourceFileForRootPath(this.rootPath, name); >+ } >+ >+ if (sourceFile == null) { >+ computeAllRootPaths(type); >+ if (this.rootPaths != null) { >+ loop: for (Iterator iterator = this.rootPaths.iterator(); iterator.hasNext(); ) { >+ String currentRootPath = (String) iterator.next(); >+ if (!currentRootPath.equals(this.rootPath)) { >+ sourceFile = getSourceFileForRootPath(currentRootPath, name); >+ if (sourceFile != null) { >+ // remember right root path >+ this.rootPath = currentRootPath; >+ break loop; >+ } >+ } >+ } >+ } >+ } >+ if (VERBOSE) { >+ System.out.println("spent " + (System.currentTimeMillis() - time) + "ms for " + type.getElementName()); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ return sourceFile; >+ } >+ >+ private Object getSourceFileForRootPath(String currentRootPath, String name) { >+ String newFullName; >+ if (!currentRootPath.equals(IPackageFragmentRoot.DEFAULT_PACKAGEROOT_PATH)) { >+ if (currentRootPath.endsWith("/")) { //$NON-NLS-1$ >+ newFullName = currentRootPath + name; >+ } else { >+ newFullName = currentRootPath + '/' + name; >+ } >+ } else { >+ newFullName = name; >+ } >+ return getSourceFile(newFullName); >+ } >+ >+ private Object getSourceFile(String fullName) { >+ Object target = JavaModel.getTarget(this.sourcePath, true); >+ if (target instanceof IContainer) { >+ IResource res = ((IContainer)target).findMember(fullName); >+ if (res instanceof IFile) { >+ return res; >+ } >+ } else { >+ // try to get the entry >+ ZipEntry entry = null; >+ ZipFile zip = null; >+ JavaModelManager manager = JavaModelManager.getJavaModelManager(); >+ try { >+ zip = manager.getZipFile(this.sourcePath); >+ entry = zip.getEntry(fullName); >+ if (entry != null) { >+ return entry; >+ } >+ } catch (CoreException e) { >+ return null; >+ } finally { >+ manager.closeZipFile(zip); // handle null case >+ } >+ } >+ return null; >+ } >+ >+ public ZipFile getSourceZipFile() { >+ JavaModelManager manager = JavaModelManager.getJavaModelManager(); >+ try { >+ return manager.getZipFile(this.sourcePath); >+ } catch (CoreException e) { >+ // ignore >+ } >+ return null; >+ } >+ > } >Index: model/org/eclipse/jdt/internal/core/ClasspathChange.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathChange.java,v >retrieving revision 1.22 >diff -u -r1.22 ClasspathChange.java >--- model/org/eclipse/jdt/internal/core/ClasspathChange.java 9 Oct 2008 08:13:07 -0000 1.22 >+++ model/org/eclipse/jdt/internal/core/ClasspathChange.java 15 Oct 2008 12:43:25 -0000 >@@ -457,6 +457,8 @@ > > int newLength = newResolvedClasspath.length; > int oldLength = this.oldResolvedClasspath.length; >+ >+ // First, look at removed classpath entries > for (int i = 0; i < oldLength; i++) { > int index = classpathContains(newResolvedClasspath, this.oldResolvedClasspath[i]); > if (index == -1) { >@@ -487,20 +489,22 @@ > } > } > >+ // Then, look at created or changed classpath entries > for (int i = 0; i < newLength; i++) { >- int index = classpathContains(this.oldResolvedClasspath, newResolvedClasspath[i]); >+ IClasspathEntry entry = newResolvedClasspath[i]; >+ int index = classpathContains(this.oldResolvedClasspath, entry); > if (index == -1) { > // remote projects are not indexed in this project >- if (newResolvedClasspath[i].getEntryKind() == IClasspathEntry.CPE_PROJECT){ >+ if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT){ > continue; > } > >- // Request indexing >- int entryKind = newResolvedClasspath[i].getEntryKind(); >+ // Request indexing for the removed classpath entry >+ int entryKind = entry.getEntryKind(); > switch (entryKind) { > case IClasspathEntry.CPE_LIBRARY: > boolean pathHasChanged = true; >- IPath newPath = newResolvedClasspath[i].getPath(); >+ IPath newPath = entry.getPath(); > for (int j = 0; j < oldLength; j++) { > IClasspathEntry oldEntry = this.oldResolvedClasspath[j]; > if (oldEntry.getPath().equals(newPath)) { >@@ -509,11 +513,10 @@ > } > } > if (pathHasChanged) { >- indexManager.indexLibrary(newPath, this.project.getProject()); >+ indexManager.indexLibrary(entry, this.project); > } > break; > case IClasspathEntry.CPE_SOURCE: >- IClasspathEntry entry = newResolvedClasspath[i]; > IPath path = entry.getPath(); > char[][] inclusionPatterns = ((ClasspathEntry)entry).fullInclusionPatternChars(); > char[][] exclusionPatterns = ((ClasspathEntry)entry).fullExclusionPatternChars(); >@@ -521,6 +524,17 @@ > break; > } > } >+ // since bug 12044, source attached are indexed instead of class files >+ // hence needs to verify whether the source attachment has changed >+ else if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { >+ IPath srcPath = entry.getSourceAttachmentPath(); >+ IPath oldSrcPath = this.oldResolvedClasspath[index].getSourceAttachmentPath(); >+ if (srcPath == null && oldSrcPath != null) { >+ indexManager.removeIndex(entry.getPath()); >+ } else if (srcPath != null && !srcPath.equals(oldSrcPath)) { >+ indexManager.indexLibrary(entry, this.project); >+ } >+ } > } > } > >Index: model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java,v >retrieving revision 1.133 >diff -u -r1.133 PackageFragmentRoot.java >--- model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java 27 Jun 2008 16:03:50 -0000 1.133 >+++ model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java 15 Oct 2008 12:43:25 -0000 >@@ -573,7 +573,16 @@ > */ > public IPath getSourceAttachmentPath() throws JavaModelException { > if (getKind() != K_BINARY) return null; >+ return sourceAttachmentPath(); >+} > >+/** >+ * @see IPackageFragmentRoot#getSourceAttachmentRootPath() >+ * Returns the same result but without opening the package fragment root. >+ * However, no verification is done on the package fragment root kind, hence >+ * provides an unpredictable result if it is not a {@link IPackageFragmentRoot#K_BINARY}. >+ */ >+public IPath sourceAttachmentPath() throws JavaModelException { > // 1) look source attachment property (set iff attachSource(...) was called > IPath path = getPath(); > String serverPathString= Util.getSourceAttachmentProperty(path); >@@ -618,7 +627,16 @@ > */ > public IPath getSourceAttachmentRootPath() throws JavaModelException { > if (getKind() != K_BINARY) return null; >+ return sourceAttachmentRootPath(); >+} > >+/** >+ * @see IPackageFragmentRoot#getSourceAttachmentRootPath() >+ * Returns the same result but without opening the package fragment root. >+ * However, no verification is done on the package fragment root kind, hence >+ * provides an unpredictable result if it is not a {@link IPackageFragmentRoot#K_BINARY}. >+ */ >+public IPath sourceAttachmentRootPath() throws JavaModelException { > // 1) look source attachment property (set iff attachSource(...) was called > IPath path = getPath(); > String serverPathString= Util.getSourceAttachmentProperty(path); >Index: model/org/eclipse/jdt/internal/core/DeltaProcessor.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessor.java,v >retrieving revision 1.330 >diff -u -r1.330 DeltaProcessor.java >--- model/org/eclipse/jdt/internal/core/DeltaProcessor.java 9 Oct 2008 08:13:07 -0000 1.330 >+++ model/org/eclipse/jdt/internal/core/DeltaProcessor.java 15 Oct 2008 12:43:25 -0000 >@@ -862,8 +862,9 @@ > continue; > } > for (int j = 0; j < entries.length; j++){ >- if (entries[j].getEntryKind() == IClasspathEntry.CPE_LIBRARY) { >- IPath entryPath = entries[j].getPath(); >+ IClasspathEntry entry = entries[j]; >+ if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { >+ IPath entryPath = entry.getPath(); > > if (!archivePathsToRefresh.contains(entryPath)) continue; // not supposed to be refreshed > >@@ -902,7 +903,7 @@ > // first remove the index so that it is forced to be re-indexed > this.manager.indexManager.removeIndex(entryPath); > // then index the jar >- this.manager.indexManager.indexLibrary(entryPath, project.getProject()); >+ this.manager.indexManager.indexLibrary(entry, javaProject); > } else { > externalArchivesStatus.put(entryPath, EXTERNAL_JAR_UNCHANGED); > } >@@ -913,7 +914,7 @@ > externalArchivesStatus.put(entryPath, EXTERNAL_JAR_ADDED); > this.state.getExternalLibTimeStamps().put(entryPath, new Long(newTimeStamp)); > // index the new jar >- this.manager.indexManager.indexLibrary(entryPath, project.getProject()); >+ this.manager.indexManager.indexLibrary(entry, javaProject); > } > } > } else { // internal JAR >@@ -2503,13 +2504,13 @@ > switch (delta.getKind()) { > case IResourceDelta.ADDED: > // index the new jar >- indexManager.indexLibrary(jarPath, root.getJavaProject().getProject()); >+ indexManager.indexPackageFragmentRoot(root); > break; > case IResourceDelta.CHANGED: > // first remove the index so that it is forced to be re-indexed > indexManager.removeIndex(jarPath); > // then index the jar >- indexManager.indexLibrary(jarPath, root.getJavaProject().getProject()); >+ indexManager.indexPackageFragmentRoot(root); > break; > case IResourceDelta.REMOVED: > // the jar was physically removed: remove the index >Index: search/org/eclipse/jdt/internal/core/search/indexing/IndexAllProject.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexAllProject.java,v >retrieving revision 1.87 >diff -u -r1.87 IndexAllProject.java >--- search/org/eclipse/jdt/internal/core/search/indexing/IndexAllProject.java 27 Jun 2008 16:03:49 -0000 1.87 >+++ search/org/eclipse/jdt/internal/core/search/indexing/IndexAllProject.java 15 Oct 2008 12:43:25 -0000 >@@ -77,7 +77,7 @@ > if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY && entry.getPath().equals(projectPath)) { > // the project is also a library folder (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=89815) > // ensure a job exists to index it as a binary folder >- this.manager.indexLibrary(projectPath, this.project); >+ this.manager.indexLibrary(entry, javaProject); > return true; > } > } >Index: search/org/eclipse/jdt/internal/core/search/indexing/AddJarFileToIndex.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddJarFileToIndex.java,v >retrieving revision 1.75 >diff -u -r1.75 AddJarFileToIndex.java >--- search/org/eclipse/jdt/internal/core/search/indexing/AddJarFileToIndex.java 27 Jun 2008 16:03:49 -0000 1.75 >+++ search/org/eclipse/jdt/internal/core/search/indexing/AddJarFileToIndex.java 15 Oct 2008 12:43:25 -0000 >@@ -10,10 +10,9 @@ > *******************************************************************************/ > package org.eclipse.jdt.internal.core.search.indexing; > >-import java.io.File; > import java.io.IOException; >-import java.net.URI; > import java.util.Enumeration; >+import java.util.Map; > import java.util.zip.ZipEntry; > import java.util.zip.ZipFile; > >@@ -22,171 +21,359 @@ > import org.eclipse.core.runtime.IPath; > import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.core.runtime.Path; >+import org.eclipse.jdt.core.IClasspathEntry; >+import org.eclipse.jdt.core.IJavaElement; >+import org.eclipse.jdt.core.IJavaProject; >+import org.eclipse.jdt.core.IPackageFragment; >+import org.eclipse.jdt.core.IPackageFragmentRoot; >+import org.eclipse.jdt.core.IType; >+import org.eclipse.jdt.core.JavaCore; >+import org.eclipse.jdt.core.JavaModelException; >+import org.eclipse.jdt.core.compiler.CharOperation; > import org.eclipse.jdt.core.search.IJavaSearchScope; > import org.eclipse.jdt.core.search.SearchEngine; > import org.eclipse.jdt.core.search.SearchParticipant; >+import org.eclipse.jdt.internal.compiler.SourceElementParser; > import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable; >+import org.eclipse.jdt.internal.compiler.util.SuffixConstants; > import org.eclipse.jdt.internal.compiler.util.Util; >+import org.eclipse.jdt.internal.core.BinaryType; > import org.eclipse.jdt.internal.core.JavaModelManager; >+import org.eclipse.jdt.internal.core.PackageFragmentRoot; >+import org.eclipse.jdt.internal.core.SourceMapper; > import org.eclipse.jdt.internal.core.index.Index; > import org.eclipse.jdt.internal.core.search.JavaSearchDocument; > import org.eclipse.jdt.internal.core.search.processing.JobManager; >+import org.eclipse.jdt.internal.core.util.HashtableOfArrayToObject; > > class AddJarFileToIndex extends IndexRequest { > > private static final char JAR_SEPARATOR = IJavaSearchScope.JAR_FILE_ENTRY_SEPARATOR.charAt(0); > IFile resource; >+ SourceMapper sourceMapper; >+ IPath sourcePath; >+ IJavaProject javaProject; >+ IPackageFragmentRoot packageFragmentRoot; >+ private HashtableOfArrayToObject packageHandles = new HashtableOfArrayToObject(); >+ >+public AddJarFileToIndex(IFile resource, IndexManager manager) { >+ super(resource.getFullPath(), manager); >+ this.resource = resource; >+} >+public AddJarFileToIndex(IPath jarPath, IndexManager manager) { >+ // external JAR scenario - no resource >+ super(jarPath, manager); >+} >+ >+private IType createTypeFromJar(String classFilePath) throws JavaModelException { >+ String[] simpleNames = new Path(classFilePath).segments(); >+ String[] pkgName; >+ int length = simpleNames.length-1; >+ if (length > 0) { >+ pkgName = new String[length]; >+ System.arraycopy(simpleNames, 0, pkgName, 0, length); >+ } else { >+ pkgName = CharOperation.NO_STRINGS; >+ } >+ IPackageFragment pkgFragment= (IPackageFragment) this.packageHandles.get(pkgName); >+ if (pkgFragment == null) { >+ pkgFragment= ((PackageFragmentRoot)this.packageFragmentRoot).getPackageFragment(pkgName); >+ this.packageHandles.put(pkgName, pkgFragment); >+ } >+ return pkgFragment.getClassFile(simpleNames[length]).getType(); >+} > >- public AddJarFileToIndex(IFile resource, IndexManager manager) { >- super(resource.getFullPath(), manager); >- this.resource = resource; >- } >- public AddJarFileToIndex(IPath jarPath, IndexManager manager) { >- // external JAR scenario - no resource >- super(jarPath, manager); >- } >- public boolean equals(Object o) { >- if (o instanceof AddJarFileToIndex) { >- if (this.resource != null) >- return this.resource.equals(((AddJarFileToIndex) o).resource); >- if (this.containerPath != null) >- return this.containerPath.equals(((AddJarFileToIndex) o).containerPath); >+void setJavaProject(IJavaProject javaProject) { >+ this.javaProject = javaProject; >+} >+ >+void setSourceMapper(IClasspathEntry classpathEntry) { >+ this.sourcePath = classpathEntry.getSourceAttachmentPath(); >+ IPath rootPath = classpathEntry.getSourceAttachmentRootPath(); >+ if (this.sourcePath != null) { >+ Map options = this.javaProject == null >+ ? JavaCore.getOptions() >+ : this.javaProject.getOptions(true); >+ this.sourceMapper = new SourceMapper( >+ this.sourcePath , >+ rootPath == null ? null : rootPath.toOSString(), >+ options); >+ } >+ if (this.javaProject != null) { >+ try { >+ IPackageFragmentRoot root= this.javaProject.findPackageFragmentRoot(classpathEntry.getPath()); >+ this.packageFragmentRoot = root; >+ } >+ catch (JavaModelException jme) { >+ // ignore > } >- return false; > } >- public int hashCode() { >+} >+ >+void setSourceMapper(IPackageFragmentRoot fragmentRoot) { >+ this.packageFragmentRoot = fragmentRoot; >+ if (this.javaProject == null) { >+ this.javaProject = fragmentRoot.getJavaProject(); >+ } >+ try { >+ this.sourcePath = ((PackageFragmentRoot)fragmentRoot).sourceAttachmentPath(); >+ if (this.sourcePath == null) { >+ this.sourcePath = fragmentRoot.getPath(); >+ } >+ IPath rootPath = ((PackageFragmentRoot)fragmentRoot).sourceAttachmentRootPath(); >+ this.sourceMapper = new SourceMapper( >+ this.sourcePath, >+ rootPath == null ? null : rootPath.toOSString(), >+ this.javaProject.getOptions(true)); >+ } catch (JavaModelException e) { >+ // skip >+ } >+} >+ >+public boolean equals(Object o) { >+ if (o instanceof AddJarFileToIndex) { > if (this.resource != null) >- return this.resource.hashCode(); >+ return this.resource.equals(((AddJarFileToIndex) o).resource); > if (this.containerPath != null) >- return this.containerPath.hashCode(); >- return -1; >+ return this.containerPath.equals(((AddJarFileToIndex) o).containerPath); > } >- public boolean execute(IProgressMonitor progressMonitor) { >+ return false; >+} >+public int hashCode() { >+ if (this.resource != null) >+ return this.resource.hashCode(); >+ if (this.containerPath != null) >+ return this.containerPath.hashCode(); >+ return -1; >+} >+public boolean execute(IProgressMonitor progressMonitor) { > >- if (this.isCancelled || progressMonitor != null && progressMonitor.isCanceled()) return true; >+ if (this.isCancelled || progressMonitor != null && progressMonitor.isCanceled()) return true; > >+ try { >+ // if index is already cached, then do not perform any check >+ // MUST reset the IndexManager if a jar file is changed >+ Index index = this.manager.getIndexForUpdate(this.containerPath, false, /*do not reuse index file*/ false /*do not create if none*/); >+ if (index != null) { >+ if (JobManager.VERBOSE) >+ org.eclipse.jdt.internal.core.util.Util.verbose("-> no indexing required (index already exists) for " + this.containerPath); //$NON-NLS-1$ >+ return true; >+ } >+ >+ index = this.manager.getIndexForUpdate(this.containerPath, true, /*reuse index file*/ true /*create if none*/); >+ if (index == null) { >+ if (JobManager.VERBOSE) >+ org.eclipse.jdt.internal.core.util.Util.verbose("-> index could not be created for " + this.containerPath); //$NON-NLS-1$ >+ return true; >+ } >+ ReadWriteMonitor monitor = index.monitor; >+ if (monitor == null) { >+ if (JobManager.VERBOSE) >+ org.eclipse.jdt.internal.core.util.Util.verbose("-> index for " + this.containerPath + " just got deleted"); //$NON-NLS-1$//$NON-NLS-2$ >+ return true; // index got deleted since acquired >+ } >+ index.separator = JAR_SEPARATOR; >+ ZipFile zip = null; >+ ZipFile sourceZip = null; >+ JavaModelManager modelManager = JavaModelManager.getJavaModelManager(); >+ modelManager.cacheZipFiles(); > try { >- // if index is already cached, then do not perform any check >- // MUST reset the IndexManager if a jar file is changed >- Index index = this.manager.getIndexForUpdate(this.containerPath, false, /*do not reuse index file*/ false /*do not create if none*/); >- if (index != null) { >- if (JobManager.VERBOSE) >- org.eclipse.jdt.internal.core.util.Util.verbose("-> no indexing required (index already exists) for " + this.containerPath); //$NON-NLS-1$ >- return true; >- } >+ // this path will be a relative path to the workspace in case the zipfile in the workspace otherwise it will be a path in the >+ // local file system >+ Path zipFilePath = null; >+ >+ monitor.enterWrite(); // ask permission to write >+ if (this.resource != null) { >+ IPath resourcePath = this.resource.getFullPath(); >+ if (JavaModelManager.ZIP_ACCESS_VERBOSE) >+ System.out.println("(" + Thread.currentThread() + ") [AddJarFileToIndex.execute()] Creating ZipFile on " + resourcePath); //$NON-NLS-1$ //$NON-NLS-2$ >+ /* >+ URI location = this.resource.getLocationURI(); >+ if (location == null) return false; >+ if (JavaModelManager.ZIP_ACCESS_VERBOSE) >+ System.out.println("(" + Thread.currentThread() + ") [AddJarFileToIndex.execute()] Creating ZipFile on " + location.getPath()); //$NON-NLS-1$ //$NON-NLS-2$ >+ File file = null; >+ try { >+ file = org.eclipse.jdt.internal.core.util.Util.toLocalFile(location, progressMonitor); >+ } catch (CoreException e) { >+ if (JobManager.VERBOSE) { >+ org.eclipse.jdt.internal.core.util.Util.verbose("-> failed to index " + location.getPath() + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$ >+ e.printStackTrace(); >+ } >+ } >+ if (file == null) { >+ if (JobManager.VERBOSE) >+ org.eclipse.jdt.internal.core.util.Util.verbose("-> failed to index " + location.getPath() + " because the file could not be fetched"); //$NON-NLS-1$ //$NON-NLS-2$ >+ return false; >+ } >+ zip = new ZipFile(file); >+ */ >+ try { >+ zip = modelManager.getZipFile(resourcePath); >+ } catch (CoreException ce) { >+ if (JobManager.VERBOSE) { >+ org.eclipse.jdt.internal.core.util.Util.verbose("-> failed to index " + resourcePath + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$ >+ ce.printStackTrace(); >+ } >+ return false; >+ } >+ zipFilePath = (Path) resourcePath.makeRelative(); >+ // absolute path relative to the workspace > >- index = this.manager.getIndexForUpdate(this.containerPath, true, /*reuse index file*/ true /*create if none*/); >- if (index == null) { >- if (JobManager.VERBOSE) >- org.eclipse.jdt.internal.core.util.Util.verbose("-> index could not be created for " + this.containerPath); //$NON-NLS-1$ >- return true; >+ // Get package fragment root if not already stored >+ if (this.packageFragmentRoot == null) { >+ IJavaElement javaElement = JavaCore.create(this.resource, this.javaProject); >+ if (javaElement.getElementType() == IJavaElement.PACKAGE_FRAGMENT_ROOT) { >+ this.packageFragmentRoot = (IPackageFragmentRoot) javaElement; >+ } >+ } >+ } else { >+ if (JavaModelManager.ZIP_ACCESS_VERBOSE) >+ System.out.println("(" + Thread.currentThread() + ") [AddJarFileToIndex.execute()] Creating ZipFile on " + this.containerPath); //$NON-NLS-1$ //$NON-NLS-2$ >+ // external file -> it is ok to use toFile() >+// zip = new ZipFile(this.containerPath.toFile()); >+ try { >+ zip = modelManager.getZipFile(this.containerPath); >+ } catch (CoreException ce) { >+ if (JobManager.VERBOSE) { >+ org.eclipse.jdt.internal.core.util.Util.verbose("-> failed to index " + this.containerPath + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$ >+ ce.printStackTrace(); >+ } >+ return false; >+ } >+ zipFilePath = (Path) this.containerPath; >+ // path is already canonical since coming from a library classpath entry > } >- ReadWriteMonitor monitor = index.monitor; >- if (monitor == null) { >+ >+ if (this.isCancelled) { > if (JobManager.VERBOSE) >- org.eclipse.jdt.internal.core.util.Util.verbose("-> index for " + this.containerPath + " just got deleted"); //$NON-NLS-1$//$NON-NLS-2$ >- return true; // index got deleted since acquired >+ org.eclipse.jdt.internal.core.util.Util.verbose("-> indexing of " + zip.getName() + " has been cancelled"); //$NON-NLS-1$ //$NON-NLS-2$ >+ return false; > } >- index.separator = JAR_SEPARATOR; >- ZipFile zip = null; >- try { >- // this path will be a relative path to the workspace in case the zipfile in the workspace otherwise it will be a path in the >- // local file system >- Path zipFilePath = null; >- >- monitor.enterWrite(); // ask permission to write >- if (this.resource != null) { >- URI location = this.resource.getLocationURI(); >- if (location == null) return false; >- if (JavaModelManager.ZIP_ACCESS_VERBOSE) >- System.out.println("(" + Thread.currentThread() + ") [AddJarFileToIndex.execute()] Creating ZipFile on " + location.getPath()); //$NON-NLS-1$ //$NON-NLS-2$ >- File file = null; >- try { >- file = org.eclipse.jdt.internal.core.util.Util.toLocalFile(location, progressMonitor); >- } catch (CoreException e) { >- if (JobManager.VERBOSE) { >- org.eclipse.jdt.internal.core.util.Util.verbose("-> failed to index " + location.getPath() + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$ >- e.printStackTrace(); >+ >+ if (JobManager.VERBOSE) >+ org.eclipse.jdt.internal.core.util.Util.verbose("-> indexing " + zip.getName()); //$NON-NLS-1$ >+ long initialTime = System.currentTimeMillis(); >+ >+ String[] paths = index.queryDocumentNames(""); // all file names //$NON-NLS-1$ >+ if (paths != null) { >+ int max = paths.length; >+ /* check integrity of the existing index file >+ * if the length is equal to 0, we want to index the whole jar again >+ * If not, then we want to check that there is no missing entry, if >+ * one entry is missing then we recreate the index >+ */ >+ String EXISTS = "OK"; //$NON-NLS-1$ >+ String DELETED = "DELETED"; //$NON-NLS-1$ >+ SimpleLookupTable indexedFileNames = new SimpleLookupTable(max == 0 ? 33 : max + 11); >+ for (int i = 0; i < max; i++) >+ indexedFileNames.put(paths[i], DELETED); >+ for (Enumeration e = zip.entries(); e.hasMoreElements();) { >+ // iterate each entry to index it >+ ZipEntry ze = (ZipEntry) e.nextElement(); >+ String zipEntryName = ze.getName(); >+ if (Util.isClassFileName(zipEntryName)) >+ indexedFileNames.put(zipEntryName, EXISTS); >+ } >+ boolean needToReindex = indexedFileNames.elementSize != max; // a new file was added >+ if (!needToReindex) { >+ Object[] valueTable = indexedFileNames.valueTable; >+ for (int i = 0, l = valueTable.length; i < l; i++) { >+ if (valueTable[i] == DELETED) { >+ needToReindex = true; // a file was deleted so re-index >+ break; > } > } >- if (file == null) { >+ if (!needToReindex) { > if (JobManager.VERBOSE) >- org.eclipse.jdt.internal.core.util.Util.verbose("-> failed to index " + location.getPath() + " because the file could not be fetched"); //$NON-NLS-1$ //$NON-NLS-2$ >- return false; >+ org.eclipse.jdt.internal.core.util.Util.verbose("-> no indexing required (index is consistent with library) for " //$NON-NLS-1$ >+ + zip.getName() + " (" //$NON-NLS-1$ >+ + (System.currentTimeMillis() - initialTime) + "ms)"); //$NON-NLS-1$ >+ this.manager.saveIndex(index); // to ensure its placed into the saved state >+ return true; > } >- zip = new ZipFile(file); >- zipFilePath = (Path) this.resource.getFullPath().makeRelative(); >- // absolute path relative to the workspace >- } else { >- if (JavaModelManager.ZIP_ACCESS_VERBOSE) >- System.out.println("(" + Thread.currentThread() + ") [AddJarFileToIndex.execute()] Creating ZipFile on " + this.containerPath); //$NON-NLS-1$ //$NON-NLS-2$ >- // external file -> it is ok to use toFile() >- zip = new ZipFile(this.containerPath.toFile()); >- zipFilePath = (Path) this.containerPath; >- // path is already canonical since coming from a library classpath entry >- } >- >- if (this.isCancelled) { >- if (JobManager.VERBOSE) >- org.eclipse.jdt.internal.core.util.Util.verbose("-> indexing of " + zip.getName() + " has been cancelled"); //$NON-NLS-1$ //$NON-NLS-2$ >- return false; > } >+ } > >- if (JobManager.VERBOSE) >- org.eclipse.jdt.internal.core.util.Util.verbose("-> indexing " + zip.getName()); //$NON-NLS-1$ >- long initialTime = System.currentTimeMillis(); >+ // Index the jar for the first time or reindex the jar in case the previous index file has been corrupted >+ // index already existed: recreate it so that we forget about previous entries >+ SearchParticipant participant = SearchEngine.getDefaultSearchParticipant(); >+ index = this.manager.recreateIndex(this.containerPath); >+ if (index == null) { >+ // failed to recreate index, see 73330 >+ this.manager.removeIndex(this.containerPath); >+ return false; >+ } >+ index.separator = JAR_SEPARATOR; > >- String[] paths = index.queryDocumentNames(""); // all file names //$NON-NLS-1$ >- if (paths != null) { >- int max = paths.length; >- /* check integrity of the existing index file >- * if the length is equal to 0, we want to index the whole jar again >- * If not, then we want to check that there is no missing entry, if >- * one entry is missing then we recreate the index >- */ >- String EXISTS = "OK"; //$NON-NLS-1$ >- String DELETED = "DELETED"; //$NON-NLS-1$ >- SimpleLookupTable indexedFileNames = new SimpleLookupTable(max == 0 ? 33 : max + 11); >- for (int i = 0; i < max; i++) >- indexedFileNames.put(paths[i], DELETED); >- for (Enumeration e = zip.entries(); e.hasMoreElements();) { >- // iterate each entry to index it >- ZipEntry ze = (ZipEntry) e.nextElement(); >- String zipEntryName = ze.getName(); >- if (Util.isClassFileName(zipEntryName)) >- indexedFileNames.put(zipEntryName, EXISTS); >+ SourceElementParser parser = null; >+ if (this.sourcePath != null) { >+ index.sourcePath = this.sourcePath.toString(); >+ try { >+ sourceZip = modelManager.getZipFile(this.sourcePath); >+ parser = this.manager.getSourceElementParser(JavaCore.create(this.javaProject.getProject()), null/*requestor will be set by indexer*/); >+ } catch (CoreException ce) { >+ // ignore >+ } >+ } >+ if (zip != null && zip == sourceZip) { >+ // TODO special way to scan the jar file entries when it's also the source attachment >+ ZipEntry[] zipEntries = new ZipEntry[10]; >+ int stackPtr = -1; >+ String previousFileName = null; >+ for (Enumeration e = zip.entries(); e.hasMoreElements();) { >+ if (this.isCancelled) { >+ if (JobManager.VERBOSE) >+ org.eclipse.jdt.internal.core.util.Util.verbose("-> indexing of " + zip.getName() + " has been cancelled"); //$NON-NLS-1$ //$NON-NLS-2$ >+ return false; > } >- boolean needToReindex = indexedFileNames.elementSize != max; // a new file was added >- if (!needToReindex) { >- Object[] valueTable = indexedFileNames.valueTable; >- for (int i = 0, l = valueTable.length; i < l; i++) { >- if (valueTable[i] == DELETED) { >- needToReindex = true; // a file was deleted so re-index >- break; >+ >+ // iterate each entry to index it >+ ZipEntry ze = (ZipEntry) e.nextElement(); >+ String zeName = ze.getName(); >+ if (Util.isClassFileName(zeName)) { >+ String fileName = zeName.substring(0, zeName.length()-SuffixConstants.SUFFIX_CLASS.length); >+ if (previousFileName != null && !(previousFileName.startsWith(fileName) && previousFileName.charAt(fileName.length()) == '$')) { >+ // no source was found for previous class file name => index it now and all member classes as well >+ while (stackPtr >= 0) { >+ ZipEntry previousEntry = zipEntries[stackPtr--]; >+ String previousEntryName = previousEntry.getName(); >+ if (!previousEntryName.startsWith(previousFileName) && previousEntryName.charAt(fileName.length()) != '$') break; >+ final byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getZipEntryByteContent(previousEntry, zip); >+ JavaSearchDocument searchDocument = new JavaSearchDocument(previousEntry, zipFilePath, classFileBytes, participant); >+ this.manager.indexDocument(searchDocument, participant, index, this.containerPath); > } > } >- if (!needToReindex) { >- if (JobManager.VERBOSE) >- org.eclipse.jdt.internal.core.util.Util.verbose("-> no indexing required (index is consistent with library) for " //$NON-NLS-1$ >- + zip.getName() + " (" //$NON-NLS-1$ >- + (System.currentTimeMillis() - initialTime) + "ms)"); //$NON-NLS-1$ >- this.manager.saveIndex(index); // to ensure its placed into the saved state >- return true; >+ previousFileName = fileName; >+ >+ int length = zipEntries.length; >+ if (++stackPtr == length) { >+ // resize (should seldom occur as happen only when local class depth is over 10! >+ System.arraycopy(zipEntries, 0, zipEntries = new ZipEntry[length + (length>>1)], 0, length); > } >+ zipEntries[stackPtr] = ze; >+ } >+ else if (Util.isJavaFileName(zeName) && zeName.startsWith(previousFileName) && zeName.length() == (previousFileName.length()+SuffixConstants.SUFFIX_java.length)) { >+ // this is the source file of previous class files => index it >+ JavaSearchDocument searchDocument = new JavaSearchDocument(zipEntries[stackPtr], zipFilePath, ze, sourceZip, this.sourcePath, participant); >+ searchDocument.setParser(parser); >+ this.manager.indexDocument(searchDocument, participant, index, this.containerPath); >+ stackPtr = -1; // flush entries stack >+ previousFileName = null; > } > } > >- // Index the jar for the first time or reindex the jar in case the previous index file has been corrupted >- // index already existed: recreate it so that we forget about previous entries >- SearchParticipant participant = SearchEngine.getDefaultSearchParticipant(); >- index = this.manager.recreateIndex(this.containerPath); >- if (index == null) { >- // failed to recreate index, see 73330 >- this.manager.removeIndex(this.containerPath); >- return false; >+ // index remaining class files if any >+ while (stackPtr >= 0) { >+ ZipEntry previousEntry = zipEntries[stackPtr--]; >+ final byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getZipEntryByteContent(previousEntry, zip); >+ JavaSearchDocument searchDocument = new JavaSearchDocument(previousEntry, zipFilePath, classFileBytes, participant); >+ this.manager.indexDocument(searchDocument, participant, index, this.containerPath); > } >- index.separator = JAR_SEPARATOR; >- >+ } else { >+ IFile previousSourceFile = null; >+ ZipEntry previousZipEntry = null; >+ ZipEntry previousSourceZipEntry = null; > for (Enumeration e = zip.entries(); e.hasMoreElements();) { > if (this.isCancelled) { > if (JobManager.VERBOSE) >@@ -196,44 +383,109 @@ > > // iterate each entry to index it > ZipEntry ze = (ZipEntry) e.nextElement(); >- if (Util.isClassFileName(ze.getName())) { >- final byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getZipEntryByteContent(ze, zip); >- JavaSearchDocument entryDocument = new JavaSearchDocument(ze, zipFilePath, classFileBytes, participant); >- this.manager.indexDocument(entryDocument, participant, index, this.containerPath); >+ String zeName = ze.getName(); >+ if (Util.isClassFileName(zeName)) { >+ IFile sourceFile = null; >+ ZipEntry sourceZipEntry = null; >+ >+ if (this.sourcePath != null) { >+ IType type = null; >+ try { >+ if (this.packageFragmentRoot != null) { >+ type = createTypeFromJar(zeName); >+ } >+ } catch (JavaModelException jme) { >+ // ignore >+ } >+ if (type != null) { >+ String sourceName = ((BinaryType) type).getSourceFileName(null); >+ Object mappedSource = this.sourceMapper.findSourceFile(type, sourceName); >+ if (mappedSource != null) { >+ if (mappedSource instanceof IFile) { >+ sourceFile = (IFile)mappedSource; >+ } else { >+ sourceZipEntry = (ZipEntry) mappedSource; >+ } >+ } >+ } >+ } >+ if (sourceFile != null) { >+ if (previousSourceFile != null && !sourceFile.equals(previousSourceFile)) { >+ JavaSearchDocument searchDocument = new JavaSearchDocument(previousZipEntry, zipFilePath, previousSourceFile, this.sourcePath, participant); >+ searchDocument.setParser(parser); >+ this.manager.indexDocument(searchDocument, participant, index, this.containerPath); >+ } >+ previousSourceFile = sourceFile; >+ } else if (sourceZipEntry != null) { >+ if (previousSourceZipEntry != null && !sourceZipEntry.getName().equals(previousSourceZipEntry.getName())) { >+ JavaSearchDocument searchDocument = new JavaSearchDocument(previousZipEntry, zipFilePath, previousSourceZipEntry, sourceZip, this.sourcePath, participant); >+ searchDocument.setParser(parser); >+ this.manager.indexDocument(searchDocument, participant, index, this.containerPath); >+ } >+ previousSourceZipEntry = sourceZipEntry; >+ } else { >+ if (previousSourceFile != null) { >+ JavaSearchDocument searchDocument = new JavaSearchDocument(previousZipEntry, zipFilePath, previousSourceFile, this.sourcePath, participant); >+ searchDocument.setParser(parser); >+ this.manager.indexDocument(searchDocument, participant, index, this.containerPath); >+ previousSourceFile = null; >+ } else if (previousSourceZipEntry != null) { >+ JavaSearchDocument searchDocument = new JavaSearchDocument(previousZipEntry, zipFilePath, previousSourceZipEntry, sourceZip, this.sourcePath, participant); >+ searchDocument.setParser(parser); >+ this.manager.indexDocument(searchDocument, participant, index, this.containerPath); >+ previousSourceZipEntry = null; >+ } >+ previousSourceZipEntry = sourceZipEntry; >+ final byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getZipEntryByteContent(ze, zip); >+ JavaSearchDocument searchDocument = new JavaSearchDocument(ze, zipFilePath, classFileBytes, participant); >+ this.manager.indexDocument(searchDocument, participant, index, this.containerPath); >+ } >+ previousZipEntry = ze; > } > } >- this.manager.saveIndex(index); >- if (JobManager.VERBOSE) >- org.eclipse.jdt.internal.core.util.Util.verbose("-> done indexing of " //$NON-NLS-1$ >- + zip.getName() + " (" //$NON-NLS-1$ >- + (System.currentTimeMillis() - initialTime) + "ms)"); //$NON-NLS-1$ >- } finally { >- if (zip != null) { >- if (JavaModelManager.ZIP_ACCESS_VERBOSE) >- System.out.println("(" + Thread.currentThread() + ") [AddJarFileToIndex.execute()] Closing ZipFile " + zip); //$NON-NLS-1$ //$NON-NLS-2$ >- zip.close(); >- } >- monitor.exitWrite(); // free write lock >- } >- } catch (IOException e) { >- if (JobManager.VERBOSE) { >- org.eclipse.jdt.internal.core.util.Util.verbose("-> failed to index " + this.containerPath + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$ >- e.printStackTrace(); >+ >+ // index the remaining source file/zip entry if any >+ if (previousZipEntry != null && (previousSourceFile != null || previousSourceZipEntry != null)) { >+ JavaSearchDocument searchDocument = previousSourceFile != null >+ ? new JavaSearchDocument(previousZipEntry, zipFilePath, previousSourceFile, this.sourcePath, participant) >+ : new JavaSearchDocument(previousZipEntry, zipFilePath, previousSourceZipEntry, sourceZip, this.sourcePath, participant); >+ searchDocument.setParser(parser); >+ this.manager.indexDocument(searchDocument, participant, index, this.containerPath); >+ } > } >- this.manager.removeIndex(this.containerPath); >- return false; >+ this.manager.saveIndex(index); >+ if (JobManager.VERBOSE) >+ org.eclipse.jdt.internal.core.util.Util.verbose("-> done indexing of " //$NON-NLS-1$ >+ + zip.getName() + " (" //$NON-NLS-1$ >+ + (System.currentTimeMillis() - initialTime) + "ms)"); //$NON-NLS-1$ >+ } finally { >+ modelManager.flushZipFiles(); >+// if (zip != null) { >+// if (JavaModelManager.ZIP_ACCESS_VERBOSE) >+// System.out.println("(" + Thread.currentThread() + ") [AddJarFileToIndex.execute()] Closing ZipFile " + zip); //$NON-NLS-1$ //$NON-NLS-2$ >+// zip.close(); >+// } >+ monitor.exitWrite(); // free write lock > } >- return true; >- } >- public String getJobFamily() { >- if (this.resource != null) >- return super.getJobFamily(); >- return this.containerPath.toOSString(); // external jar >- } >- protected Integer updatedIndexState() { >- return IndexManager.REBUILDING_STATE; >- } >- public String toString() { >- return "indexing " + this.containerPath.toString(); //$NON-NLS-1$ >+ } catch (IOException e) { >+ if (JobManager.VERBOSE) { >+ org.eclipse.jdt.internal.core.util.Util.verbose("-> failed to index " + this.containerPath + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$ >+ e.printStackTrace(); >+ } >+ this.manager.removeIndex(this.containerPath); >+ return false; > } >+ return true; >+} >+public String getJobFamily() { >+ if (this.resource != null) >+ return super.getJobFamily(); >+ return this.containerPath.toOSString(); // external jar >+} >+protected Integer updatedIndexState() { >+ return IndexManager.REBUILDING_STATE; >+} >+public String toString() { >+ return "indexing " + this.containerPath.toString(); //$NON-NLS-1$ >+} > } >Index: search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java,v >retrieving revision 1.68 >diff -u -r1.68 BinaryIndexer.java >--- search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java 27 Jun 2008 16:03:49 -0000 1.68 >+++ search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java 15 Oct 2008 12:43:25 -0000 >@@ -27,6 +27,7 @@ > import org.eclipse.jdt.internal.compiler.lookup.TagBits; > import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; > import org.eclipse.jdt.internal.compiler.util.SuffixConstants; >+import org.eclipse.jdt.internal.core.search.JavaSearchDocument; > import org.eclipse.jdt.internal.core.util.Util; > > public class BinaryIndexer extends AbstractIndexer implements SuffixConstants { >@@ -618,7 +619,21 @@ > final byte[] contents = this.document.getByteContents(); > // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=107124 > // contents can potentially be null if a IOException occurs while retrieving the contents >- if (contents == null) return; >+ if (contents == null) { >+ // See if there's some source attached >+ if (this.document instanceof JavaSearchDocument) { >+ JavaSearchDocument javaSearchDocument = (JavaSearchDocument) this.document; >+ if (javaSearchDocument.sourcePath != null) { >+ char[] source = javaSearchDocument.getCharContents(); >+ if (source.length != 0) { >+ // the source exists, then prefer to index it instead of the class file >+ SourceIndexer sourceIndexer = new SourceIndexer(this.document); >+ sourceIndexer.indexDocument(); >+ } >+ } >+ } >+ return; >+ } > final String path = this.document.getPath(); > ClassFileReader reader = new ClassFileReader(contents, path == null ? null : path.toCharArray()); > >Index: search/org/eclipse/jdt/internal/core/search/indexing/IndexManager.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexManager.java,v >retrieving revision 1.162 >diff -u -r1.162 IndexManager.java >--- search/org/eclipse/jdt/internal/core/search/indexing/IndexManager.java 3 Oct 2008 10:47:56 -0000 1.162 >+++ search/org/eclipse/jdt/internal/core/search/indexing/IndexManager.java 15 Oct 2008 12:43:25 -0000 >@@ -380,7 +380,7 @@ > for (int i = 0; i < entries.length; i++) { > IClasspathEntry entry= entries[i]; > if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) >- indexLibrary(entry.getPath(), project); >+ indexLibrary(entry, javaProject); > } > } catch(JavaModelException e){ // cannot retrieve classpath info > } >@@ -394,6 +394,52 @@ > * Trigger addition of a library to an index > * Note: the actual operation is performed in background > */ >+public void indexLibrary(IClasspathEntry classpathEntry, IJavaProject requestingProject) { >+ >+ // Otherwise index it as a jar file >+ IPath path = classpathEntry.getPath(); >+ IndexRequest request = indexLibraryRequest(path); >+ if (request == null) return; >+ if (request instanceof AddJarFileToIndex) { >+ AddJarFileToIndex jarFileRequest = (AddJarFileToIndex) request; >+ jarFileRequest.setJavaProject(requestingProject); >+ jarFileRequest.setSourceMapper(classpathEntry); >+ } >+ if (!isJobWaiting(request)) { >+ request(request); >+ } >+} >+public void indexPackageFragmentRoot(IPackageFragmentRoot fragmentRoot) { >+ IPath path = fragmentRoot.getPath(); >+ IndexRequest request = indexLibraryRequest(path); >+ if (request == null) return; >+ if (request instanceof AddJarFileToIndex) { >+ AddJarFileToIndex jarFileRequest = (AddJarFileToIndex) request; >+ jarFileRequest.setSourceMapper(fragmentRoot); >+ } >+ if (!isJobWaiting(request)) { >+ request(request); >+ } >+} >+private IndexRequest indexLibraryRequest(IPath path) { >+ // requestingProject is no longer used to cancel jobs but leave it here just in case >+ if (JavaCore.getPlugin() == null) return null; >+ >+ Object target = JavaModel.getTarget(path, true); >+ IndexRequest request = null; >+ if (target instanceof IFile) { >+ request = new AddJarFileToIndex((IFile) target, this); >+ } else if (target instanceof File) { >+ request = new AddJarFileToIndex(path, this); >+ } else if (target instanceof IContainer) { >+ request = new IndexBinaryFolder((IContainer) target, this); >+ } >+ return request; >+} >+/** >+ * Trigger addition of a library to an index >+ * Note: the actual operation is performed in background >+ */ > public void indexLibrary(IPath path, IProject requestingProject) { > // requestingProject is no longer used to cancel jobs but leave it here just in case > if (JavaCore.getPlugin() == null) return; >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.12 >diff -u -r1.12 TypeNameMatchRequestorWrapper.java >--- search/org/eclipse/jdt/internal/core/search/TypeNameMatchRequestorWrapper.java 27 Jun 2008 16:04:09 -0000 1.12 >+++ search/org/eclipse/jdt/internal/core/search/TypeNameMatchRequestorWrapper.java 15 Oct 2008 12:43:25 -0000 >@@ -105,7 +105,7 @@ > int separatorIndex= path.indexOf(IJavaSearchScope.JAR_FILE_ENTRY_SEPARATOR); > type = separatorIndex == -1 > ? createTypeFromPath(path, new String(simpleTypeName), enclosingTypeNames) >- : createTypeFromJar(path, separatorIndex); >+ : createTypeFromJar(path, separatorIndex, new String(simpleTypeName), enclosingTypeNames); // need to provide simpleTypeName and enclosing type names when the type has been found in attached source! > } > if (type != null) { > this.requestor.acceptTypeNameMatch(new JavaSearchTypeNameMatch(type, modifiers)); >@@ -114,7 +114,7 @@ > // skip > } > } >-private IType createTypeFromJar(String resourcePath, int separatorIndex) throws JavaModelException { >+private IType createTypeFromJar(String resourcePath, int separatorIndex, String simpleTypeName, char[][] enclosingTypeNames) throws JavaModelException { > // path to a class file inside a jar > // Optimization: cache package fragment root handle and package handles > if (this.lastPkgFragmentRootPath == null >@@ -143,7 +143,20 @@ > pkgFragment= ((PackageFragmentRoot) this.lastPkgFragmentRoot).getPackageFragment(pkgName); > this.packageHandles.put(pkgName, pkgFragment); > } >- return pkgFragment.getClassFile(simpleNames[length]).getType(); >+ String simpleName= simpleNames[length]; >+ IClassFile classFile= pkgFragment.getClassFile(simpleName); >+ IType type = classFile.getType(); >+ int etnLength = enclosingTypeNames == null ? 0 : enclosingTypeNames.length; >+ if (etnLength > 0) { >+ if (etnLength > 0) { >+ for (int i=1; i<etnLength; i++) { >+ type = type.getType(new String(enclosingTypeNames[i])); >+ } >+ type = type.getType(simpleTypeName); >+ } >+ } >+ return type; >+// return pkgFragment.getClassFile(simpleNames[length]).getType(); > } > private IType createTypeFromPath(String resourcePath, String simpleTypeName, char[][] enclosingTypeNames) throws JavaModelException { > // path to a file in a directory >Index: search/org/eclipse/jdt/internal/core/search/JavaSearchDocument.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/JavaSearchDocument.java,v >retrieving revision 1.16 >diff -u -r1.16 JavaSearchDocument.java >--- search/org/eclipse/jdt/internal/core/search/JavaSearchDocument.java 27 Jun 2008 16:04:09 -0000 1.16 >+++ search/org/eclipse/jdt/internal/core/search/JavaSearchDocument.java 15 Oct 2008 12:43:25 -0000 >@@ -10,6 +10,10 @@ > *******************************************************************************/ > package org.eclipse.jdt.internal.core.search; > >+import java.io.IOException; >+import java.util.zip.ZipEntry; >+import java.util.zip.ZipFile; >+ > import org.eclipse.core.resources.IFile; > import org.eclipse.core.resources.ResourcesPlugin; > import org.eclipse.core.runtime.CoreException; >@@ -26,7 +30,10 @@ > > private IFile file; > protected byte[] byteContents; >- protected char[] charContents; >+ public char[] charContents; >+ public ZipFile sourceZip; >+ public ZipEntry sourceEntry; >+ public IPath sourcePath; > > public JavaSearchDocument(String documentPath, SearchParticipant participant) { > super(documentPath, participant); >@@ -35,9 +42,24 @@ > super(zipFilePath + IJavaSearchScope.JAR_FILE_ENTRY_SEPARATOR + zipEntry.getName(), participant); > this.byteContents = contents; > } >+ public JavaSearchDocument(ZipEntry ze, Path zipFilePath, IFile file, IPath srcPath, SearchParticipant participant) { >+ this(ze, zipFilePath, (byte[]) null, participant); >+ this.file = file; >+ this.sourcePath = srcPath; >+ } >+ public JavaSearchDocument(ZipEntry ze, Path zipFilePath, ZipEntry se, ZipFile zip, IPath srcPath, SearchParticipant participant) { >+ this(ze, zipFilePath, (byte[]) null, participant); >+ this.sourceEntry = se; >+ this.sourceZip = zip; >+ this.sourcePath = srcPath; >+ } > > public byte[] getByteContents() { > if (this.byteContents != null) return this.byteContents; >+ if (this.sourcePath != null) { >+ // try to initialize source contents instead >+ if (getCharContents() != null) return null; >+ } > try { > return Util.getResourceContentsAsByteArray(getFile()); > } catch (JavaModelException e) { >@@ -48,15 +70,44 @@ > } > } > public char[] getCharContents() { >- if (this.charContents != null) return this.charContents; >- try { >- return Util.getResourceContentsAsCharArray(getFile()); >- } catch (JavaModelException e) { >- if (BasicSearchEngine.VERBOSE || JobManager.VERBOSE) { // used during search and during indexing >- e.printStackTrace(); >+ if (this.charContents == null) { >+ // The source may be found through an attachment >+ if (this.sourcePath != null) { >+ // a zip entry in an attached source zip >+ if (this.sourceEntry != null) { >+ try { >+ byte[] bytes = org.eclipse.jdt.internal.compiler.util.Util.getZipEntryByteContent(this.sourceEntry, this.sourceZip); >+ if (bytes != null) { >+ return this.charContents = org.eclipse.jdt.internal.compiler.util.Util.bytesToChar(bytes, null); >+ } >+ } catch (IOException e) { >+ // ignore >+ } >+ this.sourceEntry = null; // avoid to read it again >+ return null; >+ } >+ if (this.file != null) { >+ try { >+ return this.charContents = Util.getResourceContentsAsCharArray(this.file); >+ } catch (JavaModelException e) { >+ if (BasicSearchEngine.VERBOSE || JobManager.VERBOSE) { // used during search and during indexing >+ e.printStackTrace(); >+ } >+ } >+ this.file = null; // avoid to read it again >+ return null; >+ } >+ } else { >+ try { >+ return Util.getResourceContentsAsCharArray(getFile()); >+ } catch (JavaModelException e) { >+ if (BasicSearchEngine.VERBOSE || JobManager.VERBOSE) { // used during search and during indexing >+ e.printStackTrace(); >+ } >+ } > } >- return null; > } >+ return this.charContents; > } > public String getEncoding() { > // Return the encoding of the associated file >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.319 >diff -u -r1.319 MatchLocator.java >--- search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java 18 Sep 2008 15:24:57 -0000 1.319 >+++ search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java 15 Oct 2008 12:43:26 -0000 >@@ -2470,7 +2470,12 @@ > } else if (enclosingElement instanceof IMember) { > IMember member = (IMember) parent; > if (member.isBinary()) { >- enclosingElement = ((IClassFile)this.currentPossibleMatch.openable).getType(); >+ IType topLevelType = ((IClassFile)this.currentPossibleMatch.openable).getType(); >+ if (type.name.equals(topLevelType.getElementName())) { >+ enclosingElement = topLevelType; >+ } else { >+ enclosingElement = topLevelType.getType(new String(type.name)); >+ } > } else { > enclosingElement = member.getType(new String(type.name), occurrenceCount); > } >Index: search/org/eclipse/jdt/internal/core/index/Index.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/Index.java,v >retrieving revision 1.31 >diff -u -r1.31 Index.java >--- search/org/eclipse/jdt/internal/core/index/Index.java 27 Jun 2008 16:04:14 -0000 1.31 >+++ search/org/eclipse/jdt/internal/core/index/Index.java 15 Oct 2008 12:43:25 -0000 >@@ -29,6 +29,7 @@ > public class Index { > > public String containerPath; >+public String sourcePath; > public ReadWriteMonitor monitor; > > // Separator to use after the container path >@@ -102,6 +103,9 @@ > public String containerRelativePath(String documentPath) { > int index = documentPath.indexOf(IJavaSearchScope.JAR_FILE_ENTRY_SEPARATOR); > if (index == -1) { >+ if (this.sourcePath != null) { >+ return documentPath; >+ } > index = this.containerPath.length(); > if (documentPath.length() <= index) > throw new IllegalArgumentException("Document path " + documentPath + " must be relative to " + this.containerPath); //$NON-NLS-1$ //$NON-NLS-2$ >#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.179 >diff -u -r1.179 JavaSearchTests.java >--- src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java 9 Sep 2008 12:43:37 -0000 1.179 >+++ src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java 15 Oct 2008 12:43:30 -0000 >@@ -251,7 +251,7 @@ > * (regression test for bug 23112 search: need a way to search for references to the implicit non-arg constructor) > */ > public void testConstructorReference10() throws CoreException { // was testConstructorReferenceImplicitConstructorCall2 >- this.resultCollector.showSynthetic = true; >+ this.resultCollector.showSynthetic(); > search( > "c11.A()", > CONSTRUCTOR, >@@ -814,7 +814,7 @@ > public void testFieldReference03() throws CoreException { > IType type = getCompilationUnit("JavaSearch", "src", "q8", "EclipseTest.java").getType("EclipseTest"); > IField field = type.getField("test"); >- this.resultCollector.showPotential = false; >+ this.resultCollector.showPotential(false); > search(field, REFERENCES, getJavaSearchScope()); > assertSearchResults( > "src/q8/EclipseTest.java void q8.EclipseTest.main(String[]) [test]" >@@ -1124,7 +1124,7 @@ > public void testFieldReference20() throws CoreException { // was testFieldReferenceInOutDocComment > IType type = getCompilationUnit("JavaSearch", "src", "s4", "X.java").getType("X"); > IField field = type.getField("x"); >- this.resultCollector.showInsideDoc = true; >+ this.resultCollector.showInsideDoc(); > search(field, REFERENCES, getJavaSearchScope(), this.resultCollector); > assertSearchResults( > "src/s4/X.java int s4.X.foo() [x] OUTSIDE_JAVADOC\n" + >@@ -1734,7 +1734,7 @@ > public void testMethodReference15() throws CoreException { // was testMethodReferenceInOutDocComment > IType type = getCompilationUnit("JavaSearch", "src", "s4", "X.java").getType("X"); > IMethod method = type.getMethod("foo", new String[] {}); >- this.resultCollector.showInsideDoc = true; >+ this.resultCollector.showInsideDoc(); > search(method, REFERENCES, getJavaSearchScope(), this.resultCollector); > assertSearchResults( > "src/s4/X.java void s4.X.bar() [foo()] INSIDE_JAVADOC\n" + >@@ -1759,7 +1759,7 @@ > public void testMethodReference17() throws CoreException { > IType type = getCompilationUnit("JavaSearch/src/b111416/X.java").getType("X"); > IMethod method = type.getMethod("open", new String[] {"QString;"}); >- this.resultCollector.showAccuracy = true; >+ this.resultCollector.showAccuracy(true); > search(method, REFERENCES, ERASURE_RULE, getJavaSearchScope(), this.resultCollector); > assertSearchResults( > "src/b111416/X.java void b111416.X.foo() [open(\"\")] EXACT_MATCH", >@@ -1777,7 +1777,7 @@ > .getType("A1").getMethod("m", new String[] {}); > SearchPattern rightPattern = createPattern(rightMethod, ALL_OCCURRENCES); > SearchPattern orPattern = SearchPattern.createOrPattern(leftPattern, rightPattern); >- this.resultCollector.showAccuracy = true; >+ this.resultCollector.showAccuracy(true); > search( > orPattern, > getJavaSearchScope(), >@@ -1868,7 +1868,7 @@ > */ > public void testPackageDeclarationBug73551() throws CoreException { > JavaSearchResultCollector result = new JavaSearchResultCollector(); >- result.showAccuracy = true; >+ result.showAccuracy(true); > IPackageDeclaration packDecl = getCompilationUnit("JavaSearch", "src", "p71267", "Test.java").getPackageDeclaration("p71267"); > search(packDecl, DECLARATIONS, getJavaSearchScope(), result); > assertSearchResults( >@@ -1886,7 +1886,7 @@ > try { > test = srcRoot.createPackageFragment("b117020", true, null); > JavaSearchResultCollector result = new JavaSearchResultCollector(); >- result.showAccuracy = true; >+ result.showAccuracy(true); > search(test, DECLARATIONS, getJavaSearchScope(), result); > assertSearchResults( > "src/b117020 b117020 EXACT_MATCH", >@@ -2145,7 +2145,7 @@ > JAVA_PROJECT.setRawClasspath(newClasspath, null); > > // potential match for a field declaration >- this.resultCollector.showAccuracy = true; >+ this.resultCollector.showAccuracy(true); > search("MissingFieldType.*", FIELD, DECLARATIONS, getJavaSearchScope()); > assertSearchResults( > "AbortCompilation.jar AbortCompilation.MissingFieldType.field [No source] EXACT_MATCH\n" + >@@ -2177,7 +2177,7 @@ > } > } > }; >- collector.showAccuracy = true; >+ collector.showAccuracy(true); > search("*", FIELD, DECLARATIONS, getJavaSearchScope(), collector); > assertSearchResults( > "AbortCompilation.jar AbortCompilation.MissingFieldType.field [No source] EXACT_MATCH\n" + >@@ -2206,7 +2206,7 @@ > JAVA_PROJECT.setRawClasspath(newClasspath, null); > > // potential match for a method declaration >- this.resultCollector.showAccuracy = true; >+ this.resultCollector.showAccuracy(true); > search("MissingArgumentType.foo*", METHOD, DECLARATIONS, getJavaSearchScope()); > assertSearchResults( > "AbortCompilation.jar void AbortCompilation.MissingArgumentType.foo() [No source] EXACT_MATCH\n" + >@@ -2238,7 +2238,7 @@ > } > } > }; >- collector.showAccuracy = true; >+ collector.showAccuracy(true); > search("*", METHOD, DECLARATIONS, getJavaSearchScope(), collector); > assertSearchResults( > "AbortCompilation.jar void AbortCompilation.MissingArgumentType.foo() [No source] EXACT_MATCH\n" + >@@ -2268,7 +2268,7 @@ > JAVA_PROJECT.setRawClasspath(newClasspath, null); > > // exact match for a type declaration >- this.resultCollector.showAccuracy = true; >+ this.resultCollector.showAccuracy(true); > search("AbortCompilation.*Missing*", TYPE, DECLARATIONS, getJavaSearchScope()); > assertSearchResults( > "AbortCompilation.jar AbortCompilation.EnclosingType$MissingEnclosingType [No source] EXACT_MATCH\n" + >@@ -2291,7 +2291,7 @@ > JAVA_PROJECT.setRawClasspath(newClasspath, null); > > // exact match for a type declaration >- this.resultCollector.showAccuracy = true; >+ this.resultCollector.showAccuracy(true); > search("Missing*", TYPE, DECLARATIONS, getJavaSearchScope()); > assertSearchResults( > "AbortCompilation.jar AbortCompilation.EnclosingType$MissingEnclosingType [No source] EXACT_MATCH\n" + >@@ -2491,15 +2491,11 @@ > IPackageFragmentRoot root = getPackageFragmentRoot("JavaSearch", "test20631.jar"); > IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {root}); > >- search( >- "Y", >- TYPE, >- DECLARATIONS, >- scope, >- this.resultCollector); >+ this.resultCollector.showJarFile(); >+ search("Y", TYPE, DECLARATIONS, scope); > assertSearchResults( >- "test20631.jar Y", >- this.resultCollector); >+ "test20631.jar|X$Y.class X$Y" >+ ); > } > /** > * Type declaration using a package scope test. >@@ -2737,7 +2733,7 @@ > public void testTypeReference03() throws CoreException { > SearchPattern pattern = createPattern("x31985", TYPE, REFERENCES, false); > >- this.resultCollector.showAccuracy = true; >+ this.resultCollector.showAccuracy(true); > search( > pattern, > getJavaSearchScope(), >@@ -2857,7 +2853,7 @@ > public void testTypeReference10() throws CoreException { // was testMemberTypeReference > // references to second level member type > >- this.resultCollector.showAccuracy = true; >+ this.resultCollector.showAccuracy(true); > search( > "BMember", > TYPE, >@@ -2874,7 +2870,7 @@ > > // references to first level member type > this.resultCollector = new JavaSearchResultCollector(); >- this.resultCollector.showAccuracy = true; >+ this.resultCollector.showAccuracy(true); > search( > "AzzMember", > TYPE, >@@ -2889,7 +2885,7 @@ > > // no reference to a field with same name as member type > this.resultCollector = new JavaSearchResultCollector(); >- this.resultCollector.showAccuracy = true; >+ this.resultCollector.showAccuracy(true); > search( > "BMember", > FIELD, >@@ -2927,7 +2923,7 @@ > .getType("A") > .getType("Object"); > >- this.resultCollector.showAccuracy = true; >+ this.resultCollector.showAccuracy(true); > search( > type, > REFERENCES, >@@ -3136,7 +3132,7 @@ > public void testTypeReference24() throws CoreException { // was testTypeReferenceInThrows > IType type = getCompilationUnit("JavaSearch", "src", "a7", "X.java").getType("MyException"); > >- this.resultCollector.showAccuracy = true; >+ this.resultCollector.showAccuracy(true); > search( > type, > REFERENCES, >@@ -3173,8 +3169,8 @@ > */ > public void testTypeReference26() throws CoreException { // was testInnacurateTypeReference2 > >- this.resultCollector.showAccuracy = true; >- this.resultCollector.showSelection = true; >+ this.resultCollector.showAccuracy(true); >+ this.resultCollector.showSelection(); > search( > "p.Zork", > TYPE, >@@ -3196,7 +3192,7 @@ > public void testTypeReference27() throws CoreException { // was testInnacurateTypeReference3 > IType type = getCompilationUnit("JavaSearch", "src", "r3", "A21485.java").getType("A21485"); > >- this.resultCollector.showAccuracy = true; >+ this.resultCollector.showAccuracy(true); > search( > type, > REFERENCES, >@@ -3298,7 +3294,7 @@ > public void testTypeReference33() throws CoreException { // was testTypeReferenceWithRecovery > IType type = getCompilationUnit("JavaSearch", "src", "e1", "A29366.java").getType("A29366"); > >- this.resultCollector.showAccuracy = true; >+ this.resultCollector.showAccuracy(true); > search( > type, > REFERENCES, >@@ -3315,7 +3311,7 @@ > public void testTypeReference34() throws CoreException { // was testTypeReferenceWithProblem > IType type = getCompilationUnit("JavaSearch", "src", "e6", "A.java").getType("A"); > >- this.resultCollector.showAccuracy = true; >+ this.resultCollector.showAccuracy(true); > search( > "B36479", > TYPE, >@@ -3343,7 +3339,7 @@ > > IType type = getCompilationUnit("JavaSearch", "src", "e7", "A.java").getType("A"); > >- this.resultCollector.showAccuracy = true; >+ this.resultCollector.showAccuracy(true); > search( > type, > REFERENCES, >@@ -3363,7 +3359,7 @@ > IPackageFragment pkg = getPackageFragment("JavaSearch", "src", "f2"); > IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {pkg}); > >- this.resultCollector.showSelection = true; >+ this.resultCollector.showSelection(); > search( > "Y", > TYPE, >@@ -3384,7 +3380,7 @@ > > IJavaSearchScope scope = SearchEngine.createWorkspaceScope(); > >- this.resultCollector.showSelection = true; >+ this.resultCollector.showSelection(); > search( > localType, > REFERENCES, >@@ -3399,7 +3395,7 @@ > */ > public void testTypeReference38() throws CoreException { // was testTypeReferenceInOutDocComment > IType type = getCompilationUnit("JavaSearch", "src", "s4", "X.java").getType("X"); >- this.resultCollector.showInsideDoc = true; >+ this.resultCollector.showInsideDoc(); > search(type, REFERENCES, getJavaSearchScope(), this.resultCollector); > assertSearchResults( > "src/s4/X.java void s4.X.bar() [X] INSIDE_JAVADOC\n" + >Index: src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java,v >retrieving revision 1.224 >diff -u -r1.224 AbstractJavaModelTests.java >--- src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java 9 Oct 2008 11:55:20 -0000 1.224 >+++ src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java 15 Oct 2008 12:43:28 -0000 >@@ -433,8 +433,11 @@ > protected void addLibraryEntry(String path, boolean exported) throws JavaModelException { > addLibraryEntry(this.currentProject, new Path(path), null, null, null, null, exported); > } >+ protected void addLibraryEntry(IJavaProject project, String path) throws JavaModelException { >+ addLibraryEntry(project, new Path(path), null, null, null, null, false); >+ } > protected void addLibraryEntry(IJavaProject project, String path, boolean exported) throws JavaModelException { >- addLibraryEntry(project, new Path(path), exported); >+ addLibraryEntry(project, new Path(path), null, null, null, null, exported); > } > protected void addLibraryEntry(IJavaProject project, IPath path, boolean exported) throws JavaModelException { > addLibraryEntry(project, path, null, null, null, null, exported); >Index: src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchGenericTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchGenericTests.java,v >retrieving revision 1.6 >diff -u -r1.6 AbstractJavaSearchGenericTests.java >--- src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchGenericTests.java 27 Jun 2008 16:02:38 -0000 1.6 >+++ src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchGenericTests.java 15 Oct 2008 12:43:28 -0000 >@@ -32,8 +32,8 @@ > > protected void setUp () throws Exception { > super.setUp(); >- this.resultCollector.showAccuracy = true; >- this.resultCollector.showRule = true; >+ this.resultCollector.showAccuracy(true); >+ this.resultCollector.showRule(); > } > > /* >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.52 >diff -u -r1.52 SearchTests.java >--- src/org/eclipse/jdt/core/tests/model/SearchTests.java 19 Sep 2008 09:24:36 -0000 1.52 >+++ src/org/eclipse/jdt/core/tests/model/SearchTests.java 15 Oct 2008 12:43:30 -0000 >@@ -81,7 +81,8 @@ > CharOperation.concatWith(enclosingTypeNames, '$'), > simpleTypeName, > '$'); >- this.results.addElement(new String(CharOperation.concat(packageName, typeName, '.'))); >+ String qualifiedName = new String(CharOperation.concat(packageName, typeName, '.')); >+ this.results.addElement(qualifiedName); > } > public String toString(){ > int length = this.results.size(); >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.159 >diff -u -r1.159 JavaSearchBugsTests.java >--- src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 13 Oct 2008 14:05:19 -0000 1.159 >+++ src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 15 Oct 2008 12:43:29 -0000 >@@ -37,8 +37,8 @@ > import org.eclipse.jdt.internal.core.index.Index; > import org.eclipse.jdt.internal.core.search.AbstractSearchScope; > import org.eclipse.jdt.internal.core.search.indexing.IIndexConstants; >-import org.eclipse.jdt.internal.core.search.matching.AndPattern; > import org.eclipse.jdt.internal.core.search.indexing.IndexManager; >+import org.eclipse.jdt.internal.core.search.matching.AndPattern; > import org.eclipse.jdt.internal.core.search.matching.MatchLocator; > import org.eclipse.jdt.internal.core.search.matching.PatternLocator; > import org.eclipse.jdt.internal.core.search.matching.TypeDeclarationPattern; >@@ -57,6 +57,7 @@ > return buildModelTestSuite(JavaSearchBugsTests.class); > } > static { >+// org.eclipse.jdt.internal.core.search.processing.JobManager.VERBOSE = true; > // org.eclipse.jdt.internal.core.search.BasicSearchEngine.VERBOSE = true; > // org.eclipse.jdt.internal.codeassist.SelectionEngine.DEBUG = true; > } >@@ -130,8 +131,101 @@ > protected void setUp () throws Exception { > super.setUp(); > this.resultCollector = new TestCollector(); >- this.resultCollector.showInsideDoc = false; >- this.resultCollector.showAccuracy = true; >+ this.resultCollector.showAccuracy(true); >+} >+ >+/** >+ * @bug 12044: [search] Reference to package is not found in qualified annotation >+ * @test Ensure that references to package are also found in qualified annotation >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=12044" >+ */ >+private String[] sourcesBug12044() throws CoreException { >+ return new String[] { >+ "Def.java", >+ "public class Def {\n" + >+ " public static final int ONE = 1;\n" + >+ " public static final int TWO = 2;\n" + >+ " public static final int THREE = 3;\n" + >+ "}\n", >+ "Ref.java", >+ "public class Ref {\n" + >+ " class Sub {\n" + >+ " int x = Def.ONE;\n" + >+ " int getX() {\n" + >+ " return x;\n" + >+ " }\n" + >+ " }\n" + >+ " void foo(Sub sub) {\n" + >+ " switch (sub.getX()) {\n" + >+ " case Def.ONE:\n" + >+ " break;\n" + >+ " case Def.TWO:\n" + >+ " break;\n" + >+ " case Def.THREE:\n" + >+ " break;\n" + >+ " }\n" + >+ " }\n" + >+ "}\n" >+ }; >+} >+static { TESTS_PREFIX = "testBug12044"; } >+public void testBug12044_no_src() throws CoreException, IOException { >+ IJavaProject javaProject = null; >+ try { >+ javaProject = createJavaProject("b012044", new String[] { "src" }, new String[] {"JCL_LIB" }, "bin"); >+ waitUntilIndexesReady(); >+ String jarPath = getWorkspacePath()+"b012044"+File.separator+"b012044.jar"; >+ createJar(sourcesBug12044(), jarPath); >+ refresh(javaProject); >+ String resourcePath = "/b012044/b012044.jar"; >+ addLibraryEntry(javaProject, resourcePath); >+ waitUntilIndexesReady(); >+ IClassFile classFile = getClassFile("b012044", resourcePath, "", "Def.class"); >+ IField field = classFile.getType().getField("ONE"); >+ IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { javaProject } ); >+ this.resultCollector.showJarFile(); >+ search(field, ALL_OCCURRENCES, scope); >+ assertSearchResults( >+ "b012044.jar|Def.class Def.ONE [No source] EXACT_MATCH" >+ ); >+ } >+ finally { >+ if (javaProject != null) { >+ deleteProject(javaProject); >+ } >+ } >+} >+public void testBug12044_src_in_zip() throws CoreException, IOException { >+ IJavaProject javaProject = null; >+ try { >+ javaProject = createJavaProject("b012044", new String[] { "src" }, new String[] {"JCL_LIB" }, "bin"); >+ waitUntilIndexesReady(); >+ String path = getWorkspacePath()+"b012044"+File.separator+"b012044"; >+ String jarPath = path+".jar"; >+ createJar(sourcesBug12044(), jarPath); >+ String zipPath = path+".zip"; >+ Util.createSourceZip(sourcesBug12044(), zipPath); >+ refresh(javaProject); >+ String resourcePath = "/b012044/b012044.jar"; >+ String resourceZipPath = "/b012044/b012044.zip"; >+ addLibraryEntry(javaProject, resourcePath, resourceZipPath); >+ waitUntilIndexesReady(); >+ IClassFile classFile = getClassFile("b012044", resourcePath, "", "Def.class"); >+ IField field = classFile.getType().getField("ONE"); >+ IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { javaProject } ); >+ this.resultCollector.showJarFile(); >+ search(field, ALL_OCCURRENCES, scope); >+ assertSearchResults( >+ "b012044.jar|Def.class Def.ONE EXACT_MATCH\n" + >+ "b012044.jar|Ref.class void Ref.foo(Ref.Sub) EXACT_MATCH\n" + >+ "b012044.jar|Ref$Sub.class Ref$Sub.x EXACT_MATCH" >+ ); >+ } >+ finally { >+ if (javaProject != null) { >+ deleteProject(javaProject); >+ } >+ } > } > > /** >@@ -775,7 +869,7 @@ > ); > } > public void testBug79378b() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > this.workingCopies = new ICompilationUnit[1]; > this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b79378/A.java", > "package b79378;\n" + >@@ -1491,7 +1585,7 @@ > ); > } > public void testBug82208_TYPE() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug82208(); > search("B82208*", TYPE, ALL_OCCURRENCES); > assertSearchResults( >@@ -1502,7 +1596,7 @@ > ); > } > public void testBug82208_CLASS() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug82208(); > search("B82208*", CLASS, ALL_OCCURRENCES); > assertSearchResults( >@@ -1510,7 +1604,7 @@ > ); > } > public void testBug82208_INTERFACE() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug82208(); > search("B82208*", INTERFACE, ALL_OCCURRENCES); > assertSearchResults( >@@ -1518,7 +1612,7 @@ > ); > } > public void testBug82208_ENUM() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug82208(); > search("B82208*", ENUM, ALL_OCCURRENCES); > assertSearchResults( >@@ -1526,7 +1620,7 @@ > ); > } > public void testBug82208_ANNOTATION_TYPE() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug82208(); > search("B82208*", ANNOTATION_TYPE, ALL_OCCURRENCES); > assertSearchResults( >@@ -1534,7 +1628,7 @@ > ); > } > public void testBug82208_CLASS_AND_INTERFACE() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug82208(); > search("B82208*", CLASS_AND_INTERFACE, ALL_OCCURRENCES); > assertSearchResults( >@@ -1543,7 +1637,7 @@ > ); > } > public void testBug82208_CLASS_AND_ENUMERATION() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug82208(); > search("B82208*", CLASS_AND_ENUM, ALL_OCCURRENCES); > assertSearchResults( >@@ -1557,7 +1651,7 @@ > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=83012" > */ > public void testBug82673() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > this.workingCopies = new ICompilationUnit[1]; > this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b82673/Test.java", > "package b82673;\n" + >@@ -1590,7 +1684,7 @@ > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=83012" > */ > public void testBug83012() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > this.workingCopies = new ICompilationUnit[1]; > this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83012/Test.java", > "package b83012;\n" + >@@ -1622,7 +1716,7 @@ > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=83230" > */ > private void setUpBug83230_Explicit() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > this.workingCopies = new ICompilationUnit[1]; > this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83230/Test.java", > "package b83230;\n" + >@@ -1661,7 +1755,7 @@ > ); > } > public void testBug83230_Explicit() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug83230_Explicit(); > IMethod method = selectMethod(this.workingCopies[0], "authorName"); > search(method, REFERENCES); >@@ -1676,7 +1770,7 @@ > ); > } > public void testBug83230_Explicit01() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug83230_Explicit(); > IMethod method = selectMethod(this.workingCopies[0], "authorName"); > search(method, DECLARATIONS); >@@ -1685,7 +1779,7 @@ > ); > } > public void testBug83230_Explicit02() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug83230_Explicit(); > IType type = selectType(this.workingCopies[0], "Address"); > search(type, REFERENCES); >@@ -1695,7 +1789,7 @@ > ); > } > public void testBug83230_Explicit03() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug83230_Explicit(); > IMethod method = selectMethod(this.workingCopies[0], "foo"); > search(method, REFERENCES); >@@ -1704,7 +1798,7 @@ > ); > } > public void testBug83230_Explicit04() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug83230_Explicit(); > IField field = selectField(this.workingCopies[0], "city"); > search(field, REFERENCES); >@@ -1713,7 +1807,7 @@ > ); > } > public void testBug83230_Explicit05() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug83230_Explicit(); > IField field = selectField(this.workingCopies[0], "ageMin"); > search(field, REFERENCES); >@@ -1722,7 +1816,7 @@ > ); > } > public void testBug83230_Implicit01() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > this.workingCopies = new ICompilationUnit[1]; > this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83230/Test.java", > "package b83230;\n" + >@@ -1747,7 +1841,7 @@ > ); > } > public void testBug83230_Implicit02() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > this.workingCopies = new ICompilationUnit[1]; > this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83230/Test.java", > "package b83230;\n" + >@@ -1778,7 +1872,7 @@ > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=83304" > */ > public void testBug83304() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > this.workingCopies = new ICompilationUnit[1]; > this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83304/Test.java", > "package b83304;\n" + >@@ -1800,7 +1894,7 @@ > ); > } > private void setUpBug83304_TypeParameterizedElementPattern() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > this.workingCopies = new ICompilationUnit[1]; > this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83304/Types.java", > "package b83304;\n" + >@@ -1816,7 +1910,7 @@ > ); > } > public void testBug83304_TypeParameterizedElementPattern() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug83304_TypeParameterizedElementPattern(); > IType type = selectType(this.workingCopies[0], "Generic", 4); > search(type, REFERENCES, ERASURE_RULE); >@@ -1832,7 +1926,7 @@ > ); > } > public void testBug83304_TypeGenericElementPattern() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug83304_TypeParameterizedElementPattern(); > IType type = getClassFile("JavaSearchBugs", "lib/JavaSearch15.jar", "g1.t.s.def", "Generic.class").getType(); > search(type, REFERENCES, ERASURE_RULE); >@@ -1848,7 +1942,7 @@ > ); > } > public void testBug83304_TypeStringPattern() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug83304_TypeParameterizedElementPattern(); > search("Generic<? super Exception>", TYPE, REFERENCES, ERASURE_RULE); > assertSearchResults( >@@ -1863,7 +1957,7 @@ > ); > } > private void setUpBug83304_MethodParameterizedElementPattern() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > this.workingCopies = new ICompilationUnit[1]; > this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83304/Methods.java", > "package b83304;\n" + >@@ -1880,7 +1974,7 @@ > ); > } > public void testBug83304_MethodParameterizedElementPattern() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug83304_MethodParameterizedElementPattern(); > IMethod method = selectMethod(this.workingCopies[0], "generic", 2); > search(method, REFERENCES, ERASURE_RULE); >@@ -1891,7 +1985,7 @@ > ); > } > public void testBug83304_MethodGenericElementPattern() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug83304_MethodParameterizedElementPattern(); > IType type = getClassFile("JavaSearchBugs", "lib/JavaSearch15.jar", "g5.m.def", "Single.class").getType(); > IMethod method = type.getMethod("generic", new String[] { "TU;" }); >@@ -1903,7 +1997,7 @@ > ); > } > public void testBug83304_MethodStringPattern() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug83304_MethodParameterizedElementPattern(); > search("<Exception>generic", METHOD, REFERENCES, ERASURE_RULE); > assertSearchResults( >@@ -1913,7 +2007,7 @@ > ); > } > private void setUpBug83304_ConstructorGenericElementPattern() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > this.workingCopies = new ICompilationUnit[1]; > this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83304/Constructors.java", > "package b83304;\n" + >@@ -1929,7 +2023,7 @@ > ); > } > public void testBug83304_ConstructorGenericElementPattern() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug83304_ConstructorGenericElementPattern(); > IMethod method = selectMethod(this.workingCopies[0], "Single", 3); > search(method, REFERENCES, ERASURE_RULE); >@@ -1940,7 +2034,7 @@ > ); > } > public void testBug83304_ConstructorParameterizedElementPattern() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug83304_ConstructorGenericElementPattern(); > IType type = getClassFile("JavaSearchBugs", "lib/JavaSearch15.jar", "g5.c.def", "Single.class").getType(); > IMethod method = type.getMethod("Single", new String[] { "TT;", "TU;" }); >@@ -1952,7 +2046,7 @@ > ); > } > public void testBug83304_ConstructorStringPattern() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug83304_ConstructorGenericElementPattern(); > search("<Exception>Single", CONSTRUCTOR, REFERENCES, ERASURE_RULE); > assertSearchResults( >@@ -1997,7 +2091,7 @@ > ); > } > public void testBug83804_Type() throws CoreException { >- this.resultCollector.showInsideDoc = true; >+ this.resultCollector.showInsideDoc(); > setUpBug83804_Type(); > IType type = this.workingCopies[1].getType("Test"); > search(type, REFERENCES); >@@ -2010,7 +2104,7 @@ > ); > } > public void testBug83804_Method() throws CoreException { >- this.resultCollector.showInsideDoc = true; >+ this.resultCollector.showInsideDoc(); > setUpBug83804_Type(); > IMethod[] methods = this.workingCopies[1].getType("Test").getMethods(); > assertEquals("Invalid number of methods", 1, methods.length); >@@ -2020,7 +2114,7 @@ > ); > } > public void testBug83804_Field() throws CoreException { >- this.resultCollector.showInsideDoc = true; >+ this.resultCollector.showInsideDoc(); > setUpBug83804_Type(); > IField[] fields = this.workingCopies[1].getType("Test").getFields(); > assertEquals("Invalid number of fields", 1, fields.length); >@@ -2035,7 +2129,7 @@ > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=83388" > */ > public void testBug83388() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > this.workingCopies = new ICompilationUnit[1]; > this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83388/R.java", > "package b83388;\n" + >@@ -2063,7 +2157,7 @@ > ); > } > public void testBug83388b() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > this.workingCopies = new ICompilationUnit[1]; > this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83388/R.java", > "package b83388;\n" + >@@ -2096,8 +2190,8 @@ > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=83693" > */ > public void testBug83693() throws CoreException { >- this.resultCollector.showRule = true; >- this.resultCollector.showInsideDoc = true; >+ this.resultCollector.showRule(); >+ this.resultCollector.showInsideDoc(); > this.workingCopies = new ICompilationUnit[1]; > this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83693/A.java", > "package b83693;\n" + >@@ -2153,7 +2247,7 @@ > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=84100" > */ > private void setUpBug84100() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > this.workingCopies = new ICompilationUnit[2]; > this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b84100/X.java", > "package b84100;\n" + >@@ -2181,7 +2275,7 @@ > ); > } > public void testBug84100() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug84100(); > IMethod method = selectMethod(this.workingCopies[0], "foo", 1); > search(method, REFERENCES); >@@ -2190,7 +2284,7 @@ > ); > } > public void testBug84100b() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug84100(); > IMethod method = selectMethod(this.workingCopies[0], "foo", 2); > search(method, REFERENCES); >@@ -2199,7 +2293,7 @@ > ); > } > public void testBug84100c() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug84100(); > IMethod method = selectMethod(this.workingCopies[0], "foo", 3); > search(method, REFERENCES); >@@ -2209,7 +2303,7 @@ > ); > } > public void testBug84100d() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug84100(); > IMethod method = selectMethod(this.workingCopies[0], "foo", 4); > search(method, REFERENCES); >@@ -2218,7 +2312,7 @@ > ); > } > public void testBug84100e() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug84100(); > IMethod method = selectMethod(this.workingCopies[0], "foo", 5); > search(method, REFERENCES); >@@ -2232,7 +2326,7 @@ > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=84121" > */ > public void testBug84121() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > this.workingCopies = new ICompilationUnit[1]; > this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b84121/Test.java", > "package b84121;\n" + >@@ -2257,7 +2351,7 @@ > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=84724" > */ > private void setUpBug84724() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > this.workingCopies = new ICompilationUnit[2]; > this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b84724/X.java", > "package b84724;\n" + >@@ -2283,7 +2377,7 @@ > ); > } > public void testBug84724() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug84724(); > IMethod method = selectMethod(this.workingCopies[0], "X", 2); > search(method, REFERENCES); >@@ -2292,7 +2386,7 @@ > ); > } > public void testBug84724b() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug84724(); > IMethod method = selectMethod(this.workingCopies[0], "X", 3); > search(method, REFERENCES); >@@ -2303,7 +2397,7 @@ > ); > } > public void testBug84724c() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug84724(); > IMethod method = selectMethod(this.workingCopies[0], "X", 4); > search(method, REFERENCES); >@@ -2312,7 +2406,7 @@ > ); > } > public void testBug84724d() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug84724(); > IMethod method = selectMethod(this.workingCopies[0], "X", 5); > search(method, REFERENCES); >@@ -2326,7 +2420,7 @@ > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=84727" > */ > private void setUpBug84727() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > this.workingCopies = new ICompilationUnit[3]; > this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b84727/A.java", > "package b84727;\n" + >@@ -2353,7 +2447,7 @@ > ); > } > public void testBug84727() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug84727(); > IMethod[] methods = this.workingCopies[0].getType("A").getMethods(); > assertEquals("Invalid number of methods", 2, methods.length); >@@ -2363,7 +2457,7 @@ > ); > } > public void testBug84727b() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug84727(); > IMethod[] methods = this.workingCopies[0].getType("A").getMethods(); > assertEquals("Invalid number of methods", 2, methods.length); >@@ -2378,7 +2472,7 @@ > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=85810" > */ > public void testBug85810() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > this.workingCopies = new ICompilationUnit[1]; > this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b85810/Test.java", > "package b85810;\n" + >@@ -2400,7 +2494,7 @@ > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=86596" > */ > public void testBug86596() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > this.workingCopies = new ICompilationUnit[3]; > this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b86596/aa/link/A.java", > "package b86596.aa.link;\n" + >@@ -2431,7 +2525,7 @@ > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=86642" > */ > public void testBug86642() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > this.workingCopies = new ICompilationUnit[2]; > this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b86642/A.java", > "package b86642;\n" + >@@ -2475,7 +2569,7 @@ > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=86380" > */ > private void setUpBug86380() throws CoreException { >- this.resultCollector.showInsideDoc = true; >+ this.resultCollector.showInsideDoc(); > this.workingCopies = new ICompilationUnit[2]; > this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b86380/package-info.java", > "/**\n" + >@@ -2493,7 +2587,7 @@ > ); > } > public void testBug86380_Type() throws CoreException { >- this.resultCollector.showInsideDoc = true; >+ this.resultCollector.showInsideDoc(); > setUpBug86380(); > ICompilationUnit unit = getCompilationUnit("JavaSearchBugs", "src", "b86380", "Annot.java"); > IType type = unit.getType("Annot"); >@@ -2506,7 +2600,7 @@ > ); > } > public void testBug86380_Method() throws CoreException { >- this.resultCollector.showInsideDoc = true; >+ this.resultCollector.showInsideDoc(); > setUpBug86380(); > ICompilationUnit unit = getCompilationUnit("JavaSearchBugs", "src", "b86380", "Annot.java"); > IMethod[] methods = unit.getType("Annot").getMethods(); >@@ -2518,7 +2612,7 @@ > ); > } > public void testBug86380_Field() throws CoreException { >- this.resultCollector.showInsideDoc = true; >+ this.resultCollector.showInsideDoc(); > setUpBug86380(); > ICompilationUnit unit = getCompilationUnit("JavaSearchBugs", "src", "b86380", "Annot.java"); > IField[] fields = unit.getType("Annot").getFields(); >@@ -2535,7 +2629,7 @@ > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=88174" > */ > public void testBug88174() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > this.workingCopies = new ICompilationUnit[2]; > this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b88174/Test.java", > "package b88174;\n" + >@@ -3008,7 +3102,7 @@ > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=92944" > */ > private void setUpBug92944() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > this.workingCopies = new ICompilationUnit[1]; > this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b92944/Test.java", > "package b92944;\n" + >@@ -3019,7 +3113,7 @@ > ); > } > public void testBug92944_TYPE() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug92944(); > TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); > new SearchEngine(this.workingCopies).searchAllTypeNames( >@@ -3042,7 +3136,7 @@ > requestor); > } > public void testBug92944_CLASS() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug92944(); > TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); > new SearchEngine(this.workingCopies).searchAllTypeNames( >@@ -3063,7 +3157,7 @@ > requestor); > } > public void testBug92944_CLASS_AND_INTERFACE() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug92944(); > TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); > new SearchEngine(this.workingCopies).searchAllTypeNames( >@@ -3085,7 +3179,7 @@ > requestor); > } > public void testBug92944_CLASS_AND_ENUM() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug92944(); > TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); > new SearchEngine(this.workingCopies).searchAllTypeNames( >@@ -3107,7 +3201,7 @@ > requestor); > } > public void testBug92944_INTERFACE() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug92944(); > TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); > new SearchEngine(this.workingCopies).searchAllTypeNames( >@@ -3127,7 +3221,7 @@ > requestor); > } > public void testBug92944_ENUM() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug92944(); > TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); > new SearchEngine(this.workingCopies).searchAllTypeNames( >@@ -3147,7 +3241,7 @@ > requestor); > } > public void testBug92944_ANNOTATION_TYPE() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug92944(); > TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); > new SearchEngine(this.workingCopies).searchAllTypeNames( >@@ -3177,7 +3271,7 @@ > */ > public void testBug93392() throws CoreException { > TestCollector collector = new TestCollector(); >- collector.showAccuracy = true; >+ collector.showAccuracy(true); > this.workingCopies = new ICompilationUnit[1]; > this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b93392/Test.java", > "package b93392;\n" + >@@ -3503,7 +3597,7 @@ > > // Verify matches > TestCollector occurencesCollector = new TestCollector(); >- occurencesCollector.showAccuracy = true; >+ occurencesCollector.showAccuracy(true); > search(type, ALL_OCCURRENCES, getJavaSearchScope(), occurencesCollector); > assertSearchResults( > "src/b95794/Test.java [b95794.Test] EXACT_MATCH\n" + >@@ -3519,13 +3613,13 @@ > assertEquals("Problem with occurences or references number of matches: ", occurencesCollector.matches.size()-1, referencesCollector.matches.size()); > } > public void testBug95794b() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > ICompilationUnit unit = getCompilationUnit("JavaSearchBugs", "src", "b95794", "Test.java"); > IType type = unit.getType("Test").getType("Color"); > > // Verify matches > TestCollector occurencesCollector = new TestCollector(); >- occurencesCollector.showAccuracy = true; >+ occurencesCollector.showAccuracy(true); > search(type, ALL_OCCURRENCES, getJavaSearchScope(), occurencesCollector); > assertSearchResults( > "src/b95794/Test.java [b95794.Test.Color] EXACT_MATCH\n" + >@@ -3541,13 +3635,13 @@ > assertEquals("Problem with occurences or references number of matches: ", occurencesCollector.matches.size()-1, referencesCollector.matches.size()); > } > public void testBug95794c() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > ICompilationUnit unit = getCompilationUnit("JavaSearchBugs", "src", "b95794", "Test.java"); > IField field = unit.getType("Test").getType("Color").getField("WHITE"); > > // Verify matches > TestCollector occurencesCollector = new TestCollector(); >- occurencesCollector.showAccuracy = true; >+ occurencesCollector.showAccuracy(true); > search(field, ALL_OCCURRENCES, getJavaSearchScope(), occurencesCollector); > assertSearchResults( > "src/b95794/Test.java [WHITE] EXACT_MATCH\n" + >@@ -3656,7 +3750,7 @@ > */ > public void testBug97087() throws CoreException { > this.workingCopies = new ICompilationUnit[1]; >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b97087/Bug.java", > "package b97087;\n" + > "public class Bug<Type> {\n" + >@@ -3796,7 +3890,7 @@ > this.workingCopies[1].commitWorkingCopy(true, null); > this.workingCopies[2].commitWorkingCopy(true, null); > this.workingCopies[3].commitWorkingCopy(true, null); >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > IType type = this.workingCopies[0].getType("L"); > search(type, REFERENCES, SearchPattern.R_ERASURE_MATCH); > assertSearchResults( >@@ -3849,7 +3943,7 @@ > this.workingCopies[1].commitWorkingCopy(true, null); > this.workingCopies[2].commitWorkingCopy(true, null); > this.workingCopies[3].commitWorkingCopy(true, null); >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > IType type = this.workingCopies[0].getType("L"); > search(type, REFERENCES, SearchPattern.R_ERASURE_MATCH); > assertSearchResults( >@@ -4042,7 +4136,7 @@ > "public @interface Annot {\n" + > "}\n" > ); >- this.resultCollector.showInsideDoc = true; >+ this.resultCollector.showInsideDoc(); > IType type = this.workingCopies[1].getType("Test"); > search(type, REFERENCES); > assertSearchResults( >@@ -6036,7 +6130,7 @@ > "}" > ); > IType type = this.workingCopies[0].getType("X"); >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > search(type, REFERENCES, ERASURE_RULE); > assertSearchResults( > "src/p1/X.java p1.X.gen [X] EXACT_MATCH\n" + >@@ -6485,7 +6579,7 @@ > "}" > ); > IType type = this.workingCopies[0].getType("Foo"); >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > new SearchEngine(this.workingCopies).search( > SearchPattern.createPattern(type, REFERENCES), > new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, >@@ -7449,7 +7543,7 @@ > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=148380" > */ > public void testBug148380_SearchAllTypes_wc() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > this.workingCopies = new ICompilationUnit[4]; > this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b148380/I.java", > "package b148380;\n" + >@@ -7556,7 +7650,7 @@ > ); > waitUntilIndexesReady(); > IPackageFragment packageFragment = getPackage("/JavaSearchBugs/src/b153765"); >- this.resultCollector.showSelection = true; >+ this.resultCollector.showSelection(); > search(packageFragment, REFERENCES); > assertSearchResults( > "src/b153765/test/SomeClass.java void b153765.test.SomeClass.foo() [ @§|b153765|§.Unimportant public void foo() {}] EXACT_MATCH" >@@ -7610,7 +7704,7 @@ > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=156177" > */ > public void testBug156177() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > this.workingCopies = new ICompilationUnit[1]; > this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b156177/Test.java", > "package b156177;\n" + >@@ -7643,7 +7737,7 @@ > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=156491" > */ > public void testBug156491() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > this.workingCopies = new ICompilationUnit[1]; > this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/pack/Test.java", > "package pack;\n" + >@@ -7714,7 +7808,7 @@ > ); > } > public void testBug156491a() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug156491(); > IMethod method = this.workingCopies[0].getType("L2").getMethod("test", new String[0]); > this.resultCollector.showFlavors = PatternLocator.SUPER_INVOCATION_FLAVOR; >@@ -7726,7 +7820,7 @@ > ); > } > public void testBug156491b() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug156491(); > IMethod method = this.workingCopies[0].getType("L1").getMethod("test", new String[0]); > this.resultCollector.showFlavors = PatternLocator.SUPER_INVOCATION_FLAVOR; >@@ -7744,7 +7838,7 @@ > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=160301" > */ > public void testBug160301() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > this.workingCopies = new ICompilationUnit[1]; > this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java", > "public class Test {\n" + >@@ -7774,7 +7868,7 @@ > ); > } > public void testBug160301b() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > this.workingCopies = new ICompilationUnit[1]; > this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/test/Test.java", > "package test;\n" + >@@ -7810,7 +7904,7 @@ > ); > } > public void testBug160301_Interface() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > this.workingCopies = new ICompilationUnit[1]; > this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java", > "public class Test {\n" + >@@ -7864,7 +7958,7 @@ > ); > } > public void testBug160301_Abstract() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > this.workingCopies = new ICompilationUnit[1]; > this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java", > "public class Test {\n" + >@@ -7911,7 +8005,7 @@ > ); > } > public void testBug160301_Abstract2() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > this.workingCopies = new ICompilationUnit[1]; > this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java", > "public class Test {\n" + >@@ -7946,7 +8040,7 @@ > ); > } > public void testBug160301_Abstract3() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > this.workingCopies = new ICompilationUnit[1]; > this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java", > "public class Test {\n" + >@@ -8301,7 +8395,7 @@ > ); > } > public void testBug164121a() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug164121(); > ILocalVariable param = getLocalVariable(this.workingCopies[0], "param", "param"); > search(param, DECLARATIONS); >@@ -8310,7 +8404,7 @@ > ); > } > public void testBug164121b() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > setUpBug164121(); > ILocalVariable param = getLocalVariable(this.workingCopies[0], "param", "param"); > search(param, ALL_OCCURRENCES); >@@ -8336,7 +8430,7 @@ > assertTrue("Search match element "+element.getElementName()+" should exist!!!", element.exists()); > } > }; >- collector.showAccuracy = true; >+ collector.showAccuracy(true); > search(type, REFERENCES, getJavaSearchScope(), collector); > assertSearchResults( > "lib/b164791.jar test.<anonymous> EXACT_MATCH\n" + >@@ -8459,7 +8553,7 @@ > } > > }; >- testCollector.showAccuracy = true; >+ testCollector.showAccuracy(true); > IMethod method = this.workingCopies[0].getType("ClassA").getMethod("setValue", new String[] { "I" }); > search(method, REFERENCES, getJavaSearchScope(), testCollector); > assertSearchResults( >@@ -8675,7 +8769,7 @@ > "}\n" + > "class Ref {}" > ); >- this.resultCollector.showInsideDoc = true; >+ this.resultCollector.showInsideDoc(); > new SearchEngine(this.workingCopies).searchDeclarationsOfReferencedTypes(this.workingCopies[0], this.resultCollector, null); > assertSearchResults( > "src/b195489/Test.java b195489.Ref [Ref] EXACT_MATCH OUTSIDE_JAVADOC" >@@ -8696,7 +8790,7 @@ > "}\n" + > "class Ref {}" > ); >- this.resultCollector.showInsideDoc = true; >+ this.resultCollector.showInsideDoc(); > new SearchEngine(this.workingCopies).searchDeclarationsOfReferencedTypes(this.workingCopies[0], this.resultCollector, null); > assertSearchResults( > "src/b195489/Test.java b195489.Ref [Ref] EXACT_MATCH OUTSIDE_JAVADOC" >@@ -8713,7 +8807,7 @@ > "}\n" + > "class Ref {}" > ); >- this.resultCollector.showInsideDoc = true; >+ this.resultCollector.showInsideDoc(); > new SearchEngine(this.workingCopies).searchDeclarationsOfReferencedTypes(this.workingCopies[0], this.resultCollector, null); > assertSearchResults( > "src/b195489/Test.java b195489.Ref [Ref] EXACT_MATCH OUTSIDE_JAVADOC" >@@ -8731,7 +8825,7 @@ > "}\n" + > "class Ref {}" > ); >- this.resultCollector.showInsideDoc = true; >+ this.resultCollector.showInsideDoc(); > String docCommentSupport = JAVA_PROJECT.getOption(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, true); > JAVA_PROJECT.setOption(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.DISABLED); > try { >@@ -9305,7 +9399,7 @@ > ); > IType type = this.workingCopies[0].getType("Test"); > ReferenceCollector collector = new ReferenceCollector(); >- collector.showSelection = true; >+ collector.showSelection(); > search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector); > assertSearchResults( > "src/test/Test.java @Annot(clazz=Test.class) [ @Annot(clazz=§|Test|§.class) int x;]", >@@ -9321,7 +9415,7 @@ > "}\n" > ); > ReferenceCollector collector = new ReferenceCollector(); >- collector.showSelection = true; >+ collector.showSelection(); > search("Deprecated", TYPE, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector); > assertSearchResults( > "src/test/Test.java @Deprecated() [ @§|Deprecated|§ foo() {}]", >@@ -9347,7 +9441,7 @@ > ); > IType type = this.workingCopies[0].getType("Ref"); > ReferenceCollector collector = new ReferenceCollector(); >- collector.showSelection = true; >+ collector.showSelection(); > search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector); > assertSearchResults( > "src/comment5/Ref.java void comment5.Ref.doA(Ref).ref [ void doA(§|Ref|§ ref) {}]\n" + >@@ -9370,7 +9464,7 @@ > ); > IField field = this.workingCopies[0].getType("Num").getField("CONST"); > ReferenceCollector collector = new ReferenceCollector(); >- collector.showSelection = true; >+ collector.showSelection(); > search(field, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector); > assertSearchResults( > "src/comment10/Ref.java @Num(number=Num.CONST) [@Num(number= Num.§|CONST|§)]", >@@ -9392,7 +9486,7 @@ > ); > IType type = this.workingCopies[0].getType("Tag"); > TypeReferenceCollector collector = new TypeReferenceCollector(); >- collector.showSelection = true; >+ collector.showSelection(); > search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector); > assertSearchResults( > "src/comment22/Test.java @Tag() [ @§|Tag|§ Test test1, test2, test3;]\n" + >@@ -9414,7 +9508,7 @@ > ); > IType type = this.workingCopies[0].getType("Test"); > TypeReferenceCollector collector = new TypeReferenceCollector(); >- collector.showSelection = true; >+ collector.showSelection(); > search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector); > assertSearchResults( > "src/test/Test.java @Annot(clazz=test.Test.class) [ @Annot(clazz = §|test.Test|§.class) int x, y;]", >@@ -9469,7 +9563,7 @@ > "public class Types {\n" + > "}\n" > ); >- this.resultCollector.showSelection = true; >+ this.resultCollector.showSelection(); > search("*", TYPE, REFERENCES, getJavaSearchWorkingCopiesScope(), this.resultCollector); > assertSearchResults( > "src/generics/Generic.java [import §|java.io.Serializable|§;] EXACT_MATCH\n" + >@@ -9508,7 +9602,7 @@ > " Test test;\n" + > "}\n" > ); >- this.resultCollector.showSelection = true; >+ this.resultCollector.showSelection(); > search("*", TYPE, REFERENCES, getJavaSearchWorkingCopiesScope(), this.resultCollector); > assertSearchResults( > "src/test/Ref.java [import §|pack.Test|§;] EXACT_MATCH\n" + >@@ -9525,7 +9619,7 @@ > addLibraryEntry(JAVA_PROJECT, "/JavaSearchBugs/lib/b211366.jar", false); > try { > IType type = getClassFile("JavaSearchBugs", "lib/b211366.jar", "test", "Bug.class").getType(); >- this.resultCollector.showMatchKind = true; >+ this.resultCollector.showMatchKind(); > search(type, REFERENCES); > assertSearchResults( > "TypeReferenceMatch: lib/b211366.jar pack.Test [No source] EXACT_MATCH\n" + >@@ -9545,7 +9639,7 @@ > SearchPattern rightPattern = SearchPattern.createPattern(type, REFERENCES); > SearchPattern leftPattern = SearchPattern.createPattern(type, DECLARATIONS); > SearchPattern pattern = SearchPattern.createOrPattern(leftPattern, rightPattern); >- this.resultCollector.showMatchKind = true; >+ this.resultCollector.showMatchKind(); > new SearchEngine(this.workingCopies).search( > pattern, > new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, >@@ -9579,7 +9673,7 @@ > SearchPattern.createPattern("Bug", TYPE, REFERENCES, SearchPattern.R_EXACT_MATCH))); > IPackageFragmentRoot root = JAVA_PROJECT.getPackageFragmentRoot("/JavaSearchBugs/lib/b211366.jar"); > this.resultCollector.sorted = true; >- this.resultCollector.showMatchKind = true; >+ this.resultCollector.showMatchKind(); > new SearchEngine(this.workingCopies).search( > SearchPattern.createOrPattern(leftPattern, rightPattern), > new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, >@@ -9731,7 +9825,7 @@ > "\n" + > "}\n" > ); >- this.resultCollector.showSelection = true; >+ this.resultCollector.showSelection(); > ILocalVariable variable = selectLocalVariable(this.workingCopies[0], "test"); > search(variable, READ_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector); > assertSearchResults( >@@ -9751,7 +9845,7 @@ > " int fField;" + > "}" > ); >- this.resultCollector.showSelection = true; >+ this.resultCollector.showSelection(); > IField field = this.workingCopies[0].getType("Test").getField("fWrapped"); > search(field, READ_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector); > assertSearchResults( >@@ -9777,7 +9871,7 @@ > " }\n" + > "}\n" > ); >- this.resultCollector.showSelection = true; >+ this.resultCollector.showSelection(); > ILocalVariable variable = selectLocalVariable(this.workingCopies[1], "t1"); > search(variable, READ_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector); > assertSearchResults( >@@ -9806,7 +9900,7 @@ > " }\n" + > "}\n" > ); >- this.resultCollector.showSelection = true; >+ this.resultCollector.showSelection(); > IField field = this.workingCopies[1].getType("X").getField("t1"); > search(field, READ_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector); > assertSearchResults( >@@ -9834,7 +9928,7 @@ > " }\n" + > "}\n" > ); >- this.resultCollector.showSelection = true; >+ this.resultCollector.showSelection(); > ILocalVariable variable = selectLocalVariable(this.workingCopies[1], "t1"); > search(variable, WRITE_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector); > assertSearchResults( >@@ -9861,7 +9955,7 @@ > " }\n" + > "}\n" > ); >- this.resultCollector.showSelection = true; >+ this.resultCollector.showSelection(); > IField field = this.workingCopies[1].getType("X").getField("t1"); > search(field, WRITE_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector); > assertSearchResults( >@@ -9887,9 +9981,9 @@ > " }\n" + > "}\n" > ); >- this.resultCollector.showSelection = true; >- this.resultCollector.showAccess = true; >- this.resultCollector.showAccuracy = false; >+ this.resultCollector.showSelection(); >+ this.resultCollector.showAccess(); >+ this.resultCollector.showAccuracy(false); > ILocalVariable variable = selectLocalVariable(this.workingCopies[1], "t1"); > search(variable, REFERENCES, getJavaSearchWorkingCopiesScope(), this.resultCollector); > assertSearchResults( >@@ -9919,9 +10013,9 @@ > " }\n" + > "}\n" > ); >- this.resultCollector.showSelection = true; >- this.resultCollector.showAccess = true; >- this.resultCollector.showAccuracy = false; >+ this.resultCollector.showSelection(); >+ this.resultCollector.showAccess(); >+ this.resultCollector.showAccuracy(false); > IField field = this.workingCopies[1].getType("X").getField("t1"); > search(field, REFERENCES, getJavaSearchWorkingCopiesScope(), this.resultCollector); > assertSearchResults( >@@ -9949,7 +10043,7 @@ > " }\n" + > "}" > ); >- this.resultCollector.showSelection = true; >+ this.resultCollector.showSelection(); > IType type = selectType(this.workingCopies[0], "Row"); > search(type, REFERENCES, getJavaSearchWorkingCopiesScope(), this.resultCollector); > assertSearchResults( >@@ -9975,8 +10069,8 @@ > " }\n" + > "}\n" > ); >- this.resultCollector.showSelection = true; >- this.resultCollector.showRule = true; >+ this.resultCollector.showSelection(); >+ this.resultCollector.showRule(); > SearchPattern typePattern = SearchPattern.createPattern("test", TYPE, ALL_OCCURRENCES, SearchPattern.R_EXACT_MATCH); > SearchPattern methPattern = SearchPattern.createPattern("test", METHOD, ALL_OCCURRENCES, SearchPattern.R_EXACT_MATCH); > SearchPattern fieldPattern = SearchPattern.createPattern("test", FIELD, ALL_OCCURRENCES, SearchPattern.R_EXACT_MATCH); >@@ -10014,8 +10108,8 @@ > "public class Y<T extends X<?>> {\n" + > "}\n" > ); >- this.resultCollector.showSelection = true; >- this.resultCollector.showRule = true; >+ this.resultCollector.showSelection(); >+ this.resultCollector.showRule(); > IType type = this.workingCopies[0].getType("X"); > search(type, REFERENCES, SearchPattern.R_ERASURE_MATCH, getJavaSearchWorkingCopiesScope(), this.resultCollector); > assertSearchResults( >@@ -10036,8 +10130,8 @@ > "public class Z<T extends X<?> & I<?>> {\n" + > "}\n" > ); >- this.resultCollector.showSelection = true; >- this.resultCollector.showRule = true; >+ this.resultCollector.showSelection(); >+ this.resultCollector.showRule(); > IType type = this.workingCopies[0].getType("I"); > search(type, REFERENCES, SearchPattern.R_ERASURE_MATCH, getJavaSearchWorkingCopiesScope(), this.resultCollector); > assertSearchResults( >@@ -10107,7 +10201,7 @@ > "\n" + > "}\n" > ); >- this.resultCollector.showSelection = true; >+ this.resultCollector.showSelection(); > IType type = this.workingCopies[0].getType("Test"); > search(type, REFERENCES, getJavaSearchWorkingCopiesScope()); > >Index: src/org/eclipse/jdt/core/tests/model/JavaSearchGenericFieldTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchGenericFieldTests.java,v >retrieving revision 1.14 >diff -u -r1.14 JavaSearchGenericFieldTests.java >--- src/org/eclipse/jdt/core/tests/model/JavaSearchGenericFieldTests.java 27 Jun 2008 16:02:38 -0000 1.14 >+++ src/org/eclipse/jdt/core/tests/model/JavaSearchGenericFieldTests.java 15 Oct 2008 12:43:29 -0000 >@@ -30,7 +30,7 @@ > > protected void setUp () throws Exception { > super.setUp(); >- this.resultCollector.showAccuracy = true; >+ this.resultCollector.showAccuracy(true); > } > > /** >Index: src/org/eclipse/jdt/core/tests/model/JavaSearchScopeTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchScopeTests.java,v >retrieving revision 1.19 >diff -u -r1.19 JavaSearchScopeTests.java >--- src/org/eclipse/jdt/core/tests/model/JavaSearchScopeTests.java 27 Jun 2008 16:02:38 -0000 1.19 >+++ src/org/eclipse/jdt/core/tests/model/JavaSearchScopeTests.java 15 Oct 2008 12:43:30 -0000 >@@ -16,7 +16,6 @@ > > import org.eclipse.core.resources.IncrementalProjectBuilder; > import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.Path; > import org.eclipse.jdt.core.*; > import org.eclipse.jdt.core.search.*; > import org.eclipse.jdt.core.tests.model.AbstractJavaSearchTests.JavaSearchResultCollector; >@@ -873,7 +872,7 @@ > IPackageFragmentRoot root = project.getPackageFragmentRoot(getFolder("/P1/test")); > IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {root}); > JavaSearchResultCollector resultCollector = new JavaSearchResultCollector(); >- resultCollector.showProject = true; >+ resultCollector.showProject(); > search("foo", METHOD, DECLARATIONS, scope, resultCollector); > assertSearchResults( > "test/Test.java [in P1] void Test.foo() [foo]", >@@ -910,7 +909,7 @@ > ); > IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {project}); > JavaSearchResultCollector resultCollector = new JavaSearchResultCollector(); >- resultCollector.showProject = true; >+ resultCollector.showProject(); > search("ITest", TYPE, REFERENCES, scope, resultCollector); > assertSearchResults( > "test/Test.java [in P1] Test.test [ITest]\n" + >@@ -947,7 +946,7 @@ > assertNotNull("We should have a default fragment for project P1!", defaultFragment); > IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {defaultFragment}); > JavaSearchResultCollector resultCollector = new JavaSearchResultCollector(); >- resultCollector.showProject = true; >+ resultCollector.showProject(); > search("main(String[]) void", METHOD, DECLARATIONS, scope, resultCollector); > assertSearchResults( > "Test.java [in P1] void Test.main(String[]) [main]", >@@ -982,7 +981,7 @@ > ); > IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { project }); > JavaSearchResultCollector resultCollector = new JavaSearchResultCollector(); >- resultCollector.showProject = true; >+ resultCollector.showProject(); > search("Test", TYPE, REFERENCES, scope, resultCollector); > assertSearchResults( > "src/X.java [in P1] X.test [Test]", >@@ -1023,7 +1022,8 @@ > > // Index the output location as it is a library for the project > IndexManager indexManager = JavaModelManager.getIndexManager(); >- indexManager.indexLibrary(new Path("/P1/bin"), project.getProject()); >+ IPackageFragmentRoot root = project.getPackageFragmentRoot(getWorkspaceRoot().findMember("/P1/bin")); >+ indexManager.indexPackageFragmentRoot(root); > waitUntilIndexesReady(); > > // Search for all types >Index: src/org/eclipse/jdt/core/tests/model/JavaSearchFineGrainTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchFineGrainTests.java,v >retrieving revision 1.10 >diff -u -r1.10 JavaSearchFineGrainTests.java >--- src/org/eclipse/jdt/core/tests/model/JavaSearchFineGrainTests.java 27 Jun 2008 16:02:40 -0000 1.10 >+++ src/org/eclipse/jdt/core/tests/model/JavaSearchFineGrainTests.java 15 Oct 2008 12:43:29 -0000 >@@ -63,10 +63,10 @@ > protected void setUp () throws Exception { > super.setUp(); > this.resultCollector = new JavaSearchResultCollector(); >- this.resultCollector.showInsideDoc = false; >- this.resultCollector.showAccuracy = true; >- this.resultCollector.showSelection = true; >- this.resultCollector.showOffset = true; >+// this.resultCollector.showInsideDoc = false; >+ this.resultCollector.showAccuracy(true); >+ this.resultCollector.showSelection(); >+ this.resultCollector.showOffset(); > } > > static { >@@ -112,8 +112,8 @@ > "----------\n", > problemRequestor.problems.toString() > ); >- this.resultCollector.showSelection = true; >- this.resultCollector.showOffset = true; >+ this.resultCollector.showSelection(); >+ this.resultCollector.showOffset(); > return this.workingCopies[0].getType("Fields").getField("field"); > } > public void testFieldRef() throws CoreException { >@@ -193,8 +193,8 @@ > "----------\n", > problemRequestor.problems.toString() > ); >- this.resultCollector.showSelection = true; >- this.resultCollector.showOffset = true; >+ this.resultCollector.showSelection(); >+ this.resultCollector.showOffset(); > return this.workingCopies[0].getType("Methods").getMethod("method", new String[0]); > } > public void testMethodRef() throws CoreException { >@@ -574,8 +574,8 @@ > "----------\n", > problemRequestor.problems.toString() > ); >- this.resultCollector.showSelection = true; >- this.resultCollector.showOffset = true; >+ this.resultCollector.showSelection(); >+ this.resultCollector.showOffset(); > } > public void testTypeRefAll_Allocation() throws CoreException { > setUpTypeRefAll(); >@@ -749,8 +749,8 @@ > "----------\n", > problemRequestor.problems.toString() > ); >- this.resultCollector.showSelection = true; >- this.resultCollector.showOffset = true; >+ this.resultCollector.showSelection(); >+ this.resultCollector.showOffset(); > return this.workingCopies[0].getType("Types"); > } > public void testTypeRefGeneric01() throws CoreException { >@@ -970,8 +970,8 @@ > "----------\n", > problemRequestor.problems.toString() > ); >- this.resultCollector.showSelection = true; >- this.resultCollector.showOffset = true; >+ this.resultCollector.showSelection(); >+ this.resultCollector.showOffset(); > return this.workingCopies[0].getType("Types"); > } > public void testTypeRefGenericAll02() throws CoreException { >@@ -1154,8 +1154,8 @@ > "----------\n", > problemRequestor.problems.toString() > ); >- this.resultCollector.showSelection = true; >- this.resultCollector.showOffset = true; >+ this.resultCollector.showSelection(); >+ this.resultCollector.showOffset(); > } > public void testTypeRefGenericMethod_AllGenericFlags() throws CoreException { > setUpTypeRefGenericMethod(); >@@ -1279,8 +1279,8 @@ > "----------\n", > problemRequestor.problems.toString() > ); >- this.resultCollector.showSelection = true; >- this.resultCollector.showOffset = true; >+ this.resultCollector.showSelection(); >+ this.resultCollector.showOffset(); > } > public void testTypeRefQualifiedAll_Allocation() throws CoreException { > setUpTypeRefQualifiedAll(); >Index: src/org/eclipse/jdt/core/tests/model/JavaSearchMultipleProjectsTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchMultipleProjectsTests.java,v >retrieving revision 1.52 >diff -u -r1.52 JavaSearchMultipleProjectsTests.java >--- src/org/eclipse/jdt/core/tests/model/JavaSearchMultipleProjectsTests.java 27 Jun 2008 16:02:38 -0000 1.52 >+++ src/org/eclipse/jdt/core/tests/model/JavaSearchMultipleProjectsTests.java 15 Oct 2008 12:43:30 -0000 >@@ -96,7 +96,7 @@ > > IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {p1, p2}); > JavaSearchResultCollector resultCollector = new JavaSearchResultCollector(); >- resultCollector.showProject = true; >+ resultCollector.showProject(); > IField field = wc1.getType("X").getField("BAR"); > SearchPattern pattern = SearchPattern.createPattern(field, ALL_OCCURRENCES); > new SearchEngine(new ICompilationUnit[] {wc1, wc2}).search( >@@ -154,7 +154,7 @@ > IMethod method = type.getMethod("foo", new String[] {}); > IJavaSearchScope scope = SearchEngine.createHierarchyScope(type); > JavaSearchResultCollector resultCollector = new JavaSearchResultCollector(); >- resultCollector.showProject = true; >+ resultCollector.showProject(); > search( > method, > REFERENCES, >@@ -209,7 +209,7 @@ > IMethod method = type.getMethod("foo", new String[] {}); > IJavaSearchScope scope = SearchEngine.createHierarchyScope(type); > JavaSearchResultCollector resultCollector = new JavaSearchResultCollector(); >- resultCollector.showProject = true; >+ resultCollector.showProject(); > search( > method, > REFERENCES, >@@ -257,7 +257,7 @@ > IMethod method = type.getMethod("foo", new String[] {}); > IJavaSearchScope scope = SearchEngine.createHierarchyScope(type); > JavaSearchResultCollector resultCollector = new JavaSearchResultCollector(); >- resultCollector.showProject = true; >+ resultCollector.showProject(); > search( > method, > REFERENCES, >@@ -334,8 +334,8 @@ > IMethod method = type.getMethod("foo", new String[] {}); > IJavaSearchScope scope = SearchEngine.createHierarchyScope(type); > JavaSearchResultCollector resultCollector = new JavaSearchResultCollector(); >- resultCollector.showAccuracy = true; >- resultCollector.showProject = true; >+ resultCollector.showAccuracy(true); >+ resultCollector.showProject(); > search( > method, > REFERENCES, >@@ -379,7 +379,7 @@ > > IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {p1, p2}); > JavaSearchResultCollector resultCollector = new JavaSearchResultCollector(); >- resultCollector.showProject = true; >+ resultCollector.showProject(); > IMethod method = getCompilationUnit("/P1/p/I.java").getType("I").getMethod("method", new String[] {"QObject;"}); > search( > method, >@@ -418,7 +418,7 @@ > > IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {p1, p2}); > JavaSearchResultCollector resultCollector = new JavaSearchResultCollector(); >- resultCollector.showProject = true; >+ resultCollector.showProject(); > IPackageFragment pkg = getPackage("/P1/p"); > search( > pkg, >@@ -639,7 +639,7 @@ > > IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {p1}); > JavaSearchResultCollector resultCollector = new JavaSearchResultCollector(); >- resultCollector.showProject = true; >+ resultCollector.showProject(); > search( > "Object", > TYPE, >@@ -653,7 +653,7 @@ > > scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {p2}); > resultCollector = new JavaSearchResultCollector(); >- resultCollector.showProject = true; >+ resultCollector.showProject(); > search( > "Object", > TYPE, >@@ -712,7 +712,7 @@ > // search method declaration in workspace scope > IJavaSearchScope scope = SearchEngine.createWorkspaceScope(); //JavaSearchScope(new IJavaElement[] {p1, p2}); > JavaSearchResultCollector resultCollector = new JavaSearchResultCollector(); >- resultCollector.showProject = true; >+ resultCollector.showProject(); > search( > method, > DECLARATIONS, >@@ -725,7 +725,7 @@ > > // search method declaration in workspace scope with JDT-UI flags > resultCollector = new JavaSearchResultCollector(); >- resultCollector.showProject = true; >+ resultCollector.showProject(); > search( > method, > UI_DECLARATIONS, >@@ -780,7 +780,7 @@ > // search method declaration in project scope > IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {p2}); > JavaSearchResultCollector resultCollector = new JavaSearchResultCollector(); >- resultCollector.showProject = true; >+ resultCollector.showProject(); > search( > method, > UI_DECLARATIONS, >@@ -857,8 +857,8 @@ > // search method declaration in workspace scope > IJavaSearchScope scope = SearchEngine.createWorkspaceScope(); //JavaSearchScope(new IJavaElement[] {p1, p2}); > JavaSearchResultCollector resultCollector = new JavaSearchResultCollector(); >- resultCollector.showProject = true; >- resultCollector.showAccuracy = true; >+ resultCollector.showProject(); >+ resultCollector.showAccuracy(true); > search(method, REFERENCES, scope, resultCollector); > assertSearchResults( > "Unexpected references of method Test.getType()", >@@ -937,8 +937,8 @@ > // Create scope and search > IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p1, p2 }, IJavaSearchScope.SOURCES | IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.REFERENCED_PROJECTS); > JavaSearchResultCollector resultCollector = new JavaSearchResultCollector(); >- resultCollector.showProject = true; >- resultCollector.showAccuracy = true; >+ resultCollector.showProject(); >+ resultCollector.showAccuracy(true); > new SearchEngine().search( > SearchPattern.createPattern("toString", IJavaSearchConstants.METHOD, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_EXACT_MATCH), > new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, >@@ -965,8 +965,8 @@ > // Create scope and search > IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { p1, p2, p3 }, IJavaSearchScope.SOURCES | IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.REFERENCED_PROJECTS); > JavaSearchResultCollector resultCollector = new JavaSearchResultCollector(); >- resultCollector.showProject = true; >- resultCollector.showAccuracy = true; >+ resultCollector.showProject(); >+ resultCollector.showAccuracy(true); > new SearchEngine().search( > SearchPattern.createPattern("toString", IJavaSearchConstants.METHOD, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_EXACT_MATCH), > new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, >@@ -1258,8 +1258,8 @@ > SearchPattern leftPattern = SearchPattern.createPattern(typeA1, REFERENCES); > SearchPattern pattern = SearchPattern.createOrPattern(leftPattern, rightPattern); > JavaSearchResultCollector resultCollector = new JavaSearchResultCollector(); >- resultCollector.showProject = true; >- resultCollector.showAccuracy = true; >+ resultCollector.showProject(); >+ resultCollector.showAccuracy(true); > new SearchEngine().search( > pattern, > new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, >@@ -1322,8 +1322,8 @@ > // search annotation type reference in P2 scope > IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {p2}, false/*don't include referenced projects*/); > JavaSearchResultCollector resultCollector = new JavaSearchResultCollector(); >- resultCollector.showProject = true; >- resultCollector.showAccuracy = true; >+ resultCollector.showProject(); >+ resultCollector.showAccuracy(true); > search(type, ANNOTATION_TYPE_REFERENCE, scope, resultCollector); > assertSearchResults( > "Unexpected references of annotation type MyAnnot", >Index: src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java,v >retrieving revision 1.36 >diff -u -r1.36 AbstractJavaSearchTests.java >--- src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java 27 Jun 2008 16:02:38 -0000 1.36 >+++ src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java 15 Oct 2008 12:43:28 -0000 >@@ -24,6 +24,7 @@ > import org.eclipse.jdt.core.compiler.CharOperation; > import org.eclipse.jdt.core.search.*; > import org.eclipse.jdt.internal.compiler.problem.AbortCompilationUnit; >+import org.eclipse.jdt.internal.core.Member; > import org.eclipse.jdt.internal.core.PackageFragment; > //import org.eclipse.jdt.internal.core.ResolvedSourceMethod; > //import org.eclipse.jdt.internal.core.ResolvedSourceType; >@@ -47,22 +48,28 @@ > // boolean discard; > > /** >+ * Flags for the default search result collector >+ */ >+ static protected final int SHOW_ACCURACY = 0x0001; >+ static protected final int SHOW_SELECTION = 0x0002; >+ static protected final int SHOW_RULE = 0x0004; >+ static protected final int SHOW_INSIDE_DOC = 0x0008; >+ static protected final int SHOW_POTENTIAL = 0x0010; >+ static protected final int SHOW_PROJECT = 0x0020; >+ static protected final int SHOW_SYNTHETIC = 0x0040; >+ static protected final int SHOW_OFFSET = 0x0080; >+ static protected final int SHOW_ACCESS = 0x0100; >+ static protected final int SHOW_MATCH_KIND = 0x0200; >+ static protected final int SHOW_JAR_FILE = 0x0400; >+ >+ /** > * Collects results as a string. > */ > public static class JavaSearchResultCollector extends SearchRequestor { >+ int flags = SHOW_POTENTIAL; // default > protected SearchMatch match; > public StringBuffer results = new StringBuffer(), line; >- public boolean showAccuracy; >- public boolean showSelection; >- public boolean showRule; >- public boolean showInsideDoc; >- public boolean showPotential = true; >- public boolean showProject; >- public boolean showSynthetic; >- public boolean showOffset = false; >- public boolean showAccess = false; > public int showFlavors = 0; >- public boolean showMatchKind = false; > public int count = 0; > List lines = new ArrayList(); > boolean sorted; >@@ -76,7 +83,7 @@ > this.count++; > this.match = searchMatch; > writeLine(); >- if (this.line != null && (this.match.getAccuracy() == SearchMatch.A_ACCURATE || this.showPotential)) { >+ if (this.line != null && (this.match.getAccuracy() == SearchMatch.A_ACCURATE || (this.flags & SHOW_POTENTIAL) != 0)) { > this.lines.add(this.line); > } > } >@@ -88,13 +95,13 @@ > IResource resource = this.match.getResource(); > IJavaElement element = getElement(this.match); > this.line = new StringBuffer(); >- if (this.showMatchKind) { >+ if ((this.flags & SHOW_MATCH_KIND) != 0) { > String matchClassName = this.match.getClass().getName(); > this.line.append(matchClassName.substring(matchClassName.lastIndexOf('.')+1)); > this.line.append(": "); > } > this.line.append(getPathString(resource, element)); >- if (this.showProject) { >+ if ((this.flags & SHOW_PROJECT) != 0) { > IProject project = element.getJavaProject().getProject(); > this.line.append(" [in "); > this.line.append(project.getName()); >@@ -174,7 +181,7 @@ > if (start == -1 || (contents != null && contents.length > 0)) { // retrieving attached source not implemented here > this.line.append(" ["); > if (start > -1) { >- if (this.showSelection) { >+ if ((this.flags & SHOW_SELECTION) != 0) { > int lineStart1 = CharOperation.lastIndexOf('\n', contents, 0, start); > int lineStart2 = CharOperation.lastIndexOf('\r', contents, 0, start); > int lineStart = Math.max(lineStart1, lineStart2) + 1; >@@ -182,7 +189,7 @@ > this.line.append("§|"); > } > this.line.append(CharOperation.subarray(contents, start, end)); >- if (this.showSelection) { >+ if ((this.flags & SHOW_SELECTION) != 0) { > this.line.append("|§"); > int lineEnd1 = CharOperation.indexOf('\n', contents, end); > int lineEnd2 = CharOperation.indexOf('\r', contents, end); >@@ -190,7 +197,7 @@ > if (lineEnd == -1) lineEnd = contents.length; > this.line.append(CharOperation.subarray(contents, end, lineEnd)); > } >- if (this.showOffset) { >+ if ((this.flags & SHOW_OFFSET) != 0) { > this.line.append('@'); > this.line.append(start); > } >@@ -200,10 +207,10 @@ > this.line.append("]"); > } > } >- if (this.showAccuracy) { >+ if ((this.flags & SHOW_ACCURACY) != 0) { > this.line.append(" "); > if (this.match.getAccuracy() == SearchMatch.A_ACCURATE) { >- if (this.showRule) { >+ if ((this.flags & SHOW_RULE) != 0) { > if (this.match.isExact()) { > this.line.append("EXACT_"); > } else if (this.match.isEquivalent()) { >@@ -224,7 +231,7 @@ > this.line.append("POTENTIAL_MATCH"); > } > } >- if (this.showInsideDoc) { >+ if ((this.flags & SHOW_INSIDE_DOC) != 0) { > this.line.append(" "); > if (this.match.isInsideDocComment()) { > this.line.append("INSIDE_JAVADOC"); >@@ -232,7 +239,7 @@ > this.line.append("OUTSIDE_JAVADOC"); > } > } >- if (this.showSynthetic) { >+ if ((this.flags & SHOW_SYNTHETIC) != 0) { > if (this.match instanceof MethodReferenceMatch) { > MethodReferenceMatch methRef = (MethodReferenceMatch) this.match; > if (methRef.isSynthetic()) { >@@ -248,7 +255,7 @@ > } > } > } >- if (this.showAccess) { >+ if ((this.flags & SHOW_ACCESS) != 0) { > if (this.match instanceof FieldReferenceMatch) { > FieldReferenceMatch fieldRef = (FieldReferenceMatch) this.match; > if (fieldRef.isReadAccess()) { >@@ -277,6 +284,47 @@ > private boolean showSuperInvocation() { > return (this.showFlavors & PatternLocator.SUPER_INVOCATION_FLAVOR) != 0; > } >+ public void showAccess() { >+ this.flags |= SHOW_ACCESS; >+ } >+ public void showAccuracy(boolean on) { >+ if (on) { >+ this.flags |= SHOW_ACCURACY; >+ } else { >+ this.flags &= ~SHOW_ACCURACY; >+ } >+ } >+ public void showInsideDoc() { >+ this.flags |= SHOW_INSIDE_DOC; >+ } >+ public void showJarFile() { >+ this.flags |= SHOW_JAR_FILE; >+ } >+ public void showMatchKind() { >+ this.flags |= SHOW_MATCH_KIND; >+ } >+ public void showOffset() { >+ this.flags |= SHOW_OFFSET; >+ } >+ public void showPotential(boolean on) { >+ if (on) { >+ this.flags |= SHOW_POTENTIAL; >+ } else { >+ this.flags &= ~SHOW_POTENTIAL; >+ } >+ } >+ public void showProject() { >+ this.flags |= SHOW_PROJECT; >+ } >+ public void showRule() { >+ this.flags |= SHOW_RULE; >+ } >+ public void showSelection() { >+ this.flags |= SHOW_SELECTION; >+ } >+ public void showSynthetic() { >+ this.flags |= SHOW_SYNTHETIC; >+ } > protected void append(IAnnotation annotation) throws JavaModelException { > this.line.append("@"); > this.line.append(annotation.getElementName()); >@@ -405,6 +453,22 @@ > String pathString; > if (resource != null) { > IPath path = resource.getProjectRelativePath(); >+ if ((this.flags & SHOW_JAR_FILE) != 0 && element instanceof Member) { >+ IPackageFragmentRoot pkgFragmentRoot = null; >+ try { >+ pkgFragmentRoot = element.getJavaProject().findPackageFragmentRoot(resource.getFullPath()); >+ } catch (JavaModelException e) { >+ // ignore >+ } >+ if (pkgFragmentRoot != null && pkgFragmentRoot.isArchive()) { >+ if (pkgFragmentRoot.isExternal()) { >+ pathString = pkgFragmentRoot.getPath().toOSString(); >+ } else { >+ pathString = path.toString(); >+ } >+ return pathString + "|" + ((Member)element).getTypeRoot().getElementName(); >+ } >+ } > if (path.segmentCount() == 0) { > IJavaElement root = element; > while (root != null && !(root instanceof IPackageFragmentRoot)) { >Index: src/org/eclipse/jdt/core/tests/model/JavaSearchGenericTypeTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchGenericTypeTests.java,v >retrieving revision 1.22 >diff -u -r1.22 JavaSearchGenericTypeTests.java >--- src/org/eclipse/jdt/core/tests/model/JavaSearchGenericTypeTests.java 27 Jun 2008 16:02:39 -0000 1.22 >+++ src/org/eclipse/jdt/core/tests/model/JavaSearchGenericTypeTests.java 15 Oct 2008 12:43:30 -0000 >@@ -47,8 +47,8 @@ > > protected void setUp () throws Exception { > super.setUp(); >- this.resultCollector.showAccuracy = true; >- this.resultCollector.showRule = true; >+ this.resultCollector.showAccuracy(true); >+ this.resultCollector.showRule(); > } > > /* >Index: src/org/eclipse/jdt/core/tests/model/JavaSearchJavadocTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchJavadocTests.java,v >retrieving revision 1.35 >diff -u -r1.35 JavaSearchJavadocTests.java >--- src/org/eclipse/jdt/core/tests/model/JavaSearchJavadocTests.java 27 Jun 2008 16:02:39 -0000 1.35 >+++ src/org/eclipse/jdt/core/tests/model/JavaSearchJavadocTests.java 15 Oct 2008 12:43:30 -0000 >@@ -43,8 +43,8 @@ > super.setUp(); > this.originalOptions = JAVA_PROJECT.getOptions(true); > JAVA_PROJECT.setOption(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED); >- this.resultCollector.showAccuracy = true; >- this.resultCollector.showInsideDoc = true; >+ this.resultCollector.showAccuracy(true); >+ this.resultCollector.showInsideDoc(); > } > /* (non-Javadoc) > * @see org.eclipse.jdt.core.tests.model.SuiteOfTestCases#tearDownSuite() >@@ -857,8 +857,8 @@ > */ > public void testBug54962() throws CoreException { > setJavadocOptions(); >- this.resultCollector.showInsideDoc = true; >- this.resultCollector.showSelection = true; >+ this.resultCollector.showInsideDoc(); >+ this.resultCollector.showSelection(); > IPackageDeclaration packDecl = getCompilationUnit("JavaSearch", "src", "j6", "Bug54962.java").getPackageDeclaration("j6"); > search(packDecl, REFERENCES, getJavaSearchScope()); > assertSearchResults( >@@ -871,8 +871,8 @@ > // TODO (frederic) should no longer get POTENTIAL after 196200 got fixed > public void testBug54962qualified() throws CoreException { > setJavadocOptions(); >- this.resultCollector.showInsideDoc = true; >- this.resultCollector.showSelection = true; >+ this.resultCollector.showInsideDoc(); >+ this.resultCollector.showSelection(); > IPackageDeclaration packDecl = getCompilationUnit("JavaSearch", "src", "j7.qua.li.fied", "Bug54962a.java").getPackageDeclaration("j7.qua.li.fied"); > search(packDecl, REFERENCES, getJavaSearchScope()); > assertSearchResults( >@@ -889,7 +889,7 @@ > */ > public void testBug71267() throws CoreException { > setJavadocOptions(); >- this.resultCollector.showInsideDoc = true; >+ this.resultCollector.showInsideDoc(); > IPackageDeclaration packDecl = getCompilationUnit("JavaSearch", "src", "p71267", "Test.java").getPackageDeclaration("p71267"); > search(packDecl, REFERENCES, getJavaSearchScope()); > assertSearchResults( >@@ -900,7 +900,7 @@ > } > public void testBug71267qualified() throws CoreException { > setJavadocOptions(); >- this.resultCollector.showInsideDoc = true; >+ this.resultCollector.showInsideDoc(); > IPackageDeclaration packDecl = getCompilationUnit("JavaSearch", "src", "p71267.q71267", "Test.java").getPackageDeclaration("p71267.q71267"); > search(packDecl, REFERENCES, getJavaSearchScope()); > assertSearchResults( >@@ -918,7 +918,7 @@ > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=83285" > */ > public void testBug83285() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > this.workingCopies = new ICompilationUnit[1]; > this.workingCopies[0] = getWorkingCopy("/JavaSearch/src/b83285/A.java", > "package b83285;\n" + >@@ -941,7 +941,7 @@ > ); > } > public void testBug83285a() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > this.workingCopies = new ICompilationUnit[1]; > this.workingCopies[0] = getWorkingCopy("/JavaSearch/src/b83285/A.java", > "package b83285;\n" + >@@ -974,7 +974,7 @@ > ); > } > public void testBug83285b() throws CoreException { >- this.resultCollector.showRule = true; >+ this.resultCollector.showRule(); > this.workingCopies = new ICompilationUnit[1]; > this.workingCopies[0] = getWorkingCopy("/JavaSearch/src/b83285/A.java", > "package b83285;\n" +
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 12044
:
115133
|
115139
|
115140
|
115157
|
115271
|
115273
|
116951
|
118501