use of org.eclipse.jdt.internal.core.index.IndexLocation in project che by eclipse.
the class IndexManager method computeIndexLocation.
/**
* Compute the pre-built index location for a specified URL
*/
public synchronized IndexLocation computeIndexLocation(IPath containerPath, final URL newIndexURL) {
IndexLocation indexLocation = (IndexLocation) this.indexLocations.get(containerPath);
if (indexLocation == null) {
if (newIndexURL != null) {
indexLocation = IndexLocation.createIndexLocation(newIndexURL);
// update caches
indexLocation = (IndexLocation) getIndexStates().getKey(indexLocation);
this.indexLocations.put(containerPath, indexLocation);
}
} else {
// an existing index location exists - make sure it has not changed (i.e. the URL has not changed)
URL existingURL = indexLocation.getUrl();
if (newIndexURL != null) {
// if either URL is different then the index location has been updated so rebuild.
if (!newIndexURL.equals(existingURL)) {
// URL has changed so remove the old index and create a new one
this.removeIndex(containerPath);
// create a new one
indexLocation = IndexLocation.createIndexLocation(newIndexURL);
// update caches
indexLocation = (IndexLocation) getIndexStates().getKey(indexLocation);
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 indexLibrary.
/**
* Trigger addition of a library to an index
* Note: the actual operation is performed in background
*/
public void indexLibrary(IPath path, IProject requestingProject, URL indexURL, final boolean updateIndex) {
// requestingProject is no longer used to cancel jobs but leave it here just in case
IndexLocation indexFile = null;
if (indexURL != null) {
if (IS_MANAGING_PRODUCT_INDEXES_PROPERTY) {
indexFile = computeIndexLocation(path, indexURL);
} else {
indexFile = IndexLocation.createIndexLocation(indexURL);
}
}
// if (JavaCore.getPlugin() == null) return;
IndexRequest request = null;
boolean forceIndexUpdate = IS_MANAGING_PRODUCT_INDEXES_PROPERTY && updateIndex;
// Object target = JavaModel.getTarget(path, true);
// if (target instanceof IFile) {
// request = new AddJarFileToIndex((IFile) target, indexFile, this, forceIndexUpdate);
// } else
// if (target instanceof File) {
request = new AddJarFileToIndex(path, indexFile, this, forceIndexUpdate);
// check if the same request is not already in the queue
if (!isJobWaiting(request))
request(request);
}
use of org.eclipse.jdt.internal.core.index.IndexLocation in project che by eclipse.
the class IndexManager method getIndexStates.
private SimpleLookupTable getIndexStates() {
if (this.indexStates != null)
return this.indexStates;
this.indexStates = new SimpleLookupTable();
File indexesDirectoryPath = getSavedIndexesDirectory();
char[][] savedNames = readIndexState(getJavaPluginWorkingLocation().toOSString());
if (savedNames != null) {
for (int i = 1, l = savedNames.length; i < l; i++) {
// first name is saved signature, see readIndexState()
char[] savedName = savedNames[i];
if (savedName.length > 0) {
IndexLocation indexLocation = new FileIndexLocation(// shares indexesDirectoryPath's segments
new File(indexesDirectoryPath, String.valueOf(savedName)));
if (JobManager.VERBOSE)
//$NON-NLS-1$
Util.verbose("Reading saved index file " + indexLocation);
this.indexStates.put(indexLocation, SAVED_STATE);
}
}
} else {
// All the index files are getting deleted and hence there is no need to
// further check for change in javaLikeNames.
writeJavaLikeNamesFile();
this.javaLikeNamesChanged = false;
deleteIndexFiles();
}
readIndexMap();
return this.indexStates;
}
use of org.eclipse.jdt.internal.core.index.IndexLocation in project che by eclipse.
the class IndexManager method updateParticipant.
public void updateParticipant(IPath indexPath, IPath containerPath) {
if (this.participantsContainers == null) {
readParticipantsIndexNamesFile();
}
IndexLocation indexLocation = new FileIndexLocation(indexPath.toFile(), true);
if (this.participantsContainers.get(indexLocation) == null) {
this.participantsContainers.put(indexLocation, containerPath);
this.participantUpdated = true;
}
}
use of org.eclipse.jdt.internal.core.index.IndexLocation in project che by eclipse.
the class IndexManager method removeIndexPath.
/**
* Removes all indexes whose paths start with (or are equal to) the given path.
*/
public synchronized void removeIndexPath(IPath path) {
if (JobManager.VERBOSE || DEBUG)
//$NON-NLS-1$
Util.verbose("removing index path " + path);
Object[] keyTable = this.indexes.keyTable;
Object[] valueTable = this.indexes.valueTable;
IndexLocation[] locations = null;
int max = this.indexes.elementSize;
int count = 0;
for (int i = 0, l = keyTable.length; i < l; i++) {
IndexLocation indexLocation = (IndexLocation) keyTable[i];
if (indexLocation == null)
continue;
if (indexLocation.startsWith(path)) {
Index index = (Index) valueTable[i];
index.monitor = null;
if (locations == null)
locations = new IndexLocation[max];
locations[count++] = indexLocation;
if (this.indexStates.get(indexLocation) == REUSE_STATE) {
indexLocation.close();
} else {
if (DEBUG)
//$NON-NLS-1$
Util.verbose("removing index file " + indexLocation);
indexLocation.delete();
}
} else {
max--;
}
}
if (locations != null) {
for (int i = 0; i < count; i++) this.indexes.removeKey(locations[i]);
removeIndexesState(locations);
if (this.participantsContainers != null) {
boolean update = false;
for (int i = 0; i < count; i++) {
if (this.participantsContainers.get(locations[i]) != null) {
update = true;
this.participantsContainers.removeKey(locations[i]);
}
}
if (update)
writeParticipantsIndexNamesFile();
}
}
}
Aggregations