Example usage for org.eclipse.jdt.internal.compiler.util SimpleLookupTable SimpleLookupTable

List of usage examples for org.eclipse.jdt.internal.compiler.util SimpleLookupTable SimpleLookupTable

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.util SimpleLookupTable SimpleLookupTable.

Prototype

public SimpleLookupTable() 

Source Link

Usage

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

License:Open Source License

private SimpleLookupTable getIndexStates() {
    if (this.indexStates != null)
        return this.indexStates;

    this.indexStates = new SimpleLookupTable();
    File indexesDirectoryPath = getSavedIndexesDirectory();
    char[][] savedNames = readIndexState(getJavaPluginWorkingLocation().toOSString());
    if (savedNames != null) {
        for (int i = 1, l = savedNames.length; i < l; i++) { // first name is saved signature, see readIndexState()
            char[] savedName = savedNames[i];
            if (savedName.length > 0) {
                IndexLocation indexLocation = new FileIndexLocation(
                        new File(indexesDirectoryPath, String.valueOf(savedName))); // shares indexesDirectoryPath's segments
                if (VERBOSE)
                    Util.verbose("Reading saved index file " + indexLocation); //$NON-NLS-1$
                this.indexStates.put(indexLocation, SAVED_STATE);
            }//w  ww.  ja v a2 s.co m
        }
    } else {
        // All the index files are getting deleted and hence there is no need to
        // further check for change in javaLikeNames.
        writeJavaLikeNamesFile();
        this.javaLikeNamesChanged = false;
        deleteIndexFiles();
    }
    readIndexMap();
    return this.indexStates;
}

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

License:Open Source License

/**
 * Flush current state//  www.jav a2s.  c o  m
 */
public synchronized void reset() {
    super.reset();
    if (this.indexes != null) {
        this.indexes = new SimpleLookupTable();
        this.indexStates = null;
    }
    this.indexLocations = new SimpleLookupTable();
    this.javaPluginLocation = null;
}

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

License:Open Source License

