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