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

Side by Side Diff: packages/glob/lib/glob.dart

Issue 3014633002: Roll to pickup pool changes (Closed)
Patch Set: Created 3 years, 2 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 unified diff | Download patch
« no previous file with comments | « packages/glob/CHANGELOG.md ('k') | packages/glob/lib/src/ast.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:io'; 6 import 'dart:io';
7 7
8 import 'package:path/path.dart' as p; 8 import 'package:path/path.dart' as p;
9 9
10 import 'src/ast.dart'; 10 import 'src/ast.dart';
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 ListTree _listTree; 52 ListTree _listTree;
53 53
54 /// Whether [context]'s current directory is absolute. 54 /// Whether [context]'s current directory is absolute.
55 bool get _contextIsAbsolute { 55 bool get _contextIsAbsolute {
56 if (_contextIsAbsoluteCache == null) { 56 if (_contextIsAbsoluteCache == null) {
57 _contextIsAbsoluteCache = context.isAbsolute(context.current); 57 _contextIsAbsoluteCache = context.isAbsolute(context.current);
58 } 58 }
59 return _contextIsAbsoluteCache; 59 return _contextIsAbsoluteCache;
60 } 60 }
61
61 bool _contextIsAbsoluteCache; 62 bool _contextIsAbsoluteCache;
62 63
63 /// Whether [pattern] could match absolute paths. 64 /// Whether [pattern] could match absolute paths.
64 bool get _patternCanMatchAbsolute { 65 bool get _patternCanMatchAbsolute {
65 if (_patternCanMatchAbsoluteCache == null) { 66 if (_patternCanMatchAbsoluteCache == null) {
66 _patternCanMatchAbsoluteCache = _ast.canMatchAbsolute; 67 _patternCanMatchAbsoluteCache = _ast.canMatchAbsolute;
67 } 68 }
68 return _patternCanMatchAbsoluteCache; 69 return _patternCanMatchAbsoluteCache;
69 } 70 }
71
70 bool _patternCanMatchAbsoluteCache; 72 bool _patternCanMatchAbsoluteCache;
71 73
72 /// Whether [pattern] could match relative paths. 74 /// Whether [pattern] could match relative paths.
73 bool get _patternCanMatchRelative { 75 bool get _patternCanMatchRelative {
74 if (_patternCanMatchRelativeCache == null) { 76 if (_patternCanMatchRelativeCache == null) {
75 _patternCanMatchRelativeCache = _ast.canMatchRelative; 77 _patternCanMatchRelativeCache = _ast.canMatchRelative;
76 } 78 }
77 return _patternCanMatchRelativeCache; 79 return _patternCanMatchRelativeCache;
78 } 80 }
81
79 bool _patternCanMatchRelativeCache; 82 bool _patternCanMatchRelativeCache;
80 83
81 /// Returns [contents] with characters that are meaningful in globs 84 /// Returns [contents] with characters that are meaningful in globs
82 /// backslash-escaped. 85 /// backslash-escaped.
83 static String quote(String contents) => 86 static String quote(String contents) =>
84 contents.replaceAllMapped(_quoteRegExp, (match) => '\\${match[0]}'); 87 contents.replaceAllMapped(_quoteRegExp, (match) => '\\${match[0]}');
85 88
86 /// Creates a new glob with [pattern]. 89 /// Creates a new glob with [pattern].
87 /// 90 ///
88 /// Paths matched against the glob are interpreted according to [context]. It 91 /// Paths matched against the glob are interpreted according to [context]. It
89 /// defaults to the system context. 92 /// defaults to the system context.
90 /// 93 ///
91 /// If [recursive] is true, this glob matches and lists not only the files and 94 /// If [recursive] is true, this glob matches and lists not only the files and
92 /// directories it explicitly matches, but anything beneath those as well. 95 /// directories it explicitly matches, but anything beneath those as well.
93 /// 96 ///
94 /// If [caseSensitive] is true, this glob matches and lists only files whose 97 /// If [caseSensitive] is true, this glob matches and lists only files whose
95 /// case matches that of the characters in the glob. Otherwise, it matches 98 /// case matches that of the characters in the glob. Otherwise, it matches
96 /// regardless of case. This defaults to `false` when [context] is Windows and 99 /// regardless of case. This defaults to `false` when [context] is Windows and
97 /// `true` otherwise. 100 /// `true` otherwise.
98 factory Glob(String pattern, {p.Context context, bool recursive: false, 101 factory Glob(String pattern,
99 bool caseSensitive}) { 102 {p.Context context, bool recursive: false, bool caseSensitive}) {
100 context ??= p.context; 103 context ??= p.context;
101 caseSensitive ??= context.style == p.Style.windows ? false : true; 104 caseSensitive ??= context.style == p.Style.windows ? false : true;
102 if (recursive) pattern += "{,/**}"; 105 if (recursive) pattern += "{,/**}";
103 106
104 var parser = new Parser(pattern, context, caseSensitive: caseSensitive); 107 var parser = new Parser(pattern, context, caseSensitive: caseSensitive);
105 return new Glob._(pattern, context, parser.parse(), recursive); 108 return new Glob._(pattern, context, parser.parse(), recursive);
106 } 109 }
107 110
108 Glob._(this.pattern, this.context, this._ast, this.recursive); 111 Glob._(this.pattern, this.context, this._ast, this.recursive);
109 112
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 return null; 177 return null;
175 } 178 }
176 179
177 Iterable<Match> allMatches(String path, [int start = 0]) { 180 Iterable<Match> allMatches(String path, [int start = 0]) {
178 var match = matchAsPrefix(path, start); 181 var match = matchAsPrefix(path, start);
179 return match == null ? [] : [match]; 182 return match == null ? [] : [match];
180 } 183 }
181 184
182 String toString() => pattern; 185 String toString() => pattern;
183 } 186 }
OLDNEW
« no previous file with comments | « packages/glob/CHANGELOG.md ('k') | packages/glob/lib/src/ast.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698