lsp: Revert URL type change (#13193)

This reverts URI changes made in
https://github.com/zed-industries/zed/pull/12928 while keeping the perf
goodies in tact. We should keep an eye out for
https://github.com/gluon-lang/lsp-types/issues/284
Fixes: https://github.com/zed-industries/zed/issues/13135
Fixes: https://github.com/zed-industries/zed/issues/13131
Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2024-06-18 12:39:56 +02:00 committed by GitHub
parent 479c5df491
commit 3a26a4809d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 189 additions and 344 deletions

View file

@ -187,7 +187,7 @@ impl LspCommand for PrepareRename {
) -> lsp::TextDocumentPositionParams {
lsp::TextDocumentPositionParams {
text_document: lsp::TextDocumentIdentifier {
uri: lsp::Uri::from_file_path(path).unwrap().into(),
uri: lsp::Url::from_file_path(path).unwrap(),
},
position: point_to_lsp(self.position),
}
@ -311,7 +311,7 @@ impl LspCommand for PerformRename {
lsp::RenameParams {
text_document_position: lsp::TextDocumentPositionParams {
text_document: lsp::TextDocumentIdentifier {
uri: lsp::Uri::from_file_path(path).unwrap().into(),
uri: lsp::Url::from_file_path(path).unwrap(),
},
position: point_to_lsp(self.position),
},
@ -430,7 +430,7 @@ impl LspCommand for GetDefinition {
lsp::GotoDefinitionParams {
text_document_position_params: lsp::TextDocumentPositionParams {
text_document: lsp::TextDocumentIdentifier {
uri: lsp::Uri::from_file_path(path).unwrap().into(),
uri: lsp::Url::from_file_path(path).unwrap(),
},
position: point_to_lsp(self.position),
},
@ -523,7 +523,7 @@ impl LspCommand for GetImplementation {
lsp::GotoImplementationParams {
text_document_position_params: lsp::TextDocumentPositionParams {
text_document: lsp::TextDocumentIdentifier {
uri: lsp::Uri::from_file_path(path).unwrap().into(),
uri: lsp::Url::from_file_path(path).unwrap(),
},
position: point_to_lsp(self.position),
},
@ -624,7 +624,7 @@ impl LspCommand for GetTypeDefinition {
lsp::GotoTypeDefinitionParams {
text_document_position_params: lsp::TextDocumentPositionParams {
text_document: lsp::TextDocumentIdentifier {
uri: lsp::Uri::from_file_path(path).unwrap().into(),
uri: lsp::Url::from_file_path(path).unwrap(),
},
position: point_to_lsp(self.position),
},
@ -820,7 +820,7 @@ async fn location_links_from_lsp(
let target_buffer_handle = project
.update(&mut cx, |this, cx| {
this.open_local_buffer_via_lsp(
target_uri.into(),
target_uri,
language_server.server_id(),
lsp_adapter.name.clone(),
cx,
@ -927,7 +927,7 @@ impl LspCommand for GetReferences {
lsp::ReferenceParams {
text_document_position: lsp::TextDocumentPositionParams {
text_document: lsp::TextDocumentIdentifier {
uri: lsp::Uri::from_file_path(path).unwrap().into(),
uri: lsp::Url::from_file_path(path).unwrap(),
},
position: point_to_lsp(self.position),
},
@ -956,7 +956,7 @@ impl LspCommand for GetReferences {
let target_buffer_handle = project
.update(&mut cx, |this, cx| {
this.open_local_buffer_via_lsp(
lsp_location.uri.into(),
lsp_location.uri,
language_server.server_id(),
lsp_adapter.name.clone(),
cx,
@ -1094,7 +1094,7 @@ impl LspCommand for GetDocumentHighlights {
lsp::DocumentHighlightParams {
text_document_position_params: lsp::TextDocumentPositionParams {
text_document: lsp::TextDocumentIdentifier {
uri: lsp::Uri::from_file_path(path).unwrap().into(),
uri: lsp::Url::from_file_path(path).unwrap(),
},
position: point_to_lsp(self.position),
},
@ -1241,7 +1241,7 @@ impl LspCommand for GetHover {
lsp::HoverParams {
text_document_position_params: lsp::TextDocumentPositionParams {
text_document: lsp::TextDocumentIdentifier {
uri: lsp::Uri::from_file_path(path).unwrap().into(),
uri: lsp::Url::from_file_path(path).unwrap(),
},
position: point_to_lsp(self.position),
},
@ -1463,7 +1463,7 @@ impl LspCommand for GetCompletions {
) -> lsp::CompletionParams {
lsp::CompletionParams {
text_document_position: lsp::TextDocumentPositionParams::new(
lsp::TextDocumentIdentifier::new(lsp::Uri::from_file_path(path).unwrap().into()),
lsp::TextDocumentIdentifier::new(lsp::Url::from_file_path(path).unwrap()),
point_to_lsp(self.position),
),
context: Some(self.context.clone()),
@ -1768,7 +1768,7 @@ impl LspCommand for GetCodeActions {
lsp::CodeActionParams {
text_document: lsp::TextDocumentIdentifier::new(
lsp::Uri::from_file_path(path).unwrap().into(),
lsp::Url::from_file_path(path).unwrap(),
),
range: range_to_lsp(self.range.to_point_utf16(buffer)),
work_done_progress_params: Default::default(),
@ -1940,7 +1940,7 @@ impl LspCommand for OnTypeFormatting {
) -> lsp::DocumentOnTypeFormattingParams {
lsp::DocumentOnTypeFormattingParams {
text_document_position: lsp::TextDocumentPositionParams::new(
lsp::TextDocumentIdentifier::new(lsp::Uri::from_file_path(path).unwrap().into()),
lsp::TextDocumentIdentifier::new(lsp::Url::from_file_path(path).unwrap()),
point_to_lsp(self.position),
),
ch: self.trigger.clone(),
@ -2282,9 +2282,8 @@ impl InlayHints {
Some(((uri, range), server_id)) => Some((
LanguageServerId(server_id as usize),
lsp::Location {
uri: lsp::Uri::from_file_path(&uri)
.context("invalid uri in hint part {part:?}")?
.into(),
uri: lsp::Url::parse(&uri)
.context("invalid uri in hint part {part:?}")?,
range: lsp::Range::new(
point_to_lsp(PointUtf16::new(
range.start.row,
@ -2444,7 +2443,7 @@ impl LspCommand for InlayHints {
) -> lsp::InlayHintParams {
lsp::InlayHintParams {
text_document: lsp::TextDocumentIdentifier {
uri: lsp::Uri::from_file_path(path).unwrap().into(),
uri: lsp::Url::from_file_path(path).unwrap(),
},
range: range_to_lsp(self.range.to_point_utf16(buffer)),
work_done_progress_params: Default::default(),
@ -2600,7 +2599,7 @@ impl LspCommand for LinkedEditingRange {
let position = self.position.to_point_utf16(&buffer.snapshot());
lsp::LinkedEditingRangeParams {
text_document_position_params: lsp::TextDocumentPositionParams::new(
lsp::TextDocumentIdentifier::new(lsp::Uri::from_file_path(path).unwrap().into()),
lsp::TextDocumentIdentifier::new(lsp::Url::from_file_path(path).unwrap()),
point_to_lsp(position),
),
work_done_progress_params: Default::default(),