Search in sources :

Example 11 with Index

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

the class IndexManager method resetIndex.

/**
     * Resets the index for a given path.
     * Returns true if the index was reset, false otherwise.
     */
public synchronized boolean resetIndex(IPath containerPath) {
    // only called to over write an existing cached index...
    String containerPathString = containerPath.getDevice() == null ? containerPath.toString() : containerPath.toOSString();
    try {
        // Path is already canonical
        IndexLocation indexLocation = computeIndexLocation(containerPath);
        Index index = getIndex(indexLocation);
        if (JobManager.VERBOSE) {
            //$NON-NLS-1$ //$NON-NLS-2$
            Util.verbose("-> reseting index: " + indexLocation + " for path: " + containerPathString);
        }
        if (index == null) {
            // the index does not exist, try to recreate it
            return recreateIndex(containerPath) != null;
        }
        index.reset();
        return true;
    } catch (IOException e) {
        // The file could not be created. Possible reason: the project has been deleted.
        if (JobManager.VERBOSE) {
            //$NON-NLS-1$
            Util.verbose("-> failed to reset index for path: " + containerPathString);
            e.printStackTrace();
        }
        return false;
    }
}
Also used : FileIndexLocation(org.eclipse.jdt.internal.core.index.FileIndexLocation) IndexLocation(org.eclipse.jdt.internal.core.index.IndexLocation) DiskIndex(org.eclipse.jdt.internal.core.index.DiskIndex) Index(org.eclipse.jdt.internal.core.index.Index) IOException(java.io.IOException)

Example 12 with Index

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

the class IndexManager method toString.

public String toString() {
    StringBuffer buffer = new StringBuffer(10);
    buffer.append(super.toString());
    //$NON-NLS-1$
    buffer.append("In-memory indexes:\n");
    int count = 0;
    Object[] valueTable = this.indexes.valueTable;
    for (int i = 0, l = valueTable.length; i < l; i++) {
        Index index = (Index) valueTable[i];
        if (index != null)
            //$NON-NLS-1$
            buffer.append(++count).append(" - ").append(index.toString()).append('\n');
    }
    return buffer.toString();
}
Also used : DiskIndex(org.eclipse.jdt.internal.core.index.DiskIndex) Index(org.eclipse.jdt.internal.core.index.Index)

Aggregations

Index (org.eclipse.jdt.internal.core.index.Index)12 DiskIndex (org.eclipse.jdt.internal.core.index.DiskIndex)11 FileIndexLocation (org.eclipse.jdt.internal.core.index.FileIndexLocation)7 IndexLocation (org.eclipse.jdt.internal.core.index.IndexLocation)7 IOException (java.io.IOException)6 IFile (org.eclipse.core.resources.IFile)3 File (java.io.File)2 IPath (org.eclipse.core.runtime.IPath)2 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 IResource (org.eclipse.core.resources.IResource)1 IResourceProxy (org.eclipse.core.resources.IResourceProxy)1 IResourceProxyVisitor (org.eclipse.core.resources.IResourceProxyVisitor)1 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)1 CoreException (org.eclipse.core.runtime.CoreException)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1 IClasspathEntry (org.eclipse.jdt.core.IClasspathEntry)1 IJavaSearchScope (org.eclipse.jdt.core.search.IJavaSearchScope)1 SourceElementParser (org.eclipse.jdt.internal.compiler.SourceElementParser)1