Example usage for org.eclipse.jdt.internal.core.search.indexing IndexRequest IndexRequest

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

Introduction

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

Prototype

public IndexRequest(IPath containerPath, IndexManager manager) 

Source Link

Usage

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

License:Open Source License

public void scheduleDocumentIndexing(final SearchDocument searchDocument, IPath container,
        final IPath indexLocation, final SearchParticipant searchParticipant) {
    request(new IndexRequest(container, this) {
        public boolean execute(IProgressMonitor progressMonitor) {
            if (this.isCancelled || progressMonitor != null && progressMonitor.isCanceled())
                return true;

            /* ensure no concurrent write access to index */
            Index index = getIndex(this.containerPath, indexLocation, true,
                    /*reuse index file*/ true /*create if none*/);
            if (index == null)
                return true;
            ReadWriteMonitor monitor = index.monitor;
            if (monitor == null)
                return true; // index got deleted since acquired

            try {
                monitor.enterWrite(); // ask permission to write
                indexDocument(searchDocument, searchParticipant, index, indexLocation);
            } finally {
                monitor.exitWrite(); // free write lock
            }/*from  ww w  . j  a  v a2s  .co  m*/
            return true;
        }

        public String toString() {
            return "indexing " + searchDocument.getPath(); //$NON-NLS-1$
        }
    });
}