Example usage for org.eclipse.jdt.internal.core.index FileIndexLocation FileIndexLocation

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

Introduction

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

Prototype

public FileIndexLocation(File file, boolean participantIndex) 

Source Link

Usage

From source file:com.codenvy.ide.ext.java.server.core.search.SearchParticipant.java

License:Open Source License

/**
 * Schedules the indexing of the given document.
 * Once the document is ready to be indexed,
 * {@link #indexDocument(SearchDocument, org.eclipse.core.runtime.IPath) indexDocument(document, indexPath)}
 * will be called in a different thread than the caller's thread.
 * <p>/*ww  w  . j a v  a2s  . c om*/
 * The given index location must represent a path in the file system to a file that
 * either already exists or is going to be created. If it exists, it must be an index file,
 * otherwise its data might be overwritten.
 * </p><p>
 * When the index is no longer needed, clients should use {@link #removeIndex(org.eclipse.core.runtime.IPath) }
 * to discard it.
 * </p>
 *
 * @param document the document to index
 * @param indexPath the location on the file system of the index
 */
public final void scheduleDocumentIndexing(SearchDocument document, IPath indexPath) {
    IPath documentPath = new Path(document.getPath());
    Object file = JavaModel.getTarget(documentPath, true);
    IPath containerPath = documentPath;
    if (file instanceof IResource) {
        containerPath = ((IResource) file).getProject().getFullPath();
    } else if (file == null) {
        containerPath = documentPath.removeLastSegments(1);
    }
    //todo index manager
    IndexManager manager = null; //JavaModelManager.getIndexManager();
    // TODO (frederic) should not have to create index manually, should expose API that recreates index instead
    IndexLocation indexLocation;
    indexLocation = new FileIndexLocation(indexPath.toFile(), true);
    manager.ensureIndexExists(indexLocation, containerPath);
    manager.scheduleDocumentIndexing(document, containerPath, indexLocation, this);
    if (!indexPath.equals(this.lastIndexLocation)) {
        manager.updateParticipant(indexPath, containerPath);
        this.lastIndexLocation = indexPath;
    }
}

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

License:Open Source License

private void readParticipantsIndexNamesFile() {
    SimpleLookupTable containers = new SimpleLookupTable(3);
    try {//from  ww  w .  jav a 2s . co m
        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 (VERBOSE)
            Util.verbose("Failed to read participant index file names"); //$NON-NLS-1$
    }
    this.participantsContainers = containers;
    return;
}

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

License:Open Source License

public void updateParticipant(IPath indexPath, IPath containerPath) {
    if (this.participantsContainers == null) {
        readParticipantsIndexNamesFile();
    }//from   ww  w .  java 2 s .c om
    IndexLocation indexLocation = new FileIndexLocation(indexPath.toFile(), true);
    if (this.participantsContainers.get(indexLocation) == null) {
        this.participantsContainers.put(indexLocation, containerPath);
        this.participantUpdated = true;
    }
}

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

License:Open Source License

public Index[] getIndexes(IProgressMonitor progressMonitor) {
    // acquire the in-memory indexes on the fly
    IndexLocation[] indexLocations;/*w ww . j  ava 2  s  .  co  m*/
    int length;
    if (this.participant instanceof JavaSearchParticipant) {
        indexLocations = ((JavaSearchParticipant) this.participant).selectIndexURLs(this.pattern, this.scope);
        length = indexLocations.length;
    } else {
        IPath[] paths = this.participant.selectIndexes(this.pattern, this.scope);
        length = paths.length;
        indexLocations = new IndexLocation[paths.length];
        for (int i = 0, len = paths.length; i < len; i++) {
            indexLocations[i] = new FileIndexLocation(paths[i].toFile(), true);
        }
    }
    Index[] indexes = indexManager.getIndexes(indexLocations, progressMonitor);
    this.areIndexesReady = indexes.length == length;
    return indexes;
}

From source file:org.eclipse.che.jdt.core.search.SearchParticipant.java

License:Open Source License

/**
 * Schedules the indexing of the given document.
 * Once the document is ready to be indexed,
 * {@link #indexDocument(org.eclipse.jdt.core.search.SearchDocument, IPath) indexDocument(document, indexPath)}
 * will be called in a different thread than the caller's thread.
 * <p>/*from   w ww  .  j  a v  a 2  s. co m*/
 * The given index location must represent a path in the file system to a file that
 * either already exists or is going to be created. If it exists, it must be an index file,
 * otherwise its data might be overwritten.
 * </p><p>
 * When the index is no longer needed, clients should use {@link #removeIndex(IPath) }
 * to discard it.
 * </p>
 *
 * @param document the document to index
 * @param indexPath the location on the file system of the index
 */
public final void scheduleDocumentIndexing(SearchDocument document, IPath indexPath) {
    IPath documentPath = new Path(document.getPath());
    Object file = JavaModel.getTarget(documentPath, true);
    IPath containerPath = documentPath;
    if (file instanceof IResource) {
        containerPath = ((IResource) file).getProject().getFullPath();
    } else if (file == null) {
        containerPath = documentPath.removeLastSegments(1);
    }
    //todo index manager
    IndexManager manager = null;//JavaModelManager.getIndexManager();
    // TODO (frederic) should not have to create index manually, should expose API that recreates index instead
    IndexLocation indexLocation;
    indexLocation = new FileIndexLocation(indexPath.toFile(), true);
    manager.ensureIndexExists(indexLocation, containerPath);
    manager.scheduleDocumentIndexing(document, containerPath, indexLocation, this);
    if (!indexPath.equals(this.lastIndexLocation)) {
        manager.updateParticipant(indexPath, containerPath);
        this.lastIndexLocation = indexPath;
    }
}