1 11 package org.eclipse.search.internal.core.text; 12 13 import org.eclipse.core.runtime.CoreException; 14 import org.eclipse.core.runtime.MultiStatus; 15 16 import org.eclipse.core.resources.IResource; 17 import org.eclipse.core.resources.IResourceProxy; 18 import org.eclipse.core.resources.IResourceProxyVisitor; 19 20 import org.eclipse.search.internal.core.SearchScope; 21 22 25 public class AmountOfWorkCalculator implements IResourceProxyVisitor { 26 27 private SearchScope fScope; 28 private int fFileCount; 29 private boolean fVisitDerived; 30 private final MultiStatus fStatus; 31 32 AmountOfWorkCalculator(SearchScope scope, MultiStatus status, boolean visitDerived) { 33 fStatus= status; 34 fScope= scope; 35 fVisitDerived= visitDerived; 36 } 37 38 public boolean visit(IResourceProxy proxy) { 39 if (proxy.getType() != IResource.FILE) { 40 return true; 41 } 42 43 if ((fVisitDerived || !proxy.isDerived()) && fScope.matchesFileName(proxy.getName())) { 44 fFileCount++; 45 } 46 return true; 47 } 48 49 public int process() { 50 fFileCount= 0; 51 IResource[] roots= fScope.getRootElements(); 52 for (int i= 0; i < roots.length; i++) { 53 try { 54 roots[i].accept(this, 0); 55 } catch (CoreException ex) { 56 fStatus.add(ex.getStatus()); 57 } 58 } 59 return fFileCount; 60 } 61 } 62 | Popular Tags |