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

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

Introduction

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

Prototype

public Object remove(Object object) 

Source Link

Usage

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

License:Open Source License

private void initializeIndexLocations() {
    IPath[] projectsAndJars = this.searchScope.enclosingProjectsAndJars();
    // use a linked set to preserve the order during search: see bug 348507
    LinkedHashSet locations = new LinkedHashSet();
    IJavaElement focus = MatchLocator.projectOrJarFocus(this.pattern);
    if (focus == null) {
        for (int i = 0; i < projectsAndJars.length; i++) {
            IPath path = projectsAndJars[i];
            Object target = new File(path.toOSString());//JavaModel.getTarget(path, false/*don't check existence*/);
            if (target instanceof IFolder) // case of an external folder
                path = ((IFolder) target).getFullPath();
            locations.add(indexManager.computeIndexLocation(path));
        }//from ww w  .j  a  va2s. c  o  m
    } else {
        try {
            // See whether the state builder might be used to reduce the number of index locations

            // find the projects from projectsAndJars that see the focus then walk those projects looking for the jars from projectsAndJars
            int length = projectsAndJars.length;
            JavaProject[] projectsCanSeeFocus = new JavaProject[length];
            SimpleSet visitedProjects = new SimpleSet(length);
            int projectIndex = 0;
            SimpleSet externalLibsToCheck = new SimpleSet(length);
            ObjectVector superTypes = new ObjectVector();
            IJavaElement[] focuses = getFocusedElementsAndTypes(this.pattern, focus, superTypes);
            char[][][] focusQualifiedNames = null;
            boolean isAutoBuilding = ResourcesPlugin.getWorkspace().getDescription().isAutoBuilding();
            if (isAutoBuilding && focus instanceof IJavaProject) {
                focusQualifiedNames = getQualifiedNames(superTypes);
            }
            IJavaModel model = JavaModelManager.getJavaModelManager().getJavaModel();
            for (int i = 0; i < length; i++) {
                IPath path = projectsAndJars[i];
                JavaProject project = (JavaProject) getJavaProject(path, model);
                if (project != null) {
                    visitedProjects.add(project);
                    if (canSeeFocus(focuses, project, focusQualifiedNames)) {
                        locations.add(indexManager.computeIndexLocation(path));
                        projectsCanSeeFocus[projectIndex++] = project;
                    }
                } else {
                    externalLibsToCheck.add(path);
                }
            }
            for (int i = 0; i < projectIndex && externalLibsToCheck.elementSize > 0; i++) {
                IClasspathEntry[] entries = projectsCanSeeFocus[i].getResolvedClasspath();
                for (int j = entries.length; --j >= 0;) {
                    IClasspathEntry entry = entries[j];
                    if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
                        IPath path = entry.getPath();
                        if (externalLibsToCheck.remove(path) != null) {
                            Object target = JavaModel.getTarget(path, false/*don't check existence*/);
                            if (target instanceof IFolder) // case of an external folder
                                path = ((IFolder) target).getFullPath();
                            locations.add(indexManager.computeIndexLocation(path));
                        }
                    }
                }
            }
            // jar files can be included in the search scope without including one of the projects that references them, so scan all projects that have not been visited
            if (externalLibsToCheck.elementSize > 0) {
                IJavaProject[] allProjects = model.getJavaProjects();
                for (int i = 0, l = allProjects.length; i < l && externalLibsToCheck.elementSize > 0; i++) {
                    JavaProject project = (JavaProject) allProjects[i];
                    if (!visitedProjects.includes(project)) {
                        IClasspathEntry[] entries = project.getResolvedClasspath();
                        for (int j = entries.length; --j >= 0;) {
                            IClasspathEntry entry = entries[j];
                            if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
                                IPath path = entry.getPath();
                                if (externalLibsToCheck.remove(path) != null) {
                                    Object target = JavaModel.getTarget(path, false/*don't check existence*/);
                                    if (target instanceof IFolder) // case of an external folder
                                        path = ((IFolder) target).getFullPath();
                                    locations.add(indexManager.computeIndexLocation(path));
                                }
                            }
                        }
                    }
                }
            }
        } catch (JavaModelException e) {
            // ignored
        }
    }

    locations.remove(null); // Ensure no nulls
    this.indexLocations = (IndexLocation[]) locations.toArray(new IndexLocation[locations.size()]);
}

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

License:Open Source License

