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 import 'package:analyzer/analyzer.dart' as analyzer; | 5 import 'package:analyzer/analyzer.dart' as analyzer; |
6 import 'package:analyzer/dart/ast/ast.dart'; | 6 import 'package:analyzer/dart/ast/ast.dart'; |
7 import 'package:analyzer/dart/element/type.dart' show DartType; | 7 import 'package:analyzer/dart/element/type.dart' show DartType; |
8 import 'package:analyzer/src/dart/ast/ast.dart' show FunctionBodyImpl; | 8 import 'package:analyzer/src/dart/ast/ast.dart' show FunctionBodyImpl; |
9 import 'package:analyzer/src/dart/ast/utilities.dart' show NodeReplacer; | 9 import 'package:analyzer/src/dart/ast/utilities.dart' show NodeReplacer; |
10 import 'package:analyzer/src/dart/element/type.dart' show DynamicTypeImpl; | 10 import 'package:analyzer/src/dart/element/type.dart' show DynamicTypeImpl; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 // We use an empty name in the AST, because the JS code generator only cares | 109 // We use an empty name in the AST, because the JS code generator only cares |
110 // about the target type. It does not look at the AST name. | 110 // about the target type. It does not look at the AST name. |
111 var typeName = new TypeName(AstBuilder.identifierFromString(''), null); | 111 var typeName = new TypeName(AstBuilder.identifierFromString(''), null); |
112 typeName.type = toType; | 112 typeName.type = toType; |
113 var cast = AstBuilder.asExpression(e, typeName); | 113 var cast = AstBuilder.asExpression(e, typeName); |
114 cast.staticType = toType; | 114 cast.staticType = toType; |
115 return cast; | 115 return cast; |
116 } | 116 } |
117 | 117 |
118 /*=T*/ _clone/*<T extends AstNode>*/(/*=T*/ node) { | 118 /*=T*/ _clone/*<T extends AstNode>*/(/*=T*/ node) { |
119 var copy = node.accept(cloner); | 119 var copy = node.accept(cloner) as dynamic/*=T*/; |
120 ResolutionCopier.copyResolutionData(node, copy); | 120 ResolutionCopier.copyResolutionData(node, copy); |
121 return copy; | 121 return copy; |
122 } | 122 } |
123 } | 123 } |
124 | 124 |
125 class _TreeCloner extends analyzer.AstCloner { | 125 class _TreeCloner extends analyzer.AstCloner { |
126 void _cloneProperties(AstNode clone, AstNode node) { | 126 void _cloneProperties(AstNode clone, AstNode node) { |
127 if (clone != null) { | 127 if (clone != null) { |
128 CoercionInfo.set(clone, CoercionInfo.get(node)); | 128 CoercionInfo.set(clone, CoercionInfo.get(node)); |
129 DynamicInvoke.set(clone, DynamicInvoke.get(node)); | 129 DynamicInvoke.set(clone, DynamicInvoke.get(node)); |
130 } | 130 } |
131 } | 131 } |
132 | 132 |
133 @override | 133 @override |
134 AstNode cloneNode(AstNode node) { | 134 /*=E*/ cloneNode/*<E extends AstNode>*/(/*=E*/ node) { |
135 var clone = super.cloneNode(node); | 135 var clone = super.cloneNode(node); |
136 _cloneProperties(clone, node); | 136 _cloneProperties(clone, node); |
137 return clone; | 137 return clone; |
138 } | 138 } |
139 | 139 |
140 @override | 140 @override |
141 List cloneNodeList(List list) { | 141 List/*<E>*/ cloneNodeList/*<E extends AstNode>*/(NodeList/*<E>*/ list) { |
142 var clone = super.cloneNodeList(list); | 142 var clone = super.cloneNodeList(list); |
143 for (int i = 0, len = list.length; i < len; i++) { | 143 for (int i = 0, len = list.length; i < len; i++) { |
144 _cloneProperties(clone[i], list[i]); | 144 _cloneProperties(clone[i], list[i]); |
145 } | 145 } |
146 return clone; | 146 return clone; |
147 } | 147 } |
148 | 148 |
149 // TODO(jmesserly): ResolutionCopier is not copying this yet. | 149 // TODO(jmesserly): ResolutionCopier is not copying this yet. |
150 @override | 150 @override |
151 BlockFunctionBody visitBlockFunctionBody(BlockFunctionBody node) { | 151 BlockFunctionBody visitBlockFunctionBody(BlockFunctionBody node) { |
(...skipping 14 matching lines...) Expand all Loading... |
166 | 166 |
167 // TODO(jmesserly): workaround for | 167 // TODO(jmesserly): workaround for |
168 // https://github.com/dart-lang/sdk/issues/26368 | 168 // https://github.com/dart-lang/sdk/issues/26368 |
169 @override | 169 @override |
170 TypeName visitTypeName(TypeName node) { | 170 TypeName visitTypeName(TypeName node) { |
171 var clone = super.visitTypeName(node); | 171 var clone = super.visitTypeName(node); |
172 clone.type = node.type; | 172 clone.type = node.type; |
173 return clone; | 173 return clone; |
174 } | 174 } |
175 } | 175 } |
OLD | NEW |