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

Unified Diff: pkg/analyzer/lib/src/generated/parser.dart

Issue 668083002: Better recovery for getters in functions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 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/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 beeb4a2f42bc4a9d4ce29a3565a367d589e9250e..c776fb38af286d8c475220f4c561de20fb9948d3 100644
--- a/pkg/analyzer/lib/src/generated/parser.dart
+++ b/pkg/analyzer/lib/src/generated/parser.dart
@@ -3190,9 +3190,8 @@ class Parser {
}
/**
- * Return `true` if the current token appears to be the beginning of a function declaration.
- *
- * @return `true` if the current token appears to be the beginning of a function declaration
+ * Return `true` if the current token appears to be the beginning of a
+ * function declaration.
*/
bool _isFunctionDeclaration() {
if (_matchesKeyword(Keyword.VOID)) {
@@ -3200,13 +3199,14 @@ class Parser {
}
Token afterReturnType = _skipTypeName(_currentToken);
if (afterReturnType == null) {
- // There was no return type, but it is optional, so go back to where we started.
+ // There was no return type, but it is optional, so go back to where we
+ // started.
afterReturnType = _currentToken;
}
Token afterIdentifier = _skipSimpleIdentifier(afterReturnType);
if (afterIdentifier == null) {
- // It's possible that we parsed the function name as if it were a type name, so see whether
- // it makes sense if we assume that there is no type.
+ // It's possible that we parsed the function name as if it were a type
+ // name, so see whether it makes sense if we assume that there is no type.
afterIdentifier = _skipSimpleIdentifier(_currentToken);
}
if (afterIdentifier == null) {
@@ -3215,14 +3215,22 @@ class Parser {
if (_isFunctionExpression(afterIdentifier)) {
return true;
}
- // It's possible that we have found a getter. While this isn't valid at this point we test for
- // it in order to recover better.
+ // It's possible that we have found a getter. While this isn't valid at this
+ // point we test for it in order to recover better.
if (_matchesKeyword(Keyword.GET)) {
Token afterName = _skipSimpleIdentifier(_currentToken.next);
if (afterName == null) {
return false;
}
- return _tokenMatches(afterName, TokenType.FUNCTION) || _tokenMatches(afterName, TokenType.OPEN_CURLY_BRACKET);
+ return _tokenMatches(afterName, TokenType.FUNCTION)
+ || _tokenMatches(afterName, TokenType.OPEN_CURLY_BRACKET);
+ } else if (_tokenMatchesKeyword(afterReturnType, Keyword.GET)) {
+ Token afterName = _skipSimpleIdentifier(afterReturnType.next);
+ if (afterName == null) {
+ return false;
+ }
+ return _tokenMatches(afterName, TokenType.FUNCTION)
+ || _tokenMatches(afterName, TokenType.OPEN_CURLY_BRACKET);
}
return false;
}

Powered by Google App Engine
This is Rietveld 408576698