Example usage for org.eclipse.jdt.internal.core.index FileIndexLocation FileIndexLocation

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

Introduction

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

Prototype

public FileIndexLocation(File file) 

Source Link

Usage

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

License:Open Source License

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());
        String fileName = Long.toString(checksumCalculator.getValue()) + ".index"; //$NON-NLS-1$
        if (VERBOSE)
            Util.verbose("-> index name for " + pathString + " is " + fileName); //$NON-NLS-1$ //$NON-NLS-2$
        // 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);
    }//from   w  ww .  ja v a2s  .  c  om
    return indexLocation;
}

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

License:Open Source License

private void deleteIndexFiles(SimpleSet pathsToKeep) {
    File[] indexesFiles = getSavedIndexesDirectory().listFiles();
    if (indexesFiles == null)
        return;//from ww w  . ja  v a2 s . c om

    for (int i = 0, l = indexesFiles.length; i < l; i++) {
        String fileName = indexesFiles[i].getAbsolutePath();
        if (pathsToKeep != null && pathsToKeep.includes(new FileIndexLocation(indexesFiles[i])))
            continue;
        String suffix = ".index"; //$NON-NLS-1$
        if (fileName.regionMatches(true, fileName.length() - suffix.length(), suffix, 0, suffix.length())) {
            if (VERBOSE || DEBUG)
                Util.verbose("Deleting index file " + indexesFiles[i]); //$NON-NLS-1$
            indexesFiles[i].delete();
        }
    }
}

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

License:Open Source License

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(
                        new File(indexesDirectoryPath, String.valueOf(savedName))); // shares indexesDirectoryPath's segments
                if (VERBOSE)
                    Util.verbose("Reading saved index file " + indexLocation); //$NON-NLS-1$
                this.indexStates.put(indexLocation, SAVED_STATE);
            }/*from w  w w  . ja  v a2  s. c  o  m*/
        }
    } 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;
}