Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Unified Diff: pkg/analysis_server/test/services/completion/dart/inherited_contributor_test.dart

Issue 1467023002: step toward new completion API (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address comments and merge Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/test/services/completion/dart/inherited_contributor_test.dart
diff --git a/pkg/analysis_server/test/services/completion/dart/inherited_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/inherited_contributor_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..cda1372bdefb47f19346d16a482f115e4e8fa702
--- /dev/null
+++ b/pkg/analysis_server/test/services/completion/dart/inherited_contributor_test.dart
@@ -0,0 +1,122 @@
+// Copyright (c) 2015, 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.inherited_computer_test;
+
+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/inherited_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() {
+ // Revisit this contributor and these tests
+ // once DartChangeBuilder API has solidified.
+ // initializeTestEnvironment();
+ // defineReflectiveTests(InheritedContributorTest);
+}
+
+@reflectiveTest
+class InheritedContributorTest extends DartCompletionContributorTest {
+ @override
+ DartCompletionContributor createContributor() {
+ return new InheritedContributor();
+ }
+
+ test_fromMultipleSuperclasses() async {
+ addTestSource(r'''
+class A {
+ A suggested1(int x) => null;
+ B suggested2(String y) => null;
+}
+class B extends A {
+ B suggested2(String y) => null;
+ C suggested3([String z]) => null;
+}
+class C extends B {
+ sugg^
+}
+''');
+ await computeSuggestions();
+ _assertOverride('''@override
+ A suggested1(int x) {
+ // TODO: implement suggested1
+ return null;
+ }''');
+ _assertOverride(
+ '''@override\n A suggested1(int x) {\n // TODO: implement suggested1\n return null;\n }''');
+ _assertOverride(
+ '''@override\n B suggested2(String y) {\n // TODO: implement suggested2\n return null;\n }''');
+ _assertOverride(
+ '''@override\n C suggested3([String z]) {\n // TODO: implement suggested3\n return null;\n }''');
+ }
+
+ test_fromPart() async {
+ addSource(
+ '/myLib.dart',
+ '''
+library myLib;
+part '$testFile'
+part '/otherPart.dart'
+class A {
+ A suggested1(int x) => null;
+ B suggested2(String y) => null;
+}
+''');
+ addSource(
+ '/otherPart.dart',
+ '''
+part of myLib;
+class B extends A {
+ B suggested2(String y) => null;
+ C suggested3([String z]) => null;
+}
+''');
+ addTestSource(r'''
+part of myLib;
+class C extends B {
+ sugg^
+}
+''');
+ // assume information for context.getLibrariesContaining has been cached
+ await computeLibrariesContaining();
+ await computeSuggestions();
+ _assertOverride('''@override
+ A suggested1(int x) {
+ // TODO: implement suggested1
+ return null;
+ }''');
+ _assertOverride(
+ '''@override\n A suggested1(int x) {\n // TODO: implement suggested1\n return null;\n }''');
+ _assertOverride(
+ '''@override\n B suggested2(String y) {\n // TODO: implement suggested2\n return null;\n }''');
+ _assertOverride(
+ '''@override\n C suggested3([String z]) {\n // TODO: implement suggested3\n return null;\n }''');
+ }
+
+ CompletionSuggestion _assertOverride(String completion) {
+ CompletionSuggestion cs = getSuggest(
+ completion: completion,
+ csKind: CompletionSuggestionKind.IDENTIFIER,
+ elemKind: null);
+ if (cs == null) {
+ failedCompletion('expected $completion', suggestions);
+ }
+ expect(cs.kind, equals(CompletionSuggestionKind.IDENTIFIER));
+ expect(cs.relevance, equals(DART_RELEVANCE_HIGH));
+ expect(cs.importUri, null);
+// expect(cs.selectionOffset, equals(completion.length));
+// expect(cs.selectionLength, equals(0));
+ expect(cs.isDeprecated, isFalse);
+ expect(cs.isPotential, isFalse);
+ expect(cs.element, isNotNull);
+ return cs;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698