OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library test.services.completion.invocation; | 5 library test.services.completion.invocation; |
6 | 6 |
7 | |
8 import 'dart:async'; | 7 import 'dart:async'; |
9 | 8 |
10 import 'package:analysis_server/src/protocol.dart'; | 9 import 'package:analysis_server/src/protocol.dart'; |
11 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; | 10 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; |
12 import 'package:analysis_server/src/services/completion/invocation_computer.dart
'; | 11 import 'package:analysis_server/src/services/completion/invocation_computer.dart
'; |
13 import 'package:unittest/unittest.dart'; | 12 import 'package:unittest/unittest.dart'; |
14 | 13 |
15 import '../../reflective_tests.dart'; | 14 import '../../reflective_tests.dart'; |
16 import 'completion_test_util.dart'; | 15 import 'completion_test_util.dart'; |
17 | 16 |
18 main() { | 17 main() { |
19 groupSep = ' | '; | 18 groupSep = ' | '; |
20 runReflectiveTests(InvocationComputerTest); | 19 runReflectiveTests(InvocationComputerTest); |
21 } | 20 } |
22 | 21 |
23 @reflectiveTest | 22 @reflectiveTest |
24 class InvocationComputerTest extends AbstractSelectorSuggestionTest { | 23 class InvocationComputerTest extends AbstractSelectorSuggestionTest { |
25 | |
26 @override | 24 @override |
27 CompletionSuggestion assertSuggestInvocationField(String name, String type, | 25 CompletionSuggestion assertSuggestInvocationField(String name, String type, |
28 {int relevance: DART_RELEVANCE_DEFAULT, bool isDeprecated: false}) { | 26 {int relevance: DART_RELEVANCE_DEFAULT, bool isDeprecated: false}) { |
29 return assertSuggestField( | 27 return assertSuggestField(name, type, |
30 name, | 28 relevance: relevance, isDeprecated: isDeprecated); |
31 type, | |
32 relevance: relevance, | |
33 isDeprecated: isDeprecated); | |
34 } | 29 } |
35 | 30 |
36 /** | 31 /** |
37 * Check whether a declaration of the form [shadower] in a derived class | 32 * Check whether a declaration of the form [shadower] in a derived class |
38 * shadows a declaration of the form [shadowee] in a base class, for the | 33 * shadows a declaration of the form [shadowee] in a base class, for the |
39 * purposes of what is shown during completion. [shouldBeShadowed] indicates | 34 * purposes of what is shown during completion. [shouldBeShadowed] indicates |
40 * whether shadowing is expected. | 35 * whether shadowing is expected. |
41 */ | 36 */ |
42 Future check_shadowing(String shadower, String shadowee, | 37 Future check_shadowing( |
43 bool shouldBeShadowed) { | 38 String shadower, String shadowee, bool shouldBeShadowed) { |
44 addTestSource(''' | 39 addTestSource(''' |
45 class Base { | 40 class Base { |
46 $shadowee | 41 $shadowee |
47 } | 42 } |
48 class Derived extends Base { | 43 class Derived extends Base { |
49 $shadower | 44 $shadower |
50 } | 45 } |
51 void f(Derived d) { | 46 void f(Derived d) { |
52 d.^ | 47 d.^ |
53 } | 48 } |
54 '''); | 49 '''); |
55 return computeFull((bool result) { | 50 return computeFull((bool result) { |
56 List<CompletionSuggestion> suggestionsForX = request.suggestions.where( | 51 List<CompletionSuggestion> suggestionsForX = request.suggestions |
57 (CompletionSuggestion s) => s.completion == 'x').toList(); | 52 .where((CompletionSuggestion s) => s.completion == 'x') |
| 53 .toList(); |
58 if (shouldBeShadowed) { | 54 if (shouldBeShadowed) { |
59 expect(suggestionsForX, hasLength(1)); | 55 expect(suggestionsForX, hasLength(1)); |
60 expect(suggestionsForX[0].declaringType, 'Derived'); | 56 expect(suggestionsForX[0].declaringType, 'Derived'); |
61 } else { | 57 } else { |
62 expect(suggestionsForX, hasLength(2)); | 58 expect(suggestionsForX, hasLength(2)); |
63 } | 59 } |
64 }); | 60 }); |
65 } | 61 } |
66 | 62 |
67 fail_test_PrefixedIdentifier_trailingStmt_const_untyped() { | 63 fail_test_PrefixedIdentifier_trailingStmt_const_untyped() { |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 } | 491 } |
496 void test(Derived d) { | 492 void test(Derived d) { |
497 d.^ | 493 d.^ |
498 } | 494 } |
499 '''); | 495 '''); |
500 return computeFull((bool result) { | 496 return computeFull((bool result) { |
501 assertSuggestMethod('f', 'Base', 'void'); | 497 assertSuggestMethod('f', 'Base', 'void'); |
502 }); | 498 }); |
503 } | 499 } |
504 } | 500 } |
OLD | NEW |