| 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 55be398a41c848fbaa69a66ec9c1d4ee53d2eba4..a221ac57236950d092a9fd7ee33386be0bed436f 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
|
| @@ -30,12 +30,37 @@ main() {
|
| defineReflectiveSuite(() {
|
| defineReflectiveTests(RunFrontEndInferenceTest);
|
| });
|
| - }, timeout: new Timeout(const Duration(seconds: 60)));
|
| + }, timeout: new Timeout(const Duration(seconds: 120)));
|
| }
|
|
|
| /// Set this to `true` to cause expectation comments to be updated.
|
| const bool fixProblems = false;
|
|
|
| +void _appendElementName(StringBuffer buffer, Element element) {
|
| + // Synthetic FunctionElement(s) don't have a name or enclosing library.
|
| + if (element.isSynthetic && element is FunctionElement) {
|
| + return;
|
| + }
|
| +
|
| + LibraryElement library = element.library;
|
| + if (library == null) {
|
| + throw new StateError('Unexpected element without library: $element');
|
| + }
|
| + String libraryName = library.name;
|
| +
|
| + String name = element.name ?? '';
|
| + if (libraryName != 'dart.core' &&
|
| + libraryName != 'dart.async' &&
|
| + libraryName != 'test') {
|
| + buffer.write('$libraryName::');
|
| + }
|
| + var enclosing = element.enclosingElement;
|
| + if (enclosing is ClassElement) {
|
| + buffer.write('${enclosing.name}::');
|
| + }
|
| + buffer.write('$name');
|
| +}
|
| +
|
| @reflectiveTest
|
| class RunFrontEndInferenceTest {
|
| test_run() async {
|
| @@ -115,6 +140,20 @@ class _FrontEndInferenceTest extends BaseAnalysisDriverTest {
|
| }
|
| }
|
|
|
| +/// Instance of [InstrumentationValue] describing a [MethodElement].
|
| +class _InstrumentationValueForMethodElement extends fasta.InstrumentationValue {
|
| + final MethodElement element;
|
| +
|
| + _InstrumentationValueForMethodElement(this.element);
|
| +
|
| + @override
|
| + String toString() {
|
| + StringBuffer buffer = new StringBuffer();
|
| + _appendElementName(buffer, element);
|
| + return buffer.toString();
|
| + }
|
| +}
|
| +
|
| /**
|
| * Instance of [InstrumentationValue] describing a [DartType].
|
| */
|
| @@ -130,28 +169,6 @@ class _InstrumentationValueForType extends fasta.InstrumentationValue {
|
| return buffer.toString();
|
| }
|
|
|
| - void _appendElementName(StringBuffer buffer, Element element) {
|
| - // Synthetic FunctionElement(s) don't have a name or enclosing library.
|
| - if (element.isSynthetic && element is FunctionElement) {
|
| - return;
|
| - }
|
| -
|
| - LibraryElement library = element.library;
|
| - if (library == null) {
|
| - throw new StateError('Unexpected element without library: $element');
|
| - }
|
| - String libraryName = library.name;
|
| -
|
| - String name = element.name ?? '';
|
| - if (libraryName != 'dart.core' &&
|
| - libraryName != 'dart.async' &&
|
| - libraryName != 'test') {
|
| - buffer.write('$libraryName::$name');
|
| - } else {
|
| - buffer.write('$name');
|
| - }
|
| - }
|
| -
|
| void _appendList<T>(StringBuffer buffer, String open, String close,
|
| List<T> items, String separator, writeItem(T item),
|
| {bool includeEmpty: false}) {
|
| @@ -224,6 +241,11 @@ class _InstrumentationVisitor extends RecursiveAstVisitor<Null> {
|
|
|
| _InstrumentationVisitor(this._instrumentation, this.uri);
|
|
|
| + visitBinaryExpression(BinaryExpression node) {
|
| + super.visitBinaryExpression(node);
|
| + _recordMethodTarget(node.operator.charOffset, node.staticElement);
|
| + }
|
| +
|
| visitFunctionExpression(FunctionExpression node) {
|
| super.visitFunctionExpression(node);
|
| if (node.parent is! FunctionDeclaration) {
|
| @@ -242,6 +264,11 @@ class _InstrumentationVisitor extends RecursiveAstVisitor<Null> {
|
| }
|
| }
|
|
|
| + visitIndexExpression(IndexExpression node) {
|
| + super.visitIndexExpression(node);
|
| + _recordMethodTarget(node.leftBracket.charOffset, node.staticElement);
|
| + }
|
| +
|
| visitInstanceCreationExpression(InstanceCreationExpression node) {
|
| super.visitInstanceCreationExpression(node);
|
| DartType type = node.staticType;
|
| @@ -275,6 +302,7 @@ class _InstrumentationVisitor extends RecursiveAstVisitor<Null> {
|
|
|
| visitMethodInvocation(MethodInvocation node) {
|
| super.visitMethodInvocation(node);
|
| + _recordMethodTarget(node.methodName.offset, node.methodName.staticElement);
|
| if (node.typeArguments == null) {
|
| var inferredTypeArguments = _getInferredFunctionTypeArguments(
|
| node.function.staticType,
|
| @@ -287,6 +315,11 @@ class _InstrumentationVisitor extends RecursiveAstVisitor<Null> {
|
| }
|
| }
|
|
|
| + visitPrefixExpression(PrefixExpression node) {
|
| + super.visitPrefixExpression(node);
|
| + _recordMethodTarget(node.operator.charOffset, node.staticElement);
|
| + }
|
| +
|
| visitSimpleIdentifier(SimpleIdentifier node) {
|
| super.visitSimpleIdentifier(node);
|
| Element element = node.staticElement;
|
| @@ -338,6 +371,13 @@ class _InstrumentationVisitor extends RecursiveAstVisitor<Null> {
|
| }
|
| }
|
|
|
| + void _recordMethodTarget(int offset, Element element) {
|
| + if (element is MethodElement) {
|
| + _instrumentation.record(uri, offset, 'target',
|
| + new _InstrumentationValueForMethodElement(element));
|
| + }
|
| + }
|
| +
|
| void _recordTopType(int offset, DartType type) {
|
| _instrumentation.record(
|
| uri, offset, 'topType', new _InstrumentationValueForType(type));
|
|
|