| 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.dart.inherited_computer_test; | |
| 6 | |
| 7 import 'package:analysis_server/plugin/protocol/protocol.dart' | |
| 8 hide Element, ElementKind; | |
| 9 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
dart'; | |
| 10 import 'package:analysis_server/src/services/completion/dart/inherited_contribut
or.dart'; | |
| 11 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart' | |
| 12 hide DartCompletionContributor; | |
| 13 import 'package:test_reflective_loader/test_reflective_loader.dart'; | |
| 14 import 'package:unittest/unittest.dart'; | |
| 15 | |
| 16 import 'completion_contributor_util.dart'; | |
| 17 | |
| 18 main() { | |
| 19 // Revisit this contributor and these tests | |
| 20 // once DartChangeBuilder API has solidified. | |
| 21 // initializeTestEnvironment(); | |
| 22 // defineReflectiveTests(InheritedContributorTest); | |
| 23 } | |
| 24 | |
| 25 @reflectiveTest | |
| 26 class InheritedContributorTest extends DartCompletionContributorTest { | |
| 27 @override | |
| 28 DartCompletionContributor createContributor() { | |
| 29 return new InheritedContributor(); | |
| 30 } | |
| 31 | |
| 32 test_fromMultipleSuperclasses() async { | |
| 33 addTestSource(r''' | |
| 34 class A { | |
| 35 A suggested1(int x) => null; | |
| 36 B suggested2(String y) => null; | |
| 37 } | |
| 38 class B extends A { | |
| 39 B suggested2(String y) => null; | |
| 40 C suggested3([String z]) => null; | |
| 41 } | |
| 42 class C extends B { | |
| 43 sugg^ | |
| 44 } | |
| 45 '''); | |
| 46 await computeSuggestions(); | |
| 47 _assertOverride('''@override | |
| 48 A suggested1(int x) { | |
| 49 // TODO: implement suggested1 | |
| 50 return null; | |
| 51 }'''); | |
| 52 _assertOverride( | |
| 53 '''@override\n A suggested1(int x) {\n // TODO: implement suggested1
\n return null;\n }'''); | |
| 54 _assertOverride( | |
| 55 '''@override\n B suggested2(String y) {\n // TODO: implement suggest
ed2\n return null;\n }'''); | |
| 56 _assertOverride( | |
| 57 '''@override\n C suggested3([String z]) {\n // TODO: implement sugge
sted3\n return null;\n }'''); | |
| 58 } | |
| 59 | |
| 60 test_fromPart() async { | |
| 61 addSource( | |
| 62 '/myLib.dart', | |
| 63 ''' | |
| 64 library myLib; | |
| 65 part '$testFile' | |
| 66 part '/otherPart.dart' | |
| 67 class A { | |
| 68 A suggested1(int x) => null; | |
| 69 B suggested2(String y) => null; | |
| 70 } | |
| 71 '''); | |
| 72 addSource( | |
| 73 '/otherPart.dart', | |
| 74 ''' | |
| 75 part of myLib; | |
| 76 class B extends A { | |
| 77 B suggested2(String y) => null; | |
| 78 C suggested3([String z]) => null; | |
| 79 } | |
| 80 '''); | |
| 81 addTestSource(r''' | |
| 82 part of myLib; | |
| 83 class C extends B { | |
| 84 sugg^ | |
| 85 } | |
| 86 '''); | |
| 87 // assume information for context.getLibrariesContaining has been cached | |
| 88 await computeLibrariesContaining(); | |
| 89 await computeSuggestions(); | |
| 90 _assertOverride('''@override | |
| 91 A suggested1(int x) { | |
| 92 // TODO: implement suggested1 | |
| 93 return null; | |
| 94 }'''); | |
| 95 _assertOverride( | |
| 96 '''@override\n A suggested1(int x) {\n // TODO: implement suggested1
\n return null;\n }'''); | |
| 97 _assertOverride( | |
| 98 '''@override\n B suggested2(String y) {\n // TODO: implement suggest
ed2\n return null;\n }'''); | |
| 99 _assertOverride( | |
| 100 '''@override\n C suggested3([String z]) {\n // TODO: implement sugge
sted3\n return null;\n }'''); | |
| 101 } | |
| 102 | |
| 103 CompletionSuggestion _assertOverride(String completion) { | |
| 104 CompletionSuggestion cs = getSuggest( | |
| 105 completion: completion, | |
| 106 csKind: CompletionSuggestionKind.IDENTIFIER, | |
| 107 elemKind: null); | |
| 108 if (cs == null) { | |
| 109 failedCompletion('expected $completion', suggestions); | |
| 110 } | |
| 111 expect(cs.kind, equals(CompletionSuggestionKind.IDENTIFIER)); | |
| 112 expect(cs.relevance, equals(DART_RELEVANCE_HIGH)); | |
| 113 expect(cs.importUri, null); | |
| 114 // expect(cs.selectionOffset, equals(completion.length)); | |
| 115 // expect(cs.selectionLength, equals(0)); | |
| 116 expect(cs.isDeprecated, isFalse); | |
| 117 expect(cs.isPotential, isFalse); | |
| 118 expect(cs.element, isNotNull); | |
| 119 return cs; | |
| 120 } | |
| 121 } | |
| OLD | NEW |