| OLD | NEW |
| 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 engine.incremental_resolver_test; | 5 library engine.incremental_resolver_test; |
| 6 | 6 |
| 7 import 'package:analyzer/src/generated/ast.dart'; | 7 import 'package:analyzer/src/generated/ast.dart'; |
| 8 import 'package:analyzer/src/generated/element.dart'; | 8 import 'package:analyzer/src/generated/element.dart'; |
| 9 import 'package:analyzer/src/generated/engine.dart'; | 9 import 'package:analyzer/src/generated/engine.dart'; |
| 10 import 'package:analyzer/src/generated/error.dart'; | 10 import 'package:analyzer/src/generated/error.dart'; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 T f; | 95 T f; |
| 96 } | 96 } |
| 97 ''', r''' | 97 ''', r''' |
| 98 class A {} | 98 class A {} |
| 99 class B<T> { | 99 class B<T> { |
| 100 T f; | 100 T f; |
| 101 } | 101 } |
| 102 '''); | 102 '''); |
| 103 } | 103 } |
| 104 | 104 |
| 105 void test_false_classMemberAccessor_list_add() { |
| 106 _assertCompilationUnitMatches(false, r''' |
| 107 class A { |
| 108 get a => 1; |
| 109 get b => 2; |
| 110 } |
| 111 ''', r''' |
| 112 class A { |
| 113 get a => 1; |
| 114 get b => 2; |
| 115 get c => 3; |
| 116 } |
| 117 '''); |
| 118 } |
| 119 |
| 120 void test_false_classMemberAccessor_list_remove() { |
| 121 _assertCompilationUnitMatches(false, r''' |
| 122 class A { |
| 123 get a => 1; |
| 124 get b => 2; |
| 125 get c => 3; |
| 126 } |
| 127 ''', r''' |
| 128 class A { |
| 129 get a => 1; |
| 130 get b => 2; |
| 131 } |
| 132 '''); |
| 133 } |
| 134 |
| 135 void test_false_classMemberAccessor_wasGetter() { |
| 136 _assertCompilationUnitMatches(false, r''' |
| 137 class A { |
| 138 get a => 1; |
| 139 } |
| 140 ''', r''' |
| 141 class A { |
| 142 set a(x) {} |
| 143 } |
| 144 '''); |
| 145 } |
| 146 |
| 147 void test_false_classMemberAccessor_wasInstance() { |
| 148 _assertCompilationUnitMatches(false, r''' |
| 149 class A { |
| 150 get a => 1; |
| 151 } |
| 152 ''', r''' |
| 153 class A { |
| 154 static get a => 1; |
| 155 } |
| 156 '''); |
| 157 } |
| 158 |
| 159 void test_false_classMemberAccessor_wasSetter() { |
| 160 _assertCompilationUnitMatches(false, r''' |
| 161 class A { |
| 162 set a(x) {} |
| 163 } |
| 164 ''', r''' |
| 165 class A { |
| 166 get a => 1; |
| 167 } |
| 168 '''); |
| 169 } |
| 170 |
| 171 void test_false_classMemberAccessor_wasStatic() { |
| 172 _assertCompilationUnitMatches(false, r''' |
| 173 class A { |
| 174 static get a => 1; |
| 175 } |
| 176 ''', r''' |
| 177 class A { |
| 178 get a => 1; |
| 179 } |
| 180 '''); |
| 181 } |
| 182 |
| 105 void test_false_classTypeAlias_list_add() { | 183 void test_false_classTypeAlias_list_add() { |
| 106 _assertCompilationUnitMatches(false, r''' | 184 _assertCompilationUnitMatches(false, r''' |
| 107 class M {} | 185 class M {} |
| 108 class A = Object with M; | 186 class A = Object with M; |
| 109 ''', r''' | 187 ''', r''' |
| 110 class M {} | 188 class M {} |
| 111 class A = Object with M; | 189 class A = Object with M; |
| 112 class B = Object with M; | 190 class B = Object with M; |
| 113 '''); | 191 '''); |
| 114 } | 192 } |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 } | 609 } |
| 532 | 610 |
| 533 void test_false_import_show_remove() { | 611 void test_false_import_show_remove() { |
| 534 _assertCompilationUnitMatches(false, r''' | 612 _assertCompilationUnitMatches(false, r''' |
| 535 import 'dart:async' show Future, Stream; | 613 import 'dart:async' show Future, Stream; |
| 536 ''', r''' | 614 ''', r''' |
| 537 import 'dart:async' show Future; | 615 import 'dart:async' show Future; |
| 538 '''); | 616 '''); |
| 539 } | 617 } |
| 540 | 618 |
| 619 void test_false_method_list_add() { |
| 620 _assertCompilationUnitMatches(false, r''' |
| 621 class A { |
| 622 a() {} |
| 623 b() {} |
| 624 } |
| 625 ''', r''' |
| 626 class A { |
| 627 a() {} |
| 628 b() {} |
| 629 c() {} |
| 630 } |
| 631 '''); |
| 632 } |
| 633 |
| 634 void test_false_method_list_remove() { |
| 635 _assertCompilationUnitMatches(false, r''' |
| 636 class A { |
| 637 a() {} |
| 638 b() {} |
| 639 c() {} |
| 640 } |
| 641 ''', r''' |
| 642 class A { |
| 643 a() {} |
| 644 b() {} |
| 645 } |
| 646 '''); |
| 647 } |
| 648 |
| 649 void test_false_method_returnType_edit() { |
| 650 _assertCompilationUnitMatches(false, r''' |
| 651 class A { |
| 652 int m() {} |
| 653 } |
| 654 ''', r''' |
| 655 class A { |
| 656 String m() {} |
| 657 } |
| 658 '''); |
| 659 } |
| 660 |
| 541 void test_false_part_list_add() { | 661 void test_false_part_list_add() { |
| 542 addNamedSource('/unitA.dart', 'part of lib; class A {}'); | 662 addNamedSource('/unitA.dart', 'part of lib; class A {}'); |
| 543 addNamedSource('/unitB.dart', 'part of lib; class B {}'); | 663 addNamedSource('/unitB.dart', 'part of lib; class B {}'); |
| 544 _assertCompilationUnitMatches(false, r''' | 664 _assertCompilationUnitMatches(false, r''' |
| 545 library lib; | 665 library lib; |
| 546 part 'unitA.dart'; | 666 part 'unitA.dart'; |
| 547 ''', r''' | 667 ''', r''' |
| 548 library lib; | 668 library lib; |
| 549 part 'unitA.dart'; | 669 part 'unitA.dart'; |
| 550 part 'unitB.dart'; | 670 part 'unitB.dart'; |
| 551 '''); | 671 '''); |
| 552 } | 672 } |
| 553 | 673 |
| 554 void test_false_part_list_remove() { | 674 void test_false_part_list_remove() { |
| 555 addNamedSource('/unitA.dart', 'part of lib; class A {}'); | 675 addNamedSource('/unitA.dart', 'part of lib; class A {}'); |
| 556 addNamedSource('/unitB.dart', 'part of lib; class B {}'); | 676 addNamedSource('/unitB.dart', 'part of lib; class B {}'); |
| 557 _assertCompilationUnitMatches(false, r''' | 677 _assertCompilationUnitMatches(false, r''' |
| 558 library lib; | 678 library lib; |
| 559 part 'unitA.dart'; | 679 part 'unitA.dart'; |
| 560 part 'unitB.dart'; | 680 part 'unitB.dart'; |
| 561 ''', r''' | 681 ''', r''' |
| 562 library lib; | 682 library lib; |
| 563 part 'unitA.dart'; | 683 part 'unitA.dart'; |
| 564 '''); | 684 '''); |
| 565 } | 685 } |
| 566 | 686 |
| 687 void test_false_topLevelAccessor_list_add() { |
| 688 _assertCompilationUnitMatches(false, r''' |
| 689 get a => 1; |
| 690 get b => 2; |
| 691 ''', r''' |
| 692 get a => 1; |
| 693 get b => 2; |
| 694 get c => 3; |
| 695 '''); |
| 696 } |
| 697 |
| 698 void test_false_topLevelAccessor_list_remove() { |
| 699 _assertCompilationUnitMatches(false, r''' |
| 700 get a => 1; |
| 701 get b => 2; |
| 702 get c => 3; |
| 703 ''', r''' |
| 704 get a => 1; |
| 705 get b => 2; |
| 706 '''); |
| 707 } |
| 708 |
| 709 void test_false_topLevelAccessor_wasGetter() { |
| 710 _assertCompilationUnitMatches(false, r''' |
| 711 get a => 1; |
| 712 ''', r''' |
| 713 set a(x) {} |
| 714 '''); |
| 715 } |
| 716 |
| 717 void test_false_topLevelAccessor_wasSetter() { |
| 718 _assertCompilationUnitMatches(false, r''' |
| 719 set a(x) {} |
| 720 ''', r''' |
| 721 get a => 1; |
| 722 '''); |
| 723 } |
| 724 |
| 725 void test_false_topLevelFunction_list_add() { |
| 726 _assertCompilationUnitMatches(false, r''' |
| 727 a() {} |
| 728 b() {} |
| 729 ''', r''' |
| 730 a() {} |
| 731 b() {} |
| 732 c() {} |
| 733 '''); |
| 734 } |
| 735 |
| 736 void test_false_topLevelFunction_list_remove() { |
| 737 _assertCompilationUnitMatches(false, r''' |
| 738 a() {} |
| 739 b() {} |
| 740 c() {} |
| 741 ''', r''' |
| 742 a() {} |
| 743 b() {} |
| 744 '''); |
| 745 } |
| 746 |
| 747 void test_false_topLevelFunction_parameters_list_add() { |
| 748 _assertCompilationUnitMatches(false, r''' |
| 749 main(int a, int b) { |
| 750 } |
| 751 ''', r''' |
| 752 main(int a, int b, int c) { |
| 753 } |
| 754 '''); |
| 755 } |
| 756 |
| 757 void test_false_topLevelFunction_parameters_list_remove() { |
| 758 _assertCompilationUnitMatches(false, r''' |
| 759 main(int a, int b, int c) { |
| 760 } |
| 761 ''', r''' |
| 762 main(int a, int b) { |
| 763 } |
| 764 '''); |
| 765 } |
| 766 |
| 767 void test_false_topLevelFunction_parameters_type_edit() { |
| 768 _assertCompilationUnitMatches(false, r''' |
| 769 main(int a, int b, int c) { |
| 770 } |
| 771 ''', r''' |
| 772 main(int a, String b, int c) { |
| 773 } |
| 774 '''); |
| 775 } |
| 776 |
| 777 void test_false_topLevelFunction_returnType_edit() { |
| 778 _assertCompilationUnitMatches(false, r''' |
| 779 int a() {} |
| 780 ''', r''' |
| 781 String a() {} |
| 782 '''); |
| 783 } |
| 784 |
| 567 void test_false_topLevelVariable_list_add() { | 785 void test_false_topLevelVariable_list_add() { |
| 568 _assertCompilationUnitMatches(false, r''' | 786 _assertCompilationUnitMatches(false, r''' |
| 569 const int A = 1; | 787 const int A = 1; |
| 570 const int C = 3; | 788 const int C = 3; |
| 571 ''', r''' | 789 ''', r''' |
| 572 const int A = 1; | 790 const int A = 1; |
| 573 const int B = 2; | 791 const int B = 2; |
| 574 const int C = 3; | 792 const int C = 3; |
| 575 '''); | 793 '''); |
| 576 } | 794 } |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 } | 917 } |
| 700 | 918 |
| 701 void test_true_class_typeParameters_same() { | 919 void test_true_class_typeParameters_same() { |
| 702 _assertCompilationUnitMatches(true, r''' | 920 _assertCompilationUnitMatches(true, r''' |
| 703 class A<T> {} | 921 class A<T> {} |
| 704 ''', r''' | 922 ''', r''' |
| 705 class A<T> {} | 923 class A<T> {} |
| 706 '''); | 924 '''); |
| 707 } | 925 } |
| 708 | 926 |
| 927 void test_true_classMemberAccessor_list_reorder() { |
| 928 _assertCompilationUnitMatches(true, r''' |
| 929 class A { |
| 930 get a => 1; |
| 931 get b => 2; |
| 932 get c => 3; |
| 933 } |
| 934 ''', r''' |
| 935 class A { |
| 936 get c => 3; |
| 937 get a => 1; |
| 938 get b => 2; |
| 939 } |
| 940 '''); |
| 941 } |
| 942 |
| 943 void test_true_classMemberAccessor_list_same() { |
| 944 _assertCompilationUnitMatches(true, r''' |
| 945 class A { |
| 946 get a => 1; |
| 947 get b => 2; |
| 948 get c => 3; |
| 949 } |
| 950 ''', r''' |
| 951 class A { |
| 952 get a => 1; |
| 953 get b => 2; |
| 954 get c => 3; |
| 955 } |
| 956 '''); |
| 957 } |
| 958 |
| 709 void test_true_classTypeAlias_list_reorder() { | 959 void test_true_classTypeAlias_list_reorder() { |
| 710 _assertCompilationUnitMatches(true, r''' | 960 _assertCompilationUnitMatches(true, r''' |
| 711 class M {} | 961 class M {} |
| 712 class A = Object with M; | 962 class A = Object with M; |
| 713 class B = Object with M; | 963 class B = Object with M; |
| 714 class C = Object with M; | 964 class C = Object with M; |
| 715 ''', r''' | 965 ''', r''' |
| 716 class M {} | 966 class M {} |
| 717 class C = Object with M; | 967 class C = Object with M; |
| 718 class A = Object with M; | 968 class A = Object with M; |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 976 } | 1226 } |
| 977 | 1227 |
| 978 void test_true_import_show_reorder() { | 1228 void test_true_import_show_reorder() { |
| 979 _assertCompilationUnitMatches(true, r''' | 1229 _assertCompilationUnitMatches(true, r''' |
| 980 import 'dart:async' show Future, Stream; | 1230 import 'dart:async' show Future, Stream; |
| 981 ''', r''' | 1231 ''', r''' |
| 982 import 'dart:async' show Stream, Future; | 1232 import 'dart:async' show Stream, Future; |
| 983 '''); | 1233 '''); |
| 984 } | 1234 } |
| 985 | 1235 |
| 1236 void test_true_method_list_reorder() { |
| 1237 _assertCompilationUnitMatches(true, r''' |
| 1238 class A { |
| 1239 a() {} |
| 1240 b() {} |
| 1241 c() {} |
| 1242 } |
| 1243 ''', r''' |
| 1244 class A { |
| 1245 c() {} |
| 1246 a() {} |
| 1247 b() {} |
| 1248 } |
| 1249 '''); |
| 1250 } |
| 1251 |
| 1252 void test_true_method_list_same() { |
| 1253 _assertCompilationUnitMatches(true, r''' |
| 1254 class A { |
| 1255 a() {} |
| 1256 b() {} |
| 1257 c() {} |
| 1258 } |
| 1259 ''', r''' |
| 1260 class A { |
| 1261 a() {} |
| 1262 b() {} |
| 1263 c() {} |
| 1264 } |
| 1265 '''); |
| 1266 } |
| 1267 |
| 1268 void test_true_method_operator_minus() { |
| 1269 _assertCompilationUnitMatches(true, r''' |
| 1270 class A { |
| 1271 operator -(other) {} |
| 1272 } |
| 1273 ''', r''' |
| 1274 class A { |
| 1275 operator -(other) {} |
| 1276 } |
| 1277 '''); |
| 1278 } |
| 1279 |
| 1280 void test_true_method_operator_minusUnary() { |
| 1281 _assertCompilationUnitMatches(true, r''' |
| 1282 class A { |
| 1283 operator -() {} |
| 1284 } |
| 1285 ''', r''' |
| 1286 class A { |
| 1287 operator -() {} |
| 1288 } |
| 1289 '''); |
| 1290 } |
| 1291 |
| 1292 void test_true_method_operator_plus() { |
| 1293 _assertCompilationUnitMatches(true, r''' |
| 1294 class A { |
| 1295 operator +(other) {} |
| 1296 } |
| 1297 ''', r''' |
| 1298 class A { |
| 1299 operator +(other) {} |
| 1300 } |
| 1301 '''); |
| 1302 } |
| 1303 |
| 986 void test_true_part_list_reorder() { | 1304 void test_true_part_list_reorder() { |
| 987 addNamedSource('/unitA.dart', 'part of lib; class A {}'); | 1305 addNamedSource('/unitA.dart', 'part of lib; class A {}'); |
| 988 addNamedSource('/unitB.dart', 'part of lib; class B {}'); | 1306 addNamedSource('/unitB.dart', 'part of lib; class B {}'); |
| 989 _assertCompilationUnitMatches(true, r''' | 1307 _assertCompilationUnitMatches(true, r''' |
| 990 library lib; | 1308 library lib; |
| 991 part 'unitA.dart'; | 1309 part 'unitA.dart'; |
| 992 part 'unitB.dart'; | 1310 part 'unitB.dart'; |
| 993 ''', r''' | 1311 ''', r''' |
| 994 library lib; | 1312 library lib; |
| 995 part 'unitB.dart'; | 1313 part 'unitB.dart'; |
| 996 part 'unitA.dart'; | 1314 part 'unitA.dart'; |
| 997 '''); | 1315 '''); |
| 998 } | 1316 } |
| 999 | 1317 |
| 1000 void test_true_part_list_same() { | 1318 void test_true_part_list_same() { |
| 1001 addNamedSource('/unitA.dart', 'part of lib; class A {}'); | 1319 addNamedSource('/unitA.dart', 'part of lib; class A {}'); |
| 1002 addNamedSource('/unitB.dart', 'part of lib; class B {}'); | 1320 addNamedSource('/unitB.dart', 'part of lib; class B {}'); |
| 1003 _assertCompilationUnitMatches(true, r''' | 1321 _assertCompilationUnitMatches(true, r''' |
| 1004 library lib; | 1322 library lib; |
| 1005 part 'unitA.dart'; | 1323 part 'unitA.dart'; |
| 1006 part 'unitB.dart'; | 1324 part 'unitB.dart'; |
| 1007 ''', r''' | 1325 ''', r''' |
| 1008 library lib; | 1326 library lib; |
| 1009 part 'unitA.dart'; | 1327 part 'unitA.dart'; |
| 1010 part 'unitB.dart'; | 1328 part 'unitB.dart'; |
| 1011 '''); | 1329 '''); |
| 1012 } | 1330 } |
| 1013 | 1331 |
| 1332 void test_true_topLevelAccessor_list_reorder() { |
| 1333 _assertCompilationUnitMatches(true, r''' |
| 1334 set a(x) {} |
| 1335 set b(x) {} |
| 1336 set c(x) {} |
| 1337 ''', r''' |
| 1338 set c(x) {} |
| 1339 set a(x) {} |
| 1340 set b(x) {} |
| 1341 '''); |
| 1342 } |
| 1343 |
| 1344 void test_true_topLevelAccessor_list_same() { |
| 1345 _assertCompilationUnitMatches(true, r''' |
| 1346 get a => 1; |
| 1347 get b => 2; |
| 1348 get c => 3; |
| 1349 ''', r''' |
| 1350 get a => 1; |
| 1351 get b => 2; |
| 1352 get c => 3; |
| 1353 '''); |
| 1354 } |
| 1355 |
| 1356 void test_true_topLevelFunction_list_reorder() { |
| 1357 _assertCompilationUnitMatches(true, r''' |
| 1358 a() {} |
| 1359 b() {} |
| 1360 c() {} |
| 1361 ''', r''' |
| 1362 c() {} |
| 1363 a() {} |
| 1364 b() {} |
| 1365 '''); |
| 1366 } |
| 1367 |
| 1368 void test_true_topLevelFunction_list_same() { |
| 1369 _assertCompilationUnitMatches(true, r''' |
| 1370 a() {} |
| 1371 b() {} |
| 1372 c() {} |
| 1373 ''', r''' |
| 1374 a() {} |
| 1375 b() {} |
| 1376 c() {} |
| 1377 '''); |
| 1378 } |
| 1379 |
| 1014 void test_true_topLevelVariable_list_reorder() { | 1380 void test_true_topLevelVariable_list_reorder() { |
| 1015 _assertCompilationUnitMatches(true, r''' | 1381 _assertCompilationUnitMatches(true, r''' |
| 1016 const int A = 1; | 1382 const int A = 1; |
| 1017 const int B = 2; | 1383 const int B = 2; |
| 1018 const int C = 3; | 1384 const int C = 3; |
| 1019 ''', r''' | 1385 ''', r''' |
| 1020 const int C = 3; | 1386 const int C = 3; |
| 1021 const int A = 1; | 1387 const int A = 1; |
| 1022 const int B = 2; | 1388 const int B = 2; |
| 1023 '''); | 1389 '''); |
| (...skipping 1394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2418 _visitList(node.metadata, other.metadata); | 2784 _visitList(node.metadata, other.metadata); |
| 2419 _visitNode(node.identifier, other.identifier); | 2785 _visitNode(node.identifier, other.identifier); |
| 2420 } | 2786 } |
| 2421 | 2787 |
| 2422 static void assertSameResolution(CompilationUnit actual, | 2788 static void assertSameResolution(CompilationUnit actual, |
| 2423 CompilationUnit expected) { | 2789 CompilationUnit expected) { |
| 2424 _SameResolutionValidator validator = new _SameResolutionValidator(expected); | 2790 _SameResolutionValidator validator = new _SameResolutionValidator(expected); |
| 2425 actual.accept(validator); | 2791 actual.accept(validator); |
| 2426 } | 2792 } |
| 2427 } | 2793 } |
| OLD | NEW |