| 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.correction.fix; | 5 library test.services.correction.fix; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/plugin/edit/fix/fix_core.dart'; | 9 import 'package:analysis_server/plugin/edit/fix/fix_core.dart'; |
| 10 import 'package:analysis_server/plugin/edit/fix/fix_dart.dart'; | 10 import 'package:analysis_server/plugin/edit/fix/fix_dart.dart'; |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 DartFixKind.CHANGE_TO_STATIC_ACCESS, | 590 DartFixKind.CHANGE_TO_STATIC_ACCESS, |
| 591 ''' | 591 ''' |
| 592 import 'libB.dart'; | 592 import 'libB.dart'; |
| 593 import 'libA.dart'; | 593 import 'libA.dart'; |
| 594 main(B b) { | 594 main(B b) { |
| 595 A.foo; | 595 A.foo; |
| 596 } | 596 } |
| 597 '''); | 597 '''); |
| 598 } | 598 } |
| 599 | 599 |
| 600 test_changeTypeAnnotation_BAD_multipleVariables() async { |
| 601 resolveTestUnit(''' |
| 602 main() { |
| 603 String a, b = 42; |
| 604 } |
| 605 '''); |
| 606 await assertNoFix(DartFixKind.CHANGE_TYPE_ANNOTATION); |
| 607 } |
| 608 |
| 609 test_changeTypeAnnotation_BAD_notVariableDeclaration() async { |
| 610 resolveTestUnit(''' |
| 611 main() { |
| 612 String p; |
| 613 p = 42; |
| 614 } |
| 615 '''); |
| 616 await assertNoFix(DartFixKind.CHANGE_TYPE_ANNOTATION); |
| 617 } |
| 618 |
| 619 test_changeTypeAnnotation_OK_generic() async { |
| 620 resolveTestUnit(''' |
| 621 main() { |
| 622 String v = <int>[]; |
| 623 } |
| 624 '''); |
| 625 await assertHasFix( |
| 626 DartFixKind.CHANGE_TYPE_ANNOTATION, |
| 627 ''' |
| 628 main() { |
| 629 List<int> v = <int>[]; |
| 630 } |
| 631 '''); |
| 632 } |
| 633 |
| 634 test_changeTypeAnnotation_OK_simple() async { |
| 635 resolveTestUnit(''' |
| 636 main() { |
| 637 String v = 'abc'.length; |
| 638 } |
| 639 '''); |
| 640 await assertHasFix( |
| 641 DartFixKind.CHANGE_TYPE_ANNOTATION, |
| 642 ''' |
| 643 main() { |
| 644 int v = 'abc'.length; |
| 645 } |
| 646 '''); |
| 647 } |
| 648 |
| 600 test_createClass() async { | 649 test_createClass() async { |
| 601 resolveTestUnit(''' | 650 resolveTestUnit(''' |
| 602 main() { | 651 main() { |
| 603 Test v = null; | 652 Test v = null; |
| 604 } | 653 } |
| 605 '''); | 654 '''); |
| 606 await assertHasFix( | 655 await assertHasFix( |
| 607 DartFixKind.CREATE_CLASS, | 656 DartFixKind.CREATE_CLASS, |
| 608 ''' | 657 ''' |
| 609 main() { | 658 main() { |
| (...skipping 4113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4723 int offset = resultCode.indexOf(search); | 4772 int offset = resultCode.indexOf(search); |
| 4724 positions.add(new Position(testFile, offset)); | 4773 positions.add(new Position(testFile, offset)); |
| 4725 } | 4774 } |
| 4726 return positions; | 4775 return positions; |
| 4727 } | 4776 } |
| 4728 | 4777 |
| 4729 void _performAnalysis() { | 4778 void _performAnalysis() { |
| 4730 while (context.performAnalysisTask().hasMoreWork); | 4779 while (context.performAnalysisTask().hasMoreWork); |
| 4731 } | 4780 } |
| 4732 } | 4781 } |
| OLD | NEW |