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

Side by Side Diff: pkg/analysis_server/test/services/refactoring/inline_method_test.dart

Issue 2463493002: Fix for inlining async methods/getters. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/analysis_server/lib/src/services/refactoring/inline_method.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 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.inline_method; 5 library test.services.refactoring.inline_method;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/plugin/protocol/protocol.dart' hide Element; 9 import 'package:analysis_server/plugin/protocol/protocol.dart' hide Element;
10 import 'package:analysis_server/src/services/correction/status.dart'; 10 import 'package:analysis_server/src/services/correction/status.dart';
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 _createRefactoring('test() {'); 704 _createRefactoring('test() {');
705 // validate change 705 // validate change
706 return _assertSuccessfulRefactoring(r''' 706 return _assertSuccessfulRefactoring(r'''
707 var topLevelField = 0; 707 var topLevelField = 0;
708 main() { 708 main() {
709 print(topLevelField); 709 print(topLevelField);
710 } 710 }
711 '''); 711 ''');
712 } 712 }
713 713
714 test_getter_async() {
Brian Wilkerson 2016/10/31 14:00:38 Given that we are inlining 'test' into 'foo, perha
scheglov 2016/10/31 15:48:29 Done.
715 indexTestUnit(r'''
716 import 'dart:async';
717 class A {
718 Future<int> get test async => 42;
719 Future<int> get foo {
720 return test;
721 }
722 }
723 ''');
724 _createRefactoring('test async');
725 // validate change
726 return _assertSuccessfulRefactoring(r'''
727 import 'dart:async';
728 class A {
729 Future<int> get foo async {
730 return 42;
731 }
732 }
733 ''');
734 }
735
714 test_getter_classMember_instance() { 736 test_getter_classMember_instance() {
715 indexTestUnit(r''' 737 indexTestUnit(r'''
716 class A { 738 class A {
717 int f; 739 int f;
718 int get result => f + 1; 740 int get result => f + 1;
719 } 741 }
720 main(A a) { 742 main(A a) {
721 print(a.result); 743 print(a.result);
722 } 744 }
723 '''); 745 ''');
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 } 818 }
797 '''); 819 ''');
798 _createRefactoring('test(1, 2)'); 820 _createRefactoring('test(1, 2)');
799 deleteSource = false; 821 deleteSource = false;
800 // validate state 822 // validate state
801 await refactoring.checkInitialConditions(); 823 await refactoring.checkInitialConditions();
802 expect(refactoring.deleteSource, false); 824 expect(refactoring.deleteSource, false);
803 expect(refactoring.inlineAll, false); 825 expect(refactoring.inlineAll, false);
804 } 826 }
805 827
828 test_method_async() {
829 indexTestUnit(r'''
830 import 'dart:async';
831 class A {
832 Future<int> test() async => 42;
833 Future<int> foo() {
834 return test();
835 }
836 }
837 ''');
838 _createRefactoring('test() async');
839 // validate change
840 return _assertSuccessfulRefactoring(r'''
841 import 'dart:async';
842 class A {
843 Future<int> foo() async {
844 return 42;
845 }
846 }
847 ''');
848 }
849
850 test_method_async2() {
851 indexTestUnit(r'''
852 import 'dart:async';
853 class A {
854 Future<int> test() async => 42;
855 Future foo() {
856 return [test(), test()];
857 }
858 }
859 ''');
860 _createRefactoring('test() async');
861 // validate change
862 return _assertSuccessfulRefactoring(r'''
863 import 'dart:async';
864 class A {
865 Future foo() async {
866 return [42, 42];
867 }
868 }
869 ''');
870 }
871
806 test_method_emptyBody() { 872 test_method_emptyBody() {
807 indexTestUnit(r''' 873 indexTestUnit(r'''
808 abstract class A { 874 abstract class A {
809 test(); 875 test();
810 } 876 }
811 main(A a) { 877 main(A a) {
812 print(a.test()); 878 print(a.test());
813 } 879 }
814 '''); 880 ''');
815 _createRefactoring('test();'); 881 _createRefactoring('test();');
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
1520 SourceChange change = await refactoring.createChange(); 1586 SourceChange change = await refactoring.createChange();
1521 this.refactoringChange = change; 1587 this.refactoringChange = change;
1522 assertTestChangeResult(expectedCode); 1588 assertTestChangeResult(expectedCode);
1523 } 1589 }
1524 1590
1525 void _createRefactoring(String search) { 1591 void _createRefactoring(String search) {
1526 int offset = findOffset(search); 1592 int offset = findOffset(search);
1527 refactoring = new InlineMethodRefactoring(searchEngine, testUnit, offset); 1593 refactoring = new InlineMethodRefactoring(searchEngine, testUnit, offset);
1528 } 1594 }
1529 } 1595 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/refactoring/inline_method.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698