| 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 22ab41807f3488902aa77e2381a0d62d107e09a6..110da4d818f14f1cf55bf464b1169123b8f6c5b5 100644
|
| --- a/pkg/analysis_server/test/services/correction/fix_test.dart
|
| +++ b/pkg/analysis_server/test/services/correction/fix_test.dart
|
| @@ -1740,7 +1740,7 @@ main() {
|
| ''');
|
| }
|
|
|
| - void test_importLibraryPackage_withType() {
|
| + void test_importLibraryPackage_withClass() {
|
| _configureMyPkg('''
|
| library my_lib;
|
| class Test {}
|
| @@ -1761,24 +1761,7 @@ main() {
|
| ''');
|
| }
|
|
|
| - void test_importLibraryPrefix_withTopLevelVariable() {
|
| - resolveTestUnit('''
|
| -import 'dart:math' as pref;
|
| -main() {
|
| - print(pref.E);
|
| - print(PI);
|
| -}
|
| -''');
|
| - assertHasFix(FixKind.IMPORT_LIBRARY_PREFIX, '''
|
| -import 'dart:math' as pref;
|
| -main() {
|
| - print(pref.E);
|
| - print(pref.PI);
|
| -}
|
| -''');
|
| - }
|
| -
|
| - void test_importLibraryPrefix_withType() {
|
| + void test_importLibraryPrefix_withClass() {
|
| resolveTestUnit('''
|
| import 'dart:async' as pref;
|
| main() {
|
| @@ -1795,95 +1778,90 @@ main() {
|
| ''');
|
| }
|
|
|
| - void test_importLibraryProject_withFunction() {
|
| - addSource('/lib.dart', '''
|
| -library lib;
|
| -myFunction() {}
|
| -''');
|
| + void test_importLibraryPrefix_withTopLevelVariable() {
|
| resolveTestUnit('''
|
| +import 'dart:math' as pref;
|
| main() {
|
| - myFunction();
|
| + print(pref.E);
|
| + print(PI);
|
| }
|
| ''');
|
| - performAllAnalysisTasks();
|
| - assertHasFix(FixKind.IMPORT_LIBRARY_PROJECT, '''
|
| -import 'lib.dart';
|
| -
|
| + assertHasFix(FixKind.IMPORT_LIBRARY_PREFIX, '''
|
| +import 'dart:math' as pref;
|
| main() {
|
| - myFunction();
|
| + print(pref.E);
|
| + print(pref.PI);
|
| }
|
| ''');
|
| }
|
|
|
| - void test_importLibraryProject_withFunction_unresolvedMethod() {
|
| + void test_importLibraryProject_withClass_annotation() {
|
| addSource('/lib.dart', '''
|
| library lib;
|
| -myFunction() {}
|
| +class Test {
|
| + const Test(int p);
|
| +}
|
| ''');
|
| resolveTestUnit('''
|
| -class A {
|
| - main() {
|
| - myFunction();
|
| - }
|
| +@Test(0)
|
| +main() {
|
| }
|
| ''');
|
| performAllAnalysisTasks();
|
| assertHasFix(FixKind.IMPORT_LIBRARY_PROJECT, '''
|
| import 'lib.dart';
|
|
|
| -class A {
|
| - main() {
|
| - myFunction();
|
| - }
|
| +@Test(0)
|
| +main() {
|
| }
|
| ''');
|
| }
|
|
|
| - void test_importLibraryProject_withTopLevelVariable() {
|
| - addSource('/lib.dart', '''
|
| + void test_importLibraryProject_withClass_inParentFolder() {
|
| + testFile = '/project/bin/test.dart';
|
| + addSource('/project/lib.dart', '''
|
| library lib;
|
| -int MY_VAR = 42;
|
| +class Test {}
|
| ''');
|
| resolveTestUnit('''
|
| main() {
|
| - print(MY_VAR);
|
| + Test t = null;
|
| }
|
| ''');
|
| performAllAnalysisTasks();
|
| assertHasFix(FixKind.IMPORT_LIBRARY_PROJECT, '''
|
| -import 'lib.dart';
|
| +import '../lib.dart';
|
|
|
| main() {
|
| - print(MY_VAR);
|
| + Test t = null;
|
| }
|
| ''');
|
| }
|
|
|
| - void test_importLibraryProject_withType_annotation() {
|
| - addSource('/lib.dart', '''
|
| + void test_importLibraryProject_withClass_inRelativeFolder() {
|
| + testFile = '/project/bin/test.dart';
|
| + addSource('/project/lib/sub/folder/lib.dart', '''
|
| library lib;
|
| -class Test {
|
| - const Test(int p);
|
| -}
|
| +class Test {}
|
| ''');
|
| resolveTestUnit('''
|
| -@Test(0)
|
| main() {
|
| + Test t = null;
|
| }
|
| ''');
|
| performAllAnalysisTasks();
|
| assertHasFix(FixKind.IMPORT_LIBRARY_PROJECT, '''
|
| -import 'lib.dart';
|
| +import '../lib/sub/folder/lib.dart';
|
|
|
| -@Test(0)
|
| main() {
|
| + Test t = null;
|
| }
|
| ''');
|
| }
|
|
|
| - void test_importLibraryProject_withType_inParentFolder() {
|
| + void test_importLibraryProject_withClass_inSameFolder() {
|
| testFile = '/project/bin/test.dart';
|
| - addSource('/project/lib.dart', '''
|
| + addSource('/project/bin/lib.dart', '''
|
| library lib;
|
| class Test {}
|
| ''');
|
| @@ -1894,7 +1872,7 @@ main() {
|
| ''');
|
| performAllAnalysisTasks();
|
| assertHasFix(FixKind.IMPORT_LIBRARY_PROJECT, '''
|
| -import '../lib.dart';
|
| +import 'lib.dart';
|
|
|
| main() {
|
| Test t = null;
|
| @@ -1902,81 +1880,92 @@ main() {
|
| ''');
|
| }
|
|
|
| - void test_importLibraryProject_withType_inRelativeFolder() {
|
| - testFile = '/project/bin/test.dart';
|
| - addSource('/project/lib/sub/folder/lib.dart', '''
|
| + void test_importLibraryProject_withFunction() {
|
| + addSource('/lib.dart', '''
|
| library lib;
|
| -class Test {}
|
| +myFunction() {}
|
| ''');
|
| resolveTestUnit('''
|
| main() {
|
| - Test t = null;
|
| + myFunction();
|
| }
|
| ''');
|
| performAllAnalysisTasks();
|
| assertHasFix(FixKind.IMPORT_LIBRARY_PROJECT, '''
|
| -import '../lib/sub/folder/lib.dart';
|
| +import 'lib.dart';
|
|
|
| main() {
|
| - Test t = null;
|
| + myFunction();
|
| }
|
| ''');
|
| }
|
|
|
| - void test_importLibraryProject_withType_inSameFolder() {
|
| - testFile = '/project/bin/test.dart';
|
| - addSource('/project/bin/lib.dart', '''
|
| + void test_importLibraryProject_withFunction_unresolvedMethod() {
|
| + addSource('/lib.dart', '''
|
| library lib;
|
| -class Test {}
|
| +myFunction() {}
|
| ''');
|
| resolveTestUnit('''
|
| -main() {
|
| - Test t = null;
|
| +class A {
|
| + main() {
|
| + myFunction();
|
| + }
|
| }
|
| ''');
|
| performAllAnalysisTasks();
|
| assertHasFix(FixKind.IMPORT_LIBRARY_PROJECT, '''
|
| import 'lib.dart';
|
|
|
| -main() {
|
| - Test t = null;
|
| +class A {
|
| + main() {
|
| + myFunction();
|
| + }
|
| }
|
| ''');
|
| }
|
|
|
| - void test_importLibrarySdk_withTopLevelVariable() {
|
| + void test_importLibraryProject_withFunctionTypeAlias() {
|
| + testFile = '/project/bin/test.dart';
|
| + addSource('/project/bin/lib.dart', '''
|
| +library lib;
|
| +typedef MyFunction();
|
| +''');
|
| resolveTestUnit('''
|
| main() {
|
| - print(PI);
|
| + MyFunction t = null;
|
| }
|
| ''');
|
| performAllAnalysisTasks();
|
| - assertHasFix(FixKind.IMPORT_LIBRARY_SDK, '''
|
| -import 'dart:math';
|
| + assertHasFix(FixKind.IMPORT_LIBRARY_PROJECT, '''
|
| +import 'lib.dart';
|
|
|
| main() {
|
| - print(PI);
|
| + MyFunction t = null;
|
| }
|
| ''');
|
| }
|
|
|
| - void test_importLibrarySdk_withTopLevelVariable_annotation() {
|
| + void test_importLibraryProject_withTopLevelVariable() {
|
| + addSource('/lib.dart', '''
|
| +library lib;
|
| +int MY_VAR = 42;
|
| +''');
|
| resolveTestUnit('''
|
| -@PI
|
| main() {
|
| + print(MY_VAR);
|
| }
|
| ''');
|
| performAllAnalysisTasks();
|
| - assertHasFix(FixKind.IMPORT_LIBRARY_SDK, '''
|
| -import 'dart:math';
|
| + assertHasFix(FixKind.IMPORT_LIBRARY_PROJECT, '''
|
| +import 'lib.dart';
|
|
|
| -@PI
|
| main() {
|
| + print(MY_VAR);
|
| }
|
| ''');
|
| }
|
|
|
| - void test_importLibrarySdk_withType_AsExpression() {
|
| + void test_importLibrarySdk_withClass_AsExpression() {
|
| resolveTestUnit('''
|
| main(p) {
|
| p as Future;
|
| @@ -1991,7 +1980,7 @@ main(p) {
|
| ''');
|
| }
|
|
|
| - void test_importLibrarySdk_withType_invocationTarget() {
|
| + void test_importLibrarySdk_withClass_invocationTarget() {
|
| resolveTestUnit('''
|
| main() {
|
| Future.wait(null);
|
| @@ -2006,7 +1995,7 @@ main() {
|
| ''');
|
| }
|
|
|
| - void test_importLibrarySdk_withType_IsExpression() {
|
| + void test_importLibrarySdk_withClass_IsExpression() {
|
| resolveTestUnit('''
|
| main(p) {
|
| p is Future;
|
| @@ -2021,7 +2010,7 @@ main(p) {
|
| ''');
|
| }
|
|
|
| - void test_importLibrarySdk_withType_typeAnnotation() {
|
| + void test_importLibrarySdk_withClass_typeAnnotation() {
|
| resolveTestUnit('''
|
| main() {
|
| Future f = null;
|
| @@ -2036,7 +2025,7 @@ main() {
|
| ''');
|
| }
|
|
|
| - void test_importLibrarySdk_withType_typeAnnotation_PrefixedIdentifier() {
|
| + void test_importLibrarySdk_withClass_typeAnnotation_PrefixedIdentifier() {
|
| resolveTestUnit('''
|
| main() {
|
| Future.wait;
|
| @@ -2051,7 +2040,7 @@ main() {
|
| ''');
|
| }
|
|
|
| - void test_importLibrarySdk_withType_typeArgument() {
|
| + void test_importLibrarySdk_withClass_typeArgument() {
|
| resolveTestUnit('''
|
| main() {
|
| List<Future> futures = [];
|
| @@ -2066,6 +2055,38 @@ main() {
|
| ''');
|
| }
|
|
|
| + void test_importLibrarySdk_withTopLevelVariable() {
|
| + resolveTestUnit('''
|
| +main() {
|
| + print(PI);
|
| +}
|
| +''');
|
| + performAllAnalysisTasks();
|
| + assertHasFix(FixKind.IMPORT_LIBRARY_SDK, '''
|
| +import 'dart:math';
|
| +
|
| +main() {
|
| + print(PI);
|
| +}
|
| +''');
|
| + }
|
| +
|
| + void test_importLibrarySdk_withTopLevelVariable_annotation() {
|
| + resolveTestUnit('''
|
| +@PI
|
| +main() {
|
| +}
|
| +''');
|
| + performAllAnalysisTasks();
|
| + assertHasFix(FixKind.IMPORT_LIBRARY_SDK, '''
|
| +import 'dart:math';
|
| +
|
| +@PI
|
| +main() {
|
| +}
|
| +''');
|
| + }
|
| +
|
| void test_importLibraryShow() {
|
| resolveTestUnit('''
|
| import 'dart:async' show Stream;
|
|
|