OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:convert'; | 6 import 'dart:convert'; |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 | 8 |
9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
10 import 'package:analyzer/dart/ast/visitor.dart'; | 10 import 'package:analyzer/dart/ast/visitor.dart'; |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 DartType type = node.staticType; | 269 DartType type = node.staticType; |
270 if (type is InterfaceType) { | 270 if (type is InterfaceType) { |
271 _recordTypeArguments(node.offset, type.typeArguments); | 271 _recordTypeArguments(node.offset, type.typeArguments); |
272 } | 272 } |
273 } | 273 } |
274 } | 274 } |
275 | 275 |
276 visitSimpleIdentifier(SimpleIdentifier node) { | 276 visitSimpleIdentifier(SimpleIdentifier node) { |
277 super.visitSimpleIdentifier(node); | 277 super.visitSimpleIdentifier(node); |
278 Element element = node.staticElement; | 278 Element element = node.staticElement; |
279 if (element is LocalVariableElement && node.inGetterContext()) { | 279 void recordPromotions(DartType elementType) { |
280 int offset = node.offset; | 280 if (node.inGetterContext() && !node.inDeclarationContext()) { |
281 DartType type = node.staticType; | 281 int offset = node.offset; |
282 if (identical(type, element.type)) { | 282 DartType type = node.staticType; |
283 _instrumentation.record(uri, offset, 'promotedType', | 283 if (identical(type, elementType)) { |
284 const fasta.InstrumentationValueLiteral('none')); | 284 _instrumentation.record(uri, offset, 'promotedType', |
285 } else { | 285 const fasta.InstrumentationValueLiteral('none')); |
286 _instrumentation.record(uri, offset, 'promotedType', | 286 } else { |
287 new _InstrumentationValueForType(type)); | 287 _instrumentation.record(uri, offset, 'promotedType', |
| 288 new _InstrumentationValueForType(type)); |
| 289 } |
288 } | 290 } |
289 } | 291 } |
| 292 |
| 293 if (element is LocalVariableElement) { |
| 294 recordPromotions(element.type); |
| 295 } else if (element is ParameterElement) { |
| 296 recordPromotions(element.type); |
| 297 } |
290 } | 298 } |
291 | 299 |
292 visitVariableDeclarationList(VariableDeclarationList node) { | 300 visitVariableDeclarationList(VariableDeclarationList node) { |
293 super.visitVariableDeclarationList(node); | 301 super.visitVariableDeclarationList(node); |
294 if (node.type == null) { | 302 if (node.type == null) { |
295 for (VariableDeclaration variable in node.variables) { | 303 for (VariableDeclaration variable in node.variables) { |
296 VariableElement element = variable.element; | 304 VariableElement element = variable.element; |
297 if (element is LocalVariableElement) { | 305 if (element is LocalVariableElement) { |
298 _recordType(variable.name.offset, element.type); | 306 _recordType(variable.name.offset, element.type); |
299 } else { | 307 } else { |
(...skipping 11 matching lines...) Expand all Loading... |
311 void _recordType(int offset, DartType type) { | 319 void _recordType(int offset, DartType type) { |
312 _instrumentation.record( | 320 _instrumentation.record( |
313 uri, offset, 'type', new _InstrumentationValueForType(type)); | 321 uri, offset, 'type', new _InstrumentationValueForType(type)); |
314 } | 322 } |
315 | 323 |
316 void _recordTypeArguments(int offset, List<DartType> typeArguments) { | 324 void _recordTypeArguments(int offset, List<DartType> typeArguments) { |
317 _instrumentation.record(uri, offset, 'typeArgs', | 325 _instrumentation.record(uri, offset, 'typeArgs', |
318 new _InstrumentationValueForTypeArgs(typeArguments)); | 326 new _InstrumentationValueForTypeArgs(typeArguments)); |
319 } | 327 } |
320 } | 328 } |
OLD | NEW |