| 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 test.services.refactoring.sort_members; | 5 library test.services.refactoring.sort_members; |
| 6 | 6 |
| 7 import 'package:analysis_server/plugin/protocol/protocol.dart'; | 7 import 'package:analysis_server/plugin/protocol/protocol.dart'; |
| 8 import 'package:analysis_server/src/services/correction/sort_members.dart'; | 8 import 'package:analysis_server/src/services/correction/sort_members.dart'; |
| 9 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 9 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 export 'bbb/bbb.dart'; | 364 export 'bbb/bbb.dart'; |
| 365 | 365 |
| 366 part 'aaa/aaa.dart'; | 366 part 'aaa/aaa.dart'; |
| 367 part 'bbb/bbb.dart'; | 367 part 'bbb/bbb.dart'; |
| 368 | 368 |
| 369 main() { | 369 main() { |
| 370 } | 370 } |
| 371 '''); | 371 '''); |
| 372 } | 372 } |
| 373 | 373 |
| 374 void test_directives_comments() { | 374 void test_directives_docComment_hasLibrary_lines() { |
| 375 _parseTestUnit(r''' | 375 _parseTestUnit(r''' |
| 376 // header | 376 /// Library documentation comment A. |
| 377 library lib; | 377 /// Library documentation comment B. |
| 378 library foo.bar; |
| 378 | 379 |
| 379 import 'c.dart';// c | 380 /// bbb1 |
| 380 import 'a.dart';// aa | 381 /// bbb2 |
| 381 import 'b.dart';// bbb | 382 /// bbb3 |
| 382 | 383 import 'b.dart'; |
| 383 /** doc */ | 384 /// aaa1 |
| 384 main() { | 385 /// aaa2 |
| 385 } | 386 import 'a.dart'; |
| 386 '''); | 387 '''); |
| 387 // validate change | 388 // validate change |
| 388 _assertSort(r''' | 389 _assertSort(r''' |
| 389 // header | 390 /// Library documentation comment A. |
| 390 library lib; | 391 /// Library documentation comment B. |
| 392 library foo.bar; |
| 391 | 393 |
| 394 /// aaa1 |
| 395 /// aaa2 |
| 392 import 'a.dart'; | 396 import 'a.dart'; |
| 397 /// bbb1 |
| 398 /// bbb2 |
| 399 /// bbb3 |
| 393 import 'b.dart'; | 400 import 'b.dart'; |
| 394 import 'c.dart'; | |
| 395 // c | |
| 396 // aa | |
| 397 // bbb | |
| 398 | |
| 399 /** doc */ | |
| 400 main() { | |
| 401 } | |
| 402 '''); | 401 '''); |
| 403 } | 402 } |
| 404 | 403 |
| 404 void test_directives_docComment_hasLibrary_stars() { |
| 405 _parseTestUnit(r''' |
| 406 /** |
| 407 * Library documentation comment A. |
| 408 * Library documentation comment B. |
| 409 */ |
| 410 library foo.bar; |
| 411 |
| 412 /** |
| 413 * bbb |
| 414 */ |
| 415 import 'b.dart'; |
| 416 /** |
| 417 * aaa |
| 418 * aaa |
| 419 */ |
| 420 import 'a.dart'; |
| 421 '''); |
| 422 // validate change |
| 423 _assertSort(r''' |
| 424 /** |
| 425 * Library documentation comment A. |
| 426 * Library documentation comment B. |
| 427 */ |
| 428 library foo.bar; |
| 429 |
| 430 /** |
| 431 * aaa |
| 432 * aaa |
| 433 */ |
| 434 import 'a.dart'; |
| 435 /** |
| 436 * bbb |
| 437 */ |
| 438 import 'b.dart'; |
| 439 '''); |
| 440 } |
| 441 |
| 442 void test_directives_docComment_noLibrary_lines() { |
| 443 _parseTestUnit(r''' |
| 444 /// Library documentation comment A |
| 445 /// Library documentation comment B |
| 446 import 'b.dart'; |
| 447 /// aaa1 |
| 448 /// aaa2 |
| 449 import 'a.dart'; |
| 450 '''); |
| 451 // validate change |
| 452 _assertSort(r''' |
| 453 /// aaa1 |
| 454 /// aaa2 |
| 455 /// Library documentation comment A |
| 456 /// Library documentation comment B |
| 457 import 'a.dart'; |
| 458 import 'b.dart'; |
| 459 '''); |
| 460 } |
| 461 |
| 462 void test_directives_docComment_noLibrary_stars() { |
| 463 _parseTestUnit(r''' |
| 464 /** |
| 465 * Library documentation comment A. |
| 466 * Library documentation comment B. |
| 467 */ |
| 468 import 'b.dart'; |
| 469 /** |
| 470 * aaa |
| 471 * aaa |
| 472 */ |
| 473 import 'a.dart'; |
| 474 '''); |
| 475 // validate change |
| 476 _assertSort(r''' |
| 477 /** |
| 478 * aaa |
| 479 * aaa |
| 480 */ |
| 481 /** |
| 482 * Library documentation comment A. |
| 483 * Library documentation comment B. |
| 484 */ |
| 485 import 'a.dart'; |
| 486 import 'b.dart'; |
| 487 '''); |
| 488 } |
| 489 |
| 405 void test_directives_imports_packageAndPath() { | 490 void test_directives_imports_packageAndPath() { |
| 406 _parseTestUnit(r''' | 491 _parseTestUnit(r''' |
| 407 library lib; | 492 library lib; |
| 408 | 493 |
| 409 import 'package:product.ui.api.bbb/manager1.dart'; | 494 import 'package:product.ui.api.bbb/manager1.dart'; |
| 410 import 'package:product.ui.api/entity2.dart'; | 495 import 'package:product.ui.api/entity2.dart'; |
| 411 import 'package:product.ui/entity.dart'; | 496 import 'package:product.ui/entity.dart'; |
| 412 import 'package:product.ui.api.aaa/manager2.dart'; | 497 import 'package:product.ui.api.aaa/manager2.dart'; |
| 413 import 'package:product.ui.api/entity1.dart'; | 498 import 'package:product.ui.api/entity1.dart'; |
| 414 import 'package:product2.client/entity.dart'; | 499 import 'package:product2.client/entity.dart'; |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 List<SourceEdit> edits = sorter.sort(); | 799 List<SourceEdit> edits = sorter.sort(); |
| 715 String result = SourceEdit.applySequence(testCode, edits); | 800 String result = SourceEdit.applySequence(testCode, edits); |
| 716 expect(result, expectedCode); | 801 expect(result, expectedCode); |
| 717 } | 802 } |
| 718 | 803 |
| 719 void _parseTestUnit(String code) { | 804 void _parseTestUnit(String code) { |
| 720 addTestSource(code); | 805 addTestSource(code); |
| 721 testUnit = context.parseCompilationUnit(testSource); | 806 testUnit = context.parseCompilationUnit(testSource); |
| 722 } | 807 } |
| 723 } | 808 } |
| OLD | NEW |