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

Side by Side Diff: pkg/analyzer/lib/src/fasta/ast_builder.dart

Issue 2802753002: Include ':' before constructor separators into AST with Fasta. (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/parser_fasta_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 toAnalyzerToken(elseToken), 399 toAnalyzerToken(elseToken),
400 elsePart)); 400 elsePart));
401 } 401 }
402 402
403 void prepareInitializers() { 403 void prepareInitializers() {
404 debugEvent("prepareInitializers"); 404 debugEvent("prepareInitializers");
405 } 405 }
406 406
407 void handleNoInitializers() { 407 void handleNoInitializers() {
408 debugEvent("NoInitializers"); 408 debugEvent("NoInitializers");
409 push(NullValue.ConstructorInitializerSeparator);
409 push(NullValue.ConstructorInitializers); 410 push(NullValue.ConstructorInitializers);
410 } 411 }
411 412
412 void endInitializers(int count, Token beginToken, Token endToken) { 413 void endInitializers(int count, Token beginToken, Token endToken) {
413 debugEvent("Initializers"); 414 debugEvent("Initializers");
414 List<Object> initializerObjects = popList(count) ?? const []; 415 List<Object> initializerObjects = popList(count) ?? const [];
415 416
417 push(beginToken);
418
416 var initializers = <ConstructorInitializer>[]; 419 var initializers = <ConstructorInitializer>[];
417 for (Object initializerObject in initializerObjects) { 420 for (Object initializerObject in initializerObjects) {
418 if (initializerObject is FunctionExpressionInvocation) { 421 if (initializerObject is FunctionExpressionInvocation) {
419 Expression function = initializerObject.function; 422 Expression function = initializerObject.function;
420 if (function is SuperExpression) { 423 if (function is SuperExpression) {
421 initializers.add(ast.superConstructorInvocation(function.superKeyword, 424 initializers.add(ast.superConstructorInvocation(function.superKeyword,
422 null, null, initializerObject.argumentList)); 425 null, null, initializerObject.argumentList));
423 } else { 426 } else {
424 initializers.add(ast.redirectingConstructorInvocation( 427 initializers.add(ast.redirectingConstructorInvocation(
425 (function as ThisExpression).thisKeyword, 428 (function as ThisExpression).thisKeyword,
(...skipping 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1560 SimpleIdentifier name = pop(); 1563 SimpleIdentifier name = pop();
1561 push(ast.variableDeclaration( 1564 push(ast.variableDeclaration(
1562 name, toAnalyzerToken(assignment), initializer)); 1565 name, toAnalyzerToken(assignment), initializer));
1563 } 1566 }
1564 1567
1565 @override 1568 @override
1566 void endFunction(Token getOrSet, Token endToken) { 1569 void endFunction(Token getOrSet, Token endToken) {
1567 debugEvent("Function"); 1570 debugEvent("Function");
1568 FunctionBody body = pop(); 1571 FunctionBody body = pop();
1569 pop(); // constructor initializers 1572 pop(); // constructor initializers
1573 pop(); // ":" before constructor initializers
1570 FormalParameterList parameters = pop(); 1574 FormalParameterList parameters = pop();
1571 TypeParameterList typeParameters = pop(); 1575 TypeParameterList typeParameters = pop();
1572 // TODO(scheglov) It is an error if "getOrSet" is not null. 1576 // TODO(scheglov) It is an error if "getOrSet" is not null.
1573 push(ast.functionExpression(typeParameters, parameters, body)); 1577 push(ast.functionExpression(typeParameters, parameters, body));
1574 } 1578 }
1575 1579
1576 @override 1580 @override
1577 void endFunctionDeclaration(Token token) { 1581 void endFunctionDeclaration(Token token) {
1578 debugEvent("FunctionDeclaration"); 1582 debugEvent("FunctionDeclaration");
1579 FunctionExpression functionExpression = pop(); 1583 FunctionExpression functionExpression = pop();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1625 push(ast.typeParameterList(toAnalyzerToken(beginToken), typeParameters, 1629 push(ast.typeParameterList(toAnalyzerToken(beginToken), typeParameters,
1626 toAnalyzerToken(endToken))); 1630 toAnalyzerToken(endToken)));
1627 } 1631 }
1628 1632
1629 @override 1633 @override
1630 void endMethod(Token getOrSet, Token beginToken, Token endToken) { 1634 void endMethod(Token getOrSet, Token beginToken, Token endToken) {
1631 debugEvent("Method"); 1635 debugEvent("Method");
1632 FunctionBody body = pop(); 1636 FunctionBody body = pop();
1633 ConstructorName redirectedConstructor = null; // TODO(paulberry) 1637 ConstructorName redirectedConstructor = null; // TODO(paulberry)
1634 List<ConstructorInitializer> initializers = pop() ?? const []; 1638 List<ConstructorInitializer> initializers = pop() ?? const [];
1635 Token separator = null; // TODO(paulberry) 1639 Token separator = pop();
1636 FormalParameterList parameters = pop(); 1640 FormalParameterList parameters = pop();
1637 TypeParameterList typeParameters = pop(); // TODO(paulberry) 1641 TypeParameterList typeParameters = pop();
1638 var name = pop(); 1642 var name = pop();
1639 TypeAnnotation returnType = pop(); // TODO(paulberry) 1643 TypeAnnotation returnType = pop();
1640 _Modifiers modifiers = pop(); 1644 _Modifiers modifiers = pop();
1641 List<Annotation> metadata = pop(); 1645 List<Annotation> metadata = pop();
1642 Comment comment = pop(); 1646 Comment comment = pop();
1643 1647
1644 void constructor(SimpleIdentifier returnType, analyzer.Token period, 1648 void constructor(SimpleIdentifier returnType, analyzer.Token period,
1645 SimpleIdentifier name) { 1649 SimpleIdentifier name) {
1646 push(ast.constructorDeclaration( 1650 push(ast.constructorDeclaration(
1647 comment, 1651 comment,
1648 metadata, 1652 metadata,
1649 toAnalyzerToken(modifiers?.externalKeyword), 1653 toAnalyzerToken(modifiers?.externalKeyword),
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1949 } else if (identical('static', s)) { 1953 } else if (identical('static', s)) {
1950 staticKeyword = token; 1954 staticKeyword = token;
1951 } else if (identical('var', s)) { 1955 } else if (identical('var', s)) {
1952 finalConstOrVarKeyword = token; 1956 finalConstOrVarKeyword = token;
1953 } else { 1957 } else {
1954 internalError('Unhandled modifier: $s'); 1958 internalError('Unhandled modifier: $s');
1955 } 1959 }
1956 } 1960 }
1957 } 1961 }
1958 } 1962 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/parser_fasta_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698