OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library test.services.completion.inherited_computer_test; |
| 6 |
| 7 import 'package:analysis_server/plugin/protocol/protocol.dart' as protocol |
| 8 show Element, ElementKind; |
| 9 import 'package:analysis_server/plugin/protocol/protocol.dart' |
| 10 hide Element, ElementKind; |
| 11 import 'package:analysis_server/src/provisional/completion/completion_dart.dart'
; |
| 12 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart' |
| 13 hide DartCompletionContributor; |
| 14 import 'package:analysis_server/src/services/completion/dart/inherited_contribut
or.dart'; |
| 15 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 16 import 'package:unittest/unittest.dart'; |
| 17 |
| 18 import '../../../utils.dart'; |
| 19 import 'dart_completion_contributor_test.dart'; |
| 20 |
| 21 main() { |
| 22 initializeTestEnvironment(); |
| 23 defineReflectiveTests(InheritedContributorTest); |
| 24 } |
| 25 |
| 26 @reflectiveTest |
| 27 class InheritedContributorTest extends DartCompletionContributorTest { |
| 28 @override |
| 29 DartCompletionContributor createContributor() { |
| 30 return new InheritedContributor(); |
| 31 } |
| 32 |
| 33 test_fromMultipleSuperclasses() async { |
| 34 addTestSource(r''' |
| 35 class A { |
| 36 notSuggested() => null; |
| 37 A suggested1(int x) => null; |
| 38 B suggested2(String y) => null; |
| 39 } |
| 40 class B extends A { |
| 41 B suggested2(String y) => null; |
| 42 C suggested3([String z]) => null; |
| 43 } |
| 44 class C extends B { |
| 45 sugg^ |
| 46 } |
| 47 '''); |
| 48 await computeSuggestions(); |
| 49 _assertOverride( |
| 50 '@override\n A suggested1(int x) {\n // TODO: implement suggested1\n
return null;\n }'); |
| 51 _assertOverride( |
| 52 '''@override\n B suggested2(String y) {\n // TODO: implement suggest
ed2\n return null;\n }'''); |
| 53 _assertOverride( |
| 54 '''@override\n C suggested3([String z]) {\n // TODO: implement sugge
sted3\n return null;\n }'''); |
| 55 assertNotSuggested( |
| 56 '''@override\n notSuggested() {\n // TODO: implement notSuggested\n
return null;\n }'''); |
| 57 } |
| 58 |
| 59 CompletionSuggestion _assertOverride(String completion) { |
| 60 CompletionSuggestion cs = getSuggest( |
| 61 completion: completion, |
| 62 csKind: CompletionSuggestionKind.IDENTIFIER, |
| 63 elemKind: null); |
| 64 if (cs == null) { |
| 65 failedCompletion('expected $completion', suggestions); |
| 66 } |
| 67 expect(cs.kind, equals(CompletionSuggestionKind.IDENTIFIER)); |
| 68 expect(cs.relevance, equals(DART_RELEVANCE_HIGH)); |
| 69 expect(cs.importUri, null); |
| 70 // expect(cs.selectionOffset, equals(completion.length)); |
| 71 // expect(cs.selectionLength, equals(0)); |
| 72 expect(cs.isDeprecated, isFalse); |
| 73 expect(cs.isPotential, isFalse); |
| 74 expect(cs.element, isNotNull); |
| 75 return cs; |
| 76 } |
| 77 } |
OLD | NEW |