Example usage for org.eclipse.jdt.internal.core.search.indexing IndexManager cleanUpIndexes

List of usage examples for org.eclipse.jdt.internal.core.search.indexing IndexManager cleanUpIndexes

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core.search.indexing IndexManager cleanUpIndexes.

Prototype

public void cleanUpIndexes() 

Source Link

Usage

From source file:org.eclipse.jdt.internal.core.JavaModelManager.java

License:Open Source License

/**
 * @see ISaveParticipant/*from  w  ww  .ja v  a 2s .  c  o  m*/
 */
public void saving(ISaveContext context) throws CoreException {

    long start = -1;
    if (VERBOSE)
        start = System.currentTimeMillis();

    // save variable and container values on snapshot/full save
    saveVariablesAndContainers(context);

    if (VERBOSE)
        traceVariableAndContainers("Saved", start); //$NON-NLS-1$

    switch (context.getKind()) {
    case ISaveContext.FULL_SAVE: {
        // save non-chaining jar and invalid jar caches on full save
        saveClasspathListCache(NON_CHAINING_JARS_CACHE);
        saveClasspathListCache(INVALID_ARCHIVES_CACHE);

        // will need delta since this save (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=38658)
        context.needDelta();

        // clean up indexes on workspace full save
        // (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=52347)
        IndexManager manager = this.indexManager;
        if (manager != null
                // don't force initialization of workspace scope as we could be shutting down
                // (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=93941)
                && this.workspaceScope != null) {
            manager.cleanUpIndexes();
        }
    }
    //$FALL-THROUGH$
    case ISaveContext.SNAPSHOT: {
        // clean up external folders on full save or snapshot
        this.externalFoldersManager.cleanUp(null);
    }
    }

    IProject savedProject = context.getProject();
    if (savedProject != null) {
        if (!JavaProject.hasJavaNature(savedProject))
            return; // ignore
        PerProjectInfo info = getPerProjectInfo(savedProject, true /* create info */);
        saveState(info, context);
        return;
    }

    ArrayList vStats = null; // lazy initialized
    ArrayList values = null;
    synchronized (this.perProjectInfos) {
        values = new ArrayList(this.perProjectInfos.values());
    }
    Iterator iterator = values.iterator();
    while (iterator.hasNext()) {
        try {
            PerProjectInfo info = (PerProjectInfo) iterator.next();
            saveState(info, context);
        } catch (CoreException e) {
            if (vStats == null)
                vStats = new ArrayList();
            vStats.add(e.getStatus());
        }
    }
    if (vStats != null) {
        IStatus[] stats = new IStatus[vStats.size()];
        vStats.toArray(stats);
        throw new CoreException(new MultiStatus(JavaCore.PLUGIN_ID, IStatus.ERROR, stats,
                Messages.build_cannotSaveStates, null));
    }

    // save external libs timestamps
    this.deltaState.saveExternalLibTimeStamps();

}