diff --git a/pkg/analysis_server/test/src/services/correction/fix/fix_processor.dart b/pkg/analysis_server/test/src/services/correction/fix/fix_processor.dart index a101d9bc2df..bc2cbc3ab34 100644 --- a/pkg/analysis_server/test/src/services/correction/fix/fix_processor.dart +++ b/pkg/analysis_server/test/src/services/correction/fix/fix_processor.dart @@ -17,6 +17,7 @@ import 'package:analyzer/src/services/available_declarations.dart'; import 'package:analyzer_plugin/protocol/protocol_common.dart' hide AnalysisError; import 'package:analyzer_plugin/utilities/fixes/fixes.dart'; +import 'package:analyzer_utilities/test/experiments/experiments.dart'; import 'package:meta/meta.dart'; import 'package:test/test.dart'; @@ -89,7 +90,7 @@ abstract class BulkFixProcessorTest extends AbstractSingleUnitTest { late BulkFixProcessor processor; @override - List get experiments => const []; + List get experiments => experimentsForTests; /// The name of the lint code being tested. String? get lintCode => null; diff --git a/pkg/analysis_server/test/src/services/correction/fix/organize_imports_test.dart b/pkg/analysis_server/test/src/services/correction/fix/organize_imports_test.dart index 286057a90f6..d13772f7f10 100644 --- a/pkg/analysis_server/test/src/services/correction/fix/organize_imports_test.dart +++ b/pkg/analysis_server/test/src/services/correction/fix/organize_imports_test.dart @@ -12,31 +12,79 @@ import 'fix_processor.dart'; void main() { defineReflectiveSuite(() { defineReflectiveTests(OrganizeImportsBulkTest); - defineReflectiveTests(OrganizeImportsTest); + defineReflectiveTests(OrganizeImportsDirectivesOrderingTest); }); } @reflectiveTest class OrganizeImportsBulkTest extends BulkFixProcessorTest { + Future test_partFile() async { + newFile('$testPackageLibPath/a.dart', r''' +part 'test.dart'; +'''); + + await resolveTestCode(''' +part of 'a.dart'; + +import 'dart:io'; +import 'dart:async'; + +Future? a; +'''); + + await assertOrganize(''' +part of 'a.dart'; + +import 'dart:async'; +import 'dart:io'; + +Future? a; +'''); + } + Future test_single_file() async { await parseTestCode(''' import 'dart:io'; import 'dart:async'; -Future a; +Future? a; '''); await assertOrganize(''' import 'dart:async'; import 'dart:io'; -Future a; +Future? a; +'''); + } + + Future test_withParts() async { + newFile('$testPackageLibPath/a.dart', r''' +part of 'test.dart'; +'''); + + await parseTestCode(''' +import 'dart:io'; +import 'dart:async'; + +part 'a.dart'; + +Future? a; +'''); + + await assertOrganize(''' +import 'dart:async'; +import 'dart:io'; + +part 'a.dart'; + +Future? a; '''); } } @reflectiveTest -class OrganizeImportsTest extends FixProcessorLintTest { +class OrganizeImportsDirectivesOrderingTest extends FixProcessorLintTest { @override FixKind get kind => DartFixKind.ORGANIZE_IMPORTS;