View | Details | Raw Unified | Return to bug 215841 | Differences between
and this patch

Collapse All | Expand All

(-)search/org/eclipse/jdt/internal/core/search/SubTypeSearchJob.java (+9 lines)
Lines 28-33 Link Here
28
		if (values[i] != null)
28
		if (values[i] != null)
29
			((Index) values[i]).stopQuery();
29
			((Index) values[i]).stopQuery();
30
}
30
}
31
public Index[] getIndexes(IProgressMonitor progressMonitor) {
32
	if (this.indexes.elementSize == 0) {
33
		return super.getIndexes(progressMonitor);
34
	}
35
	this.areIndexesReady = true; // use stored indexes until the job's end
36
	Index[] values = new Index[this.indexes.elementSize];
37
	this.indexes.asArray(values);
38
	return values;
39
}	
31
public boolean search(Index index, IProgressMonitor progressMonitor) {
40
public boolean search(Index index, IProgressMonitor progressMonitor) {
32
	if (index == null) return COMPLETE;
41
	if (index == null) return COMPLETE;
33
	if (indexes.addIfNotIncluded(index) == index)
42
	if (indexes.addIfNotIncluded(index) == index)
(-)search/org/eclipse/jdt/internal/core/search/PatternSearchJob.java (-22 / +2 lines)
Lines 18-24 Link Here
18
import org.eclipse.jdt.core.search.*;
18
import org.eclipse.jdt.core.search.*;
19
import org.eclipse.jdt.internal.core.JavaModelManager;
19
import org.eclipse.jdt.internal.core.JavaModelManager;
20
import org.eclipse.jdt.internal.core.index.Index;
20
import org.eclipse.jdt.internal.core.index.Index;
21
import org.eclipse.jdt.internal.core.search.indexing.IndexManager;
22
import org.eclipse.jdt.internal.core.search.indexing.ReadWriteMonitor;
21
import org.eclipse.jdt.internal.core.search.indexing.ReadWriteMonitor;
23
import org.eclipse.jdt.internal.core.search.matching.MatchLocator;
22
import org.eclipse.jdt.internal.core.search.matching.MatchLocator;
24
import org.eclipse.jdt.internal.core.search.processing.IJob;
23
import org.eclipse.jdt.internal.core.search.processing.IJob;
Lines 79-105 Link Here
79
	// acquire the in-memory indexes on the fly
78
	// acquire the in-memory indexes on the fly
80
	IPath[] indexLocations = this.participant.selectIndexes(this.pattern, this.scope);
79
	IPath[] indexLocations = this.participant.selectIndexes(this.pattern, this.scope);
81
	int length = indexLocations.length;
80
	int length = indexLocations.length;
82
	Index[] indexes = new Index[length];
81
	Index[] indexes = JavaModelManager.getIndexManager().getIndexes(indexLocations, progressMonitor);
83
	int count = 0;
82
	this.areIndexesReady = indexes.length == length;
84
	IndexManager indexManager = JavaModelManager.getIndexManager();
85
	for (int i = 0; i < length; i++) {
86
		if (progressMonitor != null && progressMonitor.isCanceled()) throw new OperationCanceledException();
87
		// may trigger some index recreation work
88
		IPath indexLocation = indexLocations[i];
89
		Index index = indexManager.getIndex(indexLocation);
90
		if (index == null) {
91
			// only need containerPath if the index must be built
92
			IPath containerPath = (IPath) indexManager.indexLocations.keyForValue(indexLocation);
93
			if (containerPath != null) // sanity check
94
				index = indexManager.getIndex(containerPath, indexLocation, true /*reuse index file*/, false /*do not create if none*/);
95
		}
96
		if (index != null)
97
			indexes[count++] = index; // only consider indexes which are ready
98
	}
99
	if (count == length) 
100
		this.areIndexesReady = true;
101
	else
102
		System.arraycopy(indexes, 0, indexes=new Index[count], 0, count);
103
	return indexes;
83
	return indexes;
104
}	
84
}	
105
public String getJobFamily() {
85
public String getJobFamily() {
(-)search/org/eclipse/jdt/internal/core/search/indexing/IndexManager.java (-9 / +53 lines)
Lines 17-22 Link Here
17
import org.eclipse.core.resources.*;
17
import org.eclipse.core.resources.*;
18
import org.eclipse.core.runtime.IPath;
18
import org.eclipse.core.runtime.IPath;
19
import org.eclipse.core.runtime.IProgressMonitor;
19
import org.eclipse.core.runtime.IProgressMonitor;
20
import org.eclipse.core.runtime.OperationCanceledException;
20
import org.eclipse.core.runtime.Path;
21
import org.eclipse.core.runtime.Path;
21
import org.eclipse.jdt.core.*;
22
import org.eclipse.jdt.core.*;
22
import org.eclipse.jdt.core.compiler.CharOperation;
23
import org.eclipse.jdt.core.compiler.CharOperation;
Lines 191-196 Link Here
191
	return parser;
192
	return parser;
192
}
193
}
193
/**
194
/**
195
 * Returns the index for a given index location
196
 * 
197
 * @param indexLocation The path of the index file
198
 * @return The corresponding index or <code>null</code> if not found
199
 */
