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

Unified Diff: pkg/analyzer/lib/source/path_filter.dart

Issue 1452473002: Replace Glob implementation. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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
Index: pkg/analyzer/lib/source/path_filter.dart
diff --git a/pkg/analyzer/lib/source/path_filter.dart b/pkg/analyzer/lib/source/path_filter.dart
index 40e81a63427386a08c82af332d72ce753678e0b9..7eeada2aa4823d27fff3f0f57b750e0635b205fe 100644
--- a/pkg/analyzer/lib/source/path_filter.dart
+++ b/pkg/analyzer/lib/source/path_filter.dart
@@ -4,10 +4,10 @@
library source.path_filter;
-import 'package:glob/glob.dart' as glob;
+import 'package:analyzer/src/util/glob.dart';
import 'package:path/path.dart' as path;
-/// Filter paths against a set of [ignorePatterns] relative to a [root]
+/// Filter paths against a set of [_ignorePatterns] relative to a [root]
/// directory. Paths outside of [root] are also ignored.
class PathFilter {
/// The path context to use when manipulating paths.
@@ -17,7 +17,7 @@ class PathFilter {
final String root;
/// List of ignore patterns that paths are tested against.
- final List<glob.Glob> _ignorePatterns = new List<glob.Glob>();
+ final List<Glob> _ignorePatterns = new List<Glob>();
/// Construct a new path filter rooted at [root] with [ignorePatterns].
/// If [pathContext] is not specified, then the system path context is used.
@@ -39,11 +39,20 @@ class PathFilter {
_ignorePatterns.clear();
if (ignorePatterns != null) {
for (var ignorePattern in ignorePatterns) {
- _ignorePatterns.add(new glob.Glob(ignorePattern));
+ _ignorePatterns.add(new Glob(pathContext.separator, ignorePattern));
}
}
}
+ String toString() {
+ StringBuffer sb = new StringBuffer();
+ for (Glob pattern in _ignorePatterns) {
+ sb.write('$pattern ');
+ }
+ sb.writeln('');
+ return sb.toString();
+ }
+
/// Returns the absolute path of [path], relative to [root].
String _canonicalize(String path) =>
pathContext.normalize(pathContext.join(root, path));
@@ -54,7 +63,7 @@ class PathFilter {
/// Returns true if [path] matches any ignore patterns.
bool _match(String path) {
path = _relative(path);
- for (var glob in _ignorePatterns) {
+ for (Glob glob in _ignorePatterns) {
if (glob.matches(path)) {
return true;
}
@@ -64,13 +73,4 @@ class PathFilter {
/// Returns the relative portion of [path] from [root].
String _relative(String path) => pathContext.relative(path, from: root);
-
- String toString() {
- StringBuffer sb = new StringBuffer();
- for (var pattern in _ignorePatterns) {
- sb.write('$pattern ');
- }
- sb.writeln('');
- return sb.toString();
- }
}

Powered by Google App Engine
This is Rietveld 408576698