| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 /// Properties that result from Strong Mode analysis on an AST. |
| 6 /// |
| 7 /// These properties are not public, but provided by use of back-ends such as |
| 8 /// Dart Dev Compiler. |
| 9 |
| 10 import 'package:analyzer/analyzer.dart'; |
| 11 import 'package:analyzer/dart/element/type.dart'; |
| 12 |
| 13 const String _implicitAssignmentCast = '_implicitAssignmentCast'; |
| 14 const String _implicitCast = '_implicitCast'; |
| 15 const String _hasImplicitCasts = '_hasImplicitCasts'; |
| 16 const String _isDynamicInvoke = '_isDynamicInvoke'; |
| 17 |
| 18 /// True if this compilation unit has any implicit casts, otherwise false. |
| 19 /// |
| 20 /// See also [getImplicitCast]. |
| 21 bool hasImplicitCasts(CompilationUnit node) { |
| 22 return node.getProperty/*<bool>*/(_hasImplicitCasts) ?? false; |
| 23 } |
| 24 |
| 25 /// Sets [hasImplicitCasts] property for this compilation unit. |
| 26 void setHasImplicitCasts(CompilationUnit node, bool value) { |
| 27 node.setProperty(_hasImplicitCasts, value == true ? true : null); |
| 28 } |
| 29 |
| 30 /// If this expression has an implicit cast, returns the type it is coerced to, |
| 31 /// otherwise returns null. |
| 32 DartType getImplicitCast(Expression node) { |
| 33 return node.getProperty/*<DartType>*/(_implicitCast); |
| 34 } |
| 35 |
| 36 /// Sets the result of [getImplicitCast] for this node. |
| 37 void setImplicitCast(Expression node, DartType type) { |
| 38 node.setProperty(_implicitCast, type); |
| 39 } |
| 40 |
| 41 /// If this op-assign has an implicit cast on the assignment, returns the type |
| 42 /// it is coerced to, otherwise returns null. |
| 43 DartType getImplicitAssignmentCast(Expression node) { |
| 44 return node.getProperty/*<DartType>*/(_implicitAssignmentCast); |
| 45 } |
| 46 |
| 47 /// Sets the result of [getImplicitAssignmentCast] for this node. |
| 48 void setImplicitAssignmentCast(Expression node, DartType type) { |
| 49 node.setProperty(_implicitAssignmentCast, type); |
| 50 } |
| 51 |
| 52 /// True if this node is a dynamic operation that requires dispatch and/or |
| 53 /// checking at runtime. |
| 54 bool isDynamicInvoke(Expression node) { |
| 55 return node.getProperty/*<bool>*/(_isDynamicInvoke) ?? false; |
| 56 } |
| 57 |
| 58 /// Sets [isDynamicInvoke] property for this expression |
| 59 void setIsDynamicInvoke(Expression node, bool value) { |
| 60 node.setProperty(_isDynamicInvoke, value == true ? true : null); |
| 61 } |
| OLD | NEW |