Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(546)

Side by Side Diff: pkg/analysis_server/test/services/completion/invocation_computer_test.dart

Issue 791553007: suggest fields rather than synthetic getters (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 7
8 import 'package:analysis_server/src/protocol.dart'; 8 import 'package:analysis_server/src/protocol.dart';
9 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart';
9 import 'package:analysis_server/src/services/completion/invocation_computer.dart '; 10 import 'package:analysis_server/src/services/completion/invocation_computer.dart ';
10 import 'package:unittest/unittest.dart'; 11 import 'package:unittest/unittest.dart';
11 12
12 import '../../reflective_tests.dart'; 13 import '../../reflective_tests.dart';
13 import 'completion_test_util.dart'; 14 import 'completion_test_util.dart';
14 15
15 main() { 16 main() {
16 groupSep = ' | '; 17 groupSep = ' | ';
17 runReflectiveTests(InvocationComputerTest); 18 runReflectiveTests(InvocationComputerTest);
18 } 19 }
19 20
20 @ReflectiveTestCase() 21 @ReflectiveTestCase()
21 class InvocationComputerTest extends AbstractSelectorSuggestionTest { 22 class InvocationComputerTest extends AbstractSelectorSuggestionTest {
22 23
23 void assertHasNoParameterInfo(CompletionSuggestion suggestion) { 24 void assertHasNoParameterInfo(CompletionSuggestion suggestion) {
24 expect(suggestion.parameterNames, isNull); 25 expect(suggestion.parameterNames, isNull);
25 expect(suggestion.parameterTypes, isNull); 26 expect(suggestion.parameterTypes, isNull);
26 expect(suggestion.requiredParameterCount, isNull); 27 expect(suggestion.requiredParameterCount, isNull);
27 expect(suggestion.hasNamedParameters, isNull); 28 expect(suggestion.hasNamedParameters, isNull);
28 } 29 }
29 30
30 @override 31 @override
32 CompletionSuggestion assertSuggestInvocationField(String name, String type,
33 {int relevance: COMPLETION_RELEVANCE_DEFAULT, bool isDeprecated: false}) {
34 return assertSuggestField(
35 name,
36 type,
37 relevance: relevance,
38 isDeprecated: isDeprecated);
39 }
40
41 @override
31 void setUpComputer() { 42 void setUpComputer() {
32 computer = new InvocationComputer(); 43 computer = new InvocationComputer();
33 } 44 }
34 45
35 test_method_parameters_mixed_required_and_named() { 46 test_method_parameters_mixed_required_and_named() {
36 addTestSource(''' 47 addTestSource('''
37 class C { 48 class C {
38 void m(x, {int y}) {} 49 void m(x, {int y}) {}
39 } 50 }
40 void main() {new C().^}'''); 51 void main() {new C().^}''');
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 }); 149 });
139 } 150 }
140 151
141 test_no_parameters_field() { 152 test_no_parameters_field() {
142 addTestSource(''' 153 addTestSource('''
143 class C { 154 class C {
144 int x; 155 int x;
145 } 156 }
146 void main() {new C().^}'''); 157 void main() {new C().^}''');
147 return computeFull((bool result) { 158 return computeFull((bool result) {
148 CompletionSuggestion suggestion = assertSuggestGetter('x', 'int'); 159 CompletionSuggestion suggestion = assertSuggestField('x', 'int');
149 assertHasNoParameterInfo(suggestion); 160 assertHasNoParameterInfo(suggestion);
150 }); 161 });
151 } 162 }
152 163
153 test_no_parameters_getter() { 164 test_no_parameters_getter() {
154 addTestSource(''' 165 addTestSource('''
155 class C { 166 class C {
156 int get x => null; 167 int get x => null;
157 } 168 }
158 void main() {int y = new C().^}'''); 169 void main() {int y = new C().^}''');
159 return computeFull((bool result) { 170 return computeFull((bool result) {
160 CompletionSuggestion suggestion = assertSuggestGetter('x', 'int'); 171 CompletionSuggestion suggestion = assertSuggestGetter('x', 'int');
161 assertHasNoParameterInfo(suggestion); 172 assertHasNoParameterInfo(suggestion);
162 }); 173 });
163 } 174 }
164 175
165 test_no_parameters_setter() { 176 test_no_parameters_setter() {
166 addTestSource(''' 177 addTestSource('''
167 class C { 178 class C {
168 set x(int value) {}; 179 set x(int value) {};
169 } 180 }
170 void main() {int y = new C().^}'''); 181 void main() {int y = new C().^}''');
171 return computeFull((bool result) { 182 return computeFull((bool result) {
172 CompletionSuggestion suggestion = assertSuggestSetter('x'); 183 CompletionSuggestion suggestion = assertSuggestSetter('x');
173 assertHasNoParameterInfo(suggestion); 184 assertHasNoParameterInfo(suggestion);
174 }); 185 });
175 } 186 }
176 } 187 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698