Example usage for org.eclipse.jdt.internal.core.index IndexLocation startsWith

List of usage examples for org.eclipse.jdt.internal.core.index IndexLocation startsWith

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core.index IndexLocation startsWith.

Prototype

public abstract boolean startsWith(IPath path);

Source Link

Usage

From source file:com.codenvy.ide.ext.java.server.internal.core.search.indexing.IndexManager.java

License:Open Source License

/**
 * Removes all indexes whose paths start with (or are equal to) the given path.
 *//*from   w w w .j  av a2 s  . c  o  m*/
public synchronized void removeIndexPath(IPath path) {
    if (VERBOSE || DEBUG)
        Util.verbose("removing index path " + path); //$NON-NLS-1$
    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)
                    Util.verbose("removing index file " + indexLocation); //$NON-NLS-1$
                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();
        }
    }
}