| 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 analyzer.test.generated.incremental_resolver_test; | 5 library analyzer.test.generated.incremental_resolver_test; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/ast/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
| 9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/src/context/cache.dart'; | 10 import 'package:analyzer/src/context/cache.dart'; |
| 11 import 'package:analyzer/src/dart/ast/utilities.dart'; | 11 import 'package:analyzer/src/dart/ast/utilities.dart'; |
| 12 import 'package:analyzer/src/dart/element/builder.dart'; | |
| 13 import 'package:analyzer/src/dart/element/element.dart'; | 12 import 'package:analyzer/src/dart/element/element.dart'; |
| 14 import 'package:analyzer/src/dart/scanner/reader.dart'; | 13 import 'package:analyzer/src/dart/scanner/reader.dart'; |
| 15 import 'package:analyzer/src/dart/scanner/scanner.dart'; | 14 import 'package:analyzer/src/dart/scanner/scanner.dart'; |
| 16 import 'package:analyzer/src/generated/engine.dart'; | 15 import 'package:analyzer/src/generated/engine.dart'; |
| 17 import 'package:analyzer/src/generated/error.dart'; | 16 import 'package:analyzer/src/generated/error.dart'; |
| 18 import 'package:analyzer/src/generated/incremental_logger.dart' as logging; | 17 import 'package:analyzer/src/generated/incremental_logger.dart' as logging; |
| 19 import 'package:analyzer/src/generated/incremental_resolution_validator.dart'; | 18 import 'package:analyzer/src/generated/incremental_resolution_validator.dart'; |
| 20 import 'package:analyzer/src/generated/incremental_resolver.dart'; | 19 import 'package:analyzer/src/generated/incremental_resolver.dart'; |
| 21 import 'package:analyzer/src/generated/java_engine.dart'; | 20 import 'package:analyzer/src/generated/java_engine.dart'; |
| 22 import 'package:analyzer/src/generated/parser.dart'; | 21 import 'package:analyzer/src/generated/parser.dart'; |
| 23 import 'package:analyzer/src/generated/resolver.dart'; | 22 import 'package:analyzer/src/generated/resolver.dart'; |
| 24 import 'package:analyzer/src/generated/source_io.dart'; | 23 import 'package:analyzer/src/generated/source_io.dart'; |
| 25 import 'package:analyzer/src/generated/testing/ast_factory.dart'; | 24 import 'package:analyzer/src/generated/testing/ast_factory.dart'; |
| 26 import 'package:analyzer/src/generated/testing/element_factory.dart'; | 25 import 'package:analyzer/src/generated/testing/element_factory.dart'; |
| 27 import 'package:analyzer/src/generated/utilities_collection.dart'; | 26 import 'package:analyzer/src/generated/utilities_collection.dart'; |
| 28 import 'package:analyzer/src/task/dart.dart'; | 27 import 'package:analyzer/src/task/dart.dart'; |
| 29 import 'package:analyzer/task/dart.dart'; | 28 import 'package:analyzer/task/dart.dart'; |
| 30 import 'package:analyzer/task/model.dart'; | 29 import 'package:analyzer/task/model.dart'; |
| 31 import 'package:unittest/unittest.dart'; | 30 import 'package:unittest/unittest.dart'; |
| 32 | 31 |
| 33 import '../reflective_tests.dart'; | 32 import '../reflective_tests.dart'; |
| 34 import 'analysis_context_factory.dart'; | 33 import 'analysis_context_factory.dart'; |
| 35 import 'resolver_test_case.dart'; | 34 import 'resolver_test_case.dart'; |
| 36 import 'test_support.dart'; | 35 import 'test_support.dart'; |
| 37 | 36 |
| 38 main() { | 37 main() { |
| 39 initializeTestEnvironment(); | 38 initializeTestEnvironment(); |
| 40 runReflectiveTests(DeclarationMatcherTest); | |
| 41 runReflectiveTests(IncrementalResolverTest); | 39 runReflectiveTests(IncrementalResolverTest); |
| 42 runReflectiveTests(PoorMansIncrementalResolutionTest); | 40 runReflectiveTests(PoorMansIncrementalResolutionTest); |
| 43 runReflectiveTests(ResolutionContextBuilderTest); | 41 runReflectiveTests(ResolutionContextBuilderTest); |
| 44 } | 42 } |
| 45 | 43 |
| 46 void initializeTestEnvironment() {} | 44 void initializeTestEnvironment() {} |
| 47 | 45 |
| 48 void _assertEqualError(AnalysisError incError, AnalysisError fullError) { | 46 void _assertEqualError(AnalysisError incError, AnalysisError fullError) { |
| 49 if (incError.errorCode != fullError.errorCode || | 47 if (incError.errorCode != fullError.errorCode || |
| 50 incError.source != fullError.source || | 48 incError.source != fullError.source || |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 if (cache.get(key) == null) { | 129 if (cache.get(key) == null) { |
| 132 fail("cache corrupted: value of $key changed to null"); | 130 fail("cache corrupted: value of $key changed to null"); |
| 133 } | 131 } |
| 134 if (!seen.add(key)) { | 132 if (!seen.add(key)) { |
| 135 fail("cache corrupted: $key appears more than once"); | 133 fail("cache corrupted: $key appears more than once"); |
| 136 } | 134 } |
| 137 } | 135 } |
| 138 } | 136 } |
| 139 | 137 |
| 140 @reflectiveTest | 138 @reflectiveTest |
| 141 class DeclarationMatcherTest extends ResolverTestCase { | |
| 142 void setUp() { | |
| 143 super.setUp(); | |
| 144 test_resolveApiChanges = true; | |
| 145 } | |
| 146 | |
| 147 void test_false_class_annotation_accessor_edit() { | |
| 148 _assertDoesNotMatch( | |
| 149 r''' | |
| 150 const my_annotationA = const Object(); | |
| 151 const my_annotationB = const Object(); | |
| 152 @my_annotationA | |
| 153 class A { | |
| 154 } | |
| 155 ''', | |
| 156 r''' | |
| 157 const my_annotationA = const Object(); | |
| 158 const my_annotationB = const Object(); | |
| 159 @my_annotationB | |
| 160 class A { | |
| 161 } | |
| 162 '''); | |
| 163 } | |
| 164 | |
| 165 void test_false_class_annotation_constructor_edit() { | |
| 166 _assertDoesNotMatch( | |
| 167 r''' | |
| 168 class MyAnnotationA { | |
| 169 const MyAnnotationA(); | |
| 170 } | |
| 171 class MyAnnotationB { | |
| 172 const MyAnnotationB(); | |
| 173 } | |
| 174 @MyAnnotationA() | |
| 175 class A { | |
| 176 } | |
| 177 ''', | |
| 178 r''' | |
| 179 class MyAnnotationA { | |
| 180 const MyAnnotationA(); | |
| 181 } | |
| 182 class MyAnnotationB { | |
| 183 const MyAnnotationB(); | |
| 184 } | |
| 185 @MyAnnotationB() | |
| 186 class A { | |
| 187 } | |
| 188 '''); | |
| 189 } | |
| 190 | |
| 191 void test_false_class_annotations_add() { | |
| 192 _assertDoesNotMatch( | |
| 193 r''' | |
| 194 const my_annotation = const Object(); | |
| 195 class A { | |
| 196 } | |
| 197 ''', | |
| 198 r''' | |
| 199 const my_annotation = const Object(); | |
| 200 @my_annotation | |
| 201 class A { | |
| 202 } | |
| 203 '''); | |
| 204 } | |
| 205 | |
| 206 void test_false_class_annotations_remove() { | |
| 207 _assertDoesNotMatch( | |
| 208 r''' | |
| 209 const my_annotation = const Object(); | |
| 210 @my_annotation | |
| 211 class A { | |
| 212 } | |
| 213 ''', | |
| 214 r''' | |
| 215 const my_annotation = const Object(); | |
| 216 class A { | |
| 217 } | |
| 218 '''); | |
| 219 } | |
| 220 | |
| 221 void test_false_class_list_add() { | |
| 222 _assertDoesNotMatch( | |
| 223 r''' | |
| 224 class A {} | |
| 225 class B {} | |
| 226 ''', | |
| 227 r''' | |
| 228 class A {} | |
| 229 class B {} | |
| 230 class C {} | |
| 231 '''); | |
| 232 } | |
| 233 | |
| 234 void test_false_class_list_remove() { | |
| 235 _assertDoesNotMatch( | |
| 236 r''' | |
| 237 class A {} | |
| 238 class B {} | |
| 239 class C {} | |
| 240 ''', | |
| 241 r''' | |
| 242 class A {} | |
| 243 class B {} | |
| 244 '''); | |
| 245 } | |
| 246 | |
| 247 void test_false_class_typeParameters_bounds_add() { | |
| 248 _assertDoesNotMatch( | |
| 249 r''' | |
| 250 class A {} | |
| 251 class B<T> { | |
| 252 T f; | |
| 253 } | |
| 254 ''', | |
| 255 r''' | |
| 256 class A {} | |
| 257 class B<T extends A> { | |
| 258 T f; | |
| 259 } | |
| 260 '''); | |
| 261 } | |
| 262 | |
| 263 void test_false_class_typeParameters_bounds_remove() { | |
| 264 _assertDoesNotMatch( | |
| 265 r''' | |
| 266 class A {} | |
| 267 class B<T extends A> { | |
| 268 T f; | |
| 269 } | |
| 270 ''', | |
| 271 r''' | |
| 272 class A {} | |
| 273 class B<T> { | |
| 274 T f; | |
| 275 } | |
| 276 '''); | |
| 277 } | |
| 278 | |
| 279 void test_false_classMemberAccessor_list_add() { | |
| 280 _assertDoesNotMatchOK( | |
| 281 r''' | |
| 282 class A { | |
| 283 get a => 1; | |
| 284 get b => 2; | |
| 285 } | |
| 286 ''', | |
| 287 r''' | |
| 288 class A { | |
| 289 get a => 1; | |
| 290 get b => 2; | |
| 291 get c => 3; | |
| 292 } | |
| 293 '''); | |
| 294 } | |
| 295 | |
| 296 void test_false_classMemberAccessor_list_remove() { | |
| 297 _assertDoesNotMatch( | |
| 298 r''' | |
| 299 class A { | |
| 300 get a => 1; | |
| 301 get b => 2; | |
| 302 get c => 3; | |
| 303 } | |
| 304 ''', | |
| 305 r''' | |
| 306 class A { | |
| 307 get a => 1; | |
| 308 get b => 2; | |
| 309 } | |
| 310 '''); | |
| 311 } | |
| 312 | |
| 313 void test_false_classMemberAccessor_wasGetter() { | |
| 314 _assertDoesNotMatchOK( | |
| 315 r''' | |
| 316 class A { | |
| 317 get a => 1; | |
| 318 } | |
| 319 ''', | |
| 320 r''' | |
| 321 class A { | |
| 322 set a(x) {} | |
| 323 } | |
| 324 '''); | |
| 325 } | |
| 326 | |
| 327 void test_false_classMemberAccessor_wasInstance() { | |
| 328 _assertDoesNotMatchOK( | |
| 329 r''' | |
| 330 class A { | |
| 331 get a => 1; | |
| 332 } | |
| 333 ''', | |
| 334 r''' | |
| 335 class A { | |
| 336 static get a => 1; | |
| 337 } | |
| 338 '''); | |
| 339 } | |
| 340 | |
| 341 void test_false_classMemberAccessor_wasSetter() { | |
| 342 _assertDoesNotMatchOK( | |
| 343 r''' | |
| 344 class A { | |
| 345 set a(x) {} | |
| 346 } | |
| 347 ''', | |
| 348 r''' | |
| 349 class A { | |
| 350 get a => 1; | |
| 351 } | |
| 352 '''); | |
| 353 } | |
| 354 | |
| 355 void test_false_classMemberAccessor_wasStatic() { | |
| 356 _assertDoesNotMatchOK( | |
| 357 r''' | |
| 358 class A { | |
| 359 static get a => 1; | |
| 360 } | |
| 361 ''', | |
| 362 r''' | |
| 363 class A { | |
| 364 get a => 1; | |
| 365 } | |
| 366 '''); | |
| 367 } | |
| 368 | |
| 369 void test_false_classTypeAlias_list_add() { | |
| 370 _assertDoesNotMatch( | |
| 371 r''' | |
| 372 class M {} | |
| 373 class A = Object with M; | |
| 374 ''', | |
| 375 r''' | |
| 376 class M {} | |
| 377 class A = Object with M; | |
| 378 class B = Object with M; | |
| 379 '''); | |
| 380 } | |
| 381 | |
| 382 void test_false_classTypeAlias_list_remove() { | |
| 383 _assertDoesNotMatch( | |
| 384 r''' | |
| 385 class M {} | |
| 386 class A = Object with M; | |
| 387 class B = Object with M; | |
| 388 ''', | |
| 389 r''' | |
| 390 class M {} | |
| 391 class A = Object with M; | |
| 392 '''); | |
| 393 } | |
| 394 | |
| 395 void test_false_classTypeAlias_typeParameters_bounds_add() { | |
| 396 _assertDoesNotMatch( | |
| 397 r''' | |
| 398 class M<T> {} | |
| 399 class A {} | |
| 400 class B<T> = Object with M<T>; | |
| 401 ''', | |
| 402 r''' | |
| 403 class M<T> {} | |
| 404 class A {} | |
| 405 class B<T extends A> = Object with M<T>; | |
| 406 '''); | |
| 407 } | |
| 408 | |
| 409 void test_false_classTypeAlias_typeParameters_bounds_remove() { | |
| 410 _assertDoesNotMatch( | |
| 411 r''' | |
| 412 class M<T> {} | |
| 413 class A {} | |
| 414 class B<T extends A> = Object with M<T>; | |
| 415 ''', | |
| 416 r''' | |
| 417 class M<T> {} | |
| 418 class A {} | |
| 419 class B<T> = Object with M<T>; | |
| 420 '''); | |
| 421 } | |
| 422 | |
| 423 void test_false_constructor_keywordConst_add() { | |
| 424 _assertDoesNotMatch( | |
| 425 r''' | |
| 426 class A { | |
| 427 A(); | |
| 428 } | |
| 429 ''', | |
| 430 r''' | |
| 431 class A { | |
| 432 const A(); | |
| 433 } | |
| 434 '''); | |
| 435 } | |
| 436 | |
| 437 void test_false_constructor_keywordConst_remove() { | |
| 438 _assertDoesNotMatch( | |
| 439 r''' | |
| 440 class A { | |
| 441 const A(); | |
| 442 } | |
| 443 ''', | |
| 444 r''' | |
| 445 class A { | |
| 446 A(); | |
| 447 } | |
| 448 '''); | |
| 449 } | |
| 450 | |
| 451 void test_false_constructor_keywordFactory_add() { | |
| 452 _assertDoesNotMatch( | |
| 453 r''' | |
| 454 class A { | |
| 455 A(); | |
| 456 A.foo() { | |
| 457 return new A(); | |
| 458 } | |
| 459 } | |
| 460 ''', | |
| 461 r''' | |
| 462 class A { | |
| 463 A(); | |
| 464 factory A.foo() { | |
| 465 return new A(); | |
| 466 } | |
| 467 } | |
| 468 '''); | |
| 469 } | |
| 470 | |
| 471 void test_false_constructor_keywordFactory_remove() { | |
| 472 _assertDoesNotMatch( | |
| 473 r''' | |
| 474 class A { | |
| 475 A(); | |
| 476 factory A.foo() { | |
| 477 return new A(); | |
| 478 } | |
| 479 } | |
| 480 ''', | |
| 481 r''' | |
| 482 class A { | |
| 483 A(); | |
| 484 A.foo() { | |
| 485 return new A(); | |
| 486 } | |
| 487 } | |
| 488 '''); | |
| 489 } | |
| 490 | |
| 491 void test_false_constructor_parameters_list_add() { | |
| 492 _assertDoesNotMatch( | |
| 493 r''' | |
| 494 class A { | |
| 495 A(); | |
| 496 } | |
| 497 ''', | |
| 498 r''' | |
| 499 class A { | |
| 500 A(int p); | |
| 501 } | |
| 502 '''); | |
| 503 } | |
| 504 | |
| 505 void test_false_constructor_parameters_list_remove() { | |
| 506 _assertDoesNotMatch( | |
| 507 r''' | |
| 508 class A { | |
| 509 A(int p); | |
| 510 } | |
| 511 ''', | |
| 512 r''' | |
| 513 class A { | |
| 514 A(); | |
| 515 } | |
| 516 '''); | |
| 517 } | |
| 518 | |
| 519 void test_false_constructor_parameters_name() { | |
| 520 _assertDoesNotMatch( | |
| 521 r''' | |
| 522 class A { | |
| 523 A(int a); | |
| 524 } | |
| 525 ''', | |
| 526 r''' | |
| 527 class A { | |
| 528 A(int b); | |
| 529 } | |
| 530 '''); | |
| 531 } | |
| 532 | |
| 533 void test_false_constructor_parameters_type_edit() { | |
| 534 _assertDoesNotMatch( | |
| 535 r''' | |
| 536 class A { | |
| 537 A(int p); | |
| 538 } | |
| 539 ''', | |
| 540 r''' | |
| 541 class A { | |
| 542 A(String p); | |
| 543 } | |
| 544 '''); | |
| 545 } | |
| 546 | |
| 547 void test_false_constructor_unnamed_add_hadParameters() { | |
| 548 _assertDoesNotMatch( | |
| 549 r''' | |
| 550 class A { | |
| 551 } | |
| 552 ''', | |
| 553 r''' | |
| 554 class A { | |
| 555 A(int p) {} | |
| 556 } | |
| 557 '''); | |
| 558 } | |
| 559 | |
| 560 void test_false_constructor_unnamed_remove_hadParameters() { | |
| 561 _assertDoesNotMatch( | |
| 562 r''' | |
| 563 class A { | |
| 564 A(int p) {} | |
| 565 } | |
| 566 ''', | |
| 567 r''' | |
| 568 class A { | |
| 569 } | |
| 570 '''); | |
| 571 } | |
| 572 | |
| 573 void test_false_defaultFieldFormalParameterElement_wasSimple() { | |
| 574 _assertDoesNotMatch( | |
| 575 r''' | |
| 576 class A { | |
| 577 int field; | |
| 578 A(int field); | |
| 579 } | |
| 580 ''', | |
| 581 r''' | |
| 582 class A { | |
| 583 int field; | |
| 584 A([this.field = 0]); | |
| 585 } | |
| 586 '''); | |
| 587 } | |
| 588 | |
| 589 void test_false_enum_constants_add() { | |
| 590 _assertDoesNotMatch( | |
| 591 r''' | |
| 592 enum E {A, B} | |
| 593 ''', | |
| 594 r''' | |
| 595 enum E {A, B, C} | |
| 596 '''); | |
| 597 } | |
| 598 | |
| 599 void test_false_enum_constants_remove() { | |
| 600 _assertDoesNotMatch( | |
| 601 r''' | |
| 602 enum E {A, B, C} | |
| 603 ''', | |
| 604 r''' | |
| 605 enum E {A, B} | |
| 606 '''); | |
| 607 } | |
| 608 | |
| 609 void test_false_export_hide_add() { | |
| 610 _assertDoesNotMatch( | |
| 611 r''' | |
| 612 export 'dart:async' hide Future; | |
| 613 ''', | |
| 614 r''' | |
| 615 export 'dart:async' hide Future, Stream; | |
| 616 '''); | |
| 617 } | |
| 618 | |
| 619 void test_false_export_hide_remove() { | |
| 620 _assertDoesNotMatch( | |
| 621 r''' | |
| 622 export 'dart:async' hide Future, Stream; | |
| 623 ''', | |
| 624 r''' | |
| 625 export 'dart:async' hide Future; | |
| 626 '''); | |
| 627 } | |
| 628 | |
| 629 void test_false_export_list_add() { | |
| 630 _assertDoesNotMatch( | |
| 631 r''' | |
| 632 export 'dart:async'; | |
| 633 ''', | |
| 634 r''' | |
| 635 export 'dart:async'; | |
| 636 export 'dart:math'; | |
| 637 '''); | |
| 638 } | |
| 639 | |
| 640 void test_false_export_list_remove() { | |
| 641 _assertDoesNotMatch( | |
| 642 r''' | |
| 643 export 'dart:async'; | |
| 644 export 'dart:math'; | |
| 645 ''', | |
| 646 r''' | |
| 647 export 'dart:async'; | |
| 648 '''); | |
| 649 } | |
| 650 | |
| 651 void test_false_export_show_add() { | |
| 652 _assertDoesNotMatch( | |
| 653 r''' | |
| 654 export 'dart:async' show Future; | |
| 655 ''', | |
| 656 r''' | |
| 657 export 'dart:async' show Future, Stream; | |
| 658 '''); | |
| 659 } | |
| 660 | |
| 661 void test_false_export_show_remove() { | |
| 662 _assertDoesNotMatch( | |
| 663 r''' | |
| 664 export 'dart:async' show Future, Stream; | |
| 665 ''', | |
| 666 r''' | |
| 667 export 'dart:async' show Future; | |
| 668 '''); | |
| 669 } | |
| 670 | |
| 671 void test_false_extendsClause_add() { | |
| 672 _assertDoesNotMatch( | |
| 673 r''' | |
| 674 class A {} | |
| 675 class B {} | |
| 676 ''', | |
| 677 r''' | |
| 678 class A {} | |
| 679 class B extends A {} | |
| 680 '''); | |
| 681 } | |
| 682 | |
| 683 void test_false_extendsClause_different() { | |
| 684 _assertDoesNotMatch( | |
| 685 r''' | |
| 686 class A {} | |
| 687 class B {} | |
| 688 class C extends A {} | |
| 689 ''', | |
| 690 r''' | |
| 691 class A {} | |
| 692 class B {} | |
| 693 class C extends B {} | |
| 694 '''); | |
| 695 } | |
| 696 | |
| 697 void test_false_extendsClause_remove() { | |
| 698 _assertDoesNotMatch( | |
| 699 r''' | |
| 700 class A {} | |
| 701 class B extends A{} | |
| 702 ''', | |
| 703 r''' | |
| 704 class A {} | |
| 705 class B {} | |
| 706 '''); | |
| 707 } | |
| 708 | |
| 709 void test_false_field_list_add() { | |
| 710 _assertDoesNotMatch( | |
| 711 r''' | |
| 712 class T { | |
| 713 int A = 1; | |
| 714 int C = 3; | |
| 715 } | |
| 716 ''', | |
| 717 r''' | |
| 718 class T { | |
| 719 int A = 1; | |
| 720 int B = 2; | |
| 721 int C = 3; | |
| 722 } | |
| 723 '''); | |
| 724 } | |
| 725 | |
| 726 void test_false_field_list_remove() { | |
| 727 _assertDoesNotMatch( | |
| 728 r''' | |
| 729 class T { | |
| 730 int A = 1; | |
| 731 int B = 2; | |
| 732 int C = 3; | |
| 733 } | |
| 734 ''', | |
| 735 r''' | |
| 736 class T { | |
| 737 int A = 1; | |
| 738 int C = 3; | |
| 739 } | |
| 740 '''); | |
| 741 } | |
| 742 | |
| 743 void test_false_field_modifier_isConst() { | |
| 744 _assertDoesNotMatch( | |
| 745 r''' | |
| 746 class T { | |
| 747 static final A = 1; | |
| 748 } | |
| 749 ''', | |
| 750 r''' | |
| 751 class T { | |
| 752 static const A = 1; | |
| 753 } | |
| 754 '''); | |
| 755 } | |
| 756 | |
| 757 void test_false_field_modifier_isFinal() { | |
| 758 _assertDoesNotMatch( | |
| 759 r''' | |
| 760 class T { | |
| 761 int A = 1; | |
| 762 } | |
| 763 ''', | |
| 764 r''' | |
| 765 class T { | |
| 766 final int A = 1; | |
| 767 } | |
| 768 '''); | |
| 769 } | |
| 770 | |
| 771 void test_false_field_modifier_isStatic() { | |
| 772 _assertDoesNotMatch( | |
| 773 r''' | |
| 774 class T { | |
| 775 int A = 1; | |
| 776 } | |
| 777 ''', | |
| 778 r''' | |
| 779 class T { | |
| 780 static int A = 1; | |
| 781 } | |
| 782 '''); | |
| 783 } | |
| 784 | |
| 785 void test_false_field_modifier_wasConst() { | |
| 786 _assertDoesNotMatch( | |
| 787 r''' | |
| 788 class T { | |
| 789 static const A = 1; | |
| 790 } | |
| 791 ''', | |
| 792 r''' | |
| 793 class T { | |
| 794 static final A = 1; | |
| 795 } | |
| 796 '''); | |
| 797 } | |
| 798 | |
| 799 void test_false_field_modifier_wasFinal() { | |
| 800 _assertDoesNotMatch( | |
| 801 r''' | |
| 802 class T { | |
| 803 final int A = 1; | |
| 804 } | |
| 805 ''', | |
| 806 r''' | |
| 807 class T { | |
| 808 int A = 1; | |
| 809 } | |
| 810 '''); | |
| 811 } | |
| 812 | |
| 813 void test_false_field_modifier_wasStatic() { | |
| 814 _assertDoesNotMatch( | |
| 815 r''' | |
| 816 class T { | |
| 817 static int A = 1; | |
| 818 } | |
| 819 ''', | |
| 820 r''' | |
| 821 class T { | |
| 822 int A = 1; | |
| 823 } | |
| 824 '''); | |
| 825 } | |
| 826 | |
| 827 void test_false_field_type_differentArgs() { | |
| 828 _assertDoesNotMatch( | |
| 829 r''' | |
| 830 class T { | |
| 831 List<int> A; | |
| 832 } | |
| 833 ''', | |
| 834 r''' | |
| 835 class T { | |
| 836 List<String> A; | |
| 837 } | |
| 838 '''); | |
| 839 } | |
| 840 | |
| 841 void test_false_fieldFormalParameter_add() { | |
| 842 _assertDoesNotMatch( | |
| 843 r''' | |
| 844 class A { | |
| 845 final field; | |
| 846 A(field); | |
| 847 } | |
| 848 ''', | |
| 849 r''' | |
| 850 class A { | |
| 851 final field; | |
| 852 A(this.field); | |
| 853 } | |
| 854 '''); | |
| 855 } | |
| 856 | |
| 857 void test_false_fieldFormalParameter_add_function() { | |
| 858 _assertDoesNotMatch( | |
| 859 r''' | |
| 860 class A { | |
| 861 final field; | |
| 862 A(field(a)); | |
| 863 } | |
| 864 ''', | |
| 865 r''' | |
| 866 class A { | |
| 867 final field; | |
| 868 A(this.field(a)); | |
| 869 } | |
| 870 '''); | |
| 871 } | |
| 872 | |
| 873 void test_false_fieldFormalParameter_changeName_wasUnresolvedField() { | |
| 874 _assertDoesNotMatch( | |
| 875 r''' | |
| 876 class A { | |
| 877 final fff; | |
| 878 A(this.unresolved); | |
| 879 } | |
| 880 ''', | |
| 881 r''' | |
| 882 class A { | |
| 883 final fff; | |
| 884 A(this.fff); | |
| 885 } | |
| 886 '''); | |
| 887 } | |
| 888 | |
| 889 void test_false_fieldFormalParameter_differentField() { | |
| 890 _assertDoesNotMatch( | |
| 891 r''' | |
| 892 class A { | |
| 893 final aaa; | |
| 894 final bbb; | |
| 895 A(this.aaa, this.bbb); | |
| 896 } | |
| 897 ''', | |
| 898 r''' | |
| 899 class A { | |
| 900 final aaa; | |
| 901 final bbb; | |
| 902 A(this.bbb, this.aaa); | |
| 903 } | |
| 904 '''); | |
| 905 } | |
| 906 | |
| 907 void test_false_fieldFormalParameter_parameters_add() { | |
| 908 _assertDoesNotMatch( | |
| 909 r''' | |
| 910 class A { | |
| 911 final field; | |
| 912 A(this.field(a)); | |
| 913 } | |
| 914 ''', | |
| 915 r''' | |
| 916 class A { | |
| 917 final field; | |
| 918 A(this.field(a, b)); | |
| 919 } | |
| 920 '''); | |
| 921 } | |
| 922 | |
| 923 void test_false_fieldFormalParameter_parameters_remove() { | |
| 924 _assertDoesNotMatch( | |
| 925 r''' | |
| 926 class A { | |
| 927 final field; | |
| 928 A(this.field(a, b)); | |
| 929 } | |
| 930 ''', | |
| 931 r''' | |
| 932 class A { | |
| 933 final field; | |
| 934 A(this.field(a)); | |
| 935 } | |
| 936 '''); | |
| 937 } | |
| 938 | |
| 939 void test_false_fieldFormalParameter_parameters_typeEdit() { | |
| 940 _assertDoesNotMatch( | |
| 941 r''' | |
| 942 class A { | |
| 943 final field; | |
| 944 A(this.field(int p)); | |
| 945 } | |
| 946 ''', | |
| 947 r''' | |
| 948 class A { | |
| 949 final field; | |
| 950 A(this.field(String p)); | |
| 951 } | |
| 952 '''); | |
| 953 } | |
| 954 | |
| 955 void test_false_fieldFormalParameter_remove_default() { | |
| 956 _assertDoesNotMatch( | |
| 957 r''' | |
| 958 class A { | |
| 959 final field; | |
| 960 A([this.field = 0]); | |
| 961 } | |
| 962 ''', | |
| 963 r''' | |
| 964 class A { | |
| 965 final field; | |
| 966 A([field = 0]); | |
| 967 } | |
| 968 '''); | |
| 969 } | |
| 970 | |
| 971 void test_false_fieldFormalParameter_remove_function() { | |
| 972 _assertDoesNotMatch( | |
| 973 r''' | |
| 974 class A { | |
| 975 final field; | |
| 976 A(this.field(a)); | |
| 977 } | |
| 978 ''', | |
| 979 r''' | |
| 980 class A { | |
| 981 final field; | |
| 982 A(field(a)); | |
| 983 } | |
| 984 '''); | |
| 985 } | |
| 986 | |
| 987 void test_false_fieldFormalParameter_remove_normal() { | |
| 988 _assertDoesNotMatch( | |
| 989 r''' | |
| 990 class A { | |
| 991 final field; | |
| 992 A(this.field); | |
| 993 } | |
| 994 ''', | |
| 995 r''' | |
| 996 class A { | |
| 997 final field; | |
| 998 A(field); | |
| 999 } | |
| 1000 '''); | |
| 1001 } | |
| 1002 | |
| 1003 void test_false_fieldFormalParameter_typeAdd() { | |
| 1004 _assertDoesNotMatch( | |
| 1005 r''' | |
| 1006 class A { | |
| 1007 final fff; | |
| 1008 A(this.fff); | |
| 1009 } | |
| 1010 ''', | |
| 1011 r''' | |
| 1012 class A { | |
| 1013 final fff; | |
| 1014 A(int this.fff); | |
| 1015 } | |
| 1016 '''); | |
| 1017 } | |
| 1018 | |
| 1019 void test_false_fieldFormalParameter_typeEdit() { | |
| 1020 _assertDoesNotMatch( | |
| 1021 r''' | |
| 1022 class A { | |
| 1023 final fff; | |
| 1024 A(int this.fff); | |
| 1025 } | |
| 1026 ''', | |
| 1027 r''' | |
| 1028 class A { | |
| 1029 final fff; | |
| 1030 A(String this.fff); | |
| 1031 } | |
| 1032 '''); | |
| 1033 } | |
| 1034 | |
| 1035 void test_false_fieldFormalParameter_typeRemove() { | |
| 1036 _assertDoesNotMatch( | |
| 1037 r''' | |
| 1038 class A { | |
| 1039 final fff; | |
| 1040 A(int this.fff); | |
| 1041 } | |
| 1042 ''', | |
| 1043 r''' | |
| 1044 class A { | |
| 1045 final fff; | |
| 1046 A(this.fff); | |
| 1047 } | |
| 1048 '''); | |
| 1049 } | |
| 1050 | |
| 1051 void test_false_fieldFormalParameterElement_wasSimple() { | |
| 1052 _assertDoesNotMatch( | |
| 1053 r''' | |
| 1054 class A { | |
| 1055 int field; | |
| 1056 A(int field); | |
| 1057 } | |
| 1058 ''', | |
| 1059 r''' | |
| 1060 class A { | |
| 1061 int field; | |
| 1062 A(this.field); | |
| 1063 } | |
| 1064 '''); | |
| 1065 } | |
| 1066 | |
| 1067 void test_false_final_type_different() { | |
| 1068 _assertDoesNotMatch( | |
| 1069 r''' | |
| 1070 class T { | |
| 1071 int A; | |
| 1072 } | |
| 1073 ''', | |
| 1074 r''' | |
| 1075 class T { | |
| 1076 String A; | |
| 1077 } | |
| 1078 '''); | |
| 1079 } | |
| 1080 | |
| 1081 void test_false_function_async_add() { | |
| 1082 _assertDoesNotMatch( | |
| 1083 r''' | |
| 1084 main() {} | |
| 1085 ''', | |
| 1086 r''' | |
| 1087 main() async {} | |
| 1088 '''); | |
| 1089 } | |
| 1090 | |
| 1091 void test_false_function_async_remove() { | |
| 1092 _assertDoesNotMatch( | |
| 1093 r''' | |
| 1094 main() async {} | |
| 1095 ''', | |
| 1096 r''' | |
| 1097 main() {} | |
| 1098 '''); | |
| 1099 } | |
| 1100 | |
| 1101 void test_false_function_generator_add() { | |
| 1102 _assertDoesNotMatch( | |
| 1103 r''' | |
| 1104 main() async {} | |
| 1105 ''', | |
| 1106 r''' | |
| 1107 main() async* {} | |
| 1108 '''); | |
| 1109 } | |
| 1110 | |
| 1111 void test_false_function_generator_remove() { | |
| 1112 _assertDoesNotMatch( | |
| 1113 r''' | |
| 1114 main() async* {} | |
| 1115 ''', | |
| 1116 r''' | |
| 1117 main() async {} | |
| 1118 '''); | |
| 1119 } | |
| 1120 | |
| 1121 void test_false_functionTypeAlias_list_add() { | |
| 1122 _assertDoesNotMatch( | |
| 1123 r''' | |
| 1124 typedef A(int pa); | |
| 1125 typedef B(String pb); | |
| 1126 ''', | |
| 1127 r''' | |
| 1128 typedef A(int pa); | |
| 1129 typedef B(String pb); | |
| 1130 typedef C(pc); | |
| 1131 '''); | |
| 1132 } | |
| 1133 | |
| 1134 void test_false_functionTypeAlias_list_remove() { | |
| 1135 _assertDoesNotMatch( | |
| 1136 r''' | |
| 1137 typedef A(int pa); | |
| 1138 typedef B(String pb); | |
| 1139 typedef C(pc); | |
| 1140 ''', | |
| 1141 r''' | |
| 1142 typedef A(int pa); | |
| 1143 typedef B(String pb); | |
| 1144 '''); | |
| 1145 } | |
| 1146 | |
| 1147 void test_false_functionTypeAlias_parameters_list_add() { | |
| 1148 _assertDoesNotMatch( | |
| 1149 r''' | |
| 1150 typedef A(a); | |
| 1151 ''', | |
| 1152 r''' | |
| 1153 typedef A(a, b); | |
| 1154 '''); | |
| 1155 } | |
| 1156 | |
| 1157 void test_false_functionTypeAlias_parameters_list_remove() { | |
| 1158 _assertDoesNotMatch( | |
| 1159 r''' | |
| 1160 typedef A(a, b); | |
| 1161 ''', | |
| 1162 r''' | |
| 1163 typedef A(a); | |
| 1164 '''); | |
| 1165 } | |
| 1166 | |
| 1167 void test_false_functionTypeAlias_parameters_type_edit() { | |
| 1168 _assertDoesNotMatch( | |
| 1169 r''' | |
| 1170 typedef A(int p); | |
| 1171 ''', | |
| 1172 r''' | |
| 1173 typedef A(String p); | |
| 1174 '''); | |
| 1175 } | |
| 1176 | |
| 1177 void test_false_functionTypeAlias_returnType_edit() { | |
| 1178 _assertDoesNotMatch( | |
| 1179 r''' | |
| 1180 typedef int A(); | |
| 1181 ''', | |
| 1182 r''' | |
| 1183 typedef String A(); | |
| 1184 '''); | |
| 1185 } | |
| 1186 | |
| 1187 void test_false_functionTypeAlias_typeParameters_bounds_add() { | |
| 1188 _assertDoesNotMatch( | |
| 1189 r''' | |
| 1190 class A {} | |
| 1191 typedef F<T>(); | |
| 1192 ''', | |
| 1193 r''' | |
| 1194 class A {} | |
| 1195 typedef F<T extends A>(); | |
| 1196 '''); | |
| 1197 } | |
| 1198 | |
| 1199 void test_false_functionTypeAlias_typeParameters_bounds_edit() { | |
| 1200 _assertDoesNotMatch( | |
| 1201 r''' | |
| 1202 class A {} | |
| 1203 class B {} | |
| 1204 typedef F<T extends A>(); | |
| 1205 ''', | |
| 1206 r''' | |
| 1207 class A {} | |
| 1208 typedef F<T extends B>(); | |
| 1209 '''); | |
| 1210 } | |
| 1211 | |
| 1212 void test_false_functionTypeAlias_typeParameters_bounds_remove() { | |
| 1213 _assertDoesNotMatch( | |
| 1214 r''' | |
| 1215 class A {} | |
| 1216 typedef F<T extends A>(); | |
| 1217 ''', | |
| 1218 r''' | |
| 1219 class A {} | |
| 1220 typedef F<T>(); | |
| 1221 '''); | |
| 1222 } | |
| 1223 | |
| 1224 void test_false_functionTypeAlias_typeParameters_list_add() { | |
| 1225 _assertDoesNotMatch( | |
| 1226 r''' | |
| 1227 typedef F<A>(); | |
| 1228 ''', | |
| 1229 r''' | |
| 1230 typedef F<A, B>(); | |
| 1231 '''); | |
| 1232 } | |
| 1233 | |
| 1234 void test_false_functionTypeAlias_typeParameters_list_remove() { | |
| 1235 _assertDoesNotMatch( | |
| 1236 r''' | |
| 1237 typedef F<A, B>(); | |
| 1238 ''', | |
| 1239 r''' | |
| 1240 typedef F<A>(); | |
| 1241 '''); | |
| 1242 } | |
| 1243 | |
| 1244 void test_false_FunctionTypedFormalParameter_parameters_list_add() { | |
| 1245 _assertDoesNotMatch( | |
| 1246 r''' | |
| 1247 main(int callback(int a)) { | |
| 1248 } | |
| 1249 ''', | |
| 1250 r''' | |
| 1251 main(int callback(int a, String b)) { | |
| 1252 } | |
| 1253 '''); | |
| 1254 } | |
| 1255 | |
| 1256 void test_false_FunctionTypedFormalParameter_parameters_list_remove() { | |
| 1257 _assertDoesNotMatch( | |
| 1258 r''' | |
| 1259 main(int callback(int a, String b)) { | |
| 1260 } | |
| 1261 ''', | |
| 1262 r''' | |
| 1263 main(int callback(int a)) { | |
| 1264 } | |
| 1265 '''); | |
| 1266 } | |
| 1267 | |
| 1268 void test_false_FunctionTypedFormalParameter_parameterType() { | |
| 1269 _assertDoesNotMatch( | |
| 1270 r''' | |
| 1271 main(int callback(int p)) { | |
| 1272 } | |
| 1273 ''', | |
| 1274 r''' | |
| 1275 main(int callback(String p)) { | |
| 1276 } | |
| 1277 '''); | |
| 1278 } | |
| 1279 | |
| 1280 void test_false_FunctionTypedFormalParameter_returnType() { | |
| 1281 _assertDoesNotMatch( | |
| 1282 r''' | |
| 1283 main(int callback()) { | |
| 1284 } | |
| 1285 ''', | |
| 1286 r''' | |
| 1287 main(String callback()) { | |
| 1288 } | |
| 1289 '''); | |
| 1290 } | |
| 1291 | |
| 1292 void test_false_FunctionTypedFormalParameter_wasSimple() { | |
| 1293 _assertDoesNotMatch( | |
| 1294 r''' | |
| 1295 main(int callback) { | |
| 1296 } | |
| 1297 ''', | |
| 1298 r''' | |
| 1299 main(int callback(int a, String b)) { | |
| 1300 } | |
| 1301 '''); | |
| 1302 } | |
| 1303 | |
| 1304 void test_false_getter_body_add() { | |
| 1305 _assertDoesNotMatchOK( | |
| 1306 r''' | |
| 1307 class A { | |
| 1308 int get foo; | |
| 1309 } | |
| 1310 ''', | |
| 1311 r''' | |
| 1312 class A { | |
| 1313 int get foo => 0; | |
| 1314 } | |
| 1315 '''); | |
| 1316 } | |
| 1317 | |
| 1318 void test_false_getter_body_remove() { | |
| 1319 _assertDoesNotMatchOK( | |
| 1320 r''' | |
| 1321 class A { | |
| 1322 int get foo => 0; | |
| 1323 } | |
| 1324 ''', | |
| 1325 r''' | |
| 1326 class A { | |
| 1327 int get foo; | |
| 1328 } | |
| 1329 '''); | |
| 1330 } | |
| 1331 | |
| 1332 void test_false_implementsClause_add() { | |
| 1333 _assertDoesNotMatch( | |
| 1334 r''' | |
| 1335 class A {} | |
| 1336 class B {} | |
| 1337 ''', | |
| 1338 r''' | |
| 1339 class A {} | |
| 1340 class B implements A {} | |
| 1341 '''); | |
| 1342 } | |
| 1343 | |
| 1344 void test_false_implementsClause_remove() { | |
| 1345 _assertDoesNotMatch( | |
| 1346 r''' | |
| 1347 class A {} | |
| 1348 class B implements A {} | |
| 1349 ''', | |
| 1350 r''' | |
| 1351 class A {} | |
| 1352 class B {} | |
| 1353 '''); | |
| 1354 } | |
| 1355 | |
| 1356 void test_false_implementsClause_reorder() { | |
| 1357 _assertDoesNotMatch( | |
| 1358 r''' | |
| 1359 class A {} | |
| 1360 class B {} | |
| 1361 class C implements A, B {} | |
| 1362 ''', | |
| 1363 r''' | |
| 1364 class A {} | |
| 1365 class B {} | |
| 1366 class C implements B, A {} | |
| 1367 '''); | |
| 1368 } | |
| 1369 | |
| 1370 void test_false_import_hide_add() { | |
| 1371 _assertDoesNotMatch( | |
| 1372 r''' | |
| 1373 import 'dart:async' hide Future; | |
| 1374 ''', | |
| 1375 r''' | |
| 1376 import 'dart:async' hide Future, Stream; | |
| 1377 '''); | |
| 1378 } | |
| 1379 | |
| 1380 void test_false_import_hide_remove() { | |
| 1381 _assertDoesNotMatch( | |
| 1382 r''' | |
| 1383 import 'dart:async' hide Future, Stream; | |
| 1384 ''', | |
| 1385 r''' | |
| 1386 import 'dart:async' hide Future; | |
| 1387 '''); | |
| 1388 } | |
| 1389 | |
| 1390 void test_false_import_list_add() { | |
| 1391 _assertDoesNotMatch( | |
| 1392 r''' | |
| 1393 import 'dart:async'; | |
| 1394 ''', | |
| 1395 r''' | |
| 1396 import 'dart:async'; | |
| 1397 import 'dart:math'; | |
| 1398 '''); | |
| 1399 } | |
| 1400 | |
| 1401 void test_false_import_list_remove() { | |
| 1402 _assertDoesNotMatch( | |
| 1403 r''' | |
| 1404 import 'dart:async'; | |
| 1405 import 'dart:math'; | |
| 1406 ''', | |
| 1407 r''' | |
| 1408 import 'dart:async'; | |
| 1409 '''); | |
| 1410 } | |
| 1411 | |
| 1412 void test_false_import_prefix_add() { | |
| 1413 _assertDoesNotMatch( | |
| 1414 r''' | |
| 1415 import 'dart:async'; | |
| 1416 ''', | |
| 1417 r''' | |
| 1418 import 'dart:async' as async; | |
| 1419 '''); | |
| 1420 } | |
| 1421 | |
| 1422 void test_false_import_prefix_edit() { | |
| 1423 _assertDoesNotMatch( | |
| 1424 r''' | |
| 1425 import 'dart:async' as oldPrefix; | |
| 1426 ''', | |
| 1427 r''' | |
| 1428 import 'dart:async' as newPrefix; | |
| 1429 '''); | |
| 1430 } | |
| 1431 | |
| 1432 void test_false_import_prefix_remove() { | |
| 1433 _assertDoesNotMatch( | |
| 1434 r''' | |
| 1435 import 'dart:async' as async; | |
| 1436 ''', | |
| 1437 r''' | |
| 1438 import 'dart:async'; | |
| 1439 '''); | |
| 1440 } | |
| 1441 | |
| 1442 void test_false_import_show_add() { | |
| 1443 _assertDoesNotMatch( | |
| 1444 r''' | |
| 1445 import 'dart:async' show Future; | |
| 1446 ''', | |
| 1447 r''' | |
| 1448 import 'dart:async' show Future, Stream; | |
| 1449 '''); | |
| 1450 } | |
| 1451 | |
| 1452 void test_false_import_show_remove() { | |
| 1453 _assertDoesNotMatch( | |
| 1454 r''' | |
| 1455 import 'dart:async' show Future, Stream; | |
| 1456 ''', | |
| 1457 r''' | |
| 1458 import 'dart:async' show Future; | |
| 1459 '''); | |
| 1460 } | |
| 1461 | |
| 1462 void test_false_method_annotation_edit() { | |
| 1463 _assertDoesNotMatchOK( | |
| 1464 r''' | |
| 1465 const my_annotationA = const Object(); | |
| 1466 const my_annotationB = const Object(); | |
| 1467 class A { | |
| 1468 @my_annotationA | |
| 1469 void m() {} | |
| 1470 } | |
| 1471 ''', | |
| 1472 r''' | |
| 1473 const my_annotationA = const Object(); | |
| 1474 const my_annotationB = const Object(); | |
| 1475 class A { | |
| 1476 @my_annotationB | |
| 1477 void m() {} | |
| 1478 } | |
| 1479 '''); | |
| 1480 } | |
| 1481 | |
| 1482 void test_false_method_annotations_add() { | |
| 1483 _assertDoesNotMatchOK( | |
| 1484 r''' | |
| 1485 const my_annotation = const Object(); | |
| 1486 class A { | |
| 1487 void m() {} | |
| 1488 } | |
| 1489 ''', | |
| 1490 r''' | |
| 1491 const my_annotation = const Object(); | |
| 1492 class A { | |
| 1493 @my_annotation | |
| 1494 void m() {} | |
| 1495 } | |
| 1496 '''); | |
| 1497 } | |
| 1498 | |
| 1499 void test_false_method_annotations_remove() { | |
| 1500 _assertDoesNotMatchOK( | |
| 1501 r''' | |
| 1502 const my_annotation = const Object(); | |
| 1503 class A { | |
| 1504 @my_annotation | |
| 1505 void m() {} | |
| 1506 } | |
| 1507 ''', | |
| 1508 r''' | |
| 1509 const my_annotation = const Object(); | |
| 1510 class A { | |
| 1511 void m() {} | |
| 1512 } | |
| 1513 '''); | |
| 1514 } | |
| 1515 | |
| 1516 void test_false_method_async_add() { | |
| 1517 _assertDoesNotMatchOK( | |
| 1518 r''' | |
| 1519 class A { | |
| 1520 m() {} | |
| 1521 } | |
| 1522 ''', | |
| 1523 r''' | |
| 1524 class A { | |
| 1525 m() async {} | |
| 1526 } | |
| 1527 '''); | |
| 1528 } | |
| 1529 | |
| 1530 void test_false_method_async_remove() { | |
| 1531 _assertDoesNotMatchOK( | |
| 1532 r''' | |
| 1533 class A { | |
| 1534 m() async {} | |
| 1535 } | |
| 1536 ''', | |
| 1537 r''' | |
| 1538 class A { | |
| 1539 m() {} | |
| 1540 } | |
| 1541 '''); | |
| 1542 } | |
| 1543 | |
| 1544 void test_false_method_body_add() { | |
| 1545 _assertDoesNotMatchOK( | |
| 1546 r''' | |
| 1547 class A { | |
| 1548 void foo(); | |
| 1549 } | |
| 1550 ''', | |
| 1551 r''' | |
| 1552 class A { | |
| 1553 void foo() {} | |
| 1554 } | |
| 1555 '''); | |
| 1556 } | |
| 1557 | |
| 1558 void test_false_method_body_remove() { | |
| 1559 _assertDoesNotMatchOK( | |
| 1560 r''' | |
| 1561 class A { | |
| 1562 void foo() {} | |
| 1563 } | |
| 1564 ''', | |
| 1565 r''' | |
| 1566 class A { | |
| 1567 void foo(); | |
| 1568 } | |
| 1569 '''); | |
| 1570 } | |
| 1571 | |
| 1572 void test_false_method_generator_add() { | |
| 1573 _assertDoesNotMatchOK( | |
| 1574 r''' | |
| 1575 class A { | |
| 1576 m() async {} | |
| 1577 } | |
| 1578 ''', | |
| 1579 r''' | |
| 1580 class A { | |
| 1581 m() async* {} | |
| 1582 } | |
| 1583 '''); | |
| 1584 } | |
| 1585 | |
| 1586 void test_false_method_generator_remove() { | |
| 1587 _assertDoesNotMatchOK( | |
| 1588 r''' | |
| 1589 class A { | |
| 1590 m() async* {} | |
| 1591 } | |
| 1592 ''', | |
| 1593 r''' | |
| 1594 class A { | |
| 1595 m() async {} | |
| 1596 } | |
| 1597 '''); | |
| 1598 } | |
| 1599 | |
| 1600 void test_false_method_getKeyword_add() { | |
| 1601 _assertDoesNotMatchOK( | |
| 1602 r''' | |
| 1603 class A { | |
| 1604 void foo() {} | |
| 1605 } | |
| 1606 ''', | |
| 1607 r''' | |
| 1608 class A { | |
| 1609 void get foo {} | |
| 1610 } | |
| 1611 '''); | |
| 1612 } | |
| 1613 | |
| 1614 void test_false_method_getKeyword_remove() { | |
| 1615 _assertDoesNotMatchOK( | |
| 1616 r''' | |
| 1617 class A { | |
| 1618 void get foo {} | |
| 1619 } | |
| 1620 ''', | |
| 1621 r''' | |
| 1622 class A { | |
| 1623 void foo() {} | |
| 1624 } | |
| 1625 '''); | |
| 1626 } | |
| 1627 | |
| 1628 void test_false_method_list_add() { | |
| 1629 _assertDoesNotMatchOK( | |
| 1630 r''' | |
| 1631 class A { | |
| 1632 a() {} | |
| 1633 b() {} | |
| 1634 } | |
| 1635 ''', | |
| 1636 r''' | |
| 1637 class A { | |
| 1638 a() {} | |
| 1639 b() {} | |
| 1640 c() {} | |
| 1641 } | |
| 1642 '''); | |
| 1643 } | |
| 1644 | |
| 1645 void test_false_method_list_remove() { | |
| 1646 _assertDoesNotMatch( | |
| 1647 r''' | |
| 1648 class A { | |
| 1649 a() {} | |
| 1650 b() {} | |
| 1651 c() {} | |
| 1652 } | |
| 1653 ''', | |
| 1654 r''' | |
| 1655 class A { | |
| 1656 a() {} | |
| 1657 b() {} | |
| 1658 } | |
| 1659 '''); | |
| 1660 } | |
| 1661 | |
| 1662 void test_false_method_parameters_type_edit() { | |
| 1663 _assertDoesNotMatchOK( | |
| 1664 r''' | |
| 1665 class A { | |
| 1666 m(int p) { | |
| 1667 } | |
| 1668 } | |
| 1669 ''', | |
| 1670 r''' | |
| 1671 class A { | |
| 1672 m(String p) { | |
| 1673 } | |
| 1674 } | |
| 1675 '''); | |
| 1676 } | |
| 1677 | |
| 1678 void test_false_method_parameters_type_edit_insertImportPrefix() { | |
| 1679 _assertDoesNotMatchOK( | |
| 1680 r''' | |
| 1681 import 'dart:async' as a; | |
| 1682 | |
| 1683 class C { | |
| 1684 void foo(Future f) {} | |
| 1685 } | |
| 1686 | |
| 1687 class Future {} | |
| 1688 | |
| 1689 bar(C c, a.Future f) { | |
| 1690 c.foo(f); | |
| 1691 } | |
| 1692 ''', | |
| 1693 r''' | |
| 1694 import 'dart:async' as a; | |
| 1695 | |
| 1696 class C { | |
| 1697 void foo(a.Future f) {} | |
| 1698 } | |
| 1699 | |
| 1700 class Future {} | |
| 1701 | |
| 1702 bar(C c, a.Future f) { | |
| 1703 c.foo(f); | |
| 1704 } | |
| 1705 '''); | |
| 1706 } | |
| 1707 | |
| 1708 void test_false_method_returnType_edit() { | |
| 1709 _assertDoesNotMatchOK( | |
| 1710 r''' | |
| 1711 class A { | |
| 1712 int m() {} | |
| 1713 } | |
| 1714 ''', | |
| 1715 r''' | |
| 1716 class A { | |
| 1717 String m() {} | |
| 1718 } | |
| 1719 '''); | |
| 1720 } | |
| 1721 | |
| 1722 void test_false_method_setKeyword_add() { | |
| 1723 _assertDoesNotMatchOK( | |
| 1724 r''' | |
| 1725 class A { | |
| 1726 void foo(x) {} | |
| 1727 } | |
| 1728 ''', | |
| 1729 r''' | |
| 1730 class A { | |
| 1731 void set foo(x) {} | |
| 1732 } | |
| 1733 '''); | |
| 1734 } | |
| 1735 | |
| 1736 void test_false_method_setKeyword_remove() { | |
| 1737 _assertDoesNotMatchOK( | |
| 1738 r''' | |
| 1739 class A { | |
| 1740 void set foo(x) {} | |
| 1741 } | |
| 1742 ''', | |
| 1743 r''' | |
| 1744 class A { | |
| 1745 void foo(x) {} | |
| 1746 } | |
| 1747 '''); | |
| 1748 } | |
| 1749 | |
| 1750 void test_false_part_list_add() { | |
| 1751 addNamedSource('/unitA.dart', 'part of lib; class A {}'); | |
| 1752 addNamedSource('/unitB.dart', 'part of lib; class B {}'); | |
| 1753 _assertDoesNotMatch( | |
| 1754 r''' | |
| 1755 library lib; | |
| 1756 part 'unitA.dart'; | |
| 1757 ''', | |
| 1758 r''' | |
| 1759 library lib; | |
| 1760 part 'unitA.dart'; | |
| 1761 part 'unitB.dart'; | |
| 1762 '''); | |
| 1763 } | |
| 1764 | |
| 1765 void test_false_part_list_remove() { | |
| 1766 addNamedSource('/unitA.dart', 'part of lib; class A {}'); | |
| 1767 addNamedSource('/unitB.dart', 'part of lib; class B {}'); | |
| 1768 _assertDoesNotMatch( | |
| 1769 r''' | |
| 1770 library lib; | |
| 1771 part 'unitA.dart'; | |
| 1772 part 'unitB.dart'; | |
| 1773 ''', | |
| 1774 r''' | |
| 1775 library lib; | |
| 1776 part 'unitA.dart'; | |
| 1777 '''); | |
| 1778 } | |
| 1779 | |
| 1780 void test_false_SimpleFormalParameter_named_differentName() { | |
| 1781 _assertDoesNotMatch( | |
| 1782 r''' | |
| 1783 main({int oldName}) { | |
| 1784 } | |
| 1785 ''', | |
| 1786 r''' | |
| 1787 main({int newName}) { | |
| 1788 } | |
| 1789 '''); | |
| 1790 } | |
| 1791 | |
| 1792 void test_false_SimpleFormalParameter_namedDefault_addValue() { | |
| 1793 _assertDoesNotMatch( | |
| 1794 r''' | |
| 1795 main({int p}) { | |
| 1796 } | |
| 1797 ''', | |
| 1798 r''' | |
| 1799 main({int p: 2}) { | |
| 1800 } | |
| 1801 '''); | |
| 1802 } | |
| 1803 | |
| 1804 void test_false_SimpleFormalParameter_namedDefault_differentValue() { | |
| 1805 _assertDoesNotMatch( | |
| 1806 r''' | |
| 1807 main({int p: 1}) { | |
| 1808 } | |
| 1809 ''', | |
| 1810 r''' | |
| 1811 main({int p: 2}) { | |
| 1812 } | |
| 1813 '''); | |
| 1814 } | |
| 1815 | |
| 1816 void test_false_SimpleFormalParameter_namedDefault_removeValue() { | |
| 1817 _assertDoesNotMatch( | |
| 1818 r''' | |
| 1819 main({int p: 1}) { | |
| 1820 } | |
| 1821 ''', | |
| 1822 r''' | |
| 1823 main({int p}) { | |
| 1824 } | |
| 1825 '''); | |
| 1826 } | |
| 1827 | |
| 1828 void test_false_SimpleFormalParameter_optionalDefault_addValue() { | |
| 1829 _assertDoesNotMatch( | |
| 1830 r''' | |
| 1831 main([int p]) { | |
| 1832 } | |
| 1833 ''', | |
| 1834 r''' | |
| 1835 main([int p = 2]) { | |
| 1836 } | |
| 1837 '''); | |
| 1838 } | |
| 1839 | |
| 1840 void test_false_SimpleFormalParameter_optionalDefault_differentValue() { | |
| 1841 _assertDoesNotMatch( | |
| 1842 r''' | |
| 1843 main([int p = 1]) { | |
| 1844 } | |
| 1845 ''', | |
| 1846 r''' | |
| 1847 main([int p = 2]) { | |
| 1848 } | |
| 1849 '''); | |
| 1850 } | |
| 1851 | |
| 1852 void test_false_SimpleFormalParameter_optionalDefault_removeValue() { | |
| 1853 _assertDoesNotMatch( | |
| 1854 r''' | |
| 1855 main([int p = 1]) { | |
| 1856 } | |
| 1857 ''', | |
| 1858 r''' | |
| 1859 main([int p]) { | |
| 1860 } | |
| 1861 '''); | |
| 1862 } | |
| 1863 | |
| 1864 void test_false_topLevelAccessor_list_add() { | |
| 1865 _assertDoesNotMatch( | |
| 1866 r''' | |
| 1867 get a => 1; | |
| 1868 get b => 2; | |
| 1869 ''', | |
| 1870 r''' | |
| 1871 get a => 1; | |
| 1872 get b => 2; | |
| 1873 get c => 3; | |
| 1874 '''); | |
| 1875 } | |
| 1876 | |
| 1877 void test_false_topLevelAccessor_list_remove() { | |
| 1878 _assertDoesNotMatch( | |
| 1879 r''' | |
| 1880 get a => 1; | |
| 1881 get b => 2; | |
| 1882 get c => 3; | |
| 1883 ''', | |
| 1884 r''' | |
| 1885 get a => 1; | |
| 1886 get b => 2; | |
| 1887 '''); | |
| 1888 } | |
| 1889 | |
| 1890 void test_false_topLevelAccessor_wasGetter() { | |
| 1891 _assertDoesNotMatch( | |
| 1892 r''' | |
| 1893 get a => 1; | |
| 1894 ''', | |
| 1895 r''' | |
| 1896 set a(x) {} | |
| 1897 '''); | |
| 1898 } | |
| 1899 | |
| 1900 void test_false_topLevelAccessor_wasSetter() { | |
| 1901 _assertDoesNotMatch( | |
| 1902 r''' | |
| 1903 set a(x) {} | |
| 1904 ''', | |
| 1905 r''' | |
| 1906 get a => 1; | |
| 1907 '''); | |
| 1908 } | |
| 1909 | |
| 1910 void test_false_topLevelFunction_list_add() { | |
| 1911 _assertDoesNotMatch( | |
| 1912 r''' | |
| 1913 a() {} | |
| 1914 b() {} | |
| 1915 ''', | |
| 1916 r''' | |
| 1917 a() {} | |
| 1918 b() {} | |
| 1919 c() {} | |
| 1920 '''); | |
| 1921 } | |
| 1922 | |
| 1923 void test_false_topLevelFunction_list_remove() { | |
| 1924 _assertDoesNotMatch( | |
| 1925 r''' | |
| 1926 a() {} | |
| 1927 b() {} | |
| 1928 c() {} | |
| 1929 ''', | |
| 1930 r''' | |
| 1931 a() {} | |
| 1932 b() {} | |
| 1933 '''); | |
| 1934 } | |
| 1935 | |
| 1936 void test_false_topLevelFunction_parameters_list_add() { | |
| 1937 _assertDoesNotMatch( | |
| 1938 r''' | |
| 1939 main(int a, int b) { | |
| 1940 } | |
| 1941 ''', | |
| 1942 r''' | |
| 1943 main(int a, int b, int c) { | |
| 1944 } | |
| 1945 '''); | |
| 1946 } | |
| 1947 | |
| 1948 void test_false_topLevelFunction_parameters_list_remove() { | |
| 1949 _assertDoesNotMatch( | |
| 1950 r''' | |
| 1951 main(int a, int b, int c) { | |
| 1952 } | |
| 1953 ''', | |
| 1954 r''' | |
| 1955 main(int a, int b) { | |
| 1956 } | |
| 1957 '''); | |
| 1958 } | |
| 1959 | |
| 1960 void test_false_topLevelFunction_parameters_type_edit() { | |
| 1961 _assertDoesNotMatch( | |
| 1962 r''' | |
| 1963 main(int a, int b, int c) { | |
| 1964 } | |
| 1965 ''', | |
| 1966 r''' | |
| 1967 main(int a, String b, int c) { | |
| 1968 } | |
| 1969 '''); | |
| 1970 } | |
| 1971 | |
| 1972 void test_false_topLevelFunction_returnType_edit() { | |
| 1973 _assertDoesNotMatch( | |
| 1974 r''' | |
| 1975 int a() {} | |
| 1976 ''', | |
| 1977 r''' | |
| 1978 String a() {} | |
| 1979 '''); | |
| 1980 } | |
| 1981 | |
| 1982 void test_false_topLevelVariable_list_add() { | |
| 1983 _assertDoesNotMatch( | |
| 1984 r''' | |
| 1985 const int A = 1; | |
| 1986 const int C = 3; | |
| 1987 ''', | |
| 1988 r''' | |
| 1989 const int A = 1; | |
| 1990 const int B = 2; | |
| 1991 const int C = 3; | |
| 1992 '''); | |
| 1993 } | |
| 1994 | |
| 1995 void test_false_topLevelVariable_list_remove() { | |
| 1996 _assertDoesNotMatch( | |
| 1997 r''' | |
| 1998 const int A = 1; | |
| 1999 const int B = 2; | |
| 2000 const int C = 3; | |
| 2001 ''', | |
| 2002 r''' | |
| 2003 const int A = 1; | |
| 2004 const int C = 3; | |
| 2005 '''); | |
| 2006 } | |
| 2007 | |
| 2008 void test_false_topLevelVariable_modifier_isConst() { | |
| 2009 _assertDoesNotMatch( | |
| 2010 r''' | |
| 2011 final int A = 1; | |
| 2012 ''', | |
| 2013 r''' | |
| 2014 const int A = 1; | |
| 2015 '''); | |
| 2016 } | |
| 2017 | |
| 2018 void test_false_topLevelVariable_modifier_isFinal() { | |
| 2019 _assertDoesNotMatch( | |
| 2020 r''' | |
| 2021 int A = 1; | |
| 2022 ''', | |
| 2023 r''' | |
| 2024 final int A = 1; | |
| 2025 '''); | |
| 2026 } | |
| 2027 | |
| 2028 void test_false_topLevelVariable_modifier_wasConst() { | |
| 2029 _assertDoesNotMatch( | |
| 2030 r''' | |
| 2031 const int A = 1; | |
| 2032 ''', | |
| 2033 r''' | |
| 2034 final int A = 1; | |
| 2035 '''); | |
| 2036 } | |
| 2037 | |
| 2038 void test_false_topLevelVariable_modifier_wasFinal() { | |
| 2039 _assertDoesNotMatch( | |
| 2040 r''' | |
| 2041 final int A = 1; | |
| 2042 ''', | |
| 2043 r''' | |
| 2044 int A = 1; | |
| 2045 '''); | |
| 2046 } | |
| 2047 | |
| 2048 void test_false_topLevelVariable_synthetic_wasGetter() { | |
| 2049 _assertDoesNotMatch( | |
| 2050 r''' | |
| 2051 int get A => 1; | |
| 2052 ''', | |
| 2053 r''' | |
| 2054 final int A = 1; | |
| 2055 '''); | |
| 2056 } | |
| 2057 | |
| 2058 void test_false_topLevelVariable_type_different() { | |
| 2059 _assertDoesNotMatch( | |
| 2060 r''' | |
| 2061 int A; | |
| 2062 ''', | |
| 2063 r''' | |
| 2064 String A; | |
| 2065 '''); | |
| 2066 } | |
| 2067 | |
| 2068 void test_false_topLevelVariable_type_differentArgs() { | |
| 2069 _assertDoesNotMatch( | |
| 2070 r''' | |
| 2071 List<int> A; | |
| 2072 ''', | |
| 2073 r''' | |
| 2074 List<String> A; | |
| 2075 '''); | |
| 2076 } | |
| 2077 | |
| 2078 void test_false_type_noTypeArguments_hadTypeArguments() { | |
| 2079 _assertDoesNotMatch( | |
| 2080 r''' | |
| 2081 class A<T> {} | |
| 2082 A<int> main() { | |
| 2083 } | |
| 2084 ''', | |
| 2085 r''' | |
| 2086 class A<T> {} | |
| 2087 A main() { | |
| 2088 } | |
| 2089 '''); | |
| 2090 } | |
| 2091 | |
| 2092 void test_false_withClause_add() { | |
| 2093 _assertDoesNotMatch( | |
| 2094 r''' | |
| 2095 class A {} | |
| 2096 class B {} | |
| 2097 ''', | |
| 2098 r''' | |
| 2099 class A {} | |
| 2100 class B extends Object with A {} | |
| 2101 '''); | |
| 2102 } | |
| 2103 | |
| 2104 void test_false_withClause_remove() { | |
| 2105 _assertDoesNotMatch( | |
| 2106 r''' | |
| 2107 class A {} | |
| 2108 class B extends Object with A {} | |
| 2109 ''', | |
| 2110 r''' | |
| 2111 class A {} | |
| 2112 class B {} | |
| 2113 '''); | |
| 2114 } | |
| 2115 | |
| 2116 void test_false_withClause_reorder() { | |
| 2117 _assertDoesNotMatch( | |
| 2118 r''' | |
| 2119 class A {} | |
| 2120 class B {} | |
| 2121 class C extends Object with A, B {} | |
| 2122 ''', | |
| 2123 r''' | |
| 2124 class A {} | |
| 2125 class B {} | |
| 2126 class C extends Object with B, A {} | |
| 2127 '''); | |
| 2128 } | |
| 2129 | |
| 2130 void test_true_class_annotations_same() { | |
| 2131 _assertMatches( | |
| 2132 r''' | |
| 2133 const my_annotation = const Object(); | |
| 2134 @my_annotation | |
| 2135 class A { | |
| 2136 } | |
| 2137 ''', | |
| 2138 r''' | |
| 2139 const my_annotation = const Object(); | |
| 2140 @my_annotation | |
| 2141 class A { | |
| 2142 } | |
| 2143 '''); | |
| 2144 } | |
| 2145 | |
| 2146 void test_true_class_list_reorder() { | |
| 2147 _assertMatches( | |
| 2148 r''' | |
| 2149 class A {} | |
| 2150 class B {} | |
| 2151 class C {} | |
| 2152 ''', | |
| 2153 r''' | |
| 2154 class C {} | |
| 2155 class A {} | |
| 2156 class B {} | |
| 2157 '''); | |
| 2158 } | |
| 2159 | |
| 2160 void test_true_class_list_same() { | |
| 2161 _assertMatches( | |
| 2162 r''' | |
| 2163 class A {} | |
| 2164 class B {} | |
| 2165 class C {} | |
| 2166 ''', | |
| 2167 r''' | |
| 2168 class A {} | |
| 2169 class B {} | |
| 2170 class C {} | |
| 2171 '''); | |
| 2172 } | |
| 2173 | |
| 2174 void test_true_class_typeParameters_same() { | |
| 2175 _assertMatches( | |
| 2176 r''' | |
| 2177 class A<T> {} | |
| 2178 ''', | |
| 2179 r''' | |
| 2180 class A<T> {} | |
| 2181 '''); | |
| 2182 } | |
| 2183 | |
| 2184 void test_true_classMemberAccessor_getterSetter() { | |
| 2185 _assertMatches( | |
| 2186 r''' | |
| 2187 class A { | |
| 2188 int _test; | |
| 2189 get test => _test; | |
| 2190 set test(v) { | |
| 2191 _test = v; | |
| 2192 } | |
| 2193 } | |
| 2194 ''', | |
| 2195 r''' | |
| 2196 class A { | |
| 2197 int _test; | |
| 2198 get test => _test; | |
| 2199 set test(v) { | |
| 2200 _test = v; | |
| 2201 } | |
| 2202 } | |
| 2203 '''); | |
| 2204 } | |
| 2205 | |
| 2206 void test_true_classMemberAccessor_list_reorder() { | |
| 2207 _assertMatches( | |
| 2208 r''' | |
| 2209 class A { | |
| 2210 get a => 1; | |
| 2211 get b => 2; | |
| 2212 get c => 3; | |
| 2213 } | |
| 2214 ''', | |
| 2215 r''' | |
| 2216 class A { | |
| 2217 get c => 3; | |
| 2218 get a => 1; | |
| 2219 get b => 2; | |
| 2220 } | |
| 2221 '''); | |
| 2222 } | |
| 2223 | |
| 2224 void test_true_classMemberAccessor_list_same() { | |
| 2225 _assertMatches( | |
| 2226 r''' | |
| 2227 class A { | |
| 2228 get a => 1; | |
| 2229 get b => 2; | |
| 2230 get c => 3; | |
| 2231 } | |
| 2232 ''', | |
| 2233 r''' | |
| 2234 class A { | |
| 2235 get a => 1; | |
| 2236 get b => 2; | |
| 2237 get c => 3; | |
| 2238 } | |
| 2239 '''); | |
| 2240 } | |
| 2241 | |
| 2242 void test_true_classTypeAlias_list_reorder() { | |
| 2243 _assertMatches( | |
| 2244 r''' | |
| 2245 class M {} | |
| 2246 class A = Object with M; | |
| 2247 class B = Object with M; | |
| 2248 class C = Object with M; | |
| 2249 ''', | |
| 2250 r''' | |
| 2251 class M {} | |
| 2252 class C = Object with M; | |
| 2253 class A = Object with M; | |
| 2254 class B = Object with M; | |
| 2255 '''); | |
| 2256 } | |
| 2257 | |
| 2258 void test_true_classTypeAlias_list_same() { | |
| 2259 _assertMatches( | |
| 2260 r''' | |
| 2261 class M {} | |
| 2262 class A = Object with M; | |
| 2263 class B = Object with M; | |
| 2264 class C = Object with M; | |
| 2265 ''', | |
| 2266 r''' | |
| 2267 class M {} | |
| 2268 class A = Object with M; | |
| 2269 class B = Object with M; | |
| 2270 class C = Object with M; | |
| 2271 '''); | |
| 2272 } | |
| 2273 | |
| 2274 void test_true_classTypeAlias_typeParameters_same() { | |
| 2275 _assertMatches( | |
| 2276 r''' | |
| 2277 class M<T> {} | |
| 2278 class A<T> {} | |
| 2279 class B<T> = A<T> with M<T>; | |
| 2280 ''', | |
| 2281 r''' | |
| 2282 class M<T> {} | |
| 2283 class A<T> {} | |
| 2284 class B<T> = A<T> with M<T>; | |
| 2285 '''); | |
| 2286 } | |
| 2287 | |
| 2288 void test_true_constructor_body_add() { | |
| 2289 _assertMatches( | |
| 2290 r''' | |
| 2291 class A { | |
| 2292 A(int p); | |
| 2293 } | |
| 2294 ''', | |
| 2295 r''' | |
| 2296 class A { | |
| 2297 A(int p) {} | |
| 2298 } | |
| 2299 '''); | |
| 2300 } | |
| 2301 | |
| 2302 void test_true_constructor_body_remove() { | |
| 2303 _assertMatches( | |
| 2304 r''' | |
| 2305 class A { | |
| 2306 A(int p) {} | |
| 2307 } | |
| 2308 ''', | |
| 2309 r''' | |
| 2310 class A { | |
| 2311 A(int p); | |
| 2312 } | |
| 2313 '''); | |
| 2314 } | |
| 2315 | |
| 2316 void test_true_constructor_named_same() { | |
| 2317 _assertMatches( | |
| 2318 r''' | |
| 2319 class A { | |
| 2320 A.name(int p); | |
| 2321 } | |
| 2322 ''', | |
| 2323 r''' | |
| 2324 class A { | |
| 2325 A.name(int p); | |
| 2326 } | |
| 2327 '''); | |
| 2328 } | |
| 2329 | |
| 2330 void test_true_constructor_unnamed_add_noParameters() { | |
| 2331 _assertMatches( | |
| 2332 r''' | |
| 2333 class A { | |
| 2334 } | |
| 2335 ''', | |
| 2336 r''' | |
| 2337 class A { | |
| 2338 A() {} | |
| 2339 } | |
| 2340 '''); | |
| 2341 } | |
| 2342 | |
| 2343 void test_true_constructor_unnamed_remove_noParameters() { | |
| 2344 _assertMatches( | |
| 2345 r''' | |
| 2346 class A { | |
| 2347 A() {} | |
| 2348 } | |
| 2349 ''', | |
| 2350 r''' | |
| 2351 class A { | |
| 2352 } | |
| 2353 '''); | |
| 2354 } | |
| 2355 | |
| 2356 void test_true_constructor_unnamed_same() { | |
| 2357 _assertMatches( | |
| 2358 r''' | |
| 2359 class A { | |
| 2360 A(int p); | |
| 2361 } | |
| 2362 ''', | |
| 2363 r''' | |
| 2364 class A { | |
| 2365 A(int p); | |
| 2366 } | |
| 2367 '''); | |
| 2368 } | |
| 2369 | |
| 2370 void test_true_defaultFieldFormalParameterElement() { | |
| 2371 _assertMatches( | |
| 2372 r''' | |
| 2373 class A { | |
| 2374 int field; | |
| 2375 A([this.field = 0]); | |
| 2376 } | |
| 2377 ''', | |
| 2378 r''' | |
| 2379 class A { | |
| 2380 int field; | |
| 2381 A([this.field = 0]); | |
| 2382 } | |
| 2383 '''); | |
| 2384 } | |
| 2385 | |
| 2386 void test_true_enum_constants_reorder() { | |
| 2387 _assertMatches( | |
| 2388 r''' | |
| 2389 enum E {A, B, C} | |
| 2390 ''', | |
| 2391 r''' | |
| 2392 enum E {C, A, B} | |
| 2393 '''); | |
| 2394 } | |
| 2395 | |
| 2396 void test_true_enum_list_reorder() { | |
| 2397 _assertMatches( | |
| 2398 r''' | |
| 2399 enum A {A1, A2, A3} | |
| 2400 enum B {B1, B2, B3} | |
| 2401 enum C {C1, C2, C3} | |
| 2402 ''', | |
| 2403 r''' | |
| 2404 enum C {C1, C2, C3} | |
| 2405 enum A {A1, A2, A3} | |
| 2406 enum B {B1, B2, B3} | |
| 2407 '''); | |
| 2408 } | |
| 2409 | |
| 2410 void test_true_enum_list_same() { | |
| 2411 _assertMatches( | |
| 2412 r''' | |
| 2413 enum A {A1, A2, A3} | |
| 2414 enum B {B1, B2, B3} | |
| 2415 enum C {C1, C2, C3} | |
| 2416 ''', | |
| 2417 r''' | |
| 2418 enum A {A1, A2, A3} | |
| 2419 enum B {B1, B2, B3} | |
| 2420 enum C {C1, C2, C3} | |
| 2421 '''); | |
| 2422 } | |
| 2423 | |
| 2424 void test_true_executable_same_hasLabel() { | |
| 2425 _assertMatches( | |
| 2426 r''' | |
| 2427 main() { | |
| 2428 label: return 42; | |
| 2429 } | |
| 2430 ''', | |
| 2431 r''' | |
| 2432 main() { | |
| 2433 label: return 42; | |
| 2434 } | |
| 2435 '''); | |
| 2436 } | |
| 2437 | |
| 2438 void test_true_executable_same_hasLocalVariable() { | |
| 2439 _assertMatches( | |
| 2440 r''' | |
| 2441 main() { | |
| 2442 int a = 42; | |
| 2443 } | |
| 2444 ''', | |
| 2445 r''' | |
| 2446 main() { | |
| 2447 int a = 42; | |
| 2448 } | |
| 2449 '''); | |
| 2450 } | |
| 2451 | |
| 2452 void test_true_export_hide_reorder() { | |
| 2453 _assertMatches( | |
| 2454 r''' | |
| 2455 export 'dart:async' hide Future, Stream; | |
| 2456 ''', | |
| 2457 r''' | |
| 2458 export 'dart:async' hide Stream, Future; | |
| 2459 '''); | |
| 2460 } | |
| 2461 | |
| 2462 void test_true_export_list_reorder() { | |
| 2463 _assertMatches( | |
| 2464 r''' | |
| 2465 export 'dart:async'; | |
| 2466 export 'dart:math'; | |
| 2467 ''', | |
| 2468 r''' | |
| 2469 export 'dart:math'; | |
| 2470 export 'dart:async'; | |
| 2471 '''); | |
| 2472 } | |
| 2473 | |
| 2474 void test_true_export_list_same() { | |
| 2475 _assertMatches( | |
| 2476 r''' | |
| 2477 export 'dart:async'; | |
| 2478 export 'dart:math'; | |
| 2479 ''', | |
| 2480 r''' | |
| 2481 export 'dart:async'; | |
| 2482 export 'dart:math'; | |
| 2483 '''); | |
| 2484 } | |
| 2485 | |
| 2486 void test_true_export_show_reorder() { | |
| 2487 _assertMatches( | |
| 2488 r''' | |
| 2489 export 'dart:async' show Future, Stream; | |
| 2490 ''', | |
| 2491 r''' | |
| 2492 export 'dart:async' show Stream, Future; | |
| 2493 '''); | |
| 2494 } | |
| 2495 | |
| 2496 void test_true_extendsClause_same() { | |
| 2497 _assertMatches( | |
| 2498 r''' | |
| 2499 class A {} | |
| 2500 class B extends A {} | |
| 2501 ''', | |
| 2502 r''' | |
| 2503 class A {} | |
| 2504 class B extends A {} | |
| 2505 '''); | |
| 2506 } | |
| 2507 | |
| 2508 void test_true_field_list_reorder() { | |
| 2509 _assertMatches( | |
| 2510 r''' | |
| 2511 class T { | |
| 2512 int A = 1; | |
| 2513 int B = 2; | |
| 2514 int C = 3; | |
| 2515 } | |
| 2516 ''', | |
| 2517 r''' | |
| 2518 class T { | |
| 2519 int C = 3; | |
| 2520 int A = 1; | |
| 2521 int B = 2; | |
| 2522 } | |
| 2523 '''); | |
| 2524 } | |
| 2525 | |
| 2526 void test_true_field_list_same() { | |
| 2527 _assertMatches( | |
| 2528 r''' | |
| 2529 class T { | |
| 2530 int A = 1; | |
| 2531 int B = 2; | |
| 2532 int C = 3; | |
| 2533 } | |
| 2534 ''', | |
| 2535 r''' | |
| 2536 class T { | |
| 2537 int A = 1; | |
| 2538 int B = 2; | |
| 2539 int C = 3; | |
| 2540 } | |
| 2541 '''); | |
| 2542 } | |
| 2543 | |
| 2544 void test_true_fieldFormalParameter() { | |
| 2545 _assertMatches( | |
| 2546 r''' | |
| 2547 class A { | |
| 2548 int field; | |
| 2549 A(this.field); | |
| 2550 } | |
| 2551 ''', | |
| 2552 r''' | |
| 2553 class A { | |
| 2554 int field; | |
| 2555 A(this.field); | |
| 2556 } | |
| 2557 '''); | |
| 2558 } | |
| 2559 | |
| 2560 void test_true_fieldFormalParameter_function() { | |
| 2561 _assertMatches( | |
| 2562 r''' | |
| 2563 class A { | |
| 2564 final field; | |
| 2565 A(this.field(int a, String b)); | |
| 2566 } | |
| 2567 ''', | |
| 2568 r''' | |
| 2569 class A { | |
| 2570 final field; | |
| 2571 A(this.field(int a, String b)); | |
| 2572 } | |
| 2573 '''); | |
| 2574 } | |
| 2575 | |
| 2576 void test_true_functionTypeAlias_list_reorder() { | |
| 2577 _assertMatches( | |
| 2578 r''' | |
| 2579 typedef A(int pa); | |
| 2580 typedef B(String pb); | |
| 2581 typedef C(pc); | |
| 2582 ''', | |
| 2583 r''' | |
| 2584 typedef C(pc); | |
| 2585 typedef A(int pa); | |
| 2586 typedef B(String pb); | |
| 2587 '''); | |
| 2588 } | |
| 2589 | |
| 2590 void test_true_functionTypeAlias_list_same() { | |
| 2591 _assertMatches( | |
| 2592 r''' | |
| 2593 typedef String A(int pa); | |
| 2594 typedef int B(String pb); | |
| 2595 typedef C(pc); | |
| 2596 ''', | |
| 2597 r''' | |
| 2598 typedef String A(int pa); | |
| 2599 typedef int B(String pb); | |
| 2600 typedef C(pc); | |
| 2601 '''); | |
| 2602 } | |
| 2603 | |
| 2604 void test_true_functionTypeAlias_typeParameters_list_same() { | |
| 2605 _assertMatches( | |
| 2606 r''' | |
| 2607 typedef F<A, B, C>(); | |
| 2608 ''', | |
| 2609 r''' | |
| 2610 typedef F<A, B, C>(); | |
| 2611 '''); | |
| 2612 } | |
| 2613 | |
| 2614 void test_true_FunctionTypedFormalParameter() { | |
| 2615 _assertMatches( | |
| 2616 r''' | |
| 2617 main(int callback(int a, String b)) { | |
| 2618 } | |
| 2619 ''', | |
| 2620 r''' | |
| 2621 main(int callback(int a, String b)) { | |
| 2622 } | |
| 2623 '''); | |
| 2624 } | |
| 2625 | |
| 2626 void test_true_implementsClause_same() { | |
| 2627 _assertMatches( | |
| 2628 r''' | |
| 2629 class A {} | |
| 2630 class B implements A {} | |
| 2631 ''', | |
| 2632 r''' | |
| 2633 class A {} | |
| 2634 class B implements A {} | |
| 2635 '''); | |
| 2636 } | |
| 2637 | |
| 2638 void test_true_import_hide_reorder() { | |
| 2639 _assertMatches( | |
| 2640 r''' | |
| 2641 import 'dart:async' hide Future, Stream; | |
| 2642 ''', | |
| 2643 r''' | |
| 2644 import 'dart:async' hide Stream, Future; | |
| 2645 '''); | |
| 2646 } | |
| 2647 | |
| 2648 void test_true_import_list_reorder() { | |
| 2649 _assertMatches( | |
| 2650 r''' | |
| 2651 import 'dart:async'; | |
| 2652 import 'dart:math'; | |
| 2653 ''', | |
| 2654 r''' | |
| 2655 import 'dart:math'; | |
| 2656 import 'dart:async'; | |
| 2657 '''); | |
| 2658 } | |
| 2659 | |
| 2660 void test_true_import_list_same() { | |
| 2661 _assertMatches( | |
| 2662 r''' | |
| 2663 import 'dart:async'; | |
| 2664 import 'dart:math'; | |
| 2665 ''', | |
| 2666 r''' | |
| 2667 import 'dart:async'; | |
| 2668 import 'dart:math'; | |
| 2669 '''); | |
| 2670 } | |
| 2671 | |
| 2672 void test_true_import_prefix() { | |
| 2673 _assertMatches( | |
| 2674 r''' | |
| 2675 import 'dart:async' as async; | |
| 2676 ''', | |
| 2677 r''' | |
| 2678 import 'dart:async' as async; | |
| 2679 '''); | |
| 2680 } | |
| 2681 | |
| 2682 void test_true_import_show_reorder() { | |
| 2683 _assertMatches( | |
| 2684 r''' | |
| 2685 import 'dart:async' show Future, Stream; | |
| 2686 ''', | |
| 2687 r''' | |
| 2688 import 'dart:async' show Stream, Future; | |
| 2689 '''); | |
| 2690 } | |
| 2691 | |
| 2692 void test_true_method_annotation_accessor_same() { | |
| 2693 _assertMatches( | |
| 2694 r''' | |
| 2695 const my_annotation = const Object(); | |
| 2696 class A { | |
| 2697 @my_annotation | |
| 2698 void m() {} | |
| 2699 } | |
| 2700 ''', | |
| 2701 r''' | |
| 2702 const my_annotation = const Object(); | |
| 2703 class A { | |
| 2704 @my_annotation | |
| 2705 void m() {} | |
| 2706 } | |
| 2707 '''); | |
| 2708 } | |
| 2709 | |
| 2710 void test_true_method_annotation_constructor_same() { | |
| 2711 _assertMatches( | |
| 2712 r''' | |
| 2713 class MyAnnotation { | |
| 2714 const MyAnnotation(); | |
| 2715 } | |
| 2716 class A { | |
| 2717 @MyAnnotation() | |
| 2718 void m() {} | |
| 2719 } | |
| 2720 ''', | |
| 2721 r''' | |
| 2722 class MyAnnotation { | |
| 2723 const MyAnnotation(); | |
| 2724 } | |
| 2725 class A { | |
| 2726 @MyAnnotation() | |
| 2727 void m() {} | |
| 2728 } | |
| 2729 '''); | |
| 2730 } | |
| 2731 | |
| 2732 void test_true_method_async() { | |
| 2733 _assertMatches( | |
| 2734 r''' | |
| 2735 class A { | |
| 2736 m() async {} | |
| 2737 } | |
| 2738 ''', | |
| 2739 r''' | |
| 2740 class A { | |
| 2741 m() async {} | |
| 2742 } | |
| 2743 '''); | |
| 2744 } | |
| 2745 | |
| 2746 void test_true_method_list_reorder() { | |
| 2747 _assertMatches( | |
| 2748 r''' | |
| 2749 class A { | |
| 2750 a() {} | |
| 2751 b() {} | |
| 2752 c() {} | |
| 2753 } | |
| 2754 ''', | |
| 2755 r''' | |
| 2756 class A { | |
| 2757 c() {} | |
| 2758 a() {} | |
| 2759 b() {} | |
| 2760 } | |
| 2761 '''); | |
| 2762 } | |
| 2763 | |
| 2764 void test_true_method_list_same() { | |
| 2765 _assertMatches( | |
| 2766 r''' | |
| 2767 class A { | |
| 2768 a() {} | |
| 2769 b() {} | |
| 2770 c() {} | |
| 2771 } | |
| 2772 ''', | |
| 2773 r''' | |
| 2774 class A { | |
| 2775 a() {} | |
| 2776 b() {} | |
| 2777 c() {} | |
| 2778 } | |
| 2779 '''); | |
| 2780 } | |
| 2781 | |
| 2782 void test_true_method_operator_minus() { | |
| 2783 _assertMatches( | |
| 2784 r''' | |
| 2785 class A { | |
| 2786 operator -(other) {} | |
| 2787 } | |
| 2788 ''', | |
| 2789 r''' | |
| 2790 class A { | |
| 2791 operator -(other) {} | |
| 2792 } | |
| 2793 '''); | |
| 2794 } | |
| 2795 | |
| 2796 void test_true_method_operator_minusUnary() { | |
| 2797 _assertMatches( | |
| 2798 r''' | |
| 2799 class A { | |
| 2800 operator -() {} | |
| 2801 } | |
| 2802 ''', | |
| 2803 r''' | |
| 2804 class A { | |
| 2805 operator -() {} | |
| 2806 } | |
| 2807 '''); | |
| 2808 } | |
| 2809 | |
| 2810 void test_true_method_operator_plus() { | |
| 2811 _assertMatches( | |
| 2812 r''' | |
| 2813 class A { | |
| 2814 operator +(other) {} | |
| 2815 } | |
| 2816 ''', | |
| 2817 r''' | |
| 2818 class A { | |
| 2819 operator +(other) {} | |
| 2820 } | |
| 2821 '''); | |
| 2822 } | |
| 2823 | |
| 2824 void test_true_method_parameters_type_functionType() { | |
| 2825 _assertMatches( | |
| 2826 r''' | |
| 2827 typedef F(); | |
| 2828 class A { | |
| 2829 m(F p) {} | |
| 2830 } | |
| 2831 ''', | |
| 2832 r''' | |
| 2833 typedef F(); | |
| 2834 class A { | |
| 2835 m(F p) {} | |
| 2836 } | |
| 2837 '''); | |
| 2838 } | |
| 2839 | |
| 2840 void test_true_method_parameters_type_sameImportPrefix() { | |
| 2841 _assertMatches( | |
| 2842 r''' | |
| 2843 import 'dart:async' as a; | |
| 2844 | |
| 2845 bar(a.Future f) { | |
| 2846 print(f); | |
| 2847 } | |
| 2848 ''', | |
| 2849 r''' | |
| 2850 import 'dart:async' as a; | |
| 2851 | |
| 2852 bar(a.Future ff) { | |
| 2853 print(ff); | |
| 2854 } | |
| 2855 '''); | |
| 2856 } | |
| 2857 | |
| 2858 void test_true_part_list_reorder() { | |
| 2859 addNamedSource('/unitA.dart', 'part of lib; class A {}'); | |
| 2860 addNamedSource('/unitB.dart', 'part of lib; class B {}'); | |
| 2861 _assertMatches( | |
| 2862 r''' | |
| 2863 library lib; | |
| 2864 part 'unitA.dart'; | |
| 2865 part 'unitB.dart'; | |
| 2866 ''', | |
| 2867 r''' | |
| 2868 library lib; | |
| 2869 part 'unitB.dart'; | |
| 2870 part 'unitA.dart'; | |
| 2871 '''); | |
| 2872 } | |
| 2873 | |
| 2874 void test_true_part_list_same() { | |
| 2875 addNamedSource('/unitA.dart', 'part of lib; class A {}'); | |
| 2876 addNamedSource('/unitB.dart', 'part of lib; class B {}'); | |
| 2877 _assertMatches( | |
| 2878 r''' | |
| 2879 library lib; | |
| 2880 part 'unitA.dart'; | |
| 2881 part 'unitB.dart'; | |
| 2882 ''', | |
| 2883 r''' | |
| 2884 library lib; | |
| 2885 part 'unitA.dart'; | |
| 2886 part 'unitB.dart'; | |
| 2887 '''); | |
| 2888 } | |
| 2889 | |
| 2890 void test_true_SimpleFormalParameter_optional_differentName() { | |
| 2891 _assertMatches( | |
| 2892 r''' | |
| 2893 main([int oldName]) { | |
| 2894 } | |
| 2895 ''', | |
| 2896 r''' | |
| 2897 main([int newName]) { | |
| 2898 } | |
| 2899 '''); | |
| 2900 } | |
| 2901 | |
| 2902 void test_true_SimpleFormalParameter_optionalDefault_differentName() { | |
| 2903 _assertMatches( | |
| 2904 r''' | |
| 2905 main([int oldName = 1]) { | |
| 2906 } | |
| 2907 ''', | |
| 2908 r''' | |
| 2909 main([int newName = 1]) { | |
| 2910 } | |
| 2911 '''); | |
| 2912 } | |
| 2913 | |
| 2914 void test_true_SimpleFormalParameter_required_differentName() { | |
| 2915 _assertMatches( | |
| 2916 r''' | |
| 2917 main(int oldName) { | |
| 2918 } | |
| 2919 ''', | |
| 2920 r''' | |
| 2921 main(int newName) { | |
| 2922 } | |
| 2923 '''); | |
| 2924 } | |
| 2925 | |
| 2926 void test_true_topLevelAccessor_list_reorder() { | |
| 2927 _assertMatches( | |
| 2928 r''' | |
| 2929 set a(x) {} | |
| 2930 set b(x) {} | |
| 2931 set c(x) {} | |
| 2932 ''', | |
| 2933 r''' | |
| 2934 set c(x) {} | |
| 2935 set a(x) {} | |
| 2936 set b(x) {} | |
| 2937 '''); | |
| 2938 } | |
| 2939 | |
| 2940 void test_true_topLevelAccessor_list_same() { | |
| 2941 _assertMatches( | |
| 2942 r''' | |
| 2943 get a => 1; | |
| 2944 get b => 2; | |
| 2945 get c => 3; | |
| 2946 ''', | |
| 2947 r''' | |
| 2948 get a => 1; | |
| 2949 get b => 2; | |
| 2950 get c => 3; | |
| 2951 '''); | |
| 2952 } | |
| 2953 | |
| 2954 void test_true_topLevelFunction_list_reorder() { | |
| 2955 _assertMatches( | |
| 2956 r''' | |
| 2957 a() {} | |
| 2958 b() {} | |
| 2959 c() {} | |
| 2960 ''', | |
| 2961 r''' | |
| 2962 c() {} | |
| 2963 a() {} | |
| 2964 b() {} | |
| 2965 '''); | |
| 2966 } | |
| 2967 | |
| 2968 void test_true_topLevelFunction_list_same() { | |
| 2969 _assertMatches( | |
| 2970 r''' | |
| 2971 a() {} | |
| 2972 b() {} | |
| 2973 c() {} | |
| 2974 ''', | |
| 2975 r''' | |
| 2976 a() {} | |
| 2977 b() {} | |
| 2978 c() {} | |
| 2979 '''); | |
| 2980 } | |
| 2981 | |
| 2982 void test_true_topLevelVariable_list_reorder() { | |
| 2983 _assertMatches( | |
| 2984 r''' | |
| 2985 const int A = 1; | |
| 2986 const int B = 2; | |
| 2987 const int C = 3; | |
| 2988 ''', | |
| 2989 r''' | |
| 2990 const int C = 3; | |
| 2991 const int A = 1; | |
| 2992 const int B = 2; | |
| 2993 '''); | |
| 2994 } | |
| 2995 | |
| 2996 void test_true_topLevelVariable_list_same() { | |
| 2997 _assertMatches( | |
| 2998 r''' | |
| 2999 const int A = 1; | |
| 3000 const int B = 2; | |
| 3001 const int C = 3; | |
| 3002 ''', | |
| 3003 r''' | |
| 3004 const int A = 1; | |
| 3005 const int B = 2; | |
| 3006 const int C = 3; | |
| 3007 '''); | |
| 3008 } | |
| 3009 | |
| 3010 void test_true_topLevelVariable_type_sameArgs() { | |
| 3011 _assertMatches( | |
| 3012 r''' | |
| 3013 Map<int, String> A; | |
| 3014 ''', | |
| 3015 r''' | |
| 3016 Map<int, String> A; | |
| 3017 '''); | |
| 3018 } | |
| 3019 | |
| 3020 void test_true_type_dynamic() { | |
| 3021 _assertMatches( | |
| 3022 r''' | |
| 3023 dynamic a() {} | |
| 3024 ''', | |
| 3025 r''' | |
| 3026 dynamic a() {} | |
| 3027 '''); | |
| 3028 } | |
| 3029 | |
| 3030 void test_true_type_hasImportPrefix() { | |
| 3031 _assertMatches( | |
| 3032 r''' | |
| 3033 import 'dart:async' as async; | |
| 3034 async.Future F; | |
| 3035 ''', | |
| 3036 r''' | |
| 3037 import 'dart:async' as async; | |
| 3038 async.Future F; | |
| 3039 '''); | |
| 3040 } | |
| 3041 | |
| 3042 void test_true_type_noTypeArguments_implyAllDynamic() { | |
| 3043 _assertMatches( | |
| 3044 r''' | |
| 3045 class A<T> {} | |
| 3046 A main() { | |
| 3047 } | |
| 3048 ''', | |
| 3049 r''' | |
| 3050 class A<T> {} | |
| 3051 A main() { | |
| 3052 } | |
| 3053 '''); | |
| 3054 } | |
| 3055 | |
| 3056 void test_true_type_void() { | |
| 3057 _assertMatches( | |
| 3058 r''' | |
| 3059 void a() {} | |
| 3060 ''', | |
| 3061 r''' | |
| 3062 void a() {} | |
| 3063 '''); | |
| 3064 } | |
| 3065 | |
| 3066 void test_true_withClause_same() { | |
| 3067 _assertMatches( | |
| 3068 r''' | |
| 3069 class A {} | |
| 3070 class B extends Object with A {} | |
| 3071 ''', | |
| 3072 r''' | |
| 3073 class A {} | |
| 3074 class B extends Object with A {} | |
| 3075 '''); | |
| 3076 } | |
| 3077 | |
| 3078 void _assertDoesNotMatch(String oldContent, String newContent) { | |
| 3079 _assertMatchKind(DeclarationMatchKind.MISMATCH, oldContent, newContent); | |
| 3080 } | |
| 3081 | |
| 3082 void _assertDoesNotMatchOK(String oldContent, String newContent) { | |
| 3083 _assertMatchKind(DeclarationMatchKind.MISMATCH_OK, oldContent, newContent); | |
| 3084 } | |
| 3085 | |
| 3086 void _assertMatches(String oldContent, String newContent) { | |
| 3087 _assertMatchKind(DeclarationMatchKind.MATCH, oldContent, newContent); | |
| 3088 } | |
| 3089 | |
| 3090 void _assertMatchKind( | |
| 3091 DeclarationMatchKind expectMatch, String oldContent, String newContent) { | |
| 3092 Source source = addSource(oldContent); | |
| 3093 LibraryElement library = resolve2(source); | |
| 3094 CompilationUnit oldUnit = resolveCompilationUnit(source, library); | |
| 3095 // parse | |
| 3096 CompilationUnit newUnit = IncrementalResolverTest._parseUnit(newContent); | |
| 3097 // build elements | |
| 3098 { | |
| 3099 ElementHolder holder = new ElementHolder(); | |
| 3100 ElementBuilder builder = new ElementBuilder(holder, oldUnit.element); | |
| 3101 newUnit.accept(builder); | |
| 3102 } | |
| 3103 // match | |
| 3104 DeclarationMatcher matcher = new DeclarationMatcher(); | |
| 3105 DeclarationMatchKind matchKind = matcher.matches(newUnit, oldUnit.element); | |
| 3106 expect(matchKind, same(expectMatch)); | |
| 3107 } | |
| 3108 } | |
| 3109 | |
| 3110 @reflectiveTest | |
| 3111 class IncrementalResolverTest extends ResolverTestCase { | 139 class IncrementalResolverTest extends ResolverTestCase { |
| 3112 Source source; | 140 Source source; |
| 3113 String code; | 141 String code; |
| 3114 LibraryElement library; | 142 LibraryElement library; |
| 3115 CompilationUnit unit; | 143 CompilationUnit unit; |
| 3116 | 144 |
| 3117 @override | 145 @override |
| 3118 void reset() { | 146 void reset() { |
| 3119 analysisContext2 = AnalysisContextFactory.contextWithCore(); | 147 analysisContext2 = AnalysisContextFactory.contextWithCore(); |
| 3120 } | 148 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3159 _resolveUnit(r''' | 187 _resolveUnit(r''' |
| 3160 class A { | 188 class A { |
| 3161 int f; | 189 int f; |
| 3162 A(int a, int b) { | 190 A(int a, int b) { |
| 3163 f = a + b; | 191 f = a + b; |
| 3164 } | 192 } |
| 3165 }'''); | 193 }'''); |
| 3166 _resolve(_editString('+', '*'), _isFunctionBody); | 194 _resolve(_editString('+', '*'), _isFunctionBody); |
| 3167 } | 195 } |
| 3168 | 196 |
| 3169 void test_constructor_fieldInitializer_add() { | |
| 3170 _resolveUnit(r''' | |
| 3171 class A { | |
| 3172 int f; | |
| 3173 A(int a, int b); | |
| 3174 }'''); | |
| 3175 _resolve(_editString(');', ') : f = a + b;'), _isClassMember); | |
| 3176 } | |
| 3177 | |
| 3178 void test_constructor_fieldInitializer_edit() { | |
| 3179 _resolveUnit(r''' | |
| 3180 class A { | |
| 3181 int f; | |
| 3182 A(int a, int b) : f = a + b { | |
| 3183 int a = 42; | |
| 3184 } | |
| 3185 }'''); | |
| 3186 _resolve(_editString('+', '*'), _isExpression); | |
| 3187 } | |
| 3188 | |
| 3189 void test_constructor_label_add() { | 197 void test_constructor_label_add() { |
| 3190 _resolveUnit(r''' | 198 _resolveUnit(r''' |
| 3191 class A { | 199 class A { |
| 3192 A() { | 200 A() { |
| 3193 return 42; | 201 return 42; |
| 3194 } | 202 } |
| 3195 } | 203 } |
| 3196 '''); | 204 '''); |
| 3197 _resolve(_editString('return', 'label: return'), _isBlock); | 205 _resolve(_editString('return', 'label: return'), _isBlock); |
| 3198 } | 206 } |
| 3199 | 207 |
| 3200 void test_constructor_localVariable_add() { | 208 void test_constructor_localVariable_add() { |
| 3201 _resolveUnit(r''' | 209 _resolveUnit(r''' |
| 3202 class A { | 210 class A { |
| 3203 A() { | 211 A() { |
| 3204 42; | 212 42; |
| 3205 } | 213 } |
| 3206 } | 214 } |
| 3207 '''); | 215 '''); |
| 3208 _resolve(_editString('42;', 'var res = 42;'), _isBlock); | 216 _resolve(_editString('42;', 'var res = 42;'), _isBlock); |
| 3209 } | 217 } |
| 3210 | 218 |
| 3211 void test_constructor_superConstructorInvocation() { | |
| 3212 _resolveUnit(r''' | |
| 3213 class A { | |
| 3214 A(int p); | |
| 3215 } | |
| 3216 class B extends A { | |
| 3217 B(int a, int b) : super(a + b); | |
| 3218 } | |
| 3219 '''); | |
| 3220 _resolve(_editString('+', '*'), _isExpression); | |
| 3221 } | |
| 3222 | |
| 3223 void test_function_localFunction_add() { | 219 void test_function_localFunction_add() { |
| 3224 _resolveUnit(r''' | 220 _resolveUnit(r''' |
| 3225 int main() { | 221 int main() { |
| 3226 return 0; | 222 return 0; |
| 3227 } | 223 } |
| 3228 callIt(f) {} | 224 callIt(f) {} |
| 3229 '''); | 225 '''); |
| 3230 _resolve(_editString('return 0;', 'callIt((p) {});'), _isBlock); | 226 _resolve(_editString('return 0;', 'callIt((p) {});'), _isBlock); |
| 3231 } | 227 } |
| 3232 | 228 |
| 3233 void test_functionBody_body() { | 229 void test_functionBody_body() { |
| 3234 _resolveUnit(r''' | 230 _resolveUnit(r''' |
| 3235 main(int a, int b) { | 231 main(int a, int b) { |
| 3236 return a + b; | 232 return a + b; |
| 3237 }'''); | 233 }'''); |
| 3238 _resolve(_editString('+', '*'), _isFunctionBody); | 234 _resolve(_editString('+', '*'), _isFunctionBody); |
| 3239 } | 235 } |
| 3240 | 236 |
| 3241 void test_functionBody_expression() { | |
| 3242 _resolveUnit(r''' | |
| 3243 main(int a, int b) => a + b; | |
| 3244 '''); | |
| 3245 _resolve(_editString('+', '*'), _isExpression); | |
| 3246 } | |
| 3247 | |
| 3248 void test_functionBody_statement() { | 237 void test_functionBody_statement() { |
| 3249 _resolveUnit(r''' | 238 _resolveUnit(r''' |
| 3250 main(int a, int b) { | 239 main(int a, int b) { |
| 3251 return a + b; | 240 return a + b; |
| 3252 }'''); | 241 }'''); |
| 3253 _resolve(_editString('+', '*'), _isStatement); | 242 _resolve(_editString('+', '*'), _isStatement); |
| 3254 } | 243 } |
| 3255 | 244 |
| 3256 void test_method_body() { | 245 void test_method_body() { |
| 3257 _resolveUnit(r''' | 246 _resolveUnit(r''' |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3297 _resolve( | 286 _resolve( |
| 3298 _editString( | 287 _editString( |
| 3299 ' return a + b;', | 288 ' return a + b;', |
| 3300 r''' | 289 r''' |
| 3301 int res = a + b; | 290 int res = a + b; |
| 3302 return res; | 291 return res; |
| 3303 '''), | 292 '''), |
| 3304 _isBlock); | 293 _isBlock); |
| 3305 } | 294 } |
| 3306 | 295 |
| 3307 void test_method_parameter_rename() { | |
| 3308 _resolveUnit(r''' | |
| 3309 class A { | |
| 3310 int m(int a, int b, int c) { | |
| 3311 return a + b + c; | |
| 3312 } | |
| 3313 } | |
| 3314 '''); | |
| 3315 _resolve( | |
| 3316 _editString( | |
| 3317 r'''(int a, int b, int c) { | |
| 3318 return a + b + c;''', | |
| 3319 r'''(int a, int second, int c) { | |
| 3320 return a + second + c;'''), | |
| 3321 _isDeclaration); | |
| 3322 } | |
| 3323 | |
| 3324 void test_superInvocation() { | 296 void test_superInvocation() { |
| 3325 _resolveUnit(r''' | 297 _resolveUnit(r''' |
| 3326 class A { | 298 class A { |
| 3327 foo(p) {} | 299 foo(p) {} |
| 3328 } | 300 } |
| 3329 class B extends A { | 301 class B extends A { |
| 3330 bar() { | 302 bar() { |
| 3331 super.foo(1 + 2); | 303 super.foo(1 + 2); |
| 3332 } | 304 } |
| 3333 }'''); | 305 }'''); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3379 void test_topLevelFunction_localVariable_remove() { | 351 void test_topLevelFunction_localVariable_remove() { |
| 3380 _resolveUnit(r''' | 352 _resolveUnit(r''' |
| 3381 int main(int a, int b) { | 353 int main(int a, int b) { |
| 3382 int res = a * b; | 354 int res = a * b; |
| 3383 return a + b; | 355 return a + b; |
| 3384 } | 356 } |
| 3385 '''); | 357 '''); |
| 3386 _resolve(_editString('int res = a * b;', ''), _isBlock); | 358 _resolve(_editString('int res = a * b;', ''), _isBlock); |
| 3387 } | 359 } |
| 3388 | 360 |
| 3389 void test_topLevelFunction_parameter_inFunctionTyped_rename() { | |
| 3390 _resolveUnit(r''' | |
| 3391 test(f(int a, int b)) { | |
| 3392 } | |
| 3393 '''); | |
| 3394 _resolve(_editString('test(f(int a', 'test(f2(int a2'), _isDeclaration); | |
| 3395 } | |
| 3396 | |
| 3397 void test_topLevelFunction_parameter_rename() { | |
| 3398 _resolveUnit(r''' | |
| 3399 int main(int a, int b) { | |
| 3400 return a + b; | |
| 3401 } | |
| 3402 '''); | |
| 3403 _resolve( | |
| 3404 _editString( | |
| 3405 r'''(int a, int b) { | |
| 3406 return a + b;''', | |
| 3407 r'''(int first, int b) { | |
| 3408 return first + b;'''), | |
| 3409 _isDeclaration); | |
| 3410 } | |
| 3411 | |
| 3412 void test_topLevelVariable_initializer() { | |
| 3413 _resolveUnit(r''' | |
| 3414 int C = 1 + 2; | |
| 3415 '''); | |
| 3416 _resolve(_editString('+', '*'), _isExpression); | |
| 3417 } | |
| 3418 | |
| 3419 void test_updateElementOffset() { | 361 void test_updateElementOffset() { |
| 3420 _resolveUnit(r''' | 362 _resolveUnit(r''' |
| 3421 class A { | 363 class A { |
| 3422 int am(String ap) { | 364 int am(String ap) { |
| 3423 int av = 1; | 365 int av = 1; |
| 3424 return av; | 366 return av; |
| 3425 } | 367 } |
| 3426 } | 368 } |
| 3427 main(int a, int b) { | 369 main(int a, int b) { |
| 3428 return a + b; | 370 return a + b; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3480 newNode.endToken.setNext(oldEndTokenNext); | 422 newNode.endToken.setNext(oldEndTokenNext); |
| 3481 } | 423 } |
| 3482 // do incremental resolution | 424 // do incremental resolution |
| 3483 int updateOffset = edit.offset; | 425 int updateOffset = edit.offset; |
| 3484 int updateEndOld = updateOffset + edit.length; | 426 int updateEndOld = updateOffset + edit.length; |
| 3485 int updateOldNew = updateOffset + edit.replacement.length; | 427 int updateOldNew = updateOffset + edit.replacement.length; |
| 3486 IncrementalResolver resolver; | 428 IncrementalResolver resolver; |
| 3487 LibrarySpecificUnit lsu = new LibrarySpecificUnit(source, source); | 429 LibrarySpecificUnit lsu = new LibrarySpecificUnit(source, source); |
| 3488 resolver = new IncrementalResolver(cache, cache.get(source), cache.get(lsu), | 430 resolver = new IncrementalResolver(cache, cache.get(source), cache.get(lsu), |
| 3489 unit.element, updateOffset, updateEndOld, updateOldNew); | 431 unit.element, updateOffset, updateEndOld, updateOldNew); |
| 3490 bool success = resolver.resolve(newNode); | 432 |
| 433 BlockFunctionBody body = newNode.getAncestor((n) => n is BlockFunctionBody); |
| 434 expect(body, isNotNull); |
| 435 |
| 436 bool success = resolver.resolve(body); |
| 3491 expect(success, isTrue); | 437 expect(success, isTrue); |
| 3492 _checkCacheEntries(cache); | 438 _checkCacheEntries(cache); |
| 3493 | 439 |
| 3494 List<AnalysisError> newErrors = analysisContext.computeErrors(source); | 440 List<AnalysisError> newErrors = analysisContext.computeErrors(source); |
| 3495 // resolve "newCode" from scratch | 441 // resolve "newCode" from scratch |
| 3496 CompilationUnit fullNewUnit; | 442 CompilationUnit fullNewUnit; |
| 3497 { | 443 { |
| 3498 source = addSource(newCode); | 444 source = addSource(newCode); |
| 3499 _runTasks(); | 445 _runTasks(); |
| 3500 LibraryElement library = resolve2(source); | 446 LibraryElement library = resolve2(source); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 3529 | 475 |
| 3530 static AstNode _findNodeAt( | 476 static AstNode _findNodeAt( |
| 3531 CompilationUnit oldUnit, int offset, Predicate<AstNode> predicate) { | 477 CompilationUnit oldUnit, int offset, Predicate<AstNode> predicate) { |
| 3532 NodeLocator locator = new NodeLocator(offset); | 478 NodeLocator locator = new NodeLocator(offset); |
| 3533 AstNode node = locator.searchWithin(oldUnit); | 479 AstNode node = locator.searchWithin(oldUnit); |
| 3534 return node.getAncestor(predicate); | 480 return node.getAncestor(predicate); |
| 3535 } | 481 } |
| 3536 | 482 |
| 3537 static bool _isBlock(AstNode node) => node is Block; | 483 static bool _isBlock(AstNode node) => node is Block; |
| 3538 | 484 |
| 3539 static bool _isClassMember(AstNode node) => node is ClassMember; | |
| 3540 | |
| 3541 static bool _isDeclaration(AstNode node) => node is Declaration; | |
| 3542 | |
| 3543 static bool _isExpression(AstNode node) => node is Expression; | |
| 3544 | |
| 3545 static bool _isFunctionBody(AstNode node) => node is FunctionBody; | 485 static bool _isFunctionBody(AstNode node) => node is FunctionBody; |
| 3546 | 486 |
| 3547 static bool _isStatement(AstNode node) => node is Statement; | 487 static bool _isStatement(AstNode node) => node is Statement; |
| 3548 | 488 |
| 3549 static CompilationUnit _parseUnit(String code) { | 489 static CompilationUnit _parseUnit(String code) { |
| 3550 var errorListener = new BooleanErrorListener(); | 490 var errorListener = new BooleanErrorListener(); |
| 3551 var reader = new CharSequenceReader(code); | 491 var reader = new CharSequenceReader(code); |
| 3552 var scanner = new Scanner(null, reader, errorListener); | 492 var scanner = new Scanner(null, reader, errorListener); |
| 3553 var token = scanner.tokenize(); | 493 var token = scanner.tokenize(); |
| 3554 var parser = new Parser(null, errorListener); | 494 var parser = new Parser(null, errorListener); |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4170 r''' | 1110 r''' |
| 4171 class A { | 1111 class A { |
| 4172 A(int b) { | 1112 A(int b) { |
| 4173 print(b); | 1113 print(b); |
| 4174 } | 1114 } |
| 4175 } | 1115 } |
| 4176 ''', | 1116 ''', |
| 4177 expectedSuccess: false); | 1117 expectedSuccess: false); |
| 4178 } | 1118 } |
| 4179 | 1119 |
| 1120 void test_false_wholeConstructor_addInitializer() { |
| 1121 _resolveUnit(r''' |
| 1122 class A { |
| 1123 int field; |
| 1124 A(); |
| 1125 } |
| 1126 '''); |
| 1127 _updateAndValidate( |
| 1128 r''' |
| 1129 class A { |
| 1130 int field; |
| 1131 A() : field = 5; |
| 1132 } |
| 1133 ''', |
| 1134 expectedSuccess: false); |
| 1135 } |
| 1136 |
| 1137 void test_false_wholeFunction() { |
| 1138 _resolveUnit(r''' |
| 1139 foo() {} |
| 1140 main(int a) { |
| 1141 print(a); |
| 1142 } |
| 1143 '''); |
| 1144 _updateAndValidate( |
| 1145 r''' |
| 1146 foo() {} |
| 1147 main(int b) { |
| 1148 print(b); |
| 1149 } |
| 1150 ''', |
| 1151 expectedSuccess: false); |
| 1152 } |
| 1153 |
| 1154 void test_false_wholeMethod() { |
| 1155 _resolveUnit(r''' |
| 1156 class A { |
| 1157 main(int a) { |
| 1158 print(a); |
| 1159 } |
| 1160 } |
| 1161 '''); |
| 1162 _updateAndValidate( |
| 1163 r''' |
| 1164 class A { |
| 1165 main(int b) { |
| 1166 print(b); |
| 1167 } |
| 1168 } |
| 1169 ''', |
| 1170 expectedSuccess: false); |
| 1171 } |
| 1172 |
| 4180 void test_fieldClassField_propagatedType() { | 1173 void test_fieldClassField_propagatedType() { |
| 4181 _resolveUnit(r''' | 1174 _resolveUnit(r''' |
| 4182 class A { | 1175 class A { |
| 4183 static const A b = const B(); | 1176 static const A b = const B(); |
| 4184 const A(); | 1177 const A(); |
| 4185 } | 1178 } |
| 4186 | 1179 |
| 4187 class B extends A { | 1180 class B extends A { |
| 4188 const B(); | 1181 const B(); |
| 4189 } | 1182 } |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4407 print(2); | 1400 print(2); |
| 4408 } | 1401 } |
| 4409 foo() { | 1402 foo() { |
| 4410 // TODO | 1403 // TODO |
| 4411 } | 1404 } |
| 4412 '''); | 1405 '''); |
| 4413 List<AnalysisError> newErrors = analysisContext.computeErrors(source); | 1406 List<AnalysisError> newErrors = analysisContext.computeErrors(source); |
| 4414 _assertEqualErrors(newErrors, oldErrors); | 1407 _assertEqualErrors(newErrors, oldErrors); |
| 4415 } | 1408 } |
| 4416 | 1409 |
| 4417 void test_true_wholeConstructor_addInitializer() { | |
| 4418 _resolveUnit(r''' | |
| 4419 class A { | |
| 4420 int field; | |
| 4421 A(); | |
| 4422 } | |
| 4423 '''); | |
| 4424 _updateAndValidate(r''' | |
| 4425 class A { | |
| 4426 int field; | |
| 4427 A() : field = 5; | |
| 4428 } | |
| 4429 '''); | |
| 4430 } | |
| 4431 | |
| 4432 void test_true_wholeFunction() { | |
| 4433 _resolveUnit(r''' | |
| 4434 foo() {} | |
| 4435 main(int a) { | |
| 4436 print(a); | |
| 4437 } | |
| 4438 '''); | |
| 4439 _updateAndValidate(r''' | |
| 4440 foo() {} | |
| 4441 main(int b) { | |
| 4442 print(b); | |
| 4443 } | |
| 4444 '''); | |
| 4445 } | |
| 4446 | |
| 4447 void test_true_wholeFunction_firstTokenInUnit() { | |
| 4448 _resolveUnit(r''' | |
| 4449 main(int a) { | |
| 4450 print(a); | |
| 4451 } | |
| 4452 '''); | |
| 4453 _updateAndValidate(r''' | |
| 4454 main(int b) { | |
| 4455 print(b); | |
| 4456 } | |
| 4457 '''); | |
| 4458 } | |
| 4459 | |
| 4460 void test_true_wholeMethod() { | |
| 4461 _resolveUnit(r''' | |
| 4462 class A { | |
| 4463 main(int a) { | |
| 4464 print(a); | |
| 4465 } | |
| 4466 } | |
| 4467 '''); | |
| 4468 _updateAndValidate(r''' | |
| 4469 class A { | |
| 4470 main(int b) { | |
| 4471 print(b); | |
| 4472 } | |
| 4473 } | |
| 4474 '''); | |
| 4475 } | |
| 4476 | |
| 4477 void test_unusedHint_add_wasUsedOnlyInPart() { | 1410 void test_unusedHint_add_wasUsedOnlyInPart() { |
| 4478 Source partSource = addNamedSource( | 1411 Source partSource = addNamedSource( |
| 4479 '/my_unit.dart', | 1412 '/my_unit.dart', |
| 4480 r''' | 1413 r''' |
| 4481 part of lib; | 1414 part of lib; |
| 4482 | 1415 |
| 4483 f(A a) { | 1416 f(A a) { |
| 4484 a._foo(); | 1417 a._foo(); |
| 4485 } | 1418 } |
| 4486 '''); | 1419 '''); |
| (...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5315 void logException(Object exception, [Object stackTrace]) { | 2248 void logException(Object exception, [Object stackTrace]) { |
| 5316 lastException = exception; | 2249 lastException = exception; |
| 5317 lastStackTrace = stackTrace; | 2250 lastStackTrace = stackTrace; |
| 5318 } | 2251 } |
| 5319 | 2252 |
| 5320 @override | 2253 @override |
| 5321 logging.LoggingTimer startTimer() { | 2254 logging.LoggingTimer startTimer() { |
| 5322 return new logging.LoggingTimer(this); | 2255 return new logging.LoggingTimer(this); |
| 5323 } | 2256 } |
| 5324 } | 2257 } |
| OLD | NEW |