From 1bdb366d4da71edeef13cfce1f0942ce6d0f8af1 Mon Sep 17 00:00:00 2001 From: pq Date: Tue, 10 Sep 2024 17:23:40 +0000 Subject: [PATCH] =?UTF-8?q?[enhanced-parts]=20test=20=E2=80=9COrganize=20I?= =?UTF-8?q?mports=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: https://github.com/dart-lang/sdk/issues/56683 Change-Id: I6b6aae385d4313e551f7c110e1e2544cc418a5a8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384308 Commit-Queue: Phil Quitslund Reviewed-by: Brian Wilkerson Auto-Submit: Phil Quitslund --- .../correction/fix/fix_processor.dart | 3 +- .../correction/fix/organize_imports_test.dart | 56 +++++++++++++++++-- 2 files changed, 54 insertions(+), 5 deletions(-) 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;