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() { |