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

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

Issue 633153002: cascade target fix and common test (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.services.completion.util; 5 library test.services.completion.util;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/protocol.dart' as protocol show Element, 9 import 'package:analysis_server/src/protocol.dart' as protocol show Element,
10 ElementKind; 10 ElementKind;
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 CompletionSuggestion assertSuggestLocalClass(String name, 390 CompletionSuggestion assertSuggestLocalClass(String name,
391 [CompletionRelevance relevance = CompletionRelevance.DEFAULT]) { 391 [CompletionRelevance relevance = CompletionRelevance.DEFAULT]) {
392 if (computer is LocalComputer) { 392 if (computer is LocalComputer) {
393 return assertSuggestClass(name, relevance); 393 return assertSuggestClass(name, relevance);
394 } else { 394 } else {
395 return assertNotSuggested(name); 395 return assertNotSuggested(name);
396 } 396 }
397 } 397 }
398 398
399 test_Block() { 399 test_Block() {
400 // Block BlockFunctionBody MethodDeclaration
400 addSource('/testAB.dart', ''' 401 addSource('/testAB.dart', '''
401 class A {int x;} 402 class A {int x;}
402 class _B { }'''); 403 class _B { }''');
403 addSource('/testCD.dart', ''' 404 addSource('/testCD.dart', '''
404 class C { } 405 class C { }
405 class D { }'''); 406 class D { }''');
406 addSource('/testEEF.dart', ''' 407 addSource('/testEEF.dart', '''
407 class EE { } 408 class EE { }
408 class F { }'''); 409 class F { }''');
409 addSource('/testG.dart', 'class G { }'); 410 addSource('/testG.dart', 'class G { }');
(...skipping 28 matching lines...) Expand all
438 assertSuggestLibraryPrefix('g'); 439 assertSuggestLibraryPrefix('g');
439 assertNotSuggested('G'); 440 assertNotSuggested('G');
440 assertSuggestImportedClass('H', CompletionRelevance.LOW); 441 assertSuggestImportedClass('H', CompletionRelevance.LOW);
441 assertSuggestImportedClass('Object'); 442 assertSuggestImportedClass('Object');
442 // TODO (danrubel) suggest HtmlElement as low relevance 443 // TODO (danrubel) suggest HtmlElement as low relevance
443 assertNotSuggested('HtmlElement'); 444 assertNotSuggested('HtmlElement');
444 }); 445 });
445 } 446 }
446 447
447 test_CascadeExpression_selector1() { 448 test_CascadeExpression_selector1() {
449 // PropertyAccess CascadeExpression ExpressionStatement Block
448 addSource('/testB.dart', ''' 450 addSource('/testB.dart', '''
449 class B { }'''); 451 class B { }''');
450 addTestSource(''' 452 addTestSource('''
451 import "/testB.dart"; 453 import "/testB.dart";
452 class A {var b; X _c;} 454 class A {var b; X _c;}
453 class X{} 455 class X{}
454 // looks like a cascade to the parser 456 // looks like a cascade to the parser
455 // but the user is trying to get completions for a non-cascade 457 // but the user is trying to get completions for a non-cascade
456 main() {A a; a.^.z}'''); 458 main() {A a; a.^.z}''');
457 computeFast(); 459 computeFast();
458 return computeFull(true).then((_) { 460 return computeFull(true).then((_) {
459 assertSuggestInvocationGetter('b', null); 461 assertSuggestInvocationGetter('b', null);
460 assertSuggestInvocationGetter('_c', 'X'); 462 assertSuggestInvocationGetter('_c', 'X');
461 assertNotSuggested('Object'); 463 assertNotSuggested('Object');
462 assertNotSuggested('A'); 464 assertNotSuggested('A');
463 assertNotSuggested('B'); 465 assertNotSuggested('B');
464 assertNotSuggested('X'); 466 assertNotSuggested('X');
465 assertNotSuggested('z'); 467 assertNotSuggested('z');
466 }); 468 });
467 } 469 }
468 470
469 test_CascadeExpression_selector2() { 471 test_CascadeExpression_selector2() {
472 // SimpleIdentifier PropertyAccess CascadeExpression ExpressionStatement
470 addSource('/testB.dart', ''' 473 addSource('/testB.dart', '''
471 class B { }'''); 474 class B { }''');
472 addTestSource(''' 475 addTestSource('''
473 import "/testB.dart"; 476 import "/testB.dart";
474 class A {var b; X _c;} 477 class A {var b; X _c;}
475 class X{} 478 class X{}
476 main() {A a; a..^z}'''); 479 main() {A a; a..^z}''');
477 computeFast(); 480 computeFast();
478 assertNoSuggestions();
479 return computeFull(true).then((_) { 481 return computeFull(true).then((_) {
480 assertSuggestInvocationGetter('b', null); 482 assertSuggestInvocationGetter('b', null);
481 assertSuggestInvocationGetter('_c', 'X'); 483 assertSuggestInvocationGetter('_c', 'X');
482 assertNotSuggested('Object'); 484 assertNotSuggested('Object');
483 assertNotSuggested('A'); 485 assertNotSuggested('A');
484 assertNotSuggested('B'); 486 assertNotSuggested('B');
485 assertNotSuggested('X'); 487 assertNotSuggested('X');
486 assertNotSuggested('z'); 488 assertNotSuggested('z');
487 }); 489 });
488 } 490 }
491
492 test_CascadeExpression_target() {
493 // SimpleIdentifier CascadeExpression ExpressionStatement
494 addTestSource('''
495 class A {var b; X _c;}
496 class X{}
497 main() {A a; a^..b}''');
498 computeFast();
499 return computeFull(true).then((_) {
500 assertNotSuggested('b');
501 assertNotSuggested('_c');
502 assertSuggestLocalVariable('a', 'A');
503 assertSuggestLocalClass('A');
504 assertSuggestLocalClass('X');
505 assertSuggestImportedClass('Object');
506 });
507 }
489 } 508 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698