Example usage for org.eclipse.jdt.internal.core.search PatternSearchJob getIndexes

List of usage examples for org.eclipse.jdt.internal.core.search PatternSearchJob getIndexes

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core.search PatternSearchJob getIndexes.

Prototype

public Index[] getIndexes(IProgressMonitor progressMonitor) 

Source Link

Usage

From source file:org.eclipse.jdt.internal.core.search.indexing.IndexManager.java

License:Open Source License

public void cleanUpIndexes() {
    SimpleSet knownPaths = new SimpleSet();
    IJavaSearchScope scope = BasicSearchEngine.createWorkspaceScope();
    PatternSearchJob job = new PatternSearchJob(null, SearchEngine.getDefaultSearchParticipant(), scope, null);
    Index[] selectedIndexes = job.getIndexes(null);
    for (int i = 0, l = selectedIndexes.length; i < l; i++) {
        String path = selectedIndexes[i].getIndexFile().getAbsolutePath();
        knownPaths.add(path);//from  w  ww. j a v a  2 s . c  o  m
    }

    if (this.indexStates != null) {
        Object[] keys = this.indexStates.keyTable;
        IPath[] locations = new IPath[this.indexStates.elementSize];
        int count = 0;
        for (int i = 0, l = keys.length; i < l; i++) {
            IPath key = (IPath) keys[i];
            if (key != null && !knownPaths.includes(key.toOSString()))
                locations[count++] = key;
        }
        if (count > 0)
            removeIndexesState(locations);
    }
    deleteIndexFiles(knownPaths);
}