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

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

Introduction

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

Prototype

public SimpleSet() 

Source Link

Usage

From source file:com.codenvy.ide.ext.java.server.internal.core.builder.ClasspathJar.java

License:Open Source License

private SimpleSet readPackages() {
    try {// w ww. ja  va2s  . co m
        if (this.zipFile == null) {
            if (org.eclipse.jdt.internal.core.JavaModelManager.ZIP_ACCESS_VERBOSE) {
                System.out.println("(" + Thread.currentThread()
                        + ") [ClasspathJar.isPackage(String)] Creating ZipFile on " + this.zipFilename); //$NON-NLS-1$   //$NON-NLS-2$
            }
            this.zipFile = new ZipFile(this.zipFilename);
            this.closeZipFileAtEnd = true;
        }
        return findPackageSet(this);
    } catch (Exception e) {
        return new SimpleSet(); // assume for this build the zipFile is empty
    }
}

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

License:Open Source License

public void cleanUpIndexes() {
    SimpleSet knownPaths = new SimpleSet();
    IJavaSearchScope scope = BasicSearchEngine.createWorkspaceScope();
    PatternSearchJob job = new PatternSearchJob(null, SearchEngine.getDefaultSearchParticipant(this), scope,
            null, this);
    Index[] selectedIndexes = job.getIndexes(null);
    for (int i = 0, l = selectedIndexes.length; i < l; i++) {
        IndexLocation IndexLocation = selectedIndexes[i].getIndexLocation();
        knownPaths.add(IndexLocation);/*from ww w. jav a 2 s  . c  om*/
    }

    if (this.indexStates != null) {
        Object[] keys = this.indexStates.keyTable;
        IndexLocation[] locations = new IndexLocation[this.indexStates.elementSize];
        int count = 0;
        for (int i = 0, l = keys.length; i < l; i++) {
            IndexLocation key = (IndexLocation) keys[i];
            if (key != null && !knownPaths.includes(key))
                locations[count++] = key;
        }
        if (count > 0)
            removeIndexesState(locations);
    }
    deleteIndexFiles(knownPaths);
}

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

License:Open Source License

public DeclarationOfAccessedFieldsPattern(IJavaElement enclosingElement) {
    super(null, null, null, null, null, IJavaSearchConstants.REFERENCES, R_PATTERN_MATCH);

    this.enclosingElement = enclosingElement;
    this.knownFields = new SimpleSet();
    this.mustResolve = true;
}

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

License:Open Source License

public DeclarationOfReferencedMethodsPattern(IJavaElement enclosingElement) {
    super(null, null, null, null, null, null, null, null, IJavaSearchConstants.REFERENCES, R_PATTERN_MATCH);

    this.enclosingElement = enclosingElement;
    this.knownMethods = new SimpleSet();
    this.mustResolve = true;
}

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

License:Open Source License

public DeclarationOfReferencedTypesPattern(IJavaElement enclosingElement) {
    super(null, null, R_PATTERN_MATCH);

    this.enclosingElement = enclosingElement;
    this.knownTypes = new SimpleSet();
    this.mustResolve = true;
}

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

License:Open Source License

/**
 * Locates the package declarations corresponding to the search pattern.
 *//*from w  ww .j  av  a  2  s  . co m*/
protected void locatePackageDeclarations(SearchPattern searchPattern, SearchParticipant participant,
        IJavaProject[] projects) throws CoreException {
    if (this.progressMonitor != null && this.progressMonitor.isCanceled()) {
        throw new OperationCanceledException();
    }
    if (searchPattern instanceof OrPattern) {
        SearchPattern[] patterns = ((OrPattern) searchPattern).patterns;
        for (int i = 0, length = patterns.length; i < length; i++) {
            locatePackageDeclarations(patterns[i], participant, projects);
        }
    } else if (searchPattern instanceof PackageDeclarationPattern) {
        IJavaElement focus = searchPattern.focus;
        if (focus != null) {
            if (encloses(focus)) {
                SearchMatch match = new PackageDeclarationMatch(
                        focus.getAncestor(IJavaElement.PACKAGE_FRAGMENT), SearchMatch.A_ACCURATE, -1, -1,
                        participant, focus.getResource());
                report(match);
            }
            return;
        }
        PackageDeclarationPattern pkgPattern = (PackageDeclarationPattern) searchPattern;
        boolean isWorkspaceScope = this.scope == JavaModelManager.getJavaModelManager().getWorkspaceScope();
        IPath[] scopeProjectsAndJars = isWorkspaceScope ? null : this.scope.enclosingProjectsAndJars();
        int scopeLength = isWorkspaceScope ? 0 : scopeProjectsAndJars.length;
        SimpleSet packages = new SimpleSet();
        for (int i = 0, length = projects.length; i < length; i++) {
            IJavaProject javaProject = projects[i];
            if (this.progressMonitor != null) {
                if (this.progressMonitor.isCanceled())
                    throw new OperationCanceledException();
                this.progressWorked++;
                if ((this.progressWorked % this.progressStep) == 0)
                    this.progressMonitor.worked(this.progressStep);
            }
            // Verify that project belongs to the scope
            if (!isWorkspaceScope) {
                boolean found = false;
                for (int j = 0; j < scopeLength; j++) {
                    if (javaProject.getPath().equals(scopeProjectsAndJars[j])) {
                        found = true;
                        break;
                    }
                }
                if (!found)
                    continue;
            }
            // Get all project package fragment names
            this.nameLookup = ((JavaProject) projects[i]).newNameLookup(this.workingCopies);
            IPackageFragment[] packageFragments = this.nameLookup
                    .findPackageFragments(new String(pkgPattern.pkgName), false, true);
            int pLength = packageFragments == null ? 0 : packageFragments.length;
            // Report matches avoiding duplicate names
            for (int p = 0; p < pLength; p++) {
                IPackageFragment fragment = packageFragments[p];
                if (packages.addIfNotIncluded(fragment) == null)
                    continue;
                if (encloses(fragment)) {
                    IResource resource = fragment.getResource();
                    if (resource == null) // case of a file in an external jar
                        resource = javaProject.getProject();
                    try {
                        if (encloses(fragment)) {
                            SearchMatch match = new PackageDeclarationMatch(fragment, SearchMatch.A_ACCURATE,
                                    -1, -1, participant, resource);
                            report(match);
                        }
                    } catch (JavaModelException e) {
                        throw e;
                    } catch (CoreException e) {
                        throw new JavaModelException(e);
                    }
                }
            }
        }
    }
}

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

