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

Side by Side Diff: pkg/analyzer/lib/src/generated/parser.dart

Issue 2714843002: Add NormalFormalParameter.covariantKeyword setter and factory parameter. (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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.src.generated.parser; 5 library analyzer.src.generated.parser;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import "dart:math" as math; 8 import "dart:math" as math;
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 4145 matching lines...) Expand 10 before | Expand all | Expand 10 after
4156 } 4156 }
4157 FinalConstVarOrType holder = parseFinalConstVarOrType(!inFunctionType, 4157 FinalConstVarOrType holder = parseFinalConstVarOrType(!inFunctionType,
4158 inFunctionType: inFunctionType); 4158 inFunctionType: inFunctionType);
4159 Token thisKeyword = null; 4159 Token thisKeyword = null;
4160 Token period = null; 4160 Token period = null;
4161 if (_matchesKeyword(Keyword.THIS)) { 4161 if (_matchesKeyword(Keyword.THIS)) {
4162 thisKeyword = getAndAdvance(); 4162 thisKeyword = getAndAdvance();
4163 period = _expect(TokenType.PERIOD); 4163 period = _expect(TokenType.PERIOD);
4164 } 4164 }
4165 if (!_matchesIdentifier() && inFunctionType) { 4165 if (!_matchesIdentifier() && inFunctionType) {
4166 SimpleFormalParameterImpl parameter = astFactory.simpleFormalParameter( 4166 return astFactory.simpleFormalParameter(
4167 commentAndMetadata.comment, 4167 commentAndMetadata.comment,
4168 commentAndMetadata.metadata, 4168 commentAndMetadata.metadata,
4169 covariantKeyword,
4169 holder.keyword, 4170 holder.keyword,
4170 holder.type, 4171 holder.type,
4171 null); 4172 null);
4172 parameter.covariantKeyword = covariantKeyword;
4173 return parameter;
4174 } 4173 }
4175 SimpleIdentifier identifier = parseSimpleIdentifier(); 4174 SimpleIdentifier identifier = parseSimpleIdentifier();
4176 TypeParameterList typeParameters = _parseGenericMethodTypeParameters(); 4175 TypeParameterList typeParameters = _parseGenericMethodTypeParameters();
4177 if (_matches(TokenType.OPEN_PAREN)) { 4176 if (_matches(TokenType.OPEN_PAREN)) {
4178 FormalParameterList parameters = _parseFormalParameterListUnchecked(); 4177 FormalParameterList parameters = _parseFormalParameterListUnchecked();
4179 if (thisKeyword == null) { 4178 if (thisKeyword == null) {
4180 if (holder.keyword != null) { 4179 if (holder.keyword != null) {
4181 _reportErrorForToken( 4180 _reportErrorForToken(
4182 ParserErrorCode.FUNCTION_TYPED_PARAMETER_VAR, holder.keyword); 4181 ParserErrorCode.FUNCTION_TYPED_PARAMETER_VAR, holder.keyword);
4183 } 4182 }
4184 Token question = null; 4183 Token question = null;
4185 if (enableNnbd && _matches(TokenType.QUESTION)) { 4184 if (enableNnbd && _matches(TokenType.QUESTION)) {
4186 question = getAndAdvance(); 4185 question = getAndAdvance();
4187 } 4186 }
4188 FunctionTypedFormalParameterImpl parameter = 4187 return astFactory.functionTypedFormalParameter(
4189 astFactory.functionTypedFormalParameter(
4190 commentAndMetadata.comment,
4191 commentAndMetadata.metadata,
4192 holder.type,
4193 astFactory.simpleIdentifier(identifier.token,
4194 isDeclaration: true),
4195 typeParameters,
4196 parameters,
4197 question: question);
4198 parameter.covariantKeyword = covariantKeyword;
4199 return parameter;
4200 } else {
4201 FieldFormalParameterImpl parameter = astFactory.fieldFormalParameter(
4202 commentAndMetadata.comment, 4188 commentAndMetadata.comment,
4203 commentAndMetadata.metadata, 4189 commentAndMetadata.metadata,
4190 covariantKeyword,
4191 holder.type,
4192 astFactory.simpleIdentifier(identifier.token, isDeclaration: true),
4193 typeParameters,
4194 parameters,
4195 question: question);
4196 } else {
4197 return astFactory.fieldFormalParameter(
4198 commentAndMetadata.comment,
4199 commentAndMetadata.metadata,
4200 covariantKeyword,
4204 holder.keyword, 4201 holder.keyword,
4205 holder.type, 4202 holder.type,
4206 thisKeyword, 4203 thisKeyword,
4207 period, 4204 period,
4208 identifier, 4205 identifier,
4209 typeParameters, 4206 typeParameters,
4210 parameters); 4207 parameters);
4211 parameter.covariantKeyword = covariantKeyword;
4212 return parameter;
4213 } 4208 }
4214 } else if (typeParameters != null) { 4209 } else if (typeParameters != null) {
4215 // TODO(brianwilkerson) Report an error. It looks like a function-typed 4210 // TODO(brianwilkerson) Report an error. It looks like a function-typed
4216 // parameter with no parameter list. 4211 // parameter with no parameter list.
4217 //_reportErrorForToken(ParserErrorCode.MISSING_PARAMETERS, typeParameters. endToken); 4212 //_reportErrorForToken(ParserErrorCode.MISSING_PARAMETERS, typeParameters. endToken);
4218 } 4213 }
4219 TypeAnnotation type = holder.type; 4214 TypeAnnotation type = holder.type;
4220 if (type != null) { 4215 if (type != null) {
4221 if (type is TypeName && 4216 if (type is TypeName &&
4222 _tokenMatchesKeyword(type.name.beginToken, Keyword.VOID)) { 4217 _tokenMatchesKeyword(type.name.beginToken, Keyword.VOID)) {
4223 _reportErrorForToken( 4218 _reportErrorForToken(
4224 ParserErrorCode.VOID_PARAMETER, type.name.beginToken); 4219 ParserErrorCode.VOID_PARAMETER, type.name.beginToken);
4225 } else if (holder.keyword != null && 4220 } else if (holder.keyword != null &&
4226 _tokenMatchesKeyword(holder.keyword, Keyword.VAR)) { 4221 _tokenMatchesKeyword(holder.keyword, Keyword.VAR)) {
4227 _reportErrorForToken(ParserErrorCode.VAR_AND_TYPE, holder.keyword); 4222 _reportErrorForToken(ParserErrorCode.VAR_AND_TYPE, holder.keyword);
4228 } 4223 }
4229 } 4224 }
4230 if (thisKeyword != null) { 4225 if (thisKeyword != null) {
4231 // TODO(brianwilkerson) If there are type parameters but no parameters, 4226 // TODO(brianwilkerson) If there are type parameters but no parameters,
4232 // should we create a synthetic empty parameter list here so we can 4227 // should we create a synthetic empty parameter list here so we can
4233 // capture the type parameters? 4228 // capture the type parameters?
4234 FieldFormalParameterImpl parameter = astFactory.fieldFormalParameter( 4229 return astFactory.fieldFormalParameter(
4235 commentAndMetadata.comment, 4230 commentAndMetadata.comment,
4236 commentAndMetadata.metadata, 4231 commentAndMetadata.metadata,
4232 covariantKeyword,
4237 holder.keyword, 4233 holder.keyword,
4238 type, 4234 type,
4239 thisKeyword, 4235 thisKeyword,
4240 period, 4236 period,
4241 identifier, 4237 identifier,
4242 null, 4238 null,
4243 null); 4239 null);
4244 parameter.covariantKeyword = covariantKeyword;
4245 return parameter;
4246 } 4240 }
4247 SimpleFormalParameterImpl parameter = astFactory.simpleFormalParameter( 4241 return astFactory.simpleFormalParameter(
4248 commentAndMetadata.comment, 4242 commentAndMetadata.comment,
4249 commentAndMetadata.metadata, 4243 commentAndMetadata.metadata,
4244 covariantKeyword,
4250 holder.keyword, 4245 holder.keyword,
4251 type, 4246 type,
4252 astFactory.simpleIdentifier(identifier.token, isDeclaration: true)); 4247 astFactory.simpleIdentifier(identifier.token, isDeclaration: true));
4253 parameter.covariantKeyword = covariantKeyword;
4254 return parameter;
4255 } 4248 }
4256 4249
4257 /** 4250 /**
4258 * Parse an operator declaration. The [commentAndMetadata] is the 4251 * Parse an operator declaration. The [commentAndMetadata] is the
4259 * documentation comment and metadata to be associated with the declaration. 4252 * documentation comment and metadata to be associated with the declaration.
4260 * The [externalKeyword] is the 'external' token. The [returnType] is the 4253 * The [externalKeyword] is the 'external' token. The [returnType] is the
4261 * return type that has already been parsed, or `null` if there was no return 4254 * return type that has already been parsed, or `null` if there was no return
4262 * type. Return the operator declaration that was parsed. 4255 * type. Return the operator declaration that was parsed.
4263 * 4256 *
4264 * operatorDeclaration ::= 4257 * operatorDeclaration ::=
(...skipping 4244 matching lines...) Expand 10 before | Expand all | Expand 10 after
8509 */ 8502 */
8510 Parser_SyntheticKeywordToken(Keyword keyword, int offset) 8503 Parser_SyntheticKeywordToken(Keyword keyword, int offset)
8511 : super(keyword, offset); 8504 : super(keyword, offset);
8512 8505
8513 @override 8506 @override
8514 int get length => 0; 8507 int get length => 0;
8515 8508
8516 @override 8509 @override
8517 Token copy() => new Parser_SyntheticKeywordToken(keyword, offset); 8510 Token copy() => new Parser_SyntheticKeywordToken(keyword, offset);
8518 } 8511 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698