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

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

Issue 2907213002: [Extract Method] When no selection, check for implicitly selected closure. (Closed)
Patch Set: Created 3 years, 6 months 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/extract_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 import 'dart:async'; 5 import 'dart:async';
6 6
7 import 'package:analysis_server/src/services/correction/status.dart'; 7 import 'package:analysis_server/src/services/correction/status.dart';
8 import 'package:analysis_server/src/services/refactoring/extract_method.dart'; 8 import 'package:analysis_server/src/services/refactoring/extract_method.dart';
9 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; 9 import 'package:analysis_server/src/services/refactoring/refactoring.dart';
10 import 'package:analyzer_plugin/protocol/protocol_common.dart'; 10 import 'package:analyzer_plugin/protocol/protocol_common.dart';
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 } 852 }
853 853
854 res(x) { 854 res(x) {
855 print(x); 855 print(x);
856 return x * k; 856 return x * k;
857 } 857 }
858 } 858 }
859 '''); 859 ''');
860 } 860 }
861 861
862 test_closure_atArgumentName() async {
863 await indexTestUnit('''
864 void process({int fff(int x)}) {}
865 class C {
866 main() {
867 process(fff: (int x) => x * 2);
868 }
869 }
870 ''');
871 _createRefactoring(findOffset('ff: (int x)'), 0);
872 // apply refactoring
873 return _assertSuccessfulRefactoring('''
874 void process({int fff(int x)}) {}
875 class C {
876 main() {
877 process(fff: res);
878 }
879
880 int res(int x) => x * 2;
881 }
882 ''');
883 }
884
885 test_closure_atParameters() async {
886 await indexTestUnit('''
887 void process(num f(int x)) {}
888 class C {
889 main() {
890 process((int x) => x * 2);
891 }
892 }
893 ''');
894 _createRefactoring(findOffset('x) =>'), 0);
895 // apply refactoring
896 return _assertSuccessfulRefactoring('''
897 void process(num f(int x)) {}
898 class C {
899 main() {
900 process(res);
901 }
902
903 num res(int x) => x * 2;
904 }
905 ''');
906 }
907
862 test_closure_bad_referencesLocalVariable() async { 908 test_closure_bad_referencesLocalVariable() async {
863 await indexTestUnit(''' 909 await indexTestUnit('''
864 process(f(x)) {} 910 process(f(x)) {}
865 main() { 911 main() {
866 int k = 2; 912 int k = 2;
867 process((x) => x * k); 913 process((x) => x * k);
868 } 914 }
869 '''); 915 ''');
870 _createRefactoringForString('(x) => x * k'); 916 _createRefactoringForString('(x) => x * k');
871 // check 917 // check
(...skipping 1961 matching lines...) Expand 10 before | Expand all | Expand 10 after
2833 * Returns a deep copy of [refactoring] parameters. 2879 * Returns a deep copy of [refactoring] parameters.
2834 * There was a bug masked by updating parameter instances shared between the 2880 * There was a bug masked by updating parameter instances shared between the
2835 * refactoring and the test. 2881 * refactoring and the test.
2836 */ 2882 */
2837 List<RefactoringMethodParameter> _getParametersCopy() { 2883 List<RefactoringMethodParameter> _getParametersCopy() {
2838 return refactoring.parameters.map((p) { 2884 return refactoring.parameters.map((p) {
2839 return new RefactoringMethodParameter(p.kind, p.type, p.name, id: p.id); 2885 return new RefactoringMethodParameter(p.kind, p.type, p.name, id: p.id);
2840 }).toList(); 2886 }).toList();
2841 } 2887 }
2842 } 2888 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/refactoring/extract_method.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698