private void addTextMatches(IResource resource, IProgressMonitor pm) throws JavaModelException { try { String task = RefactoringCoreMessages.TextMatchUpdater_searching + resource.getFullPath(); if (resource instanceof IFile) { IJavaElement element = JavaCore.create(resource); // don't start pm task (flickering label updates; finally {pm.done()} is enough) if (!(element instanceof ICompilationUnit)) return; if (!element.exists()) return; if (!fScope.encloses(element)) return; addCuTextMatches((ICompilationUnit) element); } else if (resource instanceof IContainer) { IResource[] members = ((IContainer) resource).members(); pm.beginTask(task, members.length); pm.subTask(task); for (int i = 0; i < members.length; i++) { if (pm.isCanceled()) throw new OperationCanceledException(); addTextMatches(members[i], new SubProgressMonitor(pm, 1)); } } } catch (JavaModelException e) { throw e; } catch (CoreException e) { throw new JavaModelException(e); } finally { pm.done(); } }
private IProject[] getProjectsInScope() { IPath[] enclosingProjects = fScope.enclosingProjectsAndJars(); Set<IPath> enclosingProjectSet = new HashSet<IPath>(); enclosingProjectSet.addAll(Arrays.asList(enclosingProjects)); ArrayList<IProject> projectsInScope = new ArrayList<IProject>(); IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); for (int i = 0; i < projects.length; i++) { if (enclosingProjectSet.contains(projects[i].getFullPath())) projectsInScope.add(projects[i]); } return projectsInScope.toArray(new IProject[projectsInScope.size()]); }