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

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

Issue 2868383002: Recover from merge problem (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « pkg/analysis_server/lib/src/services/completion/statement/statement_completion.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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.statement; 5 library test.services.completion.statement;
6 6
7 import 'package:analysis_server/src/protocol_server.dart'; 7 import 'package:analysis_server/src/protocol_server.dart';
8 import 'package:analysis_server/src/services/completion/statement/statement_comp letion.dart'; 8 import 'package:analysis_server/src/services/completion/statement/statement_comp letion.dart';
9 import 'package:analyzer/src/dart/analysis/driver.dart'; 9 import 'package:analyzer/src/dart/analysis/driver.dart';
10 import 'package:test/test.dart'; 10 import 'package:test/test.dart';
11 import 'package:test_reflective_loader/test_reflective_loader.dart'; 11 import 'package:test_reflective_loader/test_reflective_loader.dart';
12 12
13 import '../../../abstract_single_unit.dart'; 13 import '../../../abstract_single_unit.dart';
14 14
15 main() { 15 main() {
16 defineReflectiveSuite(() { 16 defineReflectiveSuite(() {
17 defineReflectiveTests(_DeclarationCompletionTest); 17 defineReflectiveTests(_DeclarationCompletionTest);
18 defineReflectiveTests(_ControlFlowCompletionTest); 18 defineReflectiveTests(_ControlFlowCompletionTest);
19 defineReflectiveTests(_DoCompletionTest); 19 defineReflectiveTests(_DoCompletionTest);
20 defineReflectiveTests(_ExpressionCompletionTest);
20 defineReflectiveTests(_ForCompletionTest); 21 defineReflectiveTests(_ForCompletionTest);
21 defineReflectiveTests(_ForEachCompletionTest); 22 defineReflectiveTests(_ForEachCompletionTest);
22 defineReflectiveTests(_IfCompletionTest); 23 defineReflectiveTests(_IfCompletionTest);
23 defineReflectiveTests(_SimpleCompletionTest); 24 defineReflectiveTests(_SimpleCompletionTest);
24 defineReflectiveTests(_SwitchCompletionTest); 25 defineReflectiveTests(_SwitchCompletionTest);
25 defineReflectiveTests(_TryCompletionTest); 26 defineReflectiveTests(_TryCompletionTest);
26 defineReflectiveTests(_WhileCompletionTest); 27 defineReflectiveTests(_WhileCompletionTest);
27 }); 28 });
28 } 29 }
29 30
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 _assertHasChange( 297 _assertHasChange(
297 'Complete class declaration', 298 'Complete class declaration',
298 ''' 299 '''
299 class Sample { 300 class Sample {
300 //// 301 ////
301 } 302 }
302 ''', 303 ''',
303 (s) => _afterLast(s, ' ')); 304 (s) => _afterLast(s, ' '));
304 } 305 }
305 306
307 test_extendsNoBody() async {
308 await _prepareCompletion(
309 'Sample',
310 '''
311 class Sample extends Object
312 ''',
313 atEnd: true);
314 _assertHasChange(
315 'Complete class declaration',
316 '''
317 class Sample extends Object {
318 ////
319 }
320 ''',
321 (s) => _afterLast(s, ' '));
322 }
323
306 test_functionDeclNoBody() async { 324 test_functionDeclNoBody() async {
307 await _prepareCompletion( 325 await _prepareCompletion(
308 'source()', 326 'source()',
309 ''' 327 '''
310 String source() 328 String source()
311 ''', 329 ''',
312 atEnd: true); 330 atEnd: true);
313 _assertHasChange( 331 _assertHasChange(
314 'Complete function declaration', 332 'Complete function declaration',
315 ''' 333 '''
316 String source() { 334 String source() {
317 //// 335 ////
318 } 336 }
319 ''', 337 ''',
320 (s) => _after(s, ' ')); 338 (s) => _after(s, ' '));
321 } 339 }
322 340
341 test_functionDeclNoParen() async {
342 await _prepareCompletion(
343 'source(',
344 '''
345 String source(
346 ''',
347 atEnd: true);
348 _assertHasChange(
349 'Complete function declaration',
350 '''
351 String source() {
352 ////
353 }
354 ''',
355 (s) => _after(s, ' '));
356 }
357
358 test_implementsNoBody() async {
359 await _prepareCompletion(
360 'Sample',
361 '''
362 class Interface {}
363 class Sample implements Interface
364 ''',
365 atEnd: true);
366 _assertHasChange(
367 'Complete class declaration',
368 '''
369 class Interface {}
370 class Sample implements Interface {
371 ////
372 }
373 ''',
374 (s) => _afterLast(s, ' '));
375 }
376
323 test_methodDeclNoBody() async { 377 test_methodDeclNoBody() async {
324 await _prepareCompletion( 378 await _prepareCompletion(
325 'source()', 379 'source()',
326 ''' 380 '''
327 class Sample { 381 class Sample {
328 String source() 382 String source()
329 } 383 }
330 ''', 384 ''',
331 atEnd: true); 385 atEnd: true);
332 _assertHasChange( 386 _assertHasChange(
333 'Complete function declaration', 387 'Complete function declaration',
334 ''' 388 '''
335 class Sample { 389 class Sample {
336 String source() { 390 String source() {
337 //// 391 ////
338 } 392 }
339 } 393 }
340 ''', 394 ''',
341 (s) => _after(s, ' ')); 395 (s) => _after(s, ' '));
342 } 396 }
343 397
398 test_methodDeclNoParen() async {
399 await _prepareCompletion(
400 'source(',
401 '''
402 class Sample {
403 String source(
404 }
405 ''',
406 atEnd: true);
407 _assertHasChange(
408 'Complete function declaration',
409 '''
410 class Sample {
411 String source() {
412 ////
413 }
414 }
415 ''',
416 (s) => _after(s, ' '));
417 }
418
344 test_variableDeclNoBody() async { 419 test_variableDeclNoBody() async {
345 await _prepareCompletion( 420 await _prepareCompletion(
346 'source', 421 'source',
347 ''' 422 '''
348 String source 423 String source
349 ''', 424 ''',
350 atEnd: true); 425 atEnd: true);
351 _assertHasChange( 426 _assertHasChange(
352 'Complete variable declaration', 427 'Complete variable declaration',
353 ''' 428 '''
354 String source; 429 String source;
355 //// 430 ////
356 ''', 431 ''',
357 (s) => _after(s, ';\n')); 432 (s) => _after(s, ';\n'));
358 } 433 }
434
435 test_withNoBody() async {
436 await _prepareCompletion(
437 'Sample',
438 '''
439 class M {}
440 class Sample extends Object with M
441 ''',
442 atEnd: true);
443 _assertHasChange(
444 'Complete class declaration',
445 '''
446 class M {}
447 class Sample extends Object with M {
448 ////
449 }
450 ''',
451 (s) => _afterLast(s, ' '));
452 }
359 } 453 }
360 454
361 @reflectiveTest 455 @reflectiveTest
362 class _DoCompletionTest extends StatementCompletionTest { 456 class _DoCompletionTest extends StatementCompletionTest {
363 test_emptyCondition() async { 457 test_emptyCondition() async {
364 await _prepareCompletion( 458 await _prepareCompletion(
365 'while ()', 459 'while ()',
366 ''' 460 '''
367 main() { 461 main() {
368 do { 462 do {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 main() { 578 main() {
485 do { 579 do {
486 } while (); 580 } while ();
487 } 581 }
488 ''', 582 ''',
489 (s) => _after(s, 'while (')); 583 (s) => _after(s, 'while ('));
490 } 584 }
491 } 585 }
492 586
493 @reflectiveTest 587 @reflectiveTest
588 class _ExpressionCompletionTest extends StatementCompletionTest {
589 test_listAssign() async {
590 await _prepareCompletion(
591 '= ',
592 '''
593 main() {
594 var x = [1, 2, 3
595 }
596 ''',
597 atEnd: true);
598 _assertHasChange(
599 'Add a semicolon and newline',
600 '''
601 main() {
602 var x = [1, 2, 3];
603 ////
604 }
605 ''',
606 (s) => _afterLast(s, ' '));
607 }
608
609 test_listAssignMultiLine() async {
610 // The indent of the final line is incorrect.
611 await _prepareCompletion(
612 '3',
613 '''
614 main() {
615 var x = [
616 1,
617 2,
618 3
619 }
620 ''',
621 atEnd: true);
622 _assertHasChange(
623 'Add a semicolon and newline',
624 '''
625 main() {
626 var x = [
627 1,
628 2,
629 3,
630 ];
631 ////
632 }
633 ''',
634 (s) => _afterLast(s, ' '));
635 }
636
637 @failingTest
638 test_mapAssign() async {
639 await _prepareCompletion(
640 '3: 3',
641 '''
642 main() {
643 var x = {1: 1, 2: 2, 3: 3
644 }
645 ''',
646 atEnd: true);
647 _assertHasChange(
648 'Add a semicolon and newline',
649 '''
650 main() {
651 var x = {1: 1, 2: 2, 3: 3};
652 ////
653 }
654 ''',
655 (s) => _afterLast(s, ' '));
656 }
657
658 @failingTest
659 test_mapAssignMissingColon() async {
660 await _prepareCompletion(
661 '3',
662 '''
663 main() {
664 var x = {1: 1, 2: 2, 3
665 }
666 ''',
667 atEnd: true);
668 _assertHasChange(
669 'Add a semicolon and newline',
670 '''
671 main() {
672 var x = {1: 1, 2: 2, 3: };
673 ////
674 }
675 ''',
676 (s) => _afterLast(s, ' '));
677 }
678
679 test_returnString() async {
680 await _prepareCompletion(
681 'text',
682 '''
683 main() {
684 if (done()) {
685 return 'text
686 }
687 }
688 ''',
689 atEnd: true);
690 _assertHasChange(
691 'Complete control flow block',
692 '''
693 main() {
694 if (done()) {
695 return 'text';
696 }
697 ////
698 }
699 ''',
700 (s) => _afterLast(s, ' '));
701 }
702
703 test_stringAssign() async {
704 await _prepareCompletion(
705 '= ',
706 '''
707 main() {
708 var x = '
709 }
710 ''',
711 atEnd: true);
712 _assertHasChange(
713 'Add a semicolon and newline',
714 '''
715 main() {
716 var x = '';
717 ////
718 }
719 ''',
720 (s) => _afterLast(s, ' '));
721 }
722
723 test_stringSingle() async {
724 await _prepareCompletion(
725 'text',
726 '''
727 main() {
728 print("text
729 }
730 ''',
731 atEnd: true);
732 _assertHasChange(
733 'Insert a newline at the end of the current line',
734 '''
735 main() {
736 print("text");
737 ////
738 }
739 ''',
740 (s) => _afterLast(s, ' '));
741 }
742
743 test_stringSingleRaw() async {
744 await _prepareCompletion(
745 'text',
746 '''
747 main() {
748 print(r"text
749 }
750 ''',
751 atEnd: true);
752 _assertHasChange(
753 'Insert a newline at the end of the current line',
754 '''
755 main() {
756 print(r"text");
757 ////
758 }
759 ''',
760 (s) => _afterLast(s, ' '));
761 }
762
763 test_stringTriple() async {
764 await _prepareCompletion(
765 'text',
766 '''
767 main() {
768 print(\'\'\'text
769 }
770 ''',
771 atEnd: true);
772 _assertHasChange(
773 'Insert a newline at the end of the current line',
774 '''
775 main() {
776 print(\'\'\'text\'\'\');
777 ////
778 }
779 ''',
780 (s) => _afterLast(s, ' '));
781 }
782
783 test_stringTripleRaw() async {
784 await _prepareCompletion(
785 'text',
786 r"""
787 main() {
788 print(r'''text
789 }
790 """,
791 atEnd: true);
792 _assertHasChange(
793 'Insert a newline at the end of the current line',
794 r"""
795 main() {
796 print(r'''text''');
797 ////
798 }
799 """,
800 (s) => _afterLast(s, ' '));
801 }
802 }
803
804 @reflectiveTest
494 class _ForCompletionTest extends StatementCompletionTest { 805 class _ForCompletionTest extends StatementCompletionTest {
495 test_emptyCondition() async { 806 test_emptyCondition() async {
496 await _prepareCompletion( 807 await _prepareCompletion(
497 '}', 808 '0;',
809 '''
810 main() {
811 for (int i = 0;) /**/ ////
812 }
813 ''',
814 atEnd: true);
815 _assertHasChange(
816 'Complete for-statement',
817 '''
818 main() {
819 for (int i = 0; ; ) /**/ {
820 ////
821 }
822 }
823 ''',
824 (s) => _after(s, ' '));
825 }
826
827 test_emptyConditionWithBody() async {
828 await _prepareCompletion(
829 '0;',
498 ''' 830 '''
499 main() { 831 main() {
500 for (int i = 0;) { 832 for (int i = 0;) {
501 } 833 }
502 } 834 }
503 ''', 835 ''',
504 atEnd: true); 836 atEnd: true);
505 _assertHasChange( 837 _assertHasChange(
506 'Complete for-statement', 838 'Complete for-statement',
507 ''' 839 '''
508 main() { 840 main() {
509 for (int i = 0; ; ) { 841 for (int i = 0; ; ) {
510 } 842 }
511 } 843 }
512 ''', 844 ''',
513 (s) => _after(s, '0; ')); 845 (s) => _after(s, '0; '));
514 } 846 }
515 847
516 test_emptyInitializers() async { 848 test_emptyInitializers() async {
517 // TODO(messick) This should insert a newline and move the cursor there. 849 // This does nothing, same as for Java.
518 await _prepareCompletion( 850 await _prepareCompletion(
519 '}', 851 'r (',
520 ''' 852 '''
521 main() { 853 main() {
522 for () { 854 for () {
523 } 855 }
524 } 856 }
525 ''', 857 ''',
526 atEnd: true); 858 atEnd: true);
527 _assertHasChange( 859 _assertHasChange(
528 'Complete for-statement', 860 'Complete for-statement',
529 ''' 861 '''
530 main() { 862 main() {
531 for () { 863 for () {
532 } 864 }
533 } 865 }
534 ''', 866 ''',
535 (s) => _after(s, 'for (')); 867 (s) => _after(s, 'r ('));
868 }
869
870 test_emptyInitializersAfterBody() async {
871 await _prepareCompletion(
872 '}',
873 '''
874 main() {
875 for () {
876 }
877 }
878 ''',
879 atEnd: true);
880 _assertHasChange(
881 'Insert a newline at the end of the current line',
882 '''
883 main() {
884 for () {
885 }
886 ////
887 }
888 ''',
889 (s) => _afterLast(s, ' '));
536 } 890 }
537 891
538 test_emptyInitializersEmptyCondition() async { 892 test_emptyInitializersEmptyCondition() async {
539 await _prepareCompletion( 893 await _prepareCompletion(
540 '}', 894 '/**/',
541 ''' 895 '''
542 main() { 896 main() {
543 for (;/**/) { 897 for (;/**/)
544 }
545 } 898 }
546 ''', 899 ''',
547 atEnd: true); 900 atEnd: true);
548 _assertHasChange( 901 _assertHasChange(
549 'Complete for-statement', 902 'Complete for-statement',
550 ''' 903 '''
551 main() { 904 main() {
552 for (;/**/) { 905 for (; /**/; ) {
906 ////
553 } 907 }
554 } 908 }
555 ''', 909 ''',
556 (s) => _after(s, '/**/')); 910 (s) => _after(s, ' '));
557 } 911 }
558 912
559 test_emptyParts() async { 913 test_emptyParts() async {
560 await _prepareCompletion( 914 await _prepareCompletion(
561 ';)', 915 ';)',
562 ''' 916 '''
563 main() { 917 main() {
564 for (;;) 918 for (;;)
565 } 919 }
566 ''', 920 ''',
567 atEnd: true); 921 atEnd: true);
568 _assertHasChange( 922 _assertHasChange(
569 'Complete for-statement', 923 'Complete for-statement',
570 ''' 924 '''
571 main() { 925 main() {
572 for (;;) { 926 for (;;) {
573 //// 927 ////
574 } 928 }
575 } 929 }
576 ''', 930 ''',
577 (s) => _after(s, ' ')); 931 (s) => _after(s, ' '));
578 } 932 }
579 933
580 test_emptyUpdaters() async { 934 test_emptyUpdaters() async {
581 await _prepareCompletion( 935 await _prepareCompletion(
582 '}', 936 '/**/',
937 '''
938 main() {
939 for (int i = 0; i < 10 /**/)
940 }
941 ''',
942 atEnd: true);
943 _assertHasChange(
944 'Complete for-statement',
945 '''
946 main() {
947 for (int i = 0; i < 10 /**/; ) {
948 ////
949 }
950 }
951 ''',
952 (s) => _after(s, ' '));
953 }
954
955 test_emptyUpdatersWithBody() async {
956 await _prepareCompletion(
957 '/**/',
583 ''' 958 '''
584 main() { 959 main() {
585 for (int i = 0; i < 10 /**/) { 960 for (int i = 0; i < 10 /**/) {
586 } 961 }
587 } 962 }
588 ''', 963 ''',
589 atEnd: true); 964 atEnd: true);
590 _assertHasChange( 965 _assertHasChange(
591 'Complete for-statement', 966 'Complete for-statement',
592 ''' 967 '''
593 main() { 968 main() {
594 for (int i = 0; i < 10 /**/; ) { 969 for (int i = 0; i < 10 /**/; ) {
595 } 970 }
596 } 971 }
597 ''', 972 ''',
598 (s) => _after(s, '10 /**/; ')); 973 (s) => _after(s, '*/; '));
599 } 974 }
600 975
601 test_keywordOnly() async { 976 test_keywordOnly() async {
602 await _prepareCompletion( 977 await _prepareCompletion(
603 'for', 978 'for',
604 ''' 979 '''
605 main() { 980 main() {
606 for 981 for
607 } 982 }
608 ''', 983 ''',
609 atEnd: true); 984 atEnd: true);
610 _assertHasChange( 985 _assertHasChange(
611 'Complete for-statement', 986 'Complete for-statement',
612 ''' 987 '''
613 main() { 988 main() {
614 for () { 989 for () {
615 //// 990 ////
616 } 991 }
617 } 992 }
618 ''', 993 ''',
619 (s) => _after(s, 'for (')); 994 (s) => _after(s, 'for ('));
620 } 995 }
621 996
622 test_missingLeftSeparator() async { 997 test_missingLeftSeparator() async {
623 await _prepareCompletion( 998 await _prepareCompletion(
624 '}', 999 '= 0',
625 ''' 1000 '''
626 main() { 1001 main() {
627 for (int i = 0) { 1002 for (int i = 0) {
628 } 1003 }
629 } 1004 }
630 ''', 1005 ''',
631 atEnd: true); 1006 atEnd: true);
632 _assertHasChange( 1007 _assertHasChange(
633 'Complete for-statement', 1008 'Complete for-statement',
634 ''' 1009 '''
635 main() { 1010 main() {
636 for (int i = 0; ) { 1011 for (int i = 0; ; ) {
637 } 1012 }
638 } 1013 }
639 ''', 1014 ''',
640 (s) => _after(s, '0; ')); 1015 (s) => _after(s, '0; '));
641 } 1016 }
642 1017
643 test_noError() async { 1018 test_noError() async {
644 await _prepareCompletion( 1019 await _prepareCompletion(
645 ';)', 1020 ';)',
646 ''' 1021 '''
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 } 1123 }
749 return; 1124 return;
750 } 1125 }
751 ''', 1126 ''',
752 (s) => _after(s, ' ')); 1127 (s) => _after(s, ' '));
753 } 1128 }
754 } 1129 }
755 1130
756 @reflectiveTest 1131 @reflectiveTest
757 class _IfCompletionTest extends StatementCompletionTest { 1132 class _IfCompletionTest extends StatementCompletionTest {
758 test_afterCondition_BAD() async { 1133 test_afterCondition() async {
759 // TODO(messick) Stop inserting the space after the closing brace.
760 await _prepareCompletion( 1134 await _prepareCompletion(
761 'if (true) ', // Trigger completion after space. 1135 'if (true) ', // Trigger completion after space.
762 ''' 1136 '''
763 main() { 1137 main() {
764 if (true) //// 1138 if (true) ////
765 } 1139 }
766 ''', 1140 ''',
767 atEnd: true); 1141 atEnd: true);
768 _assertHasChange( 1142 _assertHasChange(
769 'Complete if-statement', 1143 'Complete if-statement',
770 ''' 1144 '''
771 main() { 1145 main() {
772 if (true) { 1146 if (true) {
773 //// 1147 ////
774 } //// 1148 }
775 } 1149 }
776 ''', 1150 ''',
777 (s) => _after(s, ' ')); 1151 (s) => _after(s, ' '));
778 } 1152 }
779 1153
780 test_emptyCondition() async { 1154 test_emptyCondition() async {
781 await _prepareCompletion( 1155 await _prepareCompletion(
782 'if ()', 1156 'if ()',
783 ''' 1157 '''
784 main() { 1158 main() {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 ''' 1230 '''
857 main() { 1231 main() {
858 if (true) { 1232 if (true) {
859 //// 1233 ////
860 } 1234 }
861 } 1235 }
862 ''', 1236 ''',
863 (s) => _after(s, ' ')); 1237 (s) => _after(s, ' '));
864 } 1238 }
865 1239
1240 test_withElse() async {
1241 await _prepareCompletion(
1242 'else',
1243 '''
1244 main() {
1245 if () {
1246 } else
1247 }
1248 ''',
1249 atEnd: true);
1250 _assertHasChange(
1251 'Complete if-statement',
1252 '''
1253 main() {
1254 if () {
1255 } else {
1256 ////
1257 }
1258 }
1259 ''',
1260 (s) => _after(s, ' '));
1261 }
1262
866 test_withElse_BAD() async { 1263 test_withElse_BAD() async {
867 await _prepareCompletion( 1264 await _prepareCompletion(
868 'if ()', 1265 'if ()',
869 ''' 1266 '''
870 main() { 1267 main() {
871 if () 1268 if ()
872 else 1269 else
873 } 1270 }
874 ''', 1271 ''',
875 atEnd: true); 1272 atEnd: true);
876 _assertHasChange( 1273 _assertHasChange(
877 // Note: if-statement completion should not trigger. 1274 // Note: if-statement completion should not trigger.
878 'Insert a newline at the end of the current line', 1275 'Insert a newline at the end of the current line',
879 ''' 1276 '''
880 main() { 1277 main() {
881 if () 1278 if ()
882 else 1279 else
883 } 1280 }
884 ''', 1281 ''',
885 (s) => _after(s, 'if ()')); 1282 (s) => _after(s, 'if ()'));
886 } 1283 }
887 1284
1285 test_withElseNoThen() async {
1286 await _prepareCompletion(
1287 'else',
1288 '''
1289 main() {
1290 if ()
1291 else
1292 }
1293 ''',
1294 atEnd: true);
1295 _assertHasChange(
1296 'Complete if-statement',
1297 '''
1298 main() {
1299 if ()
1300 else {
1301 ////
1302 }
1303 }
1304 ''',
1305 (s) => _after(s, ' '));
1306 }
1307
888 test_withinEmptyCondition() async { 1308 test_withinEmptyCondition() async {
889 await _prepareCompletion( 1309 await _prepareCompletion(
890 'if (', 1310 'if (',
891 ''' 1311 '''
892 main() { 1312 main() {
893 if () 1313 if ()
894 } 1314 }
895 ''', 1315 ''',
896 atEnd: true); 1316 atEnd: true);
897 _assertHasChange( 1317 _assertHasChange(
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
1326 test_onCatch() async { 1746 test_onCatch() async {
1327 await _prepareCompletion( 1747 await _prepareCompletion(
1328 'on', 1748 'on',
1329 ''' 1749 '''
1330 main() { 1750 main() {
1331 try { 1751 try {
1332 } on catch 1752 } on catch
1333 } 1753 }
1334 ''', 1754 ''',
1335 atEnd: true); 1755 atEnd: true);
1336 // It would be better to expect the cursor to follow the on-keyword but
1337 // the parser thinks the exception type is 'catch' so it's kinda broken.
1338 // See https://github.com/dart-lang/sdk/issues/29410
1339 _assertHasChange( 1756 _assertHasChange(
1340 'Complete try-statement', 1757 'Complete try-statement',
1341 ''' 1758 '''
1342 main() { 1759 main() {
1343 try { 1760 try {
1344 } on catch () { 1761 } on catch () {
1345 //// 1762 ////
1346 } 1763 }
1347 } 1764 }
1348 ''', 1765 ''',
1349 (s) => _after(s, 'catch (')); 1766 (s) => _after(s, 'catch ('));
1350 } 1767 }
1351 1768
1769 test_onCatchComment() async {
1770 await _prepareCompletion(
1771 'on',
1772 '''
1773 main() {
1774 try {
1775 } on catch
1776 //
1777 }
1778 ''',
1779 atEnd: true);
1780 _assertHasChange(
1781 'Complete try-statement',
1782 '''
1783 main() {
1784 try {
1785 } on catch () {
1786 ////
1787 }
1788 //
1789 }
1790 ''',
1791 (s) => _after(s, 'catch ('));
1792 }
1793
1352 test_onOnly() async { 1794 test_onOnly() async {
1353 await _prepareCompletion( 1795 await _prepareCompletion(
1354 'on', 1796 'on',
1355 ''' 1797 '''
1356 main() { 1798 main() {
1357 try { 1799 try {
1358 } on 1800 } on
1359 } 1801 }
1360 ''', 1802 ''',
1361 atEnd: true); 1803 atEnd: true);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1465 ''' 1907 '''
1466 main() { 1908 main() {
1467 while () { 1909 while () {
1468 //// 1910 ////
1469 } 1911 }
1470 } 1912 }
1471 ''', 1913 ''',
1472 (s) => _after(s, 'while (')); 1914 (s) => _after(s, 'while ('));
1473 } 1915 }
1474 } 1916 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/completion/statement/statement_completion.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698