| 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 /// Holds a couple utility functions used at various places in the system. | 5 /// Holds a couple utility functions used at various places in the system. | 
| 6 library dev_compiler.src.utils; | 6 library dev_compiler.src.utils; | 
| 7 | 7 | 
| 8 import 'dart:io'; | 8 import 'dart:io'; | 
| 9 | 9 | 
| 10 import 'package:path/path.dart' as path; | 10 import 'package:path/path.dart' as path; | 
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 380 /// value of that field. | 380 /// value of that field. | 
| 381 /// | 381 /// | 
| 382 /// If the field is missing or is not [expectedType], returns null. | 382 /// If the field is missing or is not [expectedType], returns null. | 
| 383 Object getConstantField( | 383 Object getConstantField( | 
| 384     DartObjectImpl value, String fieldName, DartType expectedType) { | 384     DartObjectImpl value, String fieldName, DartType expectedType) { | 
| 385   if (value == null) return null; | 385   if (value == null) return null; | 
| 386   var f = value.fields[fieldName]; | 386   var f = value.fields[fieldName]; | 
| 387   return (f == null || f.type != expectedType) ? null : f.value; | 387   return (f == null || f.type != expectedType) ? null : f.value; | 
| 388 } | 388 } | 
| 389 | 389 | 
| 390 InterfaceType fillDynamicTypeArgs(InterfaceType t, TypeProvider types) => | 390 ParameterizedType fillDynamicTypeArgs(ParameterizedType t, TypeProvider types) { | 
| 391     t.substitute4(new List.filled(t.typeArguments.length, types.dynamicType)); | 391   var dyn = new List.filled(t.typeArguments.length, types.dynamicType); | 
|  | 392   return t.substitute2(dyn, t.typeArguments); | 
|  | 393 } | 
| 392 | 394 | 
| 393 /// Similar to [SimpleIdentifier] inGetterContext, inSetterContext, and | 395 /// Similar to [SimpleIdentifier] inGetterContext, inSetterContext, and | 
| 394 /// inDeclarationContext, this method returns true if [node] is used in an | 396 /// inDeclarationContext, this method returns true if [node] is used in an | 
| 395 /// invocation context such as a MethodInvocation. | 397 /// invocation context such as a MethodInvocation. | 
| 396 bool inInvocationContext(SimpleIdentifier node) { | 398 bool inInvocationContext(SimpleIdentifier node) { | 
| 397   var parent = node.parent; | 399   var parent = node.parent; | 
| 398   return parent is MethodInvocation && parent.methodName == node; | 400   return parent is MethodInvocation && parent.methodName == node; | 
| 399 } | 401 } | 
| 400 | 402 | 
| 401 // TODO(vsm): Move this onto the appropriate class.  Ideally, we'd attach | 403 // TODO(vsm): Move this onto the appropriate class.  Ideally, we'd attach | 
| (...skipping 28 matching lines...) Expand all  Loading... | 
| 430 InterfaceType findSupertype(InterfaceType type, bool match(InterfaceType t)) { | 432 InterfaceType findSupertype(InterfaceType type, bool match(InterfaceType t)) { | 
| 431   for (var m in type.mixins.reversed) { | 433   for (var m in type.mixins.reversed) { | 
| 432     if (match(m)) return m; | 434     if (match(m)) return m; | 
| 433   } | 435   } | 
| 434   var s = type.superclass; | 436   var s = type.superclass; | 
| 435   if (s == null) return null; | 437   if (s == null) return null; | 
| 436 | 438 | 
| 437   if (match(s)) return type; | 439   if (match(s)) return type; | 
| 438   return findSupertype(s, match); | 440   return findSupertype(s, match); | 
| 439 } | 441 } | 
| OLD | NEW | 
|---|