OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 analyzer.src.dart.ast.utilities; | 5 library analyzer.src.dart.ast.utilities; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
10 import 'package:analyzer/dart/ast/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
11 import 'package:analyzer/dart/ast/visitor.dart'; | 11 import 'package:analyzer/dart/ast/visitor.dart'; |
12 import 'package:analyzer/dart/element/element.dart'; | 12 import 'package:analyzer/dart/element/element.dart'; |
13 import 'package:analyzer/exception/exception.dart'; | 13 import 'package:analyzer/exception/exception.dart'; |
14 import 'package:analyzer/src/dart/ast/ast.dart'; | 14 import 'package:analyzer/src/dart/ast/ast.dart'; |
15 import 'package:analyzer/src/dart/ast/token.dart'; | 15 import 'package:analyzer/src/dart/ast/token.dart'; |
16 import 'package:analyzer/src/generated/engine.dart' show AnalysisEngine; | 16 import 'package:analyzer/src/generated/engine.dart' show AnalysisEngine; |
17 import 'package:analyzer/src/generated/java_core.dart'; | 17 import 'package:analyzer/src/generated/java_core.dart'; |
18 import 'package:analyzer/src/generated/utilities_collection.dart' show TokenMap; | 18 import 'package:analyzer/src/generated/utilities_collection.dart' show TokenMap; |
19 import 'package:analyzer/src/generated/utilities_dart.dart'; | 19 import 'package:analyzer/src/generated/utilities_dart.dart'; |
| 20 import 'package:meta/meta.dart'; |
20 | 21 |
21 /** | 22 /** |
22 * A function used to handle exceptions that are thrown by delegates while using | 23 * A function used to handle exceptions that are thrown by delegates while using |
23 * an [ExceptionHandlingDelegatingAstVisitor]. | 24 * an [ExceptionHandlingDelegatingAstVisitor]. |
24 */ | 25 */ |
25 typedef void ExceptionInDelegateHandler( | 26 typedef void ExceptionInDelegateHandler( |
26 AstNode node, AstVisitor visitor, dynamic exception, StackTrace stackTrace); | 27 AstNode node, AstVisitor visitor, dynamic exception, StackTrace stackTrace); |
27 | 28 |
28 /** | 29 /** |
29 * An AST visitor that will clone any AST structure that it visits. The cloner | 30 * An AST visitor that will clone any AST structure that it visits. The cloner |
(...skipping 7876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7906 * Safely visit the given [token], printing the [suffix] after the token if it | 7907 * Safely visit the given [token], printing the [suffix] after the token if it |
7907 * is non-`null`. | 7908 * is non-`null`. |
7908 */ | 7909 */ |
7909 void _visitTokenWithSuffix(Token token, String suffix) { | 7910 void _visitTokenWithSuffix(Token token, String suffix) { |
7910 if (token != null) { | 7911 if (token != null) { |
7911 _writer.print(token.lexeme); | 7912 _writer.print(token.lexeme); |
7912 _writer.print(suffix); | 7913 _writer.print(suffix); |
7913 } | 7914 } |
7914 } | 7915 } |
7915 } | 7916 } |
| 7917 |
| 7918 /** |
| 7919 * A visitor used to write a source representation of a visited AST node (and |
| 7920 * all of it's children) to a sink. |
| 7921 */ |
| 7922 class ToSourceVisitor2 implements AstVisitor<Object> { |
| 7923 /** |
| 7924 * The sink to which the source is to be written. |
| 7925 */ |
| 7926 @protected |
| 7927 final StringSink sink; |
| 7928 |
| 7929 /** |
| 7930 * Initialize a newly created visitor to write source code representing the |
| 7931 * visited nodes to the given [sink]. |
| 7932 */ |
| 7933 ToSourceVisitor2(this.sink); |
| 7934 |
| 7935 /** |
| 7936 * Visit the given function [body], printing the [prefix] before if the body |
| 7937 * is not empty. |
| 7938 */ |
| 7939 @protected |
| 7940 void safelyVisitFunctionWithPrefix(String prefix, FunctionBody body) { |
| 7941 if (body is! EmptyFunctionBody) { |
| 7942 sink.write(prefix); |
| 7943 } |
| 7944 safelyVisitNode(body); |
| 7945 } |
| 7946 |
| 7947 /** |
| 7948 * Safely visit the given [node]. |
| 7949 */ |
| 7950 @protected |
| 7951 void safelyVisitNode(AstNode node) { |
| 7952 if (node != null) { |
| 7953 node.accept(this); |
| 7954 } |
| 7955 } |
| 7956 |
| 7957 /** |
| 7958 * Print a list of [nodes] without any separation. |
| 7959 */ |
| 7960 @protected |
| 7961 void safelyVisitNodeList(NodeList<AstNode> nodes) { |
| 7962 safelyVisitNodeListWithSeparator(nodes, ""); |
| 7963 } |
| 7964 |
| 7965 /** |
| 7966 * Print a list of [nodes], separated by the given [separator]. |
| 7967 */ |
| 7968 @protected |
| 7969 void safelyVisitNodeListWithSeparator( |
| 7970 NodeList<AstNode> nodes, String separator) { |
| 7971 if (nodes != null) { |
| 7972 int size = nodes.length; |
| 7973 for (int i = 0; i < size; i++) { |
| 7974 if (i > 0) { |
| 7975 sink.write(separator); |
| 7976 } |
| 7977 nodes[i].accept(this); |
| 7978 } |
| 7979 } |
| 7980 } |
| 7981 |
| 7982 /** |
| 7983 * Print a list of [nodes], prefixed by the given [prefix] if the list is not |
| 7984 * empty, and separated by the given [separator]. |
| 7985 */ |
| 7986 @protected |
| 7987 void safelyVisitNodeListWithSeparatorAndPrefix( |
| 7988 String prefix, NodeList<AstNode> nodes, String separator) { |
| 7989 if (nodes != null) { |
| 7990 int size = nodes.length; |
| 7991 if (size > 0) { |
| 7992 sink.write(prefix); |
| 7993 for (int i = 0; i < size; i++) { |
| 7994 if (i > 0) { |
| 7995 sink.write(separator); |
| 7996 } |
| 7997 nodes[i].accept(this); |
| 7998 } |
| 7999 } |
| 8000 } |
| 8001 } |
| 8002 |
| 8003 /** |
| 8004 * Print a list of [nodes], separated by the given [separator], followed by |
| 8005 * the given [suffix] if the list is not empty. |
| 8006 */ |
| 8007 @protected |
| 8008 void safelyVisitNodeListWithSeparatorAndSuffix( |
| 8009 NodeList<AstNode> nodes, String separator, String suffix) { |
| 8010 if (nodes != null) { |
| 8011 int size = nodes.length; |
| 8012 if (size > 0) { |
| 8013 for (int i = 0; i < size; i++) { |
| 8014 if (i > 0) { |
| 8015 sink.write(separator); |
| 8016 } |
| 8017 nodes[i].accept(this); |
| 8018 } |
| 8019 sink.write(suffix); |
| 8020 } |
| 8021 } |
| 8022 } |
| 8023 |
| 8024 /** |
| 8025 * Safely visit the given [node], printing the [prefix] before the node if it |
| 8026 * is non-`null`. |
| 8027 */ |
| 8028 @protected |
| 8029 void safelyVisitNodeWithPrefix(String prefix, AstNode node) { |
| 8030 if (node != null) { |
| 8031 sink.write(prefix); |
| 8032 node.accept(this); |
| 8033 } |
| 8034 } |
| 8035 |
| 8036 /** |
| 8037 * Safely visit the given [node], printing the [suffix] after the node if it |
| 8038 * is non-`null`. |
| 8039 */ |
| 8040 @protected |
| 8041 void safelyVisitNodeWithSuffix(AstNode node, String suffix) { |
| 8042 if (node != null) { |
| 8043 node.accept(this); |
| 8044 sink.write(suffix); |
| 8045 } |
| 8046 } |
| 8047 |
| 8048 /** |
| 8049 * Safely visit the given [token], printing the [suffix] after the token if it |
| 8050 * is non-`null`. |
| 8051 */ |
| 8052 @protected |
| 8053 void safelyVisitTokenWithSuffix(Token token, String suffix) { |
| 8054 if (token != null) { |
| 8055 sink.write(token.lexeme); |
| 8056 sink.write(suffix); |
| 8057 } |
| 8058 } |
| 8059 |
| 8060 @override |
| 8061 Object visitAdjacentStrings(AdjacentStrings node) { |
| 8062 safelyVisitNodeListWithSeparator(node.strings, " "); |
| 8063 return null; |
| 8064 } |
| 8065 |
| 8066 @override |
| 8067 Object visitAnnotation(Annotation node) { |
| 8068 sink.write('@'); |
| 8069 safelyVisitNode(node.name); |
| 8070 safelyVisitNodeWithPrefix(".", node.constructorName); |
| 8071 safelyVisitNode(node.arguments); |
| 8072 return null; |
| 8073 } |
| 8074 |
| 8075 @override |
| 8076 Object visitArgumentList(ArgumentList node) { |
| 8077 sink.write('('); |
| 8078 safelyVisitNodeListWithSeparator(node.arguments, ", "); |
| 8079 sink.write(')'); |
| 8080 return null; |
| 8081 } |
| 8082 |
| 8083 @override |
| 8084 Object visitAsExpression(AsExpression node) { |
| 8085 safelyVisitNode(node.expression); |
| 8086 sink.write(" as "); |
| 8087 safelyVisitNode(node.type); |
| 8088 return null; |
| 8089 } |
| 8090 |
| 8091 @override |
| 8092 Object visitAssertStatement(AssertStatement node) { |
| 8093 sink.write("assert ("); |
| 8094 safelyVisitNode(node.condition); |
| 8095 if (node.message != null) { |
| 8096 sink.write(', '); |
| 8097 safelyVisitNode(node.message); |
| 8098 } |
| 8099 sink.write(");"); |
| 8100 return null; |
| 8101 } |
| 8102 |
| 8103 @override |
| 8104 Object visitAssignmentExpression(AssignmentExpression node) { |
| 8105 safelyVisitNode(node.leftHandSide); |
| 8106 sink.write(' '); |
| 8107 sink.write(node.operator.lexeme); |
| 8108 sink.write(' '); |
| 8109 safelyVisitNode(node.rightHandSide); |
| 8110 return null; |
| 8111 } |
| 8112 |
| 8113 @override |
| 8114 Object visitAwaitExpression(AwaitExpression node) { |
| 8115 sink.write("await "); |
| 8116 safelyVisitNode(node.expression); |
| 8117 return null; |
| 8118 } |
| 8119 |
| 8120 @override |
| 8121 Object visitBinaryExpression(BinaryExpression node) { |
| 8122 safelyVisitNode(node.leftOperand); |
| 8123 sink.write(' '); |
| 8124 sink.write(node.operator.lexeme); |
| 8125 sink.write(' '); |
| 8126 safelyVisitNode(node.rightOperand); |
| 8127 return null; |
| 8128 } |
| 8129 |
| 8130 @override |
| 8131 Object visitBlock(Block node) { |
| 8132 sink.write('{'); |
| 8133 safelyVisitNodeListWithSeparator(node.statements, " "); |
| 8134 sink.write('}'); |
| 8135 return null; |
| 8136 } |
| 8137 |
| 8138 @override |
| 8139 Object visitBlockFunctionBody(BlockFunctionBody node) { |
| 8140 Token keyword = node.keyword; |
| 8141 if (keyword != null) { |
| 8142 sink.write(keyword.lexeme); |
| 8143 if (node.star != null) { |
| 8144 sink.write('*'); |
| 8145 } |
| 8146 sink.write(' '); |
| 8147 } |
| 8148 safelyVisitNode(node.block); |
| 8149 return null; |
| 8150 } |
| 8151 |
| 8152 @override |
| 8153 Object visitBooleanLiteral(BooleanLiteral node) { |
| 8154 sink.write(node.literal.lexeme); |
| 8155 return null; |
| 8156 } |
| 8157 |
| 8158 @override |
| 8159 Object visitBreakStatement(BreakStatement node) { |
| 8160 sink.write("break"); |
| 8161 safelyVisitNodeWithPrefix(" ", node.label); |
| 8162 sink.write(";"); |
| 8163 return null; |
| 8164 } |
| 8165 |
| 8166 @override |
| 8167 Object visitCascadeExpression(CascadeExpression node) { |
| 8168 safelyVisitNode(node.target); |
| 8169 safelyVisitNodeList(node.cascadeSections); |
| 8170 return null; |
| 8171 } |
| 8172 |
| 8173 @override |
| 8174 Object visitCatchClause(CatchClause node) { |
| 8175 safelyVisitNodeWithPrefix("on ", node.exceptionType); |
| 8176 if (node.catchKeyword != null) { |
| 8177 if (node.exceptionType != null) { |
| 8178 sink.write(' '); |
| 8179 } |
| 8180 sink.write("catch ("); |
| 8181 safelyVisitNode(node.exceptionParameter); |
| 8182 safelyVisitNodeWithPrefix(", ", node.stackTraceParameter); |
| 8183 sink.write(") "); |
| 8184 } else { |
| 8185 sink.write(" "); |
| 8186 } |
| 8187 safelyVisitNode(node.body); |
| 8188 return null; |
| 8189 } |
| 8190 |
| 8191 @override |
| 8192 Object visitClassDeclaration(ClassDeclaration node) { |
| 8193 safelyVisitNodeListWithSeparatorAndSuffix(node.metadata, " ", " "); |
| 8194 safelyVisitTokenWithSuffix(node.abstractKeyword, " "); |
| 8195 sink.write("class "); |
| 8196 safelyVisitNode(node.name); |
| 8197 safelyVisitNode(node.typeParameters); |
| 8198 safelyVisitNodeWithPrefix(" ", node.extendsClause); |
| 8199 safelyVisitNodeWithPrefix(" ", node.withClause); |
| 8200 safelyVisitNodeWithPrefix(" ", node.implementsClause); |
| 8201 sink.write(" {"); |
| 8202 safelyVisitNodeListWithSeparator(node.members, " "); |
| 8203 sink.write("}"); |
| 8204 return null; |
| 8205 } |
| 8206 |
| 8207 @override |
| 8208 Object visitClassTypeAlias(ClassTypeAlias node) { |
| 8209 safelyVisitNodeListWithSeparatorAndSuffix(node.metadata, " ", " "); |
| 8210 if (node.abstractKeyword != null) { |
| 8211 sink.write("abstract "); |
| 8212 } |
| 8213 sink.write("class "); |
| 8214 safelyVisitNode(node.name); |
| 8215 safelyVisitNode(node.typeParameters); |
| 8216 sink.write(" = "); |
| 8217 safelyVisitNode(node.superclass); |
| 8218 safelyVisitNodeWithPrefix(" ", node.withClause); |
| 8219 safelyVisitNodeWithPrefix(" ", node.implementsClause); |
| 8220 sink.write(";"); |
| 8221 return null; |
| 8222 } |
| 8223 |
| 8224 @override |
| 8225 Object visitComment(Comment node) => null; |
| 8226 |
| 8227 @override |
| 8228 Object visitCommentReference(CommentReference node) => null; |
| 8229 |
| 8230 @override |
| 8231 Object visitCompilationUnit(CompilationUnit node) { |
| 8232 ScriptTag scriptTag = node.scriptTag; |
| 8233 NodeList<Directive> directives = node.directives; |
| 8234 safelyVisitNode(scriptTag); |
| 8235 String prefix = scriptTag == null ? "" : " "; |
| 8236 safelyVisitNodeListWithSeparatorAndPrefix(prefix, directives, " "); |
| 8237 prefix = scriptTag == null && directives.isEmpty ? "" : " "; |
| 8238 safelyVisitNodeListWithSeparatorAndPrefix(prefix, node.declarations, " "); |
| 8239 return null; |
| 8240 } |
| 8241 |
| 8242 @override |
| 8243 Object visitConditionalExpression(ConditionalExpression node) { |
| 8244 safelyVisitNode(node.condition); |
| 8245 sink.write(" ? "); |
| 8246 safelyVisitNode(node.thenExpression); |
| 8247 sink.write(" : "); |
| 8248 safelyVisitNode(node.elseExpression); |
| 8249 return null; |
| 8250 } |
| 8251 |
| 8252 @override |
| 8253 Object visitConfiguration(Configuration node) { |
| 8254 sink.write('if ('); |
| 8255 safelyVisitNode(node.name); |
| 8256 safelyVisitNodeWithPrefix(" == ", node.value); |
| 8257 sink.write(') '); |
| 8258 safelyVisitNode(node.uri); |
| 8259 return null; |
| 8260 } |
| 8261 |
| 8262 @override |
| 8263 Object visitConstructorDeclaration(ConstructorDeclaration node) { |
| 8264 safelyVisitNodeListWithSeparatorAndSuffix(node.metadata, " ", " "); |
| 8265 safelyVisitTokenWithSuffix(node.externalKeyword, " "); |
| 8266 safelyVisitTokenWithSuffix(node.constKeyword, " "); |
| 8267 safelyVisitTokenWithSuffix(node.factoryKeyword, " "); |
| 8268 safelyVisitNode(node.returnType); |
| 8269 safelyVisitNodeWithPrefix(".", node.name); |
| 8270 safelyVisitNode(node.parameters); |
| 8271 safelyVisitNodeListWithSeparatorAndPrefix(" : ", node.initializers, ", "); |
| 8272 safelyVisitNodeWithPrefix(" = ", node.redirectedConstructor); |
| 8273 safelyVisitFunctionWithPrefix(" ", node.body); |
| 8274 return null; |
| 8275 } |
| 8276 |
| 8277 @override |
| 8278 Object visitConstructorFieldInitializer(ConstructorFieldInitializer node) { |
| 8279 safelyVisitTokenWithSuffix(node.thisKeyword, "."); |
| 8280 safelyVisitNode(node.fieldName); |
| 8281 sink.write(" = "); |
| 8282 safelyVisitNode(node.expression); |
| 8283 return null; |
| 8284 } |
| 8285 |
| 8286 @override |
| 8287 Object visitConstructorName(ConstructorName node) { |
| 8288 safelyVisitNode(node.type); |
| 8289 safelyVisitNodeWithPrefix(".", node.name); |
| 8290 return null; |
| 8291 } |
| 8292 |
| 8293 @override |
| 8294 Object visitContinueStatement(ContinueStatement node) { |
| 8295 sink.write("continue"); |
| 8296 safelyVisitNodeWithPrefix(" ", node.label); |
| 8297 sink.write(";"); |
| 8298 return null; |
| 8299 } |
| 8300 |
| 8301 @override |
| 8302 Object visitDeclaredIdentifier(DeclaredIdentifier node) { |
| 8303 safelyVisitNodeListWithSeparatorAndSuffix(node.metadata, " ", " "); |
| 8304 safelyVisitTokenWithSuffix(node.keyword, " "); |
| 8305 safelyVisitNodeWithSuffix(node.type, " "); |
| 8306 safelyVisitNode(node.identifier); |
| 8307 return null; |
| 8308 } |
| 8309 |
| 8310 @override |
| 8311 Object visitDefaultFormalParameter(DefaultFormalParameter node) { |
| 8312 safelyVisitNode(node.parameter); |
| 8313 if (node.separator != null) { |
| 8314 sink.write(" "); |
| 8315 sink.write(node.separator.lexeme); |
| 8316 safelyVisitNodeWithPrefix(" ", node.defaultValue); |
| 8317 } |
| 8318 return null; |
| 8319 } |
| 8320 |
| 8321 @override |
| 8322 Object visitDoStatement(DoStatement node) { |
| 8323 sink.write("do "); |
| 8324 safelyVisitNode(node.body); |
| 8325 sink.write(" while ("); |
| 8326 safelyVisitNode(node.condition); |
| 8327 sink.write(");"); |
| 8328 return null; |
| 8329 } |
| 8330 |
| 8331 @override |
| 8332 Object visitDottedName(DottedName node) { |
| 8333 safelyVisitNodeListWithSeparator(node.components, "."); |
| 8334 return null; |
| 8335 } |
| 8336 |
| 8337 @override |
| 8338 Object visitDoubleLiteral(DoubleLiteral node) { |
| 8339 sink.write(node.literal.lexeme); |
| 8340 return null; |
| 8341 } |
| 8342 |
| 8343 @override |
| 8344 Object visitEmptyFunctionBody(EmptyFunctionBody node) { |
| 8345 sink.write(';'); |
| 8346 return null; |
| 8347 } |
| 8348 |
| 8349 @override |
| 8350 Object visitEmptyStatement(EmptyStatement node) { |
| 8351 sink.write(';'); |
| 8352 return null; |
| 8353 } |
| 8354 |
| 8355 @override |
| 8356 Object visitEnumConstantDeclaration(EnumConstantDeclaration node) { |
| 8357 safelyVisitNodeListWithSeparatorAndSuffix(node.metadata, " ", " "); |
| 8358 safelyVisitNode(node.name); |
| 8359 return null; |
| 8360 } |
| 8361 |
| 8362 @override |
| 8363 Object visitEnumDeclaration(EnumDeclaration node) { |
| 8364 safelyVisitNodeListWithSeparatorAndSuffix(node.metadata, " ", " "); |
| 8365 sink.write("enum "); |
| 8366 safelyVisitNode(node.name); |
| 8367 sink.write(" {"); |
| 8368 safelyVisitNodeListWithSeparator(node.constants, ", "); |
| 8369 sink.write("}"); |
| 8370 return null; |
| 8371 } |
| 8372 |
| 8373 @override |
| 8374 Object visitExportDirective(ExportDirective node) { |
| 8375 safelyVisitNodeListWithSeparatorAndSuffix(node.metadata, " ", " "); |
| 8376 sink.write("export "); |
| 8377 safelyVisitNode(node.uri); |
| 8378 safelyVisitNodeListWithSeparatorAndPrefix(" ", node.combinators, " "); |
| 8379 sink.write(';'); |
| 8380 return null; |
| 8381 } |
| 8382 |
| 8383 @override |
| 8384 Object visitExpressionFunctionBody(ExpressionFunctionBody node) { |
| 8385 Token keyword = node.keyword; |
| 8386 if (keyword != null) { |
| 8387 sink.write(keyword.lexeme); |
| 8388 sink.write(' '); |
| 8389 } |
| 8390 sink.write("=> "); |
| 8391 safelyVisitNode(node.expression); |
| 8392 if (node.semicolon != null) { |
| 8393 sink.write(';'); |
| 8394 } |
| 8395 return null; |
| 8396 } |
| 8397 |
| 8398 @override |
| 8399 Object visitExpressionStatement(ExpressionStatement node) { |
| 8400 safelyVisitNode(node.expression); |
| 8401 sink.write(';'); |
| 8402 return null; |
| 8403 } |
| 8404 |
| 8405 @override |
| 8406 Object visitExtendsClause(ExtendsClause node) { |
| 8407 sink.write("extends "); |
| 8408 safelyVisitNode(node.superclass); |
| 8409 return null; |
| 8410 } |
| 8411 |
| 8412 @override |
| 8413 Object visitFieldDeclaration(FieldDeclaration node) { |
| 8414 safelyVisitNodeListWithSeparatorAndSuffix(node.metadata, " ", " "); |
| 8415 safelyVisitTokenWithSuffix(node.staticKeyword, " "); |
| 8416 safelyVisitNode(node.fields); |
| 8417 sink.write(";"); |
| 8418 return null; |
| 8419 } |
| 8420 |
| 8421 @override |
| 8422 Object visitFieldFormalParameter(FieldFormalParameter node) { |
| 8423 safelyVisitNodeListWithSeparatorAndSuffix(node.metadata, ' ', ' '); |
| 8424 safelyVisitTokenWithSuffix(node.keyword, " "); |
| 8425 safelyVisitNodeWithSuffix(node.type, " "); |
| 8426 sink.write("this."); |
| 8427 safelyVisitNode(node.identifier); |
| 8428 safelyVisitNode(node.typeParameters); |
| 8429 safelyVisitNode(node.parameters); |
| 8430 return null; |
| 8431 } |
| 8432 |
| 8433 @override |
| 8434 Object visitForEachStatement(ForEachStatement node) { |
| 8435 DeclaredIdentifier loopVariable = node.loopVariable; |
| 8436 if (node.awaitKeyword != null) { |
| 8437 sink.write("await "); |
| 8438 } |
| 8439 sink.write("for ("); |
| 8440 if (loopVariable == null) { |
| 8441 safelyVisitNode(node.identifier); |
| 8442 } else { |
| 8443 safelyVisitNode(loopVariable); |
| 8444 } |
| 8445 sink.write(" in "); |
| 8446 safelyVisitNode(node.iterable); |
| 8447 sink.write(") "); |
| 8448 safelyVisitNode(node.body); |
| 8449 return null; |
| 8450 } |
| 8451 |
| 8452 @override |
| 8453 Object visitFormalParameterList(FormalParameterList node) { |
| 8454 String groupEnd = null; |
| 8455 sink.write('('); |
| 8456 NodeList<FormalParameter> parameters = node.parameters; |
| 8457 int size = parameters.length; |
| 8458 for (int i = 0; i < size; i++) { |
| 8459 FormalParameter parameter = parameters[i]; |
| 8460 if (i > 0) { |
| 8461 sink.write(", "); |
| 8462 } |
| 8463 if (groupEnd == null && parameter is DefaultFormalParameter) { |
| 8464 if (parameter.kind == ParameterKind.NAMED) { |
| 8465 groupEnd = "}"; |
| 8466 sink.write('{'); |
| 8467 } else { |
| 8468 groupEnd = "]"; |
| 8469 sink.write('['); |
| 8470 } |
| 8471 } |
| 8472 parameter.accept(this); |
| 8473 } |
| 8474 if (groupEnd != null) { |
| 8475 sink.write(groupEnd); |
| 8476 } |
| 8477 sink.write(')'); |
| 8478 return null; |
| 8479 } |
| 8480 |
| 8481 @override |
| 8482 Object visitForStatement(ForStatement node) { |
| 8483 Expression initialization = node.initialization; |
| 8484 sink.write("for ("); |
| 8485 if (initialization != null) { |
| 8486 safelyVisitNode(initialization); |
| 8487 } else { |
| 8488 safelyVisitNode(node.variables); |
| 8489 } |
| 8490 sink.write(";"); |
| 8491 safelyVisitNodeWithPrefix(" ", node.condition); |
| 8492 sink.write(";"); |
| 8493 safelyVisitNodeListWithSeparatorAndPrefix(" ", node.updaters, ", "); |
| 8494 sink.write(") "); |
| 8495 safelyVisitNode(node.body); |
| 8496 return null; |
| 8497 } |
| 8498 |
| 8499 @override |
| 8500 Object visitFunctionDeclaration(FunctionDeclaration node) { |
| 8501 safelyVisitNodeListWithSeparatorAndSuffix(node.metadata, " ", " "); |
| 8502 safelyVisitTokenWithSuffix(node.externalKeyword, " "); |
| 8503 safelyVisitNodeWithSuffix(node.returnType, " "); |
| 8504 safelyVisitTokenWithSuffix(node.propertyKeyword, " "); |
| 8505 safelyVisitNode(node.name); |
| 8506 safelyVisitNode(node.functionExpression); |
| 8507 return null; |
| 8508 } |
| 8509 |
| 8510 @override |
| 8511 Object visitFunctionDeclarationStatement(FunctionDeclarationStatement node) { |
| 8512 safelyVisitNode(node.functionDeclaration); |
| 8513 return null; |
| 8514 } |
| 8515 |
| 8516 @override |
| 8517 Object visitFunctionExpression(FunctionExpression node) { |
| 8518 safelyVisitNode(node.typeParameters); |
| 8519 safelyVisitNode(node.parameters); |
| 8520 if (node.body is! EmptyFunctionBody) { |
| 8521 sink.write(' '); |
| 8522 } |
| 8523 safelyVisitNode(node.body); |
| 8524 return null; |
| 8525 } |
| 8526 |
| 8527 @override |
| 8528 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { |
| 8529 safelyVisitNode(node.function); |
| 8530 safelyVisitNode(node.typeArguments); |
| 8531 safelyVisitNode(node.argumentList); |
| 8532 return null; |
| 8533 } |
| 8534 |
| 8535 @override |
| 8536 Object visitFunctionTypeAlias(FunctionTypeAlias node) { |
| 8537 safelyVisitNodeListWithSeparatorAndSuffix(node.metadata, " ", " "); |
| 8538 sink.write("typedef "); |
| 8539 safelyVisitNodeWithSuffix(node.returnType, " "); |
| 8540 safelyVisitNode(node.name); |
| 8541 safelyVisitNode(node.typeParameters); |
| 8542 safelyVisitNode(node.parameters); |
| 8543 sink.write(";"); |
| 8544 return null; |
| 8545 } |
| 8546 |
| 8547 @override |
| 8548 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { |
| 8549 safelyVisitNodeListWithSeparatorAndSuffix(node.metadata, ' ', ' '); |
| 8550 safelyVisitNodeWithSuffix(node.returnType, " "); |
| 8551 safelyVisitNode(node.identifier); |
| 8552 safelyVisitNode(node.typeParameters); |
| 8553 safelyVisitNode(node.parameters); |
| 8554 if (node.question != null) { |
| 8555 sink.write('?'); |
| 8556 } |
| 8557 return null; |
| 8558 } |
| 8559 |
| 8560 @override |
| 8561 Object visitHideCombinator(HideCombinator node) { |
| 8562 sink.write("hide "); |
| 8563 safelyVisitNodeListWithSeparator(node.hiddenNames, ", "); |
| 8564 return null; |
| 8565 } |
| 8566 |
| 8567 @override |
| 8568 Object visitIfStatement(IfStatement node) { |
| 8569 sink.write("if ("); |
| 8570 safelyVisitNode(node.condition); |
| 8571 sink.write(") "); |
| 8572 safelyVisitNode(node.thenStatement); |
| 8573 safelyVisitNodeWithPrefix(" else ", node.elseStatement); |
| 8574 return null; |
| 8575 } |
| 8576 |
| 8577 @override |
| 8578 Object visitImplementsClause(ImplementsClause node) { |
| 8579 sink.write("implements "); |
| 8580 safelyVisitNodeListWithSeparator(node.interfaces, ", "); |
| 8581 return null; |
| 8582 } |
| 8583 |
| 8584 @override |
| 8585 Object visitImportDirective(ImportDirective node) { |
| 8586 safelyVisitNodeListWithSeparatorAndSuffix(node.metadata, " ", " "); |
| 8587 sink.write("import "); |
| 8588 safelyVisitNode(node.uri); |
| 8589 if (node.deferredKeyword != null) { |
| 8590 sink.write(" deferred"); |
| 8591 } |
| 8592 safelyVisitNodeWithPrefix(" as ", node.prefix); |
| 8593 safelyVisitNodeListWithSeparatorAndPrefix(" ", node.combinators, " "); |
| 8594 sink.write(';'); |
| 8595 return null; |
| 8596 } |
| 8597 |
| 8598 @override |
| 8599 Object visitIndexExpression(IndexExpression node) { |
| 8600 if (node.isCascaded) { |
| 8601 sink.write(".."); |
| 8602 } else { |
| 8603 safelyVisitNode(node.target); |
| 8604 } |
| 8605 sink.write('['); |
| 8606 safelyVisitNode(node.index); |
| 8607 sink.write(']'); |
| 8608 return null; |
| 8609 } |
| 8610 |
| 8611 @override |
| 8612 Object visitInstanceCreationExpression(InstanceCreationExpression node) { |
| 8613 safelyVisitTokenWithSuffix(node.keyword, " "); |
| 8614 safelyVisitNode(node.constructorName); |
| 8615 safelyVisitNode(node.argumentList); |
| 8616 return null; |
| 8617 } |
| 8618 |
| 8619 @override |
| 8620 Object visitIntegerLiteral(IntegerLiteral node) { |
| 8621 sink.write(node.literal.lexeme); |
| 8622 return null; |
| 8623 } |
| 8624 |
| 8625 @override |
| 8626 Object visitInterpolationExpression(InterpolationExpression node) { |
| 8627 if (node.rightBracket != null) { |
| 8628 sink.write("\${"); |
| 8629 safelyVisitNode(node.expression); |
| 8630 sink.write("}"); |
| 8631 } else { |
| 8632 sink.write("\$"); |
| 8633 safelyVisitNode(node.expression); |
| 8634 } |
| 8635 return null; |
| 8636 } |
| 8637 |
| 8638 @override |
| 8639 Object visitInterpolationString(InterpolationString node) { |
| 8640 sink.write(node.contents.lexeme); |
| 8641 return null; |
| 8642 } |
| 8643 |
| 8644 @override |
| 8645 Object visitIsExpression(IsExpression node) { |
| 8646 safelyVisitNode(node.expression); |
| 8647 if (node.notOperator == null) { |
| 8648 sink.write(" is "); |
| 8649 } else { |
| 8650 sink.write(" is! "); |
| 8651 } |
| 8652 safelyVisitNode(node.type); |
| 8653 return null; |
| 8654 } |
| 8655 |
| 8656 @override |
| 8657 Object visitLabel(Label node) { |
| 8658 safelyVisitNode(node.label); |
| 8659 sink.write(":"); |
| 8660 return null; |
| 8661 } |
| 8662 |
| 8663 @override |
| 8664 Object visitLabeledStatement(LabeledStatement node) { |
| 8665 safelyVisitNodeListWithSeparatorAndSuffix(node.labels, " ", " "); |
| 8666 safelyVisitNode(node.statement); |
| 8667 return null; |
| 8668 } |
| 8669 |
| 8670 @override |
| 8671 Object visitLibraryDirective(LibraryDirective node) { |
| 8672 safelyVisitNodeListWithSeparatorAndSuffix(node.metadata, " ", " "); |
| 8673 sink.write("library "); |
| 8674 safelyVisitNode(node.name); |
| 8675 sink.write(';'); |
| 8676 return null; |
| 8677 } |
| 8678 |
| 8679 @override |
| 8680 Object visitLibraryIdentifier(LibraryIdentifier node) { |
| 8681 sink.write(node.name); |
| 8682 return null; |
| 8683 } |
| 8684 |
| 8685 @override |
| 8686 Object visitListLiteral(ListLiteral node) { |
| 8687 if (node.constKeyword != null) { |
| 8688 sink.write(node.constKeyword.lexeme); |
| 8689 sink.write(' '); |
| 8690 } |
| 8691 safelyVisitNodeWithSuffix(node.typeArguments, " "); |
| 8692 sink.write("["); |
| 8693 safelyVisitNodeListWithSeparator(node.elements, ", "); |
| 8694 sink.write("]"); |
| 8695 return null; |
| 8696 } |
| 8697 |
| 8698 @override |
| 8699 Object visitMapLiteral(MapLiteral node) { |
| 8700 if (node.constKeyword != null) { |
| 8701 sink.write(node.constKeyword.lexeme); |
| 8702 sink.write(' '); |
| 8703 } |
| 8704 safelyVisitNodeWithSuffix(node.typeArguments, " "); |
| 8705 sink.write("{"); |
| 8706 safelyVisitNodeListWithSeparator(node.entries, ", "); |
| 8707 sink.write("}"); |
| 8708 return null; |
| 8709 } |
| 8710 |
| 8711 @override |
| 8712 Object visitMapLiteralEntry(MapLiteralEntry node) { |
| 8713 safelyVisitNode(node.key); |
| 8714 sink.write(" : "); |
| 8715 safelyVisitNode(node.value); |
| 8716 return null; |
| 8717 } |
| 8718 |
| 8719 @override |
| 8720 Object visitMethodDeclaration(MethodDeclaration node) { |
| 8721 safelyVisitNodeListWithSeparatorAndSuffix(node.metadata, " ", " "); |
| 8722 safelyVisitTokenWithSuffix(node.externalKeyword, " "); |
| 8723 safelyVisitTokenWithSuffix(node.modifierKeyword, " "); |
| 8724 safelyVisitNodeWithSuffix(node.returnType, " "); |
| 8725 safelyVisitTokenWithSuffix(node.propertyKeyword, " "); |
| 8726 safelyVisitTokenWithSuffix(node.operatorKeyword, " "); |
| 8727 safelyVisitNode(node.name); |
| 8728 if (!node.isGetter) { |
| 8729 safelyVisitNode(node.typeParameters); |
| 8730 safelyVisitNode(node.parameters); |
| 8731 } |
| 8732 safelyVisitFunctionWithPrefix(" ", node.body); |
| 8733 return null; |
| 8734 } |
| 8735 |
| 8736 @override |
| 8737 Object visitMethodInvocation(MethodInvocation node) { |
| 8738 if (node.isCascaded) { |
| 8739 sink.write(".."); |
| 8740 } else { |
| 8741 if (node.target != null) { |
| 8742 node.target.accept(this); |
| 8743 sink.write(node.operator.lexeme); |
| 8744 } |
| 8745 } |
| 8746 safelyVisitNode(node.methodName); |
| 8747 safelyVisitNode(node.typeArguments); |
| 8748 safelyVisitNode(node.argumentList); |
| 8749 return null; |
| 8750 } |
| 8751 |
| 8752 @override |
| 8753 Object visitNamedExpression(NamedExpression node) { |
| 8754 safelyVisitNode(node.name); |
| 8755 safelyVisitNodeWithPrefix(" ", node.expression); |
| 8756 return null; |
| 8757 } |
| 8758 |
| 8759 @override |
| 8760 Object visitNativeClause(NativeClause node) { |
| 8761 sink.write("native "); |
| 8762 safelyVisitNode(node.name); |
| 8763 return null; |
| 8764 } |
| 8765 |
| 8766 @override |
| 8767 Object visitNativeFunctionBody(NativeFunctionBody node) { |
| 8768 sink.write("native "); |
| 8769 safelyVisitNode(node.stringLiteral); |
| 8770 sink.write(';'); |
| 8771 return null; |
| 8772 } |
| 8773 |
| 8774 @override |
| 8775 Object visitNullLiteral(NullLiteral node) { |
| 8776 sink.write("null"); |
| 8777 return null; |
| 8778 } |
| 8779 |
| 8780 @override |
| 8781 Object visitParenthesizedExpression(ParenthesizedExpression node) { |
| 8782 sink.write('('); |
| 8783 safelyVisitNode(node.expression); |
| 8784 sink.write(')'); |
| 8785 return null; |
| 8786 } |
| 8787 |
| 8788 @override |
| 8789 Object visitPartDirective(PartDirective node) { |
| 8790 safelyVisitNodeListWithSeparatorAndSuffix(node.metadata, " ", " "); |
| 8791 sink.write("part "); |
| 8792 safelyVisitNode(node.uri); |
| 8793 sink.write(';'); |
| 8794 return null; |
| 8795 } |
| 8796 |
| 8797 @override |
| 8798 Object visitPartOfDirective(PartOfDirective node) { |
| 8799 safelyVisitNodeListWithSeparatorAndSuffix(node.metadata, " ", " "); |
| 8800 sink.write("part of "); |
| 8801 safelyVisitNode(node.libraryName); |
| 8802 sink.write(';'); |
| 8803 return null; |
| 8804 } |
| 8805 |
| 8806 @override |
| 8807 Object visitPostfixExpression(PostfixExpression node) { |
| 8808 safelyVisitNode(node.operand); |
| 8809 sink.write(node.operator.lexeme); |
| 8810 return null; |
| 8811 } |
| 8812 |
| 8813 @override |
| 8814 Object visitPrefixedIdentifier(PrefixedIdentifier node) { |
| 8815 safelyVisitNode(node.prefix); |
| 8816 sink.write('.'); |
| 8817 safelyVisitNode(node.identifier); |
| 8818 return null; |
| 8819 } |
| 8820 |
| 8821 @override |
| 8822 Object visitPrefixExpression(PrefixExpression node) { |
| 8823 sink.write(node.operator.lexeme); |
| 8824 safelyVisitNode(node.operand); |
| 8825 return null; |
| 8826 } |
| 8827 |
| 8828 @override |
| 8829 Object visitPropertyAccess(PropertyAccess node) { |
| 8830 if (node.isCascaded) { |
| 8831 sink.write(".."); |
| 8832 } else { |
| 8833 safelyVisitNode(node.target); |
| 8834 sink.write(node.operator.lexeme); |
| 8835 } |
| 8836 safelyVisitNode(node.propertyName); |
| 8837 return null; |
| 8838 } |
| 8839 |
| 8840 @override |
| 8841 Object visitRedirectingConstructorInvocation( |
| 8842 RedirectingConstructorInvocation node) { |
| 8843 sink.write("this"); |
| 8844 safelyVisitNodeWithPrefix(".", node.constructorName); |
| 8845 safelyVisitNode(node.argumentList); |
| 8846 return null; |
| 8847 } |
| 8848 |
| 8849 @override |
| 8850 Object visitRethrowExpression(RethrowExpression node) { |
| 8851 sink.write("rethrow"); |
| 8852 return null; |
| 8853 } |
| 8854 |
| 8855 @override |
| 8856 Object visitReturnStatement(ReturnStatement node) { |
| 8857 Expression expression = node.expression; |
| 8858 if (expression == null) { |
| 8859 sink.write("return;"); |
| 8860 } else { |
| 8861 sink.write("return "); |
| 8862 expression.accept(this); |
| 8863 sink.write(";"); |
| 8864 } |
| 8865 return null; |
| 8866 } |
| 8867 |
| 8868 @override |
| 8869 Object visitScriptTag(ScriptTag node) { |
| 8870 sink.write(node.scriptTag.lexeme); |
| 8871 return null; |
| 8872 } |
| 8873 |
| 8874 @override |
| 8875 Object visitShowCombinator(ShowCombinator node) { |
| 8876 sink.write("show "); |
| 8877 safelyVisitNodeListWithSeparator(node.shownNames, ", "); |
| 8878 return null; |
| 8879 } |
| 8880 |
| 8881 @override |
| 8882 Object visitSimpleFormalParameter(SimpleFormalParameter node) { |
| 8883 safelyVisitNodeListWithSeparatorAndSuffix(node.metadata, ' ', ' '); |
| 8884 safelyVisitTokenWithSuffix(node.keyword, " "); |
| 8885 safelyVisitNodeWithSuffix(node.type, " "); |
| 8886 safelyVisitNode(node.identifier); |
| 8887 return null; |
| 8888 } |
| 8889 |
| 8890 @override |
| 8891 Object visitSimpleIdentifier(SimpleIdentifier node) { |
| 8892 sink.write(node.token.lexeme); |
| 8893 return null; |
| 8894 } |
| 8895 |
| 8896 @override |
| 8897 Object visitSimpleStringLiteral(SimpleStringLiteral node) { |
| 8898 sink.write(node.literal.lexeme); |
| 8899 return null; |
| 8900 } |
| 8901 |
| 8902 @override |
| 8903 Object visitStringInterpolation(StringInterpolation node) { |
| 8904 safelyVisitNodeList(node.elements); |
| 8905 return null; |
| 8906 } |
| 8907 |
| 8908 @override |
| 8909 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { |
| 8910 sink.write("super"); |
| 8911 safelyVisitNodeWithPrefix(".", node.constructorName); |
| 8912 safelyVisitNode(node.argumentList); |
| 8913 return null; |
| 8914 } |
| 8915 |
| 8916 @override |
| 8917 Object visitSuperExpression(SuperExpression node) { |
| 8918 sink.write("super"); |
| 8919 return null; |
| 8920 } |
| 8921 |
| 8922 @override |
| 8923 Object visitSwitchCase(SwitchCase node) { |
| 8924 safelyVisitNodeListWithSeparatorAndSuffix(node.labels, " ", " "); |
| 8925 sink.write("case "); |
| 8926 safelyVisitNode(node.expression); |
| 8927 sink.write(": "); |
| 8928 safelyVisitNodeListWithSeparator(node.statements, " "); |
| 8929 return null; |
| 8930 } |
| 8931 |
| 8932 @override |
| 8933 Object visitSwitchDefault(SwitchDefault node) { |
| 8934 safelyVisitNodeListWithSeparatorAndSuffix(node.labels, " ", " "); |
| 8935 sink.write("default: "); |
| 8936 safelyVisitNodeListWithSeparator(node.statements, " "); |
| 8937 return null; |
| 8938 } |
| 8939 |
| 8940 @override |
| 8941 Object visitSwitchStatement(SwitchStatement node) { |
| 8942 sink.write("switch ("); |
| 8943 safelyVisitNode(node.expression); |
| 8944 sink.write(") {"); |
| 8945 safelyVisitNodeListWithSeparator(node.members, " "); |
| 8946 sink.write("}"); |
| 8947 return null; |
| 8948 } |
| 8949 |
| 8950 @override |
| 8951 Object visitSymbolLiteral(SymbolLiteral node) { |
| 8952 sink.write("#"); |
| 8953 List<Token> components = node.components; |
| 8954 for (int i = 0; i < components.length; i++) { |
| 8955 if (i > 0) { |
| 8956 sink.write("."); |
| 8957 } |
| 8958 sink.write(components[i].lexeme); |
| 8959 } |
| 8960 return null; |
| 8961 } |
| 8962 |
| 8963 @override |
| 8964 Object visitThisExpression(ThisExpression node) { |
| 8965 sink.write("this"); |
| 8966 return null; |
| 8967 } |
| 8968 |
| 8969 @override |
| 8970 Object visitThrowExpression(ThrowExpression node) { |
| 8971 sink.write("throw "); |
| 8972 safelyVisitNode(node.expression); |
| 8973 return null; |
| 8974 } |
| 8975 |
| 8976 @override |
| 8977 Object visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) { |
| 8978 safelyVisitNodeWithSuffix(node.variables, ";"); |
| 8979 return null; |
| 8980 } |
| 8981 |
| 8982 @override |
| 8983 Object visitTryStatement(TryStatement node) { |
| 8984 sink.write("try "); |
| 8985 safelyVisitNode(node.body); |
| 8986 safelyVisitNodeListWithSeparatorAndPrefix(" ", node.catchClauses, " "); |
| 8987 safelyVisitNodeWithPrefix(" finally ", node.finallyBlock); |
| 8988 return null; |
| 8989 } |
| 8990 |
| 8991 @override |
| 8992 Object visitTypeArgumentList(TypeArgumentList node) { |
| 8993 sink.write('<'); |
| 8994 safelyVisitNodeListWithSeparator(node.arguments, ", "); |
| 8995 sink.write('>'); |
| 8996 return null; |
| 8997 } |
| 8998 |
| 8999 @override |
| 9000 Object visitTypeName(TypeName node) { |
| 9001 safelyVisitNode(node.name); |
| 9002 safelyVisitNode(node.typeArguments); |
| 9003 if (node.question != null) { |
| 9004 sink.write('?'); |
| 9005 } |
| 9006 return null; |
| 9007 } |
| 9008 |
| 9009 @override |
| 9010 Object visitTypeParameter(TypeParameter node) { |
| 9011 safelyVisitNodeListWithSeparatorAndSuffix(node.metadata, " ", " "); |
| 9012 safelyVisitNode(node.name); |
| 9013 safelyVisitNodeWithPrefix(" extends ", node.bound); |
| 9014 return null; |
| 9015 } |
| 9016 |
| 9017 @override |
| 9018 Object visitTypeParameterList(TypeParameterList node) { |
| 9019 sink.write('<'); |
| 9020 safelyVisitNodeListWithSeparator(node.typeParameters, ", "); |
| 9021 sink.write('>'); |
| 9022 return null; |
| 9023 } |
| 9024 |
| 9025 @override |
| 9026 Object visitVariableDeclaration(VariableDeclaration node) { |
| 9027 safelyVisitNodeListWithSeparatorAndSuffix(node.metadata, " ", " "); |
| 9028 safelyVisitNode(node.name); |
| 9029 safelyVisitNodeWithPrefix(" = ", node.initializer); |
| 9030 return null; |
| 9031 } |
| 9032 |
| 9033 @override |
| 9034 Object visitVariableDeclarationList(VariableDeclarationList node) { |
| 9035 safelyVisitNodeListWithSeparatorAndSuffix(node.metadata, " ", " "); |
| 9036 safelyVisitTokenWithSuffix(node.keyword, " "); |
| 9037 safelyVisitNodeWithSuffix(node.type, " "); |
| 9038 safelyVisitNodeListWithSeparator(node.variables, ", "); |
| 9039 return null; |
| 9040 } |
| 9041 |
| 9042 @override |
| 9043 Object visitVariableDeclarationStatement(VariableDeclarationStatement node) { |
| 9044 safelyVisitNode(node.variables); |
| 9045 sink.write(";"); |
| 9046 return null; |
| 9047 } |
| 9048 |
| 9049 @override |
| 9050 Object visitWhileStatement(WhileStatement node) { |
| 9051 sink.write("while ("); |
| 9052 safelyVisitNode(node.condition); |
| 9053 sink.write(") "); |
| 9054 safelyVisitNode(node.body); |
| 9055 return null; |
| 9056 } |
| 9057 |
| 9058 @override |
| 9059 Object visitWithClause(WithClause node) { |
| 9060 sink.write("with "); |
| 9061 safelyVisitNodeListWithSeparator(node.mixinTypes, ", "); |
| 9062 return null; |
| 9063 } |
| 9064 |
| 9065 @override |
| 9066 Object visitYieldStatement(YieldStatement node) { |
| 9067 if (node.star != null) { |
| 9068 sink.write("yield* "); |
| 9069 } else { |
| 9070 sink.write("yield "); |
| 9071 } |
| 9072 safelyVisitNode(node.expression); |
| 9073 sink.write(";"); |
| 9074 return null; |
| 9075 } |
| 9076 } |
OLD | NEW |