private void initializeIndexLocations() {
    IPath[] projectsAndJars = this.searchScope.enclosingProjectsAndJars();
    // use a linked set to preserve the order during search: see bug 348507
    LinkedHashSet locations = new LinkedHashSet();
    IJavaElement focus = MatchLocator.projectOrJarFocus(this.pattern);
    if (focus == null) {
        for (int i = 0; i < projectsAndJars.length; i++) {
            IPath path = projectsAndJars[i];
            Object target = new File(path.toOSString());//JavaModel.getTarget(path, false/*don't check existence*/);
            if (target instanceof IFolder) // case of an external folder
                path = ((IFolder) target).getFullPath();
            locations.add(indexManager.computeIndexLocation(path));
        }/*  ww w .  j  ava  2  s. c o m*/
    } else {
        try {
            // See whether the state builder might be used to reduce the number of index locations

            // find the projects from projectsAndJars that see the focus then walk those projects looking for the jars from projectsAndJars
            int length = projectsAndJars.length;
            JavaProject[] projectsCanSeeFocus = new JavaProject[length];
            SimpleSet visitedProjects = new SimpleSet(length);
            int projectIndex = 0;
            SimpleSet externalLibsToCheck = new SimpleSet(length);
            ObjectVector superTypes = new ObjectVector();
            IJavaElement[] focuses = getFocusedElementsAndTypes(this.pattern, focus, superTypes);
            char[][][] focusQualifiedNames = null;
            boolean isAutoBuilding = ResourcesPlugin.getWorkspace().getDescription().isAutoBuilding();
            if (isAutoBuilding && focus instanceof IJavaProject) {
                focusQualifiedNames = getQualifiedNames(superTypes);
            }
            IJavaModel model = JavaModelManager.getJavaModelManager().getJavaModel();
            for (int i = 0; i < length; i++) {
                IPath path = projectsAndJars[i];
                JavaProject project = (JavaProject) getJavaProject(path, model);
                if (project != null) {
                    visitedProjects.add(project);
                    int canSeeFocus = canSeeFocus(focuses, project, focusQualifiedNames);
                    if (canSeeFocus == PROJECT_CAN_SEE_FOCUS) {
                        locations.add(indexManager.computeIndexLocation(path));
                    }
                    if (canSeeFocus != PROJECT_CAN_NOT_SEE_FOCUS) {
                        projectsCanSeeFocus[projectIndex++] = project;
                    }
                } else {
                    externalLibsToCheck.add(path);
                }
            }
            for (int i = 0; i < projectIndex && externalLibsToCheck.elementSize > 0; i++) {
                IClasspathEntry[] entries = projectsCanSeeFocus[i].getResolvedClasspath();
                for (int j = entries.length; --j >= 0;) {
                    IClasspathEntry entry = entries[j];
                    if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
                        IPath path = entry.getPath();
                        if (externalLibsToCheck.remove(path) != null) {
                            Object target = JavaModel.getTarget(path, false/*don't check existence*/);
                            if (target instanceof IFolder) // case of an external folder
                                path = ((IFolder) target).getFullPath();
                            locations.add(indexManager.computeIndexLocation(path));
                        }
                    }
                }
            }
            // jar files can be included in the search scope without including one of the projects that references them, so scan all projects that have not been visited
            if (externalLibsToCheck.elementSize > 0) {
                IJavaProject[] allProjects = model.getJavaProjects();
                for (int i = 0, l = allProjects.length; i < l && externalLibsToCheck.elementSize > 0; i++) {
                    JavaProject project = (JavaProject) allProjects[i];
                    if (!visitedProjects.includes(project)) {
                        IClasspathEntry[] entries = project.getResolvedClasspath();
                        for (int j = entries.length; --j >= 0;) {
                            IClasspathEntry entry = entries[j];
                            if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
                                IPath path = entry.getPath();
                                if (externalLibsToCheck.remove(path) != null) {
                                    Object target = JavaModel.getTarget(path, false/*don't check existence*/);
                                    if (target instanceof IFolder) // case of an external folder
                                        path = ((IFolder) target).getFullPath();
                                    locations.add(indexManager.computeIndexLocation(path));
                                }
                            }
                        }
                    }
                }
            }
        } catch (JavaModelException e) {
            // ignored
        }
    }

    locations.remove(null); // Ensure no nulls
    this.indexLocations = (IndexLocation[]) locations.toArray(new IndexLocation[locations.size()]);
}