Index: editor/tools/plugins/com.google.dart.tools.search/src/com/google/dart/tools/search/core/text/TextSearchScope.java |
=================================================================== |
--- editor/tools/plugins/com.google.dart.tools.search/src/com/google/dart/tools/search/core/text/TextSearchScope.java (revision 7355) |
+++ editor/tools/plugins/com.google.dart.tools.search/src/com/google/dart/tools/search/core/text/TextSearchScope.java (working copy) |
@@ -1,5 +1,5 @@ |
/* |
- * Copyright (c) 2011, the Dart project authors. |
+ * Copyright (c) 2012, the Dart project authors. |
* |
* Licensed under the Eclipse Public License v1.0 (the "License"); you may not use this file except |
* in compliance with the License. You may obtain a copy of the License at |
@@ -13,18 +13,18 @@ |
*/ |
package com.google.dart.tools.search.core.text; |
+import com.google.dart.tools.search.internal.core.text.ExternalFilesOfScopeCalculator; |
import com.google.dart.tools.search.internal.core.text.FileNamePatternSearchScope; |
import com.google.dart.tools.search.internal.core.text.FilesOfScopeCalculator; |
-import java.util.regex.Pattern; |
- |
-import org.eclipse.core.runtime.MultiStatus; |
- |
import org.eclipse.core.resources.IFile; |
import org.eclipse.core.resources.IResource; |
import org.eclipse.core.resources.IResourceProxy; |
import org.eclipse.core.resources.ResourcesPlugin; |
+import org.eclipse.core.runtime.MultiStatus; |
+import java.io.File; |
+import java.util.regex.Pattern; |
/** |
* A {@link TextSearchScope} defines the scope of a search. The scope consists of all workbench |
@@ -35,6 +35,8 @@ |
*/ |
public abstract class TextSearchScope { |
+ private static final File[] EMPTY_ARRAY = new File[0]; |
+ |
/** |
* Creates a scope that consists of all files that match the <code>fileNamePattern</code> and that |
* either are one of the roots, or have one of the roots in their parent chain. If |
@@ -55,15 +57,14 @@ |
} |
/** |
- * Returns the resources that form the root. Roots can not contain each other. Root elements are |
- * only part of the scope if they are also accepted by {@link #contains(IResourceProxy)}. |
+ * Returns if a given resource is part of the scope. If a container is not part of the scope, also |
+ * all its members are not part of the scope. |
* |
- * @return returns the set of root resources. The default behavior is to return the workspace |
- * root. |
+ * @param file the file to test. |
+ * @return returns <code>true</code> if a resource is part of the scope. if <code>false</code> is |
+ * returned the resource and all its children are not part of the scope. |
*/ |
- public IResource[] getRoots() { |
- return new IResource[] {ResourcesPlugin.getWorkspace().getRoot()}; |
- } |
+ public abstract boolean contains(File file); |
/** |
* Returns if a given resource is part of the scope. If a container is not part of the scope, also |
@@ -76,6 +77,17 @@ |
public abstract boolean contains(IResourceProxy proxy); |
/** |
+ * Evaluates all external files in this scope. |
+ * |
+ * @param status a {@link MultiStatus} to collect the error status that occurred while collecting |
+ * resources. |
+ * @return returns the files in the scope. |
+ */ |
+ public File[] evaluateExternalFilesInScope(MultiStatus status) { |
+ return new ExternalFilesOfScopeCalculator(this, status).process(); |
+ } |
+ |
+ /** |
* Evaluates all files in this scope. |
* |
* @param status a {@link MultiStatus} to collect the error status that occurred while collecting |
@@ -86,4 +98,25 @@ |
return new FilesOfScopeCalculator(this, status).process(); |
} |
+ /** |
+ * Returns the external resources that form the root. Roots can not contain each other. Root |
+ * elements are only part of the scope if they are also accepted by {@link #contains(File)}. |
+ * |
+ * @return returns the set of root resources. The default behavior is to return an empty array. |
+ */ |
+ public File[] getExternalRoots() { |
+ return EMPTY_ARRAY; |
+ } |
+ |
+ /** |
+ * Returns the resources that form the root. Roots can not contain each other. Root elements are |
+ * only part of the scope if they are also accepted by {@link #contains(IResourceProxy)}. |
+ * |
+ * @return returns the set of root resources. The default behavior is to return the workspace |
+ * root. |
+ */ |
+ public IResource[] getRoots() { |
+ return new IResource[] {ResourcesPlugin.getWorkspace().getRoot()}; |
+ } |
+ |
} |