| OLD | NEW |
| 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 4125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4136 * | 4136 * |
| 4137 * simpleFormalParameter ::= | 4137 * simpleFormalParameter ::= |
| 4138 * declaredIdentifier | 4138 * declaredIdentifier |
| 4139 * | metadata identifier | 4139 * | metadata identifier |
| 4140 */ | 4140 */ |
| 4141 NormalFormalParameter parseNormalFormalParameter( | 4141 NormalFormalParameter parseNormalFormalParameter( |
| 4142 {bool inFunctionType: false}) { | 4142 {bool inFunctionType: false}) { |
| 4143 Token covariantKeyword; | 4143 Token covariantKeyword; |
| 4144 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata(); | 4144 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata(); |
| 4145 if (_matchesKeyword(Keyword.COVARIANT)) { | 4145 if (_matchesKeyword(Keyword.COVARIANT)) { |
| 4146 covariantKeyword = getAndAdvance(); | 4146 // Check to ensure that 'covariant' isn't being used as the parameter name
. |
| 4147 Token next = _peek(); |
| 4148 if (_tokenMatchesKeyword(next, Keyword.FINAL) || |
| 4149 _tokenMatchesKeyword(next, Keyword.CONST) || |
| 4150 _tokenMatchesKeyword(next, Keyword.VAR) || |
| 4151 _tokenMatchesKeyword(next, Keyword.THIS) || |
| 4152 _tokenMatchesIdentifier(next)) { |
| 4153 covariantKeyword = getAndAdvance(); |
| 4154 } |
| 4147 } | 4155 } |
| 4148 FinalConstVarOrType holder = parseFinalConstVarOrType(!inFunctionType, | 4156 FinalConstVarOrType holder = parseFinalConstVarOrType(!inFunctionType, |
| 4149 inFunctionType: inFunctionType); | 4157 inFunctionType: inFunctionType); |
| 4150 Token thisKeyword = null; | 4158 Token thisKeyword = null; |
| 4151 Token period = null; | 4159 Token period = null; |
| 4152 if (_matchesKeyword(Keyword.THIS)) { | 4160 if (_matchesKeyword(Keyword.THIS)) { |
| 4153 thisKeyword = getAndAdvance(); | 4161 thisKeyword = getAndAdvance(); |
| 4154 period = _expect(TokenType.PERIOD); | 4162 period = _expect(TokenType.PERIOD); |
| 4155 } | 4163 } |
| 4156 if (!_matchesIdentifier() && inFunctionType) { | 4164 if (!_matchesIdentifier() && inFunctionType) { |
| (...skipping 4168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8325 * setter, or method. | 8333 * setter, or method. |
| 8326 */ | 8334 */ |
| 8327 void _validateModifiersForGetterOrSetterOrMethod(Modifiers modifiers) { | 8335 void _validateModifiersForGetterOrSetterOrMethod(Modifiers modifiers) { |
| 8328 if (modifiers.abstractKeyword != null) { | 8336 if (modifiers.abstractKeyword != null) { |
| 8329 _reportErrorForCurrentToken(ParserErrorCode.ABSTRACT_CLASS_MEMBER); | 8337 _reportErrorForCurrentToken(ParserErrorCode.ABSTRACT_CLASS_MEMBER); |
| 8330 } | 8338 } |
| 8331 if (modifiers.constKeyword != null) { | 8339 if (modifiers.constKeyword != null) { |
| 8332 _reportErrorForToken( | 8340 _reportErrorForToken( |
| 8333 ParserErrorCode.CONST_METHOD, modifiers.constKeyword); | 8341 ParserErrorCode.CONST_METHOD, modifiers.constKeyword); |
| 8334 } | 8342 } |
| 8343 if (modifiers.covariantKeyword != null) { |
| 8344 _reportErrorForToken( |
| 8345 ParserErrorCode.COVARIANT_MEMBER, modifiers.covariantKeyword); |
| 8346 } |
| 8335 if (modifiers.factoryKeyword != null) { | 8347 if (modifiers.factoryKeyword != null) { |
| 8336 _reportErrorForToken( | 8348 _reportErrorForToken( |
| 8337 ParserErrorCode.NON_CONSTRUCTOR_FACTORY, modifiers.factoryKeyword); | 8349 ParserErrorCode.NON_CONSTRUCTOR_FACTORY, modifiers.factoryKeyword); |
| 8338 } | 8350 } |
| 8339 if (modifiers.finalKeyword != null) { | 8351 if (modifiers.finalKeyword != null) { |
| 8340 _reportErrorForToken( | 8352 _reportErrorForToken( |
| 8341 ParserErrorCode.FINAL_METHOD, modifiers.finalKeyword); | 8353 ParserErrorCode.FINAL_METHOD, modifiers.finalKeyword); |
| 8342 } | 8354 } |
| 8343 if (modifiers.varKeyword != null) { | 8355 if (modifiers.varKeyword != null) { |
| 8344 _reportErrorForToken( | 8356 _reportErrorForToken( |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8493 */ | 8505 */ |
| 8494 Parser_SyntheticKeywordToken(Keyword keyword, int offset) | 8506 Parser_SyntheticKeywordToken(Keyword keyword, int offset) |
| 8495 : super(keyword, offset); | 8507 : super(keyword, offset); |
| 8496 | 8508 |
| 8497 @override | 8509 @override |
| 8498 int get length => 0; | 8510 int get length => 0; |
| 8499 | 8511 |
| 8500 @override | 8512 @override |
| 8501 Token copy() => new Parser_SyntheticKeywordToken(keyword, offset); | 8513 Token copy() => new Parser_SyntheticKeywordToken(keyword, offset); |
| 8502 } | 8514 } |
| OLD | NEW |