200
public synchronized Index getIndex(IPath indexLocation) {
201
	return (Index) this.indexes.get(indexLocation); // is null if unknown, call if the containerPath must be computed
202
}
203
/**
194
 * Returns the index for a given project, according to the following algorithm:
204
 * Returns the index for a given project, according to the following algorithm:
195
 * - if index is already in memory: answers this one back
205
 * - if index is already in memory: answers this one back
196
 * - if (reuseExistingFile) then read it and return this index and record it in memory
206
 * - if (reuseExistingFile) then read it and return this index and record it in memory
Lines 268-276 Link Here
268
	//System.out.println(" index name: " + path.toOSString() + " <----> " + index.getIndexFile().getName());	
278
	//System.out.println(" index name: " + path.toOSString() + " <----> " + index.getIndexFile().getName());	
269
	return index;
279
	return index;
270
}
280
}
271
public synchronized Index getIndex(IPath indexLocation) {
281
/**
272
	return (Index) this.indexes.get(indexLocation); // is null if unknown, call if the containerPath must be computed
282
 * Returns all the existing indexes for a list of index locations.
273
}
283
 * Note that this may trigger some indexes recreation work
284
 * 
285
 * @param locations The list of of the index files path
286
 * @return The corresponding indexes list.
287
 */
288
public Index[] getIndexes(IPath[] locations, IProgressMonitor progressMonitor) {
289
	// acquire the in-memory indexes on the fly
290
	int length = locations.length;
291
	Index[] locatedIndexes = new Index[length];
292
	int count = 0;
293
	for (int i = 0; i < length; i++) {
294
		if (progressMonitor != null && progressMonitor.isCanceled()) {
295
			throw new OperationCanceledException();
296
		}
297
		// may trigger some index recreation work
298
		IPath indexLocation = locations[i];
299
		Index index = getIndex(indexLocation);
300
		if (index == null) {
301
			// only need containerPath if the index must be built
302
			IPath containerPath = (IPath) indexLocations.keyForValue(indexLocation);
303
			if (containerPath != null) // sanity check
304
				index = getIndex(containerPath, indexLocation, true /*reuse index file*/, false /*do not create if none*/);
305
		}
306
		if (index != null)
307
			locatedIndexes[count++] = index; // only consider indexes which are ready
308
	}
309
	if (count < length) {
310
		System.arraycopy(locatedIndexes, 0, locatedIndexes=new Index[count], 0, count);
311
	}
312
	return locatedIndexes;
313
}	
274
public synchronized Index getIndexForUpdate(IPath containerPath, boolean reuseExistingFile, boolean createIfMissing) {
314
public synchronized Index getIndexForUpdate(IPath containerPath, boolean reuseExistingFile, boolean createIfMissing) {
275
	IPath indexLocation = computeIndexLocation(containerPath);
315
	IPath indexLocation = computeIndexLocation(containerPath);
276
	if (getIndexStates().get(indexLocation) == REBUILDING_STATE)
316
	if (getIndexStates().get(indexLocation) == REBUILDING_STATE)
Lines 726-737 Link Here
726
	writeSavedIndexNamesFile();
766
	writeSavedIndexNamesFile();
727
767
728
	if (VERBOSE) {
768
	if (VERBOSE) {
729
		String state = "?"; //$NON-NLS-1$
769
		if (indexState == null) {
730
		if (indexState == SAVED_STATE) state = "SAVED"; //$NON-NLS-1$
770
			Util.verbose("-> index state removed for: "+indexLocation); //$NON-NLS-1$
731
		else if (indexState == UPDATING_STATE) state = "UPDATING"; //$NON-NLS-1$
771
		} else {
732
		else if (indexState == UNKNOWN_STATE) state = "UNKNOWN"; //$NON-NLS-1$
772
			String state = "?"; //$NON-NLS-1$
733
		else if (indexState == REBUILDING_STATE) state = "REBUILDING"; //$NON-NLS-1$
773
			if (indexState == SAVED_STATE) state = "SAVED"; //$NON-NLS-1$
734
		Util.verbose("-> index state updated to: " + state + " for: "+indexLocation); //$NON-NLS-1$ //$NON-NLS-2$
774
			else if (indexState == UPDATING_STATE) state = "UPDATING"; //$NON-NLS-1$
775
			else if (indexState == UNKNOWN_STATE) state = "UNKNOWN"; //$NON-NLS-1$
776
			else if (indexState == REBUILDING_STATE) state = "REBUILDING"; //$NON-NLS-1$
777
			Util.verbose("-> index state updated to: " + state + " for: "+indexLocation); //$NON-NLS-1$ //$NON-NLS-2$
778
		}
735
	}
779
	}
736
}
780
}
737
private void writeSavedIndexNamesFile() {
781
private void writeSavedIndexNamesFile() {

Return to bug 215841