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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/test/services/correction/assist_test.dart
diff --git a/pkg/analysis_server/test/services/correction/assist_test.dart b/pkg/analysis_server/test/services/correction/assist_test.dart
index f530db1b11297a854a53e12e7f9f33331d23c60f..8e27fa5aa6120795f490d9741a10f7b2bdd9d3bf 100644
--- a/pkg/analysis_server/test/services/correction/assist_test.dart
+++ b/pkg/analysis_server/test/services/correction/assist_test.dart
@@ -939,6 +939,95 @@ fff() {
assertNoAssistAt('fff()', DartAssistKind.CONVERT_INTO_EXPRESSION_BODY);
}
+ void test_convertToFieldParameter_BAD_additionalUse() {
+ resolveTestUnit('''
+class A {
+ int aaa2;
+ int bbb2;
+ A(int aaa) : aaa2 = aaa, bbb2 = aaa;
+}
+''');
+ assertNoAssistAt('aaa)', DartAssistKind.CONVERT_TO_FIELD_PARAMETER);
+ }
+
+ void test_convertToFieldParameter_BAD_notPureAssignment() {
+ resolveTestUnit('''
+class A {
+ int aaa2;
+ A(int aaa) : aaa2 = aaa * 2;
+}
+''');
+ assertNoAssistAt('aaa)', DartAssistKind.CONVERT_TO_FIELD_PARAMETER);
+ }
+
+ void test_convertToFieldParameter_OK_firstInitializer() {
+ resolveTestUnit('''
+class A {
+ double aaa2;
+ int bbb2;
+ A(int aaa, int bbb) : aaa2 = aaa, bbb2 = bbb;
+}
+''');
+ assertHasAssistAt('aaa, ', DartAssistKind.CONVERT_TO_FIELD_PARAMETER, '''
+class A {
+ double aaa2;
+ int bbb2;
+ A(this.aaa2, int bbb) : bbb2 = bbb;
+}
+''');
+ }
+
+ void test_convertToFieldParameter_OK_onParameterName_inInitializer() {
+ resolveTestUnit('''
+class A {
+ int test2;
+ A(int test) : test2 = test {
+ }
+}
+''');
+ assertHasAssistAt('test {', DartAssistKind.CONVERT_TO_FIELD_PARAMETER, '''
+class A {
+ int test2;
+ A(this.test2) {
+ }
+}
+''');
+ }
+
+ void test_convertToFieldParameter_OK_onParameterName_inParameters() {
+ resolveTestUnit('''
+class A {
+ int test;
+ A(int test) : test = test {
+ }
+}
+''');
+ assertHasAssistAt('test)', DartAssistKind.CONVERT_TO_FIELD_PARAMETER, '''
+class A {
+ int test;
+ A(this.test) {
+ }
+}
+''');
+ }
+
+ void test_convertToFieldParameter_OK_secondInitializer() {
+ resolveTestUnit('''
+class A {
+ double aaa2;
+ int bbb2;
+ A(int aaa, int bbb) : aaa2 = aaa, bbb2 = bbb;
+}
+''');
+ assertHasAssistAt('bbb)', DartAssistKind.CONVERT_TO_FIELD_PARAMETER, '''
+class A {
+ double aaa2;
+ int bbb2;
+ A(int aaa, this.bbb2) : aaa2 = aaa;
+}
+''');
+ }
+
void test_convertToForIndex_BAD_bodyNotBlock() {
resolveTestUnit('''
main(List<String> items) {
« 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