1 11 package org.eclipse.search.internal.core.text; 12 13 import java.util.ArrayList ; 14 15 import org.eclipse.core.runtime.CoreException; 16 import org.eclipse.core.runtime.MultiStatus; 17 18 import org.eclipse.core.resources.IFile; 19 import org.eclipse.core.resources.IResource; 20 import org.eclipse.core.resources.IResourceProxy; 21 import org.eclipse.core.resources.IResourceProxyVisitor; 22 23 import org.eclipse.search.core.text.TextSearchScope; 24 25 public class FilesOfScopeCalculator implements IResourceProxyVisitor { 26 27 private final TextSearchScope fScope; 28 private final MultiStatus fStatus; 29 private ArrayList fFiles; 30 31 public FilesOfScopeCalculator(TextSearchScope scope, MultiStatus status) { 32 fScope= scope; 33 fStatus= status; 34 } 35 36 public boolean visit(IResourceProxy proxy) { 37 boolean inScope= fScope.contains(proxy); 38 39 if (inScope && proxy.getType() == IResource.FILE) { 40 fFiles.add(proxy.requestResource()); 41 } 42 return inScope; 43 } 44 45 public IFile[] process() { 46 fFiles= new ArrayList (); 47 try { 48 IResource[] roots= fScope.getRoots(); 49 for (int i= 0; i < roots.length; i++) { 50 try { 51 IResource resource= roots[i]; 52 if (resource.isAccessible()) { 53 resource.accept(this, 0); 54 } 55 } catch (CoreException ex) { 56 fStatus.add(ex.getStatus()); 58 } 59 } 60 return (IFile[]) fFiles.toArray(new IFile[fFiles.size()]); 61 } finally { 62 fFiles= null; 63 } 64 } 65 } 66 | Popular Tags |