SimpleLookupTable directoryTable(String qualifiedPackageName) {
    SimpleLookupTable dirTable = (SimpleLookupTable) this.directoryCache.get(qualifiedPackageName);
    if (dirTable == this.missingPackageHolder)
        return null; // package exists in another classpath directory or jar
    if (dirTable != null)
        return dirTable;

    try {/*from  w  ww.j av  a 2 s  .c om*/
        //            IResource container = this.sourceFolder.findMember(qualifiedPackageName); // this is a case-sensitive check
        File container = new File(sourceFolder, qualifiedPackageName);
        if (container.isDirectory()) {
            dirTable = new SimpleLookupTable();
            DirectoryStream<Path> members = Files.newDirectoryStream(container.toPath());
            for (Path member : members) {
                String name;
                if (!member.toFile().isDirectory()) {
                    int index = Util.indexOfJavaLikeExtension(name = member.getFileName().toString());
                    if (index >= 0) {
                        String fullPath = member.toAbsolutePath().toString();
                        if (!org.eclipse.jdt.internal.compiler.util.Util.isExcluded(fullPath.toCharArray(),
                                this.fulInclusionPatternChars, this.fullExclusionPatternChars,
                                false/*not a folder path*/)) {
                            dirTable.put(name.substring(0, index), member.toFile());
                        }
                    }
                }
            }
            this.directoryCache.put(qualifiedPackageName, dirTable);
            return dirTable;
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    this.directoryCache.put(qualifiedPackageName, this.missingPackageHolder);
    return null;
}

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

License:Open Source License

/**
 * Locate the matches in the given files and report them using the search requestor.
 */// w ww .j a  v  a  2  s  .  c o m
public void locateMatches(SearchDocument[] searchDocuments) throws CoreException {
    if (this.patternLocator == null)
        return;
    int docsLength = searchDocuments.length;
    int progressLength = docsLength;
    if (BasicSearchEngine.VERBOSE) {
        System.out.println("Locating matches in documents ["); //$NON-NLS-1$
        for (int i = 0; i < docsLength; i++)
            System.out.println("\t" + searchDocuments[i]); //$NON-NLS-1$
        System.out.println("]"); //$NON-NLS-1$
    }
    IJavaProject[] javaModelProjects = null;
    if (this.searchPackageDeclaration) {
        javaModelProjects = JavaModelManager.getJavaModelManager().getJavaModel().getJavaProjects();
        progressLength += javaModelProjects.length;
    }

    // init infos for progress increasing
    int n = progressLength < 1000 ? Math.min(Math.max(progressLength / 200 + 1, 2), 4)
            : 5 * (progressLength / 1000);
    this.progressStep = progressLength < n ? 1 : progressLength / n; // step should not be 0
    this.progressWorked = 0;

    // extract working copies
    ArrayList copies = new ArrayList();
    for (int i = 0; i < docsLength; i++) {
        SearchDocument document = searchDocuments[i];
        if (document instanceof WorkingCopyDocument) {
            copies.add(((WorkingCopyDocument) document).workingCopy);
        }
    }
    int copiesLength = copies.size();
    this.workingCopies = new org.eclipse.jdt.core.ICompilationUnit[copiesLength];
    copies.toArray(this.workingCopies);

    JavaModelManager manager = JavaModelManager.getJavaModelManager();
    this.bindings = new SimpleLookupTable();
    try {
        // optimize access to zip files during search operation
        manager.cacheZipFiles(this);

        // initialize handle factory (used as a cache of handles so as to optimize space)
        if (this.handleFactory == null)
            this.handleFactory = new HandleFactory();

        if (this.progressMonitor != null) {
            this.progressMonitor.beginTask("", searchDocuments.length); //$NON-NLS-1$
        }

        // initialize pattern for polymorphic search (i.e. method reference pattern)
        this.patternLocator.initializePolymorphicSearch(this);

        JavaProject previousJavaProject = null;
        PossibleMatchSet matchSet = new PossibleMatchSet();
        Util.sort(searchDocuments, new Util.Comparer() {
            public int compare(Object a, Object b) {
                return ((SearchDocument) a).getPath().compareTo(((SearchDocument) b).getPath());
            }
        });
        int displayed = 0; // progress worked displayed
        String previousPath = null;
        SearchParticipant searchParticipant = null;
        for (int i = 0; i < docsLength; i++) {
            if (this.progressMonitor != null && this.progressMonitor.isCanceled()) {
                throw new OperationCanceledException();
            }

            // skip duplicate paths
            SearchDocument searchDocument = searchDocuments[i];
            if (searchParticipant == null) {
                searchParticipant = searchDocument.getParticipant();
            }
            searchDocuments[i] = null; // free current document
            String pathString = searchDocument.getPath();
            if (i > 0 && pathString.equals(previousPath)) {
                if (this.progressMonitor != null) {
                    this.progressWorked++;
                    if ((this.progressWorked % this.progressStep) == 0)
                        this.progressMonitor.worked(this.progressStep);
                }
                displayed++;
                continue;
            }
            previousPath = pathString;

            Openable openable;
            org.eclipse.jdt.core.ICompilationUnit workingCopy = null;
            if (searchDocument instanceof WorkingCopyDocument) {
                workingCopy = ((WorkingCopyDocument) searchDocument).workingCopy;
                openable = (Openable) workingCopy;
            } else {
                openable = this.handleFactory.createOpenable(pathString, this.scope);
            }
            //         if (openable == null) {
            //            if (this.progressMonitor != null) {
            //               this.progressWorked++;
            //               if ((this.progressWorked%this.progressStep)==0) this.progressMonitor.worked(this.progressStep);
            //            }
            //            displayed++;
            //            continue; // match is outside classpath
            //         }

            // create new parser and lookup environment if this is a new project
            IResource resource = null;
            JavaProject javaProject = (JavaProject) openable.getJavaProject();
            resource = workingCopy != null ? workingCopy.getResource() : openable.getResource();
            if (resource == null)
                resource = javaProject.getProject(); // case of a file in an external jar or external folder
            if (!javaProject.equals(previousJavaProject)) {
                // locate matches in previous project
                if (previousJavaProject != null) {
                    try {
                        locateMatches(previousJavaProject, matchSet, i - displayed);
                        displayed = i;
                    } catch (JavaModelException e) {
                        // problem with classpath in this project -> skip it
                    }
                    matchSet.reset();
                }
                previousJavaProject = javaProject;
            }
            matchSet.add(new PossibleMatch(this, resource, openable, searchDocument, this.pattern.mustResolve));
        }

        // last project
        if (previousJavaProject != null) {
            try {
                locateMatches(previousJavaProject, matchSet, docsLength - displayed);
            } catch (JavaModelException e) {
                // problem with classpath in last project -> ignore
            }
        }

        if (this.searchPackageDeclaration) {
            locatePackageDeclarations(searchParticipant, javaModelProjects);
        }

    } finally {
        if (this.progressMonitor != null)
            this.progressMonitor.done();
        if (this.nameEnvironment != null)
            this.nameEnvironment.cleanup();
        manager.flushZipFiles(this);
        this.bindings = null;
    }
}

From source file:net.sf.j2s.core.builder.IncrementalImageBuilder.java

License:Open Source License

protected void finishedWith(String sourceLocator, CompilationResult result, char[] mainTypeName,
        ArrayList definedTypeNames, ArrayList duplicateTypeNames) {
    char[][] previousTypeNames = this.newState.getDefinedTypeNamesFor(sourceLocator);
    if (previousTypeNames == null)
        previousTypeNames = new char[][] { mainTypeName };
    IPath packagePath = null;//from   w w w. ja v  a2  s.  c  o  m
    next: for (int i = 0, l = previousTypeNames.length; i < l; i++) {
        char[] previous = previousTypeNames[i];
        for (int j = 0, m = definedTypeNames.size(); j < m; j++)
            if (CharOperation.equals(previous, (char[]) definedTypeNames.get(j)))
                continue next;

        SourceFile sourceFile = (SourceFile) result.getCompilationUnit();
        if (packagePath == null) {
            int count = sourceFile.sourceLocation.sourceFolder.getFullPath().segmentCount();
            packagePath = sourceFile.resource.getFullPath().removeFirstSegments(count).removeLastSegments(1);
        }
        if (this.secondaryTypesToRemove == null)
            this.secondaryTypesToRemove = new SimpleLookupTable();
        ArrayList types = (ArrayList) this.secondaryTypesToRemove.get(sourceFile.sourceLocation.binaryFolder);
        if (types == null)
            types = new ArrayList(definedTypeNames.size());
        types.add(packagePath.append(new String(previous)));
        this.secondaryTypesToRemove.put(sourceFile.sourceLocation.binaryFolder, types);
    }
    super.finishedWith(sourceLocator, result, mainTypeName, definedTypeNames, duplicateTypeNames);
}

From source file:org.eclipse.ajdt.internal.core.builder.BuildClasspathResolver.java

License:Open Source License

/**
 * Resolve the classpath of the given project into a string
 *///  w ww.j av a 2  s  .c  om
public String getClasspath(IWorkspaceRoot root, IJavaProject javaProject) {
    if (binaryLocations == null) {
        try {
            computeClasspathLocations(root, (JavaProject) javaProject, new SimpleLookupTable());
        } catch (CoreException e) {
        }
    }

    StringBuffer classpath = new StringBuffer();
    for (int i = 0; i < binaryLocations.length; i++) {
        classpath.append(binaryLocations[i].toOSString());
        classpath.append(File.pathSeparator);
    }
    return classpath.toString();
}

From source file:org.eclipse.che.jdt.internal.core.search.matching.ClasspathSourceDirectory.java

License:Open Source License

SimpleLookupTable directoryTable(final String qualifiedPackageName) {
    final ConcurrentHashMap<String, Future<SimpleLookupTable>> directoryCache = this.directoryCache;
    Future<SimpleLookupTable> future = directoryCache.get(qualifiedPackageName);
    if (future == missingPackageHolder) {
        // package exists in another classpath directory or jar
        return null;
    }/*from w  w  w  . ja  va 2 s  .  co  m*/
    if (future == null) {
        FutureTask<SimpleLookupTable> newFuture = new FutureTask<>(new Callable<SimpleLookupTable>() {
            @Override
            public SimpleLookupTable call() throws Exception {
                File container = new File(sourceFolder, qualifiedPackageName);
                SimpleLookupTable dirTable = new SimpleLookupTable();
                if (container.isDirectory()) {
                    try (DirectoryStream<Path> members = Files.newDirectoryStream(container.toPath())) {
                        for (Path member : members) {
                            String name;
                            if (!member.toFile().isDirectory()) {
                                int index = Util
                                        .indexOfJavaLikeExtension(name = member.getFileName().toString());
                                if (index >= 0) {
                                    String fullPath = member.toAbsolutePath().toString();
                                    if (!org.eclipse.jdt.internal.compiler.util.Util.isExcluded(
                                            fullPath.toCharArray(), fulInclusionPatternChars,
                                            fullExclusionPatternChars, false/*not a folder path*/)) {
                                        dirTable.put(name.substring(0, index), member.toString());
                                    }
                                }
                            }
                        }
                        return dirTable;
                    }
                }
                directoryCache.put(qualifiedPackageName, missingPackageHolder);
                return null;
            }
        });
        future = directoryCache.putIfAbsent(qualifiedPackageName, newFuture);
        if (future == null) {
            future = newFuture;
            newFuture.run();
        }
    }
    try {
        return future.get();
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("Error while reading source directory", e);
    }
    directoryCache.put(qualifiedPackageName, missingPackageHolder);
    return null;
}

From source file:org.eclipse.che.jdt.internal.core.search.matching.MatchLocator.java

License:Open Source License

/**
* Locate the matches in the given files and report them using the search requestor.
*///from  ww  w . j  a v a  2s .  co m
public void locateMatches(SearchDocument[] searchDocuments) throws CoreException {
    if (this.patternLocator == null)
        return;
    int docsLength = searchDocuments.length;
    int progressLength = docsLength;
    if (BasicSearchEngine.VERBOSE) {
        System.out.println("Locating matches in documents ["); //$NON-NLS-1$
        for (int i = 0; i < docsLength; i++)
            System.out.println("\t" + searchDocuments[i]); //$NON-NLS-1$
        System.out.println("]"); //$NON-NLS-1$
    }
    IJavaProject[] javaModelProjects = null;
    if (this.searchPackageDeclaration) {
        javaModelProjects = JavaModelManager.getJavaModelManager().getJavaModel().getJavaProjects();
        progressLength += javaModelProjects.length;
    }

    // init infos for progress increasing
    int n = progressLength < 1000 ? Math.min(Math.max(progressLength / 200 + 1, 2), 4)
            : 5 * (progressLength / 1000);
    this.progressStep = progressLength < n ? 1 : progressLength / n; // step should not be 0
    this.progressWorked = 0;

    // extract working copies
    ArrayList copies = new ArrayList();
    for (int i = 0; i < docsLength; i++) {
        SearchDocument document = searchDocuments[i];
        if (document instanceof WorkingCopyDocument) {
            copies.add(((WorkingCopyDocument) document).workingCopy);
        }
    }
    int copiesLength = copies.size();
    this.workingCopies = new org.eclipse.jdt.core.ICompilationUnit[copiesLength];
    copies.toArray(this.workingCopies);

    JavaModelManager manager = JavaModelManager.getJavaModelManager();
    this.bindings = new SimpleLookupTable();
    try {
        // optimize access to zip files during search operation
        manager.cacheZipFiles(this);

        // initialize handle factory (used as a cache of handles so as to optimize space)
        if (this.handleFactory == null)
            this.handleFactory = new HandleFactory();

        if (this.progressMonitor != null) {
            this.progressMonitor.beginTask("", searchDocuments.length); //$NON-NLS-1$
        }

        // initialize pattern for polymorphic search (i.e. method reference pattern)
        this.patternLocator.initializePolymorphicSearch(this);

        JavaProject previousJavaProject = null;
        PossibleMatchSet matchSet = new PossibleMatchSet();
        Util.sort(searchDocuments, new Util.Comparer() {
            public int compare(Object a, Object b) {
                return ((SearchDocument) a).getPath().compareTo(((SearchDocument) b).getPath());
            }
        });
        int displayed = 0; // progress worked displayed
        String previousPath = null;
        SearchParticipant searchParticipant = null;
        for (int i = 0; i < docsLength; i++) {
            if (this.progressMonitor != null && this.progressMonitor.isCanceled()) {
                throw new OperationCanceledException();
            }

            // skip duplicate paths
            SearchDocument searchDocument = searchDocuments[i];
            if (searchParticipant == null) {
                searchParticipant = searchDocument.getParticipant();
            }
            searchDocuments[i] = null; // free current document
            String pathString = searchDocument.getPath();
            if (i > 0 && pathString.equals(previousPath)) {
                if (this.progressMonitor != null) {
                    this.progressWorked++;
                    if ((this.progressWorked % this.progressStep) == 0)
                        this.progressMonitor.worked(this.progressStep);
                }
                displayed++;
                continue;
            }
            previousPath = pathString;

            Openable openable;
            org.eclipse.jdt.core.ICompilationUnit workingCopy = null;
            if (searchDocument instanceof WorkingCopyDocument) {
                workingCopy = ((WorkingCopyDocument) searchDocument).workingCopy;
                openable = (Openable) workingCopy;
            } else {
                openable = this.handleFactory.createOpenable(pathString, this.scope);
            }
            if (openable == null) {
                if (this.progressMonitor != null) {
                    this.progressWorked++;
                    if ((this.progressWorked % this.progressStep) == 0)
                        this.progressMonitor.worked(this.progressStep);
                }
                displayed++;
                continue; // match is outside classpath
            }

            // create new parser and lookup environment if this is a new project
            IResource resource = null;
            JavaProject javaProject = (JavaProject) openable.getJavaProject();
            resource = workingCopy != null ? workingCopy.getResource() : openable.getResource();
            if (resource == null)
                resource = javaProject.getProject(); // case of a file in an external jar or external folder
            if (!javaProject.equals(previousJavaProject)) {
                // locate matches in previous project
                if (previousJavaProject != null) {
                    try {
                        locateMatches(previousJavaProject, matchSet, i - displayed);
                        displayed = i;
                    } catch (JavaModelException e) {
                        // problem with classpath in this project -> skip it
                    }
                    matchSet.reset();
                }
                previousJavaProject = javaProject;
            }
            matchSet.add(new PossibleMatch(this, resource, openable, searchDocument, this.pattern.mustResolve));
        }

        // last project
        if (previousJavaProject != null) {
            try {
                locateMatches(previousJavaProject, matchSet, docsLength - displayed);
            } catch (JavaModelException e) {
                // problem with classpath in last project -> ignore
            }
        }

        if (this.searchPackageDeclaration) {
            locatePackageDeclarations(searchParticipant, javaModelProjects);
        }

    } finally {
        if (this.progressMonitor != null)
            this.progressMonitor.done();
        if (this.nameEnvironment != null)
            this.nameEnvironment.cleanup();
        this.unitScope = null;
        manager.flushZipFiles(this);
        this.bindings = null;
    }
}

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

License:Open Source License

private SimpleLookupTable getIndexStates() {
    if (this.indexStates != null)
        return this.indexStates;

    this.indexStates = new SimpleLookupTable();
    IPath indexesDirectoryPath = getJavaPluginWorkingLocation();
    char[][] savedNames = readIndexState(indexesDirectoryPath.toOSString());
    if (savedNames != null) {
        for (int i = 1, l = savedNames.length; i < l; i++) { // first name is saved signature, see readIndexState()
            char[] savedName = savedNames[i];
            if (savedName.length > 0) {
                IPath indexLocation = indexesDirectoryPath.append(new String(savedName)); // shares indexesDirectoryPath's segments
                if (VERBOSE)
                    Util.verbose("Reading saved index file " + indexLocation); //$NON-NLS-1$
                this.indexStates.put(indexLocation, SAVED_STATE);
            }// w w w  . j  av a 2 s  . c om
        }
    } else {
        // All the index files are getting deleted and hence there is no need to 
        // further check for change in javaLikeNames. 
        writeJavaLikeNamesFile();
        this.javaLikeNamesChanged = false;
        deleteIndexFiles();
    }
    return this.indexStates;
}

From source file:org.eclipse.jdt.internal.core.search.matching.MatchLocator.java

License:Open Source License

/**
 * Locate the matches in the given files and report them using the search requestor.
 *//*from  w  w  w  . jav  a  2 s.  c  o m*/
public void locateMatches(SearchDocument[] searchDocuments) throws CoreException {
    if (this.patternLocator == null)
        return;
    int docsLength = searchDocuments.length;
    int progressLength = docsLength;
    if (BasicSearchEngine.VERBOSE) {
        System.out.println("Locating matches in documents ["); //$NON-NLS-1$
        for (int i = 0; i < docsLength; i++)
            System.out.println("\t" + searchDocuments[i]); //$NON-NLS-1$
        System.out.println("]"); //$NON-NLS-1$
    }
    IJavaProject[] javaModelProjects = null;
    if (this.searchPackageDeclaration) {
        javaModelProjects = JavaModelManager.getJavaModelManager().getJavaModel().getJavaProjects();
        progressLength += javaModelProjects.length;
    }

    // init infos for progress increasing
    int n = progressLength < 1000 ? Math.min(Math.max(progressLength / 200 + 1, 2), 4)
            : 5 * (progressLength / 1000);
    this.progressStep = progressLength < n ? 1 : progressLength / n; // step should not be 0
    this.progressWorked = 0;

    // extract working copies
    ArrayList copies = new ArrayList();
    for (int i = 0; i < docsLength; i++) {
        SearchDocument document = searchDocuments[i];
        if (document instanceof WorkingCopyDocument) {
            copies.add(((WorkingCopyDocument) document).workingCopy);
        }
    }
    int copiesLength = copies.size();
    this.workingCopies = new org.eclipse.jdt.core.ICompilationUnit[copiesLength];
    copies.toArray(this.workingCopies);

    JavaModelManager manager = JavaModelManager.getJavaModelManager();
    this.bindings = new SimpleLookupTable();
    try {
        // optimize access to zip files during search operation
        manager.cacheZipFiles(this);

        // initialize handle factory (used as a cache of handles so as to optimize space)
        if (this.handleFactory == null)
            this.handleFactory = new HandleFactory();

        if (this.progressMonitor != null) {
            this.progressMonitor.beginTask("", searchDocuments.length); //$NON-NLS-1$
        }

        // initialize pattern for polymorphic search (i.e. method reference pattern)
        this.patternLocator.initializePolymorphicSearch(this);

        JavaProject previousJavaProject = null;
        PossibleMatchSet matchSet = new PossibleMatchSet();
        Util.sort(searchDocuments, new Util.Comparer() {
            public int compare(Object a, Object b) {
                return ((SearchDocument) a).getPath().compareTo(((SearchDocument) b).getPath());
            }
        });
        int displayed = 0; // progress worked displayed
        String previousPath = null;
        SearchParticipant searchParticipant = null;
        for (int i = 0; i < docsLength; i++) {
            if (this.progressMonitor != null && this.progressMonitor.isCanceled()) {
                throw new OperationCanceledException();
            }

            // skip duplicate paths
            SearchDocument searchDocument = searchDocuments[i];
            if (searchParticipant == null) {
                searchParticipant = searchDocument.getParticipant();
            }
            searchDocuments[i] = null; // free current document
            String pathString = searchDocument.getPath();
            if (i > 0 && pathString.equals(previousPath)) {
                if (this.progressMonitor != null) {
                    this.progressWorked++;
                    if ((this.progressWorked % this.progressStep) == 0)
                        this.progressMonitor.worked(this.progressStep);
                }
                displayed++;
                continue;
            }
            previousPath = pathString;

            Openable openable;
            org.eclipse.jdt.core.ICompilationUnit workingCopy = null;
            if (searchDocument instanceof WorkingCopyDocument) {
                workingCopy = ((WorkingCopyDocument) searchDocument).workingCopy;
                openable = (Openable) workingCopy;
            } else {
                openable = this.handleFactory.createOpenable(pathString, this.scope);
            }
            if (openable == null) {
                if (this.progressMonitor != null) {
                    this.progressWorked++;
                    if ((this.progressWorked % this.progressStep) == 0)
                        this.progressMonitor.worked(this.progressStep);
                }
                displayed++;
                continue; // match is outside classpath
            }

            // create new parser and lookup environment if this is a new project
            IResource resource = null;
            JavaProject javaProject = (JavaProject) openable.getJavaProject();
            resource = workingCopy != null ? workingCopy.getResource() : openable.getResource();
            if (resource == null)
                resource = javaProject.getProject(); // case of a file in an external jar or external folder
            if (!javaProject.equals(previousJavaProject)) {
                // locate matches in previous project
                if (previousJavaProject != null) {
                    try {
                        locateMatches(previousJavaProject, matchSet, i - displayed);
                        displayed = i;
                    } catch (JavaModelException e) {
                        // problem with classpath in this project -> skip it
                    }
                    matchSet.reset();
                }
                previousJavaProject = javaProject;
            }
            matchSet.add(new PossibleMatch(this, resource, openable, searchDocument, this.pattern.mustResolve));
        }

        // last project
        if (previousJavaProject != null) {
            try {
                locateMatches(previousJavaProject, matchSet, docsLength - displayed);
            } catch (JavaModelException e) {
                // problem with classpath in last project -> ignore
            }
        }

        if (this.searchPackageDeclaration) {
            locatePackageDeclarations(searchParticipant, javaModelProjects);
        }

    } finally {
        if (this.progressMonitor != null)
            this.progressMonitor.done();
        if (this.nameEnvironment != null)
            this.nameEnvironment.cleanup();
        manager.flushZipFiles(this);
        this.bindings = null;
    }
}