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

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

Issue 626303002: filter undesired suggestions from prefix expression (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 6 years, 2 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
« no previous file with comments | « pkg/analysis_server/test/services/completion/imported_computer_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.dart.local; 5 library test.services.completion.dart.local;
6 6
7 import 'package:analysis_server/src/services/completion/local_computer.dart'; 7 import 'package:analysis_server/src/services/completion/local_computer.dart';
8 import 'package:unittest/unittest.dart'; 8 import 'package:unittest/unittest.dart';
9 9
10 import '../../reflective_tests.dart'; 10 import '../../reflective_tests.dart';
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 assertSuggestLocalVariable('foo', null); 117 assertSuggestLocalVariable('foo', null);
118 } 118 }
119 119
120 test_ForStatement_body() { 120 test_ForStatement_body() {
121 // Block ForStatement 121 // Block ForStatement
122 addTestSource('main(args) {for (int i; i < 10; ++i) {^}}'); 122 addTestSource('main(args) {for (int i; i < 10; ++i) {^}}');
123 expect(computeFast(), isTrue); 123 expect(computeFast(), isTrue);
124 assertSuggestLocalVariable('i', 'int'); 124 assertSuggestLocalVariable('i', 'int');
125 } 125 }
126 126
127 test_ForStatement_condition() {
128 // SimpleIdentifier ForStatement
129 addTestSource('main() {for (int index = 0; i^)}');
130 expect(computeFast(), isTrue);
131 assertSuggestLocalVariable('index', 'int');
132 }
133
134 test_ForStatement_updaters() {
135 // SimpleIdentifier ForStatement
136 addTestSource('main() {for (int index = 0; index < 10; i^)}');
137 expect(computeFast(), isTrue);
138 assertSuggestLocalVariable('index', 'int');
139 }
140
141 test_ForStatement_updaters_prefix_expression() {
142 // SimpleIdentifier PrefixExpression ForStatement
143 addTestSource('main() {for (int index = 0; index < 10; ++i^)}');
144 expect(computeFast(), isTrue);
145 assertSuggestLocalVariable('index', 'int');
146 }
147
127 test_FunctionExpression_body_function() { 148 test_FunctionExpression_body_function() {
128 // Block BlockFunctionBody FunctionExpression 149 // Block BlockFunctionBody FunctionExpression
129 addTestSource('String foo(List args) {x.then((R b) {^});}'); 150 addTestSource('String foo(List args) {x.then((R b) {^});}');
130 expect(computeFast(), isTrue); 151 expect(computeFast(), isTrue);
131 var f = assertSuggestFunction('foo', 'String', false); 152 var f = assertSuggestFunction('foo', 'String', false);
132 expect(f.element.isPrivate, isFalse); 153 expect(f.element.isPrivate, isFalse);
133 assertSuggestParameter('args', 'List'); 154 assertSuggestParameter('args', 'List');
134 assertSuggestParameter('b', 'R'); 155 assertSuggestParameter('b', 'R');
135 } 156 }
136 157
137 test_InstanceCreationExpression() { 158 test_InstanceCreationExpression() {
138 // SimpleIdentifier TypeName ConstructorName InstanceCreationExpression 159 // SimpleIdentifier TypeName ConstructorName InstanceCreationExpression
139 addTestSource('class A {a() {var f; {var x;} new ^}} class B { }'); 160 addTestSource('class A {a() {var f; {var x;} new ^}} class B { }');
140 expect(computeFast(), isTrue); 161 expect(computeFast(), isTrue);
141 assertSuggestClass('A'); 162 assertSuggestClass('A');
142 assertSuggestClass('B'); 163 assertSuggestClass('B');
143 // TODO (danrubel) should only suggest types 164 // TODO (danrubel) should only suggest types
144 //assertNotSuggested('a'); 165 //assertNotSuggested('a');
145 assertSuggestMethod('a', 'A', null); 166 assertSuggestMethod('a', 'A', null);
146 //assertNotSuggested('f'); 167 //assertNotSuggested('f');
147 assertSuggestLocalVariable('f', null); 168 assertSuggestLocalVariable('f', null);
148 assertNotSuggested('x'); 169 assertNotSuggested('x');
149 } 170 }
150 171
172 test_InterpolationExpression() {
173 // SimpleIdentifier InterpolationExpression StringInterpolation
174 addTestSource('main() {String name; print("hello \$^");}');
175 expect(computeFast(), isTrue);
176 assertSuggestLocalVariable('name', 'String');
177 }
178
179 test_InterpolationExpression_block() {
180 // SimpleIdentifier InterpolationExpression StringInterpolation
181 addTestSource('main() {String name; print("hello \${n^}");}');
182 expect(computeFast(), isTrue);
183 assertSuggestLocalVariable('name', 'String');
184 }
185
151 test_MethodDeclaration_body_getters() { 186 test_MethodDeclaration_body_getters() {
152 // Block BlockFunctionBody MethodDeclaration 187 // Block BlockFunctionBody MethodDeclaration
153 addTestSource('class A {@deprecated X get f => 0; Z a() {^} get _g => 1;}'); 188 addTestSource('class A {@deprecated X get f => 0; Z a() {^} get _g => 1;}');
154 expect(computeFast(), isTrue); 189 expect(computeFast(), isTrue);
155 var a = assertSuggestMethod('a', 'A', 'Z'); 190 var a = assertSuggestMethod('a', 'A', 'Z');
156 expect(a.element.isDeprecated, isFalse); 191 expect(a.element.isDeprecated, isFalse);
157 expect(a.element.isPrivate, isFalse); 192 expect(a.element.isPrivate, isFalse);
158 var f = assertSuggestGetter('f', 'X'); 193 var f = assertSuggestGetter('f', 'X');
159 expect(f.element.isDeprecated, isTrue); 194 expect(f.element.isDeprecated, isTrue);
160 expect(f.element.isPrivate, isFalse); 195 expect(f.element.isPrivate, isFalse);
(...skipping 30 matching lines...) Expand all
191 226
192 test_MethodDeclaration_parameters_positional() { 227 test_MethodDeclaration_parameters_positional() {
193 // Block BlockFunctionBody MethodDeclaration 228 // Block BlockFunctionBody MethodDeclaration
194 addTestSource('class A {Z a(X x, [int y=1]) {^}}'); 229 addTestSource('class A {Z a(X x, [int y=1]) {^}}');
195 expect(computeFast(), isTrue); 230 expect(computeFast(), isTrue);
196 assertSuggestMethod('a', 'A', 'Z'); 231 assertSuggestMethod('a', 'A', 'Z');
197 assertSuggestParameter('x', 'X'); 232 assertSuggestParameter('x', 'X');
198 assertSuggestParameter('y', 'int'); 233 assertSuggestParameter('y', 'int');
199 } 234 }
200 235
236 test_PrefixedIdentifier() {
237 // SimpleIdentifier PrefixedIdentifier ExpressionStatement
238 addTestSource('''
239 class A {var b; X _c;}
240 class X{}
241 main() {A a; a.^}''');
242 expect(computeFast(), isTrue);
243 // PrefixedIdentifier is handled by InvocationComputer
244 assertNotSuggested('b');
245 assertNotSuggested('_c');
246 }
247
248 test_PrefixedIdentifier_interpolation() {
249 // SimpleIdentifier PrefixedIdentifier InterpolationExpression
250 addTestSource('main() {String name; print("hello \${name.^}");}');
251 expect(computeFast(), isTrue);
252 // InvocationComputer creates suggestions for prefixed identifiers
253 assertNotSuggested('name');
254 assertNotSuggested('length');
255 }
256
257 test_PrefixedIdentifier_prefix() {
258 // SimpleIdentifier PrefixedIdentifier InterpolationExpression
259 addTestSource('main() {String name; print("hello \${nam^e.length}");}');
260 expect(computeFast(), isTrue);
261 assertSuggestLocalVariable('name', 'String');
262 assertNotSuggested('length');
263 }
264
201 test_TopLevelVariableDeclaration_typed_name() { 265 test_TopLevelVariableDeclaration_typed_name() {
202 // SimpleIdentifier VariableDeclaration VariableDeclarationList 266 // SimpleIdentifier VariableDeclaration VariableDeclarationList
203 // TopLevelVariableDeclaration 267 // TopLevelVariableDeclaration
204 addTestSource('class A {} B ^'); 268 addTestSource('class A {} B ^');
205 expect(computeFast(), isTrue); 269 expect(computeFast(), isTrue);
206 assertNotSuggested('A'); 270 assertNotSuggested('A');
207 } 271 }
208 272
209 test_TopLevelVariableDeclaration_untyped_name() { 273 test_TopLevelVariableDeclaration_untyped_name() {
210 // SimpleIdentifier VariableDeclaration VariableDeclarationList 274 // SimpleIdentifier VariableDeclaration VariableDeclarationList
211 // TopLevelVariableDeclaration 275 // TopLevelVariableDeclaration
212 addTestSource('class A {} var ^'); 276 addTestSource('class A {} var ^');
213 expect(computeFast(), isTrue); 277 expect(computeFast(), isTrue);
214 assertNotSuggested('A'); 278 assertNotSuggested('A');
215 } 279 }
216 280
217 test_VariableDeclarationStatement_name() { 281 test_VariableDeclarationStatement_name() {
218 // SimpleIdentifier VariableDeclaration VariableDeclarationList 282 // SimpleIdentifier VariableDeclaration VariableDeclarationList
219 // VariableDeclarationStatement 283 // VariableDeclarationStatement
220 addTestSource('class _A {a() {var f; var ^}}'); 284 addTestSource('class _A {a() {var f; var ^}}');
221 expect(computeFast(), isTrue); 285 expect(computeFast(), isTrue);
222 assertNotSuggested('A'); 286 assertNotSuggested('A');
223 assertNotSuggested('a'); 287 assertNotSuggested('a');
224 assertNotSuggested('f'); 288 assertNotSuggested('f');
225 } 289 }
226 290
227 test_VariableDeclaration_RHS() { 291 test_VariableDeclaration_RHS() {
228 292 // VariableDeclaration VariableDeclarationList
229 // VariableDeclaration VariableDeclarationList VariableDeclarationStat ement 293 // VariableDeclarationStatement
230 addTestSource('class A {a() {var f; {var x;} var e = ^ var g;}}'); 294 addTestSource('class A {a() {var f; {var x;} var e = ^ var g;}}');
231 expect(computeFast(), isTrue); 295 expect(computeFast(), isTrue);
232 assertSuggestClass('A'); 296 assertSuggestClass('A');
233 assertSuggestLocalVariable('f', null); 297 assertSuggestLocalVariable('f', null);
234 assertNotSuggested('g'); 298 assertNotSuggested('g');
235 assertNotSuggested('x'); 299 assertNotSuggested('x');
236 } 300 }
237 } 301 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/services/completion/imported_computer_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698