[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 <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
Danny Tuppeny
2026-06-04 11:29:49 -07:00
committed by Brian Wilkerson
parent 050afdb4ae
commit 6fed0f7527
7 changed files with 10 additions and 101 deletions
@@ -104,7 +104,6 @@ class LspClientCapabilities {
final bool completionDefaultEditRange;
final bool completionDefaultTextMode;
final bool experimentalSnippetTextEdit;
final Set<String> codeActionCommandParameterSupportedKinds;
final Set<String> 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<String> errors;
final bool snippetTextEdit;
final Set<String> commandParameterKinds;
final Set<String> interactiveFormInputTypes;
final Set<String> 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,
@@ -92,17 +92,13 @@ class RefactoringProcessor {
? producer.parameters
: <CommandParameter>[];
// 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;
@@ -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);
}
}
@@ -1114,35 +1114,6 @@ class InitializationTest extends AbstractLspAnalysisServerTest {
}, 'ClientCapabilities.experimental.commands must be a List<String>?');
}
Future<void> test_invalidExperimental_dartCodeAction() async {
await expectInvalidExperimentalParams(
{'dartCodeAction': 1},
'ClientCapabilities.experimental.dartCodeAction must be a Map<String, Object?>?',
);
}
Future<void>
test_invalidExperimental_dartCodeAction_commandParameterSupport() async {
await expectInvalidExperimentalParams(
{
'dartCodeAction': {'commandParameterSupport': 1},
},
'ClientCapabilities.experimental.dartCodeAction.commandParameterSupport must be a Map<String, Object?>?',
);
}
Future<void>
test_invalidExperimental_dartCodeAction_commandParameterSupport_supportedKinds() async {
await expectInvalidExperimentalParams(
{
'dartCodeAction': {
'commandParameterSupport': {'supportedKinds': 1},
},
},
'ClientCapabilities.experimental.dartCodeAction.commandParameterSupport.supportedKinds must be a List<String>?',
);
}
Future<void> test_invalidExperimental_snippetTextEdit() async {
await expectInvalidExperimentalParams({
'snippetTextEdit': 1,
@@ -780,12 +780,6 @@ mixin ClientCapabilitiesHelperMixin {
);
}
void setSupportedCommandParameterKinds(Set<String>? kinds) {
experimentalCapabilities['dartCodeAction'] = {
'commandParameterSupport': {'supportedKinds': kinds?.toList()},
};
}
void setSupportedInteractiveFormInputKinds(Set<String>? inputTypes) {
const parentKey = 'interactiveResolve';
const inputTypesKey = 'inputTypes';
@@ -1424,19 +1424,12 @@ class A {}<<<<<<<<<<
);
}
Future<void>
test_protocol_available_withClientCommandParameterSupport() async {
Future<void> test_protocol_available() async {
addTestSource(simpleClassContent);
await initializeServer();
await expectCodeActionWithTitle(simpleClassRefactorTitle);
}
Future<void>
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);
}
@@ -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<TypeReference> baseTypes;