project: Remove redundant Option from parse_register_capabilities (#36874)
Release Notes: - N/A
This commit is contained in:
parent
fda5111dc0
commit
2fe3dbed31
1 changed files with 38 additions and 45 deletions
|
@ -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),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue