Skip to content

Commit

Permalink
Drop Pair util class (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevmoo committed Aug 29, 2024
1 parent a645c39 commit b3d299e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 22 deletions.
8 changes: 3 additions & 5 deletions lib/src/parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -667,7 +665,7 @@ class Parser {
ScalarEvent(location.pointSpan() as FileSpan, '', ScalarStyle.PLAIN);

/// Parses directives.
Pair<VersionDirective?, List<TagDirective>> _processDirectives() {
(VersionDirective?, List<TagDirective>) _processDirectives() {
var token = _scanner.peek()!;

VersionDirective? versionDirective;
Expand Down Expand Up @@ -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.
Expand Down
12 changes: 6 additions & 6 deletions lib/src/scanner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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.
Expand All @@ -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<int, String> _scanBlockScalarBreaks(int indent) {
({int indent, String trailingBreaks}) _scanBlockScalarBreaks(int indent) {
var maxIndent = 0;
var breaks = StringBuffer();

Expand Down Expand Up @@ -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.
Expand Down
11 changes: 0 additions & 11 deletions lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,6 @@

import 'package:source_span/source_span.dart';

/// A pair of values.
class Pair<E, F> {
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.
Expand Down

0 comments on commit b3d299e

Please sign in to comment.