Skip to content

Commit 5bb3a10

Browse files
authored
Drop Pair util class (dart-archive/yaml#169)
1 parent a0f9e57 commit 5bb3a10

File tree

3 files changed

+9
-22
lines changed

3 files changed

+9
-22
lines changed

pkgs/yaml/lib/src/parser.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,7 @@ class Parser {
174174

175175
// Parse an explicit document.
176176
var start = token.span;
177-
var pair = _processDirectives();
178-
var versionDirective = pair.first;
179-
var tagDirectives = pair.last;
177+
var (versionDirective, tagDirectives) = _processDirectives();
180178
token = _scanner.peek()!;
181179
if (token.type != TokenType.documentStart) {
182180
throw YamlException('Expected document start.', token.span);
@@ -667,7 +665,7 @@ class Parser {
667665
ScalarEvent(location.pointSpan() as FileSpan, '', ScalarStyle.PLAIN);
668666

669667
/// Parses directives.
670-
Pair<VersionDirective?, List<TagDirective>> _processDirectives() {
668+
(VersionDirective?, List<TagDirective>) _processDirectives() {
671669
var token = _scanner.peek()!;
672670

673671
VersionDirective? versionDirective;
@@ -707,7 +705,7 @@ class Parser {
707705
TagDirective('!!', 'tag:yaml.org,2002:'), token.span.start.pointSpan(),
708706
allowDuplicates: true);
709707

710-
return Pair(versionDirective, tagDirectives);
708+
return (versionDirective, tagDirectives);
711709
}
712710

713711
/// Adds a tag directive to the directives stack.

pkgs/yaml/lib/src/scanner.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,8 +1142,8 @@ class Scanner {
11421142
// Scan the leading line breaks to determine the indentation level if
11431143
// needed.
11441144
var pair = _scanBlockScalarBreaks(indent);
1145-
indent = pair.first;
1146-
var trailingBreaks = pair.last;
1145+
indent = pair.indent;
1146+
var trailingBreaks = pair.trailingBreaks;
11471147

11481148
// Scan the block scalar contents.
11491149
var buffer = StringBuffer();
@@ -1194,8 +1194,8 @@ class Scanner {
11941194

11951195
// Eat the following indentation and spaces.
11961196
var pair = _scanBlockScalarBreaks(indent);
1197-
indent = pair.first;
1198-
trailingBreaks = pair.last;
1197+
indent = pair.indent;
1198+
trailingBreaks = pair.trailingBreaks;
11991199
}
12001200

12011201
// Chomp the tail.
@@ -1210,7 +1210,7 @@ class Scanner {
12101210
///
12111211
/// Determines the intendation level if needed. Returns the new indentation
12121212
/// level and the text of the line breaks.
1213-
Pair<int, String> _scanBlockScalarBreaks(int indent) {
1213+
({int indent, String trailingBreaks}) _scanBlockScalarBreaks(int indent) {
12141214
var maxIndent = 0;
12151215
var breaks = StringBuffer();
12161216

@@ -1238,7 +1238,7 @@ class Scanner {
12381238
// be supported by the spec.
12391239
}
12401240

1241-
return Pair(indent, breaks.toString());
1241+
return (indent: indent, trailingBreaks: breaks.toString());
12421242
}
12431243

12441244
// Scans a quoted scalar.

pkgs/yaml/lib/src/utils.dart

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,6 @@
77

88
import 'package:source_span/source_span.dart';
99

10-
/// A pair of values.
11-
class Pair<E, F> {
12-
final E first;
13-
final F last;
14-
15-
Pair(this.first, this.last);
16-
17-
@override
18-
String toString() => '($first, $last)';
19-
}
20-
2110
/// Print a warning.
2211
///
2312
/// If [span] is passed, associates the warning with that span.

0 commit comments

Comments
 (0)