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

Unified Diff: pkg/compiler/lib/src/parser/element_listener.dart

Issue 2759663002: Improve parsing of async and generator methods. (Closed)
Patch Set: Created 3 years, 9 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
Index: pkg/compiler/lib/src/parser/element_listener.dart
diff --git a/pkg/compiler/lib/src/parser/element_listener.dart b/pkg/compiler/lib/src/parser/element_listener.dart
index 55e7e25605c0112dab0d4ad989b8c4ea96e028b5..2fbd225d247e3aaf4d919967bdfb8a3e05ec068e 100644
--- a/pkg/compiler/lib/src/parser/element_listener.dart
+++ b/pkg/compiler/lib/src/parser/element_listener.dart
@@ -741,6 +741,78 @@ class ElementListener extends Listener {
errorCode = MessageKind.GENERIC;
arguments = {"text": "Can't use '${token.lexeme}' as a name here."};
break;
+
+ case ErrorKind.AbstractNotSync:
+ errorCode = MessageKind.GENERIC;
+ arguments = {
+ "text": "Abstract methods can't use 'async', 'async*', or 'sync*'."
+ };
+ break;
+
+ case ErrorKind.SetterNotSync:
+ errorCode = MessageKind.GENERIC;
+ arguments = {
+ "text": "Setters can't use 'async', 'async*', or 'sync*'."
+ };
+ break;
+
+ case ErrorKind.FactoryNotSync:
+ errorCode = MessageKind.GENERIC;
+ arguments = {
+ "text": "Factories can't use 'async', 'async*', or 'sync*'."
+ };
+ break;
+
+ case ErrorKind.AwaitForNotAsync:
+ errorCode = MessageKind.GENERIC;
+ arguments = {
+ "text": "Asynchronous for-loop can only be used "
+ "in 'async' or 'async*' methods."
+ };
+ break;
+
+ case ErrorKind.AsyncAsIdentifier:
+ errorCode = MessageKind.GENERIC;
+ arguments = {
+ "text": "'async' can't be used as an identifier in "
+ "'async', 'async*', or 'sync*' methods."
+ };
+ break;
+
+ case ErrorKind.YieldNotGenerator:
+ errorCode = MessageKind.GENERIC;
+ arguments = {
+ "text": "'yield' can only be used 'sync*' or 'async*' methods."
Johnni Winther 2017/03/17 13:34:10 used 'sync*' -> used in 'sync*'
ahe 2017/03/17 14:00:16 Done.
+ };
+ break;
+
+ case ErrorKind.YieldAsIdentifier:
+ errorCode = MessageKind.GENERIC;
+ arguments = {
+ "text": "'yield' can't be used as an identifier in "
+ "'async', 'async*', or 'sync*' methods."
+ };
+ break;
+
+ case ErrorKind.GeneratorReturnsValue:
+ errorCode = MessageKind.GENERIC;
+ arguments = {"text": "'sync*' and 'async*' can't return a value."};
+ break;
+
+ case ErrorKind.AwaitNotAsync:
+ errorCode = MessageKind.GENERIC;
+ arguments = {
+ "text": "'await' can only be used in 'async' or 'async*' methods."
+ };
+ break;
+
+ case ErrorKind.AwaitAsIdentifier:
+ errorCode = MessageKind.GENERIC;
+ arguments = {
+ "text": "'yield' can't be used as an identifier in "
+ "'async', 'async*', or 'sync*' methods."
Johnni Winther 2017/03/17 13:34:10 'yield' -> 'await'
ahe 2017/03/17 14:00:15 Done.
+ };
+ break;
}
SourceSpan span = reporter.spanFromToken(token);
reportError(span, errorCode, arguments);
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/parser/error_kind.dart » ('j') | tests/language/language_kernel.status » ('J')

Powered by Google App Engine
This is Rietveld 408576698