Fix a check for adjusting parse errors (#582)

This commit is contained in:
Natalie Weizenbaum 2019-02-01 14:55:34 -08:00 committed by GitHub
parent e8ac314f56
commit cd3b82e2be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -2,6 +2,10 @@
* Improve error output, particularly for errors that cover multiple lines.
* Improve source locations for some parse errors. Rather than pointing to the
next token that wasn't what was expected, they point *after* the previous
token. This should generally provide more context for the syntax error.
### Command-Line Interface
* The new error output uses non-ASCII Unicode characters by default. Add a

View File

@ -10,6 +10,7 @@ import 'package:string_scanner/string_scanner.dart';
import '../exception.dart';
import '../logger.dart';
import '../util/character.dart';
import '../utils.dart';
/// The abstract base class for all parsers.
///
@ -627,7 +628,7 @@ abstract class Parser {
return callback();
} on SourceSpanFormatException catch (error) {
var span = error.span as FileSpan;
if (error.message.startsWith("Expected") && span.length == 0) {
if (startsWithIgnoreCase(error.message, "expected") && span.length == 0) {
var startPosition = _firstNewlineBefore(span.start.offset);
if (startPosition != span.start.offset) {
span = span.file.span(startPosition, startPosition);