Skip to content

Commit

Permalink
Change matchers list from List to Iterable
Browse files Browse the repository at this point in the history
  • Loading branch information
kaboc committed Dec 28, 2023
1 parent e2e26f6 commit 2107733
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lib/src/parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const _kMatcherGroupPrefix = '__mg__';

class Parser {
Parser({
required List<TextMatcher> matchers,
required Iterable<TextMatcher> matchers,
required this.multiLine,
required this.caseSensitive,
required this.unicode,
Expand All @@ -19,14 +19,14 @@ class Parser {
final bool unicode;
final bool dotAll;

late List<TextMatcher> _matchers;
late Iterable<TextMatcher> _matchers;
final List<String> _matcherGroupNames = [];
final List<List<int>> _matcherGroupRanges = [];
late String _pattern;

List<TextMatcher> get matchers => List.unmodifiable(_matchers);

void update(List<TextMatcher> matchers) {
void update(Iterable<TextMatcher> matchers) {
assert(
matchers.isNotEmpty,
'At least one matcher must not specified.',
Expand All @@ -43,7 +43,7 @@ class Parser {
final groupName = '$_kMatcherGroupPrefix$i';
_matcherGroupNames.add(groupName);

var pattern = matchers[i].pattern;
var pattern = matchers.elementAt(i).pattern;
if (pattern.isEmpty) {
// Expression that does not match anything.
pattern = '(?!)';
Expand Down
2 changes: 1 addition & 1 deletion lib/text_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class TextParser {
/// If [dotAll] is enabled, then the `.` pattern will match _all_
/// characters, including line terminators.
TextParser({
required List<TextMatcher> matchers,
required Iterable<TextMatcher> matchers,
bool multiLine = false,
bool caseSensitive = true,
bool unicode = false,
Expand Down

0 comments on commit 2107733

Please sign in to comment.