| 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; |
| 11 import 'package:analyzer/src/generated/ast.dart' | 11 import 'package:analyzer/src/generated/ast.dart' |
| 12 show | 12 show |
| 13 ImportDirective, | 13 ImportDirective, |
| 14 ExportDirective, | 14 ExportDirective, |
| 15 PartDirective, | 15 PartDirective, |
| 16 CompilationUnit, | 16 CompilationUnit, |
| 17 Identifier, | 17 Identifier, |
| 18 AnnotatedNode, | 18 AnnotatedNode, |
| 19 AstNode, | 19 AstNode, |
| 20 Expression, | 20 Expression, |
| 21 SimpleIdentifier; | 21 SimpleIdentifier, |
| 22 MethodInvocation; |
| 22 import 'package:analyzer/src/generated/constant.dart' show DartObjectImpl; | 23 import 'package:analyzer/src/generated/constant.dart' show DartObjectImpl; |
| 23 import 'package:analyzer/src/generated/element.dart'; | 24 import 'package:analyzer/src/generated/element.dart'; |
| 24 import 'package:analyzer/src/generated/engine.dart' | 25 import 'package:analyzer/src/generated/engine.dart' |
| 25 show ParseDartTask, AnalysisContext; | 26 show ParseDartTask, AnalysisContext; |
| 26 import 'package:analyzer/src/generated/resolver.dart' show TypeProvider; | 27 import 'package:analyzer/src/generated/resolver.dart' show TypeProvider; |
| 27 import 'package:analyzer/src/generated/source.dart' show Source; | 28 import 'package:analyzer/src/generated/source.dart' show Source; |
| 28 import 'package:analyzer/analyzer.dart' show parseDirectives; | 29 import 'package:analyzer/analyzer.dart' show parseDirectives; |
| 29 import 'package:crypto/crypto.dart' show CryptoUtils, MD5; | 30 import 'package:crypto/crypto.dart' show CryptoUtils, MD5; |
| 30 import 'package:source_span/source_span.dart'; | 31 import 'package:source_span/source_span.dart'; |
| 31 import 'package:yaml/yaml.dart'; | 32 import 'package:yaml/yaml.dart'; |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 /// If the field is missing or is not [expectedType], returns null. | 382 /// If the field is missing or is not [expectedType], returns null. |
| 382 Object getConstantField( | 383 Object getConstantField( |
| 383 DartObjectImpl value, String fieldName, DartType expectedType) { | 384 DartObjectImpl value, String fieldName, DartType expectedType) { |
| 384 if (value == null) return null; | 385 if (value == null) return null; |
| 385 var f = value.fields[fieldName]; | 386 var f = value.fields[fieldName]; |
| 386 return (f == null || f.type != expectedType) ? null : f.value; | 387 return (f == null || f.type != expectedType) ? null : f.value; |
| 387 } | 388 } |
| 388 | 389 |
| 389 InterfaceType fillDynamicTypeArgs(InterfaceType t, TypeProvider types) => | 390 InterfaceType fillDynamicTypeArgs(InterfaceType t, TypeProvider types) => |
| 390 t.substitute4(new List.filled(t.typeArguments.length, types.dynamicType)); | 391 t.substitute4(new List.filled(t.typeArguments.length, types.dynamicType)); |
| 392 |
| 393 /// Similar to [SimpleIdentifier] inGetterContext, inSetterContext, and |
| 394 /// inDeclarationContext, this method returns true if [node] is used in an |
| 395 /// invocation context such as a MethodInvocation. |
| 396 bool inInvocationContext(SimpleIdentifier node) { |
| 397 var parent = node.parent; |
| 398 return parent is MethodInvocation && parent.methodName == node; |
| 399 } |
| OLD | NEW |