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 'dart:async'; |
| 8 |
| 9 import 'package:analysis_server/src/protocol.dart'; |
| 10 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; |
| 11 import 'package:analysis_server/src/services/completion/inherited_computer.dart'
; |
| 12 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 13 import 'package:unittest/src/matcher/core_matchers.dart'; |
| 14 import 'package:unittest/unittest.dart'; |
| 15 |
| 16 import '../../utils.dart'; |
| 17 import 'completion_test_util.dart'; |
| 18 |
| 19 main() { |
| 20 initializeTestEnvironment(); |
| 21 defineReflectiveTests(InheritedContributorTest); |
| 22 } |
| 23 |
| 24 @reflectiveTest |
| 25 class InheritedContributorTest extends AbstractCompletionTest { |
| 26 @override |
| 27 void setUpContributor() { |
| 28 contributor = new NewCompletionWrapper(new InheritedContributor()); |
| 29 } |
| 30 |
| 31 test_fromMultipleSuperclasses() { |
| 32 addTestSource(r''' |
| 33 class A { |
| 34 notSuggested() => null; |
| 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 computeFast(); |
| 47 return computeFull((bool result) { |
| 48 _assertOverride( |
| 49 '@override\n A suggested1(int x) {\n // TODO: implement suggested1
\n return null;\n }'); |
| 50 _assertOverride( |
| 51 '''@override\n B suggested2(String y) {\n // TODO: implement sugge
sted2\n return null;\n }'''); |
| 52 _assertOverride( |
| 53 '''@override\n C suggested3([String z]) {\n // TODO: implement sug
gested3\n return null;\n }'''); |
| 54 assertNotSuggested( |
| 55 '''@override\n notSuggested() {\n // TODO: implement notSuggested\
n return null;\n }'''); |
| 56 }); |
| 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', request.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 |