mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-16 00:47:39 +03:00
lsp: Use LspCommand.check_capabilities
consistently (#14733)
This is a follow-up to #14666 in which I noticed that we don't need that additional check, since each request will check whether it's supported via the call to `check_capabilities` before sending the request. Release Notes: - N/A
This commit is contained in:
parent
80558a3986
commit
76ce1a8f50
@ -1354,6 +1354,14 @@ impl LspCommand for GetHover {
|
||||
type LspRequest = lsp::request::HoverRequest;
|
||||
type ProtoRequest = proto::GetHover;
|
||||
|
||||
fn check_capabilities(&self, capabilities: AdapterServerCapabilities) -> bool {
|
||||
match capabilities.server_capabilities.hover_provider {
|
||||
Some(lsp::HoverProviderCapability::Simple(enabled)) => enabled,
|
||||
Some(lsp::HoverProviderCapability::Options(_)) => true,
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn to_lsp(
|
||||
&self,
|
||||
path: &Path,
|
||||
@ -2062,17 +2070,6 @@ impl GetCodeActions {
|
||||
})
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
pub fn supports_code_actions(capabilities: &ServerCapabilities) -> bool {
|
||||
capabilities
|
||||
.code_action_provider
|
||||
.as_ref()
|
||||
.map(|options| match options {
|
||||
lsp::CodeActionProviderCapability::Simple(is_supported) => *is_supported,
|
||||
lsp::CodeActionProviderCapability::Options(_) => true,
|
||||
})
|
||||
.unwrap_or(false)
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait(?Send)]
|
||||
|
@ -61,7 +61,7 @@ use lsp::{
|
||||
CompletionContext, DiagnosticSeverity, DiagnosticTag, DidChangeWatchedFilesRegistrationOptions,
|
||||
DocumentHighlightKind, Edit, FileSystemWatcher, InsertTextFormat, LanguageServer,
|
||||
LanguageServerBinary, LanguageServerId, LspRequestFuture, MessageActionItem, OneOf,
|
||||
ServerCapabilities, ServerHealthStatus, ServerStatus, TextEdit, WorkDoneProgressCancelParams,
|
||||
ServerHealthStatus, ServerStatus, TextEdit, WorkDoneProgressCancelParams,
|
||||
};
|
||||
use lsp_command::*;
|
||||
use node_runtime::NodeRuntime;
|
||||
@ -5621,7 +5621,6 @@ impl Project {
|
||||
let all_actions_task = self.request_multiple_lsp_locally(
|
||||
buffer,
|
||||
Some(position),
|
||||
|server_capabilities| server_capabilities.signature_help_provider.is_some(),
|
||||
GetSignatureHelp { position },
|
||||
cx,
|
||||
);
|
||||
@ -5696,11 +5695,6 @@ impl Project {
|
||||
let all_actions_task = self.request_multiple_lsp_locally(
|
||||
&buffer,
|
||||
Some(position),
|
||||
|server_capabilities| match server_capabilities.hover_provider {
|
||||
Some(lsp::HoverProviderCapability::Simple(enabled)) => enabled,
|
||||
Some(lsp::HoverProviderCapability::Options(_)) => true,
|
||||
None => false,
|
||||
},
|
||||
GetHover { position },
|
||||
cx,
|
||||
);
|
||||
@ -6286,7 +6280,6 @@ impl Project {
|
||||
let all_actions_task = self.request_multiple_lsp_locally(
|
||||
&buffer_handle,
|
||||
Some(range.start),
|
||||
GetCodeActions::supports_code_actions,
|
||||
GetCodeActions {
|
||||
range: range.clone(),
|
||||
kinds: None,
|
||||
@ -7431,7 +7424,6 @@ impl Project {
|
||||
&self,
|
||||
buffer: &Model<Buffer>,
|
||||
position: Option<P>,
|
||||
server_capabilities_check: fn(&ServerCapabilities) -> bool,
|
||||
request: R,
|
||||
cx: &mut ModelContext<'_, Self>,
|
||||
) -> Task<Vec<R::Response>>
|
||||
@ -7449,7 +7441,6 @@ impl Project {
|
||||
let scope = position.and_then(|position| snapshot.language_scope_at(position));
|
||||
let mut response_results = self
|
||||
.language_servers_for_buffer(buffer.read(cx), cx)
|
||||
.filter(|(_, server)| server_capabilities_check(&server.capabilities()))
|
||||
.filter(|(adapter, _)| {
|
||||
scope
|
||||
.as_ref()
|
||||
@ -8575,11 +8566,6 @@ impl Project {
|
||||
project.request_multiple_lsp_locally(
|
||||
&buffer,
|
||||
Some(get_hover.position),
|
||||
|server_capabilities| match server_capabilities.hover_provider {
|
||||
Some(lsp::HoverProviderCapability::Simple(enabled)) => enabled,
|
||||
Some(lsp::HoverProviderCapability::Options(_)) => true,
|
||||
None => false,
|
||||
},
|
||||
get_hover,
|
||||
cx,
|
||||
)
|
||||
@ -8617,7 +8603,6 @@ impl Project {
|
||||
project.request_multiple_lsp_locally(
|
||||
&buffer,
|
||||
Some(get_code_actions.range.start),
|
||||
GetCodeActions::supports_code_actions,
|
||||
get_code_actions,
|
||||
cx,
|
||||
)
|
||||
@ -8655,9 +8640,6 @@ impl Project {
|
||||
project.request_multiple_lsp_locally(
|
||||
&buffer,
|
||||
Some(get_signature_help.position),
|
||||
|server_capabilities| {
|
||||
server_capabilities.signature_help_provider.is_some()
|
||||
},
|
||||
get_signature_help,
|
||||
cx,
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user