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(),

View file

@ -58,7 +58,7 @@ impl LspCommand for ExpandMacro {
) -> ExpandMacroParams {
ExpandMacroParams {
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),
}

View file

@ -61,8 +61,7 @@ use lsp::{
CompletionContext, DiagnosticSeverity, DiagnosticTag, DidChangeWatchedFilesRegistrationOptions,
DocumentHighlightKind, Edit, FileSystemWatcher, InsertTextFormat, LanguageServer,
LanguageServerBinary, LanguageServerId, LspRequestFuture, MessageActionItem, OneOf,
ServerCapabilities, ServerHealthStatus, ServerStatus, TextEdit, Uri,
WorkDoneProgressCancelParams,
ServerCapabilities, ServerHealthStatus, ServerStatus, TextEdit, WorkDoneProgressCancelParams,
};
use lsp_command::*;
use node_runtime::NodeRuntime;
@ -2141,7 +2140,7 @@ impl Project {
/// LanguageServerName is owned, because it is inserted into a map
pub fn open_local_buffer_via_lsp(
&mut self,
abs_path: lsp::Uri,
abs_path: lsp::Url,
language_server_id: LanguageServerId,
language_server_name: LanguageServerName,
cx: &mut ModelContext<Self>,
@ -2441,15 +2440,13 @@ impl Project {
cx.observe_release(buffer, |this, buffer, cx| {
if let Some(file) = File::from_dyn(buffer.file()) {
if file.is_local() {
let uri = lsp::Uri::from_file_path(file.abs_path(cx)).unwrap();
let uri = lsp::Url::from_file_path(file.abs_path(cx)).unwrap();
for server in this.language_servers_for_buffer(buffer, cx) {
server
.1
.notify::<lsp::notification::DidCloseTextDocument>(
lsp::DidCloseTextDocumentParams {
text_document: lsp::TextDocumentIdentifier::new(
uri.clone().into(),
),
text_document: lsp::TextDocumentIdentifier::new(uri.clone()),
},
)
.log_err();
@ -2481,7 +2478,7 @@ impl Project {
}
let abs_path = file.abs_path(cx);
let Some(uri) = lsp::Uri::from_file_path(&abs_path).log_err() else {
let Some(uri) = lsp::Url::from_file_path(&abs_path).log_err() else {
return;
};
let initial_snapshot = buffer.text_snapshot();
@ -2519,7 +2516,7 @@ impl Project {
.notify::<lsp::notification::DidOpenTextDocument>(
lsp::DidOpenTextDocumentParams {
text_document: lsp::TextDocumentItem::new(
uri.clone().into(),
uri.clone(),
adapter.language_id(&language),
0,
initial_snapshot.text(),
@ -2577,14 +2574,12 @@ impl Project {
}
self.buffer_snapshots.remove(&buffer.remote_id());
let file_url = lsp::Uri::from_file_path(old_path).unwrap();
let file_url = lsp::Url::from_file_path(old_path).unwrap();
for (_, language_server) in self.language_servers_for_buffer(buffer, cx) {
language_server
.notify::<lsp::notification::DidCloseTextDocument>(
lsp::DidCloseTextDocumentParams {
text_document: lsp::TextDocumentIdentifier::new(
file_url.clone().into(),
),
text_document: lsp::TextDocumentIdentifier::new(file_url.clone()),
},
)
.log_err();
@ -2743,7 +2738,7 @@ impl Project {
let buffer = buffer.read(cx);
let file = File::from_dyn(buffer.file())?;
let abs_path = file.as_local()?.abs_path(cx);
let uri = lsp::Uri::from_file_path(abs_path).unwrap();
let uri = lsp::Url::from_file_path(abs_path).unwrap();
let next_snapshot = buffer.text_snapshot();
let language_servers: Vec<_> = self
@ -2824,7 +2819,7 @@ impl Project {
.notify::<lsp::notification::DidChangeTextDocument>(
lsp::DidChangeTextDocumentParams {
text_document: lsp::VersionedTextDocumentIdentifier::new(
uri.clone().into(),
uri.clone(),
next_version,
),
content_changes,
@ -2839,7 +2834,7 @@ impl Project {
let worktree_id = file.worktree_id(cx);
let abs_path = file.as_local()?.abs_path(cx);
let text_document = lsp::TextDocumentIdentifier {
uri: lsp::Uri::from_file_path(abs_path).unwrap().into(),
uri: lsp::Url::from_file_path(abs_path).unwrap(),
};
for (_, _, server) in self.language_servers_for_worktree(worktree_id) {
@ -3879,11 +3874,11 @@ impl Project {
let snapshot = versions.last().unwrap();
let version = snapshot.version;
let initial_snapshot = &snapshot.snapshot;
let uri = lsp::Uri::from_file_path(file.abs_path(cx)).unwrap();
let uri = lsp::Url::from_file_path(file.abs_path(cx)).unwrap();
language_server.notify::<lsp::notification::DidOpenTextDocument>(
lsp::DidOpenTextDocumentParams {
text_document: lsp::TextDocumentItem::new(
uri.into(),
uri,
adapter.language_id(&language),
version,
initial_snapshot.text(),
@ -4507,13 +4502,10 @@ impl Project {
lsp::OneOf::Left(workspace_folder) => &workspace_folder.uri,
lsp::OneOf::Right(base_uri) => base_uri,
};
lsp::Uri::from(base_uri.clone())
.to_file_path()
.ok()
.and_then(|file_path| {
(file_path.to_str() == Some(abs_path))
.then_some(rp.pattern.as_str())
})
base_uri.to_file_path().ok().and_then(|file_path| {
(file_path.to_str() == Some(abs_path))
.then_some(rp.pattern.as_str())
})
}
};
if let Some(relative_glob_pattern) = relative_glob_pattern {
@ -4602,9 +4594,10 @@ impl Project {
disk_based_sources: &[String],
cx: &mut ModelContext<Self>,
) -> Result<()> {
let abs_path = Uri::from(params.uri.clone())
let abs_path = params
.uri
.to_file_path()
.map_err(|_| anyhow!("URI `{}` is not a file", params.uri.as_str()))?;
.map_err(|_| anyhow!("URI is not a file"))?;
let mut diagnostics = Vec::default();
let mut primary_diagnostic_group_ids = HashMap::default();
let mut sources_by_group_id = HashMap::default();
@ -5285,9 +5278,9 @@ impl Project {
tab_size: NonZeroU32,
cx: &mut AsyncAppContext,
) -> Result<Vec<(Range<Anchor>, String)>> {
let uri = lsp::Uri::from_file_path(abs_path)
let uri = lsp::Url::from_file_path(abs_path)
.map_err(|_| anyhow!("failed to convert abs path to uri"))?;
let text_document = lsp::TextDocumentIdentifier::new(uri.into());
let text_document = lsp::TextDocumentIdentifier::new(uri);
let capabilities = &language_server.capabilities();
let formatting_provider = capabilities.document_formatting_provider.as_ref();
@ -5592,8 +5585,7 @@ impl Project {
lsp_symbols
.into_iter()
.filter_map(|(symbol_name, symbol_kind, symbol_location)| {
let abs_path: lsp::Uri = symbol_location.uri.into();
let abs_path = abs_path.to_file_path().ok()?;
let abs_path = symbol_location.uri.to_file_path().ok()?;
let source_worktree = source_worktree.upgrade()?;
let source_worktree_id = source_worktree.read(cx).id();
@ -5695,7 +5687,7 @@ impl Project {
};
let symbol_abs_path = resolve_path(&worktree_abs_path, &symbol.path.path);
let symbol_uri = if let Ok(uri) = lsp::Uri::from_file_path(symbol_abs_path) {
let symbol_uri = if let Ok(uri) = lsp::Url::from_file_path(symbol_abs_path) {
uri
} else {
return Task::ready(Err(anyhow!("invalid symbol path")));
@ -6628,7 +6620,8 @@ impl Project {
for operation in operations {
match operation {
lsp::DocumentChangeOperation::Op(lsp::ResourceOp::Create(op)) => {
let abs_path = Uri::from(op.uri)
let abs_path = op
.uri
.to_file_path()
.map_err(|_| anyhow!("can't convert URI to path"))?;
@ -6652,10 +6645,12 @@ impl Project {
}
lsp::DocumentChangeOperation::Op(lsp::ResourceOp::Rename(op)) => {
let source_abs_path = Uri::from(op.old_uri)
let source_abs_path = op
.old_uri
.to_file_path()
.map_err(|_| anyhow!("can't convert URI to path"))?;
let target_abs_path = Uri::from(op.new_uri)
let target_abs_path = op
.new_uri
.to_file_path()
.map_err(|_| anyhow!("can't convert URI to path"))?;
fs.rename(
@ -6672,7 +6667,8 @@ impl Project {
}
lsp::DocumentChangeOperation::Op(lsp::ResourceOp::Delete(op)) => {
let abs_path: PathBuf = Uri::from(op.uri)
let abs_path = op
.uri
.to_file_path()
.map_err(|_| anyhow!("can't convert URI to path"))?;
let options = op
@ -6693,7 +6689,7 @@ impl Project {
let buffer_to_edit = this
.update(cx, |this, cx| {
this.open_local_buffer_via_lsp(
op.text_document.uri.clone().into(),
op.text_document.uri.clone(),
language_server.server_id(),
lsp_adapter.name.clone(),
cx,
@ -8008,9 +8004,7 @@ impl Project {
PathChange::AddedOrUpdated => lsp::FileChangeType::CHANGED,
};
Some(lsp::FileEvent {
uri: lsp::Uri::from_file_path(abs_path.join(path))
.unwrap()
.into(),
uri: lsp::Url::from_file_path(abs_path.join(path)).unwrap(),
typ,
})
})

View file

@ -378,9 +378,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
.await
.text_document,
lsp::TextDocumentItem {
uri: lsp::Uri::from_file_path("/the-root/test.rs")
.unwrap()
.into(),
uri: lsp::Url::from_file_path("/the-root/test.rs").unwrap(),
version: 0,
text: "const A: i32 = 1;".to_string(),
language_id: "rust".to_string(),
@ -406,9 +404,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
.await
.text_document,
lsp::VersionedTextDocumentIdentifier::new(
lsp::Uri::from_file_path("/the-root/test.rs")
.unwrap()
.into(),
lsp::Url::from_file_path("/the-root/test.rs").unwrap(),
1
)
);
@ -429,9 +425,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
.await
.text_document,
lsp::TextDocumentItem {
uri: lsp::Uri::from_file_path("/the-root/package.json")
.unwrap()
.into(),
uri: lsp::Url::from_file_path("/the-root/package.json").unwrap(),
version: 0,
text: "{\"a\": 1}".to_string(),
language_id: "json".to_string(),
@ -470,9 +464,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
.await
.text_document,
lsp::VersionedTextDocumentIdentifier::new(
lsp::Uri::from_file_path("/the-root/test2.rs")
.unwrap()
.into(),
lsp::Url::from_file_path("/the-root/test2.rs").unwrap(),
1
)
);
@ -487,22 +479,14 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
.receive_notification::<lsp::notification::DidSaveTextDocument>()
.await
.text_document,
lsp::TextDocumentIdentifier::new(
lsp::Uri::from_file_path("/the-root/Cargo.toml")
.unwrap()
.into()
)
lsp::TextDocumentIdentifier::new(lsp::Url::from_file_path("/the-root/Cargo.toml").unwrap())
);
assert_eq!(
fake_json_server
.receive_notification::<lsp::notification::DidSaveTextDocument>()
.await
.text_document,
lsp::TextDocumentIdentifier::new(
lsp::Uri::from_file_path("/the-root/Cargo.toml")
.unwrap()
.into()
)
lsp::TextDocumentIdentifier::new(lsp::Url::from_file_path("/the-root/Cargo.toml").unwrap())
);
// Renames are reported only to servers matching the buffer's language.
@ -518,11 +502,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
.receive_notification::<lsp::notification::DidCloseTextDocument>()
.await
.text_document,
lsp::TextDocumentIdentifier::new(
lsp::Uri::from_file_path("/the-root/test2.rs")
.unwrap()
.into()
),
lsp::TextDocumentIdentifier::new(lsp::Url::from_file_path("/the-root/test2.rs").unwrap()),
);
assert_eq!(
fake_rust_server
@ -530,9 +510,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
.await
.text_document,
lsp::TextDocumentItem {
uri: lsp::Uri::from_file_path("/the-root/test3.rs")
.unwrap()
.into(),
uri: lsp::Url::from_file_path("/the-root/test3.rs").unwrap(),
version: 0,
text: rust_buffer2.update(cx, |buffer, _| buffer.text()),
language_id: "rust".to_string(),
@ -574,11 +552,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
.receive_notification::<lsp::notification::DidCloseTextDocument>()
.await
.text_document,
lsp::TextDocumentIdentifier::new(
lsp::Uri::from_file_path("/the-root/test3.rs")
.unwrap()
.into(),
),
lsp::TextDocumentIdentifier::new(lsp::Url::from_file_path("/the-root/test3.rs").unwrap(),),
);
assert_eq!(
fake_json_server
@ -586,9 +560,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
.await
.text_document,
lsp::TextDocumentItem {
uri: lsp::Uri::from_file_path("/the-root/test3.json")
.unwrap()
.into(),
uri: lsp::Url::from_file_path("/the-root/test3.json").unwrap(),
version: 0,
text: rust_buffer2.update(cx, |buffer, _| buffer.text()),
language_id: "json".to_string(),
@ -614,9 +586,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
.await
.text_document,
lsp::VersionedTextDocumentIdentifier::new(
lsp::Uri::from_file_path("/the-root/test3.json")
.unwrap()
.into(),
lsp::Url::from_file_path("/the-root/test3.json").unwrap(),
1
)
);
@ -645,9 +615,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
.await
.text_document,
lsp::TextDocumentItem {
uri: lsp::Uri::from_file_path("/the-root/test.rs")
.unwrap()
.into(),
uri: lsp::Url::from_file_path("/the-root/test.rs").unwrap(),
version: 0,
text: rust_buffer.update(cx, |buffer, _| buffer.text()),
language_id: "rust".to_string(),
@ -668,17 +636,13 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
],
[
lsp::TextDocumentItem {
uri: lsp::Uri::from_file_path("/the-root/package.json")
.unwrap()
.into(),
uri: lsp::Url::from_file_path("/the-root/package.json").unwrap(),
version: 0,
text: json_buffer.update(cx, |buffer, _| buffer.text()),
language_id: "json".to_string(),
},
lsp::TextDocumentItem {
uri: lsp::Uri::from_file_path("/the-root/test3.json")
.unwrap()
.into(),
uri: lsp::Url::from_file_path("/the-root/test3.json").unwrap(),
version: 0,
text: rust_buffer2.update(cx, |buffer, _| buffer.text()),
language_id: "json".to_string(),
@ -690,9 +654,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
cx.update(|_| drop(json_buffer));
let close_message = lsp::DidCloseTextDocumentParams {
text_document: lsp::TextDocumentIdentifier::new(
lsp::Uri::from_file_path("/the-root/package.json")
.unwrap()
.into(),
lsp::Url::from_file_path("/the-root/package.json").unwrap(),
),
};
assert_eq!(
@ -882,21 +844,15 @@ async fn test_reporting_fs_changes_to_language_servers(cx: &mut gpui::TestAppCon
&*file_changes.lock(),
&[
lsp::FileEvent {
uri: lsp::Uri::from_file_path("/the-root/src/b.rs")
.unwrap()
.into(),
uri: lsp::Url::from_file_path("/the-root/src/b.rs").unwrap(),
typ: lsp::FileChangeType::DELETED,
},
lsp::FileEvent {
uri: lsp::Uri::from_file_path("/the-root/src/c.rs")
.unwrap()
.into(),
uri: lsp::Url::from_file_path("/the-root/src/c.rs").unwrap(),
typ: lsp::FileChangeType::CREATED,
},
lsp::FileEvent {
uri: lsp::Uri::from_file_path("/the-root/target/y/out/y2.rs")
.unwrap()
.into(),
uri: lsp::Url::from_file_path("/the-root/target/y/out/y2.rs").unwrap(),
typ: lsp::FileChangeType::CREATED,
},
]
@ -933,7 +889,7 @@ async fn test_single_file_worktrees_diagnostics(cx: &mut gpui::TestAppContext) {
.update_diagnostics(
LanguageServerId(0),
lsp::PublishDiagnosticsParams {
uri: Uri::from_file_path("/dir/a.rs").unwrap().into(),
uri: Url::from_file_path("/dir/a.rs").unwrap(),
version: None,
diagnostics: vec![lsp::Diagnostic {
range: lsp::Range::new(lsp::Position::new(0, 4), lsp::Position::new(0, 5)),
@ -950,7 +906,7 @@ async fn test_single_file_worktrees_diagnostics(cx: &mut gpui::TestAppContext) {
.update_diagnostics(
LanguageServerId(0),
lsp::PublishDiagnosticsParams {
uri: Uri::from_file_path("/dir/b.rs").unwrap().into(),
uri: Url::from_file_path("/dir/b.rs").unwrap(),
version: None,
diagnostics: vec![lsp::Diagnostic {
range: lsp::Range::new(lsp::Position::new(0, 4), lsp::Position::new(0, 5)),
@ -1039,7 +995,7 @@ async fn test_omitted_diagnostics(cx: &mut gpui::TestAppContext) {
.update_diagnostics(
server_id,
lsp::PublishDiagnosticsParams {
uri: Uri::from_file_path("/root/dir/b.rs").unwrap().into(),
uri: Url::from_file_path("/root/dir/b.rs").unwrap(),
version: None,
diagnostics: vec![lsp::Diagnostic {
range: lsp::Range::new(lsp::Position::new(0, 4), lsp::Position::new(0, 5)),
@ -1056,7 +1012,7 @@ async fn test_omitted_diagnostics(cx: &mut gpui::TestAppContext) {
.update_diagnostics(
server_id,
lsp::PublishDiagnosticsParams {
uri: Uri::from_file_path("/root/other.rs").unwrap().into(),
uri: Url::from_file_path("/root/other.rs").unwrap(),
version: None,
diagnostics: vec![lsp::Diagnostic {
range: lsp::Range::new(lsp::Position::new(0, 8), lsp::Position::new(0, 9)),
@ -1191,7 +1147,7 @@ async fn test_disk_based_diagnostics_progress(cx: &mut gpui::TestAppContext) {
);
fake_server.notify::<lsp::notification::PublishDiagnostics>(lsp::PublishDiagnosticsParams {
uri: Uri::from_file_path("/dir/a.rs").unwrap().into(),
uri: Url::from_file_path("/dir/a.rs").unwrap(),
version: None,
diagnostics: vec![lsp::Diagnostic {
range: lsp::Range::new(lsp::Position::new(0, 9), lsp::Position::new(0, 10)),
@ -1243,7 +1199,7 @@ async fn test_disk_based_diagnostics_progress(cx: &mut gpui::TestAppContext) {
// Ensure publishing empty diagnostics twice only results in one update event.
fake_server.notify::<lsp::notification::PublishDiagnostics>(lsp::PublishDiagnosticsParams {
uri: Uri::from_file_path("/dir/a.rs").unwrap().into(),
uri: Url::from_file_path("/dir/a.rs").unwrap(),
version: None,
diagnostics: Default::default(),
});
@ -1256,7 +1212,7 @@ async fn test_disk_based_diagnostics_progress(cx: &mut gpui::TestAppContext) {
);
fake_server.notify::<lsp::notification::PublishDiagnostics>(lsp::PublishDiagnosticsParams {
uri: Uri::from_file_path("/dir/a.rs").unwrap().into(),
uri: Url::from_file_path("/dir/a.rs").unwrap(),
version: None,
diagnostics: Default::default(),
});
@ -1365,7 +1321,7 @@ async fn test_restarting_server_with_diagnostics_published(cx: &mut gpui::TestAp
// Publish diagnostics
let fake_server = fake_servers.next().await.unwrap();
fake_server.notify::<lsp::notification::PublishDiagnostics>(lsp::PublishDiagnosticsParams {
uri: Uri::from_file_path("/dir/a.rs").unwrap().into(),
uri: Url::from_file_path("/dir/a.rs").unwrap(),
version: None,
diagnostics: vec![lsp::Diagnostic {
range: lsp::Range::new(lsp::Position::new(0, 0), lsp::Position::new(0, 0)),
@ -1445,7 +1401,7 @@ async fn test_restarted_server_reporting_invalid_buffer_version(cx: &mut gpui::T
// Before restarting the server, report diagnostics with an unknown buffer version.
let fake_server = fake_servers.next().await.unwrap();
fake_server.notify::<lsp::notification::PublishDiagnostics>(lsp::PublishDiagnosticsParams {
uri: lsp::Uri::from_file_path("/dir/a.rs").unwrap().into(),
uri: lsp::Url::from_file_path("/dir/a.rs").unwrap(),
version: Some(10000),
diagnostics: Vec::new(),
});
@ -1684,7 +1640,7 @@ async fn test_transforming_diagnostics(cx: &mut gpui::TestAppContext) {
// Report some diagnostics for the initial version of the buffer
fake_server.notify::<lsp::notification::PublishDiagnostics>(lsp::PublishDiagnosticsParams {
uri: lsp::Uri::from_file_path("/dir/a.rs").unwrap().into(),
uri: lsp::Url::from_file_path("/dir/a.rs").unwrap(),
version: Some(open_notification.text_document.version),
diagnostics: vec![
lsp::Diagnostic {
@ -1770,7 +1726,7 @@ async fn test_transforming_diagnostics(cx: &mut gpui::TestAppContext) {
// Ensure overlapping diagnostics are highlighted correctly.
fake_server.notify::<lsp::notification::PublishDiagnostics>(lsp::PublishDiagnosticsParams {
uri: lsp::Uri::from_file_path("/dir/a.rs").unwrap().into(),
uri: lsp::Url::from_file_path("/dir/a.rs").unwrap(),
version: Some(open_notification.text_document.version),
diagnostics: vec![
lsp::Diagnostic {
@ -1862,7 +1818,7 @@ async fn test_transforming_diagnostics(cx: &mut gpui::TestAppContext) {
// Handle out-of-order diagnostics
fake_server.notify::<lsp::notification::PublishDiagnostics>(lsp::PublishDiagnosticsParams {
uri: lsp::Uri::from_file_path("/dir/a.rs").unwrap().into(),
uri: lsp::Url::from_file_path("/dir/a.rs").unwrap(),
version: Some(change_notification_2.text_document.version),
diagnostics: vec![
lsp::Diagnostic {
@ -2456,14 +2412,14 @@ async fn test_definition(cx: &mut gpui::TestAppContext) {
fake_server.handle_request::<lsp::request::GotoDefinition, _, _>(|params, _| async move {
let params = params.text_document_position_params;
assert_eq!(
Uri::from(params.text_document.uri).to_file_path().unwrap(),
params.text_document.uri.to_file_path().unwrap(),
Path::new("/dir/b.rs"),
);
assert_eq!(params.position, lsp::Position::new(0, 22));
Ok(Some(lsp::GotoDefinitionResponse::Scalar(
lsp::Location::new(
lsp::Uri::from_file_path("/dir/a.rs").unwrap().into(),
lsp::Url::from_file_path("/dir/a.rs").unwrap(),
lsp::Range::new(lsp::Position::new(0, 9), lsp::Position::new(0, 10)),
),
)))
@ -2771,7 +2727,7 @@ async fn test_apply_code_actions_with_commands(cx: &mut gpui::TestAppContext) {
edit: lsp::WorkspaceEdit {
changes: Some(
[(
lsp::Uri::from_file_path("/dir/a.ts").unwrap().into(),
lsp::Url::from_file_path("/dir/a.ts").unwrap(),
vec![lsp::TextEdit {
range: lsp::Range::new(
lsp::Position::new(0, 0),
@ -3604,9 +3560,9 @@ async fn test_grouped_diagnostics(cx: &mut gpui::TestAppContext) {
.await
.unwrap();
let buffer_uri = Uri::from_file_path("/the-dir/a.rs").unwrap();
let buffer_uri = Url::from_file_path("/the-dir/a.rs").unwrap();
let message = lsp::PublishDiagnosticsParams {
uri: buffer_uri.clone().into(),
uri: buffer_uri.clone(),
diagnostics: vec![
lsp::Diagnostic {
range: lsp::Range::new(lsp::Position::new(1, 8), lsp::Position::new(1, 9)),
@ -3614,7 +3570,7 @@ async fn test_grouped_diagnostics(cx: &mut gpui::TestAppContext) {
message: "error 1".to_string(),
related_information: Some(vec![lsp::DiagnosticRelatedInformation {
location: lsp::Location {
uri: buffer_uri.clone().into(),
uri: buffer_uri.clone(),
range: lsp::Range::new(lsp::Position::new(1, 8), lsp::Position::new(1, 9)),
},
message: "error 1 hint 1".to_string(),
@ -3627,7 +3583,7 @@ async fn test_grouped_diagnostics(cx: &mut gpui::TestAppContext) {
message: "error 1 hint 1".to_string(),
related_information: Some(vec![lsp::DiagnosticRelatedInformation {
location: lsp::Location {
uri: buffer_uri.clone().into(),
uri: buffer_uri.clone(),
range: lsp::Range::new(lsp::Position::new(1, 8), lsp::Position::new(1, 9)),
},
message: "original diagnostic".to_string(),
@ -3641,7 +3597,7 @@ async fn test_grouped_diagnostics(cx: &mut gpui::TestAppContext) {
related_information: Some(vec![
lsp::DiagnosticRelatedInformation {
location: lsp::Location {
uri: buffer_uri.clone().into(),
uri: buffer_uri.clone(),
range: lsp::Range::new(
lsp::Position::new(1, 13),
lsp::Position::new(1, 15),
@ -3651,7 +3607,7 @@ async fn test_grouped_diagnostics(cx: &mut gpui::TestAppContext) {
},
lsp::DiagnosticRelatedInformation {
location: lsp::Location {
uri: buffer_uri.clone().into(),
uri: buffer_uri.clone(),
range: lsp::Range::new(
lsp::Position::new(1, 13),
lsp::Position::new(1, 15),
@ -3668,7 +3624,7 @@ async fn test_grouped_diagnostics(cx: &mut gpui::TestAppContext) {
message: "error 2 hint 1".to_string(),
related_information: Some(vec![lsp::DiagnosticRelatedInformation {
location: lsp::Location {
uri: buffer_uri.clone().into(),
uri: buffer_uri.clone(),
range: lsp::Range::new(lsp::Position::new(2, 8), lsp::Position::new(2, 17)),
},
message: "original diagnostic".to_string(),
@ -3681,7 +3637,7 @@ async fn test_grouped_diagnostics(cx: &mut gpui::TestAppContext) {
message: "error 2 hint 2".to_string(),
related_information: Some(vec![lsp::DiagnosticRelatedInformation {
location: lsp::Location {
uri: buffer_uri.into(),
uri: buffer_uri,
range: lsp::Range::new(lsp::Position::new(2, 8), lsp::Position::new(2, 17)),
},
message: "original diagnostic".to_string(),
@ -3899,14 +3855,14 @@ async fn test_rename(cx: &mut gpui::TestAppContext) {
changes: Some(
[
(
lsp::Uri::from_file_path("/dir/one.rs").unwrap().into(),
lsp::Url::from_file_path("/dir/one.rs").unwrap(),
vec![lsp::TextEdit::new(
lsp::Range::new(lsp::Position::new(0, 6), lsp::Position::new(0, 9)),
"THREE".to_string(),
)],
),
(
lsp::Uri::from_file_path("/dir/two.rs").unwrap().into(),
lsp::Url::from_file_path("/dir/two.rs").unwrap(),
vec![
lsp::TextEdit::new(
lsp::Range::new(