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

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

Issue 2990383002: Emit a hint when using generic method comment syntax (issue 30356) (Closed)
Patch Set: Created 3 years, 4 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 5f67ad19f2399d91387942a51721feb026de126c..cccaba0e9facacbc309d314fcc2146a6adc8fd1f 100644
--- a/pkg/analyzer/lib/src/generated/parser.dart
+++ b/pkg/analyzer/lib/src/generated/parser.dart
@@ -5192,47 +5192,6 @@ class Parser {
}
/**
- * Parse a type which is not `void`.
- *
- * typeNotVoid ::=
- * functionType
- * | typeNotVoidWithoutFunction
- */
- TypeAnnotation parseTypeNotVoid(bool inExpression) {
- TypeAnnotation type = null;
- if (_atGenericFunctionTypeAfterReturnType(_currentToken)) {
- // Generic function type with no return type.
- type = parseGenericFunctionTypeAfterReturnType(null);
- } else if (_currentToken.keyword == Keyword.VOID &&
- _atGenericFunctionTypeAfterReturnType(_currentToken.next)) {
- type = astFactory.typeName(
- astFactory.simpleIdentifier(getAndAdvance()), null);
- } else {
- type = parseTypeName(inExpression);
- }
- while (_atGenericFunctionTypeAfterReturnType(_currentToken)) {
- type = parseGenericFunctionTypeAfterReturnType(type);
- }
- return type;
- }
-
- /**
- * Parse a type which is not a function type.
- *
- * typeWithoutFunction ::=
- * `void`
- * | typeNotVoidWithoutFunction
- */
- TypeAnnotation parseTypeWithoutFunction(bool inExpression) {
- if (_currentToken.keyword == Keyword.VOID) {
- return astFactory.typeName(
- astFactory.simpleIdentifier(getAndAdvance()), null);
- } else {
- return parseTypeName(inExpression);
- }
- }
-
- /**
* Parse a list of type arguments. Return the type argument list that was
* parsed.
*
@@ -5276,6 +5235,31 @@ class Parser {
}
/**
+ * Parse a type which is not `void`.
+ *
+ * typeNotVoid ::=
+ * functionType
+ * | typeNotVoidWithoutFunction
+ */
+ TypeAnnotation parseTypeNotVoid(bool inExpression) {
+ TypeAnnotation type = null;
+ if (_atGenericFunctionTypeAfterReturnType(_currentToken)) {
+ // Generic function type with no return type.
+ type = parseGenericFunctionTypeAfterReturnType(null);
+ } else if (_currentToken.keyword == Keyword.VOID &&
+ _atGenericFunctionTypeAfterReturnType(_currentToken.next)) {
+ type = astFactory.typeName(
+ astFactory.simpleIdentifier(getAndAdvance()), null);
+ } else {
+ type = parseTypeName(inExpression);
+ }
+ while (_atGenericFunctionTypeAfterReturnType(_currentToken)) {
+ type = parseGenericFunctionTypeAfterReturnType(type);
+ }
+ return type;
+ }
+
+ /**
* Parse a type parameter. Return the type parameter that was parsed.
*
* typeParameter ::=
@@ -5319,6 +5303,22 @@ class Parser {
}
/**
+ * Parse a type which is not a function type.
+ *
+ * typeWithoutFunction ::=
+ * `void`
+ * | typeNotVoidWithoutFunction
+ */
+ TypeAnnotation parseTypeWithoutFunction(bool inExpression) {
+ if (_currentToken.keyword == Keyword.VOID) {
+ return astFactory.typeName(
+ astFactory.simpleIdentifier(getAndAdvance()), null);
+ } else {
+ return parseTypeName(inExpression);
+ }
+ }
+
+ /**
* Parse a unary expression. Return the unary expression that was parsed.
*
* unaryExpression ::=
@@ -5690,22 +5690,6 @@ class Parser {
}
/**
- * Parse a typeWithoutFunction, starting at the [startToken], without actually
- * creating a TypeAnnotation or changing the current token. Return the token
- * following the typeWithoutFunction that was parsed, or `null` if the given
- * token is not the first token in a valid typeWithoutFunction.
- *
- * This method must be kept in sync with [parseTypeWithoutFunction].
- */
- Token skipTypeWithoutFunction(Token startToken) {
- if (startToken.keyword == Keyword.VOID) {
- return startToken.next;
- } else {
- return skipTypeName(startToken);
- }
- }
-
- /**
* Parse a list of type arguments, starting at the [startToken], without
* actually creating a type argument list or changing the current token.
* Return the token following the type argument list that was parsed, or
@@ -5805,6 +5789,22 @@ class Parser {
}
/**
+ * Parse a typeWithoutFunction, starting at the [startToken], without actually
+ * creating a TypeAnnotation or changing the current token. Return the token
+ * following the typeWithoutFunction that was parsed, or `null` if the given
+ * token is not the first token in a valid typeWithoutFunction.
+ *
+ * This method must be kept in sync with [parseTypeWithoutFunction].
+ */
+ Token skipTypeWithoutFunction(Token startToken) {
+ if (startToken.keyword == Keyword.VOID) {
+ return startToken.next;
+ } else {
+ return skipTypeName(startToken);
+ }
+ }
+
+ /**
* Advance to the next token in the token stream.
*/
void _advance() {
@@ -6156,6 +6156,7 @@ class Parser {
String comment = t.lexeme.substring(prefixLen, t.lexeme.length - 2);
Token list = _scanGenericMethodComment(comment, t.offset + prefixLen);
if (list != null) {
+ _reportErrorForToken(HintCode.GENERIC_METHOD_COMMENT, t);
// Remove the token from the comment stream.
t.remove();
// Insert the tokens into the stream.
« no previous file with comments | « pkg/analyzer/lib/src/dart/error/hint_codes.dart ('k') | pkg/analyzer/test/generated/compile_time_error_code_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698