Example usage for org.eclipse.jdt.internal.core.index IndexLocation createIndexLocation

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

Introduction

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

Prototype

public static IndexLocation createIndexLocation(URL url) 

Source Link

Usage

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

License:Open Source License

/**
 * Compute the pre-built index location for a specified URL
 *//*w ww .j ava2  s.co  m*/
public synchronized IndexLocation computeIndexLocation(IPath containerPath, final URL newIndexURL) {
    IndexLocation indexLocation = (IndexLocation) this.indexLocations.get(containerPath);
    if (indexLocation == null) {
        if (newIndexURL != null) {
            indexLocation = IndexLocation.createIndexLocation(newIndexURL);
            // update caches
            indexLocation = (IndexLocation) getIndexStates().getKey(indexLocation);
            this.indexLocations.put(containerPath, indexLocation);
        }
    } else {
        // an existing index location exists - make sure it has not changed (i.e. the URL has not changed)
        URL existingURL = indexLocation.getUrl();
        if (newIndexURL != null) {
            // if either URL is different then the index location has been updated so rebuild.
            if (!newIndexURL.equals(existingURL)) {
                // URL has changed so remove the old index and create a new one
                this.removeIndex(containerPath);
                // create a new one
                indexLocation = IndexLocation.createIndexLocation(newIndexURL);
                // update caches
                indexLocation = (IndexLocation) getIndexStates().getKey(indexLocation);
                this.indexLocations.put(containerPath, indexLocation);
            }
        }
    }
    return indexLocation;
}

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

License:Open Source License

/**
 * Trigger addition of a library to an index
 * Note: the actual operation is performed in background
 *///from  w  w  w  . jav  a  2 s. co  m
public void indexLibrary(IPath path, /*IProject requestingProject,*/ URL indexURL, final boolean updateIndex) {
    // requestingProject is no longer used to cancel jobs but leave it here just in case
    IndexLocation indexFile = null;
    if (indexURL != null) {
        if (IS_MANAGING_PRODUCT_INDEXES_PROPERTY) {
            indexFile = computeIndexLocation(path, indexURL);
        } else {
            indexFile = IndexLocation.createIndexLocation(indexURL);
        }
    }
    //        if (JavaCore.getPlugin() == null) return;
    IndexRequest request = null;
    boolean forceIndexUpdate = IS_MANAGING_PRODUCT_INDEXES_PROPERTY && updateIndex;
    //        Object target = JavaModel.getTarget(path, true);
    //   if (target instanceof IFile) {
    //      request = new AddJarFileToIndex((IFile) target, indexFile, this, forceIndexUpdate);
    //   } else
    //        if (target instanceof File) {
    request = new AddJarFileToIndex(path, indexFile, this, forceIndexUpdate);
    //   } else if (target instanceof IContainer) {
    //      request = new IndexBinaryFolder((IContainer) target, this);
    //        } else {
    //            return;
    //        }

    // check if the same request is not already in the queue
    if (!isJobWaiting(request))
        request(request);
}

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

License:Open Source License

private void readIndexMap() {
    try {/*w w  w.  j a v a 2  s  .co  m*/
        char[] indexMaps = org.eclipse.jdt.internal.compiler.util.Util
                .getFileCharContent(this.indexNamesMapFile, null);
        char[][] names = CharOperation.splitOn('\n', indexMaps);
        if (names.length >= 3) {
            // First line is DiskIndex signature (see writeIndexMapFile())
            String savedSignature = DiskIndex.SIGNATURE;
            if (savedSignature.equals(new String(names[0]))) {
                for (int i = 1, l = names.length - 1; i < l; i += 2) {
                    IndexLocation indexPath = IndexLocation.createIndexLocation(new URL(new String(names[i])));
                    this.indexLocations.put(new Path(new String(names[i + 1])), indexPath);
                    this.indexStates.put(indexPath, REUSE_STATE);
                }
            }
        }
    } catch (IOException ignored) {
        if (VERBOSE)
            Util.verbose("Failed to read saved index file names"); //$NON-NLS-1$
    }
    return;
}

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

License:Open Source License

/**
 * Trigger addition of a library to an index
 * Note: the actual operation is performed in background
 *///from   w w  w.  ja v a  2  s . co m
public void indexLibrary(IPath path, /*IProject requestingProject,*/ URL indexURL, final boolean updateIndex) {
    // requestingProject is no longer used to cancel jobs but leave it here just in case
    IndexLocation indexFile = null;
    if (indexURL != null) {
        if (IS_MANAGING_PRODUCT_INDEXES_PROPERTY) {
            indexFile = computeIndexLocation(path, indexURL);
        } else {
            indexFile = IndexLocation.createIndexLocation(indexURL);
        }
    }
    //        if (JavaCore.getPlugin() == null) return;
    IndexRequest request = null;
    boolean forceIndexUpdate = IS_MANAGING_PRODUCT_INDEXES_PROPERTY && updateIndex;
    //        Object target = JavaModel.getTarget(path, true);
    //   if (target instanceof IFile) {
    //      request = new AddJarFileToIndex((IFile) target, indexFile, this, forceIndexUpdate);
    //   } else
    //        if (target instanceof File) {
    request = new AddJarFileToIndex(path, indexFile, this, forceIndexUpdate, javaProject);
    //   } else if (target instanceof IContainer) {
    //      request = new IndexBinaryFolder((IContainer) target, this);
    //        } else {
    //            return;
    //        }

    // check if the same request is not already in the queue
    if (!isJobWaiting(request))
        request(request);
}

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

License:Open Source License

private void readIndexMap() {
    try {//from   w  ww  . j  a v  a 2 s  .c  o  m
        char[] indexMaps = org.eclipse.jdt.internal.compiler.util.Util
                .getFileCharContent(this.indexNamesMapFile, null);
        char[][] names = CharOperation.splitOn('\n', indexMaps);
        if (names.length >= 3) {
            // First line is DiskIndex signature (see writeIndexMapFile())
            String savedSignature = DiskIndex.SIGNATURE;
            if (savedSignature.equals(new String(names[0]))) {
                for (int i = 1, l = names.length - 1; i < l; i += 2) {
                    IndexLocation indexPath = IndexLocation.createIndexLocation(new URL(new String(names[i])));
                    if (indexPath == null)
                        continue;
                    this.indexLocations.put(new Path(new String(names[i + 1])), indexPath);
                    this.indexStates.put(indexPath, REUSE_STATE);
                }
            }
        }
    } catch (IOException ignored) {
        if (VERBOSE)
            Util.verbose("Failed to read saved index file names"); //$NON-NLS-1$
    }
    return;
}