| Index: pkg/analysis_server/test/services/completion/dart/reference_contributor_test.dart
|
| diff --git a/pkg/analysis_server/test/services/completion/dart/reference_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/reference_contributor_test.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..ddfacc96f597677a05c0a4e8b8794e64432b2fc1
|
| --- /dev/null
|
| +++ b/pkg/analysis_server/test/services/completion/dart/reference_contributor_test.dart
|
| @@ -0,0 +1,99 @@
|
| +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
|
| +// for details. All rights reserved. Use of this source code is governed by a
|
| +// BSD-style license that can be found in the LICENSE file.
|
| +
|
| +library test.services.completion.contributor.dart.reference;
|
| +
|
| +import 'package:analysis_server/plugin/protocol/protocol.dart' as protocol
|
| + show Element, ElementKind;
|
| +import 'package:analysis_server/plugin/protocol/protocol.dart'
|
| + hide Element, ElementKind;
|
| +import 'package:analysis_server/src/provisional/completion/completion_dart.dart';
|
| +import 'package:analysis_server/src/services/completion/dart/reference_contributor.dart';
|
| +import 'package:analysis_server/src/services/completion/dart_completion_manager.dart'
|
| + hide DartCompletionContributor;
|
| +import 'package:test_reflective_loader/test_reflective_loader.dart';
|
| +import 'package:unittest/unittest.dart';
|
| +
|
| +import '../../../utils.dart';
|
| +import 'dart_completion_contributor_test.dart';
|
| +
|
| +main() {
|
| + initializeTestEnvironment();
|
| + defineReflectiveTests(ReferenceContributorTest);
|
| +}
|
| +
|
| +@reflectiveTest
|
| +class ReferenceContributorTest extends DartCompletionContributorTest {
|
| + CompletionSuggestion assertSuggestFunction(String name, String returnType,
|
| + {CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION,
|
| + bool deprecated: false,
|
| + int relevance: DART_RELEVANCE_DEFAULT,
|
| + String importUri}) {
|
| + CompletionSuggestion cs = assertSuggest(name,
|
| + csKind: kind,
|
| + relevance: relevance,
|
| + importUri: importUri,
|
| + isDeprecated: deprecated);
|
| + expect(cs.returnType, returnType != null ? returnType : 'dynamic');
|
| + protocol.Element element = cs.element;
|
| + expect(element, isNotNull);
|
| + expect(element.kind, equals(protocol.ElementKind.FUNCTION));
|
| + expect(element.name, equals(name));
|
| + expect(element.isDeprecated, equals(deprecated));
|
| + String param = element.parameters;
|
| + expect(param, isNotNull);
|
| + expect(param[0], equals('('));
|
| + expect(param[param.length - 1], equals(')'));
|
| + expect(element.returnType,
|
| + equals(returnType != null ? returnType : 'dynamic'));
|
| + assertHasParameterInfo(cs);
|
| + return cs;
|
| + }
|
| +
|
| + CompletionSuggestion assertSuggestLocalFunction(
|
| + String name, String returnType,
|
| + {CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION,
|
| + bool deprecated: false,
|
| + int relevance: DART_RELEVANCE_LOCAL_FUNCTION}) {
|
| + return assertSuggestFunction(name, returnType,
|
| + kind: kind, deprecated: deprecated, relevance: relevance);
|
| + }
|
| +
|
| + @override
|
| + DartCompletionContributor createContributor() {
|
| + return new ReferenceContributor();
|
| + }
|
| +
|
| + test_ArgumentList_InstanceCreationExpression_functionalArg() async {
|
| + // ArgumentList InstanceCreationExpression ExpressionStatement Block
|
| + addSource(
|
| + '/libA.dart',
|
| + '''
|
| +library A;
|
| +class A { A(f()) { } }
|
| +bool hasLength(int expected) { }
|
| +void baz() { }''');
|
| + addTestSource('''
|
| +import 'dart:async';
|
| +import '/libA.dart';
|
| +class B { }
|
| +String bar() => true;
|
| +void main() {new A(^)}''');
|
| + await computeSuggestions();
|
| + assertSuggestLocalFunction('bar', 'String',
|
| + kind: CompletionSuggestionKind.IDENTIFIER);
|
| +// assertSuggestImportedFunction('hasLength', 'bool',
|
| +// kind: CompletionSuggestionKind.IDENTIFIER);
|
| +// assertSuggestImportedFunction('identical', 'bool',
|
| +// kind: CompletionSuggestionKind.IDENTIFIER);
|
| +// assertSuggestLocalClass('B', kind: CompletionSuggestionKind.IDENTIFIER);
|
| +// assertSuggestImportedClass('A',
|
| +// kind: CompletionSuggestionKind.IDENTIFIER);
|
| +// assertSuggestImportedClass('Object',
|
| +// kind: CompletionSuggestionKind.IDENTIFIER);
|
| +// assertNotSuggested('main');
|
| +// assertNotSuggested('baz');
|
| +// assertNotSuggested('print');
|
| + }
|
| +}
|
|
|