| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 fasta.analyzer.ast_builder; | 5 library fasta.analyzer.ast_builder; |
| 6 | 6 |
| 7 import 'package:analyzer/analyzer.dart'; | 7 import 'package:analyzer/analyzer.dart'; |
| 8 import 'package:analyzer/dart/ast/ast_factory.dart' show AstFactory; | 8 import 'package:analyzer/dart/ast/ast_factory.dart' show AstFactory; |
| 9 import 'package:analyzer/dart/ast/standard_ast_factory.dart' as standard; | 9 import 'package:analyzer/dart/ast/standard_ast_factory.dart' as standard; |
| 10 import 'package:analyzer/dart/ast/token.dart' as analyzer show Token; | 10 import 'package:analyzer/dart/ast/token.dart' as analyzer show Token; |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 debugEvent("ValuedFormalParameter"); | 493 debugEvent("ValuedFormalParameter"); |
| 494 Expression value = pop(); | 494 Expression value = pop(); |
| 495 push(new _ParameterDefaultValue(equals, value)); | 495 push(new _ParameterDefaultValue(equals, value)); |
| 496 } | 496 } |
| 497 | 497 |
| 498 void handleFormalParameterWithoutValue(Token token) { | 498 void handleFormalParameterWithoutValue(Token token) { |
| 499 debugEvent("FormalParameterWithoutValue"); | 499 debugEvent("FormalParameterWithoutValue"); |
| 500 push(NullValue.ParameterDefaultValue); | 500 push(NullValue.ParameterDefaultValue); |
| 501 } | 501 } |
| 502 | 502 |
| 503 void endFormalParameter(Token thisKeyword, FormalParameterType kind) { | 503 void endFormalParameter( |
| 504 Token covariantKeyword, Token thisKeyword, FormalParameterType kind) { |
| 504 debugEvent("FormalParameter"); | 505 debugEvent("FormalParameter"); |
| 505 _ParameterDefaultValue defaultValue = pop(); | 506 _ParameterDefaultValue defaultValue = pop(); |
| 506 SimpleIdentifier name = pop(); | 507 SimpleIdentifier name = pop(); |
| 507 TypeName type = pop(); | 508 TypeName type = pop(); |
| 508 Token keyword = _popOptionalSingleModifier(); | 509 Token keyword = _popOptionalSingleModifier(); |
| 509 pop(); // TODO(paulberry): Metadata. | 510 pop(); // TODO(paulberry): Metadata. |
| 510 // TODO(paulberry): handle covariant keyword. | |
| 511 | 511 |
| 512 FormalParameter node; | 512 FormalParameter node; |
| 513 if (thisKeyword == null) { | 513 if (thisKeyword == null) { |
| 514 node = ast.simpleFormalParameter( | 514 node = ast.simpleFormalParameter2( |
| 515 null, null, toAnalyzerToken(keyword), type, name); | 515 covariantKeyword: toAnalyzerToken(covariantKeyword), |
| 516 keyword: toAnalyzerToken(keyword), |
| 517 type: type, |
| 518 identifier: name); |
| 516 } else { | 519 } else { |
| 517 // TODO(scheglov): Ideally the period token should be passed in. | 520 // TODO(scheglov): Ideally the period token should be passed in. |
| 518 Token period = identical('.', thisKeyword.next?.stringValue) | 521 Token period = identical('.', thisKeyword.next?.stringValue) |
| 519 ? thisKeyword.next | 522 ? thisKeyword.next |
| 520 : null; | 523 : null; |
| 521 TypeParameterList typeParameters; // TODO(scheglov) | 524 TypeParameterList typeParameters; // TODO(scheglov) |
| 522 FormalParameterList formalParameters; // TODO(scheglov) | 525 FormalParameterList formalParameters; // TODO(scheglov) |
| 523 node = ast.fieldFormalParameter( | 526 node = ast.fieldFormalParameter2( |
| 524 null, | 527 covariantKeyword: toAnalyzerToken(covariantKeyword), |
| 525 null, | 528 keyword: toAnalyzerToken(keyword), |
| 526 toAnalyzerToken(keyword), | 529 type: type, |
| 527 type, | 530 thisKeyword: toAnalyzerToken(thisKeyword), |
| 528 toAnalyzerToken(thisKeyword), | 531 period: toAnalyzerToken(period), |
| 529 toAnalyzerToken(period), | 532 identifier: name, |
| 530 name, | 533 typeParameters: typeParameters, |
| 531 typeParameters, | 534 parameters: formalParameters); |
| 532 formalParameters); | |
| 533 } | 535 } |
| 534 | 536 |
| 535 if (defaultValue != null) { | 537 if (defaultValue != null) { |
| 536 node = ast.defaultFormalParameter(node, _toAnalyzerParameterKind(kind), | 538 node = ast.defaultFormalParameter(node, _toAnalyzerParameterKind(kind), |
| 537 toAnalyzerToken(defaultValue.separator), defaultValue.value); | 539 toAnalyzerToken(defaultValue.separator), defaultValue.value); |
| 538 } | 540 } |
| 539 | 541 |
| 540 scope[name.name] = name.staticElement = new AnalyzerParameterElement(node); | 542 scope[name.name] = name.staticElement = new AnalyzerParameterElement(node); |
| 541 push(node); | 543 push(node); |
| 542 } | 544 } |
| (...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1259 } | 1261 } |
| 1260 | 1262 |
| 1261 /// Data structure placed on the stack to represent the default parameter | 1263 /// Data structure placed on the stack to represent the default parameter |
| 1262 /// value with the separator token. | 1264 /// value with the separator token. |
| 1263 class _ParameterDefaultValue { | 1265 class _ParameterDefaultValue { |
| 1264 final Token separator; | 1266 final Token separator; |
| 1265 final Expression value; | 1267 final Expression value; |
| 1266 | 1268 |
| 1267 _ParameterDefaultValue(this.separator, this.value); | 1269 _ParameterDefaultValue(this.separator, this.value); |
| 1268 } | 1270 } |
| OLD | NEW |