project: Remove redundant Option from parse_register_capabilities (#36874)

Release Notes:

- N/A
This commit is contained in:
Smit Barmase 2025-08-25 21:00:53 +05:30 committed by GitHub
parent fda5111dc0
commit 2fe3dbed31
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -11706,13 +11706,12 @@ impl LspStore {
// Ignore payload since we notify clients of setting changes unconditionally, relying on them pulling the latest settings.
}
"workspace/symbol" => {
if let Some(options) = parse_register_capabilities(reg)? {
let options = parse_register_capabilities(reg)?;
server.update_capabilities(|capabilities| {
capabilities.workspace_symbol_provider = Some(options);
});
notify_server_capabilities_updated(&server, cx);
}
}
"workspace/fileOperations" => {
if let Some(options) = reg.register_options {
let caps = serde_json::from_value(options)?;
@ -11735,13 +11734,12 @@ impl LspStore {
}
}
"textDocument/rangeFormatting" => {
if let Some(options) = parse_register_capabilities(reg)? {
let options = parse_register_capabilities(reg)?;
server.update_capabilities(|capabilities| {
capabilities.document_range_formatting_provider = Some(options);
});
notify_server_capabilities_updated(&server, cx);
}
}
"textDocument/onTypeFormatting" => {
if let Some(options) = reg
.register_options
@ -11755,37 +11753,33 @@ impl LspStore {
}
}
"textDocument/formatting" => {
if let Some(options) = parse_register_capabilities(reg)? {
let options = parse_register_capabilities(reg)?;
server.update_capabilities(|capabilities| {
capabilities.document_formatting_provider = Some(options);
});
notify_server_capabilities_updated(&server, cx);
}
}
"textDocument/rename" => {
if let Some(options) = parse_register_capabilities(reg)? {
let options = parse_register_capabilities(reg)?;
server.update_capabilities(|capabilities| {
capabilities.rename_provider = Some(options);
});
notify_server_capabilities_updated(&server, cx);
}
}
"textDocument/inlayHint" => {
if let Some(options) = parse_register_capabilities(reg)? {
let options = parse_register_capabilities(reg)?;
server.update_capabilities(|capabilities| {
capabilities.inlay_hint_provider = Some(options);
});
notify_server_capabilities_updated(&server, cx);
}
}
"textDocument/documentSymbol" => {
if let Some(options) = parse_register_capabilities(reg)? {
let options = parse_register_capabilities(reg)?;
server.update_capabilities(|capabilities| {
capabilities.document_symbol_provider = Some(options);
});
notify_server_capabilities_updated(&server, cx);
}
}
"textDocument/codeAction" => {
if let Some(options) = reg
.register_options
@ -11800,13 +11794,12 @@ impl LspStore {
}
}
"textDocument/definition" => {
if let Some(options) = parse_register_capabilities(reg)? {
let options = parse_register_capabilities(reg)?;
server.update_capabilities(|capabilities| {
capabilities.definition_provider = Some(options);
});
notify_server_capabilities_updated(&server, cx);
}
}
"textDocument/completion" => {
if let Some(caps) = reg
.register_options
@ -12184,10 +12177,10 @@ impl LspStore {
// https://github.com/microsoft/vscode-languageserver-node/blob/d90a87f9557a0df9142cfb33e251cfa6fe27d970/client/src/common/client.ts#L2133
fn parse_register_capabilities<T: serde::de::DeserializeOwned>(
reg: lsp::Registration,
) -> anyhow::Result<Option<OneOf<bool, T>>> {
) -> Result<OneOf<bool, T>> {
Ok(match reg.register_options {
Some(options) => Some(OneOf::Right(serde_json::from_value::<T>(options)?)),
None => Some(OneOf::Left(true)),
Some(options) => OneOf::Right(serde_json::from_value::<T>(options)?),
None => OneOf::Left(true),
})
}