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 176958 Details for
Bug 308402
[index] PatternSearchJob ignores participant index entries
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch on HEAD
patch2.txt (text/plain), 10.21 KB, created by
Satyam Kandula
on 2010-08-19 01:00:29 EDT
(
hide
)
Description:
Proposed patch on HEAD
Filename:
MIME Type:
Creator:
Satyam Kandula
Created:
2010-08-19 01:00:29 EDT
Size:
10.21 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: search/org/eclipse/jdt/core/search/SearchParticipant.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchParticipant.java,v >retrieving revision 1.27 >diff -u -r1.27 SearchParticipant.java >--- search/org/eclipse/jdt/core/search/SearchParticipant.java 27 Jun 2008 16:04:08 -0000 1.27 >+++ search/org/eclipse/jdt/core/search/SearchParticipant.java 19 Aug 2010 04:58:11 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -49,6 +49,8 @@ > */ > public abstract class SearchParticipant { > >+ private IPath lastIndexLocation; >+ > /** > * Creates a new search participant. > */ >@@ -205,6 +207,10 @@ > // TODO (frederic) should not have to create index manually, should expose API that recreates index instead > manager.ensureIndexExists(indexLocation, containerPath); > manager.scheduleDocumentIndexing(document, containerPath, indexLocation, this); >+ if (indexLocation != this.lastIndexLocation) { >+ manager.updateParticipant(indexLocation, containerPath); >+ this.lastIndexLocation = indexLocation; >+ } > } > > /** >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.167 >diff -u -r1.167 IndexManager.java >--- search/org/eclipse/jdt/internal/core/search/indexing/IndexManager.java 9 Aug 2010 05:49:23 -0000 1.167 >+++ search/org/eclipse/jdt/internal/core/search/indexing/IndexManager.java 19 Aug 2010 04:58:11 -0000 >@@ -58,6 +58,11 @@ > public static final Integer UPDATING_STATE = new Integer(1); > public static final Integer UNKNOWN_STATE = new Integer(2); > public static final Integer REBUILDING_STATE = new Integer(3); >+ >+ // search participants who register indexes with the index manager >+ private SimpleLookupTable participantsContainers = null; >+ private boolean participantUpdated = false; >+ private static final String PARTICIPANTS_INDEX_NAMES = "participantsIndexNames.txt"; //$NON-NLS-1$ > > // Debug > public static boolean DEBUG = false; >@@ -324,6 +329,20 @@ > rebuildIndex(indexLocation, containerPath); > index = null; > } >+ } else { >+ if (!getJavaPluginWorkingLocation().isPrefixOf(indexLocation)) { // the index belongs to non-jdt search participant >+ if (indexLocation.toFile().exists()) { >+ try { >+ IPath container = getParticipantsContainer(indexLocation); >+ if (container != null) { >+ index = new Index(indexLocation.toOSString(), container.toOSString(), true /*reuse index file*/); >+ this.indexes.put(indexLocation, index); >+ } >+ } catch (IOException e) { >+ // ignore >+ } >+ } >+ } > } > } > if (index != null) >@@ -370,6 +389,13 @@ > } > return this.indexStates; > } >+private IPath getParticipantsContainer(IPath indexLocation) { >+ if (this.participantsContainers == null) { >+ readParticipantsIndexNamesFile(); >+ if (this.participantsContainers == null) return null; >+ } >+ return (IPath)this.participantsContainers.get(indexLocation); >+} > private IPath getJavaPluginWorkingLocation() { > if (this.javaPluginLocation != null) return this.javaPluginLocation; > >@@ -662,6 +688,9 @@ > this.indexes.removeKey(locations[i]); > removeIndexesState(locations); > } >+ if (this.participantsContainers != null && this.participantsContainers.get(path.toOSString()) != null) { >+ this.participantsContainers.removeKey(path.toOSString()); >+ } > } > /** > * Removes all indexes whose paths start with (or are equal to) the given path. >@@ -802,6 +831,10 @@ > monitor.exitRead(); > } > } >+ if (this.participantsContainers != null && this.participantUpdated) { >+ writeParticipantsIndexNamesFile(); >+ this.participantUpdated = false; >+ } > this.needToSave = !allSaved; > } > public void scheduleDocumentIndexing(final SearchDocument searchDocument, IPath container, final IPath indexLocation, final SearchParticipant searchParticipant) { >@@ -861,6 +894,30 @@ > } > return null; > } >+private void readParticipantsIndexNamesFile() { >+ try { >+ File participantsIndexNamesFile = new File(getSavedIndexesDirectory(), PARTICIPANTS_INDEX_NAMES); >+ char[] savedIndexNames = org.eclipse.jdt.internal.compiler.util.Util.getFileCharContent(participantsIndexNamesFile, null); >+ if (savedIndexNames.length > 0) { >+ char[][] names = CharOperation.splitOn('\n', savedIndexNames); >+ if (names.length >= 3) { >+ // First line is DiskIndex signature (see writeParticipantsIndexNamesFile()) >+ String savedSignature = DiskIndex.SIGNATURE; >+ if (savedSignature.equals(new String(names[0]))) { >+ SimpleLookupTable containers = new SimpleLookupTable(3); >+ for (int i = 1, l = names.length-1 ; i < l ; i+=2) { >+ containers.put(new Path(new String(names[i])), new Path(new String(names[i+1]))); >+ } >+ this.participantsContainers = containers; >+ } >+ } >+ } >+ } catch (IOException ignored) { >+ if (VERBOSE) >+ Util.verbose("Failed to read saved index file names"); //$NON-NLS-1$ >+ } >+ return; >+} > private synchronized void removeIndexesState(IPath[] locations) { > getIndexStates(); // ensure the states are initialized > int length = locations.length; >@@ -907,6 +964,17 @@ > } > > } >+public void updateParticipant(IPath indexLocation, IPath containerPath) { >+ if (this.participantsContainers == null) { >+ readParticipantsIndexNamesFile(); >+ if (this.participantsContainers == null) >+ this.participantsContainers = new SimpleLookupTable(3); >+ } >+ if (this.participantsContainers.get(indexLocation) == null) { >+ this.participantsContainers.put(indexLocation, containerPath); >+ this.participantUpdated = true; >+ } >+} > private void writeJavaLikeNamesFile() { > BufferedWriter writer = null; > String pathName = getJavaPluginWorkingLocation().toOSString(); >@@ -941,6 +1009,37 @@ > } > } > } >+private void writeParticipantsIndexNamesFile() { >+ BufferedWriter writer = null; >+ try { >+ File participantsIndexNamesFile = new File(getSavedIndexesDirectory(), PARTICIPANTS_INDEX_NAMES); >+ writer = new BufferedWriter(new FileWriter(participantsIndexNamesFile)); >+ writer.write(DiskIndex.SIGNATURE); >+ writer.write('\n'); >+ Object[] indexFiles = this.participantsContainers.keyTable; >+ Object[] containers = this.participantsContainers.valueTable; >+ for (int i = 0, l = indexFiles.length; i < l; i++) { >+ IPath indexFile = (IPath)indexFiles[i]; >+ if (indexFile != null) { >+ writer.write(indexFile.toOSString()); >+ writer.write('\n'); >+ writer.write(((IPath)containers[i]).toOSString()); >+ writer.write('\n'); >+ } >+ } >+ } catch (IOException ignored) { >+ if (VERBOSE) >+ Util.verbose("Failed to write participant index file names", System.err); //$NON-NLS-1$ >+ } finally { >+ if (writer != null) { >+ try { >+ writer.close(); >+ } catch (IOException e) { >+ // ignore >+ } >+ } >+ } >+} > private void writeSavedIndexNamesFile() { > BufferedWriter writer = null; > try { >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/SearchParticipantTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SearchParticipantTests.java,v >retrieving revision 1.18 >diff -u -r1.18 SearchParticipantTests.java >--- src/org/eclipse/jdt/core/tests/model/SearchParticipantTests.java 27 Jun 2008 16:02:38 -0000 1.18 >+++ src/org/eclipse/jdt/core/tests/model/SearchParticipantTests.java 19 Aug 2010 04:58:14 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -127,7 +127,7 @@ > // Use this static initializer to specify subset for tests > // All specified tests which do not belong to the class are skipped... > static { >-// TESTS_NAMES = new String[] { "testSearch"}; >+ // TESTS_NAMES = new String[] { "testSearchAfterRestart"}; > // TESTS_NUMBERS = new int[] { 23, 28, 38 }; > // TESTS_RANGE = new int[] { 21, 38 }; > } >@@ -314,4 +314,40 @@ > "X.test X [X]", > requestor); > } >+ >+ /* >+ * Ensures that a simple search that forwards queries to the default participant works as expected even after restart >+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=308402 >+ */ >+ public void testSearchAfterRestart() throws CoreException { >+ createFile( >+ "/P/X.test", >+ "public class X {\n" + >+ "}" >+ ); >+ >+ // index file >+ TestSearchParticipant participant = new TestSearchParticipant(); >+ TestSearchDocument document = new TestSearchDocument("/P/X.test", participant); >+ participant.scheduleDocumentIndexing(document, getIndexLocation()); >+ waitUntilIndexesReady(); >+ try { >+ Thread.sleep(5000); // wait for the indexes to go into the disk >+ } catch (InterruptedException e) { >+ // ignore >+ } >+ simulateExit(); >+ simulateRestart(); >+ waitUntilIndexesReady(); >+ >+ // search for declaration of X >+ SearchPattern pattern = SearchPattern.createPattern("X", IJavaSearchConstants.DECLARATIONS, IJavaSearchConstants.TYPE, SearchPattern.R_EXACT_MATCH); >+ IJavaSearchScope scope = SearchEngine.createWorkspaceScope(); >+ SearchRequestor requestor = new TestResultCollector(); >+ new SearchEngine().search(pattern, new SearchParticipant[] {participant}, scope, requestor, null); >+ assertSearchResults( >+ "X.test X [X]", >+ requestor); >+ >+ } > }
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 308402
:
176958
|
176961
|
177018
|
177073