License:Open Source License

public boolean isPackage(String qualifiedPackageName) {
    if (this.knownPackageNames != null)
        return this.knownPackageNames.includes(qualifiedPackageName);

    try {//from  w w  w .j av  a 2s. c  om
        if (this.zipFile == null) {
            if (org.eclipse.jdt.internal.core.JavaModelManager.ZIP_ACCESS_VERBOSE) {
                System.out.println("(" + Thread.currentThread() //$NON-NLS-1$
                        + ") [ClasspathJar.isPackage(String)] Creating ZipFile on " + this.zipFilename); //$NON-NLS-1$
            }
            this.zipFile = new ZipFile(this.zipFilename);
            this.closeZipFileAtEnd = true;
        }
        this.knownPackageNames = findPackageSet(this);
    } catch (Exception e) {
        this.knownPackageNames = new SimpleSet(); // assume for this build the zipFile is empty
    }
    return this.knownPackageNames.includes(qualifiedPackageName);
}

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

License:Open Source License

public WorkQueue() {
    this.needsCompileList = new SimpleSet();
    this.compiledList = new SimpleSet();
}

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

License:Open Source License

public boolean isPackage(String qualifiedPackageName) {
    if (this.knownPackageNames != null)
        return this.knownPackageNames.includes(qualifiedPackageName);

    try {/*ww  w. j  av  a  2s .c  o  m*/
        if (this.zipFile == null) {
            if (org.eclipse.jdt.internal.core.JavaModelManager.ZIP_ACCESS_VERBOSE) {
                AJLog.log(AJLog.BUILDER_CLASSPATH, "(" + Thread.currentThread() //$NON-NLS-1$
                        + ") [ClasspathJar.isPackage(String)] Creating ZipFile on " + zipFilename); //$NON-NLS-1$
            }
            this.zipFile = new ZipFile(zipFilename);
            this.closeZipFileAtEnd = true;
        }
        this.knownPackageNames = findPackageSet(this.zipFile);
    } catch (Exception e) {
        this.knownPackageNames = new SimpleSet(); // assume for this build the zipFile is empty
    }
    return this.knownPackageNames.includes(qualifiedPackageName);
}

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

License:Open Source License

public void cleanUpIndexes() {
    SimpleSet knownPaths = new SimpleSet();
    IJavaSearchScope scope = BasicSearchEngine.createWorkspaceScope();
    PatternSearchJob job = new PatternSearchJob(null,
            SearchEngine.getDefaultSearchParticipant(this, javaProject), scope, null, this);
    Index[] selectedIndexes = job.getIndexes(null);
    for (int i = 0, l = selectedIndexes.length; i < l; i++) {
        IndexLocation IndexLocation = selectedIndexes[i].getIndexLocation();
        knownPaths.add(IndexLocation);/*from   w ww.  j a va  2 s .c  o  m*/
    }

    if (this.indexStates != null) {
        Object[] keys = this.indexStates.keyTable;
        IndexLocation[] locations = new IndexLocation[this.indexStates.elementSize];
        int count = 0;
        for (int i = 0, l = keys.length; i < l; i++) {
            IndexLocation key = (IndexLocation) keys[i];
            if (key != null && !knownPaths.includes(key))
                locations[count++] = key;
        }
        if (count > 0)
            removeIndexesState(locations);
    }
    deleteIndexFiles(knownPaths);
}