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

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

Issue 961583002: Issue 20827. Extract library importing helper and use it fox Quick Fixes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 feb88df6b66848b83ca48f6802de187bcde87239..22ab41807f3488902aa77e2381a0d62d107e09a6 100644
--- a/pkg/analysis_server/test/services/correction/fix_test.dart
+++ b/pkg/analysis_server/test/services/correction/fix_test.dart
@@ -185,6 +185,33 @@ main(A a) {
''');
}
+ void test_changeToStaticAccess_method_importType() {
+ addSource('/libA.dart', r'''
+library libA;
+class A {
+ static foo() {}
+}
+''');
+ addSource('/libB.dart', r'''
+library libB;
+import 'libA.dart';
+class B extends A {}
+''');
+ resolveTestUnit('''
+import 'libB.dart';
+main(B b) {
+ b.foo();
+}
+''');
+ assertHasFix(FixKind.CHANGE_TO_STATIC_ACCESS, '''
+import 'libB.dart';
+import 'libA.dart';
+main(B b) {
+ A.foo();
+}
+''');
+ }
+
void test_changeToStaticAccess_method_prefixLibrary() {
resolveTestUnit('''
import 'dart:async' as pref;
@@ -219,6 +246,33 @@ main(A a) {
''');
}
+ void test_changeToStaticAccess_property_importType() {
+ addSource('/libA.dart', r'''
+library libA;
+class A {
+ static get foo => null;
+}
+''');
+ addSource('/libB.dart', r'''
+library libB;
+import 'libA.dart';
+class B extends A {}
+''');
+ resolveTestUnit('''
+import 'libB.dart';
+main(B b) {
+ b.foo;
+}
+''');
+ assertHasFix(FixKind.CHANGE_TO_STATIC_ACCESS, '''
+import 'libB.dart';
+import 'libA.dart';
+main(B b) {
+ A.foo;
+}
+''');
+ }
+
void test_createClass() {
resolveTestUnit('''
main() {
@@ -408,6 +462,32 @@ class B extends A {
''');
}
+ void test_createConstructorSuperImplicit_importType() {
+ addSource('/libA.dart', r'''
+library libA;
+class A {}
+''');
+ addSource('/libB.dart', r'''
+library libB;
+import 'libA.dart';
+class B {
+ B(A a);
+}
+''');
+ resolveTestUnit('''
+import 'libB.dart';
+class C extends B {
+}
+''');
+ assertHasFix(FixKind.CREATE_CONSTRUCTOR_SUPER, '''
+import 'libB.dart';
+import 'libA.dart';
+class C extends B {
+ C(A a) : super(a);
+}
+''');
+ }
+
void test_createConstructorSuperImplicit_named() {
resolveTestUnit('''
class A {
@@ -584,6 +664,36 @@ class A {
''');
}
+ void test_createField_importType() {
+ addSource('/libA.dart', r'''
+library libA;
+class A {}
+''');
+ addSource('/libB.dart', r'''
+library libB;
+import 'libA.dart';
+A getA() => null;
+''');
+ resolveTestUnit('''
+import 'libB.dart';
+class C {
+}
+main(C c) {
+ c.test = getA();
+}
+''');
+ assertHasFix(FixKind.CREATE_FIELD, '''
+import 'libB.dart';
+import 'libA.dart';
+class C {
+ A test;
+}
+main(C c) {
+ c.test = getA();
+}
+''');
+ }
+
void test_createField_setter_generic_BAD() {
resolveTestUnit('''
class A {
@@ -1477,6 +1587,34 @@ int test(double a, String b) {
''');
}
+ void test_creationFunction_forFunctionType_importType() {
+ addSource('/libA.dart', r'''
+library libA;
+class A {}
+''');
+ addSource('/libB.dart', r'''
+library libB;
+import 'libA.dart';
+useFunction(int g(A a)) {}
+''');
+ resolveTestUnit('''
+import 'libB.dart';
+main() {
+ useFunction(test);
+}
+''');
+ assertHasFix(FixKind.CREATE_FUNCTION, '''
+import 'libB.dart';
+import 'libA.dart';
+main() {
+ useFunction(test);
+}
+
+int test(A a) {
+}
+''');
+ }
+
void test_creationFunction_forFunctionType_method_enclosingClass_static() {
resolveTestUnit('''
class A {
@@ -2288,6 +2426,30 @@ void process(List<int> items) {
''');
}
+ void test_undefinedFunction_create_importType() {
+ addSource('/lib.dart', r'''
+library lib;
+import 'dart:async';
+Future getFuture() => null;
+''');
+ resolveTestUnit('''
+import 'lib.dart';
+main() {
+ test(getFuture());
+}
+''');
+ assertHasFix(FixKind.CREATE_FUNCTION, '''
+import 'lib.dart';
+import 'dart:async';
+main() {
+ test(getFuture());
+}
+
+void test(Future future) {
+}
+''');
+ }
+
void test_undefinedFunction_create_nullArgument() {
resolveTestUnit('''
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