Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Unified Diff: pkg/analyzer/lib/src/fasta/ast_builder.dart

Issue 2978993002: translate more fasta error codes to analyzer error codes (Closed)
Patch Set: rebase Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/parser_fasta_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/fasta/ast_builder.dart
diff --git a/pkg/analyzer/lib/src/fasta/ast_builder.dart b/pkg/analyzer/lib/src/fasta/ast_builder.dart
index 0c545cf6d4655928f986757c6d307bf0bbc89015..1c08bf99cdb110e59ba461e898def6c12bf50aed 100644
--- a/pkg/analyzer/lib/src/fasta/ast_builder.dart
+++ b/pkg/analyzer/lib/src/fasta/ast_builder.dart
@@ -1143,7 +1143,7 @@ class AstBuilder extends ScopeListener {
declarations.add(node);
} else {
unhandled(
- "${node.runtimeType}", "compilation unit", node.offset, uri);
+ "${node.runtimeType}", "compilation unit", node?.offset, uri);
}
}
}
@@ -1866,11 +1866,27 @@ class AstBuilder extends ScopeListener {
@override
void addCompileTimeError(Message message, int charOffset) {
Code code = message.code;
+ Map<String, dynamic> arguments = message.arguments;
switch (code.analyzerCode) {
case "EXPECTED_TYPE_NAME":
errorReporter?.reportErrorForOffset(
ParserErrorCode.EXPECTED_TYPE_NAME, charOffset, 1);
return;
+ case "EXPECTED_STRING_LITERAL":
+ errorReporter?.reportErrorForOffset(
+ ParserErrorCode.EXPECTED_STRING_LITERAL, charOffset, 1);
+ return;
+ case "UNEXPECTED_TOKEN":
+ var text = arguments['string'];
+ if (text == null) {
+ Token token = arguments['token'];
+ if (token != null) {
+ text = token.lexeme;
+ }
+ }
+ errorReporter?.reportErrorForOffset(
+ ParserErrorCode.UNEXPECTED_TOKEN, charOffset, 1, [text]);
+ return;
default:
// fall through
}
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/parser_fasta_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698