Remove old LSP definitions (#37995)
Last time MultiLspQuery was used in Zed was 0.201.x and Nightly is of 0.205.x version, hence it's time to clean up the old code. Release Notes: - N/A
This commit is contained in:
@@ -3586,7 +3586,6 @@ impl LspStore {
|
||||
pub fn init(client: &AnyProtoClient) {
|
||||
client.add_entity_request_handler(Self::handle_lsp_query);
|
||||
client.add_entity_message_handler(Self::handle_lsp_query_response);
|
||||
client.add_entity_request_handler(Self::handle_multi_lsp_query);
|
||||
client.add_entity_request_handler(Self::handle_restart_language_servers);
|
||||
client.add_entity_request_handler(Self::handle_stop_language_servers);
|
||||
client.add_entity_request_handler(Self::handle_cancel_language_server_work);
|
||||
@@ -3610,9 +3609,7 @@ impl LspStore {
|
||||
client.add_entity_request_handler(Self::handle_register_buffer_with_language_servers);
|
||||
client.add_entity_request_handler(Self::handle_rename_project_entry);
|
||||
client.add_entity_request_handler(Self::handle_pull_workspace_diagnostics);
|
||||
client.add_entity_request_handler(Self::handle_lsp_command::<GetCodeActions>);
|
||||
client.add_entity_request_handler(Self::handle_lsp_command::<GetCompletions>);
|
||||
client.add_entity_request_handler(Self::handle_lsp_command::<GetHover>);
|
||||
client.add_entity_request_handler(Self::handle_lsp_command::<GetDocumentHighlights>);
|
||||
client.add_entity_request_handler(Self::handle_lsp_command::<GetDocumentSymbols>);
|
||||
client.add_entity_request_handler(Self::handle_lsp_command::<PrepareRename>);
|
||||
@@ -3633,7 +3630,6 @@ impl LspStore {
|
||||
client.add_entity_request_handler(
|
||||
Self::handle_lsp_command::<lsp_ext_command::SwitchSourceHeader>,
|
||||
);
|
||||
client.add_entity_request_handler(Self::handle_lsp_command::<GetDocumentDiagnostics>);
|
||||
}
|
||||
|
||||
pub fn as_remote(&self) -> Option<&RemoteLspStore> {
|
||||
@@ -8269,473 +8265,6 @@ impl LspStore {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// todo(lsp) remove after Zed Stable hits v0.204.x
|
||||
async fn handle_multi_lsp_query(
|
||||
lsp_store: Entity<Self>,
|
||||
envelope: TypedEnvelope<proto::MultiLspQuery>,
|
||||
mut cx: AsyncApp,
|
||||
) -> Result<proto::MultiLspQueryResponse> {
|
||||
let response_from_ssh = lsp_store.read_with(&cx, |this, _| {
|
||||
let (upstream_client, project_id) = this.upstream_client()?;
|
||||
let mut payload = envelope.payload.clone();
|
||||
payload.project_id = project_id;
|
||||
|
||||
Some(upstream_client.request(payload))
|
||||
})?;
|
||||
if let Some(response_from_ssh) = response_from_ssh {
|
||||
return response_from_ssh.await;
|
||||
}
|
||||
|
||||
let sender_id = envelope.original_sender_id().unwrap_or_default();
|
||||
let buffer_id = BufferId::new(envelope.payload.buffer_id)?;
|
||||
let version = deserialize_version(&envelope.payload.version);
|
||||
let buffer = lsp_store.update(&mut cx, |this, cx| {
|
||||
this.buffer_store.read(cx).get_existing(buffer_id)
|
||||
})??;
|
||||
buffer
|
||||
.update(&mut cx, |buffer, _| {
|
||||
buffer.wait_for_version(version.clone())
|
||||
})?
|
||||
.await?;
|
||||
let buffer_version = buffer.read_with(&cx, |buffer, _| buffer.version())?;
|
||||
match envelope
|
||||
.payload
|
||||
.strategy
|
||||
.context("invalid request without the strategy")?
|
||||
{
|
||||
proto::multi_lsp_query::Strategy::All(_) => {
|
||||
// currently, there's only one multiple language servers query strategy,
|
||||
// so just ensure it's specified correctly
|
||||
}
|
||||
}
|
||||
match envelope.payload.request {
|
||||
Some(proto::multi_lsp_query::Request::GetHover(message)) => {
|
||||
buffer
|
||||
.update(&mut cx, |buffer, _| {
|
||||
buffer.wait_for_version(deserialize_version(&message.version))
|
||||
})?
|
||||
.await?;
|
||||
let get_hover =
|
||||
GetHover::from_proto(message, lsp_store.clone(), buffer.clone(), cx.clone())
|
||||
.await?;
|
||||
let all_hovers = lsp_store
|
||||
.update(&mut cx, |this, cx| {
|
||||
this.request_multiple_lsp_locally(
|
||||
&buffer,
|
||||
Some(get_hover.position),
|
||||
get_hover,
|
||||
cx,
|
||||
)
|
||||
})?
|
||||
.await
|
||||
.into_iter()
|
||||
.filter_map(|(server_id, hover)| {
|
||||
Some((server_id, remove_empty_hover_blocks(hover?)?))
|
||||
});
|
||||
lsp_store.update(&mut cx, |project, cx| proto::MultiLspQueryResponse {
|
||||
responses: all_hovers
|
||||
.map(|(server_id, hover)| proto::LspResponse {
|
||||
server_id: server_id.to_proto(),
|
||||
response: Some(proto::lsp_response::Response::GetHoverResponse(
|
||||
GetHover::response_to_proto(
|
||||
Some(hover),
|
||||
project,
|
||||
sender_id,
|
||||
&buffer_version,
|
||||
cx,
|
||||
),
|
||||
)),
|
||||
})
|
||||
.collect(),
|
||||
})
|
||||
}
|
||||
Some(proto::multi_lsp_query::Request::GetCodeActions(message)) => {
|
||||
buffer
|
||||
.update(&mut cx, |buffer, _| {
|
||||
buffer.wait_for_version(deserialize_version(&message.version))
|
||||
})?
|
||||
.await?;
|
||||
let get_code_actions = GetCodeActions::from_proto(
|
||||
message,
|
||||
lsp_store.clone(),
|
||||
buffer.clone(),
|
||||
cx.clone(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
let all_actions = lsp_store
|
||||
.update(&mut cx, |project, cx| {
|
||||
project.request_multiple_lsp_locally(
|
||||
&buffer,
|
||||
Some(get_code_actions.range.start),
|
||||
get_code_actions,
|
||||
cx,
|
||||
)
|
||||
})?
|
||||
.await
|
||||
.into_iter();
|
||||
|
||||
lsp_store.update(&mut cx, |project, cx| proto::MultiLspQueryResponse {
|
||||
responses: all_actions
|
||||
.map(|(server_id, code_actions)| proto::LspResponse {
|
||||
server_id: server_id.to_proto(),
|
||||
response: Some(proto::lsp_response::Response::GetCodeActionsResponse(
|
||||
GetCodeActions::response_to_proto(
|
||||
code_actions,
|
||||
project,
|
||||
sender_id,
|
||||
&buffer_version,
|
||||
cx,
|
||||
),
|
||||
)),
|
||||
})
|
||||
.collect(),
|
||||
})
|
||||
}
|
||||
Some(proto::multi_lsp_query::Request::GetSignatureHelp(message)) => {
|
||||
buffer
|
||||
.update(&mut cx, |buffer, _| {
|
||||
buffer.wait_for_version(deserialize_version(&message.version))
|
||||
})?
|
||||
.await?;
|
||||
let get_signature_help = GetSignatureHelp::from_proto(
|
||||
message,
|
||||
lsp_store.clone(),
|
||||
buffer.clone(),
|
||||
cx.clone(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
let all_signatures = lsp_store
|
||||
.update(&mut cx, |project, cx| {
|
||||
project.request_multiple_lsp_locally(
|
||||
&buffer,
|
||||
Some(get_signature_help.position),
|
||||
get_signature_help,
|
||||
cx,
|
||||
)
|
||||
})?
|
||||
.await
|
||||
.into_iter();
|
||||
|
||||
lsp_store.update(&mut cx, |project, cx| proto::MultiLspQueryResponse {
|
||||
responses: all_signatures
|
||||
.map(|(server_id, signature_help)| proto::LspResponse {
|
||||
server_id: server_id.to_proto(),
|
||||
response: Some(
|
||||
proto::lsp_response::Response::GetSignatureHelpResponse(
|
||||
GetSignatureHelp::response_to_proto(
|
||||
signature_help,
|
||||
project,
|
||||
sender_id,
|
||||
&buffer_version,
|
||||
cx,
|
||||
),
|
||||
),
|
||||
),
|
||||
})
|
||||
.collect(),
|
||||
})
|
||||
}
|
||||
Some(proto::multi_lsp_query::Request::GetCodeLens(message)) => {
|
||||
buffer
|
||||
.update(&mut cx, |buffer, _| {
|
||||
buffer.wait_for_version(deserialize_version(&message.version))
|
||||
})?
|
||||
.await?;
|
||||
let get_code_lens =
|
||||
GetCodeLens::from_proto(message, lsp_store.clone(), buffer.clone(), cx.clone())
|
||||
.await?;
|
||||
|
||||
let code_lens_actions = lsp_store
|
||||
.update(&mut cx, |project, cx| {
|
||||
project.request_multiple_lsp_locally(
|
||||
&buffer,
|
||||
None::<usize>,
|
||||
get_code_lens,
|
||||
cx,
|
||||
)
|
||||
})?
|
||||
.await
|
||||
.into_iter();
|
||||
|
||||
lsp_store.update(&mut cx, |project, cx| proto::MultiLspQueryResponse {
|
||||
responses: code_lens_actions
|
||||
.map(|(server_id, actions)| proto::LspResponse {
|
||||
server_id: server_id.to_proto(),
|
||||
response: Some(proto::lsp_response::Response::GetCodeLensResponse(
|
||||
GetCodeLens::response_to_proto(
|
||||
actions,
|
||||
project,
|
||||
sender_id,
|
||||
&buffer_version,
|
||||
cx,
|
||||
),
|
||||
)),
|
||||
})
|
||||
.collect(),
|
||||
})
|
||||
}
|
||||
Some(proto::multi_lsp_query::Request::GetDocumentDiagnostics(message)) => {
|
||||
buffer
|
||||
.update(&mut cx, |buffer, _| {
|
||||
buffer.wait_for_version(deserialize_version(&message.version))
|
||||
})?
|
||||
.await?;
|
||||
lsp_store
|
||||
.update(&mut cx, |lsp_store, cx| {
|
||||
lsp_store.pull_diagnostics_for_buffer(buffer, cx)
|
||||
})?
|
||||
.await?;
|
||||
// `pull_diagnostics_for_buffer` will merge in the new diagnostics and send them to the client.
|
||||
// The client cannot merge anything into its non-local LspStore, so we do not need to return anything.
|
||||
Ok(proto::MultiLspQueryResponse {
|
||||
responses: Vec::new(),
|
||||
})
|
||||
}
|
||||
Some(proto::multi_lsp_query::Request::GetDocumentColor(message)) => {
|
||||
buffer
|
||||
.update(&mut cx, |buffer, _| {
|
||||
buffer.wait_for_version(deserialize_version(&message.version))
|
||||
})?
|
||||
.await?;
|
||||
let get_document_color = GetDocumentColor::from_proto(
|
||||
message,
|
||||
lsp_store.clone(),
|
||||
buffer.clone(),
|
||||
cx.clone(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
let all_colors = lsp_store
|
||||
.update(&mut cx, |project, cx| {
|
||||
project.request_multiple_lsp_locally(
|
||||
&buffer,
|
||||
None::<usize>,
|
||||
get_document_color,
|
||||
cx,
|
||||
)
|
||||
})?
|
||||
.await
|
||||
.into_iter();
|
||||
|
||||
lsp_store.update(&mut cx, |project, cx| proto::MultiLspQueryResponse {
|
||||
responses: all_colors
|
||||
.map(|(server_id, colors)| proto::LspResponse {
|
||||
server_id: server_id.to_proto(),
|
||||
response: Some(
|
||||
proto::lsp_response::Response::GetDocumentColorResponse(
|
||||
GetDocumentColor::response_to_proto(
|
||||
colors,
|
||||
project,
|
||||
sender_id,
|
||||
&buffer_version,
|
||||
cx,
|
||||
),
|
||||
),
|
||||
),
|
||||
})
|
||||
.collect(),
|
||||
})
|
||||
}
|
||||
Some(proto::multi_lsp_query::Request::GetDefinition(message)) => {
|
||||
let get_definitions = GetDefinitions::from_proto(
|
||||
message,
|
||||
lsp_store.clone(),
|
||||
buffer.clone(),
|
||||
cx.clone(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
let definitions = lsp_store
|
||||
.update(&mut cx, |project, cx| {
|
||||
project.request_multiple_lsp_locally(
|
||||
&buffer,
|
||||
Some(get_definitions.position),
|
||||
get_definitions,
|
||||
cx,
|
||||
)
|
||||
})?
|
||||
.await
|
||||
.into_iter();
|
||||
|
||||
lsp_store.update(&mut cx, |project, cx| proto::MultiLspQueryResponse {
|
||||
responses: definitions
|
||||
.map(|(server_id, definitions)| proto::LspResponse {
|
||||
server_id: server_id.to_proto(),
|
||||
response: Some(proto::lsp_response::Response::GetDefinitionResponse(
|
||||
GetDefinitions::response_to_proto(
|
||||
definitions,
|
||||
project,
|
||||
sender_id,
|
||||
&buffer_version,
|
||||
cx,
|
||||
),
|
||||
)),
|
||||
})
|
||||
.collect(),
|
||||
})
|
||||
}
|
||||
Some(proto::multi_lsp_query::Request::GetDeclaration(message)) => {
|
||||
let get_declarations = GetDeclarations::from_proto(
|
||||
message,
|
||||
lsp_store.clone(),
|
||||
buffer.clone(),
|
||||
cx.clone(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
let declarations = lsp_store
|
||||
.update(&mut cx, |project, cx| {
|
||||
project.request_multiple_lsp_locally(
|
||||
&buffer,
|
||||
Some(get_declarations.position),
|
||||
get_declarations,
|
||||
cx,
|
||||
)
|
||||
})?
|
||||
.await
|
||||
.into_iter();
|
||||
|
||||
lsp_store.update(&mut cx, |project, cx| proto::MultiLspQueryResponse {
|
||||
responses: declarations
|
||||
.map(|(server_id, declarations)| proto::LspResponse {
|
||||
server_id: server_id.to_proto(),
|
||||
response: Some(proto::lsp_response::Response::GetDeclarationResponse(
|
||||
GetDeclarations::response_to_proto(
|
||||
declarations,
|
||||
project,
|
||||
sender_id,
|
||||
&buffer_version,
|
||||
cx,
|
||||
),
|
||||
)),
|
||||
})
|
||||
.collect(),
|
||||
})
|
||||
}
|
||||
Some(proto::multi_lsp_query::Request::GetTypeDefinition(message)) => {
|
||||
let get_type_definitions = GetTypeDefinitions::from_proto(
|
||||
message,
|
||||
lsp_store.clone(),
|
||||
buffer.clone(),
|
||||
cx.clone(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
let type_definitions = lsp_store
|
||||
.update(&mut cx, |project, cx| {
|
||||
project.request_multiple_lsp_locally(
|
||||
&buffer,
|
||||
Some(get_type_definitions.position),
|
||||
get_type_definitions,
|
||||
cx,
|
||||
)
|
||||
})?
|
||||
.await
|
||||
.into_iter();
|
||||
|
||||
lsp_store.update(&mut cx, |project, cx| proto::MultiLspQueryResponse {
|
||||
responses: type_definitions
|
||||
.map(|(server_id, type_definitions)| proto::LspResponse {
|
||||
server_id: server_id.to_proto(),
|
||||
response: Some(
|
||||
proto::lsp_response::Response::GetTypeDefinitionResponse(
|
||||
GetTypeDefinitions::response_to_proto(
|
||||
type_definitions,
|
||||
project,
|
||||
sender_id,
|
||||
&buffer_version,
|
||||
cx,
|
||||
),
|
||||
),
|
||||
),
|
||||
})
|
||||
.collect(),
|
||||
})
|
||||
}
|
||||
Some(proto::multi_lsp_query::Request::GetImplementation(message)) => {
|
||||
let get_implementations = GetImplementations::from_proto(
|
||||
message,
|
||||
lsp_store.clone(),
|
||||
buffer.clone(),
|
||||
cx.clone(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
let implementations = lsp_store
|
||||
.update(&mut cx, |project, cx| {
|
||||
project.request_multiple_lsp_locally(
|
||||
&buffer,
|
||||
Some(get_implementations.position),
|
||||
get_implementations,
|
||||
cx,
|
||||
)
|
||||
})?
|
||||
.await
|
||||
.into_iter();
|
||||
|
||||
lsp_store.update(&mut cx, |project, cx| proto::MultiLspQueryResponse {
|
||||
responses: implementations
|
||||
.map(|(server_id, implementations)| proto::LspResponse {
|
||||
server_id: server_id.to_proto(),
|
||||
response: Some(
|
||||
proto::lsp_response::Response::GetImplementationResponse(
|
||||
GetImplementations::response_to_proto(
|
||||
implementations,
|
||||
project,
|
||||
sender_id,
|
||||
&buffer_version,
|
||||
cx,
|
||||
),
|
||||
),
|
||||
),
|
||||
})
|
||||
.collect(),
|
||||
})
|
||||
}
|
||||
Some(proto::multi_lsp_query::Request::GetReferences(message)) => {
|
||||
let get_references = GetReferences::from_proto(
|
||||
message,
|
||||
lsp_store.clone(),
|
||||
buffer.clone(),
|
||||
cx.clone(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
let references = lsp_store
|
||||
.update(&mut cx, |project, cx| {
|
||||
project.request_multiple_lsp_locally(
|
||||
&buffer,
|
||||
Some(get_references.position),
|
||||
get_references,
|
||||
cx,
|
||||
)
|
||||
})?
|
||||
.await
|
||||
.into_iter();
|
||||
|
||||
lsp_store.update(&mut cx, |project, cx| proto::MultiLspQueryResponse {
|
||||
responses: references
|
||||
.map(|(server_id, references)| proto::LspResponse {
|
||||
server_id: server_id.to_proto(),
|
||||
response: Some(proto::lsp_response::Response::GetReferencesResponse(
|
||||
GetReferences::response_to_proto(
|
||||
references,
|
||||
project,
|
||||
sender_id,
|
||||
&buffer_version,
|
||||
cx,
|
||||
),
|
||||
)),
|
||||
})
|
||||
.collect(),
|
||||
})
|
||||
}
|
||||
None => anyhow::bail!("empty multi lsp query request"),
|
||||
}
|
||||
}
|
||||
|
||||
async fn handle_apply_code_action(
|
||||
this: Entity<Self>,
|
||||
envelope: TypedEnvelope<proto::ApplyCodeAction>,
|
||||
|
||||
Reference in New Issue
Block a user