Ignore recoverable parser errors in outline_builder to avoid double reporting.

R=danrubel@google.com

Review-Url: https://codereview.chromium.org/2940843003 .
This commit is contained in:
Peter von der Ahé 2017-06-14 19:14:51 +02:00
parent 3fd4b27c9d
commit 246334011a

View file

@ -50,6 +50,12 @@ class OutlineBuilder extends UnhandledListener {
final bool enableNative;
/// When true, recoverable parser errors are silently ignored. This is
/// because they will be reported by the BodyBuilder later. However, typedefs
/// are fully compiled by the outline builder, so parser errors are turned on
/// when parsing typedefs.
bool silenceParserErrors = true;
String nativeMethodName;
OutlineBuilder(SourceLibraryBuilder library)
@ -597,6 +603,7 @@ class OutlineBuilder extends UnhandledListener {
@override
void beginFunctionTypeAlias(Token token) {
library.beginNestedDeclaration(null, hasMembers: false);
silenceParserErrors = false;
}
@override
@ -649,6 +656,7 @@ class OutlineBuilder extends UnhandledListener {
library.addFunctionTypeAlias(
metadata, returnType, name, typeVariables, formals, charOffset);
checkEmpty(typedefKeyword.charOffset);
silenceParserErrors = true;
}
@override
@ -814,6 +822,15 @@ class OutlineBuilder extends UnhandledListener {
push(popList(count) ?? NullValue.Modifiers);
}
@override
void handleRecoverableError(Token token, FastaMessage message) {
if (silenceParserErrors) {
debugEvent("RecoverableError");
} else {
super.handleRecoverableError(token, message);
}
}
@override
Token handleUnrecoverableError(Token token, FastaMessage message) {
if (enableNative && message.code == codeExpectedBlockToSkip) {