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

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

Issue 1024573002: Issue 22886. Quick fixes create getter' and 'create field' for hints. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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/fix_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/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 6625ff2244dcf83c26f204c7b29f19cbb5f50dce..9a493c70abe1bee63c9ed0dc0169c1af4b1f6290 100644
--- a/pkg/analysis_server/test/services/correction/fix_test.dart
+++ b/pkg/analysis_server/test/services/correction/fix_test.dart
@@ -752,6 +752,46 @@ class A {
''');
}
+ void test_createField_hint() {
+ resolveTestUnit('''
+class A {
+}
+main(A a) {
+ var x = a;
+ int v = x.test;
+}
+''');
+ assertHasFix(FixKind.CREATE_FIELD, '''
+class A {
+ int test;
+}
+main(A a) {
+ var x = a;
+ int v = x.test;
+}
+''');
+ }
+
+ void test_createField_hint_setter() {
+ resolveTestUnit('''
+class A {
+}
+main(A a) {
+ var x = a;
+ x.test = 0;
+}
+''');
+ assertHasFix(FixKind.CREATE_FIELD, '''
+class A {
+ int test;
+}
+main(A a) {
+ var x = a;
+ x.test = 0;
+}
+''');
+ }
+
void test_createField_importType() {
addSource('/libA.dart', r'''
library libA;
@@ -977,6 +1017,26 @@ main(List p) {
assertNoFix(FixKind.CREATE_GETTER);
}
+ void test_createGetter_hint_getter() {
+ resolveTestUnit('''
+class A {
+}
+main(A a) {
+ var x = a;
+ int v = x.test;
+}
+''');
+ assertHasFix(FixKind.CREATE_GETTER, '''
+class A {
+ int get test => null;
+}
+main(A a) {
+ var x = a;
+ int v = x.test;
+}
+''');
+ }
+
void test_createGetter_multiLevel() {
resolveTestUnit('''
class A {
@@ -2818,6 +2878,27 @@ main() {
''');
}
+ void test_undefinedGetter_useSimilar_hint() {
+ resolveTestUnit('''
+class A {
+ int myField;
+}
+main(A a) {
+ var x = a;
+ print(x.myFild);
+}
+''');
+ assertHasFix(FixKind.CHANGE_TO, '''
+class A {
+ int myField;
+}
+main(A a) {
+ var x = a;
+ print(x.myField);
+}
+''');
+ }
+
void test_undefinedGetter_useSimilar_qualified() {
resolveTestUnit('''
class A {
@@ -3243,6 +3324,46 @@ class A {
''');
}
+ void test_undefinedSetter_useSimilar_hint() {
+ resolveTestUnit('''
+class A {
+ int myField;
+}
+main(A a) {
+ var x = a;
+ x.myFild = 42;
+}
+''');
+ assertHasFix(FixKind.CHANGE_TO, '''
+class A {
+ int myField;
+}
+main(A a) {
+ var x = a;
+ x.myField = 42;
+}
+''');
+ }
+
+ void test_undefinedSetter_useSimilar_qualified() {
+ resolveTestUnit('''
+class A {
+ int myField;
+}
+main(A a) {
+ a.myFild = 42;
+}
+''');
+ assertHasFix(FixKind.CHANGE_TO, '''
+class A {
+ int myField;
+}
+main(A a) {
+ a.myField = 42;
+}
+''');
+ }
+
void test_undefinedSetter_useSimilar_unqualified() {
resolveTestUnit('''
class A {
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/fix_internal.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698