Chromium Code Reviews| 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' show Token, TokenType; | 10 import 'package:analyzer/dart/ast/token.dart' show Token, TokenType; |
| (...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1117 name, | 1117 name, |
| 1118 ast.functionExpression(typeParameters, parameters, body))); | 1118 ast.functionExpression(typeParameters, parameters, body))); |
| 1119 } | 1119 } |
| 1120 | 1120 |
| 1121 @override | 1121 @override |
| 1122 void endTopLevelDeclaration(Token token) { | 1122 void endTopLevelDeclaration(Token token) { |
| 1123 debugEvent("TopLevelDeclaration"); | 1123 debugEvent("TopLevelDeclaration"); |
| 1124 } | 1124 } |
| 1125 | 1125 |
| 1126 @override | 1126 @override |
| 1127 void handleInvalidTopLevelDeclaration(Token endToken) { | |
| 1128 debugEvent("InvalidTopLevelDeclaration"); | |
| 1129 pop(); // metadata star | |
| 1130 // TODO(danrubel): consider creating a AST node | |
| 1131 // representing the invalid declaration to better support code completion, | |
| 1132 // quick fixes, etc, rather than discarding the metadata and token | |
| 1133 push(NullValue.InvalidTopLevelDeclaration); | |
| 1134 } | |
| 1135 | |
| 1136 @override | |
| 1127 void beginCompilationUnit(Token token) { | 1137 void beginCompilationUnit(Token token) { |
| 1128 push(token); | 1138 push(token); |
| 1129 } | 1139 } |
| 1130 | 1140 |
| 1131 @override | 1141 @override |
| 1132 void endCompilationUnit(int count, Token endToken) { | 1142 void endCompilationUnit(int count, Token endToken) { |
| 1133 debugEvent("CompilationUnit"); | 1143 debugEvent("CompilationUnit"); |
| 1134 List<Object> elements = popList(count); | 1144 List<Object> elements = popList(count); |
| 1135 Token beginToken = pop(); | 1145 Token beginToken = pop(); |
| 1136 | 1146 |
| 1137 ScriptTag scriptTag = null; | 1147 ScriptTag scriptTag = null; |
| 1138 var directives = <Directive>[]; | 1148 var directives = <Directive>[]; |
| 1139 var declarations = <CompilationUnitMember>[]; | 1149 var declarations = <CompilationUnitMember>[]; |
| 1140 if (elements != null) { | 1150 if (elements != null) { |
| 1141 for (AstNode node in elements) { | 1151 for (AstNode node in elements) { |
| 1142 if (node is ScriptTag) { | 1152 if (node is ScriptTag) { |
| 1143 scriptTag = node; | 1153 scriptTag = node; |
| 1144 } else if (node is Directive) { | 1154 } else if (node is Directive) { |
| 1145 directives.add(node); | 1155 directives.add(node); |
| 1146 } else if (node is CompilationUnitMember) { | 1156 } else if (node is CompilationUnitMember) { |
| 1147 declarations.add(node); | 1157 declarations.add(node); |
| 1158 } else if (node == NullValue.InvalidTopLevelDeclaration) { | |
| 1159 // TODO(danrubel): consider creating a AST node | |
| 1160 // representing the invalid declaration to better support code complet ion, | |
|
ahe
2017/08/16 13:22:45
Long line! P0!!! ;-)
danrubel
2017/08/16 13:34:29
Fixed. :-)
| |
| 1161 // quick fixes, etc, rather than discarding the metadata and token | |
| 1148 } else { | 1162 } else { |
| 1149 unhandled( | 1163 unhandled( |
| 1150 "${node.runtimeType}", "compilation unit", node?.offset, uri); | 1164 "${node.runtimeType}", "compilation unit", node?.offset, uri); |
| 1151 } | 1165 } |
| 1152 } | 1166 } |
| 1153 } | 1167 } |
| 1154 | 1168 |
| 1155 push(ast.compilationUnit( | 1169 push(ast.compilationUnit( |
| 1156 beginToken, scriptTag, directives, declarations, endToken)); | 1170 beginToken, scriptTag, directives, declarations, endToken)); |
| 1157 } | 1171 } |
| (...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2010 } else if (identical('var', s)) { | 2024 } else if (identical('var', s)) { |
| 2011 finalConstOrVarKeyword = token; | 2025 finalConstOrVarKeyword = token; |
| 2012 } else if (identical('covariant', s)) { | 2026 } else if (identical('covariant', s)) { |
| 2013 covariantKeyword = token; | 2027 covariantKeyword = token; |
| 2014 } else { | 2028 } else { |
| 2015 unhandled("$s", "modifier", token.charOffset, null); | 2029 unhandled("$s", "modifier", token.charOffset, null); |
| 2016 } | 2030 } |
| 2017 } | 2031 } |
| 2018 } | 2032 } |
| 2019 } | 2033 } |
| OLD | NEW |