diff --git a/lib/src/parser.dart b/lib/src/parser.dart index ddbfd4e..e924e40 100644 --- a/lib/src/parser.dart +++ b/lib/src/parser.dart @@ -174,9 +174,7 @@ class Parser { // Parse an explicit document. var start = token.span; - var pair = _processDirectives(); - var versionDirective = pair.first; - var tagDirectives = pair.last; + var (versionDirective, tagDirectives) = _processDirectives(); token = _scanner.peek()!; if (token.type != TokenType.documentStart) { throw YamlException('Expected document start.', token.span); @@ -667,7 +665,7 @@ class Parser { ScalarEvent(location.pointSpan() as FileSpan, '', ScalarStyle.PLAIN); /// Parses directives. - Pair> _processDirectives() { + (VersionDirective?, List) _processDirectives() { var token = _scanner.peek()!; VersionDirective? versionDirective; @@ -707,7 +705,7 @@ class Parser { TagDirective('!!', 'tag:yaml.org,2002:'), token.span.start.pointSpan(), allowDuplicates: true); - return Pair(versionDirective, tagDirectives); + return (versionDirective, tagDirectives); } /// Adds a tag directive to the directives stack. diff --git a/lib/src/scanner.dart b/lib/src/scanner.dart index 4b155e1..1cfd3af 100644 --- a/lib/src/scanner.dart +++ b/lib/src/scanner.dart @@ -1142,8 +1142,8 @@ class Scanner { // Scan the leading line breaks to determine the indentation level if // needed. var pair = _scanBlockScalarBreaks(indent); - indent = pair.first; - var trailingBreaks = pair.last; + indent = pair.indent; + var trailingBreaks = pair.trailingBreaks; // Scan the block scalar contents. var buffer = StringBuffer(); @@ -1194,8 +1194,8 @@ class Scanner { // Eat the following indentation and spaces. var pair = _scanBlockScalarBreaks(indent); - indent = pair.first; - trailingBreaks = pair.last; + indent = pair.indent; + trailingBreaks = pair.trailingBreaks; } // Chomp the tail. @@ -1210,7 +1210,7 @@ class Scanner { /// /// Determines the intendation level if needed. Returns the new indentation /// level and the text of the line breaks. - Pair _scanBlockScalarBreaks(int indent) { + ({int indent, String trailingBreaks}) _scanBlockScalarBreaks(int indent) { var maxIndent = 0; var breaks = StringBuffer(); @@ -1238,7 +1238,7 @@ class Scanner { // be supported by the spec. } - return Pair(indent, breaks.toString()); + return (indent: indent, trailingBreaks: breaks.toString()); } // Scans a quoted scalar. diff --git a/lib/src/utils.dart b/lib/src/utils.dart index d9e20d1..0dc132f 100644 --- a/lib/src/utils.dart +++ b/lib/src/utils.dart @@ -7,17 +7,6 @@ import 'package:source_span/source_span.dart'; -/// A pair of values. -class Pair { - final E first; - final F last; - - Pair(this.first, this.last); - - @override - String toString() => '($first, $last)'; -} - /// Print a warning. /// /// If [span] is passed, associates the warning with that span.