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

Unified Diff: lib/src/parser.dart

Issue 1491003002: Add a caseSensitive flag to new Glob(). (Closed) Base URL: git@github.com:dart-lang/glob@master
Patch Set: Code review changes Created 5 years 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 | « lib/src/list_tree.dart ('k') | pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/parser.dart
diff --git a/lib/src/parser.dart b/lib/src/parser.dart
index 5dac14617bc517d6fe25f73f0f49b35d4ff5a70b..24090535558d42a283bf37e71bfee0f355c7665e 100644
--- a/lib/src/parser.dart
+++ b/lib/src/parser.dart
@@ -21,8 +21,12 @@ class Parser {
/// The path context for the glob.
final p.Context _context;
- Parser(String component, this._context)
- : _scanner = new StringScanner(component);
+ /// Whether this glob is case-sensitive.
+ final bool _caseSensitive;
+
+ Parser(String component, this._context, {bool caseSensitive: true})
+ : _scanner = new StringScanner(component),
+ _caseSensitive = caseSensitive;
/// Parses an entire glob.
SequenceNode parse() => _parseSequence();
@@ -42,7 +46,7 @@ class Parser {
nodes.add(_parseNode(inOptions: inOptions));
}
- return new SequenceNode(nodes);
+ return new SequenceNode(nodes, caseSensitive: _caseSensitive);
}
/// Parses an [AstNode].
@@ -69,7 +73,9 @@ class Parser {
/// Returns `null` if there's not one to parse.
AstNode _parseStar() {
if (!_scanner.scan('*')) return null;
- return _scanner.scan('*') ? new DoubleStarNode(_context) : new StarNode();
+ return _scanner.scan('*')
+ ? new DoubleStarNode(_context, caseSensitive: _caseSensitive)
+ : new StarNode(caseSensitive: _caseSensitive);
}
/// Tries to parse an [AnyCharNode].
@@ -77,7 +83,7 @@ class Parser {
/// Returns `null` if there's not one to parse.
AstNode _parseAnyChar() {
if (!_scanner.scan('?')) return null;
- return new AnyCharNode();
+ return new AnyCharNode(caseSensitive: _caseSensitive);
}
/// Tries to parse an [RangeNode].
@@ -125,7 +131,8 @@ class Parser {
}
}
- return new RangeNode(ranges, negated: negated);
+ return new RangeNode(ranges,
+ negated: negated, caseSensitive: _caseSensitive);
}
/// Tries to parse an [OptionsNode].
@@ -144,7 +151,7 @@ class Parser {
if (options.length == 1) _scanner.expect(',');
_scanner.expect('}');
- return new OptionsNode(options);
+ return new OptionsNode(options, caseSensitive: _caseSensitive);
}
/// Parses a [LiteralNode].
@@ -168,6 +175,7 @@ class Parser {
}
if (!inOptions && _scanner.matches('}')) _scanner.error('unexpected "}"');
- return new LiteralNode(buffer.toString(), _context);
+ return new LiteralNode(buffer.toString(),
+ context: _context, caseSensitive: _caseSensitive);
}
}
« no previous file with comments | « lib/src/list_tree.dart ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698