From 6fed0f75270cfc4f7a7dbfe9edfe0c3089c6ebf4 Mon Sep 17 00:00:00 2001 From: Danny Tuppeny Date: Thu, 4 Jun 2026 11:29:49 -0700 Subject: [PATCH] [analysis_server] Remove some unnecessary code related to original interactive refactors When we built the added the original interactive refactors support, we supported the client telling the server which field kinds it can prompt for, so that if there were questions the client didn't support that did not have default values, the refactor could be hidden. However, we only implemented one such refactor (Move to File) and the only field (destination URI) has a default value, so the client capabilities never have any effect. Since we're replacing this support with the new "Interactive Forms" and don't intend to create any new refactors using the old system, this code is all redundant and therefore can be deleted. Change-Id: Ic940dc54e325ccab05b28f496dbedee76e17e0b4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/509460 Reviewed-by: Samuel Rawlins Reviewed-by: Brian Wilkerson --- .../lib/src/lsp/client_capabilities.dart | 23 --------------- .../framework/refactoring_processor.dart | 16 ++++------ .../framework/refactoring_producer.dart | 10 ------- .../test/lsp/initialization_test.dart | 29 ------------------- .../test/lsp/server_abstract.dart | 6 ---- .../move_top_level_to_file_test.dart | 15 +++------- .../tool/lsp_spec/meta_model.dart | 12 -------- 7 files changed, 10 insertions(+), 101 deletions(-) diff --git a/pkg/analysis_server/lib/src/lsp/client_capabilities.dart b/pkg/analysis_server/lib/src/lsp/client_capabilities.dart index ed3898e727d..dba5a441ae2 100644 --- a/pkg/analysis_server/lib/src/lsp/client_capabilities.dart +++ b/pkg/analysis_server/lib/src/lsp/client_capabilities.dart @@ -104,7 +104,6 @@ class LspClientCapabilities { final bool completionDefaultEditRange; final bool completionDefaultTextMode; final bool experimentalSnippetTextEdit; - final Set codeActionCommandParameterSupportedKinds; final Set supportedInteractiveFormInputTypes; final bool supportsShowMessageRequest; @@ -224,8 +223,6 @@ class LspClientCapabilities { completionDefaultEditRange: completionDefaultEditRange, completionDefaultTextMode: completionDefaultTextMode, experimentalSnippetTextEdit: experimental.snippetTextEdit, - codeActionCommandParameterSupportedKinds: - experimental.commandParameterKinds, supportedInteractiveFormInputTypes: experimental.interactiveFormInputTypes, supportsShowMessageRequest: experimental.showMessageRequest, @@ -267,7 +264,6 @@ class LspClientCapabilities { required this.completionDefaultEditRange, required this.completionDefaultTextMode, required this.experimentalSnippetTextEdit, - required this.codeActionCommandParameterSupportedKinds, required this.supportedInteractiveFormInputTypes, required this.supportsShowMessageRequest, required this.supportedCommands, @@ -294,14 +290,12 @@ class _ExperimentalClientCapabilities { final List errors; final bool snippetTextEdit; - final Set commandParameterKinds; final Set interactiveFormInputTypes; final Set commands; final bool showMessageRequest; new({ required this.snippetTextEdit, - required this.commandParameterKinds, required this.interactiveFormInputTypes, required this.commands, required this.showMessageRequest, @@ -352,22 +346,6 @@ class _ExperimentalClientCapabilities { experimental['snippetTextEdit'], ); - // Refactor command parameters. - var experimentalActions = expectMap( - '.dartCodeAction', - experimental['dartCodeAction'], - ); - experimentalActions ??= const {}; - var commandParameters = expectMap( - '.dartCodeAction.commandParameterSupport', - experimentalActions['commandParameterSupport'], - ); - commandParameters ??= {}; - var commandParameterKinds = expectNullableStringSet( - '.dartCodeAction.commandParameterSupport.supportedKinds', - commandParameters['supportedKinds'], - ); - // Interactive Forms. var interactiveForms = expectMap( '.interactiveResolve', @@ -399,7 +377,6 @@ class _ExperimentalClientCapabilities { return _ExperimentalClientCapabilities( snippetTextEdit: snippetTextEdit ?? false, - commandParameterKinds: commandParameterKinds ?? {}, interactiveFormInputTypes: interactiveFormInputTypes ?? {}, commands: commands ?? {}, showMessageRequest: showMessageRequest ?? false, diff --git a/pkg/analysis_server/lib/src/services/refactoring/framework/refactoring_processor.dart b/pkg/analysis_server/lib/src/services/refactoring/framework/refactoring_processor.dart index 6a56e245459..6fb16254d6b 100644 --- a/pkg/analysis_server/lib/src/services/refactoring/framework/refactoring_processor.dart +++ b/pkg/analysis_server/lib/src/services/refactoring/framework/refactoring_processor.dart @@ -92,17 +92,13 @@ class RefactoringProcessor { ? producer.parameters : []; // In debug mode, throw if we produced a refactoring that has parameters - // without default values that are not supported by the client. + // without default values. Support for fields without defaults was + // removed since this functionality was replaced by Interactive Forms, + // the only existing interactive refactor always has one, and we do not + // intend to add any more. assert( - () { - return parameters.every( - (parameter) => - parameter.defaultValue != null || - producer.supportsCommandParameter(parameter.kind), - ); - }(), - '${producer.title} refactor returned parameters without defaults ' - 'that are not supported by the client', + parameters.every((parameter) => parameter.defaultValue != null), + '${producer.title} refactor returned parameters without defaults', ); var command = entry.key; diff --git a/pkg/analysis_server/lib/src/services/refactoring/framework/refactoring_producer.dart b/pkg/analysis_server/lib/src/services/refactoring/framework/refactoring_producer.dart index 9e8111f7c49..78990dbd02e 100644 --- a/pkg/analysis_server/lib/src/services/refactoring/framework/refactoring_producer.dart +++ b/pkg/analysis_server/lib/src/services/refactoring/framework/refactoring_producer.dart @@ -186,14 +186,4 @@ abstract class RefactoringProducer { bool selectionIsInToken(Token? token) { return refactoringContext.selectionIsInToken(token); } - - /// Return `true` if the client has support for command parameters of the - /// provided `kind`. Subclasses that produce command parameters of this kind - /// that don't have a default value must not create a refactoring if this - /// returns `false`. - bool supportsCommandParameter(String kind) { - var capabilities = refactoringContext.clientCapabilities; - return capabilities != null && - capabilities.codeActionCommandParameterSupportedKinds.contains(kind); - } } diff --git a/pkg/analysis_server/test/lsp/initialization_test.dart b/pkg/analysis_server/test/lsp/initialization_test.dart index b584233cb57..feeb505acad 100644 --- a/pkg/analysis_server/test/lsp/initialization_test.dart +++ b/pkg/analysis_server/test/lsp/initialization_test.dart @@ -1114,35 +1114,6 @@ class InitializationTest extends AbstractLspAnalysisServerTest { }, 'ClientCapabilities.experimental.commands must be a List?'); } - Future test_invalidExperimental_dartCodeAction() async { - await expectInvalidExperimentalParams( - {'dartCodeAction': 1}, - 'ClientCapabilities.experimental.dartCodeAction must be a Map?', - ); - } - - Future - test_invalidExperimental_dartCodeAction_commandParameterSupport() async { - await expectInvalidExperimentalParams( - { - 'dartCodeAction': {'commandParameterSupport': 1}, - }, - 'ClientCapabilities.experimental.dartCodeAction.commandParameterSupport must be a Map?', - ); - } - - Future - test_invalidExperimental_dartCodeAction_commandParameterSupport_supportedKinds() async { - await expectInvalidExperimentalParams( - { - 'dartCodeAction': { - 'commandParameterSupport': {'supportedKinds': 1}, - }, - }, - 'ClientCapabilities.experimental.dartCodeAction.commandParameterSupport.supportedKinds must be a List?', - ); - } - Future test_invalidExperimental_snippetTextEdit() async { await expectInvalidExperimentalParams({ 'snippetTextEdit': 1, diff --git a/pkg/analysis_server/test/lsp/server_abstract.dart b/pkg/analysis_server/test/lsp/server_abstract.dart index c82e340bd58..4baec15ac68 100644 --- a/pkg/analysis_server/test/lsp/server_abstract.dart +++ b/pkg/analysis_server/test/lsp/server_abstract.dart @@ -780,12 +780,6 @@ mixin ClientCapabilitiesHelperMixin { ); } - void setSupportedCommandParameterKinds(Set? kinds) { - experimentalCapabilities['dartCodeAction'] = { - 'commandParameterSupport': {'supportedKinds': kinds?.toList()}, - }; - } - void setSupportedInteractiveFormInputKinds(Set? inputTypes) { const parentKey = 'interactiveResolve'; const inputTypesKey = 'inputTypes'; 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 e95911ffd07..8c80beca362 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 @@ -1424,19 +1424,12 @@ class A {}<<<<<<<<<< ); } - Future - test_protocol_available_withClientCommandParameterSupport() async { + Future test_protocol_available() async { addTestSource(simpleClassContent); await initializeServer(); - await expectCodeActionWithTitle(simpleClassRefactorTitle); - } - - Future - test_protocol_available_withoutClientCommandParameterSupport() async { - addTestSource(simpleClassContent); - await initializeServer(); - // This refactor is available without command parameter support because - // it has defaults. + // This refactor is available regardless of command parameter support + // because it has a default value for the only field which is coded into + // the arguments by default. await expectCodeActionWithTitle(simpleClassRefactorTitle); } diff --git a/pkg/analysis_server/tool/lsp_spec/meta_model.dart b/pkg/analysis_server/tool/lsp_spec/meta_model.dart index bddebc1fd7f..c5b92cc8d28 100644 --- a/pkg/analysis_server/tool/lsp_spec/meta_model.dart +++ b/pkg/analysis_server/tool/lsp_spec/meta_model.dart @@ -82,18 +82,6 @@ class Field extends Member { }); } -class FixedValueField extends Field { - final String value; - new({ - required super.name, - super.comment, - required this.value, - required super.type, - required super.allowsNull, - required super.allowsUndefined, - }); -} - /// An interface/class parsed from the LSP JSON model. class Interface extends LspEntity { final List baseTypes;