Add a "missing colon" hint. Closes dart-lang/yaml#11 R=kathyw@google.com Review URL: https://codereview.chromium.org//1176653003.
diff --git a/pkgs/yaml/CHANGELOG.md b/pkgs/yaml/CHANGELOG.md index b864250..5dcd749 100644 --- a/pkgs/yaml/CHANGELOG.md +++ b/pkgs/yaml/CHANGELOG.md
@@ -1,3 +1,8 @@ +## 2.1.3 + +* Add a hint that a colon might be missing when a mapping value is found in the + wrong context. + ## 2.1.2 * Fix a crashing bug when parsing block scalars.
diff --git a/pkgs/yaml/lib/src/scanner.dart b/pkgs/yaml/lib/src/scanner.dart index e1b578e..512d72e 100644 --- a/pkgs/yaml/lib/src/scanner.dart +++ b/pkgs/yaml/lib/src/scanner.dart
@@ -653,7 +653,7 @@ if (_inBlockContext) { if (!_simpleKeyAllowed) { throw new YamlException( - "Block sequence entries are not allowed in this context.", + "Block sequence entries are not allowed here.", _scanner.emptySpan); } @@ -676,7 +676,7 @@ void _fetchKey() { if (_inBlockContext) { if (!_simpleKeyAllowed) { - throw new YamlException("Mapping keys are not allowed in this context.", + throw new YamlException("Mapping keys are not allowed here.", _scanner.emptySpan); } @@ -714,14 +714,15 @@ // A simple key cannot follow another simple key. _simpleKeyAllowed = false; } else if (_inBlockContext) { - // If we're here, we've found the ':' indicator following a complex key. - if (!_simpleKeyAllowed) { throw new YamlException( - "Mapping values are not allowed in this context.", + "Mapping values are not allowed here. Did you miss a colon " + "earlier?", _scanner.emptySpan); } + // If we're here, we've found the ':' indicator following a complex key. + _rollIndent( _scanner.column, TokenType.BLOCK_MAPPING_START,
diff --git a/pkgs/yaml/pubspec.yaml b/pkgs/yaml/pubspec.yaml index e8a62c0..d00d31f 100644 --- a/pkgs/yaml/pubspec.yaml +++ b/pkgs/yaml/pubspec.yaml
@@ -1,5 +1,5 @@ name: yaml -version: 2.1.3-dev +version: 2.1.3 author: "Dart Team <misc@dartlang.org>" homepage: https://github.com/dart-lang/yaml description: A parser for YAML.