Enable and fix a number of lints
diff --git a/pkgs/yaml/analysis_options.yaml b/pkgs/yaml/analysis_options.yaml new file mode 100644 index 0000000..7f965d2 --- /dev/null +++ b/pkgs/yaml/analysis_options.yaml
@@ -0,0 +1,43 @@ +include: package:pedantic/analysis_options.yaml +analyzer: + strong-mode: + implicit-casts: false +linter: + rules: + - avoid_empty_else + - avoid_init_to_null + - avoid_null_checks_in_equality_operators + - avoid_unused_constructor_parameters + - await_only_futures + - camel_case_types + - cancel_subscriptions + #- constant_identifier_names + - control_flow_in_finally + - directives_ordering + - empty_catches + - empty_constructor_bodies + - empty_statements + - hash_and_equals + - implementation_imports + - iterable_contains_unrelated_type + - library_names + - library_prefixes + - list_remove_unrelated_type + - non_constant_identifier_names + - overridden_fields + - package_api_docs + - package_names + - package_prefixed_library_names + - prefer_equal_for_default_values + - prefer_final_fields + - prefer_generic_function_type_aliases + - prefer_is_not_empty + - slash_for_doc_comments + - test_types_in_equals + - throw_in_finally + - type_init_formals + - unnecessary_brace_in_string_interps + - unnecessary_const + - unnecessary_new + - unrelated_type_equality_checks + - valid_regexps
diff --git a/pkgs/yaml/benchmark/benchmark.dart b/pkgs/yaml/benchmark/benchmark.dart index e3521b1..5e080eb 100644 --- a/pkgs/yaml/benchmark/benchmark.dart +++ b/pkgs/yaml/benchmark/benchmark.dart
@@ -23,7 +23,7 @@ // Run the benchmark several times. This ensures the VM is warmed up and lets // us see how much variance there is. for (var i = 0; i <= numTrials; i++) { - var start = new DateTime.now(); + var start = DateTime.now(); // For a single benchmark, convert the source multiple times. var result; @@ -32,7 +32,7 @@ } var elapsed = - new DateTime.now().difference(start).inMilliseconds / runsPerTrial; + DateTime.now().difference(start).inMilliseconds / runsPerTrial; // Keep track of the best run so far. if (elapsed >= best) continue; @@ -56,7 +56,7 @@ String loadFile(String name) { var path = p.join(p.dirname(p.fromUri(Platform.script)), name); - return new File(path).readAsStringSync(); + return File(path).readAsStringSync(); } void printResult(String label, double time) {
diff --git a/pkgs/yaml/codereview.settings b/pkgs/yaml/codereview.settings deleted file mode 100644 index 03b6c27..0000000 --- a/pkgs/yaml/codereview.settings +++ /dev/null
@@ -1,3 +0,0 @@ -CODE_REVIEW_SERVER: https://codereview.chromium.org/ -VIEW_VC: https://github.com/dart-lang/yaml/commit/ -CC_LIST: reviews@dartlang.org \ No newline at end of file
diff --git a/pkgs/yaml/lib/src/equality.dart b/pkgs/yaml/lib/src/equality.dart index 3c947a9..66b8196 100644 --- a/pkgs/yaml/lib/src/equality.dart +++ b/pkgs/yaml/lib/src/equality.dart
@@ -10,13 +10,13 @@ /// Returns a [Map] that compares its keys based on [deepEquals]. Map<K, V> deepEqualsMap<K, V>() => - new HashMap(equals: deepEquals, hashCode: deepHashCode); + HashMap(equals: deepEquals, hashCode: deepHashCode); /// Returns whether two objects are structurally equivalent. /// /// This considers `NaN` values to be equivalent, handles self-referential /// structures, and considers [YamlScalar]s to be equal to their values. -bool deepEquals(obj1, obj2) => new _DeepEquals().equals(obj1, obj2); +bool deepEquals(obj1, obj2) => _DeepEquals().equals(obj1, obj2); /// A class that provides access to the list of parent objects used for loop /// detection.
diff --git a/pkgs/yaml/lib/src/event.dart b/pkgs/yaml/lib/src/event.dart index 296df22..3be5a0a 100644 --- a/pkgs/yaml/lib/src/event.dart +++ b/pkgs/yaml/lib/src/event.dart
@@ -38,7 +38,7 @@ DocumentStartEvent(this.span, {this.versionDirective, List<TagDirective> tagDirectives, - this.isImplicit: true}) + this.isImplicit = true}) : tagDirectives = tagDirectives == null ? [] : tagDirectives; String toString() => "DOCUMENT_START"; @@ -53,7 +53,7 @@ /// `...` sequence). final bool isImplicit; - DocumentEndEvent(this.span, {this.isImplicit: true}); + DocumentEndEvent(this.span, {this.isImplicit = true}); String toString() => "DOCUMENT_END"; } @@ -81,7 +81,7 @@ String get tag; String toString() { - var buffer = new StringBuffer('$type'); + var buffer = StringBuffer('$type'); if (anchor != null) buffer.write(" &$anchor"); if (tag != null) buffer.write(" $tag"); return buffer.toString(); @@ -134,20 +134,20 @@ /// An enum of types of [Event] object. class EventType { - static const STREAM_START = const EventType._("STREAM_START"); - static const STREAM_END = const EventType._("STREAM_END"); + static const STREAM_START = EventType._("STREAM_START"); + static const STREAM_END = EventType._("STREAM_END"); - static const DOCUMENT_START = const EventType._("DOCUMENT_START"); - static const DOCUMENT_END = const EventType._("DOCUMENT_END"); + static const DOCUMENT_START = EventType._("DOCUMENT_START"); + static const DOCUMENT_END = EventType._("DOCUMENT_END"); - static const ALIAS = const EventType._("ALIAS"); - static const SCALAR = const EventType._("SCALAR"); + static const ALIAS = EventType._("ALIAS"); + static const SCALAR = EventType._("SCALAR"); - static const SEQUENCE_START = const EventType._("SEQUENCE_START"); - static const SEQUENCE_END = const EventType._("SEQUENCE_END"); + static const SEQUENCE_START = EventType._("SEQUENCE_START"); + static const SEQUENCE_END = EventType._("SEQUENCE_END"); - static const MAPPING_START = const EventType._("MAPPING_START"); - static const MAPPING_END = const EventType._("MAPPING_END"); + static const MAPPING_START = EventType._("MAPPING_START"); + static const MAPPING_END = EventType._("MAPPING_END"); final String name;
diff --git a/pkgs/yaml/lib/src/loader.dart b/pkgs/yaml/lib/src/loader.dart index 956b17c..70aec36 100644 --- a/pkgs/yaml/lib/src/loader.dart +++ b/pkgs/yaml/lib/src/loader.dart
@@ -23,7 +23,7 @@ final Parser _parser; /// Aliases by the alias name. - final _aliases = new Map<String, YamlNode>(); + final _aliases = Map<String, YamlNode>(); /// The span of the entire stream emitted so far. FileSpan get span => _span; @@ -33,7 +33,7 @@ /// /// [sourceUrl] can be a String or a [Uri]. Loader(String source, {sourceUrl}) - : _parser = new Parser(source, sourceUrl: sourceUrl) { + : _parser = Parser(source, sourceUrl: sourceUrl) { var event = _parser.parse(); _span = event.span; assert(event.type == EventType.STREAM_START); @@ -51,8 +51,8 @@ return null; } - var document = _loadDocument(event); - _span = _span.expand(document.span); + var document = _loadDocument(event as DocumentStartEvent); + _span = _span.expand(document.span as FileSpan); _aliases.clear(); return document; } @@ -64,7 +64,7 @@ var lastEvent = _parser.parse() as DocumentEndEvent; assert(lastEvent.type == EventType.DOCUMENT_END); - return new YamlDocument.internal( + return YamlDocument.internal( contents, firstEvent.span.expand(lastEvent.span), firstEvent.versionDirective, @@ -77,13 +77,13 @@ YamlNode _loadNode(Event firstEvent) { switch (firstEvent.type) { case EventType.ALIAS: - return _loadAlias(firstEvent); + return _loadAlias(firstEvent as AliasEvent); case EventType.SCALAR: - return _loadScalar(firstEvent); + return _loadScalar(firstEvent as ScalarEvent); case EventType.SEQUENCE_START: - return _loadSequence(firstEvent); + return _loadSequence(firstEvent as SequenceStartEvent); case EventType.MAPPING_START: - return _loadMapping(firstEvent); + return _loadMapping(firstEvent as MappingStartEvent); default: throw "Unreachable"; } @@ -105,14 +105,14 @@ var alias = _aliases[event.name]; if (alias != null) return alias; - throw new YamlException("Undefined alias.", event.span); + throw YamlException("Undefined alias.", event.span); } /// Composes a scalar node. YamlNode _loadScalar(ScalarEvent scalar) { - var node; + YamlNode node; if (scalar.tag == "!") { - node = new YamlScalar.internal(scalar.value, scalar); + node = YamlScalar.internal(scalar.value, scalar); } else if (scalar.tag != null) { node = _parseByTag(scalar); } else { @@ -128,12 +128,11 @@ if (firstEvent.tag != "!" && firstEvent.tag != null && firstEvent.tag != "tag:yaml.org,2002:seq") { - throw new YamlException("Invalid tag for sequence.", firstEvent.span); + throw YamlException("Invalid tag for sequence.", firstEvent.span); } var children = <YamlNode>[]; - var node = - new YamlList.internal(children, firstEvent.span, firstEvent.style); + var node = YamlList.internal(children, firstEvent.span, firstEvent.style); _registerAnchor(firstEvent.anchor, node); var event = _parser.parse(); @@ -151,12 +150,11 @@ if (firstEvent.tag != "!" && firstEvent.tag != null && firstEvent.tag != "tag:yaml.org,2002:map") { - throw new YamlException("Invalid tag for mapping.", firstEvent.span); + throw YamlException("Invalid tag for mapping.", firstEvent.span); } var children = deepEqualsMap<dynamic, YamlNode>(); - var node = - new YamlMap.internal(children, firstEvent.span, firstEvent.style); + var node = YamlMap.internal(children, firstEvent.span, firstEvent.style); _registerAnchor(firstEvent.anchor, node); var event = _parser.parse(); @@ -164,7 +162,7 @@ var key = _loadNode(event); var value = _loadNode(_parser.parse()); if (children.containsKey(key)) { - throw new YamlException("Duplicate mapping key.", key.span); + throw YamlException("Duplicate mapping key.", key.span); } children[key] = value; @@ -181,29 +179,29 @@ case "tag:yaml.org,2002:null": var result = _parseNull(scalar); if (result != null) return result; - throw new YamlException("Invalid null scalar.", scalar.span); + throw YamlException("Invalid null scalar.", scalar.span); case "tag:yaml.org,2002:bool": var result = _parseBool(scalar); if (result != null) return result; - throw new YamlException("Invalid bool scalar.", scalar.span); + throw YamlException("Invalid bool scalar.", scalar.span); case "tag:yaml.org,2002:int": var result = _parseNumber(scalar, allowFloat: false); if (result != null) return result; - throw new YamlException("Invalid int scalar.", scalar.span); + throw YamlException("Invalid int scalar.", scalar.span); case "tag:yaml.org,2002:float": var result = _parseNumber(scalar, allowInt: false); if (result != null) return result; - throw new YamlException("Invalid float scalar.", scalar.span); + throw YamlException("Invalid float scalar.", scalar.span); case "tag:yaml.org,2002:str": - return new YamlScalar.internal(scalar.value, scalar); + return YamlScalar.internal(scalar.value, scalar); default: - throw new YamlException('Undefined tag: ${scalar.tag}.', scalar.span); + throw YamlException('Undefined tag: ${scalar.tag}.', scalar.span); } } /// Parses [scalar], which may be one of several types. YamlScalar _parseScalar(ScalarEvent scalar) => - _tryParseScalar(scalar) ?? new YamlScalar.internal(scalar.value, scalar); + _tryParseScalar(scalar) ?? YamlScalar.internal(scalar.value, scalar); /// Tries to parse [scalar]. /// @@ -212,7 +210,7 @@ YamlScalar _tryParseScalar(ScalarEvent scalar) { // Quickly check for the empty string, which means null. var length = scalar.value.length; - if (length == 0) return new YamlScalar.internal(null, scalar); + if (length == 0) return YamlScalar.internal(null, scalar); // Dispatch on the first character. var firstChar = scalar.value.codeUnitAt(0); @@ -231,7 +229,7 @@ case $F: return length == 5 ? _parseBool(scalar) : null; case $tilde: - return length == 1 ? new YamlScalar.internal(null, scalar) : null; + return length == 1 ? YamlScalar.internal(null, scalar) : null; default: if (firstChar >= $0 && firstChar <= $9) return _parseNumber(scalar); return null; @@ -248,7 +246,7 @@ case "Null": case "NULL": case "~": - return new YamlScalar.internal(null, scalar); + return YamlScalar.internal(null, scalar); default: return null; } @@ -262,11 +260,11 @@ case "true": case "True": case "TRUE": - return new YamlScalar.internal(true, scalar); + return YamlScalar.internal(true, scalar); case "false": case "False": case "FALSE": - return new YamlScalar.internal(false, scalar); + return YamlScalar.internal(false, scalar); default: return null; } @@ -275,18 +273,18 @@ /// Parses a numeric scalar. /// /// Returns `null` if parsing fails. - YamlNode _parseNumber(ScalarEvent scalar, - {bool allowInt: true, bool allowFloat: true}) { + YamlScalar _parseNumber(ScalarEvent scalar, + {bool allowInt = true, bool allowFloat = true}) { var value = _parseNumberValue(scalar.value, allowInt: allowInt, allowFloat: allowFloat); - return value == null ? null : new YamlScalar.internal(value, scalar); + return value == null ? null : YamlScalar.internal(value, scalar); } /// Parses the value of a number. /// /// Returns the number if it's parsed successfully, or `null` if it's not. num _parseNumberValue(String contents, - {bool allowInt: true, bool allowFloat: true}) { + {bool allowInt = true, bool allowFloat = true}) { assert(allowInt || allowFloat); var firstChar = contents.codeUnitAt(0); @@ -317,7 +315,7 @@ secondChar >= $0 && secondChar <= $9)) { // Try to parse an int or, failing that, a double. - var result = null; + num result; if (allowInt) { // Pass "radix: 10" explicitly to ensure that "-0x10", which is valid // Dart but invalid YAML, doesn't get parsed.
diff --git a/pkgs/yaml/lib/src/null_span.dart b/pkgs/yaml/lib/src/null_span.dart index eab4ec0..7f0c9d6 100644 --- a/pkgs/yaml/lib/src/null_span.dart +++ b/pkgs/yaml/lib/src/null_span.dart
@@ -14,5 +14,5 @@ SourceLocation get end => start; final text = ""; - NullSpan(sourceUrl) : start = new SourceLocation(0, sourceUrl: sourceUrl); + NullSpan(sourceUrl) : start = SourceLocation(0, sourceUrl: sourceUrl); }
diff --git a/pkgs/yaml/lib/src/parser.dart b/pkgs/yaml/lib/src/parser.dart index 24e9e02..bffaa17 100644 --- a/pkgs/yaml/lib/src/parser.dart +++ b/pkgs/yaml/lib/src/parser.dart
@@ -23,13 +23,13 @@ final Scanner _scanner; /// The stack of parse states for nested contexts. - final _states = new List<_State>(); + final _states = List<_State>(); /// The current parse state. var _state = _State.STREAM_START; /// The custom tag directives, by tag handle. - final _tagDirectives = new Map<String, TagDirective>(); + final _tagDirectives = Map<String, TagDirective>(); /// Whether the parser has finished parsing. bool get isDone => _state == _State.END; @@ -38,16 +38,16 @@ /// /// [sourceUrl] can be a String or a [Uri]. Parser(String source, {sourceUrl}) - : _scanner = new Scanner(source, sourceUrl: sourceUrl); + : _scanner = Scanner(source, sourceUrl: sourceUrl); /// Consumes and returns the next event. Event parse() { try { - if (isDone) throw new StateError("No more events."); + if (isDone) throw StateError("No more events."); var event = _stateMachine(); return event; } on StringScannerException catch (error) { - throw new YamlException(error.message, error.span); + throw YamlException(error.message, error.span); } } @@ -119,7 +119,7 @@ assert(token.type == TokenType.STREAM_START); _state = _State.DOCUMENT_START; - return new Event(EventType.STREAM_START, token.span); + return Event(EventType.STREAM_START, token.span); } /// Parses the productions: @@ -149,13 +149,13 @@ _processDirectives(); _states.add(_State.DOCUMENT_END); _state = _State.BLOCK_NODE; - return new DocumentStartEvent(token.span.start.pointSpan()); + return DocumentStartEvent(token.span.start.pointSpan()); } if (token.type == TokenType.STREAM_END) { _state = _State.END; _scanner.scan(); - return new Event(EventType.STREAM_END, token.span); + return Event(EventType.STREAM_END, token.span); } // Parse an explicit document. @@ -165,13 +165,13 @@ var tagDirectives = pair.last; token = _scanner.peek(); if (token.type != TokenType.DOCUMENT_START) { - throw new YamlException("Expected document start.", token.span); + throw YamlException("Expected document start.", token.span); } _states.add(_State.DOCUMENT_END); _state = _State.DOCUMENT_CONTENT; _scanner.scan(); - return new DocumentStartEvent(start.expand(token.span), + return DocumentStartEvent(start.expand(token.span), versionDirective: versionDirective, tagDirectives: tagDirectives, isImplicit: false); @@ -212,10 +212,9 @@ var token = _scanner.peek(); if (token.type == TokenType.DOCUMENT_END) { _scanner.scan(); - return new DocumentEndEvent(token.span, isImplicit: false); + return DocumentEndEvent(token.span, isImplicit: false); } else { - return new DocumentEndEvent(token.span.start.pointSpan(), - isImplicit: true); + return DocumentEndEvent(token.span.start.pointSpan(), isImplicit: true); } } @@ -246,46 +245,46 @@ /// ****** /// flow_content ::= flow_collection | SCALAR /// ****** - Event _parseNode({bool block: false, bool indentlessSequence: false}) { + Event _parseNode({bool block = false, bool indentlessSequence = false}) { var token = _scanner.peek(); if (token is AliasToken) { _scanner.scan(); _state = _states.removeLast(); - return new AliasEvent(token.span, token.name); + return AliasEvent(token.span, token.name); } - var anchor; - var tagToken; + String anchor; + TagToken tagToken; var span = token.span.start.pointSpan(); - parseAnchor(token) { + Token parseAnchor(AnchorToken token) { anchor = token.name; span = span.expand(token.span); return _scanner.advance(); } - parseTag(token) { + Token parseTag(TagToken token) { tagToken = token; span = span.expand(token.span); return _scanner.advance(); } if (token is AnchorToken) { - token = parseAnchor(token); - if (token is TagToken) token = parseTag(token); + token = parseAnchor(token as AnchorToken); + if (token is TagToken) token = parseTag(token as TagToken); } else if (token is TagToken) { - token = parseTag(token); - if (token is AnchorToken) token = parseAnchor(token); + token = parseTag(token as TagToken); + if (token is AnchorToken) token = parseAnchor(token as AnchorToken); } - var tag; + String tag; if (tagToken != null) { if (tagToken.handle == null) { tag = tagToken.suffix; } else { var tagDirective = _tagDirectives[tagToken.handle]; if (tagDirective == null) { - throw new YamlException("Undefined tag handle.", tagToken.span); + throw YamlException("Undefined tag handle.", tagToken.span); } tag = tagDirective.prefix + tagToken.suffix; @@ -294,8 +293,7 @@ if (indentlessSequence && token.type == TokenType.BLOCK_ENTRY) { _state = _State.INDENTLESS_SEQUENCE_ENTRY; - return new SequenceStartEvent( - span.expand(token.span), CollectionStyle.BLOCK, + return SequenceStartEvent(span.expand(token.span), CollectionStyle.BLOCK, anchor: anchor, tag: tag); } @@ -305,45 +303,40 @@ _state = _states.removeLast(); _scanner.scan(); - return new ScalarEvent(span.expand(token.span), token.value, token.style, + return ScalarEvent(span.expand(token.span), token.value, token.style, anchor: anchor, tag: tag); } if (token.type == TokenType.FLOW_SEQUENCE_START) { _state = _State.FLOW_SEQUENCE_FIRST_ENTRY; - return new SequenceStartEvent( - span.expand(token.span), CollectionStyle.FLOW, + return SequenceStartEvent(span.expand(token.span), CollectionStyle.FLOW, anchor: anchor, tag: tag); } if (token.type == TokenType.FLOW_MAPPING_START) { _state = _State.FLOW_MAPPING_FIRST_KEY; - return new MappingStartEvent( - span.expand(token.span), CollectionStyle.FLOW, + return MappingStartEvent(span.expand(token.span), CollectionStyle.FLOW, anchor: anchor, tag: tag); } if (block && token.type == TokenType.BLOCK_SEQUENCE_START) { _state = _State.BLOCK_SEQUENCE_FIRST_ENTRY; - return new SequenceStartEvent( - span.expand(token.span), CollectionStyle.BLOCK, + return SequenceStartEvent(span.expand(token.span), CollectionStyle.BLOCK, anchor: anchor, tag: tag); } if (block && token.type == TokenType.BLOCK_MAPPING_START) { _state = _State.BLOCK_MAPPING_FIRST_KEY; - return new MappingStartEvent( - span.expand(token.span), CollectionStyle.BLOCK, + return MappingStartEvent(span.expand(token.span), CollectionStyle.BLOCK, anchor: anchor, tag: tag); } if (anchor != null || tag != null) { _state = _states.removeLast(); - return new ScalarEvent(span, '', ScalarStyle.PLAIN, - anchor: anchor, tag: tag); + return ScalarEvent(span, '', ScalarStyle.PLAIN, anchor: anchor, tag: tag); } - throw new YamlException("Expected node content.", span); + throw YamlException("Expected node content.", span); } /// Parses the productions: @@ -370,10 +363,10 @@ if (token.type == TokenType.BLOCK_END) { _scanner.scan(); _state = _states.removeLast(); - return new Event(EventType.SEQUENCE_END, token.span); + return Event(EventType.SEQUENCE_END, token.span); } - throw new YamlException("While parsing a block collection, expected '-'.", + throw YamlException("While parsing a block collection, expected '-'.", token.span.start.pointSpan()); } @@ -386,7 +379,7 @@ if (token.type != TokenType.BLOCK_ENTRY) { _state = _states.removeLast(); - return new Event(EventType.SEQUENCE_END, token.span.start.pointSpan()); + return Event(EventType.SEQUENCE_END, token.span.start.pointSpan()); } var start = token.span.start; @@ -442,10 +435,10 @@ if (token.type == TokenType.BLOCK_END) { _scanner.scan(); _state = _states.removeLast(); - return new Event(EventType.MAPPING_END, token.span); + return Event(EventType.MAPPING_END, token.span); } - throw new YamlException("Expected a key while parsing a block mapping.", + throw YamlException("Expected a key while parsing a block mapping.", token.span.start.pointSpan()); } @@ -493,14 +486,14 @@ /// flow_sequence_entry ::= /// flow_node | KEY flow_node? (VALUE flow_node?)? /// * - Event _parseFlowSequenceEntry({bool first: false}) { + Event _parseFlowSequenceEntry({bool first = false}) { if (first) _scanner.scan(); var token = _scanner.peek(); if (token.type != TokenType.FLOW_SEQUENCE_END) { if (!first) { if (token.type != TokenType.FLOW_ENTRY) { - throw new YamlException( + throw YamlException( "While parsing a flow sequence, expected ',' or ']'.", token.span.start.pointSpan()); } @@ -511,7 +504,7 @@ if (token.type == TokenType.KEY) { _state = _State.FLOW_SEQUENCE_ENTRY_MAPPING_KEY; _scanner.scan(); - return new MappingStartEvent(token.span, CollectionStyle.FLOW); + return MappingStartEvent(token.span, CollectionStyle.FLOW); } else if (token.type != TokenType.FLOW_SEQUENCE_END) { _states.add(_State.FLOW_SEQUENCE_ENTRY); return _parseNode(); @@ -520,7 +513,7 @@ _scanner.scan(); _state = _states.removeLast(); - return new Event(EventType.SEQUENCE_END, token.span); + return Event(EventType.SEQUENCE_END, token.span); } /// Parses the productions: @@ -575,8 +568,7 @@ /// * Event _parseFlowSequenceEntryMappingEnd() { _state = _State.FLOW_SEQUENCE_ENTRY; - return new Event( - EventType.MAPPING_END, _scanner.peek().span.start.pointSpan()); + return Event(EventType.MAPPING_END, _scanner.peek().span.start.pointSpan()); } /// Parses the productions: @@ -592,14 +584,14 @@ /// flow_mapping_entry ::= /// flow_node | KEY flow_node? (VALUE flow_node?)? /// * *** * - Event _parseFlowMappingKey({bool first: false}) { + Event _parseFlowMappingKey({bool first = false}) { if (first) _scanner.scan(); var token = _scanner.peek(); if (token.type != TokenType.FLOW_MAPPING_END) { if (!first) { if (token.type != TokenType.FLOW_ENTRY) { - throw new YamlException( + throw YamlException( "While parsing a flow mapping, expected ',' or '}'.", token.span.start.pointSpan()); } @@ -626,7 +618,7 @@ _scanner.scan(); _state = _states.removeLast(); - return new Event(EventType.MAPPING_END, token.span); + return Event(EventType.MAPPING_END, token.span); } /// Parses the productions: @@ -634,7 +626,7 @@ /// flow_mapping_entry ::= /// flow_node | KEY flow_node? (VALUE flow_node?)? /// * ***** * - Event _parseFlowMappingValue({bool empty: false}) { + Event _parseFlowMappingValue({bool empty = false}) { var token = _scanner.peek(); if (empty) { @@ -657,7 +649,7 @@ /// Generate an empty scalar event. Event _processEmptyScalar(SourceLocation location) => - new ScalarEvent(location.pointSpan(), '', ScalarStyle.PLAIN); + ScalarEvent(location.pointSpan() as FileSpan, '', ScalarStyle.PLAIN); /// Parses directives. Pair<VersionDirective, List<TagDirective>> _processDirectives() { @@ -669,11 +661,11 @@ token.type == TokenType.TAG_DIRECTIVE) { if (token is VersionDirectiveToken) { if (versionDirective != null) { - throw new YamlException("Duplicate %YAML directive.", token.span); + throw YamlException("Duplicate %YAML directive.", token.span); } if (token.major != 1 || token.minor == 0) { - throw new YamlException( + throw YamlException( "Incompatible YAML document. This parser only supports YAML 1.1 " "and 1.2.", token.span); @@ -684,9 +676,9 @@ token.span); } - versionDirective = new VersionDirective(token.major, token.minor); + versionDirective = VersionDirective(token.major, token.minor); } else if (token is TagDirectiveToken) { - var tagDirective = new TagDirective(token.handle, token.prefix); + var tagDirective = TagDirective(token.handle, token.prefix); _appendTagDirective(tagDirective, token.span); tagDirectives.add(tagDirective); } @@ -694,22 +686,21 @@ token = _scanner.advance(); } - _appendTagDirective( - new TagDirective("!", "!"), token.span.start.pointSpan(), + _appendTagDirective(TagDirective("!", "!"), token.span.start.pointSpan(), allowDuplicates: true); - _appendTagDirective(new TagDirective("!!", "tag:yaml.org,2002:"), - token.span.start.pointSpan(), + _appendTagDirective( + TagDirective("!!", "tag:yaml.org,2002:"), token.span.start.pointSpan(), allowDuplicates: true); - return new Pair(versionDirective, tagDirectives); + return Pair(versionDirective, tagDirectives); } /// Adds a tag directive to the directives stack. void _appendTagDirective(TagDirective newDirective, FileSpan span, - {bool allowDuplicates: false}) { + {bool allowDuplicates = false}) { if (_tagDirectives.containsKey(newDirective.handle)) { if (allowDuplicates) return; - throw new YamlException("Duplicate %TAG directive.", span); + throw YamlException("Duplicate %TAG directive.", span); } _tagDirectives[newDirective.handle] = newDirective; @@ -719,86 +710,81 @@ /// The possible states for the parser. class _State { /// Expect [TokenType.STREAM_START]. - static const STREAM_START = const _State("STREAM_START"); + static const STREAM_START = _State("STREAM_START"); /// Expect the beginning of an implicit document. - static const IMPLICIT_DOCUMENT_START = - const _State("IMPLICIT_DOCUMENT_START"); + static const IMPLICIT_DOCUMENT_START = _State("IMPLICIT_DOCUMENT_START"); /// Expect [TokenType.DOCUMENT_START]. - static const DOCUMENT_START = const _State("DOCUMENT_START"); + static const DOCUMENT_START = _State("DOCUMENT_START"); /// Expect the content of a document. - static const DOCUMENT_CONTENT = const _State("DOCUMENT_CONTENT"); + static const DOCUMENT_CONTENT = _State("DOCUMENT_CONTENT"); /// Expect [TokenType.DOCUMENT_END]. - static const DOCUMENT_END = const _State("DOCUMENT_END"); + static const DOCUMENT_END = _State("DOCUMENT_END"); /// Expect a block node. - static const BLOCK_NODE = const _State("BLOCK_NODE"); + static const BLOCK_NODE = _State("BLOCK_NODE"); /// Expect a block node or indentless sequence. static const BLOCK_NODE_OR_INDENTLESS_SEQUENCE = - const _State("BLOCK_NODE_OR_INDENTLESS_SEQUENCE"); + _State("BLOCK_NODE_OR_INDENTLESS_SEQUENCE"); /// Expect a flow node. - static const FLOW_NODE = const _State("FLOW_NODE"); + static const FLOW_NODE = _State("FLOW_NODE"); /// Expect the first entry of a block sequence. static const BLOCK_SEQUENCE_FIRST_ENTRY = - const _State("BLOCK_SEQUENCE_FIRST_ENTRY"); + _State("BLOCK_SEQUENCE_FIRST_ENTRY"); /// Expect an entry of a block sequence. - static const BLOCK_SEQUENCE_ENTRY = const _State("BLOCK_SEQUENCE_ENTRY"); + static const BLOCK_SEQUENCE_ENTRY = _State("BLOCK_SEQUENCE_ENTRY"); /// Expect an entry of an indentless sequence. - static const INDENTLESS_SEQUENCE_ENTRY = - const _State("INDENTLESS_SEQUENCE_ENTRY"); + static const INDENTLESS_SEQUENCE_ENTRY = _State("INDENTLESS_SEQUENCE_ENTRY"); /// Expect the first key of a block mapping. - static const BLOCK_MAPPING_FIRST_KEY = - const _State("BLOCK_MAPPING_FIRST_KEY"); + static const BLOCK_MAPPING_FIRST_KEY = _State("BLOCK_MAPPING_FIRST_KEY"); /// Expect a block mapping key. - static const BLOCK_MAPPING_KEY = const _State("BLOCK_MAPPING_KEY"); + static const BLOCK_MAPPING_KEY = _State("BLOCK_MAPPING_KEY"); /// Expect a block mapping value. - static const BLOCK_MAPPING_VALUE = const _State("BLOCK_MAPPING_VALUE"); + static const BLOCK_MAPPING_VALUE = _State("BLOCK_MAPPING_VALUE"); /// Expect the first entry of a flow sequence. - static const FLOW_SEQUENCE_FIRST_ENTRY = - const _State("FLOW_SEQUENCE_FIRST_ENTRY"); + static const FLOW_SEQUENCE_FIRST_ENTRY = _State("FLOW_SEQUENCE_FIRST_ENTRY"); /// Expect an entry of a flow sequence. - static const FLOW_SEQUENCE_ENTRY = const _State("FLOW_SEQUENCE_ENTRY"); + static const FLOW_SEQUENCE_ENTRY = _State("FLOW_SEQUENCE_ENTRY"); /// Expect a key of an ordered mapping. static const FLOW_SEQUENCE_ENTRY_MAPPING_KEY = - const _State("FLOW_SEQUENCE_ENTRY_MAPPING_KEY"); + _State("FLOW_SEQUENCE_ENTRY_MAPPING_KEY"); /// Expect a value of an ordered mapping. static const FLOW_SEQUENCE_ENTRY_MAPPING_VALUE = - const _State("FLOW_SEQUENCE_ENTRY_MAPPING_VALUE"); + _State("FLOW_SEQUENCE_ENTRY_MAPPING_VALUE"); /// Expect the and of an ordered mapping entry. static const FLOW_SEQUENCE_ENTRY_MAPPING_END = - const _State("FLOW_SEQUENCE_ENTRY_MAPPING_END"); + _State("FLOW_SEQUENCE_ENTRY_MAPPING_END"); /// Expect the first key of a flow mapping. - static const FLOW_MAPPING_FIRST_KEY = const _State("FLOW_MAPPING_FIRST_KEY"); + static const FLOW_MAPPING_FIRST_KEY = _State("FLOW_MAPPING_FIRST_KEY"); /// Expect a key of a flow mapping. - static const FLOW_MAPPING_KEY = const _State("FLOW_MAPPING_KEY"); + static const FLOW_MAPPING_KEY = _State("FLOW_MAPPING_KEY"); /// Expect a value of a flow mapping. - static const FLOW_MAPPING_VALUE = const _State("FLOW_MAPPING_VALUE"); + static const FLOW_MAPPING_VALUE = _State("FLOW_MAPPING_VALUE"); /// Expect an empty value of a flow mapping. - static const FLOW_MAPPING_EMPTY_VALUE = - const _State("FLOW_MAPPING_EMPTY_VALUE"); + static const FLOW_MAPPING_EMPTY_VALUE = _State("FLOW_MAPPING_EMPTY_VALUE"); /// Expect nothing. - static const END = const _State("END"); + static const END = _State("END"); final String name;
diff --git a/pkgs/yaml/lib/src/scanner.dart b/pkgs/yaml/lib/src/scanner.dart index 91556af..637c8dd 100644 --- a/pkgs/yaml/lib/src/scanner.dart +++ b/pkgs/yaml/lib/src/scanner.dart
@@ -3,8 +3,8 @@ // BSD-style license that can be found in the LICENSE file. import 'package:collection/collection.dart'; -import 'package:string_scanner/string_scanner.dart'; import 'package:source_span/source_span.dart'; +import 'package:string_scanner/string_scanner.dart'; import 'style.dart'; import 'token.dart'; @@ -108,7 +108,7 @@ /// These are queued up in advance so that [TokenType.KEY] tokens can be /// inserted once the scanner determines that a series of tokens represents a /// mapping key. - final _tokens = new QueueList<Token>(); + final _tokens = QueueList<Token>(); /// The number of tokens that have been emitted. /// @@ -291,11 +291,11 @@ /// /// [sourceUrl] can be a String or a [Uri]. Scanner(String source, {sourceUrl}) - : _scanner = new SpanScanner.eager(source, sourceUrl: sourceUrl); + : _scanner = SpanScanner.eager(source, sourceUrl: sourceUrl); /// Consumes and returns the next token. Token scan() { - if (_streamEndProduced) throw new StateError("Out of tokens."); + if (_streamEndProduced) throw StateError("Out of tokens."); if (!_tokenAvailable) _fetchMoreTokens(); var token = _tokens.removeFirst(); @@ -488,7 +488,7 @@ if (key.line == _scanner.line) continue; if (key.required) { - throw new YamlException("Expected ':'.", _scanner.emptySpan); + throw YamlException("Expected ':'.", _scanner.emptySpan); } _simpleKeys[i] = null; @@ -511,7 +511,7 @@ // If the current position may start a simple key, save it. _removeSimpleKey(); - _simpleKeys[_simpleKeys.length - 1] = new _SimpleKey( + _simpleKeys[_simpleKeys.length - 1] = _SimpleKey( _tokensParsed + _tokens.length, _scanner.line, _scanner.column, @@ -523,7 +523,7 @@ void _removeSimpleKey() { var key = _simpleKeys.last; if (key != null && key.required) { - throw new YamlException("Could not find expected ':' for simple key.", + throw YamlException("Could not find expected ':' for simple key.", key.location.pointSpan()); } @@ -557,7 +557,7 @@ _indents.add(column); // Create a token and insert it into the queue. - var token = new Token(type, location.pointSpan()); + var token = Token(type, location.pointSpan() as FileSpan); if (tokenNumber == null) { _tokens.add(token); } else { @@ -573,7 +573,7 @@ if (!_inBlockContext) return; while (_indent > column) { - _tokens.add(new Token(TokenType.BLOCK_END, _scanner.emptySpan)); + _tokens.add(Token(TokenType.BLOCK_END, _scanner.emptySpan)); _indents.removeLast(); } } @@ -589,7 +589,7 @@ // Much of libyaml's initialization logic here is done in variable // initializers instead. _streamStartProduced = true; - _tokens.add(new Token(TokenType.STREAM_START, _scanner.emptySpan)); + _tokens.add(Token(TokenType.STREAM_START, _scanner.emptySpan)); } /// Produces a [TokenType.STREAM_END] token. @@ -597,7 +597,7 @@ _resetIndent(); _removeSimpleKey(); _simpleKeyAllowed = false; - _tokens.add(new Token(TokenType.STREAM_END, _scanner.emptySpan)); + _tokens.add(Token(TokenType.STREAM_END, _scanner.emptySpan)); } /// Produces a [TokenType.VERSION_DIRECTIVE] or [TokenType.TAG_DIRECTIVE] @@ -622,7 +622,7 @@ _scanner.readChar(); _scanner.readChar(); - _tokens.add(new Token(type, _scanner.spanFrom(start))); + _tokens.add(Token(type, _scanner.spanFrom(start))); } /// Produces a [TokenType.FLOW_SEQUENCE_START] or @@ -654,7 +654,7 @@ void _fetchBlockEntry() { if (_inBlockContext) { if (!_simpleKeyAllowed) { - throw new YamlException( + throw YamlException( "Block sequence entries are not allowed here.", _scanner.emptySpan); } @@ -675,7 +675,7 @@ void _fetchKey() { if (_inBlockContext) { if (!_simpleKeyAllowed) { - throw new YamlException( + throw YamlException( "Mapping keys are not allowed here.", _scanner.emptySpan); } @@ -695,7 +695,7 @@ // Add a [TokenType.KEY] directive before the first token of the simple // key so the parser knows that it's part of a key/value pair. _tokens.insert(simpleKey.tokenNumber - _tokensParsed, - new Token(TokenType.KEY, simpleKey.location.pointSpan())); + Token(TokenType.KEY, simpleKey.location.pointSpan() as FileSpan)); // In the block context, we may need to add the // [TokenType.BLOCK_MAPPING_START] token. @@ -710,7 +710,7 @@ _simpleKeyAllowed = false; } else if (_inBlockContext) { if (!_simpleKeyAllowed) { - throw new YamlException( + throw YamlException( "Mapping values are not allowed here. Did you miss a colon " "earlier?", _scanner.emptySpan); @@ -737,11 +737,11 @@ void _addCharToken(TokenType type) { var start = _scanner.state; _scanner.readChar(); - _tokens.add(new Token(type, _scanner.spanFrom(start))); + _tokens.add(Token(type, _scanner.spanFrom(start))); } /// Produces a [TokenType.ALIAS] or [TokenType.ANCHOR] token. - void _fetchAnchor({bool anchor: true}) { + void _fetchAnchor({bool anchor = true}) { _saveSimpleKey(); _simpleKeyAllowed = false; _tokens.add(_scanAnchor(anchor: anchor)); @@ -756,7 +756,7 @@ /// Produces a [TokenType.SCALAR] token with style [ScalarStyle.LITERAL] or /// [ScalarStyle.FOLDED]. - void _fetchBlockScalar({bool literal: false}) { + void _fetchBlockScalar({bool literal = false}) { _removeSimpleKey(); _simpleKeyAllowed = true; _tokens.add(_scanBlockScalar(literal: literal)); @@ -764,7 +764,7 @@ /// Produces a [TokenType.SCALAR] token with style [ScalarStyle.SINGLE_QUOTED] /// or [ScalarStyle.DOUBLE_QUOTED]. - void _fetchFlowScalar({bool singleQuote: false}) { + void _fetchFlowScalar({bool singleQuote = false}) { _saveSimpleKey(); _simpleKeyAllowed = false; _tokens.add(_scanFlowScalar(singleQuote: singleQuote)); @@ -828,7 +828,7 @@ // Eat '%'. _scanner.readChar(); - var token; + Token token; var name = _scanDirectiveName(); if (name == "YAML") { token = _scanVersionDirectiveValue(start); @@ -851,7 +851,7 @@ _skipComment(); if (!_isBreakOrEnd) { - throw new YamlException("Expected comment or line break after directive.", + throw YamlException("Expected comment or line break after directive.", _scanner.spanFrom(start)); } @@ -875,9 +875,9 @@ var name = _scanner.substring(start); if (name.isEmpty) { - throw new YamlException("Expected directive name.", _scanner.emptySpan); + throw YamlException("Expected directive name.", _scanner.emptySpan); } else if (!_isBlankOrEnd) { - throw new YamlException( + throw YamlException( "Unexpected character in directive name.", _scanner.emptySpan); } @@ -895,7 +895,7 @@ _scanner.expect('.'); var minor = _scanVersionDirectiveNumber(); - return new VersionDirectiveToken(_scanner.spanFrom(start), major, minor); + return VersionDirectiveToken(_scanner.spanFrom(start), major, minor); } /// Scans the version number of a version directive. @@ -912,7 +912,7 @@ var number = _scanner.substring(start); if (number.isEmpty) { - throw new YamlException("Expected version number.", _scanner.emptySpan); + throw YamlException("Expected version number.", _scanner.emptySpan); } return int.parse(number); @@ -927,21 +927,21 @@ var handle = _scanTagHandle(directive: true); if (!_isBlank) { - throw new YamlException("Expected whitespace.", _scanner.emptySpan); + throw YamlException("Expected whitespace.", _scanner.emptySpan); } _skipBlanks(); var prefix = _scanTagUri(); if (!_isBlankOrEnd) { - throw new YamlException("Expected whitespace.", _scanner.emptySpan); + throw YamlException("Expected whitespace.", _scanner.emptySpan); } - return new TagDirectiveToken(_scanner.spanFrom(start), handle, prefix); + return TagDirectiveToken(_scanner.spanFrom(start), handle, prefix); } /// Scans a [TokenType.ANCHOR] token. - Token _scanAnchor({bool anchor: true}) { + Token _scanAnchor({bool anchor = true}) { var start = _scanner.state; // Eat the indicator character. @@ -966,21 +966,21 @@ next != PERCENT && next != AT && next != GRAVE_ACCENT)) { - throw new YamlException( + throw YamlException( "Expected alphanumeric character.", _scanner.emptySpan); } if (anchor) { - return new AnchorToken(_scanner.spanFrom(start), name); + return AnchorToken(_scanner.spanFrom(start), name); } else { - return new AliasToken(_scanner.spanFrom(start), name); + return AliasToken(_scanner.spanFrom(start), name); } } /// Scans a [TokenType.TAG] token. Token _scanTag() { - var handle; - var suffix; + String handle; + String suffix; var start = _scanner.state; // Check if the tag is in the canonical form. @@ -1018,14 +1018,14 @@ // libyaml insists on whitespace after a tag, but example 7.2 indicates // that it's not required: http://yaml.org/spec/1.2/spec.html#id2786720. - return new TagToken(_scanner.spanFrom(start), handle, suffix); + return TagToken(_scanner.spanFrom(start), handle, suffix); } /// Scans a tag handle. - String _scanTagHandle({bool directive: false}) { + String _scanTagHandle({bool directive = false}) { _scanner.expect('!'); - var buffer = new StringBuffer('!'); + var buffer = StringBuffer('!'); // libyaml only allows word characters in tags, but the spec disagrees: // http://yaml.org/spec/1.2/spec.html#ns-tag-char. @@ -1052,9 +1052,9 @@ /// [head] is the initial portion of the tag that's already been scanned. /// [flowSeparators] indicates whether the tag URI can contain flow /// separators. - String _scanTagUri({String head, bool flowSeparators: true}) { + String _scanTagUri({String head, bool flowSeparators = true}) { var length = head == null ? 0 : head.length; - var buffer = new StringBuffer(); + var buffer = StringBuffer(); // Copy the head if needed. // @@ -1083,7 +1083,7 @@ } /// Scans a block scalar. - Token _scanBlockScalar({bool literal: false}) { + Token _scanBlockScalar({bool literal = false}) { var start = _scanner.state; // Eat the indicator '|' or '>'. @@ -1101,8 +1101,7 @@ if (_isDigit) { // Check that the indentation is greater than 0. if (_scanner.peekChar() == NUMBER_0) { - throw new YamlException( - "0 may not be used as an indentation indicator.", + throw YamlException("0 may not be used as an indentation indicator.", _scanner.spanFrom(start)); } @@ -1111,8 +1110,7 @@ } else if (_isDigit) { // Do the same as above, but in the opposite order. if (_scanner.peekChar() == NUMBER_0) { - throw new YamlException( - "0 may not be used as an indentation indicator.", + throw YamlException("0 may not be used as an indentation indicator.", _scanner.spanFrom(start)); } @@ -1131,7 +1129,7 @@ // Check if we're at the end of the line. if (!_isBreakOrEnd) { - throw new YamlException( + throw YamlException( "Expected comment or line break.", _scanner.emptySpan); } @@ -1152,7 +1150,7 @@ var trailingBreaks = pair.last; // Scan the block scalar contents. - var buffer = new StringBuffer(); + var buffer = StringBuffer(); var leadingBreak = ''; var leadingBlank = false; var trailingBlank = false; @@ -1208,7 +1206,7 @@ if (chomping != _Chomping.STRIP) buffer.write(leadingBreak); if (chomping == _Chomping.KEEP) buffer.write(trailingBreaks); - return new ScalarToken(_scanner.spanFrom(start, end), buffer.toString(), + return ScalarToken(_scanner.spanFrom(start, end), buffer.toString(), literal ? ScalarStyle.LITERAL : ScalarStyle.FOLDED); } @@ -1218,7 +1216,7 @@ /// level and the text of the line breaks. Pair<int, String> _scanBlockScalarBreaks(int indent) { var maxIndent = 0; - var breaks = new StringBuffer(); + var breaks = StringBuffer(); while (true) { while ((indent == 0 || _scanner.column < indent) && @@ -1244,13 +1242,13 @@ // be supported by the spec. } - return new Pair(indent, breaks.toString()); + return Pair(indent, breaks.toString()); } // Scans a quoted scalar. - Token _scanFlowScalar({bool singleQuote: false}) { + Token _scanFlowScalar({bool singleQuote = false}) { var start = _scanner.state; - var buffer = new StringBuffer(); + var buffer = StringBuffer(); // Eat the left quote. _scanner.readChar(); @@ -1263,7 +1261,7 @@ } if (_scanner.isDone) { - throw new YamlException("Unexpected end of file.", _scanner.emptySpan); + throw YamlException("Unexpected end of file.", _scanner.emptySpan); } var leadingBlanks = false; @@ -1289,7 +1287,7 @@ var escapeStart = _scanner.state; // An escape sequence. - var codeLength = null; + int codeLength; switch (_scanner.peekChar(1)) { case NUMBER_0: buffer.writeCharCode(NULL); @@ -1350,7 +1348,7 @@ codeLength = 8; break; default: - throw new YamlException( + throw YamlException( "Unknown escape character.", _scanner.spanFrom(escapeStart)); } @@ -1362,7 +1360,7 @@ for (var i = 0; i < codeLength; i++) { if (!_isHex) { _scanner.readChar(); - throw new YamlException( + throw YamlException( "Expected $codeLength-digit hexidecimal number.", _scanner.spanFrom(escapeStart)); } @@ -1372,7 +1370,7 @@ // Check the value and write the character. if ((value >= 0xD800 && value <= 0xDFFF) || value > 0x10FFFF) { - throw new YamlException("Invalid Unicode character escape code.", + throw YamlException("Invalid Unicode character escape code.", _scanner.spanFrom(escapeStart)); } @@ -1388,9 +1386,9 @@ break; } - var whitespace = new StringBuffer(); + var whitespace = StringBuffer(); var leadingBreak = ''; - var trailingBreaks = new StringBuffer(); + var trailingBreaks = StringBuffer(); while (_isBlank || _isBreak) { if (_isBlank) { // Consume a space or a tab. @@ -1427,7 +1425,7 @@ // Eat the right quote. _scanner.readChar(); - return new ScalarToken(_scanner.spanFrom(start), buffer.toString(), + return ScalarToken(_scanner.spanFrom(start), buffer.toString(), singleQuote ? ScalarStyle.SINGLE_QUOTED : ScalarStyle.DOUBLE_QUOTED); } @@ -1435,10 +1433,10 @@ Token _scanPlainScalar() { var start = _scanner.state; var end = _scanner.state; - var buffer = new StringBuffer(); + var buffer = StringBuffer(); var leadingBreak = ''; var trailingBreaks = ''; - var whitespace = new StringBuffer(); + var whitespace = StringBuffer(); var indent = _indent + 1; while (true) { @@ -1508,7 +1506,7 @@ // Allow a simple key after a plain scalar with leading blanks. if (leadingBreak.isNotEmpty) _simpleKeyAllowed = true; - return new ScalarToken( + return ScalarToken( _scanner.spanFrom(start, end), buffer.toString(), ScalarStyle.PLAIN); } @@ -1527,7 +1525,7 @@ // libyaml supports NEL, PS, and LS characters as line separators, but this // is explicitly forbidden in section 5.4 of the YAML spec. if (char != CR && char != LF) { - throw new YamlException("Expected newline.", _scanner.emptySpan); + throw YamlException("Expected newline.", _scanner.emptySpan); } _scanner.readChar(); @@ -1670,13 +1668,13 @@ /// See http://yaml.org/spec/1.2/spec.html#id2794534. class _Chomping { /// All trailing whitespace is discarded. - static const STRIP = const _Chomping("STRIP"); + static const STRIP = _Chomping("STRIP"); /// A single trailing newline is retained. - static const CLIP = const _Chomping("CLIP"); + static const CLIP = _Chomping("CLIP"); /// All trailing whitespace is preserved. - static const KEEP = const _Chomping("KEEP"); + static const KEEP = _Chomping("KEEP"); final String name;
diff --git a/pkgs/yaml/lib/src/style.dart b/pkgs/yaml/lib/src/style.dart index 30082cf..e945da8 100644 --- a/pkgs/yaml/lib/src/style.dart +++ b/pkgs/yaml/lib/src/style.dart
@@ -7,32 +7,32 @@ /// No source style was specified. /// /// This usually indicates a scalar constructed with [YamlScalar.wrap]. - static const ANY = const ScalarStyle._("ANY"); + static const ANY = ScalarStyle._("ANY"); /// The plain scalar style, unquoted and without a prefix. /// /// See http://yaml.org/spec/1.2/spec.html#style/flow/plain. - static const PLAIN = const ScalarStyle._("PLAIN"); + static const PLAIN = ScalarStyle._("PLAIN"); /// The literal scalar style, with a `|` prefix. /// /// See http://yaml.org/spec/1.2/spec.html#id2795688. - static const LITERAL = const ScalarStyle._("LITERAL"); + static const LITERAL = ScalarStyle._("LITERAL"); /// The folded scalar style, with a `>` prefix. /// /// See http://yaml.org/spec/1.2/spec.html#id2796251. - static const FOLDED = const ScalarStyle._("FOLDED"); + static const FOLDED = ScalarStyle._("FOLDED"); /// The single-quoted scalar style. /// /// See http://yaml.org/spec/1.2/spec.html#style/flow/single-quoted. - static const SINGLE_QUOTED = const ScalarStyle._("SINGLE_QUOTED"); + static const SINGLE_QUOTED = ScalarStyle._("SINGLE_QUOTED"); /// The double-quoted scalar style. /// /// See http://yaml.org/spec/1.2/spec.html#style/flow/double-quoted. - static const DOUBLE_QUOTED = const ScalarStyle._("DOUBLE_QUOTED"); + static const DOUBLE_QUOTED = ScalarStyle._("DOUBLE_QUOTED"); final String name; @@ -50,17 +50,17 @@ /// /// This usually indicates a collection constructed with [YamlList.wrap] or /// [YamlMap.wrap]. - static const ANY = const CollectionStyle._("ANY"); + static const ANY = CollectionStyle._("ANY"); /// The indentation-based block style. /// /// See http://yaml.org/spec/1.2/spec.html#id2797293. - static const BLOCK = const CollectionStyle._("BLOCK"); + static const BLOCK = CollectionStyle._("BLOCK"); /// The delimiter-based block style. /// /// See http://yaml.org/spec/1.2/spec.html#id2790088. - static const FLOW = const CollectionStyle._("FLOW"); + static const FLOW = CollectionStyle._("FLOW"); final String name;
diff --git a/pkgs/yaml/lib/src/token.dart b/pkgs/yaml/lib/src/token.dart index 5f91ce9..62c7c58 100644 --- a/pkgs/yaml/lib/src/token.dart +++ b/pkgs/yaml/lib/src/token.dart
@@ -111,32 +111,32 @@ /// An enum of types of [Token] object. class TokenType { - static const STREAM_START = const TokenType._("STREAM_START"); - static const STREAM_END = const TokenType._("STREAM_END"); + static const STREAM_START = TokenType._("STREAM_START"); + static const STREAM_END = TokenType._("STREAM_END"); - static const VERSION_DIRECTIVE = const TokenType._("VERSION_DIRECTIVE"); - static const TAG_DIRECTIVE = const TokenType._("TAG_DIRECTIVE"); - static const DOCUMENT_START = const TokenType._("DOCUMENT_START"); - static const DOCUMENT_END = const TokenType._("DOCUMENT_END"); + static const VERSION_DIRECTIVE = TokenType._("VERSION_DIRECTIVE"); + static const TAG_DIRECTIVE = TokenType._("TAG_DIRECTIVE"); + static const DOCUMENT_START = TokenType._("DOCUMENT_START"); + static const DOCUMENT_END = TokenType._("DOCUMENT_END"); - static const BLOCK_SEQUENCE_START = const TokenType._("BLOCK_SEQUENCE_START"); - static const BLOCK_MAPPING_START = const TokenType._("BLOCK_MAPPING_START"); - static const BLOCK_END = const TokenType._("BLOCK_END"); + static const BLOCK_SEQUENCE_START = TokenType._("BLOCK_SEQUENCE_START"); + static const BLOCK_MAPPING_START = TokenType._("BLOCK_MAPPING_START"); + static const BLOCK_END = TokenType._("BLOCK_END"); - static const FLOW_SEQUENCE_START = const TokenType._("FLOW_SEQUENCE_START"); - static const FLOW_SEQUENCE_END = const TokenType._("FLOW_SEQUENCE_END"); - static const FLOW_MAPPING_START = const TokenType._("FLOW_MAPPING_START"); - static const FLOW_MAPPING_END = const TokenType._("FLOW_MAPPING_END"); + static const FLOW_SEQUENCE_START = TokenType._("FLOW_SEQUENCE_START"); + static const FLOW_SEQUENCE_END = TokenType._("FLOW_SEQUENCE_END"); + static const FLOW_MAPPING_START = TokenType._("FLOW_MAPPING_START"); + static const FLOW_MAPPING_END = TokenType._("FLOW_MAPPING_END"); - static const BLOCK_ENTRY = const TokenType._("BLOCK_ENTRY"); - static const FLOW_ENTRY = const TokenType._("FLOW_ENTRY"); - static const KEY = const TokenType._("KEY"); - static const VALUE = const TokenType._("VALUE"); + static const BLOCK_ENTRY = TokenType._("BLOCK_ENTRY"); + static const FLOW_ENTRY = TokenType._("FLOW_ENTRY"); + static const KEY = TokenType._("KEY"); + static const VALUE = TokenType._("VALUE"); - static const ALIAS = const TokenType._("ALIAS"); - static const ANCHOR = const TokenType._("ANCHOR"); - static const TAG = const TokenType._("TAG"); - static const SCALAR = const TokenType._("SCALAR"); + static const ALIAS = TokenType._("ALIAS"); + static const ANCHOR = TokenType._("ANCHOR"); + static const TAG = TokenType._("TAG"); + static const SCALAR = TokenType._("SCALAR"); final String name;
diff --git a/pkgs/yaml/lib/src/utils.dart b/pkgs/yaml/lib/src/utils.dart index 36e4e93..93954aa 100644 --- a/pkgs/yaml/lib/src/utils.dart +++ b/pkgs/yaml/lib/src/utils.dart
@@ -25,7 +25,7 @@ /// [message] is the text of the warning. If [span] is passed, it's the portion /// of the document that the warning is associated with and should be included /// in the printed warning. -typedef YamlWarningCallback(String message, [SourceSpan span]); +typedef YamlWarningCallback = Function(String message, [SourceSpan span]); /// A callback for emitting a warning. ///
diff --git a/pkgs/yaml/lib/src/yaml_document.dart b/pkgs/yaml/lib/src/yaml_document.dart index b373223..07806e9 100644 --- a/pkgs/yaml/lib/src/yaml_document.dart +++ b/pkgs/yaml/lib/src/yaml_document.dart
@@ -32,8 +32,8 @@ /// Users of the library should not use this constructor. YamlDocument.internal(this.contents, this.span, this.versionDirective, List<TagDirective> tagDirectives, - {this.startImplicit: false, this.endImplicit: false}) - : tagDirectives = new UnmodifiableListView(tagDirectives); + {this.startImplicit = false, this.endImplicit = false}) + : tagDirectives = UnmodifiableListView(tagDirectives); String toString() => contents.toString(); }
diff --git a/pkgs/yaml/lib/src/yaml_node.dart b/pkgs/yaml/lib/src/yaml_node.dart index 7190c81..3b0a983 100644 --- a/pkgs/yaml/lib/src/yaml_node.dart +++ b/pkgs/yaml/lib/src/yaml_node.dart
@@ -64,7 +64,7 @@ /// is passed, it's used as the [SourceSpan.sourceUrl]. /// /// [sourceUrl] may be either a [String], a [Uri], or `null`. - factory YamlMap({sourceUrl}) => new YamlMapWrapper(const {}, sourceUrl); + factory YamlMap({sourceUrl}) => YamlMapWrapper(const {}, sourceUrl); /// Wraps a Dart map so that it can be accessed (recursively) like a /// [YamlMap]. @@ -76,11 +76,11 @@ /// /// [sourceUrl] may be either a [String], a [Uri], or `null`. factory YamlMap.wrap(Map dartMap, {sourceUrl}) => - new YamlMapWrapper(dartMap, sourceUrl); + YamlMapWrapper(dartMap, sourceUrl); /// Users of the library should not use this constructor. YamlMap.internal(Map<dynamic, YamlNode> nodes, SourceSpan span, this.style) - : nodes = new UnmodifiableMapView<dynamic, YamlNode>(nodes) { + : nodes = UnmodifiableMapView<dynamic, YamlNode>(nodes) { _span = span; } @@ -103,7 +103,7 @@ int get length => nodes.length; set length(int index) { - throw new UnsupportedError("Cannot modify an unmodifiable List"); + throw UnsupportedError("Cannot modify an unmodifiable List"); } /// Creates an empty YamlList. @@ -113,7 +113,7 @@ /// [sourceUrl] is passed, it's used as the [SourceSpan.sourceUrl]. /// /// [sourceUrl] may be either a [String], a [Uri], or `null`. - factory YamlList({sourceUrl}) => new YamlListWrapper(const [], sourceUrl); + factory YamlList({sourceUrl}) => YamlListWrapper(const [], sourceUrl); /// Wraps a Dart list so that it can be accessed (recursively) like a /// [YamlList]. @@ -125,18 +125,18 @@ /// /// [sourceUrl] may be either a [String], a [Uri], or `null`. factory YamlList.wrap(List dartList, {sourceUrl}) => - new YamlListWrapper(dartList, sourceUrl); + YamlListWrapper(dartList, sourceUrl); /// Users of the library should not use this constructor. YamlList.internal(List<YamlNode> nodes, SourceSpan span, this.style) - : nodes = new UnmodifiableListView<YamlNode>(nodes) { + : nodes = UnmodifiableListView<YamlNode>(nodes) { _span = span; } operator [](int index) => nodes[index].value; operator []=(int index, value) { - throw new UnsupportedError("Cannot modify an unmodifiable List"); + throw UnsupportedError("Cannot modify an unmodifiable List"); } } @@ -155,7 +155,7 @@ /// /// [sourceUrl] may be either a [String], a [Uri], or `null`. YamlScalar.wrap(this.value, {sourceUrl}) : style = ScalarStyle.ANY { - _span = new NullSpan(sourceUrl); + _span = NullSpan(sourceUrl); } /// Users of the library should not use this constructor.
diff --git a/pkgs/yaml/lib/src/yaml_node_wrapper.dart b/pkgs/yaml/lib/src/yaml_node_wrapper.dart index bcb0faa..fc987af 100644 --- a/pkgs/yaml/lib/src/yaml_node_wrapper.dart +++ b/pkgs/yaml/lib/src/yaml_node_wrapper.dart
@@ -27,18 +27,17 @@ Iterable get keys => _dartMap.keys; - YamlMapWrapper(Map dartMap, sourceUrl) - : this._(dartMap, new NullSpan(sourceUrl)); + YamlMapWrapper(Map dartMap, sourceUrl) : this._(dartMap, NullSpan(sourceUrl)); YamlMapWrapper._(Map dartMap, SourceSpan span) : _dartMap = dartMap, span = span, - nodes = new _YamlMapNodes(dartMap, span); + nodes = _YamlMapNodes(dartMap, span); operator [](Object key) { var value = _dartMap[key]; - if (value is Map) return new YamlMapWrapper._(value, span); - if (value is List) return new YamlListWrapper._(value, span); + if (value is Map) return YamlMapWrapper._(value, span); + if (value is List) return YamlListWrapper._(value, span); return value; } @@ -57,7 +56,7 @@ final SourceSpan _span; Iterable get keys => - _dartMap.keys.map((key) => new YamlScalar.internalWithSpan(key, _span)); + _dartMap.keys.map((key) => YamlScalar.internalWithSpan(key, _span)); _YamlMapNodes(this._dartMap, this._span); @@ -90,26 +89,26 @@ int get length => _dartList.length; set length(int index) { - throw new UnsupportedError("Cannot modify an unmodifiable List."); + throw UnsupportedError("Cannot modify an unmodifiable List."); } YamlListWrapper(List dartList, sourceUrl) - : this._(dartList, new NullSpan(sourceUrl)); + : this._(dartList, NullSpan(sourceUrl)); YamlListWrapper._(List dartList, SourceSpan span) : _dartList = dartList, span = span, - nodes = new _YamlListNodes(dartList, span); + nodes = _YamlListNodes(dartList, span); operator [](int index) { var value = _dartList[index]; - if (value is Map) return new YamlMapWrapper._(value, span); - if (value is List) return new YamlListWrapper._(value, span); + if (value is Map) return YamlMapWrapper._(value, span); + if (value is List) return YamlListWrapper._(value, span); return value; } operator []=(int index, value) { - throw new UnsupportedError("Cannot modify an unmodifiable List."); + throw UnsupportedError("Cannot modify an unmodifiable List."); } int get hashCode => _dartList.hashCode; @@ -129,7 +128,7 @@ int get length => _dartList.length; set length(int index) { - throw new UnsupportedError("Cannot modify an unmodifiable List."); + throw UnsupportedError("Cannot modify an unmodifiable List."); } _YamlListNodes(this._dartList, this._span); @@ -137,7 +136,7 @@ YamlNode operator [](int index) => _nodeForValue(_dartList[index], _span); operator []=(int index, value) { - throw new UnsupportedError("Cannot modify an unmodifiable List."); + throw UnsupportedError("Cannot modify an unmodifiable List."); } int get hashCode => _dartList.hashCode; @@ -147,7 +146,7 @@ } YamlNode _nodeForValue(value, SourceSpan span) { - if (value is Map) return new YamlMapWrapper._(value, span); - if (value is List) return new YamlListWrapper._(value, span); - return new YamlScalar.internalWithSpan(value, span); + if (value is Map) return YamlMapWrapper._(value, span); + if (value is List) return YamlListWrapper._(value, span); + return YamlScalar.internalWithSpan(value, span); }
diff --git a/pkgs/yaml/lib/yaml.dart b/pkgs/yaml/lib/yaml.dart index 13d6dc2..e2435ad 100644 --- a/pkgs/yaml/lib/yaml.dart +++ b/pkgs/yaml/lib/yaml.dart
@@ -47,18 +47,16 @@ /// normal Dart value this returns a [YamlDocument] instead. This allows the /// caller to access document metadata. YamlDocument loadYamlDocument(String yaml, {sourceUrl}) { - var loader = new Loader(yaml, sourceUrl: sourceUrl); + var loader = Loader(yaml, sourceUrl: sourceUrl); var document = loader.load(); if (document == null) { - return new YamlDocument.internal( - new YamlScalar.internalWithSpan(null, loader.span), - loader.span, - null, const []); + return YamlDocument.internal(YamlScalar.internalWithSpan(null, loader.span), + loader.span, null, const []); } var nextDocument = loader.load(); if (nextDocument != null) { - throw new YamlException("Only expected one document.", nextDocument.span); + throw YamlException("Only expected one document.", nextDocument.span); } return document; @@ -78,7 +76,7 @@ /// If [sourceUrl] is passed, it's used as the URL from which the YAML /// originated for error reporting. It can be a [String], a [Uri], or `null`. YamlList loadYamlStream(String yaml, {sourceUrl}) { - var loader = new Loader(yaml, sourceUrl: sourceUrl); + var loader = Loader(yaml, sourceUrl: sourceUrl); var documents = <YamlDocument>[]; var document = loader.load(); @@ -89,7 +87,7 @@ // TODO(jmesserly): the type on the `document` parameter is a workaround for: // https://github.com/dart-lang/dev_compiler/issues/203 - return new YamlList.internal( + return YamlList.internal( documents.map((YamlDocument document) => document.contents).toList(), loader.span, CollectionStyle.ANY); @@ -100,7 +98,7 @@ /// This is like [loadYamlStream], except that it returns [YamlDocument]s with /// metadata wrapping the document contents. List<YamlDocument> loadYamlDocuments(String yaml, {sourceUrl}) { - var loader = new Loader(yaml, sourceUrl: sourceUrl); + var loader = Loader(yaml, sourceUrl: sourceUrl); var documents = <YamlDocument>[]; var document = loader.load();
diff --git a/pkgs/yaml/pubspec.yaml b/pkgs/yaml/pubspec.yaml index e8782f9..e42ab42 100644 --- a/pkgs/yaml/pubspec.yaml +++ b/pkgs/yaml/pubspec.yaml
@@ -15,5 +15,6 @@ source_span: '>=1.0.0 <2.0.0' dev_dependencies: + pedantic: ^1.0.0 path: '>=1.2.0 <2.0.0' test: '>=0.12.0 <2.0.0'
diff --git a/pkgs/yaml/test/utils.dart b/pkgs/yaml/test/utils.dart index 39fe203..5ecbd14 100644 --- a/pkgs/yaml/test/utils.dart +++ b/pkgs/yaml/test/utils.dart
@@ -7,7 +7,7 @@ import 'package:yaml/yaml.dart'; /// A matcher that validates that a closure or Future throws a [YamlException]. -final Matcher throwsYamlException = throwsA(new TypeMatcher<YamlException>()); +final Matcher throwsYamlException = throwsA(TypeMatcher<YamlException>()); /// Returns a matcher that asserts that the value equals [expected]. ///
diff --git a/pkgs/yaml/test/yaml_node_wrapper_test.dart b/pkgs/yaml/test/yaml_node_wrapper_test.dart index d9b5010..f9b0272 100644 --- a/pkgs/yaml/test/yaml_node_wrapper_test.dart +++ b/pkgs/yaml/test/yaml_node_wrapper_test.dart
@@ -8,31 +8,31 @@ main() { test("YamlMap() with no sourceUrl", () { - var map = new YamlMap(); + var map = YamlMap(); expect(map, isEmpty); expect(map.nodes, isEmpty); expect(map.span, isNullSpan(isNull)); }); test("YamlMap() with a sourceUrl", () { - var map = new YamlMap(sourceUrl: "source"); + var map = YamlMap(sourceUrl: "source"); expect(map.span, isNullSpan(Uri.parse("source"))); }); test("YamlList() with no sourceUrl", () { - var list = new YamlList(); + var list = YamlList(); expect(list, isEmpty); expect(list.nodes, isEmpty); expect(list.span, isNullSpan(isNull)); }); test("YamlList() with a sourceUrl", () { - var list = new YamlList(sourceUrl: "source"); + var list = YamlList(sourceUrl: "source"); expect(list.span, isNullSpan(Uri.parse("source"))); }); test("YamlMap.wrap() with no sourceUrl", () { - var map = new YamlMap.wrap({ + var map = YamlMap.wrap({ "list": [1, 2, 3], "map": { "foo": "bar", @@ -53,24 +53,24 @@ })); expect(map.span, isNullSpan(isNull)); - expect(map["list"], new TypeMatcher<YamlList>()); - expect(map["list"].nodes[0], new TypeMatcher<YamlScalar>()); + expect(map["list"], TypeMatcher<YamlList>()); + expect(map["list"].nodes[0], TypeMatcher<YamlScalar>()); expect(map["list"].span, isNullSpan(isNull)); - expect(map["map"], new TypeMatcher<YamlMap>()); - expect(map["map"].nodes["foo"], new TypeMatcher<YamlScalar>()); - expect(map["map"]["nested"], new TypeMatcher<YamlList>()); + expect(map["map"], TypeMatcher<YamlMap>()); + expect(map["map"].nodes["foo"], TypeMatcher<YamlScalar>()); + expect(map["map"]["nested"], TypeMatcher<YamlList>()); expect(map["map"].span, isNullSpan(isNull)); - expect(map.nodes["scalar"], new TypeMatcher<YamlScalar>()); + expect(map.nodes["scalar"], TypeMatcher<YamlScalar>()); expect(map.nodes["scalar"].value, "value"); expect(map.nodes["scalar"].span, isNullSpan(isNull)); expect(map["scalar"], "value"); expect(map.keys, unorderedEquals(["list", "map", "scalar"])); - expect(map.nodes.keys, everyElement(new TypeMatcher<YamlScalar>())); - expect(map.nodes[new YamlScalar.wrap("list")], equals([1, 2, 3])); + expect(map.nodes.keys, everyElement(TypeMatcher<YamlScalar>())); + expect(map.nodes[YamlScalar.wrap("list")], equals([1, 2, 3])); }); test("YamlMap.wrap() with a sourceUrl", () { - var map = new YamlMap.wrap({ + var map = YamlMap.wrap({ "list": [1, 2, 3], "map": { "foo": "bar", @@ -87,7 +87,7 @@ }); test("YamlList.wrap() with no sourceUrl", () { - var list = new YamlList.wrap([ + var list = YamlList.wrap([ [1, 2, 3], { "foo": "bar", @@ -108,21 +108,21 @@ ])); expect(list.span, isNullSpan(isNull)); - expect(list[0], new TypeMatcher<YamlList>()); - expect(list[0].nodes[0], new TypeMatcher<YamlScalar>()); + expect(list[0], TypeMatcher<YamlList>()); + expect(list[0].nodes[0], TypeMatcher<YamlScalar>()); expect(list[0].span, isNullSpan(isNull)); - expect(list[1], new TypeMatcher<YamlMap>()); - expect(list[1].nodes["foo"], new TypeMatcher<YamlScalar>()); - expect(list[1]["nested"], new TypeMatcher<YamlList>()); + expect(list[1], TypeMatcher<YamlMap>()); + expect(list[1].nodes["foo"], TypeMatcher<YamlScalar>()); + expect(list[1]["nested"], TypeMatcher<YamlList>()); expect(list[1].span, isNullSpan(isNull)); - expect(list.nodes[2], new TypeMatcher<YamlScalar>()); + expect(list.nodes[2], TypeMatcher<YamlScalar>()); expect(list.nodes[2].value, "value"); expect(list.nodes[2].span, isNullSpan(isNull)); expect(list[2], "value"); }); test("YamlList.wrap() with a sourceUrl", () { - var list = new YamlList.wrap([ + var list = YamlList.wrap([ [1, 2, 3], { "foo": "bar", @@ -138,22 +138,22 @@ }); test("re-wrapped objects equal one another", () { - var list = new YamlList.wrap([ + var list = YamlList.wrap([ [1, 2, 3], {"foo": "bar"} ]); expect(list[0] == list[0], isTrue); expect(list[0].nodes == list[0].nodes, isTrue); - expect(list[0] == new YamlList.wrap([1, 2, 3]), isFalse); + expect(list[0] == YamlList.wrap([1, 2, 3]), isFalse); expect(list[1] == list[1], isTrue); expect(list[1].nodes == list[1].nodes, isTrue); - expect(list[1] == new YamlMap.wrap({"foo": "bar"}), isFalse); + expect(list[1] == YamlMap.wrap({"foo": "bar"}), isFalse); }); } Matcher isNullSpan(sourceUrl) => predicate((span) { - expect(span, new TypeMatcher<SourceSpan>()); + expect(span, TypeMatcher<SourceSpan>()); expect(span.length, equals(0)); expect(span.text, isEmpty); expect(span.start, equals(span.end));
diff --git a/pkgs/yaml/test/yaml_test.dart b/pkgs/yaml/test/yaml_test.dart index 727ee8e..27b2025 100644 --- a/pkgs/yaml/test/yaml_test.dart +++ b/pkgs/yaml/test/yaml_test.dart
@@ -476,19 +476,19 @@ // Chapter 5: Characters group('5.1: Character Set', () { expectAllowsCharacter(int charCode) { - var char = new String.fromCharCodes([charCode]); + var char = String.fromCharCodes([charCode]); expectYamlLoads('The character "$char" is allowed', 'The character "$char" is allowed'); } expectAllowsQuotedCharacter(int charCode) { - var char = new String.fromCharCodes([charCode]); + var char = String.fromCharCodes([charCode]); expectYamlLoads("The character '$char' is allowed", '"The character \'$char\' is allowed"'); } expectDisallowsCharacter(int charCode) { - var char = new String.fromCharCodes([charCode]); + var char = String.fromCharCodes([charCode]); expectYamlFails('The character "$char" is disallowed'); } @@ -635,10 +635,10 @@ test('[Example 5.13]', () { expectYamlLoads( "Fun with \x5C " - "\x22 \x07 \x08 \x1B \x0C " - "\x0A \x0D \x09 \x0B \x00 " - "\x20 \xA0 \x85 \u2028 \u2029 " - "A A A", + "\x22 \x07 \x08 \x1B \x0C " + "\x0A \x0D \x09 \x0B \x00 " + "\x20 \xA0 \x85 \u2028 \u2029 " + "A A A", ''' "Fun with \\\\ \\" \\a \\b \\e \\f \\