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

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

Issue 2975253002: Format analyzer, analysis_server, analyzer_plugin, front_end and kernel with the latest dartfmt. (Closed)
Patch Set: Created 3 years, 5 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
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 import 'package:analysis_server/src/protocol_server.dart'; 5 import 'package:analysis_server/src/protocol_server.dart';
6 import 'package:analysis_server/src/provisional/completion/dart/completion_dart. dart'; 6 import 'package:analysis_server/src/provisional/completion/dart/completion_dart. dart';
7 import 'package:analysis_server/src/services/completion/dart/imported_reference_ contributor.dart'; 7 import 'package:analysis_server/src/services/completion/dart/imported_reference_ contributor.dart';
8 import 'package:analyzer/src/generated/engine.dart'; 8 import 'package:analyzer/src/generated/engine.dart';
9 import 'package:analyzer/src/generated/source.dart'; 9 import 'package:analyzer/src/generated/source.dart';
10 import 'package:test/test.dart'; 10 import 'package:test/test.dart';
(...skipping 14 matching lines...) Expand all
25 25
26 @override 26 @override
27 DartCompletionContributor createContributor() { 27 DartCompletionContributor createContributor() {
28 return new ImportedReferenceContributor(); 28 return new ImportedReferenceContributor();
29 } 29 }
30 30
31 /// Sanity check. Permutations tested in local_ref_contributor. 31 /// Sanity check. Permutations tested in local_ref_contributor.
32 test_ArgDefaults_function_with_required_named() async { 32 test_ArgDefaults_function_with_required_named() async {
33 addMetaPackageSource(); 33 addMetaPackageSource();
34 34
35 resolveSource( 35 resolveSource('/testB.dart', '''
36 '/testB.dart',
37 '''
38 lib B; 36 lib B;
39 import 'package:meta/meta.dart'; 37 import 'package:meta/meta.dart';
40 38
41 bool foo(int bar, {bool boo, @required int baz}) => false; 39 bool foo(int bar, {bool boo, @required int baz}) => false;
42 '''); 40 ''');
43 41
44 addTestSource(''' 42 addTestSource('''
45 import "/testB.dart"; 43 import "/testB.dart";
46 44
47 void main() {f^}'''); 45 void main() {f^}''');
48 await computeSuggestions(); 46 await computeSuggestions();
49 47
50 assertSuggestFunction('foo', 'bool', 48 assertSuggestFunction('foo', 'bool',
51 defaultArgListString: 'bar, baz: null'); 49 defaultArgListString: 'bar, baz: null');
52 } 50 }
53 51
54 test_ArgumentList() async { 52 test_ArgumentList() async {
55 // ArgumentList MethodInvocation ExpressionStatement Block 53 // ArgumentList MethodInvocation ExpressionStatement Block
56 resolveSource( 54 resolveSource('/libA.dart', '''
57 '/libA.dart',
58 '''
59 library A; 55 library A;
60 bool hasLength(int expected) { } 56 bool hasLength(int expected) { }
61 void baz() { }'''); 57 void baz() { }''');
62 addTestSource(''' 58 addTestSource('''
63 import '/libA.dart'; 59 import '/libA.dart';
64 class B { } 60 class B { }
65 String bar() => true; 61 String bar() => true;
66 void main() {expect(^)}'''); 62 void main() {expect(^)}''');
67 63
68 await computeSuggestions(); 64 await computeSuggestions();
69 expect(replacementOffset, completionOffset); 65 expect(replacementOffset, completionOffset);
70 expect(replacementLength, 0); 66 expect(replacementLength, 0);
71 assertNoSuggestions(kind: CompletionSuggestionKind.ARGUMENT_LIST); 67 assertNoSuggestions(kind: CompletionSuggestionKind.ARGUMENT_LIST);
72 assertNotSuggested('bar'); 68 assertNotSuggested('bar');
73 assertSuggestFunction('hasLength', 'bool'); 69 assertSuggestFunction('hasLength', 'bool');
74 assertSuggestFunction('identical', 'bool'); 70 assertSuggestFunction('identical', 'bool');
75 assertNotSuggested('B'); 71 assertNotSuggested('B');
76 assertSuggestClass('Object'); 72 assertSuggestClass('Object');
77 assertNotSuggested('main'); 73 assertNotSuggested('main');
78 assertNotSuggested('baz'); 74 assertNotSuggested('baz');
79 assertNotSuggested('print'); 75 assertNotSuggested('print');
80 } 76 }
81 77
82 test_ArgumentList_imported_function() async { 78 test_ArgumentList_imported_function() async {
83 // ArgumentList MethodInvocation ExpressionStatement Block 79 // ArgumentList MethodInvocation ExpressionStatement Block
84 resolveSource( 80 resolveSource('/libA.dart', '''
85 '/libA.dart',
86 '''
87 library A; 81 library A;
88 bool hasLength(int expected) { } 82 bool hasLength(int expected) { }
89 expect(arg) { } 83 expect(arg) { }
90 void baz() { }'''); 84 void baz() { }''');
91 addTestSource(''' 85 addTestSource('''
92 import '/libA.dart' 86 import '/libA.dart'
93 class B { } 87 class B { }
94 String bar() => true; 88 String bar() => true;
95 void main() {expect(^)}'''); 89 void main() {expect(^)}''');
96 90
97 await computeSuggestions(); 91 await computeSuggestions();
98 expect(replacementOffset, completionOffset); 92 expect(replacementOffset, completionOffset);
99 expect(replacementLength, 0); 93 expect(replacementLength, 0);
100 assertNoSuggestions(kind: CompletionSuggestionKind.ARGUMENT_LIST); 94 assertNoSuggestions(kind: CompletionSuggestionKind.ARGUMENT_LIST);
101 assertNotSuggested('bar'); 95 assertNotSuggested('bar');
102 assertSuggestFunction('hasLength', 'bool'); 96 assertSuggestFunction('hasLength', 'bool');
103 assertSuggestFunction('identical', 'bool'); 97 assertSuggestFunction('identical', 'bool');
104 assertNotSuggested('B'); 98 assertNotSuggested('B');
105 assertSuggestClass('Object'); 99 assertSuggestClass('Object');
106 assertNotSuggested('main'); 100 assertNotSuggested('main');
107 assertNotSuggested('baz'); 101 assertNotSuggested('baz');
108 assertNotSuggested('print'); 102 assertNotSuggested('print');
109 } 103 }
110 104
111 test_ArgumentList_InstanceCreationExpression_functionalArg() async { 105 test_ArgumentList_InstanceCreationExpression_functionalArg() async {
112 // ArgumentList InstanceCreationExpression ExpressionStatement Block 106 // ArgumentList InstanceCreationExpression ExpressionStatement Block
113 addSource( 107 addSource('/libA.dart', '''
114 '/libA.dart',
115 '''
116 library A; 108 library A;
117 class A { A(f()) { } } 109 class A { A(f()) { } }
118 bool hasLength(int expected) { } 110 bool hasLength(int expected) { }
119 void baz() { }'''); 111 void baz() { }''');
120 addTestSource(''' 112 addTestSource('''
121 import 'dart:async'; 113 import 'dart:async';
122 import '/libA.dart'; 114 import '/libA.dart';
123 class B { } 115 class B { }
124 String bar() => true; 116 String bar() => true;
125 void main() {new A(^)}'''); 117 void main() {new A(^)}''');
(...skipping 10 matching lines...) Expand all
136 assertNotSuggested('B'); 128 assertNotSuggested('B');
137 assertSuggestClass('A', kind: CompletionSuggestionKind.IDENTIFIER); 129 assertSuggestClass('A', kind: CompletionSuggestionKind.IDENTIFIER);
138 assertSuggestClass('Object', kind: CompletionSuggestionKind.IDENTIFIER); 130 assertSuggestClass('Object', kind: CompletionSuggestionKind.IDENTIFIER);
139 assertNotSuggested('main'); 131 assertNotSuggested('main');
140 assertNotSuggested('baz'); 132 assertNotSuggested('baz');
141 assertNotSuggested('print'); 133 assertNotSuggested('print');
142 } 134 }
143 135
144 test_ArgumentList_InstanceCreationExpression_typedefArg() async { 136 test_ArgumentList_InstanceCreationExpression_typedefArg() async {
145 // ArgumentList InstanceCreationExpression ExpressionStatement Block 137 // ArgumentList InstanceCreationExpression ExpressionStatement Block
146 addSource( 138 addSource('/libA.dart', '''
147 '/libA.dart',
148 '''
149 library A; 139 library A;
150 typedef Funct(); 140 typedef Funct();
151 class A { A(Funct f) { } } 141 class A { A(Funct f) { } }
152 bool hasLength(int expected) { } 142 bool hasLength(int expected) { }
153 void baz() { }'''); 143 void baz() { }''');
154 addTestSource(''' 144 addTestSource('''
155 import 'dart:async'; 145 import 'dart:async';
156 import '/libA.dart'; 146 import '/libA.dart';
157 class B { } 147 class B { }
158 String bar() => true; 148 String bar() => true;
(...skipping 11 matching lines...) Expand all
170 assertNotSuggested('B'); 160 assertNotSuggested('B');
171 assertSuggestClass('A', kind: CompletionSuggestionKind.IDENTIFIER); 161 assertSuggestClass('A', kind: CompletionSuggestionKind.IDENTIFIER);
172 assertSuggestClass('Object', kind: CompletionSuggestionKind.IDENTIFIER); 162 assertSuggestClass('Object', kind: CompletionSuggestionKind.IDENTIFIER);
173 assertNotSuggested('main'); 163 assertNotSuggested('main');
174 assertNotSuggested('baz'); 164 assertNotSuggested('baz');
175 assertNotSuggested('print'); 165 assertNotSuggested('print');
176 } 166 }
177 167
178 test_ArgumentList_local_function() async { 168 test_ArgumentList_local_function() async {
179 // ArgumentList MethodInvocation ExpressionStatement Block 169 // ArgumentList MethodInvocation ExpressionStatement Block
180 resolveSource( 170 resolveSource('/libA.dart', '''
181 '/libA.dart',
182 '''
183 library A; 171 library A;
184 bool hasLength(int expected) { } 172 bool hasLength(int expected) { }
185 void baz() { }'''); 173 void baz() { }''');
186 addTestSource(''' 174 addTestSource('''
187 import '/libA.dart' 175 import '/libA.dart'
188 expect(arg) { } 176 expect(arg) { }
189 class B { } 177 class B { }
190 String bar() => true; 178 String bar() => true;
191 void main() {expect(^)}'''); 179 void main() {expect(^)}''');
192 180
193 await computeSuggestions(); 181 await computeSuggestions();
194 expect(replacementOffset, completionOffset); 182 expect(replacementOffset, completionOffset);
195 expect(replacementLength, 0); 183 expect(replacementLength, 0);
196 assertNoSuggestions(kind: CompletionSuggestionKind.ARGUMENT_LIST); 184 assertNoSuggestions(kind: CompletionSuggestionKind.ARGUMENT_LIST);
197 assertNotSuggested('bar'); 185 assertNotSuggested('bar');
198 assertSuggestFunction('hasLength', 'bool'); 186 assertSuggestFunction('hasLength', 'bool');
199 assertSuggestFunction('identical', 'bool'); 187 assertSuggestFunction('identical', 'bool');
200 assertNotSuggested('B'); 188 assertNotSuggested('B');
201 assertSuggestClass('Object'); 189 assertSuggestClass('Object');
202 assertNotSuggested('main'); 190 assertNotSuggested('main');
203 assertNotSuggested('baz'); 191 assertNotSuggested('baz');
204 assertNotSuggested('print'); 192 assertNotSuggested('print');
205 } 193 }
206 194
207 test_ArgumentList_local_method() async { 195 test_ArgumentList_local_method() async {
208 // ArgumentList MethodInvocation ExpressionStatement Block 196 // ArgumentList MethodInvocation ExpressionStatement Block
209 resolveSource( 197 resolveSource('/libA.dart', '''
210 '/libA.dart',
211 '''
212 library A; 198 library A;
213 bool hasLength(int expected) { } 199 bool hasLength(int expected) { }
214 void baz() { }'''); 200 void baz() { }''');
215 addTestSource(''' 201 addTestSource('''
216 import '/libA.dart' 202 import '/libA.dart'
217 class B { 203 class B {
218 expect(arg) { } 204 expect(arg) { }
219 void foo() {expect(^)}} 205 void foo() {expect(^)}}
220 String bar() => true;'''); 206 String bar() => true;''');
221 207
222 await computeSuggestions(); 208 await computeSuggestions();
223 expect(replacementOffset, completionOffset); 209 expect(replacementOffset, completionOffset);
224 expect(replacementLength, 0); 210 expect(replacementLength, 0);
225 assertNoSuggestions(kind: CompletionSuggestionKind.ARGUMENT_LIST); 211 assertNoSuggestions(kind: CompletionSuggestionKind.ARGUMENT_LIST);
226 assertNotSuggested('bar'); 212 assertNotSuggested('bar');
227 assertSuggestFunction('hasLength', 'bool'); 213 assertSuggestFunction('hasLength', 'bool');
228 assertSuggestFunction('identical', 'bool'); 214 assertSuggestFunction('identical', 'bool');
229 assertNotSuggested('B'); 215 assertNotSuggested('B');
230 assertSuggestClass('Object'); 216 assertSuggestClass('Object');
231 assertNotSuggested('main'); 217 assertNotSuggested('main');
232 assertNotSuggested('baz'); 218 assertNotSuggested('baz');
233 assertNotSuggested('print'); 219 assertNotSuggested('print');
234 } 220 }
235 221
236 test_ArgumentList_MethodInvocation_functionalArg() async { 222 test_ArgumentList_MethodInvocation_functionalArg() async {
237 // ArgumentList MethodInvocation ExpressionStatement Block 223 // ArgumentList MethodInvocation ExpressionStatement Block
238 addSource( 224 addSource('/libA.dart', '''
239 '/libA.dart',
240 '''
241 library A; 225 library A;
242 class A { A(f()) { } } 226 class A { A(f()) { } }
243 bool hasLength(int expected) { } 227 bool hasLength(int expected) { }
244 void baz() { }'''); 228 void baz() { }''');
245 addTestSource(''' 229 addTestSource('''
246 import 'dart:async'; 230 import 'dart:async';
247 import '/libA.dart'; 231 import '/libA.dart';
248 class B { } 232 class B { }
249 String bar(f()) => true; 233 String bar(f()) => true;
250 void main() {bar(^);}'''); 234 void main() {bar(^);}''');
(...skipping 10 matching lines...) Expand all
261 assertNotSuggested('B'); 245 assertNotSuggested('B');
262 assertSuggestClass('A', kind: CompletionSuggestionKind.IDENTIFIER); 246 assertSuggestClass('A', kind: CompletionSuggestionKind.IDENTIFIER);
263 assertSuggestClass('Object', kind: CompletionSuggestionKind.IDENTIFIER); 247 assertSuggestClass('Object', kind: CompletionSuggestionKind.IDENTIFIER);
264 assertNotSuggested('main'); 248 assertNotSuggested('main');
265 assertNotSuggested('baz'); 249 assertNotSuggested('baz');
266 assertNotSuggested('print'); 250 assertNotSuggested('print');
267 } 251 }
268 252
269 test_ArgumentList_MethodInvocation_methodArg() async { 253 test_ArgumentList_MethodInvocation_methodArg() async {
270 // ArgumentList MethodInvocation ExpressionStatement Block 254 // ArgumentList MethodInvocation ExpressionStatement Block
271 addSource( 255 addSource('/libA.dart', '''
272 '/libA.dart',
273 '''
274 library A; 256 library A;
275 class A { A(f()) { } } 257 class A { A(f()) { } }
276 bool hasLength(int expected) { } 258 bool hasLength(int expected) { }
277 void baz() { }'''); 259 void baz() { }''');
278 addTestSource(''' 260 addTestSource('''
279 import 'dart:async'; 261 import 'dart:async';
280 import '/libA.dart'; 262 import '/libA.dart';
281 class B { String bar(f()) => true; } 263 class B { String bar(f()) => true; }
282 void main() {new B().bar(^);}'''); 264 void main() {new B().bar(^);}''');
283 265
284 await computeSuggestions(); 266 await computeSuggestions();
285 expect(replacementOffset, completionOffset); 267 expect(replacementOffset, completionOffset);
286 expect(replacementLength, 0); 268 expect(replacementLength, 0);
287 assertNoSuggestions(kind: CompletionSuggestionKind.ARGUMENT_LIST); 269 assertNoSuggestions(kind: CompletionSuggestionKind.ARGUMENT_LIST);
288 assertSuggestFunction('hasLength', 'bool', 270 assertSuggestFunction('hasLength', 'bool',
289 kind: CompletionSuggestionKind.IDENTIFIER); 271 kind: CompletionSuggestionKind.IDENTIFIER);
290 assertSuggestFunction('identical', 'bool', 272 assertSuggestFunction('identical', 'bool',
291 kind: CompletionSuggestionKind.IDENTIFIER); 273 kind: CompletionSuggestionKind.IDENTIFIER);
292 assertNotSuggested('B'); 274 assertNotSuggested('B');
293 assertSuggestClass('A', kind: CompletionSuggestionKind.IDENTIFIER); 275 assertSuggestClass('A', kind: CompletionSuggestionKind.IDENTIFIER);
294 assertSuggestClass('Object', kind: CompletionSuggestionKind.IDENTIFIER); 276 assertSuggestClass('Object', kind: CompletionSuggestionKind.IDENTIFIER);
295 assertNotSuggested('main'); 277 assertNotSuggested('main');
296 assertNotSuggested('baz'); 278 assertNotSuggested('baz');
297 assertNotSuggested('print'); 279 assertNotSuggested('print');
298 } 280 }
299 281
300 test_ArgumentList_namedParam() async { 282 test_ArgumentList_namedParam() async {
301 // SimpleIdentifier NamedExpression ArgumentList MethodInvocation 283 // SimpleIdentifier NamedExpression ArgumentList MethodInvocation
302 // ExpressionStatement 284 // ExpressionStatement
303 addSource( 285 addSource('/libA.dart', '''
304 '/libA.dart',
305 '''
306 library A; 286 library A;
307 bool hasLength(int expected) { }'''); 287 bool hasLength(int expected) { }''');
308 addTestSource(''' 288 addTestSource('''
309 import '/libA.dart' 289 import '/libA.dart'
310 String bar() => true; 290 String bar() => true;
311 void main() {expect(foo: ^)}'''); 291 void main() {expect(foo: ^)}''');
312 292
313 await computeSuggestions(); 293 await computeSuggestions();
314 expect(replacementOffset, completionOffset); 294 expect(replacementOffset, completionOffset);
315 expect(replacementLength, 0); 295 expect(replacementLength, 0);
(...skipping 17 matching lines...) Expand all
333 expect(replacementLength, 0); 313 expect(replacementLength, 0);
334 assertNotSuggested('b'); 314 assertNotSuggested('b');
335 assertNotSuggested('_c'); 315 assertNotSuggested('_c');
336 assertSuggestClass('Object'); 316 assertSuggestClass('Object');
337 assertNotSuggested('A'); 317 assertNotSuggested('A');
338 assertNotSuggested('=='); 318 assertNotSuggested('==');
339 } 319 }
340 320
341 test_AsExpression_type_subtype_extends_filter() async { 321 test_AsExpression_type_subtype_extends_filter() async {
342 // SimpleIdentifier TypeName AsExpression IfStatement 322 // SimpleIdentifier TypeName AsExpression IfStatement
343 addSource( 323 addSource('/testB.dart', '''
344 '/testB.dart',
345 '''
346 foo() { } 324 foo() { }
347 class A {} class B extends A {} class C extends B {} 325 class A {} class B extends A {} class C extends B {}
348 class X {X.c(); X._d(); z() {}}'''); 326 class X {X.c(); X._d(); z() {}}''');
349 addTestSource(''' 327 addTestSource('''
350 import "/testB.dart"; 328 import "/testB.dart";
351 main(){A a; if (a as ^)}'''); 329 main(){A a; if (a as ^)}''');
352 330
353 await computeSuggestions(); 331 await computeSuggestions();
354 expect(replacementOffset, completionOffset); 332 expect(replacementOffset, completionOffset);
355 expect(replacementLength, 0); 333 expect(replacementLength, 0);
356 assertSuggestClass('B'); 334 assertSuggestClass('B');
357 assertSuggestClass('C'); 335 assertSuggestClass('C');
358 assertNotSuggested('A'); 336 assertNotSuggested('A');
359 assertNotSuggested('X'); 337 assertNotSuggested('X');
360 assertNotSuggested('Object'); 338 assertNotSuggested('Object');
361 assertNotSuggested('a'); 339 assertNotSuggested('a');
362 assertNotSuggested('main'); 340 assertNotSuggested('main');
363 } 341 }
364 342
365 test_AsExpression_type_subtype_implements_filter() async { 343 test_AsExpression_type_subtype_implements_filter() async {
366 // SimpleIdentifier TypeName AsExpression IfStatement 344 // SimpleIdentifier TypeName AsExpression IfStatement
367 addSource( 345 addSource('/testB.dart', '''
368 '/testB.dart',
369 '''
370 foo() { } 346 foo() { }
371 class A {} class B implements A {} class C implements B {} 347 class A {} class B implements A {} class C implements B {}
372 class X {X.c(); X._d(); z() {}}'''); 348 class X {X.c(); X._d(); z() {}}''');
373 addTestSource(''' 349 addTestSource('''
374 import "/testB.dart"; 350 import "/testB.dart";
375 main(){A a; if (a as ^)}'''); 351 main(){A a; if (a as ^)}''');
376 352
377 await computeSuggestions(); 353 await computeSuggestions();
378 expect(replacementOffset, completionOffset); 354 expect(replacementOffset, completionOffset);
379 expect(replacementLength, 0); 355 expect(replacementLength, 0);
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 await computeSuggestions(); 484 await computeSuggestions();
509 expect(replacementOffset, completionOffset); 485 expect(replacementOffset, completionOffset);
510 expect(replacementLength, 0); 486 expect(replacementLength, 0);
511 assertNotSuggested('a'); 487 assertNotSuggested('a');
512 assertNotSuggested('main'); 488 assertNotSuggested('main');
513 assertNotSuggested('A'); 489 assertNotSuggested('A');
514 assertSuggestClass('Object'); 490 assertSuggestClass('Object');
515 } 491 }
516 492
517 test_AwaitExpression_function() async { 493 test_AwaitExpression_function() async {
518 resolveSource( 494 resolveSource('/libA.dart', '''
519 '/libA.dart',
520 '''
521 Future y() async {return 0;} 495 Future y() async {return 0;}
522 '''); 496 ''');
523 addTestSource(''' 497 addTestSource('''
524 import '/libA.dart'; 498 import '/libA.dart';
525 class B extends A { 499 class B extends A {
526 int x; 500 int x;
527 foo() async {await ^} 501 foo() async {await ^}
528 } 502 }
529 '''); 503 ''');
530 await computeSuggestions(); 504 await computeSuggestions();
531 expect(replacementOffset, completionOffset); 505 expect(replacementOffset, completionOffset);
532 expect(replacementLength, 0); 506 expect(replacementLength, 0);
533 assertSuggestFunction('y', 'dynamic'); 507 assertSuggestFunction('y', 'dynamic');
534 assertNotSuggested('A'); 508 assertNotSuggested('A');
535 assertSuggestClass('Object'); 509 assertSuggestClass('Object');
536 } 510 }
537 511
538 test_AwaitExpression_inherited() async { 512 test_AwaitExpression_inherited() async {
539 // SimpleIdentifier AwaitExpression ExpressionStatement 513 // SimpleIdentifier AwaitExpression ExpressionStatement
540 addSource( 514 addSource('/testB.dart', '''
541 '/testB.dart',
542 '''
543 lib libB; 515 lib libB;
544 class A { 516 class A {
545 Future y() async { return 0; } 517 Future y() async { return 0; }
546 }'''); 518 }''');
547 addTestSource(''' 519 addTestSource('''
548 import "/testB.dart"; 520 import "/testB.dart";
549 class B extends A { 521 class B extends A {
550 foo() async {await ^} 522 foo() async {await ^}
551 } 523 }
552 '''); 524 ''');
(...skipping 30 matching lines...) Expand all
583 expect(replacementOffset, completionOffset); 555 expect(replacementOffset, completionOffset);
584 expect(replacementLength, 0); 556 expect(replacementLength, 0);
585 assertNotSuggested('a'); 557 assertNotSuggested('a');
586 assertSuggestClass('Object'); 558 assertSuggestClass('Object');
587 assertNotSuggested('b'); 559 assertNotSuggested('b');
588 assertNotSuggested('=='); 560 assertNotSuggested('==');
589 } 561 }
590 562
591 test_Block() async { 563 test_Block() async {
592 // Block BlockFunctionBody MethodDeclaration 564 // Block BlockFunctionBody MethodDeclaration
593 addSource( 565 addSource('/testAB.dart', '''
594 '/testAB.dart',
595 '''
596 export "dart:math" hide max; 566 export "dart:math" hide max;
597 class A {int x;} 567 class A {int x;}
598 @deprecated D1() {int x;} 568 @deprecated D1() {int x;}
599 class _B {boo() { partBoo() {}} }'''); 569 class _B {boo() { partBoo() {}} }''');
600 addSource( 570 addSource('/testCD.dart', '''
601 '/testCD.dart',
602 '''
603 String T1; 571 String T1;
604 var _T2; 572 var _T2;
605 class C { } 573 class C { }
606 class D { }'''); 574 class D { }''');
607 addSource( 575 addSource('/testEEF.dart', '''
608 '/testEEF.dart',
609 '''
610 class EE { } 576 class EE { }
611 class F { }'''); 577 class F { }''');
612 addSource('/testG.dart', 'class G { }'); 578 addSource('/testG.dart', 'class G { }');
613 addSource( 579 addSource('/testH.dart', '''
614 '/testH.dart',
615 '''
616 class H { } 580 class H { }
617 int T3; 581 int T3;
618 var _T4;'''); // not imported 582 var _T4;'''); // not imported
619 addTestSource(''' 583 addTestSource('''
620 import "/testAB.dart"; 584 import "/testAB.dart";
621 import "/testCD.dart" hide D; 585 import "/testCD.dart" hide D;
622 import "/testEEF.dart" show EE; 586 import "/testEEF.dart" show EE;
623 import "/testG.dart" as g; 587 import "/testG.dart" as g;
624 int T5; 588 int T5;
625 var _T6; 589 var _T6;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 assertNotSuggested('blog'); 655 assertNotSuggested('blog');
692 // TODO (danrubel) suggest HtmlElement as low relevance 656 // TODO (danrubel) suggest HtmlElement as low relevance
693 assertNotSuggested('HtmlElement'); 657 assertNotSuggested('HtmlElement');
694 assertSuggestClass('Uri'); 658 assertSuggestClass('Uri');
695 assertNotSuggested('parseIPv6Address'); 659 assertNotSuggested('parseIPv6Address');
696 assertNotSuggested('parseHex'); 660 assertNotSuggested('parseHex');
697 } 661 }
698 662
699 test_Block_final() async { 663 test_Block_final() async {
700 // Block BlockFunctionBody MethodDeclaration 664 // Block BlockFunctionBody MethodDeclaration
701 addSource( 665 addSource('/testAB.dart', '''
702 '/testAB.dart',
703 '''
704 export "dart:math" hide max; 666 export "dart:math" hide max;
705 class A {int x;} 667 class A {int x;}
706 @deprecated D1() {int x;} 668 @deprecated D1() {int x;}
707 class _B {boo() { partBoo() {}} }'''); 669 class _B {boo() { partBoo() {}} }''');
708 addSource( 670 addSource('/testCD.dart', '''
709 '/testCD.dart',
710 '''
711 String T1; 671 String T1;
712 var _T2; 672 var _T2;
713 class C { } 673 class C { }
714 class D { }'''); 674 class D { }''');
715 addSource( 675 addSource('/testEEF.dart', '''
716 '/testEEF.dart',
717 '''
718 class EE { } 676 class EE { }
719 class F { }'''); 677 class F { }''');
720 addSource('/testG.dart', 'class G { }'); 678 addSource('/testG.dart', 'class G { }');
721 addSource( 679 addSource('/testH.dart', '''
722 '/testH.dart',
723 '''
724 class H { } 680 class H { }
725 int T3; 681 int T3;
726 var _T4;'''); // not imported 682 var _T4;'''); // not imported
727 addTestSource(''' 683 addTestSource('''
728 import "/testAB.dart"; 684 import "/testAB.dart";
729 import "/testCD.dart" hide D; 685 import "/testCD.dart" hide D;
730 import "/testEEF.dart" show EE; 686 import "/testEEF.dart" show EE;
731 import "/testG.dart" as g; 687 import "/testG.dart" as g;
732 int T5; 688 int T5;
733 var _T6; 689 var _T6;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 768
813 test_Block_final3() async { 769 test_Block_final3() async {
814 addTestSource('main() {final ^ v;}'); 770 addTestSource('main() {final ^ v;}');
815 771
816 await computeSuggestions(); 772 await computeSuggestions();
817 assertSuggestClass('String'); 773 assertSuggestClass('String');
818 } 774 }
819 775
820 test_Block_final_final() async { 776 test_Block_final_final() async {
821 // Block BlockFunctionBody MethodDeclaration 777 // Block BlockFunctionBody MethodDeclaration
822 addSource( 778 addSource('/testAB.dart', '''
823 '/testAB.dart',
824 '''
825 export "dart:math" hide max; 779 export "dart:math" hide max;
826 class A {int x;} 780 class A {int x;}
827 @deprecated D1() {int x;} 781 @deprecated D1() {int x;}
828 class _B {boo() { partBoo() {}} }'''); 782 class _B {boo() { partBoo() {}} }''');
829 addSource( 783 addSource('/testCD.dart', '''
830 '/testCD.dart',
831 '''
832 String T1; 784 String T1;
833 var _T2; 785 var _T2;
834 class C { } 786 class C { }
835 class D { }'''); 787 class D { }''');
836 addSource( 788 addSource('/testEEF.dart', '''
837 '/testEEF.dart',
838 '''
839 class EE { } 789 class EE { }
840 class F { }'''); 790 class F { }''');
841 addSource('/testG.dart', 'class G { }'); 791 addSource('/testG.dart', 'class G { }');
842 addSource( 792 addSource('/testH.dart', '''
843 '/testH.dart',
844 '''
845 class H { } 793 class H { }
846 int T3; 794 int T3;
847 var _T4;'''); // not imported 795 var _T4;'''); // not imported
848 addTestSource(''' 796 addTestSource('''
849 import "/testAB.dart"; 797 import "/testAB.dart";
850 import "/testCD.dart" hide D; 798 import "/testCD.dart" hide D;
851 import "/testEEF.dart" show EE; 799 import "/testEEF.dart" show EE;
852 import "/testG.dart" as g hide G; 800 import "/testG.dart" as g hide G;
853 int T5; 801 int T5;
854 var _T6; 802 var _T6;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 assertNotSuggested('blog'); 869 assertNotSuggested('blog');
922 // TODO (danrubel) suggest HtmlElement as low relevance 870 // TODO (danrubel) suggest HtmlElement as low relevance
923 assertNotSuggested('HtmlElement'); 871 assertNotSuggested('HtmlElement');
924 assertSuggestClass('Uri'); 872 assertSuggestClass('Uri');
925 assertNotSuggested('parseIPv6Address'); 873 assertNotSuggested('parseIPv6Address');
926 assertNotSuggested('parseHex'); 874 assertNotSuggested('parseHex');
927 } 875 }
928 876
929 test_Block_final_var() async { 877 test_Block_final_var() async {
930 // Block BlockFunctionBody MethodDeclaration 878 // Block BlockFunctionBody MethodDeclaration
931 addSource( 879 addSource('/testAB.dart', '''
932 '/testAB.dart',
933 '''
934 export "dart:math" hide max; 880 export "dart:math" hide max;
935 class A {int x;} 881 class A {int x;}
936 @deprecated D1() {int x;} 882 @deprecated D1() {int x;}
937 class _B {boo() { partBoo() {}} }'''); 883 class _B {boo() { partBoo() {}} }''');
938 addSource( 884 addSource('/testCD.dart', '''
939 '/testCD.dart',
940 '''
941 String T1; 885 String T1;
942 var _T2; 886 var _T2;
943 class C { } 887 class C { }
944 class D { }'''); 888 class D { }''');
945 addSource( 889 addSource('/testEEF.dart', '''
946 '/testEEF.dart',
947 '''
948 class EE { } 890 class EE { }
949 class F { }'''); 891 class F { }''');
950 addSource('/testG.dart', 'class G { }'); 892 addSource('/testG.dart', 'class G { }');
951 addSource( 893 addSource('/testH.dart', '''
952 '/testH.dart',
953 '''
954 class H { } 894 class H { }
955 int T3; 895 int T3;
956 var _T4;'''); // not imported 896 var _T4;'''); // not imported
957 addTestSource(''' 897 addTestSource('''
958 import "/testAB.dart"; 898 import "/testAB.dart";
959 import "/testCD.dart" hide D; 899 import "/testCD.dart" hide D;
960 import "/testEEF.dart" show EE; 900 import "/testEEF.dart" show EE;
961 import "/testG.dart" as g; 901 import "/testG.dart" as g;
962 int T5; 902 int T5;
963 var _T6; 903 var _T6;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 assertNotSuggested('clog'); 967 assertNotSuggested('clog');
1028 assertNotSuggested('blog'); 968 assertNotSuggested('blog');
1029 // TODO (danrubel) suggest HtmlElement as low relevance 969 // TODO (danrubel) suggest HtmlElement as low relevance
1030 assertNotSuggested('HtmlElement'); 970 assertNotSuggested('HtmlElement');
1031 assertSuggestClass('Uri'); 971 assertSuggestClass('Uri');
1032 assertNotSuggested('parseIPv6Address'); 972 assertNotSuggested('parseIPv6Address');
1033 assertNotSuggested('parseHex'); 973 assertNotSuggested('parseHex');
1034 } 974 }
1035 975
1036 test_Block_identifier_partial() async { 976 test_Block_identifier_partial() async {
1037 resolveSource( 977 resolveSource('/testAB.dart', '''
1038 '/testAB.dart',
1039 '''
1040 export "dart:math" hide max; 978 export "dart:math" hide max;
1041 class A {int x;} 979 class A {int x;}
1042 @deprecated D1() {int x;} 980 @deprecated D1() {int x;}
1043 class _B { }'''); 981 class _B { }''');
1044 addSource( 982 addSource('/testCD.dart', '''
1045 '/testCD.dart',
1046 '''
1047 String T1; 983 String T1;
1048 var _T2; 984 var _T2;
1049 class C { } 985 class C { }
1050 class D { }'''); 986 class D { }''');
1051 addSource( 987 addSource('/testEEF.dart', '''
1052 '/testEEF.dart',
1053 '''
1054 class EE { } 988 class EE { }
1055 class DF { }'''); 989 class DF { }''');
1056 addSource('/testG.dart', 'class G { }'); 990 addSource('/testG.dart', 'class G { }');
1057 addSource( 991 addSource('/testH.dart', '''
1058 '/testH.dart',
1059 '''
1060 class H { } 992 class H { }
1061 class D3 { } 993 class D3 { }
1062 int T3; 994 int T3;
1063 var _T4;'''); // not imported 995 var _T4;'''); // not imported
1064 addTestSource(''' 996 addTestSource('''
1065 import "/testAB.dart"; 997 import "/testAB.dart";
1066 import "/testCD.dart" hide D; 998 import "/testCD.dart" hide D;
1067 import "/testEEF.dart" show EE; 999 import "/testEEF.dart" show EE;
1068 import "/testG.dart" as g; 1000 import "/testG.dart" as g;
1069 int T5; 1001 int T5;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 assertNotSuggested('_T4'); 1045 assertNotSuggested('_T4');
1114 //assertNotSuggested('T5'); 1046 //assertNotSuggested('T5');
1115 //assertNotSuggested('_T6'); 1047 //assertNotSuggested('_T6');
1116 assertNotSuggested('=='); 1048 assertNotSuggested('==');
1117 // TODO (danrubel) suggest HtmlElement as low relevance 1049 // TODO (danrubel) suggest HtmlElement as low relevance
1118 assertNotSuggested('HtmlElement'); 1050 assertNotSuggested('HtmlElement');
1119 } 1051 }
1120 1052
1121 test_Block_inherited_imported() async { 1053 test_Block_inherited_imported() async {
1122 // Block BlockFunctionBody MethodDeclaration ClassDeclaration 1054 // Block BlockFunctionBody MethodDeclaration ClassDeclaration
1123 addSource( 1055 addSource('/testB.dart', '''
1124 '/testB.dart',
1125 '''
1126 lib B; 1056 lib B;
1127 class F { var f1; f2() { } get f3 => 0; set f4(fx) { } var _pf; } 1057 class F { var f1; f2() { } get f3 => 0; set f4(fx) { } var _pf; }
1128 class E extends F { var e1; e2() { } } 1058 class E extends F { var e1; e2() { } }
1129 class I { int i1; i2() { } } 1059 class I { int i1; i2() { } }
1130 class M { var m1; int m2() { } }'''); 1060 class M { var m1; int m2() { } }''');
1131 addTestSource(''' 1061 addTestSource('''
1132 import "/testB.dart"; 1062 import "/testB.dart";
1133 class A extends E implements I with M {a() {^}}'''); 1063 class A extends E implements I with M {a() {^}}''');
1134 1064
1135 await computeSuggestions(); 1065 await computeSuggestions();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 assertNotSuggested('m1'); 1099 assertNotSuggested('m1');
1170 assertNotSuggested('f3'); 1100 assertNotSuggested('f3');
1171 assertNotSuggested('f4'); 1101 assertNotSuggested('f4');
1172 assertNotSuggested('e2'); 1102 assertNotSuggested('e2');
1173 assertNotSuggested('f2'); 1103 assertNotSuggested('f2');
1174 assertNotSuggested('i2'); 1104 assertNotSuggested('i2');
1175 assertNotSuggested('m2'); 1105 assertNotSuggested('m2');
1176 } 1106 }
1177 1107
1178 test_Block_local_function() async { 1108 test_Block_local_function() async {
1179 addSource( 1109 addSource('/testAB.dart', '''
1180 '/testAB.dart',
1181 '''
1182 export "dart:math" hide max; 1110 export "dart:math" hide max;
1183 class A {int x;} 1111 class A {int x;}
1184 @deprecated D1() {int x;} 1112 @deprecated D1() {int x;}
1185 class _B {boo() { partBoo() {}} }'''); 1113 class _B {boo() { partBoo() {}} }''');
1186 addSource( 1114 addSource('/testCD.dart', '''
1187 '/testCD.dart',
1188 '''
1189 String T1; 1115 String T1;
1190 var _T2; 1116 var _T2;
1191 class C { } 1117 class C { }
1192 class D { }'''); 1118 class D { }''');
1193 addSource( 1119 addSource('/testEEF.dart', '''
1194 '/testEEF.dart',
1195 '''
1196 class EE { } 1120 class EE { }
1197 class F { }'''); 1121 class F { }''');
1198 addSource('/testG.dart', 'class G { }'); 1122 addSource('/testG.dart', 'class G { }');
1199 addSource( 1123 addSource('/testH.dart', '''
1200 '/testH.dart',
1201 '''
1202 class H { } 1124 class H { }
1203 int T3; 1125 int T3;
1204 var _T4;'''); // not imported 1126 var _T4;'''); // not imported
1205 addTestSource(''' 1127 addTestSource('''
1206 import "/testAB.dart"; 1128 import "/testAB.dart";
1207 import "/testCD.dart" hide D; 1129 import "/testCD.dart" hide D;
1208 import "/testEEF.dart" show EE; 1130 import "/testEEF.dart" show EE;
1209 import "/testG.dart" as g; 1131 import "/testG.dart" as g;
1210 int T5; 1132 int T5;
1211 var _T6; 1133 var _T6;
(...skipping 17 matching lines...) Expand all
1229 expect(replacementLength, 1); 1151 expect(replacementLength, 1);
1230 1152
1231 assertNotSuggested('partT8'); 1153 assertNotSuggested('partT8');
1232 assertNotSuggested('partBoo'); 1154 assertNotSuggested('partBoo');
1233 assertNotSuggested('parseIPv6Address'); 1155 assertNotSuggested('parseIPv6Address');
1234 assertNotSuggested('parseHex'); 1156 assertNotSuggested('parseHex');
1235 } 1157 }
1236 1158
1237 test_Block_partial_results() async { 1159 test_Block_partial_results() async {
1238 // Block BlockFunctionBody MethodDeclaration 1160 // Block BlockFunctionBody MethodDeclaration
1239 addSource( 1161 addSource('/testAB.dart', '''
1240 '/testAB.dart',
1241 '''
1242 export "dart:math" hide max; 1162 export "dart:math" hide max;
1243 class A {int x;} 1163 class A {int x;}
1244 @deprecated D1() {int x;} 1164 @deprecated D1() {int x;}
1245 class _B { }'''); 1165 class _B { }''');
1246 addSource( 1166 addSource('/testCD.dart', '''
1247 '/testCD.dart',
1248 '''
1249 String T1; 1167 String T1;
1250 var _T2; 1168 var _T2;
1251 class C { } 1169 class C { }
1252 class D { }'''); 1170 class D { }''');
1253 addSource( 1171 addSource('/testEEF.dart', '''
1254 '/testEEF.dart',
1255 '''
1256 class EE { } 1172 class EE { }
1257 class F { }'''); 1173 class F { }''');
1258 addSource('/testG.dart', 'class G { }'); 1174 addSource('/testG.dart', 'class G { }');
1259 addSource( 1175 addSource('/testH.dart', '''
1260 '/testH.dart',
1261 '''
1262 class H { } 1176 class H { }
1263 int T3; 1177 int T3;
1264 var _T4;'''); // not imported 1178 var _T4;'''); // not imported
1265 addTestSource(''' 1179 addTestSource('''
1266 import "/testAB.dart"; 1180 import "/testAB.dart";
1267 import "/testCD.dart" hide D; 1181 import "/testCD.dart" hide D;
1268 import "/testEEF.dart" show EE; 1182 import "/testEEF.dart" show EE;
1269 import "/testG.dart" as g; 1183 import "/testG.dart" as g;
1270 int T5; 1184 int T5;
1271 var _T6; 1185 var _T6;
(...skipping 16 matching lines...) Expand all
1288 expect(replacementOffset, completionOffset - 1); 1202 expect(replacementOffset, completionOffset - 1);
1289 expect(replacementLength, 1); 1203 expect(replacementLength, 1);
1290 // Not imported, so not suggested 1204 // Not imported, so not suggested
1291 assertNotSuggested('Foo'); 1205 assertNotSuggested('Foo');
1292 assertNotSuggested('Foo2'); 1206 assertNotSuggested('Foo2');
1293 assertNotSuggested('Future'); 1207 assertNotSuggested('Future');
1294 } 1208 }
1295 1209
1296 test_CascadeExpression_selector1() async { 1210 test_CascadeExpression_selector1() async {
1297 // PropertyAccess CascadeExpression ExpressionStatement Block 1211 // PropertyAccess CascadeExpression ExpressionStatement Block
1298 addSource( 1212 addSource('/testB.dart', '''
1299 '/testB.dart',
1300 '''
1301 class B { }'''); 1213 class B { }''');
1302 addTestSource(''' 1214 addTestSource('''
1303 import "/testB.dart"; 1215 import "/testB.dart";
1304 class A {var b; X _c;} 1216 class A {var b; X _c;}
1305 class X{} 1217 class X{}
1306 // looks like a cascade to the parser 1218 // looks like a cascade to the parser
1307 // but the user is trying to get completions for a non-cascade 1219 // but the user is trying to get completions for a non-cascade
1308 main() {A a; a.^.z}'''); 1220 main() {A a; a.^.z}''');
1309 1221
1310 await computeSuggestions(); 1222 await computeSuggestions();
1311 expect(replacementOffset, completionOffset); 1223 expect(replacementOffset, completionOffset);
1312 expect(replacementLength, 0); 1224 expect(replacementLength, 0);
1313 assertNotSuggested('b'); 1225 assertNotSuggested('b');
1314 assertNotSuggested('_c'); 1226 assertNotSuggested('_c');
1315 assertNotSuggested('Object'); 1227 assertNotSuggested('Object');
1316 assertNotSuggested('A'); 1228 assertNotSuggested('A');
1317 assertNotSuggested('B'); 1229 assertNotSuggested('B');
1318 assertNotSuggested('X'); 1230 assertNotSuggested('X');
1319 assertNotSuggested('z'); 1231 assertNotSuggested('z');
1320 assertNotSuggested('=='); 1232 assertNotSuggested('==');
1321 } 1233 }
1322 1234
1323 test_CascadeExpression_selector2() async { 1235 test_CascadeExpression_selector2() async {
1324 // SimpleIdentifier PropertyAccess CascadeExpression ExpressionStatement 1236 // SimpleIdentifier PropertyAccess CascadeExpression ExpressionStatement
1325 addSource( 1237 addSource('/testB.dart', '''
1326 '/testB.dart',
1327 '''
1328 class B { }'''); 1238 class B { }''');
1329 addTestSource(''' 1239 addTestSource('''
1330 import "/testB.dart"; 1240 import "/testB.dart";
1331 class A {var b; X _c;} 1241 class A {var b; X _c;}
1332 class X{} 1242 class X{}
1333 main() {A a; a..^z}'''); 1243 main() {A a; a..^z}''');
1334 1244
1335 await computeSuggestions(); 1245 await computeSuggestions();
1336 expect(replacementOffset, completionOffset); 1246 expect(replacementOffset, completionOffset);
1337 expect(replacementLength, 1); 1247 expect(replacementLength, 1);
1338 assertNotSuggested('b'); 1248 assertNotSuggested('b');
1339 assertNotSuggested('_c'); 1249 assertNotSuggested('_c');
1340 assertNotSuggested('Object'); 1250 assertNotSuggested('Object');
1341 assertNotSuggested('A'); 1251 assertNotSuggested('A');
1342 assertNotSuggested('B'); 1252 assertNotSuggested('B');
1343 assertNotSuggested('X'); 1253 assertNotSuggested('X');
1344 assertNotSuggested('z'); 1254 assertNotSuggested('z');
1345 assertNotSuggested('=='); 1255 assertNotSuggested('==');
1346 } 1256 }
1347 1257
1348 test_CascadeExpression_selector2_withTrailingReturn() async { 1258 test_CascadeExpression_selector2_withTrailingReturn() async {
1349 // PropertyAccess CascadeExpression ExpressionStatement Block 1259 // PropertyAccess CascadeExpression ExpressionStatement Block
1350 addSource( 1260 addSource('/testB.dart', '''
1351 '/testB.dart',
1352 '''
1353 class B { }'''); 1261 class B { }''');
1354 addTestSource(''' 1262 addTestSource('''
1355 import "/testB.dart"; 1263 import "/testB.dart";
1356 class A {var b; X _c;} 1264 class A {var b; X _c;}
1357 class X{} 1265 class X{}
1358 main() {A a; a..^ return}'''); 1266 main() {A a; a..^ return}''');
1359 1267
1360 await computeSuggestions(); 1268 await computeSuggestions();
1361 expect(replacementOffset, completionOffset); 1269 expect(replacementOffset, completionOffset);
1362 expect(replacementLength, 0); 1270 expect(replacementLength, 0);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1437 expect(replacementLength, 0); 1345 expect(replacementLength, 0);
1438 assertNotSuggested('e'); 1346 assertNotSuggested('e');
1439 assertNotSuggested('s'); 1347 assertNotSuggested('s');
1440 assertNotSuggested('a'); 1348 assertNotSuggested('a');
1441 assertSuggestClass('Object'); 1349 assertSuggestClass('Object');
1442 assertNotSuggested('x'); 1350 assertNotSuggested('x');
1443 } 1351 }
1444 1352
1445 test_ClassDeclaration_body() async { 1353 test_ClassDeclaration_body() async {
1446 // ClassDeclaration CompilationUnit 1354 // ClassDeclaration CompilationUnit
1447 addSource( 1355 addSource('/testB.dart', '''
1448 '/testB.dart',
1449 '''
1450 class B { }'''); 1356 class B { }''');
1451 addTestSource(''' 1357 addTestSource('''
1452 import "testB.dart" as x; 1358 import "testB.dart" as x;
1453 @deprecated class A {^} 1359 @deprecated class A {^}
1454 class _B {} 1360 class _B {}
1455 A T;'''); 1361 A T;''');
1456 1362
1457 await computeSuggestions(); 1363 await computeSuggestions();
1458 expect(replacementOffset, completionOffset); 1364 expect(replacementOffset, completionOffset);
1459 expect(replacementLength, 0); 1365 expect(replacementLength, 0);
1460 assertNotSuggested('A'); 1366 assertNotSuggested('A');
1461 assertNotSuggested('_B'); 1367 assertNotSuggested('_B');
1462 CompletionSuggestion suggestionO = assertSuggestClass('Object'); 1368 CompletionSuggestion suggestionO = assertSuggestClass('Object');
1463 if (suggestionO != null) { 1369 if (suggestionO != null) {
1464 expect(suggestionO.element.isDeprecated, isFalse); 1370 expect(suggestionO.element.isDeprecated, isFalse);
1465 expect(suggestionO.element.isPrivate, isFalse); 1371 expect(suggestionO.element.isPrivate, isFalse);
1466 } 1372 }
1467 assertNotSuggested('T'); 1373 assertNotSuggested('T');
1468 // Suggested by LibraryPrefixContributor 1374 // Suggested by LibraryPrefixContributor
1469 assertNotSuggested('x'); 1375 assertNotSuggested('x');
1470 } 1376 }
1471 1377
1472 test_ClassDeclaration_body_final() async { 1378 test_ClassDeclaration_body_final() async {
1473 // ClassDeclaration CompilationUnit 1379 // ClassDeclaration CompilationUnit
1474 addSource( 1380 addSource('/testB.dart', '''
1475 '/testB.dart',
1476 '''
1477 class B { }'''); 1381 class B { }''');
1478 addTestSource(''' 1382 addTestSource('''
1479 import "testB.dart" as x; 1383 import "testB.dart" as x;
1480 class A {final ^} 1384 class A {final ^}
1481 class _B {} 1385 class _B {}
1482 A T;'''); 1386 A T;''');
1483 1387
1484 await computeSuggestions(); 1388 await computeSuggestions();
1485 expect(replacementOffset, completionOffset); 1389 expect(replacementOffset, completionOffset);
1486 expect(replacementLength, 0); 1390 expect(replacementLength, 0);
1487 assertNotSuggested('A'); 1391 assertNotSuggested('A');
1488 assertNotSuggested('_B'); 1392 assertNotSuggested('_B');
1489 assertSuggestClass('Object'); 1393 assertSuggestClass('Object');
1490 assertNotSuggested('T'); 1394 assertNotSuggested('T');
1491 // Suggested by LibraryPrefixContributor 1395 // Suggested by LibraryPrefixContributor
1492 assertNotSuggested('x'); 1396 assertNotSuggested('x');
1493 } 1397 }
1494 1398
1495 test_ClassDeclaration_body_final_field() async { 1399 test_ClassDeclaration_body_final_field() async {
1496 // ClassDeclaration CompilationUnit 1400 // ClassDeclaration CompilationUnit
1497 addSource( 1401 addSource('/testB.dart', '''
1498 '/testB.dart',
1499 '''
1500 class B { }'''); 1402 class B { }''');
1501 addTestSource(''' 1403 addTestSource('''
1502 import "testB.dart" as x; 1404 import "testB.dart" as x;
1503 class A {final ^ A(){}} 1405 class A {final ^ A(){}}
1504 class _B {} 1406 class _B {}
1505 A T;'''); 1407 A T;''');
1506 1408
1507 await computeSuggestions(); 1409 await computeSuggestions();
1508 expect(replacementOffset, completionOffset); 1410 expect(replacementOffset, completionOffset);
1509 expect(replacementLength, 0); 1411 expect(replacementLength, 0);
1510 assertNotSuggested('A'); 1412 assertNotSuggested('A');
1511 assertNotSuggested('_B'); 1413 assertNotSuggested('_B');
1512 assertSuggestClass('String'); 1414 assertSuggestClass('String');
1513 assertNotSuggested('T'); 1415 assertNotSuggested('T');
1514 // Suggested by LibraryPrefixContributor 1416 // Suggested by LibraryPrefixContributor
1515 assertNotSuggested('x'); 1417 assertNotSuggested('x');
1516 } 1418 }
1517 1419
1518 test_ClassDeclaration_body_final_field2() async { 1420 test_ClassDeclaration_body_final_field2() async {
1519 // ClassDeclaration CompilationUnit 1421 // ClassDeclaration CompilationUnit
1520 addSource( 1422 addSource('/testB.dart', '''
1521 '/testB.dart',
1522 '''
1523 class B { }'''); 1423 class B { }''');
1524 addTestSource(''' 1424 addTestSource('''
1525 import "testB.dart" as Soo; 1425 import "testB.dart" as Soo;
1526 class A {final S^ A();} 1426 class A {final S^ A();}
1527 class _B {} 1427 class _B {}
1528 A Sew;'''); 1428 A Sew;''');
1529 1429
1530 await computeSuggestions(); 1430 await computeSuggestions();
1531 expect(replacementOffset, completionOffset - 1); 1431 expect(replacementOffset, completionOffset - 1);
1532 expect(replacementLength, 1); 1432 expect(replacementLength, 1);
1533 assertNotSuggested('A'); 1433 assertNotSuggested('A');
1534 assertNotSuggested('_B'); 1434 assertNotSuggested('_B');
1535 assertSuggestClass('String'); 1435 assertSuggestClass('String');
1536 assertNotSuggested('Sew'); 1436 assertNotSuggested('Sew');
1537 // Suggested by LibraryPrefixContributor 1437 // Suggested by LibraryPrefixContributor
1538 assertNotSuggested('Soo'); 1438 assertNotSuggested('Soo');
1539 } 1439 }
1540 1440
1541 test_ClassDeclaration_body_final_final() async { 1441 test_ClassDeclaration_body_final_final() async {
1542 // ClassDeclaration CompilationUnit 1442 // ClassDeclaration CompilationUnit
1543 addSource( 1443 addSource('/testB.dart', '''
1544 '/testB.dart',
1545 '''
1546 class B { }'''); 1444 class B { }''');
1547 addTestSource(''' 1445 addTestSource('''
1548 import "testB.dart" as x; 1446 import "testB.dart" as x;
1549 class A {final ^ final foo;} 1447 class A {final ^ final foo;}
1550 class _B {} 1448 class _B {}
1551 A T;'''); 1449 A T;''');
1552 1450
1553 await computeSuggestions(); 1451 await computeSuggestions();
1554 expect(replacementOffset, completionOffset); 1452 expect(replacementOffset, completionOffset);
1555 expect(replacementLength, 0); 1453 expect(replacementLength, 0);
1556 assertNotSuggested('A'); 1454 assertNotSuggested('A');
1557 assertNotSuggested('_B'); 1455 assertNotSuggested('_B');
1558 assertSuggestClass('Object'); 1456 assertSuggestClass('Object');
1559 assertNotSuggested('T'); 1457 assertNotSuggested('T');
1560 // Suggested by LibraryPrefixContributor 1458 // Suggested by LibraryPrefixContributor
1561 assertNotSuggested('x'); 1459 assertNotSuggested('x');
1562 } 1460 }
1563 1461
1564 test_ClassDeclaration_body_final_var() async { 1462 test_ClassDeclaration_body_final_var() async {
1565 // ClassDeclaration CompilationUnit 1463 // ClassDeclaration CompilationUnit
1566 addSource( 1464 addSource('/testB.dart', '''
1567 '/testB.dart',
1568 '''
1569 class B { }'''); 1465 class B { }''');
1570 addTestSource(''' 1466 addTestSource('''
1571 import "testB.dart" as x; 1467 import "testB.dart" as x;
1572 class A {final ^ var foo;} 1468 class A {final ^ var foo;}
1573 class _B {} 1469 class _B {}
1574 A T;'''); 1470 A T;''');
1575 1471
1576 await computeSuggestions(); 1472 await computeSuggestions();
1577 expect(replacementOffset, completionOffset); 1473 expect(replacementOffset, completionOffset);
1578 expect(replacementLength, 0); 1474 expect(replacementLength, 0);
1579 assertNotSuggested('A'); 1475 assertNotSuggested('A');
1580 assertNotSuggested('_B'); 1476 assertNotSuggested('_B');
1581 assertSuggestClass('Object'); 1477 assertSuggestClass('Object');
1582 assertNotSuggested('T'); 1478 assertNotSuggested('T');
1583 // Suggested by LibraryPrefixContributor 1479 // Suggested by LibraryPrefixContributor
1584 assertNotSuggested('x'); 1480 assertNotSuggested('x');
1585 } 1481 }
1586 1482
1587 test_Combinator_hide() async { 1483 test_Combinator_hide() async {
1588 // SimpleIdentifier HideCombinator ImportDirective 1484 // SimpleIdentifier HideCombinator ImportDirective
1589 addSource( 1485 addSource('/testAB.dart', '''
1590 '/testAB.dart',
1591 '''
1592 library libAB; 1486 library libAB;
1593 part '/partAB.dart'; 1487 part '/partAB.dart';
1594 class A { } 1488 class A { }
1595 class B { }'''); 1489 class B { }''');
1596 addSource( 1490 addSource('/partAB.dart', '''
1597 '/partAB.dart',
1598 '''
1599 part of libAB; 1491 part of libAB;
1600 var T1; 1492 var T1;
1601 PB F1() => new PB(); 1493 PB F1() => new PB();
1602 class PB { }'''); 1494 class PB { }''');
1603 addSource( 1495 addSource('/testCD.dart', '''
1604 '/testCD.dart',
1605 '''
1606 class C { } 1496 class C { }
1607 class D { }'''); 1497 class D { }''');
1608 addTestSource(''' 1498 addTestSource('''
1609 import "/testAB.dart" hide ^; 1499 import "/testAB.dart" hide ^;
1610 import "/testCD.dart"; 1500 import "/testCD.dart";
1611 class X {}'''); 1501 class X {}''');
1612 1502
1613 await computeSuggestions(); 1503 await computeSuggestions();
1614 assertNoSuggestions(); 1504 assertNoSuggestions();
1615 } 1505 }
1616 1506
1617 test_Combinator_show() async { 1507 test_Combinator_show() async {
1618 // SimpleIdentifier HideCombinator ImportDirective 1508 // SimpleIdentifier HideCombinator ImportDirective
1619 addSource( 1509 addSource('/testAB.dart', '''
1620 '/testAB.dart',
1621 '''
1622 library libAB; 1510 library libAB;
1623 part '/partAB.dart'; 1511 part '/partAB.dart';
1624 class A { } 1512 class A { }
1625 class B { }'''); 1513 class B { }''');
1626 addSource( 1514 addSource('/partAB.dart', '''
1627 '/partAB.dart',
1628 '''
1629 part of libAB; 1515 part of libAB;
1630 var T1; 1516 var T1;
1631 PB F1() => new PB(); 1517 PB F1() => new PB();
1632 typedef PB2 F2(int blat); 1518 typedef PB2 F2(int blat);
1633 class Clz = Object with Object; 1519 class Clz = Object with Object;
1634 class PB { }'''); 1520 class PB { }''');
1635 addSource( 1521 addSource('/testCD.dart', '''
1636 '/testCD.dart',
1637 '''
1638 class C { } 1522 class C { }
1639 class D { }'''); 1523 class D { }''');
1640 addTestSource(''' 1524 addTestSource('''
1641 import "/testAB.dart" show ^; 1525 import "/testAB.dart" show ^;
1642 import "/testCD.dart"; 1526 import "/testCD.dart";
1643 class X {}'''); 1527 class X {}''');
1644 1528
1645 await computeSuggestions(); 1529 await computeSuggestions();
1646 assertNoSuggestions(); 1530 assertNoSuggestions();
1647 } 1531 }
1648 1532
1649 test_ConditionalExpression_elseExpression() async { 1533 test_ConditionalExpression_elseExpression() async {
1650 // SimpleIdentifier ConditionalExpression ReturnStatement 1534 // SimpleIdentifier ConditionalExpression ReturnStatement
1651 addSource( 1535 addSource('/testA.dart', '''
1652 '/testA.dart',
1653 '''
1654 int T1; 1536 int T1;
1655 F1() { } 1537 F1() { }
1656 class A {int x;}'''); 1538 class A {int x;}''');
1657 addTestSource(''' 1539 addTestSource('''
1658 import "/testA.dart"; 1540 import "/testA.dart";
1659 int T2; 1541 int T2;
1660 F2() { } 1542 F2() { }
1661 class B {int x;} 1543 class B {int x;}
1662 class C {foo(){var f; {var x;} return a ? T1 : T^}}'''); 1544 class C {foo(){var f; {var x;} return a ? T1 : T^}}''');
1663 1545
1664 await computeSuggestions(); 1546 await computeSuggestions();
1665 // top level results are partially filtered based on first char 1547 // top level results are partially filtered based on first char
1666 assertNotSuggested('T2'); 1548 assertNotSuggested('T2');
1667 // TODO (danrubel) getter is being suggested instead of top level var 1549 // TODO (danrubel) getter is being suggested instead of top level var
1668 //assertSuggestImportedTopLevelVar('T1', 'int'); 1550 //assertSuggestImportedTopLevelVar('T1', 'int');
1669 } 1551 }
1670 1552
1671 test_ConditionalExpression_elseExpression_empty() async { 1553 test_ConditionalExpression_elseExpression_empty() async {
1672 // SimpleIdentifier ConditionalExpression ReturnStatement 1554 // SimpleIdentifier ConditionalExpression ReturnStatement
1673 resolveSource( 1555 resolveSource('/testA.dart', '''
1674 '/testA.dart',
1675 '''
1676 int T1; 1556 int T1;
1677 F1() { } 1557 F1() { }
1678 class A {int x;}'''); 1558 class A {int x;}''');
1679 addTestSource(''' 1559 addTestSource('''
1680 import "/testA.dart"; 1560 import "/testA.dart";
1681 int T2; 1561 int T2;
1682 F2() { } 1562 F2() { }
1683 class B {int x;} 1563 class B {int x;}
1684 class C {foo(){var f; {var x;} return a ? T1 : ^}}'''); 1564 class C {foo(){var f; {var x;} return a ? T1 : ^}}''');
1685 1565
1686 await computeSuggestions(); 1566 await computeSuggestions();
1687 assertNotSuggested('x'); 1567 assertNotSuggested('x');
1688 assertNotSuggested('f'); 1568 assertNotSuggested('f');
1689 assertNotSuggested('foo'); 1569 assertNotSuggested('foo');
1690 assertNotSuggested('C'); 1570 assertNotSuggested('C');
1691 assertNotSuggested('F2'); 1571 assertNotSuggested('F2');
1692 assertNotSuggested('T2'); 1572 assertNotSuggested('T2');
1693 assertSuggestClass('A'); 1573 assertSuggestClass('A');
1694 assertSuggestFunction('F1', 'dynamic'); 1574 assertSuggestFunction('F1', 'dynamic');
1695 // TODO (danrubel) getter is being suggested instead of top level var 1575 // TODO (danrubel) getter is being suggested instead of top level var
1696 //assertSuggestImportedTopLevelVar('T1', 'int'); 1576 //assertSuggestImportedTopLevelVar('T1', 'int');
1697 } 1577 }
1698 1578
1699 test_ConditionalExpression_partial_thenExpression() async { 1579 test_ConditionalExpression_partial_thenExpression() async {
1700 // SimpleIdentifier ConditionalExpression ReturnStatement 1580 // SimpleIdentifier ConditionalExpression ReturnStatement
1701 addSource( 1581 addSource('/testA.dart', '''
1702 '/testA.dart',
1703 '''
1704 int T1; 1582 int T1;
1705 F1() { } 1583 F1() { }
1706 class A {int x;}'''); 1584 class A {int x;}''');
1707 addTestSource(''' 1585 addTestSource('''
1708 import "/testA.dart"; 1586 import "/testA.dart";
1709 int T2; 1587 int T2;
1710 F2() { } 1588 F2() { }
1711 class B {int x;} 1589 class B {int x;}
1712 class C {foo(){var f; {var x;} return a ? T^}}'''); 1590 class C {foo(){var f; {var x;} return a ? T^}}''');
1713 1591
1714 await computeSuggestions(); 1592 await computeSuggestions();
1715 // top level results are partially filtered based on first char 1593 // top level results are partially filtered based on first char
1716 assertNotSuggested('T2'); 1594 assertNotSuggested('T2');
1717 // TODO (danrubel) getter is being suggested instead of top level var 1595 // TODO (danrubel) getter is being suggested instead of top level var
1718 //assertSuggestImportedTopLevelVar('T1', 'int'); 1596 //assertSuggestImportedTopLevelVar('T1', 'int');
1719 } 1597 }
1720 1598
1721 test_ConditionalExpression_partial_thenExpression_empty() async { 1599 test_ConditionalExpression_partial_thenExpression_empty() async {
1722 // SimpleIdentifier ConditionalExpression ReturnStatement 1600 // SimpleIdentifier ConditionalExpression ReturnStatement
1723 resolveSource( 1601 resolveSource('/testA.dart', '''
1724 '/testA.dart',
1725 '''
1726 int T1; 1602 int T1;
1727 F1() { } 1603 F1() { }
1728 class A {int x;}'''); 1604 class A {int x;}''');
1729 addTestSource(''' 1605 addTestSource('''
1730 import "/testA.dart"; 1606 import "/testA.dart";
1731 int T2; 1607 int T2;
1732 F2() { } 1608 F2() { }
1733 class B {int x;} 1609 class B {int x;}
1734 class C {foo(){var f; {var x;} return a ? ^}}'''); 1610 class C {foo(){var f; {var x;} return a ? ^}}''');
1735 1611
1736 await computeSuggestions(); 1612 await computeSuggestions();
1737 assertNotSuggested('x'); 1613 assertNotSuggested('x');
1738 assertNotSuggested('f'); 1614 assertNotSuggested('f');
1739 assertNotSuggested('foo'); 1615 assertNotSuggested('foo');
1740 assertNotSuggested('C'); 1616 assertNotSuggested('C');
1741 assertNotSuggested('F2'); 1617 assertNotSuggested('F2');
1742 assertNotSuggested('T2'); 1618 assertNotSuggested('T2');
1743 assertSuggestClass('A'); 1619 assertSuggestClass('A');
1744 assertSuggestFunction('F1', 'dynamic'); 1620 assertSuggestFunction('F1', 'dynamic');
1745 // TODO (danrubel) getter is being suggested instead of top level var 1621 // TODO (danrubel) getter is being suggested instead of top level var
1746 //assertSuggestImportedTopLevelVar('T1', 'int'); 1622 //assertSuggestImportedTopLevelVar('T1', 'int');
1747 } 1623 }
1748 1624
1749 test_ConditionalExpression_thenExpression() async { 1625 test_ConditionalExpression_thenExpression() async {
1750 // SimpleIdentifier ConditionalExpression ReturnStatement 1626 // SimpleIdentifier ConditionalExpression ReturnStatement
1751 addSource( 1627 addSource('/testA.dart', '''
1752 '/testA.dart',
1753 '''
1754 int T1; 1628 int T1;
1755 F1() { } 1629 F1() { }
1756 class A {int x;}'''); 1630 class A {int x;}''');
1757 addTestSource(''' 1631 addTestSource('''
1758 import "/testA.dart"; 1632 import "/testA.dart";
1759 int T2; 1633 int T2;
1760 F2() { } 1634 F2() { }
1761 class B {int x;} 1635 class B {int x;}
1762 class C {foo(){var f; {var x;} return a ? T^ : c}}'''); 1636 class C {foo(){var f; {var x;} return a ? T^ : c}}''');
1763 1637
1764 await computeSuggestions(); 1638 await computeSuggestions();
1765 // top level results are partially filtered based on first char 1639 // top level results are partially filtered based on first char
1766 assertNotSuggested('T2'); 1640 assertNotSuggested('T2');
1767 // TODO (danrubel) getter is being suggested instead of top level var 1641 // TODO (danrubel) getter is being suggested instead of top level var
1768 //assertSuggestImportedTopLevelVar('T1', 'int'); 1642 //assertSuggestImportedTopLevelVar('T1', 'int');
1769 } 1643 }
1770 1644
1771 test_ConstructorName_importedClass() async { 1645 test_ConstructorName_importedClass() async {
1772 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName 1646 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName
1773 // InstanceCreationExpression 1647 // InstanceCreationExpression
1774 addSource( 1648 addSource('/testB.dart', '''
1775 '/testB.dart',
1776 '''
1777 lib B; 1649 lib B;
1778 int T1; 1650 int T1;
1779 F1() { } 1651 F1() { }
1780 class X {X.c(); X._d(); z() {}}'''); 1652 class X {X.c(); X._d(); z() {}}''');
1781 addTestSource(''' 1653 addTestSource('''
1782 import "/testB.dart"; 1654 import "/testB.dart";
1783 var m; 1655 var m;
1784 main() {new X.^}'''); 1656 main() {new X.^}''');
1785 1657
1786 await computeSuggestions(); 1658 await computeSuggestions();
1787 expect(replacementOffset, completionOffset); 1659 expect(replacementOffset, completionOffset);
1788 expect(replacementLength, 0); 1660 expect(replacementLength, 0);
1789 // Suggested by NamedConstructorContributor 1661 // Suggested by NamedConstructorContributor
1790 assertNotSuggested('c'); 1662 assertNotSuggested('c');
1791 assertNotSuggested('F1'); 1663 assertNotSuggested('F1');
1792 assertNotSuggested('T1'); 1664 assertNotSuggested('T1');
1793 assertNotSuggested('_d'); 1665 assertNotSuggested('_d');
1794 assertNotSuggested('z'); 1666 assertNotSuggested('z');
1795 assertNotSuggested('m'); 1667 assertNotSuggested('m');
1796 } 1668 }
1797 1669
1798 test_ConstructorName_importedFactory() async { 1670 test_ConstructorName_importedFactory() async {
1799 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName 1671 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName
1800 // InstanceCreationExpression 1672 // InstanceCreationExpression
1801 addSource( 1673 addSource('/testB.dart', '''
1802 '/testB.dart',
1803 '''
1804 lib B; 1674 lib B;
1805 int T1; 1675 int T1;
1806 F1() { } 1676 F1() { }
1807 class X {factory X.c(); factory X._d(); z() {}}'''); 1677 class X {factory X.c(); factory X._d(); z() {}}''');
1808 addTestSource(''' 1678 addTestSource('''
1809 import "/testB.dart"; 1679 import "/testB.dart";
1810 var m; 1680 var m;
1811 main() {new X.^}'''); 1681 main() {new X.^}''');
1812 1682
1813 await computeSuggestions(); 1683 await computeSuggestions();
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1894 expect(replacementLength, 0); 1764 expect(replacementLength, 0);
1895 assertNotSuggested('foo'); 1765 assertNotSuggested('foo');
1896 assertNotSuggested('a'); 1766 assertNotSuggested('a');
1897 assertNotSuggested('A'); 1767 assertNotSuggested('A');
1898 assertSuggestClass('String'); 1768 assertSuggestClass('String');
1899 assertSuggestFunction('identical', 'bool'); 1769 assertSuggestFunction('identical', 'bool');
1900 assertNotSuggested('bar'); 1770 assertNotSuggested('bar');
1901 } 1771 }
1902 1772
1903 test_doc_class() async { 1773 test_doc_class() async {
1904 addSource( 1774 addSource('/libA.dart', r'''
1905 '/libA.dart',
1906 r'''
1907 library A; 1775 library A;
1908 /// My class. 1776 /// My class.
1909 /// Short description. 1777 /// Short description.
1910 /// 1778 ///
1911 /// Longer description. 1779 /// Longer description.
1912 class A {} 1780 class A {}
1913 '''); 1781 ''');
1914 addTestSource('import "/libA.dart"; main() {^}'); 1782 addTestSource('import "/libA.dart"; main() {^}');
1915 1783
1916 await computeSuggestions(); 1784 await computeSuggestions();
1917 1785
1918 CompletionSuggestion suggestion = assertSuggestClass('A'); 1786 CompletionSuggestion suggestion = assertSuggestClass('A');
1919 expect(suggestion.docSummary, 'My class.\nShort description.'); 1787 expect(suggestion.docSummary, 'My class.\nShort description.');
1920 expect(suggestion.docComplete, 1788 expect(suggestion.docComplete,
1921 'My class.\nShort description.\n\nLonger description.'); 1789 'My class.\nShort description.\n\nLonger description.');
1922 } 1790 }
1923 1791
1924 test_doc_function() async { 1792 test_doc_function() async {
1925 resolveSource( 1793 resolveSource('/libA.dart', r'''
1926 '/libA.dart',
1927 r'''
1928 library A; 1794 library A;
1929 /// My function. 1795 /// My function.
1930 /// Short description. 1796 /// Short description.
1931 /// 1797 ///
1932 /// Longer description. 1798 /// Longer description.
1933 int myFunc() {} 1799 int myFunc() {}
1934 '''); 1800 ''');
1935 addTestSource('import "/libA.dart"; main() {^}'); 1801 addTestSource('import "/libA.dart"; main() {^}');
1936 1802
1937 await computeSuggestions(); 1803 await computeSuggestions();
1938 1804
1939 CompletionSuggestion suggestion = assertSuggestFunction('myFunc', 'int'); 1805 CompletionSuggestion suggestion = assertSuggestFunction('myFunc', 'int');
1940 expect(suggestion.docSummary, 'My function.\nShort description.'); 1806 expect(suggestion.docSummary, 'My function.\nShort description.');
1941 expect(suggestion.docComplete, 1807 expect(suggestion.docComplete,
1942 'My function.\nShort description.\n\nLonger description.'); 1808 'My function.\nShort description.\n\nLonger description.');
1943 } 1809 }
1944 1810
1945 test_doc_function_c_style() async { 1811 test_doc_function_c_style() async {
1946 resolveSource( 1812 resolveSource('/libA.dart', r'''
1947 '/libA.dart',
1948 r'''
1949 library A; 1813 library A;
1950 /** 1814 /**
1951 * My function. 1815 * My function.
1952 * Short description. 1816 * Short description.
1953 * 1817 *
1954 * Longer description. 1818 * Longer description.
1955 */ 1819 */
1956 int myFunc() {} 1820 int myFunc() {}
1957 '''); 1821 ''');
1958 addTestSource('import "/libA.dart"; main() {^}'); 1822 addTestSource('import "/libA.dart"; main() {^}');
(...skipping 21 matching lines...) Expand all
1980 await computeSuggestions(); 1844 await computeSuggestions();
1981 // TODO(danrube) investigate why suggestion/element is not deprecated 1845 // TODO(danrube) investigate why suggestion/element is not deprecated
1982 // when AST node has correct @deprecated annotation 1846 // when AST node has correct @deprecated annotation
1983 assertSuggestEnum('E', isDeprecated: true); 1847 assertSuggestEnum('E', isDeprecated: true);
1984 assertNotSuggested('one'); 1848 assertNotSuggested('one');
1985 assertNotSuggested('two'); 1849 assertNotSuggested('two');
1986 } 1850 }
1987 1851
1988 test_ExpressionStatement_identifier() async { 1852 test_ExpressionStatement_identifier() async {
1989 // SimpleIdentifier ExpressionStatement Block 1853 // SimpleIdentifier ExpressionStatement Block
1990 resolveSource( 1854 resolveSource('/testA.dart', '''
1991 '/testA.dart',
1992 '''
1993 _B F1() { } 1855 _B F1() { }
1994 class A {int x;} 1856 class A {int x;}
1995 class _B { }'''); 1857 class _B { }''');
1996 addTestSource(''' 1858 addTestSource('''
1997 import "/testA.dart"; 1859 import "/testA.dart";
1998 typedef int F2(int blat); 1860 typedef int F2(int blat);
1999 class Clz = Object with Object; 1861 class Clz = Object with Object;
2000 class C {foo(){^} void bar() {}}'''); 1862 class C {foo(){^} void bar() {}}''');
2001 1863
2002 await computeSuggestions(); 1864 await computeSuggestions();
2003 expect(replacementOffset, completionOffset); 1865 expect(replacementOffset, completionOffset);
2004 expect(replacementLength, 0); 1866 expect(replacementLength, 0);
2005 assertSuggestClass('A'); 1867 assertSuggestClass('A');
2006 assertSuggestFunction('F1', '_B'); 1868 assertSuggestFunction('F1', '_B');
2007 assertNotSuggested('C'); 1869 assertNotSuggested('C');
2008 assertNotSuggested('foo'); 1870 assertNotSuggested('foo');
2009 assertNotSuggested('bar'); 1871 assertNotSuggested('bar');
2010 assertNotSuggested('F2'); 1872 assertNotSuggested('F2');
2011 assertNotSuggested('Clz'); 1873 assertNotSuggested('Clz');
2012 assertNotSuggested('C'); 1874 assertNotSuggested('C');
2013 assertNotSuggested('x'); 1875 assertNotSuggested('x');
2014 assertNotSuggested('_B'); 1876 assertNotSuggested('_B');
2015 } 1877 }
2016 1878
2017 test_ExpressionStatement_name() async { 1879 test_ExpressionStatement_name() async {
2018 // ExpressionStatement Block BlockFunctionBody MethodDeclaration 1880 // ExpressionStatement Block BlockFunctionBody MethodDeclaration
2019 addSource( 1881 addSource('/testA.dart', '''
2020 '/testA.dart',
2021 '''
2022 B T1; 1882 B T1;
2023 class B{}'''); 1883 class B{}''');
2024 addTestSource(''' 1884 addTestSource('''
2025 import "/testA.dart"; 1885 import "/testA.dart";
2026 class C {a() {C ^}}'''); 1886 class C {a() {C ^}}''');
2027 1887
2028 await computeSuggestions(); 1888 await computeSuggestions();
2029 assertNoSuggestions(); 1889 assertNoSuggestions();
2030 } 1890 }
2031 1891
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
2219 2079
2220 await computeSuggestions(); 2080 await computeSuggestions();
2221 expect(replacementOffset, completionOffset - 1); 2081 expect(replacementOffset, completionOffset - 1);
2222 expect(replacementLength, 1); 2082 expect(replacementLength, 1);
2223 assertNotSuggested('index'); 2083 assertNotSuggested('index');
2224 assertNotSuggested('main'); 2084 assertNotSuggested('main');
2225 assertNotSuggested('bar'); 2085 assertNotSuggested('bar');
2226 } 2086 }
2227 2087
2228 test_function_parameters_mixed_required_and_named() async { 2088 test_function_parameters_mixed_required_and_named() async {
2229 resolveSource( 2089 resolveSource('/libA.dart', '''
2230 '/libA.dart',
2231 '''
2232 int m(x, {int y}) {} 2090 int m(x, {int y}) {}
2233 '''); 2091 ''');
2234 addTestSource(''' 2092 addTestSource('''
2235 import '/libA.dart'; 2093 import '/libA.dart';
2236 class B extends A { 2094 class B extends A {
2237 main() {^} 2095 main() {^}
2238 } 2096 }
2239 '''); 2097 ''');
2240 await computeSuggestions(); 2098 await computeSuggestions();
2241 CompletionSuggestion suggestion = assertSuggestFunction('m', 'int'); 2099 CompletionSuggestion suggestion = assertSuggestFunction('m', 'int');
2242 expect(suggestion.parameterNames, hasLength(2)); 2100 expect(suggestion.parameterNames, hasLength(2));
2243 expect(suggestion.parameterNames[0], 'x'); 2101 expect(suggestion.parameterNames[0], 'x');
2244 expect(suggestion.parameterTypes[0], 'dynamic'); 2102 expect(suggestion.parameterTypes[0], 'dynamic');
2245 expect(suggestion.parameterNames[1], 'y'); 2103 expect(suggestion.parameterNames[1], 'y');
2246 expect(suggestion.parameterTypes[1], 'int'); 2104 expect(suggestion.parameterTypes[1], 'int');
2247 expect(suggestion.requiredParameterCount, 1); 2105 expect(suggestion.requiredParameterCount, 1);
2248 expect(suggestion.hasNamedParameters, true); 2106 expect(suggestion.hasNamedParameters, true);
2249 } 2107 }
2250 2108
2251 test_function_parameters_mixed_required_and_positional() async { 2109 test_function_parameters_mixed_required_and_positional() async {
2252 resolveSource( 2110 resolveSource('/libA.dart', '''
2253 '/libA.dart',
2254 '''
2255 void m(x, [int y]) {} 2111 void m(x, [int y]) {}
2256 '''); 2112 ''');
2257 addTestSource(''' 2113 addTestSource('''
2258 import '/libA.dart'; 2114 import '/libA.dart';
2259 class B extends A { 2115 class B extends A {
2260 main() {^} 2116 main() {^}
2261 } 2117 }
2262 '''); 2118 ''');
2263 await computeSuggestions(); 2119 await computeSuggestions();
2264 CompletionSuggestion suggestion = assertSuggestFunction('m', 'void'); 2120 CompletionSuggestion suggestion = assertSuggestFunction('m', 'void');
2265 expect(suggestion.parameterNames, hasLength(2)); 2121 expect(suggestion.parameterNames, hasLength(2));
2266 expect(suggestion.parameterNames[0], 'x'); 2122 expect(suggestion.parameterNames[0], 'x');
2267 expect(suggestion.parameterTypes[0], 'dynamic'); 2123 expect(suggestion.parameterTypes[0], 'dynamic');
2268 expect(suggestion.parameterNames[1], 'y'); 2124 expect(suggestion.parameterNames[1], 'y');
2269 expect(suggestion.parameterTypes[1], 'int'); 2125 expect(suggestion.parameterTypes[1], 'int');
2270 expect(suggestion.requiredParameterCount, 1); 2126 expect(suggestion.requiredParameterCount, 1);
2271 expect(suggestion.hasNamedParameters, false); 2127 expect(suggestion.hasNamedParameters, false);
2272 } 2128 }
2273 2129
2274 test_function_parameters_named() async { 2130 test_function_parameters_named() async {
2275 resolveSource( 2131 resolveSource('/libA.dart', '''
2276 '/libA.dart',
2277 '''
2278 void m({x, int y}) {} 2132 void m({x, int y}) {}
2279 '''); 2133 ''');
2280 addTestSource(''' 2134 addTestSource('''
2281 import '/libA.dart'; 2135 import '/libA.dart';
2282 class B extends A { 2136 class B extends A {
2283 main() {^} 2137 main() {^}
2284 } 2138 }
2285 '''); 2139 ''');
2286 await computeSuggestions(); 2140 await computeSuggestions();
2287 CompletionSuggestion suggestion = assertSuggestFunction('m', 'void'); 2141 CompletionSuggestion suggestion = assertSuggestFunction('m', 'void');
2288 expect(suggestion.parameterNames, hasLength(2)); 2142 expect(suggestion.parameterNames, hasLength(2));
2289 expect(suggestion.parameterNames[0], 'x'); 2143 expect(suggestion.parameterNames[0], 'x');
2290 expect(suggestion.parameterTypes[0], 'dynamic'); 2144 expect(suggestion.parameterTypes[0], 'dynamic');
2291 expect(suggestion.parameterNames[1], 'y'); 2145 expect(suggestion.parameterNames[1], 'y');
2292 expect(suggestion.parameterTypes[1], 'int'); 2146 expect(suggestion.parameterTypes[1], 'int');
2293 expect(suggestion.requiredParameterCount, 0); 2147 expect(suggestion.requiredParameterCount, 0);
2294 expect(suggestion.hasNamedParameters, true); 2148 expect(suggestion.hasNamedParameters, true);
2295 } 2149 }
2296 2150
2297 test_function_parameters_none() async { 2151 test_function_parameters_none() async {
2298 resolveSource( 2152 resolveSource('/libA.dart', '''
2299 '/libA.dart',
2300 '''
2301 void m() {} 2153 void m() {}
2302 '''); 2154 ''');
2303 addTestSource(''' 2155 addTestSource('''
2304 import '/libA.dart'; 2156 import '/libA.dart';
2305 class B extends A { 2157 class B extends A {
2306 main() {^} 2158 main() {^}
2307 } 2159 }
2308 '''); 2160 ''');
2309 2161
2310 await computeSuggestions(); 2162 await computeSuggestions();
2311 CompletionSuggestion suggestion = assertSuggestFunction('m', 'void'); 2163 CompletionSuggestion suggestion = assertSuggestFunction('m', 'void');
2312 expect(suggestion.parameterNames, isEmpty); 2164 expect(suggestion.parameterNames, isEmpty);
2313 expect(suggestion.parameterTypes, isEmpty); 2165 expect(suggestion.parameterTypes, isEmpty);
2314 expect(suggestion.requiredParameterCount, 0); 2166 expect(suggestion.requiredParameterCount, 0);
2315 expect(suggestion.hasNamedParameters, false); 2167 expect(suggestion.hasNamedParameters, false);
2316 } 2168 }
2317 2169
2318 test_function_parameters_positional() async { 2170 test_function_parameters_positional() async {
2319 resolveSource( 2171 resolveSource('/libA.dart', '''
2320 '/libA.dart',
2321 '''
2322 void m([x, int y]) {} 2172 void m([x, int y]) {}
2323 '''); 2173 ''');
2324 addTestSource(''' 2174 addTestSource('''
2325 import '/libA.dart'; 2175 import '/libA.dart';
2326 class B extends A { 2176 class B extends A {
2327 main() {^} 2177 main() {^}
2328 } 2178 }
2329 '''); 2179 ''');
2330 await computeSuggestions(); 2180 await computeSuggestions();
2331 CompletionSuggestion suggestion = assertSuggestFunction('m', 'void'); 2181 CompletionSuggestion suggestion = assertSuggestFunction('m', 'void');
2332 expect(suggestion.parameterNames, hasLength(2)); 2182 expect(suggestion.parameterNames, hasLength(2));
2333 expect(suggestion.parameterNames[0], 'x'); 2183 expect(suggestion.parameterNames[0], 'x');
2334 expect(suggestion.parameterTypes[0], 'dynamic'); 2184 expect(suggestion.parameterTypes[0], 'dynamic');
2335 expect(suggestion.parameterNames[1], 'y'); 2185 expect(suggestion.parameterNames[1], 'y');
2336 expect(suggestion.parameterTypes[1], 'int'); 2186 expect(suggestion.parameterTypes[1], 'int');
2337 expect(suggestion.requiredParameterCount, 0); 2187 expect(suggestion.requiredParameterCount, 0);
2338 expect(suggestion.hasNamedParameters, false); 2188 expect(suggestion.hasNamedParameters, false);
2339 } 2189 }
2340 2190
2341 test_function_parameters_required() async { 2191 test_function_parameters_required() async {
2342 resolveSource( 2192 resolveSource('/libA.dart', '''
2343 '/libA.dart',
2344 '''
2345 void m(x, int y) {} 2193 void m(x, int y) {}
2346 '''); 2194 ''');
2347 addTestSource(''' 2195 addTestSource('''
2348 import '/libA.dart'; 2196 import '/libA.dart';
2349 class B extends A { 2197 class B extends A {
2350 main() {^} 2198 main() {^}
2351 } 2199 }
2352 '''); 2200 ''');
2353 await computeSuggestions(); 2201 await computeSuggestions();
2354 CompletionSuggestion suggestion = assertSuggestFunction('m', 'void'); 2202 CompletionSuggestion suggestion = assertSuggestFunction('m', 'void');
2355 expect(suggestion.parameterNames, hasLength(2)); 2203 expect(suggestion.parameterNames, hasLength(2));
2356 expect(suggestion.parameterNames[0], 'x'); 2204 expect(suggestion.parameterNames[0], 'x');
2357 expect(suggestion.parameterTypes[0], 'dynamic'); 2205 expect(suggestion.parameterTypes[0], 'dynamic');
2358 expect(suggestion.parameterNames[1], 'y'); 2206 expect(suggestion.parameterNames[1], 'y');
2359 expect(suggestion.parameterTypes[1], 'int'); 2207 expect(suggestion.parameterTypes[1], 'int');
2360 expect(suggestion.requiredParameterCount, 2); 2208 expect(suggestion.requiredParameterCount, 2);
2361 expect(suggestion.hasNamedParameters, false); 2209 expect(suggestion.hasNamedParameters, false);
2362 } 2210 }
2363 2211
2364 test_FunctionDeclaration_returnType_afterComment() async { 2212 test_FunctionDeclaration_returnType_afterComment() async {
2365 // ClassDeclaration CompilationUnit 2213 // ClassDeclaration CompilationUnit
2366 resolveSource( 2214 resolveSource('/testA.dart', '''
2367 '/testA.dart',
2368 '''
2369 int T1; 2215 int T1;
2370 F1() { } 2216 F1() { }
2371 typedef D1(); 2217 typedef D1();
2372 class C1 {C1(this.x) { } int x;}'''); 2218 class C1 {C1(this.x) { } int x;}''');
2373 addTestSource(''' 2219 addTestSource('''
2374 import "/testA.dart"; 2220 import "/testA.dart";
2375 int T2; 2221 int T2;
2376 F2() { } 2222 F2() { }
2377 typedef D2(); 2223 typedef D2();
2378 class C2 { } 2224 class C2 { }
2379 /* */ ^ zoo(z) { } String name;'''); 2225 /* */ ^ zoo(z) { } String name;''');
2380 2226
2381 await computeSuggestions(); 2227 await computeSuggestions();
2382 expect(replacementOffset, completionOffset); 2228 expect(replacementOffset, completionOffset);
2383 expect(replacementLength, 0); 2229 expect(replacementLength, 0);
2384 assertSuggestClass('Object'); 2230 assertSuggestClass('Object');
2385 assertNotSuggested('T1'); 2231 assertNotSuggested('T1');
2386 assertNotSuggested('F1'); 2232 assertNotSuggested('F1');
2387 assertSuggestFunctionTypeAlias('D1', 'dynamic'); 2233 assertSuggestFunctionTypeAlias('D1', 'dynamic');
2388 assertSuggestClass('C1'); 2234 assertSuggestClass('C1');
2389 assertNotSuggested('T2'); 2235 assertNotSuggested('T2');
2390 assertNotSuggested('F2'); 2236 assertNotSuggested('F2');
2391 assertNotSuggested('D2'); 2237 assertNotSuggested('D2');
2392 assertNotSuggested('C2'); 2238 assertNotSuggested('C2');
2393 assertNotSuggested('name'); 2239 assertNotSuggested('name');
2394 } 2240 }
2395 2241
2396 test_FunctionDeclaration_returnType_afterComment2() async { 2242 test_FunctionDeclaration_returnType_afterComment2() async {
2397 // FunctionDeclaration ClassDeclaration CompilationUnit 2243 // FunctionDeclaration ClassDeclaration CompilationUnit
2398 resolveSource( 2244 resolveSource('/testA.dart', '''
2399 '/testA.dart',
2400 '''
2401 int T1; 2245 int T1;
2402 F1() { } 2246 F1() { }
2403 typedef D1(); 2247 typedef D1();
2404 class C1 {C1(this.x) { } int x;}'''); 2248 class C1 {C1(this.x) { } int x;}''');
2405 addTestSource(''' 2249 addTestSource('''
2406 import "/testA.dart"; 2250 import "/testA.dart";
2407 int T2; 2251 int T2;
2408 F2() { } 2252 F2() { }
2409 typedef D2(); 2253 typedef D2();
2410 class C2 { } 2254 class C2 { }
2411 /** */ ^ zoo(z) { } String name;'''); 2255 /** */ ^ zoo(z) { } String name;''');
2412 2256
2413 await computeSuggestions(); 2257 await computeSuggestions();
2414 expect(replacementOffset, completionOffset); 2258 expect(replacementOffset, completionOffset);
2415 expect(replacementLength, 0); 2259 expect(replacementLength, 0);
2416 assertSuggestClass('Object'); 2260 assertSuggestClass('Object');
2417 assertNotSuggested('T1'); 2261 assertNotSuggested('T1');
2418 assertNotSuggested('F1'); 2262 assertNotSuggested('F1');
2419 assertSuggestFunctionTypeAlias('D1', 'dynamic'); 2263 assertSuggestFunctionTypeAlias('D1', 'dynamic');
2420 assertSuggestClass('C1'); 2264 assertSuggestClass('C1');
2421 assertNotSuggested('T2'); 2265 assertNotSuggested('T2');
2422 assertNotSuggested('F2'); 2266 assertNotSuggested('F2');
2423 assertNotSuggested('D2'); 2267 assertNotSuggested('D2');
2424 assertNotSuggested('C2'); 2268 assertNotSuggested('C2');
2425 assertNotSuggested('name'); 2269 assertNotSuggested('name');
2426 } 2270 }
2427 2271
2428 test_FunctionDeclaration_returnType_afterComment3() async { 2272 test_FunctionDeclaration_returnType_afterComment3() async {
2429 // FunctionDeclaration ClassDeclaration CompilationUnit 2273 // FunctionDeclaration ClassDeclaration CompilationUnit
2430 resolveSource( 2274 resolveSource('/testA.dart', '''
2431 '/testA.dart',
2432 '''
2433 int T1; 2275 int T1;
2434 F1() { } 2276 F1() { }
2435 typedef D1(); 2277 typedef D1();
2436 class C1 {C1(this.x) { } int x;}'''); 2278 class C1 {C1(this.x) { } int x;}''');
2437 addTestSource(''' 2279 addTestSource('''
2438 import "/testA.dart"; 2280 import "/testA.dart";
2439 int T2; 2281 int T2;
2440 F2() { } 2282 F2() { }
2441 typedef D2(); 2283 typedef D2();
2442 /// some dartdoc 2284 /// some dartdoc
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
2544 addTestSource(''' 2386 addTestSource('''
2545 import "dart^"; 2387 import "dart^";
2546 main() {}'''); 2388 main() {}''');
2547 2389
2548 await computeSuggestions(); 2390 await computeSuggestions();
2549 assertNoSuggestions(); 2391 assertNoSuggestions();
2550 } 2392 }
2551 2393
2552 test_IndexExpression() async { 2394 test_IndexExpression() async {
2553 // ExpressionStatement Block 2395 // ExpressionStatement Block
2554 resolveSource( 2396 resolveSource('/testA.dart', '''
2555 '/testA.dart',
2556 '''
2557 int T1; 2397 int T1;
2558 F1() { } 2398 F1() { }
2559 class A {int x;}'''); 2399 class A {int x;}''');
2560 addTestSource(''' 2400 addTestSource('''
2561 import "/testA.dart"; 2401 import "/testA.dart";
2562 int T2; 2402 int T2;
2563 F2() { } 2403 F2() { }
2564 class B {int x;} 2404 class B {int x;}
2565 class C {foo(){var f; {var x;} f[^]}}'''); 2405 class C {foo(){var f; {var x;} f[^]}}''');
2566 2406
2567 await computeSuggestions(); 2407 await computeSuggestions();
2568 assertNotSuggested('x'); 2408 assertNotSuggested('x');
2569 assertNotSuggested('f'); 2409 assertNotSuggested('f');
2570 assertNotSuggested('foo'); 2410 assertNotSuggested('foo');
2571 assertNotSuggested('C'); 2411 assertNotSuggested('C');
2572 assertNotSuggested('F2'); 2412 assertNotSuggested('F2');
2573 assertNotSuggested('T2'); 2413 assertNotSuggested('T2');
2574 assertSuggestClass('A'); 2414 assertSuggestClass('A');
2575 assertSuggestFunction('F1', 'dynamic'); 2415 assertSuggestFunction('F1', 'dynamic');
2576 // TODO (danrubel) getter is being suggested instead of top level var 2416 // TODO (danrubel) getter is being suggested instead of top level var
2577 //assertSuggestImportedTopLevelVar('T1', 'int'); 2417 //assertSuggestImportedTopLevelVar('T1', 'int');
2578 } 2418 }
2579 2419
2580 test_IndexExpression2() async { 2420 test_IndexExpression2() async {
2581 // SimpleIdentifier IndexExpression ExpressionStatement Block 2421 // SimpleIdentifier IndexExpression ExpressionStatement Block
2582 addSource( 2422 addSource('/testA.dart', '''
2583 '/testA.dart',
2584 '''
2585 int T1; 2423 int T1;
2586 F1() { } 2424 F1() { }
2587 class A {int x;}'''); 2425 class A {int x;}''');
2588 addTestSource(''' 2426 addTestSource('''
2589 import "/testA.dart"; 2427 import "/testA.dart";
2590 int T2; 2428 int T2;
2591 F2() { } 2429 F2() { }
2592 class B {int x;} 2430 class B {int x;}
2593 class C {foo(){var f; {var x;} f[T^]}}'''); 2431 class C {foo(){var f; {var x;} f[T^]}}''');
2594 2432
2595 await computeSuggestions(); 2433 await computeSuggestions();
2596 // top level results are partially filtered based on first char 2434 // top level results are partially filtered based on first char
2597 assertNotSuggested('T2'); 2435 assertNotSuggested('T2');
2598 // TODO (danrubel) getter is being suggested instead of top level var 2436 // TODO (danrubel) getter is being suggested instead of top level var
2599 //assertSuggestImportedTopLevelVar('T1', 'int'); 2437 //assertSuggestImportedTopLevelVar('T1', 'int');
2600 } 2438 }
2601 2439
2602 test_InstanceCreationExpression() async { 2440 test_InstanceCreationExpression() async {
2603 resolveSource( 2441 resolveSource('/testA.dart', '''
2604 '/testA.dart',
2605 '''
2606 class A {foo(){var f; {var x;}}} 2442 class A {foo(){var f; {var x;}}}
2607 class B {B(this.x, [String boo]) { } int x;} 2443 class B {B(this.x, [String boo]) { } int x;}
2608 class C {C.bar({boo: 'hoo', int z: 0}) { } }'''); 2444 class C {C.bar({boo: 'hoo', int z: 0}) { } }''');
2609 addTestSource(''' 2445 addTestSource('''
2610 import "/testA.dart"; 2446 import "/testA.dart";
2611 import "dart:math" as math; 2447 import "dart:math" as math;
2612 main() {new ^ String x = "hello";}'''); 2448 main() {new ^ String x = "hello";}''');
2613 2449
2614 await computeSuggestions(); 2450 await computeSuggestions();
2615 CompletionSuggestion suggestion; 2451 CompletionSuggestion suggestion;
(...skipping 29 matching lines...) Expand all
2645 expect(suggestion.parameterTypes[1], 'int'); 2481 expect(suggestion.parameterTypes[1], 'int');
2646 expect(suggestion.requiredParameterCount, 0); 2482 expect(suggestion.requiredParameterCount, 0);
2647 expect(suggestion.hasNamedParameters, true); 2483 expect(suggestion.hasNamedParameters, true);
2648 2484
2649 // Suggested by LibraryPrefixContributor 2485 // Suggested by LibraryPrefixContributor
2650 assertNotSuggested('math'); 2486 assertNotSuggested('math');
2651 } 2487 }
2652 2488
2653 test_InstanceCreationExpression_imported() async { 2489 test_InstanceCreationExpression_imported() async {
2654 // SimpleIdentifier TypeName ConstructorName InstanceCreationExpression 2490 // SimpleIdentifier TypeName ConstructorName InstanceCreationExpression
2655 addSource( 2491 addSource('/testA.dart', '''
2656 '/testA.dart',
2657 '''
2658 int T1; 2492 int T1;
2659 F1() { } 2493 F1() { }
2660 class A {A(this.x) { } int x;}'''); 2494 class A {A(this.x) { } int x;}''');
2661 addTestSource(''' 2495 addTestSource('''
2662 import "/testA.dart"; 2496 import "/testA.dart";
2663 import "dart:async"; 2497 import "dart:async";
2664 int T2; 2498 int T2;
2665 F2() { } 2499 F2() { }
2666 class B {B(this.x, [String boo]) { } int x;} 2500 class B {B(this.x, [String boo]) { } int x;}
2667 class C {foo(){var f; {var x;} new ^}}'''); 2501 class C {foo(){var f; {var x;} new ^}}''');
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2708 await computeSuggestions(); 2542 await computeSuggestions();
2709 assertSuggest('print'); 2543 assertSuggest('print');
2710 // Not imported, so not suggested 2544 // Not imported, so not suggested
2711 assertNotSuggested('pow'); 2545 assertNotSuggested('pow');
2712 // Do not suggest completions from internal SDK library 2546 // Do not suggest completions from internal SDK library
2713 assertNotSuggested('printToConsole'); 2547 assertNotSuggested('printToConsole');
2714 } 2548 }
2715 2549
2716 test_InterpolationExpression() async { 2550 test_InterpolationExpression() async {
2717 // SimpleIdentifier InterpolationExpression StringInterpolation 2551 // SimpleIdentifier InterpolationExpression StringInterpolation
2718 addSource( 2552 addSource('/testA.dart', '''
2719 '/testA.dart',
2720 '''
2721 int T1; 2553 int T1;
2722 F1() { } 2554 F1() { }
2723 typedef D1(); 2555 typedef D1();
2724 class C1 {C1(this.x) { } int x;}'''); 2556 class C1 {C1(this.x) { } int x;}''');
2725 addTestSource(''' 2557 addTestSource('''
2726 import "/testA.dart"; 2558 import "/testA.dart";
2727 int T2; 2559 int T2;
2728 F2() { } 2560 F2() { }
2729 typedef D2(); 2561 typedef D2();
2730 class C2 { } 2562 class C2 { }
2731 main() {String name; print("hello \$^");}'''); 2563 main() {String name; print("hello \$^");}''');
2732 2564
2733 await computeSuggestions(); 2565 await computeSuggestions();
2734 expect(replacementOffset, completionOffset); 2566 expect(replacementOffset, completionOffset);
2735 expect(replacementLength, 0); 2567 expect(replacementLength, 0);
2736 assertNotSuggested('Object'); 2568 assertNotSuggested('Object');
2737 assertSuggestTopLevelVar('T1', null); 2569 assertSuggestTopLevelVar('T1', null);
2738 assertSuggestFunction('F1', null); 2570 assertSuggestFunction('F1', null);
2739 assertNotSuggested('D1'); 2571 assertNotSuggested('D1');
2740 assertNotSuggested('C1'); 2572 assertNotSuggested('C1');
2741 assertNotSuggested('T2'); 2573 assertNotSuggested('T2');
2742 assertNotSuggested('F2'); 2574 assertNotSuggested('F2');
2743 assertNotSuggested('D2'); 2575 assertNotSuggested('D2');
2744 assertNotSuggested('C2'); 2576 assertNotSuggested('C2');
2745 assertNotSuggested('name'); 2577 assertNotSuggested('name');
2746 } 2578 }
2747 2579
2748 test_InterpolationExpression_block() async { 2580 test_InterpolationExpression_block() async {
2749 // SimpleIdentifier InterpolationExpression StringInterpolation 2581 // SimpleIdentifier InterpolationExpression StringInterpolation
2750 addSource( 2582 addSource('/testA.dart', '''
2751 '/testA.dart',
2752 '''
2753 int T1; 2583 int T1;
2754 F1() { } 2584 F1() { }
2755 typedef D1(); 2585 typedef D1();
2756 class C1 {C1(this.x) { } int x;}'''); 2586 class C1 {C1(this.x) { } int x;}''');
2757 addTestSource(''' 2587 addTestSource('''
2758 import "/testA.dart"; 2588 import "/testA.dart";
2759 int T2; 2589 int T2;
2760 F2() { } 2590 F2() { }
2761 typedef D2(); 2591 typedef D2();
2762 class C2 { } 2592 class C2 { }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2816 2646
2817 await computeSuggestions(); 2647 await computeSuggestions();
2818 assertNotSuggested('name'); 2648 assertNotSuggested('name');
2819 // top level results are partially filtered 2649 // top level results are partially filtered
2820 //assertSuggestClass('Object'); 2650 //assertSuggestClass('Object');
2821 assertNotSuggested('length'); 2651 assertNotSuggested('length');
2822 } 2652 }
2823 2653
2824 test_IsExpression() async { 2654 test_IsExpression() async {
2825 // SimpleIdentifier TypeName IsExpression IfStatement 2655 // SimpleIdentifier TypeName IsExpression IfStatement
2826 addSource( 2656 addSource('/testB.dart', '''
2827 '/testB.dart',
2828 '''
2829 lib B; 2657 lib B;
2830 foo() { } 2658 foo() { }
2831 class X {X.c(); X._d(); z() {}}'''); 2659 class X {X.c(); X._d(); z() {}}''');
2832 addTestSource(''' 2660 addTestSource('''
2833 import "/testB.dart"; 2661 import "/testB.dart";
2834 class Y {Y.c(); Y._d(); z() {}} 2662 class Y {Y.c(); Y._d(); z() {}}
2835 main() {var x; if (x is ^) { }}'''); 2663 main() {var x; if (x is ^) { }}''');
2836 2664
2837 await computeSuggestions(); 2665 await computeSuggestions();
2838 expect(replacementOffset, completionOffset); 2666 expect(replacementOffset, completionOffset);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2888 expect(replacementOffset, completionOffset - 3); 2716 expect(replacementOffset, completionOffset - 3);
2889 expect(replacementLength, 3); 2717 expect(replacementLength, 3);
2890 assertNotSuggested('a'); 2718 assertNotSuggested('a');
2891 assertNotSuggested('main'); 2719 assertNotSuggested('main');
2892 assertNotSuggested('A'); 2720 assertNotSuggested('A');
2893 assertSuggestClass('Object'); 2721 assertSuggestClass('Object');
2894 } 2722 }
2895 2723
2896 test_IsExpression_type_subtype_extends_filter() async { 2724 test_IsExpression_type_subtype_extends_filter() async {
2897 // SimpleIdentifier TypeName IsExpression IfStatement 2725 // SimpleIdentifier TypeName IsExpression IfStatement
2898 addSource( 2726 addSource('/testB.dart', '''
2899 '/testB.dart',
2900 '''
2901 foo() { } 2727 foo() { }
2902 class A {} class B extends A {} class C extends B {} 2728 class A {} class B extends A {} class C extends B {}
2903 class X {X.c(); X._d(); z() {}}'''); 2729 class X {X.c(); X._d(); z() {}}''');
2904 addTestSource(''' 2730 addTestSource('''
2905 import "/testB.dart"; 2731 import "/testB.dart";
2906 main(){A a; if (a is ^)}'''); 2732 main(){A a; if (a is ^)}''');
2907 2733
2908 await computeSuggestions(); 2734 await computeSuggestions();
2909 expect(replacementOffset, completionOffset); 2735 expect(replacementOffset, completionOffset);
2910 expect(replacementLength, 0); 2736 expect(replacementLength, 0);
2911 assertSuggestClass('B'); 2737 assertSuggestClass('B');
2912 assertSuggestClass('C'); 2738 assertSuggestClass('C');
2913 assertNotSuggested('A'); 2739 assertNotSuggested('A');
2914 assertNotSuggested('X'); 2740 assertNotSuggested('X');
2915 assertNotSuggested('Object'); 2741 assertNotSuggested('Object');
2916 assertNotSuggested('a'); 2742 assertNotSuggested('a');
2917 assertNotSuggested('main'); 2743 assertNotSuggested('main');
2918 } 2744 }
2919 2745
2920 test_IsExpression_type_subtype_implements_filter() async { 2746 test_IsExpression_type_subtype_implements_filter() async {
2921 // SimpleIdentifier TypeName IsExpression IfStatement 2747 // SimpleIdentifier TypeName IsExpression IfStatement
2922 addSource( 2748 addSource('/testB.dart', '''
2923 '/testB.dart',
2924 '''
2925 foo() { } 2749 foo() { }
2926 class A {} class B implements A {} class C implements B {} 2750 class A {} class B implements A {} class C implements B {}
2927 class X {X.c(); X._d(); z() {}}'''); 2751 class X {X.c(); X._d(); z() {}}''');
2928 addTestSource(''' 2752 addTestSource('''
2929 import "/testB.dart"; 2753 import "/testB.dart";
2930 main(){A a; if (a is ^)}'''); 2754 main(){A a; if (a is ^)}''');
2931 2755
2932 await computeSuggestions(); 2756 await computeSuggestions();
2933 expect(replacementOffset, completionOffset); 2757 expect(replacementOffset, completionOffset);
2934 expect(replacementLength, 0); 2758 expect(replacementLength, 0);
2935 assertSuggestClass('B'); 2759 assertSuggestClass('B');
2936 assertSuggestClass('C'); 2760 assertSuggestClass('C');
2937 assertNotSuggested('A'); 2761 assertNotSuggested('A');
2938 assertNotSuggested('X'); 2762 assertNotSuggested('X');
2939 assertNotSuggested('Object'); 2763 assertNotSuggested('Object');
2940 assertNotSuggested('a'); 2764 assertNotSuggested('a');
2941 assertNotSuggested('main'); 2765 assertNotSuggested('main');
2942 } 2766 }
2943 2767
2944 test_keyword() async { 2768 test_keyword() async {
2945 resolveSource( 2769 resolveSource('/testB.dart', '''
2946 '/testB.dart',
2947 '''
2948 lib B; 2770 lib B;
2949 int newT1; 2771 int newT1;
2950 int T1; 2772 int T1;
2951 nowIsIt() { } 2773 nowIsIt() { }
2952 class X {factory X.c(); factory X._d(); z() {}}'''); 2774 class X {factory X.c(); factory X._d(); z() {}}''');
2953 addTestSource(''' 2775 addTestSource('''
2954 import "/testB.dart"; 2776 import "/testB.dart";
2955 String newer() {} 2777 String newer() {}
2956 var m; 2778 var m;
2957 main() {new^ X.c();}'''); 2779 main() {new^ X.c();}''');
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2998 2820
2999 test_localVariableDeclarationName() async { 2821 test_localVariableDeclarationName() async {
3000 addTestSource('main() {String m^}'); 2822 addTestSource('main() {String m^}');
3001 await computeSuggestions(); 2823 await computeSuggestions();
3002 assertNotSuggested('main'); 2824 assertNotSuggested('main');
3003 assertNotSuggested('min'); 2825 assertNotSuggested('min');
3004 } 2826 }
3005 2827
3006 test_MapLiteralEntry() async { 2828 test_MapLiteralEntry() async {
3007 // MapLiteralEntry MapLiteral VariableDeclaration 2829 // MapLiteralEntry MapLiteral VariableDeclaration
3008 addSource( 2830 addSource('/testA.dart', '''
3009 '/testA.dart',
3010 '''
3011 int T1; 2831 int T1;
3012 F1() { } 2832 F1() { }
3013 typedef D1(); 2833 typedef D1();
3014 class C1 {C1(this.x) { } int x;}'''); 2834 class C1 {C1(this.x) { } int x;}''');
3015 addTestSource(''' 2835 addTestSource('''
3016 import "/testA.dart"; 2836 import "/testA.dart";
3017 int T2; 2837 int T2;
3018 F2() { } 2838 F2() { }
3019 typedef D2(); 2839 typedef D2();
3020 class C2 { } 2840 class C2 { }
(...skipping 13 matching lines...) Expand all
3034 assertSuggestFunctionTypeAlias('D1', /* null */ 'dynamic'); 2854 assertSuggestFunctionTypeAlias('D1', /* null */ 'dynamic');
3035 assertSuggestClass('C1'); 2855 assertSuggestClass('C1');
3036 assertNotSuggested('T2'); 2856 assertNotSuggested('T2');
3037 assertNotSuggested('F2'); 2857 assertNotSuggested('F2');
3038 assertNotSuggested('D2'); 2858 assertNotSuggested('D2');
3039 assertNotSuggested('C2'); 2859 assertNotSuggested('C2');
3040 } 2860 }
3041 2861
3042 test_MapLiteralEntry1() async { 2862 test_MapLiteralEntry1() async {
3043 // MapLiteralEntry MapLiteral VariableDeclaration 2863 // MapLiteralEntry MapLiteral VariableDeclaration
3044 addSource( 2864 addSource('/testA.dart', '''
3045 '/testA.dart',
3046 '''
3047 int T1; 2865 int T1;
3048 F1() { } 2866 F1() { }
3049 typedef D1(); 2867 typedef D1();
3050 class C1 {C1(this.x) { } int x;}'''); 2868 class C1 {C1(this.x) { } int x;}''');
3051 addTestSource(''' 2869 addTestSource('''
3052 import "/testA.dart"; 2870 import "/testA.dart";
3053 int T2; 2871 int T2;
3054 F2() { } 2872 F2() { }
3055 typedef D2(); 2873 typedef D2();
3056 class C2 { } 2874 class C2 { }
3057 foo = {T^'''); 2875 foo = {T^''');
3058 2876
3059 await computeSuggestions(); 2877 await computeSuggestions();
3060 expect(replacementOffset, completionOffset - 1); 2878 expect(replacementOffset, completionOffset - 1);
3061 expect(replacementLength, 1); 2879 expect(replacementLength, 1);
3062 // Simulate unresolved imported library, 2880 // Simulate unresolved imported library,
3063 // in which case suggestions will have null return types (unresolved) 2881 // in which case suggestions will have null return types (unresolved)
3064 // The current DartCompletionRequest#resolveExpression resolves 2882 // The current DartCompletionRequest#resolveExpression resolves
3065 // the world (which it should not) and causes the imported library 2883 // the world (which it should not) and causes the imported library
3066 // to be resolved. 2884 // to be resolved.
3067 assertSuggestTopLevelVar('T1', /* null */ 'int'); 2885 assertSuggestTopLevelVar('T1', /* null */ 'int');
3068 assertNotSuggested('T2'); 2886 assertNotSuggested('T2');
3069 } 2887 }
3070 2888
3071 test_MapLiteralEntry2() async { 2889 test_MapLiteralEntry2() async {
3072 // SimpleIdentifier MapLiteralEntry MapLiteral VariableDeclaration 2890 // SimpleIdentifier MapLiteralEntry MapLiteral VariableDeclaration
3073 resolveSource( 2891 resolveSource('/testA.dart', '''
3074 '/testA.dart',
3075 '''
3076 int T1; 2892 int T1;
3077 F1() { } 2893 F1() { }
3078 typedef D1(); 2894 typedef D1();
3079 class C1 {C1(this.x) { } int x;}'''); 2895 class C1 {C1(this.x) { } int x;}''');
3080 addTestSource(''' 2896 addTestSource('''
3081 import "/testA.dart"; 2897 import "/testA.dart";
3082 int T2; 2898 int T2;
3083 F2() { } 2899 F2() { }
3084 typedef D2(); 2900 typedef D2();
3085 class C2 { } 2901 class C2 { }
3086 foo = {7:T^};'''); 2902 foo = {7:T^};''');
3087 2903
3088 await computeSuggestions(); 2904 await computeSuggestions();
3089 expect(replacementOffset, completionOffset - 1); 2905 expect(replacementOffset, completionOffset - 1);
3090 expect(replacementLength, 1); 2906 expect(replacementLength, 1);
3091 assertSuggestTopLevelVar('T1', 'int'); 2907 assertSuggestTopLevelVar('T1', 'int');
3092 assertNotSuggested('T2'); 2908 assertNotSuggested('T2');
3093 } 2909 }
3094 2910
3095 test_method_parameters_mixed_required_and_named() async { 2911 test_method_parameters_mixed_required_and_named() async {
3096 resolveSource( 2912 resolveSource('/libA.dart', '''
3097 '/libA.dart',
3098 '''
3099 void m(x, {int y}) {} 2913 void m(x, {int y}) {}
3100 '''); 2914 ''');
3101 addTestSource(''' 2915 addTestSource('''
3102 import '/libA.dart'; 2916 import '/libA.dart';
3103 class B extends A { 2917 class B extends A {
3104 main() {^} 2918 main() {^}
3105 } 2919 }
3106 '''); 2920 ''');
3107 await computeSuggestions(); 2921 await computeSuggestions();
3108 CompletionSuggestion suggestion = assertSuggestFunction('m', 'void'); 2922 CompletionSuggestion suggestion = assertSuggestFunction('m', 'void');
3109 expect(suggestion.parameterNames, hasLength(2)); 2923 expect(suggestion.parameterNames, hasLength(2));
3110 expect(suggestion.parameterNames[0], 'x'); 2924 expect(suggestion.parameterNames[0], 'x');
3111 expect(suggestion.parameterTypes[0], 'dynamic'); 2925 expect(suggestion.parameterTypes[0], 'dynamic');
3112 expect(suggestion.parameterNames[1], 'y'); 2926 expect(suggestion.parameterNames[1], 'y');
3113 expect(suggestion.parameterTypes[1], 'int'); 2927 expect(suggestion.parameterTypes[1], 'int');
3114 expect(suggestion.requiredParameterCount, 1); 2928 expect(suggestion.requiredParameterCount, 1);
3115 expect(suggestion.hasNamedParameters, true); 2929 expect(suggestion.hasNamedParameters, true);
3116 } 2930 }
3117 2931
3118 test_method_parameters_mixed_required_and_positional() async { 2932 test_method_parameters_mixed_required_and_positional() async {
3119 resolveSource( 2933 resolveSource('/libA.dart', '''
3120 '/libA.dart',
3121 '''
3122 void m(x, [int y]) {} 2934 void m(x, [int y]) {}
3123 '''); 2935 ''');
3124 addTestSource(''' 2936 addTestSource('''
3125 import '/libA.dart'; 2937 import '/libA.dart';
3126 class B extends A { 2938 class B extends A {
3127 main() {^} 2939 main() {^}
3128 } 2940 }
3129 '''); 2941 ''');
3130 await computeSuggestions(); 2942 await computeSuggestions();
3131 CompletionSuggestion suggestion = assertSuggestFunction('m', 'void'); 2943 CompletionSuggestion suggestion = assertSuggestFunction('m', 'void');
3132 expect(suggestion.parameterNames, hasLength(2)); 2944 expect(suggestion.parameterNames, hasLength(2));
3133 expect(suggestion.parameterNames[0], 'x'); 2945 expect(suggestion.parameterNames[0], 'x');
3134 expect(suggestion.parameterTypes[0], 'dynamic'); 2946 expect(suggestion.parameterTypes[0], 'dynamic');
3135 expect(suggestion.parameterNames[1], 'y'); 2947 expect(suggestion.parameterNames[1], 'y');
3136 expect(suggestion.parameterTypes[1], 'int'); 2948 expect(suggestion.parameterTypes[1], 'int');
3137 expect(suggestion.requiredParameterCount, 1); 2949 expect(suggestion.requiredParameterCount, 1);
3138 expect(suggestion.hasNamedParameters, false); 2950 expect(suggestion.hasNamedParameters, false);
3139 } 2951 }
3140 2952
3141 test_method_parameters_named() async { 2953 test_method_parameters_named() async {
3142 resolveSource( 2954 resolveSource('/libA.dart', '''
3143 '/libA.dart',
3144 '''
3145 void m({x, int y}) {} 2955 void m({x, int y}) {}
3146 '''); 2956 ''');
3147 addTestSource(''' 2957 addTestSource('''
3148 import '/libA.dart'; 2958 import '/libA.dart';
3149 class B extends A { 2959 class B extends A {
3150 main() {^} 2960 main() {^}
3151 } 2961 }
3152 '''); 2962 ''');
3153 await computeSuggestions(); 2963 await computeSuggestions();
3154 CompletionSuggestion suggestion = assertSuggestFunction('m', 'void'); 2964 CompletionSuggestion suggestion = assertSuggestFunction('m', 'void');
3155 expect(suggestion.parameterNames, hasLength(2)); 2965 expect(suggestion.parameterNames, hasLength(2));
3156 expect(suggestion.parameterNames[0], 'x'); 2966 expect(suggestion.parameterNames[0], 'x');
3157 expect(suggestion.parameterTypes[0], 'dynamic'); 2967 expect(suggestion.parameterTypes[0], 'dynamic');
3158 expect(suggestion.parameterNames[1], 'y'); 2968 expect(suggestion.parameterNames[1], 'y');
3159 expect(suggestion.parameterTypes[1], 'int'); 2969 expect(suggestion.parameterTypes[1], 'int');
3160 expect(suggestion.requiredParameterCount, 0); 2970 expect(suggestion.requiredParameterCount, 0);
3161 expect(suggestion.hasNamedParameters, true); 2971 expect(suggestion.hasNamedParameters, true);
3162 } 2972 }
3163 2973
3164 test_method_parameters_none() async { 2974 test_method_parameters_none() async {
3165 resolveSource( 2975 resolveSource('/libA.dart', '''
3166 '/libA.dart',
3167 '''
3168 void m() {} 2976 void m() {}
3169 '''); 2977 ''');
3170 addTestSource(''' 2978 addTestSource('''
3171 import '/libA.dart'; 2979 import '/libA.dart';
3172 class B extends A { 2980 class B extends A {
3173 main() {^} 2981 main() {^}
3174 } 2982 }
3175 '''); 2983 ''');
3176 2984
3177 await computeSuggestions(); 2985 await computeSuggestions();
3178 CompletionSuggestion suggestion = assertSuggestFunction('m', 'void'); 2986 CompletionSuggestion suggestion = assertSuggestFunction('m', 'void');
3179 expect(suggestion.parameterNames, isEmpty); 2987 expect(suggestion.parameterNames, isEmpty);
3180 expect(suggestion.parameterTypes, isEmpty); 2988 expect(suggestion.parameterTypes, isEmpty);
3181 expect(suggestion.requiredParameterCount, 0); 2989 expect(suggestion.requiredParameterCount, 0);
3182 expect(suggestion.hasNamedParameters, false); 2990 expect(suggestion.hasNamedParameters, false);
3183 } 2991 }
3184 2992
3185 test_method_parameters_positional() async { 2993 test_method_parameters_positional() async {
3186 resolveSource( 2994 resolveSource('/libA.dart', '''
3187 '/libA.dart',
3188 '''
3189 void m([x, int y]) {} 2995 void m([x, int y]) {}
3190 '''); 2996 ''');
3191 addTestSource(''' 2997 addTestSource('''
3192 import '/libA.dart'; 2998 import '/libA.dart';
3193 class B extends A { 2999 class B extends A {
3194 main() {^} 3000 main() {^}
3195 } 3001 }
3196 '''); 3002 ''');
3197 await computeSuggestions(); 3003 await computeSuggestions();
3198 CompletionSuggestion suggestion = assertSuggestFunction('m', 'void'); 3004 CompletionSuggestion suggestion = assertSuggestFunction('m', 'void');
3199 expect(suggestion.parameterNames, hasLength(2)); 3005 expect(suggestion.parameterNames, hasLength(2));
3200 expect(suggestion.parameterNames[0], 'x'); 3006 expect(suggestion.parameterNames[0], 'x');
3201 expect(suggestion.parameterTypes[0], 'dynamic'); 3007 expect(suggestion.parameterTypes[0], 'dynamic');
3202 expect(suggestion.parameterNames[1], 'y'); 3008 expect(suggestion.parameterNames[1], 'y');
3203 expect(suggestion.parameterTypes[1], 'int'); 3009 expect(suggestion.parameterTypes[1], 'int');
3204 expect(suggestion.requiredParameterCount, 0); 3010 expect(suggestion.requiredParameterCount, 0);
3205 expect(suggestion.hasNamedParameters, false); 3011 expect(suggestion.hasNamedParameters, false);
3206 } 3012 }
3207 3013
3208 test_method_parameters_required() async { 3014 test_method_parameters_required() async {
3209 resolveSource( 3015 resolveSource('/libA.dart', '''
3210 '/libA.dart',
3211 '''
3212 void m(x, int y) {} 3016 void m(x, int y) {}
3213 '''); 3017 ''');
3214 addTestSource(''' 3018 addTestSource('''
3215 import '/libA.dart'; 3019 import '/libA.dart';
3216 class B { 3020 class B {
3217 main() {^} 3021 main() {^}
3218 } 3022 }
3219 '''); 3023 ''');
3220 await computeSuggestions(); 3024 await computeSuggestions();
3221 CompletionSuggestion suggestion = assertSuggestFunction('m', 'void'); 3025 CompletionSuggestion suggestion = assertSuggestFunction('m', 'void');
(...skipping 13 matching lines...) Expand all
3235 await computeSuggestions(); 3039 await computeSuggestions();
3236 expect(replacementOffset, completionOffset); 3040 expect(replacementOffset, completionOffset);
3237 expect(replacementLength, 0); 3041 expect(replacementLength, 0);
3238 assertNotSuggested('a'); 3042 assertNotSuggested('a');
3239 assertNotSuggested('f'); 3043 assertNotSuggested('f');
3240 assertNotSuggested('_g'); 3044 assertNotSuggested('_g');
3241 } 3045 }
3242 3046
3243 test_MethodDeclaration_body_static() async { 3047 test_MethodDeclaration_body_static() async {
3244 // Block BlockFunctionBody MethodDeclaration 3048 // Block BlockFunctionBody MethodDeclaration
3245 addSource( 3049 addSource('/testC.dart', '''
3246 '/testC.dart',
3247 '''
3248 class C { 3050 class C {
3249 c1() {} 3051 c1() {}
3250 var c2; 3052 var c2;
3251 static c3() {} 3053 static c3() {}
3252 static var c4;}'''); 3054 static var c4;}''');
3253 addTestSource(''' 3055 addTestSource('''
3254 import "/testC.dart"; 3056 import "/testC.dart";
3255 class B extends C { 3057 class B extends C {
3256 b1() {} 3058 b1() {}
3257 var b2; 3059 var b2;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
3320 assertNotSuggested('foo'); 3122 assertNotSuggested('foo');
3321 assertNotSuggested('bar'); 3123 assertNotSuggested('bar');
3322 assertNotSuggested('a'); 3124 assertNotSuggested('a');
3323 assertNotSuggested('x'); 3125 assertNotSuggested('x');
3324 assertNotSuggested('y'); 3126 assertNotSuggested('y');
3325 assertSuggestClass('String'); 3127 assertSuggestClass('String');
3326 } 3128 }
3327 3129
3328 test_MethodDeclaration_returnType() async { 3130 test_MethodDeclaration_returnType() async {
3329 // ClassDeclaration CompilationUnit 3131 // ClassDeclaration CompilationUnit
3330 resolveSource( 3132 resolveSource('/testA.dart', '''
3331 '/testA.dart',
3332 '''
3333 int T1; 3133 int T1;
3334 F1() { } 3134 F1() { }
3335 typedef D1(); 3135 typedef D1();
3336 class C1 {C1(this.x) { } int x;}'''); 3136 class C1 {C1(this.x) { } int x;}''');
3337 addTestSource(''' 3137 addTestSource('''
3338 import "/testA.dart"; 3138 import "/testA.dart";
3339 int T2; 3139 int T2;
3340 F2() { } 3140 F2() { }
3341 typedef D2(); 3141 typedef D2();
3342 class C2 {^ zoo(z) { } String name; }'''); 3142 class C2 {^ zoo(z) { } String name; }''');
3343 3143
3344 await computeSuggestions(); 3144 await computeSuggestions();
3345 expect(replacementOffset, completionOffset); 3145 expect(replacementOffset, completionOffset);
3346 expect(replacementLength, 0); 3146 expect(replacementLength, 0);
3347 assertSuggestClass('Object'); 3147 assertSuggestClass('Object');
3348 assertNotSuggested('T1'); 3148 assertNotSuggested('T1');
3349 assertNotSuggested('F1'); 3149 assertNotSuggested('F1');
3350 assertSuggestFunctionTypeAlias('D1', 'dynamic'); 3150 assertSuggestFunctionTypeAlias('D1', 'dynamic');
3351 assertSuggestClass('C1'); 3151 assertSuggestClass('C1');
3352 assertNotSuggested('T2'); 3152 assertNotSuggested('T2');
3353 assertNotSuggested('F2'); 3153 assertNotSuggested('F2');
3354 assertNotSuggested('D2'); 3154 assertNotSuggested('D2');
3355 assertNotSuggested('C2'); 3155 assertNotSuggested('C2');
3356 assertNotSuggested('name'); 3156 assertNotSuggested('name');
3357 } 3157 }
3358 3158
3359 test_MethodDeclaration_returnType_afterComment() async { 3159 test_MethodDeclaration_returnType_afterComment() async {
3360 // ClassDeclaration CompilationUnit 3160 // ClassDeclaration CompilationUnit
3361 resolveSource( 3161 resolveSource('/testA.dart', '''
3362 '/testA.dart',
3363 '''
3364 int T1; 3162 int T1;
3365 F1() { } 3163 F1() { }
3366 typedef D1(); 3164 typedef D1();
3367 class C1 {C1(this.x) { } int x;}'''); 3165 class C1 {C1(this.x) { } int x;}''');
3368 addTestSource(''' 3166 addTestSource('''
3369 import "/testA.dart"; 3167 import "/testA.dart";
3370 int T2; 3168 int T2;
3371 F2() { } 3169 F2() { }
3372 typedef D2(); 3170 typedef D2();
3373 class C2 {/* */ ^ zoo(z) { } String name; }'''); 3171 class C2 {/* */ ^ zoo(z) { } String name; }''');
3374 3172
3375 await computeSuggestions(); 3173 await computeSuggestions();
3376 expect(replacementOffset, completionOffset); 3174 expect(replacementOffset, completionOffset);
3377 expect(replacementLength, 0); 3175 expect(replacementLength, 0);
3378 assertSuggestClass('Object'); 3176 assertSuggestClass('Object');
3379 assertNotSuggested('T1'); 3177 assertNotSuggested('T1');
3380 assertNotSuggested('F1'); 3178 assertNotSuggested('F1');
3381 assertSuggestFunctionTypeAlias('D1', 'dynamic'); 3179 assertSuggestFunctionTypeAlias('D1', 'dynamic');
3382 assertSuggestClass('C1'); 3180 assertSuggestClass('C1');
3383 assertNotSuggested('T2'); 3181 assertNotSuggested('T2');
3384 assertNotSuggested('F2'); 3182 assertNotSuggested('F2');
3385 assertNotSuggested('D2'); 3183 assertNotSuggested('D2');
3386 assertNotSuggested('C2'); 3184 assertNotSuggested('C2');
3387 assertNotSuggested('name'); 3185 assertNotSuggested('name');
3388 } 3186 }
3389 3187
3390 test_MethodDeclaration_returnType_afterComment2() async { 3188 test_MethodDeclaration_returnType_afterComment2() async {
3391 // MethodDeclaration ClassDeclaration CompilationUnit 3189 // MethodDeclaration ClassDeclaration CompilationUnit
3392 resolveSource( 3190 resolveSource('/testA.dart', '''
3393 '/testA.dart',
3394 '''
3395 int T1; 3191 int T1;
3396 F1() { } 3192 F1() { }
3397 typedef D1(); 3193 typedef D1();
3398 class C1 {C1(this.x) { } int x;}'''); 3194 class C1 {C1(this.x) { } int x;}''');
3399 addTestSource(''' 3195 addTestSource('''
3400 import "/testA.dart"; 3196 import "/testA.dart";
3401 int T2; 3197 int T2;
3402 F2() { } 3198 F2() { }
3403 typedef D2(); 3199 typedef D2();
3404 class C2 {/** */ ^ zoo(z) { } String name; }'''); 3200 class C2 {/** */ ^ zoo(z) { } String name; }''');
3405 3201
3406 await computeSuggestions(); 3202 await computeSuggestions();
3407 expect(replacementOffset, completionOffset); 3203 expect(replacementOffset, completionOffset);
3408 expect(replacementLength, 0); 3204 expect(replacementLength, 0);
3409 assertSuggestClass('Object'); 3205 assertSuggestClass('Object');
3410 assertNotSuggested('T1'); 3206 assertNotSuggested('T1');
3411 assertNotSuggested('F1'); 3207 assertNotSuggested('F1');
3412 assertSuggestFunctionTypeAlias('D1', 'dynamic'); 3208 assertSuggestFunctionTypeAlias('D1', 'dynamic');
3413 assertSuggestClass('C1'); 3209 assertSuggestClass('C1');
3414 assertNotSuggested('T2'); 3210 assertNotSuggested('T2');
3415 assertNotSuggested('F2'); 3211 assertNotSuggested('F2');
3416 assertNotSuggested('D2'); 3212 assertNotSuggested('D2');
3417 assertNotSuggested('C2'); 3213 assertNotSuggested('C2');
3418 assertNotSuggested('name'); 3214 assertNotSuggested('name');
3419 } 3215 }
3420 3216
3421 test_MethodDeclaration_returnType_afterComment3() async { 3217 test_MethodDeclaration_returnType_afterComment3() async {
3422 // MethodDeclaration ClassDeclaration CompilationUnit 3218 // MethodDeclaration ClassDeclaration CompilationUnit
3423 resolveSource( 3219 resolveSource('/testA.dart', '''
3424 '/testA.dart',
3425 '''
3426 int T1; 3220 int T1;
3427 F1() { } 3221 F1() { }
3428 typedef D1(); 3222 typedef D1();
3429 class C1 {C1(this.x) { } int x;}'''); 3223 class C1 {C1(this.x) { } int x;}''');
3430 addTestSource(''' 3224 addTestSource('''
3431 import "/testA.dart"; 3225 import "/testA.dart";
3432 int T2; 3226 int T2;
3433 F2() { } 3227 F2() { }
3434 typedef D2(); 3228 typedef D2();
3435 class C2 { 3229 class C2 {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
3478 assertNotSuggested('m'); 3272 assertNotSuggested('m');
3479 assertNotSuggested('_n'); 3273 assertNotSuggested('_n');
3480 assertNotSuggested('a'); 3274 assertNotSuggested('a');
3481 assertNotSuggested('A'); 3275 assertNotSuggested('A');
3482 assertNotSuggested('X'); 3276 assertNotSuggested('X');
3483 assertNotSuggested('Object'); 3277 assertNotSuggested('Object');
3484 assertNotSuggested('=='); 3278 assertNotSuggested('==');
3485 } 3279 }
3486 3280
3487 test_mixin_ordering() async { 3281 test_mixin_ordering() async {
3488 addSource( 3282 addSource('/libA.dart', '''
3489 '/libA.dart',
3490 '''
3491 class B {} 3283 class B {}
3492 class M1 { 3284 class M1 {
3493 void m() {} 3285 void m() {}
3494 } 3286 }
3495 class M2 { 3287 class M2 {
3496 void m() {} 3288 void m() {}
3497 } 3289 }
3498 '''); 3290 ''');
3499 addTestSource(''' 3291 addTestSource('''
3500 import '/libA.dart'; 3292 import '/libA.dart';
(...skipping 23 matching lines...) Expand all
3524 context2.applyChanges(changeSet); 3316 context2.applyChanges(changeSet);
3525 context2.setContents(source2, content2); 3317 context2.setContents(source2, content2);
3526 3318
3527 // Resolve the source in the 2nd context and update the index 3319 // Resolve the source in the 2nd context and update the index
3528 var result = context2.performAnalysisTask(); 3320 var result = context2.performAnalysisTask();
3529 while (result.hasMoreWork) { 3321 while (result.hasMoreWork) {
3530 result = context2.performAnalysisTask(); 3322 result = context2.performAnalysisTask();
3531 } 3323 }
3532 3324
3533 // Check that source in 2nd context does not appear in completion in 1st 3325 // Check that source in 2nd context does not appear in completion in 1st
3534 addSource( 3326 addSource('/context1/libA.dart', '''
3535 '/context1/libA.dart',
3536 '''
3537 library libA; 3327 library libA;
3538 class ClassInLocalContext {int x;}'''); 3328 class ClassInLocalContext {int x;}''');
3539 testFile = '/context1/completionTest.dart'; 3329 testFile = '/context1/completionTest.dart';
3540 addTestSource(''' 3330 addTestSource('''
3541 import "/context1/libA.dart"; 3331 import "/context1/libA.dart";
3542 import "/foo.dart"; 3332 import "/foo.dart";
3543 main() {C^} 3333 main() {C^}
3544 '''); 3334 ''');
3545 3335
3546 await computeSuggestions(); 3336 await computeSuggestions();
3547 assertSuggestClass('ClassInLocalContext'); 3337 assertSuggestClass('ClassInLocalContext');
3548 // Assert contributor does not include results from 2nd context. 3338 // Assert contributor does not include results from 2nd context.
3549 assertNotSuggested('ClassFromAnotherContext'); 3339 assertNotSuggested('ClassFromAnotherContext');
3550 } 3340 }
3551 3341
3552 test_new_instance() async { 3342 test_new_instance() async {
3553 addTestSource('import "dart:math"; class A {x() {new Random().^}}'); 3343 addTestSource('import "dart:math"; class A {x() {new Random().^}}');
3554 3344
3555 await computeSuggestions(); 3345 await computeSuggestions();
3556 assertNotSuggested('nextBool'); 3346 assertNotSuggested('nextBool');
3557 assertNotSuggested('nextDouble'); 3347 assertNotSuggested('nextDouble');
3558 assertNotSuggested('nextInt'); 3348 assertNotSuggested('nextInt');
3559 assertNotSuggested('Random'); 3349 assertNotSuggested('Random');
3560 assertNotSuggested('Object'); 3350 assertNotSuggested('Object');
3561 assertNotSuggested('A'); 3351 assertNotSuggested('A');
3562 } 3352 }
3563 3353
3564 test_no_parameters_field() async { 3354 test_no_parameters_field() async {
3565 addSource( 3355 addSource('/libA.dart', '''
3566 '/libA.dart',
3567 '''
3568 int x; 3356 int x;
3569 '''); 3357 ''');
3570 addTestSource(''' 3358 addTestSource('''
3571 import '/libA.dart'; 3359 import '/libA.dart';
3572 class B extends A { 3360 class B extends A {
3573 main() {^} 3361 main() {^}
3574 } 3362 }
3575 '''); 3363 ''');
3576 await computeSuggestions(); 3364 await computeSuggestions();
3577 CompletionSuggestion suggestion = assertSuggestTopLevelVar('x', null); 3365 CompletionSuggestion suggestion = assertSuggestTopLevelVar('x', null);
3578 assertHasNoParameterInfo(suggestion); 3366 assertHasNoParameterInfo(suggestion);
3579 } 3367 }
3580 3368
3581 test_no_parameters_getter() async { 3369 test_no_parameters_getter() async {
3582 resolveSource( 3370 resolveSource('/libA.dart', '''
3583 '/libA.dart',
3584 '''
3585 int get x => null; 3371 int get x => null;
3586 '''); 3372 ''');
3587 addTestSource(''' 3373 addTestSource('''
3588 import '/libA.dart'; 3374 import '/libA.dart';
3589 class B extends A { 3375 class B extends A {
3590 main() {^} 3376 main() {^}
3591 } 3377 }
3592 '''); 3378 ''');
3593 await computeSuggestions(); 3379 await computeSuggestions();
3594 CompletionSuggestion suggestion = assertSuggestGetter('x', 'int'); 3380 CompletionSuggestion suggestion = assertSuggestGetter('x', 'int');
3595 assertHasNoParameterInfo(suggestion); 3381 assertHasNoParameterInfo(suggestion);
3596 } 3382 }
3597 3383
3598 test_no_parameters_setter() async { 3384 test_no_parameters_setter() async {
3599 addSource( 3385 addSource('/libA.dart', '''
3600 '/libA.dart',
3601 '''
3602 set x(int value) {}; 3386 set x(int value) {};
3603 '''); 3387 ''');
3604 addTestSource(''' 3388 addTestSource('''
3605 import '/libA.dart'; 3389 import '/libA.dart';
3606 class B extends A { 3390 class B extends A {
3607 main() {^} 3391 main() {^}
3608 } 3392 }
3609 '''); 3393 ''');
3610 await computeSuggestions(); 3394 await computeSuggestions();
3611 CompletionSuggestion suggestion = assertSuggestSetter('x'); 3395 CompletionSuggestion suggestion = assertSuggestSetter('x');
3612 assertHasNoParameterInfo(suggestion); 3396 assertHasNoParameterInfo(suggestion);
3613 } 3397 }
3614 3398
3615 test_parameterName_excludeTypes() async { 3399 test_parameterName_excludeTypes() async {
3616 addTestSource('m(int ^) {}'); 3400 addTestSource('m(int ^) {}');
3617 await computeSuggestions(); 3401 await computeSuggestions();
3618 assertNotSuggested('int'); 3402 assertNotSuggested('int');
3619 assertNotSuggested('bool'); 3403 assertNotSuggested('bool');
3620 } 3404 }
3621 3405
3622 test_partFile_TypeName() async { 3406 test_partFile_TypeName() async {
3623 // SimpleIdentifier TypeName ConstructorName 3407 // SimpleIdentifier TypeName ConstructorName
3624 addSource( 3408 addSource('/testB.dart', '''
3625 '/testB.dart',
3626 '''
3627 lib B; 3409 lib B;
3628 int T1; 3410 int T1;
3629 F1() { } 3411 F1() { }
3630 class X {X.c(); X._d(); z() {}}'''); 3412 class X {X.c(); X._d(); z() {}}''');
3631 addSource( 3413 addSource('/testA.dart', '''
3632 '/testA.dart',
3633 '''
3634 library libA; 3414 library libA;
3635 import "/testB.dart"; 3415 import "/testB.dart";
3636 part "$testFile"; 3416 part "$testFile";
3637 class A { } 3417 class A { }
3638 var m;'''); 3418 var m;''');
3639 addTestSource(''' 3419 addTestSource('''
3640 part of libA; 3420 part of libA;
3641 class B { factory B.bar(int x) => null; } 3421 class B { factory B.bar(int x) => null; }
3642 main() {new ^}'''); 3422 main() {new ^}''');
3643 3423
(...skipping 10 matching lines...) Expand all
3654 assertNotSuggested('A'); 3434 assertNotSuggested('A');
3655 assertNotSuggested('F1'); 3435 assertNotSuggested('F1');
3656 assertNotSuggested('T1'); 3436 assertNotSuggested('T1');
3657 assertNotSuggested('_d'); 3437 assertNotSuggested('_d');
3658 assertNotSuggested('z'); 3438 assertNotSuggested('z');
3659 assertNotSuggested('m'); 3439 assertNotSuggested('m');
3660 } 3440 }
3661 3441
3662 test_partFile_TypeName2() async { 3442 test_partFile_TypeName2() async {
3663 // SimpleIdentifier TypeName ConstructorName 3443 // SimpleIdentifier TypeName ConstructorName
3664 addSource( 3444 addSource('/testB.dart', '''
3665 '/testB.dart',
3666 '''
3667 lib libB; 3445 lib libB;
3668 int T1; 3446 int T1;
3669 F1() { } 3447 F1() { }
3670 class X {X.c(); X._d(); z() {}}'''); 3448 class X {X.c(); X._d(); z() {}}''');
3671 addSource( 3449 addSource('/testA.dart', '''
3672 '/testA.dart',
3673 '''
3674 part of libA; 3450 part of libA;
3675 class B { }'''); 3451 class B { }''');
3676 addTestSource(''' 3452 addTestSource('''
3677 library libA; 3453 library libA;
3678 import "/testB.dart"; 3454 import "/testB.dart";
3679 part "/testA.dart"; 3455 part "/testA.dart";
3680 class A { A({String boo: 'hoo'}) { } } 3456 class A { A({String boo: 'hoo'}) { } }
3681 main() {new ^} 3457 main() {new ^}
3682 var m;'''); 3458 var m;''');
3683 3459
(...skipping 10 matching lines...) Expand all
3694 assertNotSuggested('B'); 3470 assertNotSuggested('B');
3695 assertNotSuggested('F1'); 3471 assertNotSuggested('F1');
3696 assertNotSuggested('T1'); 3472 assertNotSuggested('T1');
3697 assertNotSuggested('_d'); 3473 assertNotSuggested('_d');
3698 assertNotSuggested('z'); 3474 assertNotSuggested('z');
3699 assertNotSuggested('m'); 3475 assertNotSuggested('m');
3700 } 3476 }
3701 3477
3702 test_PrefixedIdentifier_class_const() async { 3478 test_PrefixedIdentifier_class_const() async {
3703 // SimpleIdentifier PrefixedIdentifier ExpressionStatement Block 3479 // SimpleIdentifier PrefixedIdentifier ExpressionStatement Block
3704 addSource( 3480 addSource('/testB.dart', '''
3705 '/testB.dart',
3706 '''
3707 lib B; 3481 lib B;
3708 class I { 3482 class I {
3709 static const scI = 'boo'; 3483 static const scI = 'boo';
3710 X get f => new A(); 3484 X get f => new A();
3711 get _g => new A();} 3485 get _g => new A();}
3712 class B implements I { 3486 class B implements I {
3713 static const int scB = 12; 3487 static const int scB = 12;
3714 var b; X _c; 3488 var b; X _c;
3715 X get d => new A();get _e => new A(); 3489 X get d => new A();get _e => new A();
3716 set s1(I x) {} set _s2(I x) {} 3490 set s1(I x) {} set _s2(I x) {}
(...skipping 26 matching lines...) Expand all
3743 assertNotSuggested('a'); 3517 assertNotSuggested('a');
3744 assertNotSuggested('A'); 3518 assertNotSuggested('A');
3745 assertNotSuggested('X'); 3519 assertNotSuggested('X');
3746 assertNotSuggested('w'); 3520 assertNotSuggested('w');
3747 assertNotSuggested('Object'); 3521 assertNotSuggested('Object');
3748 assertNotSuggested('=='); 3522 assertNotSuggested('==');
3749 } 3523 }
3750 3524
3751 test_PrefixedIdentifier_class_imported() async { 3525 test_PrefixedIdentifier_class_imported() async {
3752 // SimpleIdentifier PrefixedIdentifier ExpressionStatement 3526 // SimpleIdentifier PrefixedIdentifier ExpressionStatement
3753 addSource( 3527 addSource('/testB.dart', '''
3754 '/testB.dart',
3755 '''
3756 lib B; 3528 lib B;
3757 class I {X get f => new A();get _g => new A();} 3529 class I {X get f => new A();get _g => new A();}
3758 class A implements I { 3530 class A implements I {
3759 static const int sc = 12; 3531 static const int sc = 12;
3760 @deprecated var b; X _c; 3532 @deprecated var b; X _c;
3761 X get d => new A();get _e => new A(); 3533 X get d => new A();get _e => new A();
3762 set s1(I x) {} set _s2(I x) {} 3534 set s1(I x) {} set _s2(I x) {}
3763 m(X x) {} I _n(X x) {}} 3535 m(X x) {} I _n(X x) {}}
3764 class X{}'''); 3536 class X{}''');
3765 addTestSource(''' 3537 addTestSource('''
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
3824 test_PrefixedIdentifier_getter() async { 3596 test_PrefixedIdentifier_getter() async {
3825 // SimpleIdentifier PrefixedIdentifier ExpressionStatement 3597 // SimpleIdentifier PrefixedIdentifier ExpressionStatement
3826 addTestSource('String get g => "one"; f() {g.^}'); 3598 addTestSource('String get g => "one"; f() {g.^}');
3827 3599
3828 await computeSuggestions(); 3600 await computeSuggestions();
3829 assertNotSuggested('length'); 3601 assertNotSuggested('length');
3830 } 3602 }
3831 3603
3832 test_PrefixedIdentifier_library() async { 3604 test_PrefixedIdentifier_library() async {
3833 // SimpleIdentifier PrefixedIdentifier ExpressionStatement 3605 // SimpleIdentifier PrefixedIdentifier ExpressionStatement
3834 addSource( 3606 addSource('/testB.dart', '''
3835 '/testB.dart',
3836 '''
3837 lib B; 3607 lib B;
3838 var T1; 3608 var T1;
3839 class X { } 3609 class X { }
3840 class Y { }'''); 3610 class Y { }''');
3841 addTestSource(''' 3611 addTestSource('''
3842 import "/testB.dart" as b; 3612 import "/testB.dart" as b;
3843 var T2; 3613 var T2;
3844 class A { } 3614 class A { }
3845 main() {b.^}'''); 3615 main() {b.^}''');
3846 3616
3847 await computeSuggestions(); 3617 await computeSuggestions();
3848 expect(replacementOffset, completionOffset); 3618 expect(replacementOffset, completionOffset);
3849 expect(replacementLength, 0); 3619 expect(replacementLength, 0);
3850 // Suggested by LibraryMemberContributor 3620 // Suggested by LibraryMemberContributor
3851 assertNotSuggested('X'); 3621 assertNotSuggested('X');
3852 assertNotSuggested('Y'); 3622 assertNotSuggested('Y');
3853 assertNotSuggested('T1'); 3623 assertNotSuggested('T1');
3854 assertNotSuggested('T2'); 3624 assertNotSuggested('T2');
3855 assertNotSuggested('Object'); 3625 assertNotSuggested('Object');
3856 assertNotSuggested('b'); 3626 assertNotSuggested('b');
3857 assertNotSuggested('A'); 3627 assertNotSuggested('A');
3858 assertNotSuggested('=='); 3628 assertNotSuggested('==');
3859 } 3629 }
3860 3630
3861 test_PrefixedIdentifier_library_typesOnly() async { 3631 test_PrefixedIdentifier_library_typesOnly() async {
3862 // SimpleIdentifier PrefixedIdentifier TypeName 3632 // SimpleIdentifier PrefixedIdentifier TypeName
3863 addSource( 3633 addSource('/testB.dart', '''
3864 '/testB.dart',
3865 '''
3866 lib B; 3634 lib B;
3867 var T1; 3635 var T1;
3868 class X { } 3636 class X { }
3869 class Y { }'''); 3637 class Y { }''');
3870 addTestSource(''' 3638 addTestSource('''
3871 import "/testB.dart" as b; 3639 import "/testB.dart" as b;
3872 var T2; 3640 var T2;
3873 class A { } 3641 class A { }
3874 foo(b.^ f) {}'''); 3642 foo(b.^ f) {}''');
3875 3643
3876 await computeSuggestions(); 3644 await computeSuggestions();
3877 expect(replacementOffset, completionOffset); 3645 expect(replacementOffset, completionOffset);
3878 expect(replacementLength, 0); 3646 expect(replacementLength, 0);
3879 // Suggested by LibraryMemberContributor 3647 // Suggested by LibraryMemberContributor
3880 assertNotSuggested('X'); 3648 assertNotSuggested('X');
3881 assertNotSuggested('Y'); 3649 assertNotSuggested('Y');
3882 assertNotSuggested('T1'); 3650 assertNotSuggested('T1');
3883 assertNotSuggested('T2'); 3651 assertNotSuggested('T2');
3884 assertNotSuggested('Object'); 3652 assertNotSuggested('Object');
3885 assertNotSuggested('b'); 3653 assertNotSuggested('b');
3886 assertNotSuggested('A'); 3654 assertNotSuggested('A');
3887 assertNotSuggested('=='); 3655 assertNotSuggested('==');
3888 } 3656 }
3889 3657
3890 test_PrefixedIdentifier_library_typesOnly2() async { 3658 test_PrefixedIdentifier_library_typesOnly2() async {
3891 // SimpleIdentifier PrefixedIdentifier TypeName 3659 // SimpleIdentifier PrefixedIdentifier TypeName
3892 addSource( 3660 addSource('/testB.dart', '''
3893 '/testB.dart',
3894 '''
3895 lib B; 3661 lib B;
3896 var T1; 3662 var T1;
3897 class X { } 3663 class X { }
3898 class Y { }'''); 3664 class Y { }''');
3899 addTestSource(''' 3665 addTestSource('''
3900 import "/testB.dart" as b; 3666 import "/testB.dart" as b;
3901 var T2; 3667 var T2;
3902 class A { } 3668 class A { }
3903 foo(b.^) {}'''); 3669 foo(b.^) {}''');
3904 3670
3905 await computeSuggestions(); 3671 await computeSuggestions();
3906 expect(replacementOffset, completionOffset); 3672 expect(replacementOffset, completionOffset);
3907 expect(replacementLength, 0); 3673 expect(replacementLength, 0);
3908 // Suggested by LibraryMemberContributor 3674 // Suggested by LibraryMemberContributor
3909 assertNotSuggested('X'); 3675 assertNotSuggested('X');
3910 assertNotSuggested('Y'); 3676 assertNotSuggested('Y');
3911 assertNotSuggested('T1'); 3677 assertNotSuggested('T1');
3912 assertNotSuggested('T2'); 3678 assertNotSuggested('T2');
3913 assertNotSuggested('Object'); 3679 assertNotSuggested('Object');
3914 assertNotSuggested('b'); 3680 assertNotSuggested('b');
3915 assertNotSuggested('A'); 3681 assertNotSuggested('A');
3916 assertNotSuggested('=='); 3682 assertNotSuggested('==');
3917 } 3683 }
3918 3684
3919 test_PrefixedIdentifier_parameter() async { 3685 test_PrefixedIdentifier_parameter() async {
3920 // SimpleIdentifier PrefixedIdentifier ExpressionStatement 3686 // SimpleIdentifier PrefixedIdentifier ExpressionStatement
3921 addSource( 3687 addSource('/testB.dart', '''
3922 '/testB.dart',
3923 '''
3924 lib B; 3688 lib B;
3925 class _W {M y; var _z;} 3689 class _W {M y; var _z;}
3926 class X extends _W {} 3690 class X extends _W {}
3927 class M{}'''); 3691 class M{}''');
3928 addTestSource(''' 3692 addTestSource('''
3929 import "/testB.dart"; 3693 import "/testB.dart";
3930 foo(X x) {x.^}'''); 3694 foo(X x) {x.^}''');
3931 3695
3932 await computeSuggestions(); 3696 await computeSuggestions();
3933 expect(replacementOffset, completionOffset); 3697 expect(replacementOffset, completionOffset);
3934 expect(replacementLength, 0); 3698 expect(replacementLength, 0);
3935 assertNotSuggested('y'); 3699 assertNotSuggested('y');
3936 assertNotSuggested('_z'); 3700 assertNotSuggested('_z');
3937 assertNotSuggested('=='); 3701 assertNotSuggested('==');
3938 } 3702 }
3939 3703
3940 test_PrefixedIdentifier_prefix() async { 3704 test_PrefixedIdentifier_prefix() async {
3941 // SimpleIdentifier PrefixedIdentifier ExpressionStatement 3705 // SimpleIdentifier PrefixedIdentifier ExpressionStatement
3942 addSource( 3706 addSource('/testA.dart', '''
3943 '/testA.dart',
3944 '''
3945 class A {static int bar = 10;} 3707 class A {static int bar = 10;}
3946 _B() {}'''); 3708 _B() {}''');
3947 addTestSource(''' 3709 addTestSource('''
3948 import "/testA.dart"; 3710 import "/testA.dart";
3949 class X {foo(){A^.bar}}'''); 3711 class X {foo(){A^.bar}}''');
3950 3712
3951 await computeSuggestions(); 3713 await computeSuggestions();
3952 expect(replacementOffset, completionOffset - 1); 3714 expect(replacementOffset, completionOffset - 1);
3953 expect(replacementLength, 1); 3715 expect(replacementLength, 1);
3954 assertSuggestClass('A'); 3716 assertSuggestClass('A');
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
4375 // SimpleIdentifier VariableDeclaration VariableDeclarationList 4137 // SimpleIdentifier VariableDeclaration VariableDeclarationList
4376 // TopLevelVariableDeclaration 4138 // TopLevelVariableDeclaration
4377 addTestSource('class A {} var ^'); 4139 addTestSource('class A {} var ^');
4378 4140
4379 await computeSuggestions(); 4141 await computeSuggestions();
4380 assertNoSuggestions(); 4142 assertNoSuggestions();
4381 } 4143 }
4382 4144
4383 test_TypeArgumentList() async { 4145 test_TypeArgumentList() async {
4384 // SimpleIdentifier BinaryExpression ExpressionStatement 4146 // SimpleIdentifier BinaryExpression ExpressionStatement
4385 resolveSource( 4147 resolveSource('/testA.dart', '''
4386 '/testA.dart',
4387 '''
4388 class C1 {int x;} 4148 class C1 {int x;}
4389 F1() => 0; 4149 F1() => 0;
4390 typedef String T1(int blat);'''); 4150 typedef String T1(int blat);''');
4391 addTestSource(''' 4151 addTestSource('''
4392 import "/testA.dart";' 4152 import "/testA.dart";'
4393 class C2 {int x;} 4153 class C2 {int x;}
4394 F2() => 0; 4154 F2() => 0;
4395 typedef int T2(int blat); 4155 typedef int T2(int blat);
4396 class C<E> {} 4156 class C<E> {}
4397 main() { C<^> c; }'''); 4157 main() { C<^> c; }''');
4398 4158
4399 await computeSuggestions(); 4159 await computeSuggestions();
4400 expect(replacementOffset, completionOffset); 4160 expect(replacementOffset, completionOffset);
4401 expect(replacementLength, 0); 4161 expect(replacementLength, 0);
4402 assertSuggestClass('Object'); 4162 assertSuggestClass('Object');
4403 assertSuggestClass('C1'); 4163 assertSuggestClass('C1');
4404 assertSuggestFunctionTypeAlias('T1', 'String'); 4164 assertSuggestFunctionTypeAlias('T1', 'String');
4405 assertNotSuggested('C2'); 4165 assertNotSuggested('C2');
4406 assertNotSuggested('T2'); 4166 assertNotSuggested('T2');
4407 assertNotSuggested('F1'); 4167 assertNotSuggested('F1');
4408 assertNotSuggested('F2'); 4168 assertNotSuggested('F2');
4409 } 4169 }
4410 4170
4411 test_TypeArgumentList2() async { 4171 test_TypeArgumentList2() async {
4412 // TypeName TypeArgumentList TypeName 4172 // TypeName TypeArgumentList TypeName
4413 addSource( 4173 addSource('/testA.dart', '''
4414 '/testA.dart',
4415 '''
4416 class C1 {int x;} 4174 class C1 {int x;}
4417 F1() => 0; 4175 F1() => 0;
4418 typedef String T1(int blat);'''); 4176 typedef String T1(int blat);''');
4419 addTestSource(''' 4177 addTestSource('''
4420 import "/testA.dart";' 4178 import "/testA.dart";'
4421 class C2 {int x;} 4179 class C2 {int x;}
4422 F2() => 0; 4180 F2() => 0;
4423 typedef int T2(int blat); 4181 typedef int T2(int blat);
4424 class C<E> {} 4182 class C<E> {}
4425 main() { C<C^> c; }'''); 4183 main() { C<C^> c; }''');
4426 4184
4427 await computeSuggestions(); 4185 await computeSuggestions();
4428 expect(replacementOffset, completionOffset - 1); 4186 expect(replacementOffset, completionOffset - 1);
4429 expect(replacementLength, 1); 4187 expect(replacementLength, 1);
4430 assertSuggestClass('C1'); 4188 assertSuggestClass('C1');
4431 assertNotSuggested('C2'); 4189 assertNotSuggested('C2');
4432 } 4190 }
4433 4191
4434 test_VariableDeclaration_name() async { 4192 test_VariableDeclaration_name() async {
4435 // SimpleIdentifier VariableDeclaration VariableDeclarationList 4193 // SimpleIdentifier VariableDeclaration VariableDeclarationList
4436 // VariableDeclarationStatement Block 4194 // VariableDeclarationStatement Block
4437 addSource( 4195 addSource('/testB.dart', '''
4438 '/testB.dart',
4439 '''
4440 lib B; 4196 lib B;
4441 foo() { } 4197 foo() { }
4442 class _B { } 4198 class _B { }
4443 class X {X.c(); X._d(); z() {}}'''); 4199 class X {X.c(); X._d(); z() {}}''');
4444 addTestSource(''' 4200 addTestSource('''
4445 import "/testB.dart"; 4201 import "/testB.dart";
4446 class Y {Y.c(); Y._d(); z() {}} 4202 class Y {Y.c(); Y._d(); z() {}}
4447 main() {var ^}'''); 4203 main() {var ^}''');
4448 4204
4449 await computeSuggestions(); 4205 await computeSuggestions();
4450 assertNoSuggestions(); 4206 assertNoSuggestions();
4451 } 4207 }
4452 4208
4453 test_VariableDeclarationList_final() async { 4209 test_VariableDeclarationList_final() async {
4454 // VariableDeclarationList VariableDeclarationStatement Block 4210 // VariableDeclarationList VariableDeclarationStatement Block
4455 addTestSource('main() {final ^} class C { }'); 4211 addTestSource('main() {final ^} class C { }');
4456 4212
4457 await computeSuggestions(); 4213 await computeSuggestions();
4458 assertSuggestClass('Object'); 4214 assertSuggestClass('Object');
4459 assertNotSuggested('C'); 4215 assertNotSuggested('C');
4460 assertNotSuggested('=='); 4216 assertNotSuggested('==');
4461 } 4217 }
4462 4218
4463 test_VariableDeclarationStatement_RHS() async { 4219 test_VariableDeclarationStatement_RHS() async {
4464 // SimpleIdentifier VariableDeclaration VariableDeclarationList 4220 // SimpleIdentifier VariableDeclaration VariableDeclarationList
4465 // VariableDeclarationStatement 4221 // VariableDeclarationStatement
4466 addSource( 4222 addSource('/testB.dart', '''
4467 '/testB.dart',
4468 '''
4469 lib B; 4223 lib B;
4470 foo() { } 4224 foo() { }
4471 class _B { } 4225 class _B { }
4472 class X {X.c(); X._d(); z() {}}'''); 4226 class X {X.c(); X._d(); z() {}}''');
4473 addTestSource(''' 4227 addTestSource('''
4474 import "/testB.dart"; 4228 import "/testB.dart";
4475 class Y {Y.c(); Y._d(); z() {}} 4229 class Y {Y.c(); Y._d(); z() {}}
4476 class C {bar(){var f; {var x;} var e = ^}}'''); 4230 class C {bar(){var f; {var x;} var e = ^}}''');
4477 4231
4478 await computeSuggestions(); 4232 await computeSuggestions();
4479 expect(replacementOffset, completionOffset); 4233 expect(replacementOffset, completionOffset);
4480 expect(replacementLength, 0); 4234 expect(replacementLength, 0);
4481 assertSuggestClass('X'); 4235 assertSuggestClass('X');
4482 assertNotSuggested('_B'); 4236 assertNotSuggested('_B');
4483 assertNotSuggested('Y'); 4237 assertNotSuggested('Y');
4484 assertNotSuggested('C'); 4238 assertNotSuggested('C');
4485 assertNotSuggested('f'); 4239 assertNotSuggested('f');
4486 assertNotSuggested('x'); 4240 assertNotSuggested('x');
4487 assertNotSuggested('e'); 4241 assertNotSuggested('e');
4488 } 4242 }
4489 4243
4490 test_VariableDeclarationStatement_RHS_missing_semicolon() async { 4244 test_VariableDeclarationStatement_RHS_missing_semicolon() async {
4491 // VariableDeclaration VariableDeclarationList 4245 // VariableDeclaration VariableDeclarationList
4492 // VariableDeclarationStatement 4246 // VariableDeclarationStatement
4493 resolveSource( 4247 resolveSource('/testB.dart', '''
4494 '/testB.dart',
4495 '''
4496 lib B; 4248 lib B;
4497 foo1() { } 4249 foo1() { }
4498 void bar1() { } 4250 void bar1() { }
4499 class _B { } 4251 class _B { }
4500 class X {X.c(); X._d(); z() {}}'''); 4252 class X {X.c(); X._d(); z() {}}''');
4501 addTestSource(''' 4253 addTestSource('''
4502 import "/testB.dart"; 4254 import "/testB.dart";
4503 foo2() { } 4255 foo2() { }
4504 void bar2() { } 4256 void bar2() { }
4505 class Y {Y.c(); Y._d(); z() {}} 4257 class Y {Y.c(); Y._d(); z() {}}
4506 class C {bar(){var f; {var x;} var e = ^ var g}}'''); 4258 class C {bar(){var f; {var x;} var e = ^ var g}}''');
4507 await computeSuggestions(); 4259 await computeSuggestions();
4508 expect(replacementOffset, completionOffset); 4260 expect(replacementOffset, completionOffset);
4509 expect(replacementLength, 0); 4261 expect(replacementLength, 0);
4510 assertSuggestClass('X'); 4262 assertSuggestClass('X');
4511 assertSuggestFunction('foo1', 'dynamic'); 4263 assertSuggestFunction('foo1', 'dynamic');
4512 assertNotSuggested('bar1'); 4264 assertNotSuggested('bar1');
4513 assertNotSuggested('foo2'); 4265 assertNotSuggested('foo2');
4514 assertNotSuggested('bar2'); 4266 assertNotSuggested('bar2');
4515 assertNotSuggested('_B'); 4267 assertNotSuggested('_B');
4516 assertNotSuggested('Y'); 4268 assertNotSuggested('Y');
4517 assertNotSuggested('C'); 4269 assertNotSuggested('C');
4518 assertNotSuggested('f'); 4270 assertNotSuggested('f');
4519 assertNotSuggested('x'); 4271 assertNotSuggested('x');
4520 assertNotSuggested('e'); 4272 assertNotSuggested('e');
4521 } 4273 }
4522 } 4274 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698