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;