| 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 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1047 name, | 1047 name, |
| 1048 ast.functionExpression(typeParameters, parameters, body))); | 1048 ast.functionExpression(typeParameters, parameters, body))); |
| 1049 } | 1049 } |
| 1050 | 1050 |
| 1051 @override | 1051 @override |
| 1052 void endTopLevelDeclaration(Token token) { | 1052 void endTopLevelDeclaration(Token token) { |
| 1053 debugEvent("TopLevelDeclaration"); | 1053 debugEvent("TopLevelDeclaration"); |
| 1054 } | 1054 } |
| 1055 | 1055 |
| 1056 @override | 1056 @override |
| 1057 void endCompilationUnit(int count, Token token) { | 1057 void beginCompilationUnit(Token token) { |
| 1058 push(token); |
| 1059 } |
| 1060 |
| 1061 @override |
| 1062 void endCompilationUnit(int count, Token endToken) { |
| 1058 debugEvent("CompilationUnit"); | 1063 debugEvent("CompilationUnit"); |
| 1059 analyzer.Token beginToken = null; // TODO(paulberry) | 1064 List<Object> elements = popList(count); |
| 1065 Token beginToken = pop(); |
| 1066 |
| 1060 ScriptTag scriptTag = null; | 1067 ScriptTag scriptTag = null; |
| 1061 var directives = <Directive>[]; | 1068 var directives = <Directive>[]; |
| 1062 var declarations = <CompilationUnitMember>[]; | 1069 var declarations = <CompilationUnitMember>[]; |
| 1063 analyzer.Token endToken = null; // TODO(paulberry) | |
| 1064 List<Object> elements = popList(count); | |
| 1065 if (elements != null) { | 1070 if (elements != null) { |
| 1066 for (AstNode node in elements) { | 1071 for (AstNode node in elements) { |
| 1067 if (node is ScriptTag) { | 1072 if (node is ScriptTag) { |
| 1068 scriptTag = node; | 1073 scriptTag = node; |
| 1069 } else if (node is Directive) { | 1074 } else if (node is Directive) { |
| 1070 directives.add(node); | 1075 directives.add(node); |
| 1071 } else if (node is CompilationUnitMember) { | 1076 } else if (node is CompilationUnitMember) { |
| 1072 declarations.add(node); | 1077 declarations.add(node); |
| 1073 } else { | 1078 } else { |
| 1074 internalError( | 1079 internalError( |
| 1075 'Unrecognized compilation unit member: ${node.runtimeType}'); | 1080 'Unrecognized compilation unit member: ${node.runtimeType}'); |
| 1076 } | 1081 } |
| 1077 } | 1082 } |
| 1078 } | 1083 } |
| 1084 |
| 1079 push(ast.compilationUnit( | 1085 push(ast.compilationUnit( |
| 1080 beginToken, scriptTag, directives, declarations, endToken)); | 1086 beginToken, scriptTag, directives, declarations, endToken)); |
| 1081 } | 1087 } |
| 1082 | 1088 |
| 1083 void endImport(Token importKeyword, Token deferredKeyword, Token asKeyword, | 1089 void endImport(Token importKeyword, Token deferredKeyword, Token asKeyword, |
| 1084 Token semicolon) { | 1090 Token semicolon) { |
| 1085 debugEvent("Import"); | 1091 debugEvent("Import"); |
| 1086 List<Combinator> combinators = pop(); | 1092 List<Combinator> combinators = pop(); |
| 1087 SimpleIdentifier prefix; | 1093 SimpleIdentifier prefix; |
| 1088 if (asKeyword != null) prefix = pop(); | 1094 if (asKeyword != null) prefix = pop(); |
| (...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1864 } else if (identical('static', s)) { | 1870 } else if (identical('static', s)) { |
| 1865 staticKeyword = token; | 1871 staticKeyword = token; |
| 1866 } else if (identical('var', s)) { | 1872 } else if (identical('var', s)) { |
| 1867 finalConstOrVarKeyword = token; | 1873 finalConstOrVarKeyword = token; |
| 1868 } else { | 1874 } else { |
| 1869 internalError('Unhandled modifier: $s'); | 1875 internalError('Unhandled modifier: $s'); |
| 1870 } | 1876 } |
| 1871 } | 1877 } |
| 1872 } | 1878 } |
| 1873 } | 1879 } |
| OLD | NEW |