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.contributor.dart.constructor; | 5 import 'package:analysis_server/protocol/protocol_generated.dart'; |
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/protocol_server.dart'; | 6 import 'package:analysis_server/src/protocol_server.dart'; |
12 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
dart'; | 7 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
dart'; |
13 import 'package:analysis_server/src/services/completion/dart/local_constructor_c
ontributor.dart'; | 8 import 'package:analysis_server/src/services/completion/dart/local_constructor_c
ontributor.dart'; |
14 import 'package:test/test.dart'; | 9 import 'package:test/test.dart'; |
15 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 10 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
16 | 11 |
17 import 'completion_contributor_util.dart'; | 12 import 'completion_contributor_util.dart'; |
18 | 13 |
19 main() { | 14 main() { |
20 defineReflectiveSuite(() { | 15 defineReflectiveSuite(() { |
21 defineReflectiveTests(LocalConstructorContributorTest); | 16 defineReflectiveTests(LocalConstructorContributorTest); |
22 defineReflectiveTests(LocalConstructorContributorTest_Driver); | 17 defineReflectiveTests(LocalConstructorContributorTest_Driver); |
23 }); | 18 }); |
24 } | 19 } |
25 | 20 |
26 @reflectiveTest | 21 @reflectiveTest |
27 class LocalConstructorContributorTest extends DartCompletionContributorTest { | 22 class LocalConstructorContributorTest extends DartCompletionContributorTest { |
28 CompletionSuggestion assertSuggestLocalVariable( | 23 CompletionSuggestion assertSuggestLocalVariable( |
29 String name, String returnType, | 24 String name, String returnType, |
30 {int relevance: DART_RELEVANCE_LOCAL_VARIABLE}) { | 25 {int relevance: DART_RELEVANCE_LOCAL_VARIABLE}) { |
31 // Local variables should only be suggested by LocalReferenceContributor | 26 // Local variables should only be suggested by LocalReferenceContributor |
32 CompletionSuggestion cs = assertSuggest(name, | 27 CompletionSuggestion cs = assertSuggest(name, |
33 csKind: CompletionSuggestionKind.INVOCATION, relevance: relevance); | 28 csKind: CompletionSuggestionKind.INVOCATION, relevance: relevance); |
34 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); | 29 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); |
35 protocol.Element element = cs.element; | 30 Element element = cs.element; |
36 expect(element, isNotNull); | 31 expect(element, isNotNull); |
37 expect(element.kind, equals(protocol.ElementKind.LOCAL_VARIABLE)); | 32 expect(element.kind, equals(ElementKind.LOCAL_VARIABLE)); |
38 expect(element.name, equals(name)); | 33 expect(element.name, equals(name)); |
39 expect(element.parameters, isNull); | 34 expect(element.parameters, isNull); |
40 expect(element.returnType, returnType != null ? returnType : 'dynamic'); | 35 expect(element.returnType, returnType != null ? returnType : 'dynamic'); |
41 assertHasNoParameterInfo(cs); | 36 assertHasNoParameterInfo(cs); |
42 return cs; | 37 return cs; |
43 } | 38 } |
44 | 39 |
45 CompletionSuggestion assertSuggestParameter(String name, String returnType, | 40 CompletionSuggestion assertSuggestParameter(String name, String returnType, |
46 {int relevance: DART_RELEVANCE_PARAMETER}) { | 41 {int relevance: DART_RELEVANCE_PARAMETER}) { |
47 CompletionSuggestion cs = assertSuggest(name, | 42 CompletionSuggestion cs = assertSuggest(name, |
48 csKind: CompletionSuggestionKind.INVOCATION, relevance: relevance); | 43 csKind: CompletionSuggestionKind.INVOCATION, relevance: relevance); |
49 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); | 44 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); |
50 protocol.Element element = cs.element; | 45 Element element = cs.element; |
51 expect(element, isNotNull); | 46 expect(element, isNotNull); |
52 expect(element.kind, equals(protocol.ElementKind.PARAMETER)); | 47 expect(element.kind, equals(ElementKind.PARAMETER)); |
53 expect(element.name, equals(name)); | 48 expect(element.name, equals(name)); |
54 expect(element.parameters, isNull); | 49 expect(element.parameters, isNull); |
55 expect(element.returnType, | 50 expect(element.returnType, |
56 equals(returnType != null ? returnType : 'dynamic')); | 51 equals(returnType != null ? returnType : 'dynamic')); |
57 return cs; | 52 return cs; |
58 } | 53 } |
59 | 54 |
60 @override | 55 @override |
61 DartCompletionContributor createContributor() { | 56 DartCompletionContributor createContributor() { |
62 return new LocalConstructorContributor(); | 57 return new LocalConstructorContributor(); |
(...skipping 4101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4164 A(int bar, {bool boo, @required int baz}); | 4159 A(int bar, {bool boo, @required int baz}); |
4165 baz() { | 4160 baz() { |
4166 new A^ | 4161 new A^ |
4167 } | 4162 } |
4168 }'''); | 4163 }'''); |
4169 await computeSuggestions(); | 4164 await computeSuggestions(); |
4170 | 4165 |
4171 assertSuggestConstructor('A', defaultArgListString: 'bar, baz: null'); | 4166 assertSuggestConstructor('A', defaultArgListString: 'bar, baz: null'); |
4172 } | 4167 } |
4173 } | 4168 } |
OLD | NEW |