| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 js; | 5 library js; |
| 6 | 6 |
| 7 import 'package:js_ast/js_ast.dart'; | 7 import 'package:js_ast/js_ast.dart'; |
| 8 export 'package:js_ast/js_ast.dart'; | 8 export 'package:js_ast/js_ast.dart'; |
| 9 | 9 |
| 10 import '../common.dart'; | 10 import '../common.dart'; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 final Node tree; | 130 final Node tree; |
| 131 final Compiler _compiler; | 131 final Compiler _compiler; |
| 132 final bool _protectForEval; | 132 final bool _protectForEval; |
| 133 LiteralString _cachedLiteral; | 133 LiteralString _cachedLiteral; |
| 134 | 134 |
| 135 Iterable<Node> get containedNodes => [tree]; | 135 Iterable<Node> get containedNodes => [tree]; |
| 136 | 136 |
| 137 /// A [js.Literal] that represents the string result of unparsing [ast]. | 137 /// A [js.Literal] that represents the string result of unparsing [ast]. |
| 138 /// | 138 /// |
| 139 /// When its string [value] is requested, the node pretty-prints the given | 139 /// When its string [value] is requested, the node pretty-prints the given |
| 140 /// [ast] and, if [protectForEval] is true, wraps the resulting | 140 /// [ast] and, if [protectForEval] is true, wraps the resulting string in |
| 141 /// string in parenthesis. The result is also escaped. | 141 /// parenthesis. The result is also escaped. |
| 142 UnparsedNode(this.tree, this._compiler, this._protectForEval); | 142 UnparsedNode(this.tree, this._compiler, this._protectForEval); |
| 143 | 143 |
| 144 LiteralString get _literal { | 144 LiteralString get _literal { |
| 145 if (_cachedLiteral == null) { | 145 if (_cachedLiteral == null) { |
| 146 String text = prettyPrint(tree, _compiler).getText(); | 146 String text = prettyPrint(tree, _compiler).getText(); |
| 147 if (_protectForEval) { | 147 if (_protectForEval) { |
| 148 if (tree is Fun) text = '($text)'; | 148 if (tree is Fun) text = '($text)'; |
| 149 if (tree is LiteralExpression) { | 149 if (tree is LiteralExpression) { |
| 150 LiteralExpression literalExpression = tree; | 150 LiteralExpression literalExpression = tree; |
| 151 String template = literalExpression.template; | 151 String template = literalExpression.template; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 179 } | 179 } |
| 180 if (node is PropertyAccess) { | 180 if (node is PropertyAccess) { |
| 181 PropertyAccess access = node; | 181 PropertyAccess access = node; |
| 182 if (access.receiver is InterpolatedExpression) { | 182 if (access.receiver is InterpolatedExpression) { |
| 183 InterpolatedExpression hole = access.receiver; | 183 InterpolatedExpression hole = access.receiver; |
| 184 return hole.isPositional && hole.nameOrPosition == 0; | 184 return hole.isPositional && hole.nameOrPosition == 0; |
| 185 } | 185 } |
| 186 } | 186 } |
| 187 return false; | 187 return false; |
| 188 } | 188 } |
| OLD | NEW |