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 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
524 push(variable); | 524 push(variable); |
525 scope[variable.name.name] = variable.name.staticElement = | 525 scope[variable.name.name] = variable.name.staticElement = |
526 new AnalyzerLocalVariableElemment(variable); | 526 new AnalyzerLocalVariableElemment(variable); |
527 } | 527 } |
528 | 528 |
529 void endVariablesDeclaration(int count, Token endToken) { | 529 void endVariablesDeclaration(int count, Token endToken) { |
530 debugEvent("VariablesDeclaration"); | 530 debugEvent("VariablesDeclaration"); |
531 List<VariableDeclaration> variables = popList(count); | 531 List<VariableDeclaration> variables = popList(count); |
532 TypeAnnotation type = pop(); | 532 TypeAnnotation type = pop(); |
533 pop(); // TODO(paulberry): Modifiers. | 533 pop(); // TODO(paulberry): Modifiers. |
534 pop(); // Metadata. | |
535 pop(); // Comment. | |
534 push(ast.variableDeclarationStatement( | 536 push(ast.variableDeclarationStatement( |
535 ast.variableDeclarationList(null, null, null, type, variables), | 537 ast.variableDeclarationList(null, null, null, type, variables), |
536 toAnalyzerToken(endToken))); | 538 toAnalyzerToken(endToken))); |
537 } | 539 } |
538 | 540 |
539 void handleAssignmentExpression(Token token) { | 541 void handleAssignmentExpression(Token token) { |
540 debugEvent("AssignmentExpression"); | 542 debugEvent("AssignmentExpression"); |
541 Expression rhs = pop(); | 543 Expression rhs = pop(); |
542 Expression lhs = pop(); | 544 Expression lhs = pop(); |
543 push(ast.assignmentExpression(lhs, toAnalyzerToken(token), rhs)); | 545 push(ast.assignmentExpression(lhs, toAnalyzerToken(token), rhs)); |
(...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1843 | 1845 |
1844 // This is temporary placeholder code to get tests to pass. | 1846 // This is temporary placeholder code to get tests to pass. |
1845 // TODO(paulberry): after analyzer and fasta token representations are | 1847 // TODO(paulberry): after analyzer and fasta token representations are |
1846 // unified, refactor the code in analyzer's parser that handles | 1848 // unified, refactor the code in analyzer's parser that handles |
1847 // documentation comments so that it is reusable, and reuse it here. | 1849 // documentation comments so that it is reusable, and reuse it here. |
1848 // See Parser.parseCommentAndMetadata | 1850 // See Parser.parseCommentAndMetadata |
1849 var tokens = <analyzer.Token>[toAnalyzerCommentToken(comments)]; | 1851 var tokens = <analyzer.Token>[toAnalyzerCommentToken(comments)]; |
1850 var references = <CommentReference>[]; | 1852 var references = <CommentReference>[]; |
1851 return ast.documentationComment(tokens, references); | 1853 return ast.documentationComment(tokens, references); |
1852 } | 1854 } |
1855 | |
1856 @override | |
1857 void debugEvent(String name) { | |
1858 // printEvent(name); | |
1859 } | |
scheglov
2017/04/04 15:57:30
Do we need this?
Did you forget to remove this aft
ahe
2017/04/05 14:18:03
It's not needed, but keeping the method here makes
| |
1853 } | 1860 } |
1854 | 1861 |
1855 /// Data structure placed on the stack to represent a class body. | 1862 /// Data structure placed on the stack to represent a class body. |
1856 /// | 1863 /// |
1857 /// This is needed because analyzer has no separate AST representation of a | 1864 /// This is needed because analyzer has no separate AST representation of a |
1858 /// class body; it simply stores all of the relevant data in the | 1865 /// class body; it simply stores all of the relevant data in the |
1859 /// [ClassDeclaration] object. | 1866 /// [ClassDeclaration] object. |
1860 class _ClassBody { | 1867 class _ClassBody { |
1861 final Token beginToken; | 1868 final Token beginToken; |
1862 | 1869 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1947 } else if (identical('static', s)) { | 1954 } else if (identical('static', s)) { |
1948 staticKeyword = token; | 1955 staticKeyword = token; |
1949 } else if (identical('var', s)) { | 1956 } else if (identical('var', s)) { |
1950 finalConstOrVarKeyword = token; | 1957 finalConstOrVarKeyword = token; |
1951 } else { | 1958 } else { |
1952 internalError('Unhandled modifier: $s'); | 1959 internalError('Unhandled modifier: $s'); |
1953 } | 1960 } |
1954 } | 1961 } |
1955 } | 1962 } |
1956 } | 1963 } |
OLD | NEW |