| 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 c3592214a2db867c8810849ccf4f51eca7ddda04..3ca13a611ca212017e86f741e4a5713aa680e477 100644
|
| --- a/pkg/analysis_server/test/services/correction/fix_test.dart
|
| +++ b/pkg/analysis_server/test/services/correction/fix_test.dart
|
| @@ -488,7 +488,7 @@ f(String s) {}
|
| ''');
|
| }
|
|
|
| - void test_createField_getter_unqualified_instance_assignmentLhs() {
|
| + void test_createField_getter_unqualified_instance_assignmentRhs() {
|
| _indexTestUnit('''
|
| class A {
|
| main() {
|
| @@ -694,6 +694,160 @@ import 'my_file.dart';
|
| expect(fileEdit.edits[0].replacement, contains('library my.file;'));
|
| }
|
|
|
| + void test_createGetter_multiLevel() {
|
| + _indexTestUnit('''
|
| +class A {
|
| +}
|
| +class B {
|
| + A a;
|
| +}
|
| +class C {
|
| + B b;
|
| +}
|
| +main(C c) {
|
| + int v = c.b.a.test;
|
| +}
|
| +''');
|
| + assertHasFix(FixKind.CREATE_GETTER, '''
|
| +class A {
|
| + int get test => null;
|
| +}
|
| +class B {
|
| + A a;
|
| +}
|
| +class C {
|
| + B b;
|
| +}
|
| +main(C c) {
|
| + int v = c.b.a.test;
|
| +}
|
| +''');
|
| + }
|
| +
|
| + void test_createGetter_qualified_instance() {
|
| + _indexTestUnit('''
|
| +class A {
|
| +}
|
| +main(A a) {
|
| + int v = a.test;
|
| +}
|
| +''');
|
| + assertHasFix(FixKind.CREATE_GETTER, '''
|
| +class A {
|
| + int get test => null;
|
| +}
|
| +main(A a) {
|
| + int v = a.test;
|
| +}
|
| +''');
|
| + }
|
| +
|
| + void test_createGetter_qualified_instance_dynamicType() {
|
| + _indexTestUnit('''
|
| +class A {
|
| + B b;
|
| + void f(Object p) {
|
| + p == b.test;
|
| + }
|
| +}
|
| +class B {
|
| +}
|
| +''');
|
| + assertHasFix(FixKind.CREATE_GETTER, '''
|
| +class A {
|
| + B b;
|
| + void f(Object p) {
|
| + p == b.test;
|
| + }
|
| +}
|
| +class B {
|
| + get test => null;
|
| +}
|
| +''');
|
| + }
|
| +
|
| + void test_createGetter_setterContext() {
|
| + _indexTestUnit('''
|
| +class A {
|
| +}
|
| +main(A a) {
|
| + a.test = 42;
|
| +}
|
| +''');
|
| + assertNoFix(FixKind.CREATE_GETTER);
|
| + }
|
| +
|
| + void test_createGetter_unqualified_instance_asInvocationArgument() {
|
| + _indexTestUnit('''
|
| +class A {
|
| + main() {
|
| + f(test);
|
| + }
|
| +}
|
| +f(String s) {}
|
| +''');
|
| + assertHasFix(FixKind.CREATE_GETTER, '''
|
| +class A {
|
| + String get test => null;
|
| +
|
| + main() {
|
| + f(test);
|
| + }
|
| +}
|
| +f(String s) {}
|
| +''');
|
| + }
|
| +
|
| + void test_createGetter_unqualified_instance_assignmentLhs() {
|
| + _indexTestUnit('''
|
| +class A {
|
| + main() {
|
| + test = 42;
|
| + }
|
| +}
|
| +''');
|
| + assertNoFix(FixKind.CREATE_GETTER);
|
| + }
|
| +
|
| + void test_createGetter_unqualified_instance_assignmentRhs() {
|
| + _indexTestUnit('''
|
| +class A {
|
| + main() {
|
| + int v = test;
|
| + }
|
| +}
|
| +''');
|
| + assertHasFix(FixKind.CREATE_GETTER, '''
|
| +class A {
|
| + int get test => null;
|
| +
|
| + main() {
|
| + int v = test;
|
| + }
|
| +}
|
| +''');
|
| + }
|
| +
|
| + void test_createGetter_unqualified_instance_asStatement() {
|
| + _indexTestUnit('''
|
| +class A {
|
| + main() {
|
| + test;
|
| + }
|
| +}
|
| +''');
|
| + // TODO
|
| + assertHasFix(FixKind.CREATE_GETTER, '''
|
| +class A {
|
| + get test => null;
|
| +
|
| + main() {
|
| + test;
|
| + }
|
| +}
|
| +''');
|
| + }
|
| +
|
| void test_createLocalVariable_read_typeAssignment() {
|
| _indexTestUnit('''
|
| main() {
|
| @@ -1096,6 +1250,35 @@ class B extends A {
|
| ''');
|
| }
|
|
|
| + void test_creatGetter_location_afterLastGetter() {
|
| + _indexTestUnit('''
|
| +class A {
|
| + int existingField;
|
| +
|
| + int get existingGetter => null;
|
| +
|
| + existingMethod() {}
|
| +}
|
| +main(A a) {
|
| + int v = a.test;
|
| +}
|
| +''');
|
| + assertHasFix(FixKind.CREATE_GETTER, '''
|
| +class A {
|
| + int existingField;
|
| +
|
| + int get existingGetter => null;
|
| +
|
| + int get test => null;
|
| +
|
| + existingMethod() {}
|
| +}
|
| +main(A a) {
|
| + int v = a.test;
|
| +}
|
| +''');
|
| + }
|
| +
|
| void test_creationFunction_forFunctionType_cascadeSecond() {
|
| _indexTestUnit('''
|
| class A {
|
|
|