Verify that `move_top_level_to_file` does not change macro generated code
See https://dart-review.googlesource.com/c/sdk/+/353780 for the general approach to adding macro test support.
Open: is there a better way to get macro-generated source?
Change-Id: Ib5cda2f8e48bdbfc639ee3e9513e4d43a482bb85
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/354705
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
diff --git a/pkg/analysis_server/test/lsp/server_abstract.dart b/pkg/analysis_server/test/lsp/server_abstract.dart
index 3562689..a7a8e16 100644
--- a/pkg/analysis_server/test/lsp/server_abstract.dart
+++ b/pkg/analysis_server/test/lsp/server_abstract.dart
@@ -33,6 +33,7 @@
import '../mocks_lsp.dart';
import '../src/utilities/mock_packages.dart';
import '../support/configuration_files.dart';
+import '../test_macros.dart';
import 'change_verifier.dart';
import 'request_helpers_mixin.dart';
@@ -51,7 +52,8 @@
LspVerifyEditHelpersMixin,
LspAnalysisServerTestMixin,
MockPackagesMixin,
- ConfigurationFilesMixin {
+ ConfigurationFilesMixin,
+ TestMacros {
late MockLspServerChannel channel;
late TestPluginManager pluginManager;
late LspAnalysisServer server;
diff --git a/pkg/analysis_server/test/src/services/refactoring/move_top_level_to_file_test.dart b/pkg/analysis_server/test/src/services/refactoring/move_top_level_to_file_test.dart
index 751f3fb..43a2035 100644
--- a/pkg/analysis_server/test/src/services/refactoring/move_top_level_to_file_test.dart
+++ b/pkg/analysis_server/test/src/services/refactoring/move_top_level_to_file_test.dart
@@ -1060,6 +1060,39 @@
);
}
+ Future<void> test_kind_class_referencedInMacro() async {
+ addMacros([declareInTypeMacro()]);
+
+ var originalSource = '''
+import 'macros.dart';
+
+class ClassToMove^ {}
+
+@DeclareInType(' ClassToMove? c;')
+class A {}
+''';
+ var declarationName = 'ClassToMove';
+
+ var expected = '''
+>>>>>>>>>> lib/class_to_move.dart created
+class ClassToMove {}
+>>>>>>>>>> lib/main.dart
+import 'package:test/class_to_move.dart';
+
+import 'macros.dart';
+
+@DeclareInType(' ClassToMove? c;')
+class A {}
+''';
+
+ // Perform and verify the move.
+ await _singleDeclaration(
+ originalSource: originalSource,
+ expected: expected,
+ declarationName: declarationName,
+ );
+ }
+
Future<void> test_kind_extensionType() async {
var originalSource = '''
class A {}