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

Unified Diff: pkg/analysis_server/test/services/correction/fix_test.dart

Issue 610323005: Issue 19670. Extend the 'Create Field' Quick Fix to support getter context. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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/util.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/fix_test.dart
diff --git a/pkg/analysis_server/test/services/correction/fix_test.dart b/pkg/analysis_server/test/services/correction/fix_test.dart
index 2d5ffa0b6ca958172bb540a37b34e022dde0a0e5..766afc02ffda23d99d79666fc9f3dc23cd49a64f 100644
--- a/pkg/analysis_server/test/services/correction/fix_test.dart
+++ b/pkg/analysis_server/test/services/correction/fix_test.dart
@@ -395,7 +395,114 @@ main() {
''');
}
- void test_createField_qualified_instance_hasField() {
+ void test_createField_getter_multiLevel() {
+ _indexTestUnit('''
+class A {
+}
+class B {
+ A a;
+}
+class C {
+ B b;
+}
+main(C c) {
+ int v = c.b.a.test;
+}
+''');
+ assertHasFix(FixKind.CREATE_FIELD, '''
+class A {
+ int test;
+}
+class B {
+ A a;
+}
+class C {
+ B b;
+}
+main(C c) {
+ int v = c.b.a.test;
+}
+''');
+ }
+
+ void test_createField_getter_qualified_instance() {
+ _indexTestUnit('''
+class A {
+}
+main(A a) {
+ int v = a.test;
+}
+''');
+ assertHasFix(FixKind.CREATE_FIELD, '''
+class A {
+ int test;
+}
+main(A a) {
+ int v = a.test;
+}
+''');
+ }
+
+ void test_createField_getter_unqualified_instance_asInvocationArgument() {
+ _indexTestUnit('''
+class A {
+ main() {
+ f(test);
+ }
+}
+f(String s) {}
+''');
+ assertHasFix(FixKind.CREATE_FIELD, '''
+class A {
+ String test;
+
+ main() {
+ f(test);
+ }
+}
+f(String s) {}
+''');
+ }
+
+ void test_createField_getter_unqualified_instance_asStatement() {
+ _indexTestUnit('''
+class A {
+ main() {
+ test;
+ }
+}
+''');
+ assertHasFix(FixKind.CREATE_FIELD, '''
+class A {
+ var test;
+
+ main() {
+ test;
+ }
+}
+''');
+ }
+
+ void test_createField_getter_unqualified_instance_assignmentLhs() {
+ _indexTestUnit('''
+class A {
+ main() {
+ int v = test;
+ }
+}
+''');
+ assertHasFix(FixKind.CREATE_FIELD, '''
+class A {
+ int test;
+
+ main() {
+ int v = test;
+ }
+}
+''');
+ }
+
+ void test_createField_setter_qualified_instance_hasField() {
_indexTestUnit('''
class A {
int aaa;
@@ -422,7 +529,7 @@ main(A a) {
''');
}
- void test_createField_qualified_instance_hasMethod() {
+ void test_createField_setter_qualified_instance_hasMethod() {
_indexTestUnit('''
class A {
existingMethod() {}
@@ -443,7 +550,7 @@ main(A a) {
''');
}
- void test_createField_qualified_static() {
+ void test_createField_setter_qualified_static() {
_indexTestUnit('''
class A {
}
@@ -461,7 +568,7 @@ main() {
''');
}
- void test_createField_unqualified_instance() {
+ void test_createField_setter_unqualified_instance() {
_indexTestUnit('''
class A {
main() {
@@ -480,7 +587,7 @@ class A {
''');
}
- void test_createField_unqualified_static() {
+ void test_createField_setter_unqualified_static() {
_indexTestUnit('''
class A {
static main() {
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/util.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698