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

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

Issue 1260443006: Make PathFilter use the resource providers path context (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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 | « pkg/analysis_server/lib/src/context_manager.dart ('k') | pkg/analyzer/test/source/path_filter_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 9ee0070b7d8d83bf593f17552b9bc472c65c7891..6e54ac6549d113e90b73ce91301b783ef4690d7d 100644
--- a/pkg/analyzer/lib/source/path_filter.dart
+++ b/pkg/analyzer/lib/source/path_filter.dart
@@ -5,16 +5,33 @@
library source.path_filter;
import 'package:glob/glob.dart' as glob;
-import 'package:path/path.dart' as pos;
+import 'package:path/path.dart';
/// 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.
+ final Context pathContext;
+
+ /// Path that all ignore patterns are relative to.
+ final String root;
+
+ /// List of ignore patterns that paths are tested against.
+ final List<glob.Glob> _ignorePatterns = new List<glob.Glob>();
+
/// Construct a new path filter rooted at [root] with [ignorePatterns].
- PathFilter(this.root, List<String> ignorePatterns) {
+ PathFilter(this.pathContext, this.root, List<String> ignorePatterns) {
setIgnorePatterns(ignorePatterns);
}
+ /// Returns true if [path] should be ignored. A path is ignored if it is not
+ /// contained in [root] or matches one of the ignore patterns.
+ /// [path] is absolute or relative to [root].
+ bool ignored(String path) {
+ path = _canonicalize(path);
+ return !_contained(path) || _match(path);
+ }
+
/// Set the ignore patterns.
void setIgnorePatterns(List<String> ignorePatterns) {
_ignorePatterns.clear();
@@ -25,19 +42,9 @@ class PathFilter {
}
}
- /// Returns true if [path] should be ignored. A path is ignored if it is not
- /// contained in [root] or matches one of the ignore patterns.
- /// [path] is absolute or relative to [root].
- bool ignored(String path) {
- path = _canonicalize(path);
- return !_contained(path) || _match(path);
- }
-
/// Returns the absolute path of [path], relative to [root].
- String _canonicalize(String path) => pos.normalize(pos.join(root, path));
-
- /// Returns the relative portion of [path] from [root].
- String _relative(String path) => pos.relative(path, from:root);
+ String _canonicalize(String path) =>
+ pathContext.normalize(pathContext.join(root, path));
/// Returns true when [path] is contained inside [root].
bool _contained(String path) => path.startsWith(root);
@@ -53,9 +60,6 @@ class PathFilter {
return false;
}
- /// Path that all ignore patterns are relative to.
- final String root;
-
- /// List of ignore patterns that paths are tested against.
- final List<glob.Glob> _ignorePatterns = new List<glob.Glob>();
+ /// Returns the relative portion of [path] from [root].
+ String _relative(String path) => pathContext.relative(path, from: root);
}
« no previous file with comments | « pkg/analysis_server/lib/src/context_manager.dart ('k') | pkg/analyzer/test/source/path_filter_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698