Example usage for org.eclipse.jdt.internal.core.index Index reset

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

Introduction

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

Prototype

public void reset() throws IOException 

Source Link

Document

Reset memory and disk indexes.

Usage

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

License:Open Source License

/**
 * Resets the index for a given path.//from  w ww.  j  a v  a2s .  c  o m
 * 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 (VERBOSE) {
            Util.verbose("-> reseting index: " + indexLocation + " for path: " + containerPathString); //$NON-NLS-1$ //$NON-NLS-2$
        }
        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 (VERBOSE) {
            Util.verbose("-> failed to reset index for path: " + containerPathString); //$NON-NLS-1$
            e.printStackTrace();
        }
        return false;
    }
}

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

License:Open Source License

/**
 * Resets the index for a given path./*from  ww w  . java 2 s .  c om*/
 * 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
        IPath indexLocation = computeIndexLocation(containerPath);
        Index index = getIndex(indexLocation);
        if (VERBOSE) {
            Util.verbose("-> reseting index: " + indexLocation + " for path: " + containerPathString); //$NON-NLS-1$ //$NON-NLS-2$
        }
        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 (VERBOSE) {
            Util.verbose("-> failed to reset index for path: " + containerPathString); //$NON-NLS-1$
            e.printStackTrace();
        }
        return false;
    }
}