Index: pkg/analyzer/lib/src/generated/parser.dart |
diff --git a/pkg/analyzer/lib/src/generated/parser.dart b/pkg/analyzer/lib/src/generated/parser.dart |
index 33510ed07a8247196bc173ce794b9e16c4339dea..de0306f68f7c9a3cc8eca99b9598f94f1bbd2b18 100644 |
--- a/pkg/analyzer/lib/src/generated/parser.dart |
+++ b/pkg/analyzer/lib/src/generated/parser.dart |
@@ -2108,6 +2108,11 @@ class Parser { |
int _errorListenerLock = 0; |
/** |
+ * A flag indicating whether the parser is to parse the async support. |
+ */ |
+ bool _parseAsync = true; |
+ |
+ /** |
* A flag indicating whether parser is to parse function bodies. |
*/ |
bool _parseFunctionBodies = true; |
@@ -2188,6 +2193,13 @@ class Parser { |
} |
/** |
+ * Set whether the parser is to parse the async support. |
+ */ |
+ void set parseAsync(bool parseAsync) { |
+ this._parseAsync = parseAsync; |
+ } |
+ |
+ /** |
* Set whether parser is to parse function bodies. |
*/ |
void set parseFunctionBodies(bool parseFunctionBodies) { |
@@ -6087,6 +6099,9 @@ class Parser { |
Token star = null; |
if (_matchesString(ASYNC)) { |
keyword = getAndAdvance(); |
+ if (!_parseAsync) { |
+ _reportErrorForToken(ParserErrorCode.ASYNC_NOT_SUPPORTED, keyword); |
+ } |
if (_matches(TokenType.STAR)) { |
star = getAndAdvance(); |
_inGenerator = true; |
@@ -6094,6 +6109,9 @@ class Parser { |
_inAsync = true; |
} else if (_matchesString(SYNC)) { |
keyword = getAndAdvance(); |
+ if (!_parseAsync) { |
+ _reportErrorForToken(ParserErrorCode.ASYNC_NOT_SUPPORTED, keyword); |
+ } |
if (_matches(TokenType.STAR)) { |
star = getAndAdvance(); |
_inGenerator = true; |
@@ -9360,6 +9378,13 @@ class ParserErrorCode extends ErrorCode { |
const ParserErrorCode('ASYNC_KEYWORD_USED_AS_IDENTIFIER', |
"The keywords 'async', 'await', and 'yield' may not be used as identifiers in an asynchronous or generator function."); |
+ /** |
+ * Some environments, such as Fletch, do not support async. |
+ */ |
+ static const CompileTimeErrorCode ASYNC_NOT_SUPPORTED = |
+ const CompileTimeErrorCode('ASYNC_NOT_SUPPORTED', |
+ "Async and sync are not supported in this environment."); |
+ |
static const ParserErrorCode BREAK_OUTSIDE_OF_LOOP = const ParserErrorCode( |
'BREAK_OUTSIDE_OF_LOOP', |
"A break statement cannot be used outside of a loop or switch statement"); |