Index: lib/src/utils.dart |
diff --git a/lib/src/utils.dart b/lib/src/utils.dart |
index 314c5fb5e0eadfbbc24aa04be6dd84c6cc3f3d54..5bafdb3db1e9dff0c50c72223955f98f6d598246 100644 |
--- a/lib/src/utils.dart |
+++ b/lib/src/utils.dart |
@@ -18,7 +18,8 @@ import 'package:analyzer/src/generated/ast.dart' |
AnnotatedNode, |
AstNode, |
Expression, |
- SimpleIdentifier; |
+ SimpleIdentifier, |
+ MethodInvocation; |
import 'package:analyzer/src/generated/constant.dart' show DartObjectImpl; |
import 'package:analyzer/src/generated/element.dart'; |
import 'package:analyzer/src/generated/engine.dart' |
@@ -388,3 +389,11 @@ Object getConstantField( |
InterfaceType fillDynamicTypeArgs(InterfaceType t, TypeProvider types) => |
t.substitute4(new List.filled(t.typeArguments.length, types.dynamicType)); |
+ |
+/// Similar to [SimpleIdentifier] inGetterContext, inSetterContext, and |
+/// inDeclarationContext, this method returns true if [node] is used in an |
+/// invocation context such as a MethodInvocation. |
+bool inInvocationContext(SimpleIdentifier node) { |
+ var parent = node.parent; |
+ return parent is MethodInvocation && parent.methodName == node; |
+} |