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

Side by Side Diff: pkg/analysis_server/test/services/correction/assist_test.dart

Issue 1216463004: New Quick Assist - 'Convert to field formal parameter'. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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/correction/assist_internal.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.correction.assist; 5 library test.services.correction.assist;
6 6
7 import 'package:analysis_server/edit/assist/assist_core.dart'; 7 import 'package:analysis_server/edit/assist/assist_core.dart';
8 import 'package:analysis_server/src/plugin/server_plugin.dart'; 8 import 'package:analysis_server/src/plugin/server_plugin.dart';
9 import 'package:analysis_server/src/protocol.dart'; 9 import 'package:analysis_server/src/protocol.dart';
10 import 'package:analysis_server/src/services/correction/assist.dart'; 10 import 'package:analysis_server/src/services/correction/assist.dart';
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 932
933 void test_convertToExpressionBody_wrong_noReturnValue() { 933 void test_convertToExpressionBody_wrong_noReturnValue() {
934 resolveTestUnit(''' 934 resolveTestUnit('''
935 fff() { 935 fff() {
936 return; 936 return;
937 } 937 }
938 '''); 938 ''');
939 assertNoAssistAt('fff()', DartAssistKind.CONVERT_INTO_EXPRESSION_BODY); 939 assertNoAssistAt('fff()', DartAssistKind.CONVERT_INTO_EXPRESSION_BODY);
940 } 940 }
941 941
942 void test_convertToFieldParameter_BAD_additionalUse() {
943 resolveTestUnit('''
944 class A {
945 int aaa2;
946 int bbb2;
947 A(int aaa) : aaa2 = aaa, bbb2 = aaa;
948 }
949 ''');
950 assertNoAssistAt('aaa)', DartAssistKind.CONVERT_TO_FIELD_PARAMETER);
951 }
952
953 void test_convertToFieldParameter_BAD_notPureAssignment() {
954 resolveTestUnit('''
955 class A {
956 int aaa2;
957 A(int aaa) : aaa2 = aaa * 2;
958 }
959 ''');
960 assertNoAssistAt('aaa)', DartAssistKind.CONVERT_TO_FIELD_PARAMETER);
961 }
962
963 void test_convertToFieldParameter_OK_firstInitializer() {
964 resolveTestUnit('''
965 class A {
966 double aaa2;
967 int bbb2;
968 A(int aaa, int bbb) : aaa2 = aaa, bbb2 = bbb;
969 }
970 ''');
971 assertHasAssistAt('aaa, ', DartAssistKind.CONVERT_TO_FIELD_PARAMETER, '''
972 class A {
973 double aaa2;
974 int bbb2;
975 A(this.aaa2, int bbb) : bbb2 = bbb;
976 }
977 ''');
978 }
979
980 void test_convertToFieldParameter_OK_onParameterName_inInitializer() {
981 resolveTestUnit('''
982 class A {
983 int test2;
984 A(int test) : test2 = test {
985 }
986 }
987 ''');
988 assertHasAssistAt('test {', DartAssistKind.CONVERT_TO_FIELD_PARAMETER, '''
989 class A {
990 int test2;
991 A(this.test2) {
992 }
993 }
994 ''');
995 }
996
997 void test_convertToFieldParameter_OK_onParameterName_inParameters() {
998 resolveTestUnit('''
999 class A {
1000 int test;
1001 A(int test) : test = test {
1002 }
1003 }
1004 ''');
1005 assertHasAssistAt('test)', DartAssistKind.CONVERT_TO_FIELD_PARAMETER, '''
1006 class A {
1007 int test;
1008 A(this.test) {
1009 }
1010 }
1011 ''');
1012 }
1013
1014 void test_convertToFieldParameter_OK_secondInitializer() {
1015 resolveTestUnit('''
1016 class A {
1017 double aaa2;
1018 int bbb2;
1019 A(int aaa, int bbb) : aaa2 = aaa, bbb2 = bbb;
1020 }
1021 ''');
1022 assertHasAssistAt('bbb)', DartAssistKind.CONVERT_TO_FIELD_PARAMETER, '''
1023 class A {
1024 double aaa2;
1025 int bbb2;
1026 A(int aaa, this.bbb2) : aaa2 = aaa;
1027 }
1028 ''');
1029 }
1030
942 void test_convertToForIndex_BAD_bodyNotBlock() { 1031 void test_convertToForIndex_BAD_bodyNotBlock() {
943 resolveTestUnit(''' 1032 resolveTestUnit('''
944 main(List<String> items) { 1033 main(List<String> items) {
945 for (String item in items) print(item); 1034 for (String item in items) print(item);
946 } 1035 }
947 '''); 1036 ''');
948 assertNoAssistAt('for (String', DartAssistKind.CONVERT_INTO_FOR_INDEX); 1037 assertNoAssistAt('for (String', DartAssistKind.CONVERT_INTO_FOR_INDEX);
949 } 1038 }
950 1039
951 void test_convertToForIndex_BAD_doesNotDeclareVariable() { 1040 void test_convertToForIndex_BAD_doesNotDeclareVariable() {
(...skipping 2181 matching lines...) Expand 10 before | Expand all | Expand 10 after
3133 positions.add(new Position(testFile, offset)); 3222 positions.add(new Position(testFile, offset));
3134 } 3223 }
3135 return positions; 3224 return positions;
3136 } 3225 }
3137 3226
3138 void _setStartEndSelection() { 3227 void _setStartEndSelection() {
3139 offset = findOffset('// start\n') + '// start\n'.length; 3228 offset = findOffset('// start\n') + '// start\n'.length;
3140 length = findOffset('// end') - offset; 3229 length = findOffset('// end') - offset;
3141 } 3230 }
3142 } 3231 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/assist_internal.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698