Search in sources :

Example 1 with FileIndexLocation

use of org.eclipse.jdt.internal.core.index.FileIndexLocation 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;
}
Also used : SimpleLookupTable(org.eclipse.jdt.internal.compiler.util.SimpleLookupTable) FileIndexLocation(org.eclipse.jdt.internal.core.index.FileIndexLocation) IndexLocation(org.eclipse.jdt.internal.core.index.IndexLocation) FileIndexLocation(org.eclipse.jdt.internal.core.index.FileIndexLocation) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Example 2 with FileIndexLocation

use of org.eclipse.jdt.internal.core.index.FileIndexLocation 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;
    }
}
Also used : FileIndexLocation(org.eclipse.jdt.internal.core.index.FileIndexLocation) IndexLocation(org.eclipse.jdt.internal.core.index.IndexLocation) FileIndexLocation(org.eclipse.jdt.internal.core.index.FileIndexLocation)

Example 3 with FileIndexLocation

use of org.eclipse.jdt.internal.core.index.FileIndexLocation in project che by eclipse.

the class IndexManager method readParticipantsIndexNamesFile.

private void readParticipantsIndexNamesFile() {
    SimpleLookupTable containers = new SimpleLookupTable(3);
    try {
        char[] participantIndexNames = org.eclipse.jdt.internal.compiler.util.Util.getFileCharContent(this.participantIndexNamesFile, null);
        if (participantIndexNames.length > 0) {
            char[][] names = CharOperation.splitOn('\n', participantIndexNames);
            if (names.length >= 3) {
                // First line is DiskIndex signature  (see writeParticipantsIndexNamesFile())
                if (DiskIndex.SIGNATURE.equals(new String(names[0]))) {
                    for (int i = 1, l = names.length - 1; i < l; i += 2) {
                        IndexLocation indexLocation = new FileIndexLocation(new File(new String(names[i])), true);
                        containers.put(indexLocation, new Path(new String(names[i + 1])));
                    }
                }
            }
        }
    } catch (IOException ignored) {
        if (JobManager.VERBOSE)
            //$NON-NLS-1$
            Util.verbose("Failed to read participant index file names");
    }
    this.participantsContainers = containers;
    return;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) SimpleLookupTable(org.eclipse.jdt.internal.compiler.util.SimpleLookupTable) FileIndexLocation(org.eclipse.jdt.internal.core.index.FileIndexLocation) IndexLocation(org.eclipse.jdt.internal.core.index.IndexLocation) IOException(java.io.IOException) FileIndexLocation(org.eclipse.jdt.internal.core.index.FileIndexLocation) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Example 4 with FileIndexLocation

use of org.eclipse.jdt.internal.core.index.FileIndexLocation 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;
}
Also used : CRC32(java.util.zip.CRC32) FileIndexLocation(org.eclipse.jdt.internal.core.index.FileIndexLocation) IndexLocation(org.eclipse.jdt.internal.core.index.IndexLocation) FileIndexLocation(org.eclipse.jdt.internal.core.index.FileIndexLocation) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Aggregations

FileIndexLocation (org.eclipse.jdt.internal.core.index.FileIndexLocation)4 IndexLocation (org.eclipse.jdt.internal.core.index.IndexLocation)4 File (java.io.File)3 IFile (org.eclipse.core.resources.IFile)3 SimpleLookupTable (org.eclipse.jdt.internal.compiler.util.SimpleLookupTable)2 IOException (java.io.IOException)1 CRC32 (java.util.zip.CRC32)1 IPath (org.eclipse.core.runtime.IPath)1 Path (org.eclipse.core.runtime.Path)1