Replace more calls to parseTypeVariablesOpt with computeTypeParamOrArg
Change-Id: I03966a8b06516f8cff612ccea25443da682f8da9
Reviewed-on: https://dart-review.googlesource.com/57541
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
diff --git a/pkg/analyzer/lib/src/generated/parser_fasta.dart b/pkg/analyzer/lib/src/generated/parser_fasta.dart
index c0402b1..69905bb 100644
--- a/pkg/analyzer/lib/src/generated/parser_fasta.dart
+++ b/pkg/analyzer/lib/src/generated/parser_fasta.dart
@@ -307,22 +307,38 @@
@override
TypeParameter parseTypeParameter() {
- currentToken = fastaParser
- .parseTypeVariable(fastaParser.syntheticPreviousToken(currentToken))
- .next;
- return astBuilder.pop();
+ currentToken = new SyntheticBeginToken(TokenType.LT, 0)
+ ..endGroup = new SyntheticToken(TokenType.GT, 0)
+ ..setNext(currentToken);
+ appendToken(currentToken, currentToken.endGroup);
+ TypeParameterList typeParams = parseTypeParameterList();
+ return typeParams.typeParameters[0];
}
@override
TypeParameterList parseTypeParameterList() {
- currentToken = fastaParser
- .parseTypeVariablesOpt(fastaParser.syntheticPreviousToken(currentToken))
+ Token token = fastaParser.syntheticPreviousToken(currentToken);
+ currentToken = fasta
+ .computeTypeParamOrArg(token, true)
+ .parseVariables(token, fastaParser)
.next;
return astBuilder.pop();
}
@override
Expression parseUnaryExpression() => parseExpression2();
+
+ /// Append the given token to the end of the token stream,
+ /// and update the token's offset.
+ appendToken(Token token, Token newToken) {
+ while (!token.next.isEof) {
+ token = token.next;
+ }
+ newToken
+ ..offset = token.end
+ ..setNext(token.next);
+ token.setNext(newToken);
+ }
}
/**
diff --git a/pkg/front_end/lib/src/fasta/parser/parser.dart b/pkg/front_end/lib/src/fasta/parser/parser.dart
index 7b623b3..83f8cc8 100644
--- a/pkg/front_end/lib/src/fasta/parser/parser.dart
+++ b/pkg/front_end/lib/src/fasta/parser/parser.dart
@@ -3291,8 +3291,9 @@
Token parseFunctionLiteral(
final Token start, TypeInfo typeInfo, IdentifierContext context) {
Token beforeName = typeInfo.skipType(start);
- assert(beforeName.next.isIdentifier);
- Token formals = parseTypeVariablesOpt(beforeName.next);
+ Token name = beforeName.next;
+ assert(name.isIdentifier);
+ Token formals = computeTypeParamOrArg(name).parseVariables(name, this);
listener.beginNamedFunctionExpression(start.next);
typeInfo.parseType(start, this);
return parseNamedFunctionRest(beforeName, start.next, formals, true);
@@ -4374,7 +4375,7 @@
if (constKeyword == null &&
closeBrace != null &&
identical(closeBrace.next.kind, OPEN_PAREN_TOKEN)) {
- token = parseTypeVariablesOpt(token);
+ token = computeTypeParamOrArg(token).parseVariables(token, this);
return parseLiteralFunctionSuffix(token);
} else {
token = computeTypeParamOrArg(token).parseArguments(token, this);