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,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),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue