use of org.eclipse.jdt.internal.core.index.IndexLocation in project che by eclipse.
the class IndexManager method computeIndexLocation.
public synchronized IndexLocation computeIndexLocation(IPath containerPath) {
IndexLocation indexLocation = (IndexLocation) this.indexLocations.get(containerPath);
if (indexLocation == null) {
String pathString = containerPath.toOSString();
CRC32 checksumCalculator = new CRC32();
checksumCalculator.update(pathString.getBytes());
//$NON-NLS-1$
String fileName = Long.toString(checksumCalculator.getValue()) + ".index";
if (JobManager.VERBOSE)
//$NON-NLS-1$ //$NON-NLS-2$
Util.verbose("-> index name for " + pathString + " is " + fileName);
// to share the indexLocation between the indexLocations and indexStates tables, get the key from the indexStates table
indexLocation = (IndexLocation) getIndexStates().getKey(new FileIndexLocation(new File(getSavedIndexesDirectory(), fileName)));
this.indexLocations.put(containerPath, indexLocation);
}
return indexLocation;
}
use of org.eclipse.jdt.internal.core.index.IndexLocation in project che by eclipse.
the class IndexManager method resetIndex.
/**
* Resets the index for a given path.
* Returns true if the index was reset, false otherwise.
*/
public synchronized boolean resetIndex(IPath containerPath) {
// only called to over write an existing cached index...
String containerPathString = containerPath.getDevice() == null ? containerPath.toString() : containerPath.toOSString();
try {
// Path is already canonical
IndexLocation indexLocation = computeIndexLocation(containerPath);
Index index = getIndex(indexLocation);
if (JobManager.VERBOSE) {
//$NON-NLS-1$ //$NON-NLS-2$
Util.verbose("-> reseting index: " + indexLocation + " for path: " + containerPathString);
}
if (index == null) {
// the index does not exist, try to recreate it
return recreateIndex(containerPath) != null;
}
index.reset();
return true;
} catch (IOException e) {
// The file could not be created. Possible reason: the project has been deleted.
if (JobManager.VERBOSE) {
//$NON-NLS-1$
Util.verbose("-> failed to reset index for path: " + containerPathString);
e.printStackTrace();
}
return false;
}
}
Aggregations