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

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

Issue 608363003: Issue 19670. 'Create field' quick fix. (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
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 c434434edd54e1c68bd393e7244c5139aff5c67e..2d5ffa0b6ca958172bb540a37b34e022dde0a0e5 100644
--- a/pkg/analysis_server/test/services/correction/fix_test.dart
+++ b/pkg/analysis_server/test/services/correction/fix_test.dart
@@ -395,6 +395,110 @@ main() {
''');
}
+ void test_createField_qualified_instance_hasField() {
+ _indexTestUnit('''
+class A {
+ int aaa;
+ int zzz;
+
+ existingMethod() {}
+}
+main(A a) {
+ a.test = 5;
+}
+''');
+ assertHasFix(FixKind.CREATE_FIELD, '''
+class A {
+ int aaa;
+ int zzz;
+
+ int test;
+
+ existingMethod() {}
+}
+main(A a) {
+ a.test = 5;
+}
+''');
+ }
+
+ void test_createField_qualified_instance_hasMethod() {
+ _indexTestUnit('''
+class A {
+ existingMethod() {}
+}
+main(A a) {
+ a.test = 5;
+}
+''');
+ assertHasFix(FixKind.CREATE_FIELD, '''
+class A {
+ int test;
+
+ existingMethod() {}
+}
+main(A a) {
+ a.test = 5;
+}
+''');
+ }
+
+ void test_createField_qualified_static() {
+ _indexTestUnit('''
+class A {
+}
+main() {
+ A.test = 5;
+}
+''');
+ assertHasFix(FixKind.CREATE_FIELD, '''
+class A {
+ static int test;
+}
+main() {
+ A.test = 5;
+}
+''');
+ }
+
+ void test_createField_unqualified_instance() {
+ _indexTestUnit('''
+class A {
+ main() {
+ test = 5;
+ }
+}
+''');
+ assertHasFix(FixKind.CREATE_FIELD, '''
+class A {
+ int test;
+
+ main() {
+ test = 5;
+ }
+}
+''');
+ }
+
+ void test_createField_unqualified_static() {
+ _indexTestUnit('''
+class A {
+ static main() {
+ test = 5;
+ }
+}
+''');
+ assertHasFix(FixKind.CREATE_FIELD, '''
+class A {
+ static int test;
+
+ static main() {
+ test = 5;
+ }
+}
+''');
+ }
+
void test_createFile_forImport() {
testFile = '/my/project/bin/test.dart';
_indexTestUnit('''

Powered by Google App Engine
This is Rietveld 408576698