Index: pkg/analyzer/test/src/task/strong/front_end_inference_test.dart |
diff --git a/pkg/analyzer/test/src/task/strong/front_end_inference_test.dart b/pkg/analyzer/test/src/task/strong/front_end_inference_test.dart |
index df8b30f91e681d5f97cc93a1f15281a04cce4281..c9b7209f13b68a936d0a58e9972cce8690cf619d 100644 |
--- a/pkg/analyzer/test/src/task/strong/front_end_inference_test.dart |
+++ b/pkg/analyzer/test/src/task/strong/front_end_inference_test.dart |
@@ -154,12 +154,13 @@ class _FrontEndInferenceTest extends BaseAnalysisDriverTest { |
} |
} |
-/// Instance of [InstrumentationValue] describing a [MethodElement]. |
-class _InstrumentationValueForMethodElement extends fasta.InstrumentationValue { |
- final MethodElement element; |
+/// Instance of [InstrumentationValue] describing an [ExecutableElement]. |
+class _InstrumentationValueForExecutableElement |
+ extends fasta.InstrumentationValue { |
+ final ExecutableElement element; |
final _ElementNamer elementNamer; |
- _InstrumentationValueForMethodElement(this.element, this.elementNamer); |
+ _InstrumentationValueForExecutableElement(this.element, this.elementNamer); |
@override |
String toString() { |
@@ -294,6 +295,14 @@ class _InstrumentationVisitor extends RecursiveAstVisitor<Null> { |
elementNamer = oldElementNamer; |
} |
+ @override |
+ visitDeclaredIdentifier(DeclaredIdentifier node) { |
+ super.visitDeclaredIdentifier(node); |
+ if (node.type == null) { |
+ _recordType(node.identifier.offset, node.element.type); |
+ } |
+ } |
+ |
visitFunctionExpression(FunctionExpression node) { |
super.visitFunctionExpression(node); |
if (node.parent is! FunctionDeclaration) { |
@@ -365,7 +374,10 @@ class _InstrumentationVisitor extends RecursiveAstVisitor<Null> { |
visitMethodInvocation(MethodInvocation node) { |
super.visitMethodInvocation(node); |
- _recordMethodTarget(node.methodName.offset, node.methodName.staticElement); |
+ if (node.target != null) { |
+ _recordMethodTarget( |
+ node.methodName.offset, node.methodName.staticElement); |
+ } |
if (node.typeArguments == null) { |
var inferredTypeArguments = _getInferredFunctionTypeArguments( |
node.function.staticType, |
@@ -378,11 +390,32 @@ class _InstrumentationVisitor extends RecursiveAstVisitor<Null> { |
} |
} |
+ @override |
+ visitPrefixedIdentifier(PrefixedIdentifier node) { |
+ super.visitPrefixedIdentifier(node); |
+ if (node.prefix.staticElement is! PrefixElement && |
+ node.prefix.staticElement is! ClassElement) { |
+ if (node.identifier.inGetterContext()) { |
+ _recordMethodTarget( |
+ node.identifier.offset, node.identifier.staticElement); |
+ } |
+ } |
+ } |
+ |
visitPrefixExpression(PrefixExpression node) { |
super.visitPrefixExpression(node); |
_recordMethodTarget(node.operator.charOffset, node.staticElement); |
} |
+ @override |
+ visitPropertyAccess(PropertyAccess node) { |
+ super.visitPropertyAccess(node); |
+ if (node.propertyName.inGetterContext()) { |
+ _recordMethodTarget( |
+ node.propertyName.offset, node.propertyName.staticElement); |
+ } |
+ } |
+ |
visitSimpleIdentifier(SimpleIdentifier node) { |
super.visitSimpleIdentifier(node); |
Element element = node.staticElement; |
@@ -404,14 +437,6 @@ class _InstrumentationVisitor extends RecursiveAstVisitor<Null> { |
} |
} |
- @override |
- visitDeclaredIdentifier(DeclaredIdentifier node) { |
- super.visitDeclaredIdentifier(node); |
- if (node.type == null) { |
- _recordType(node.identifier.offset, node.element.type); |
- } |
- } |
- |
visitVariableDeclarationList(VariableDeclarationList node) { |
super.visitVariableDeclarationList(node); |
if (node.type == null) { |
@@ -440,9 +465,9 @@ class _InstrumentationVisitor extends RecursiveAstVisitor<Null> { |
} |
void _recordMethodTarget(int offset, Element element) { |
scheglov
2017/05/31 18:40:13
Maybe this method should also be renamed.
Paul Berry
2017/05/31 19:08:33
Good point. Renamed to "_recordTarget".
|
- if (element is MethodElement) { |
+ if (element is ExecutableElement) { |
_instrumentation.record(uri, offset, 'target', |
- new _InstrumentationValueForMethodElement(element, elementNamer)); |
+ new _InstrumentationValueForExecutableElement(element, elementNamer)); |
} |
} |