Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Unified Diff: editor/tools/plugins/com.google.dart.tools.search/src/com/google/dart/tools/search/internal/ui/text/TextSearchScopeFilter.java

Issue 10694039: Fix to limit SDK text search matches to darty files (dartbug.com/3896). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: editor/tools/plugins/com.google.dart.tools.search/src/com/google/dart/tools/search/internal/ui/text/TextSearchScopeFilter.java
===================================================================
--- editor/tools/plugins/com.google.dart.tools.search/src/com/google/dart/tools/search/internal/ui/text/TextSearchScopeFilter.java (revision 9254)
+++ editor/tools/plugins/com.google.dart.tools.search/src/com/google/dart/tools/search/internal/ui/text/TextSearchScopeFilter.java (working copy)
@@ -24,8 +24,11 @@
*/
public class TextSearchScopeFilter {
- private static final String LIB_CONFIG_PATH = "dart-sdk" + File.separator + "lib"
- + File.separator + "config";
+ /**
+ * A whitelist of file extensions that should be included in external file search.
+ */
+ private static final String[] SEARCHABLE_EXTERNAL_FILE_EXTENSIONS = {
+ ".css", ".dart", ".html", ".js"};
/**
* Checks if the given file should be filtered out of a search scope.
@@ -34,30 +37,41 @@
* @return <code>true</code> if the file should be excluded, <code>false</code> otherwise
*/
public static boolean isFiltered(File file) {
- //dart-sdk/lib/config
- if (file.getAbsolutePath().endsWith(LIB_CONFIG_PATH)) {
- return true;
- }
- return isFiltered(file.getName());
+ return file.isFile() && isExternaFileNameFiltered(file.getName());
}
/**
- * Checks if the given file should be filtered out of a search scope.
+ * Checks if the given workspace file should be filtered out of a search scope.
*
* @param file the file to check
* @return <code>true</code> if the file should be excluded, <code>false</code> otherwise
*/
public static boolean isFiltered(IResourceProxy file) {
- return isFiltered(file.getName());
+ return isWorkspaceFileNameFiltered(file.getName());
}
/**
+ * Checks if the given external file should be filtered out of a search scope.
+ *
+ * @param fileName the fileName to check
+ * @return <code>true</code> if the file should be excluded, <code>false</code> otherwise
+ */
+ private static boolean isExternaFileNameFiltered(String fileName) {
+ for (String ext : SEARCHABLE_EXTERNAL_FILE_EXTENSIONS) {
+ if (fileName.endsWith(ext)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
* Checks if the given file name should be filtered out of a search scope.
*
* @param fileName the file name to check
* @return <code>true</code> if the file should be excluded, <code>false</code> otherwise
*/
- private static boolean isFiltered(String fileName) {
+ private static boolean isWorkspaceFileNameFiltered(String fileName) {
//ignore .files (and avoid traversing into folders prefixed with a '.')
if (fileName.startsWith(".")) {
return true;
@@ -65,10 +79,6 @@
if (fileName.endsWith(".dart.js")) {
return true;
}
- //dart2js-gened file (temporary)
- if (fileName.endsWith(".dart.js_")) {
- return true;
- }
return DartCore.isImageLikeFileName(fileName);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698