Update lsp-types to properly handle brackets (#37166)
Closes #21062 See also this pull request: https://github.com/zed-industries/lsp-types/pull/6. Release Notes: - Fixed incorrect URL encoding of file paths with `[` `]` in them
This commit is contained in:
@@ -50,8 +50,8 @@ pub fn lsp_formatting_options(settings: &LanguageSettings) -> lsp::FormattingOpt
|
||||
}
|
||||
}
|
||||
|
||||
pub fn file_path_to_lsp_url(path: &Path) -> Result<lsp::Url> {
|
||||
match lsp::Url::from_file_path(path) {
|
||||
pub fn file_path_to_lsp_url(path: &Path) -> Result<lsp::Uri> {
|
||||
match lsp::Uri::from_file_path(path) {
|
||||
Ok(url) => Ok(url),
|
||||
Err(()) => anyhow::bail!("Invalid file path provided to LSP request: {path:?}"),
|
||||
}
|
||||
@@ -3135,7 +3135,7 @@ impl InlayHints {
|
||||
Some(((uri, range), server_id)) => Some((
|
||||
LanguageServerId(server_id as usize),
|
||||
lsp::Location {
|
||||
uri: lsp::Url::parse(&uri)
|
||||
uri: lsp::Uri::from_str(&uri)
|
||||
.context("invalid uri in hint part {part:?}")?,
|
||||
range: lsp::Range::new(
|
||||
point_to_lsp(PointUtf16::new(
|
||||
@@ -3733,7 +3733,7 @@ impl GetDocumentDiagnostics {
|
||||
.filter_map(|diagnostics| {
|
||||
Some(LspPullDiagnostics::Response {
|
||||
server_id: LanguageServerId::from_proto(diagnostics.server_id),
|
||||
uri: lsp::Url::from_str(diagnostics.uri.as_str()).log_err()?,
|
||||
uri: lsp::Uri::from_str(diagnostics.uri.as_str()).log_err()?,
|
||||
diagnostics: if diagnostics.changed {
|
||||
PulledDiagnostics::Unchanged {
|
||||
result_id: diagnostics.result_id?,
|
||||
@@ -3788,7 +3788,7 @@ impl GetDocumentDiagnostics {
|
||||
start: point_to_lsp(PointUtf16::new(start.row, start.column)),
|
||||
end: point_to_lsp(PointUtf16::new(end.row, end.column)),
|
||||
},
|
||||
uri: lsp::Url::parse(&info.location_url.unwrap()).unwrap(),
|
||||
uri: lsp::Uri::from_str(&info.location_url.unwrap()).unwrap(),
|
||||
},
|
||||
message: info.message,
|
||||
}
|
||||
@@ -3821,7 +3821,7 @@ impl GetDocumentDiagnostics {
|
||||
code_description: diagnostic
|
||||
.code_description
|
||||
.map(|code_description| CodeDescription {
|
||||
href: Some(lsp::Url::parse(&code_description).unwrap()),
|
||||
href: Some(lsp::Uri::from_str(&code_description).unwrap()),
|
||||
}),
|
||||
related_information: Some(related_information),
|
||||
tags: Some(tags),
|
||||
@@ -3961,7 +3961,7 @@ pub struct WorkspaceLspPullDiagnostics {
|
||||
}
|
||||
|
||||
fn process_full_workspace_diagnostics_report(
|
||||
diagnostics: &mut HashMap<lsp::Url, WorkspaceLspPullDiagnostics>,
|
||||
diagnostics: &mut HashMap<lsp::Uri, WorkspaceLspPullDiagnostics>,
|
||||
server_id: LanguageServerId,
|
||||
report: lsp::WorkspaceFullDocumentDiagnosticReport,
|
||||
) {
|
||||
@@ -3984,7 +3984,7 @@ fn process_full_workspace_diagnostics_report(
|
||||
}
|
||||
|
||||
fn process_unchanged_workspace_diagnostics_report(
|
||||
diagnostics: &mut HashMap<lsp::Url, WorkspaceLspPullDiagnostics>,
|
||||
diagnostics: &mut HashMap<lsp::Uri, WorkspaceLspPullDiagnostics>,
|
||||
server_id: LanguageServerId,
|
||||
report: lsp::WorkspaceUnchangedDocumentDiagnosticReport,
|
||||
) {
|
||||
@@ -4343,9 +4343,9 @@ impl LspCommand for GetDocumentColor {
|
||||
}
|
||||
|
||||
fn process_related_documents(
|
||||
diagnostics: &mut HashMap<lsp::Url, LspPullDiagnostics>,
|
||||
diagnostics: &mut HashMap<lsp::Uri, LspPullDiagnostics>,
|
||||
server_id: LanguageServerId,
|
||||
documents: impl IntoIterator<Item = (lsp::Url, lsp::DocumentDiagnosticReportKind)>,
|
||||
documents: impl IntoIterator<Item = (lsp::Uri, lsp::DocumentDiagnosticReportKind)>,
|
||||
) {
|
||||
for (url, report_kind) in documents {
|
||||
match report_kind {
|
||||
@@ -4360,9 +4360,9 @@ fn process_related_documents(
|
||||
}
|
||||
|
||||
fn process_unchanged_diagnostics_report(
|
||||
diagnostics: &mut HashMap<lsp::Url, LspPullDiagnostics>,
|
||||
diagnostics: &mut HashMap<lsp::Uri, LspPullDiagnostics>,
|
||||
server_id: LanguageServerId,
|
||||
uri: lsp::Url,
|
||||
uri: lsp::Uri,
|
||||
report: lsp::UnchangedDocumentDiagnosticReport,
|
||||
) {
|
||||
let result_id = report.result_id;
|
||||
@@ -4404,9 +4404,9 @@ fn process_unchanged_diagnostics_report(
|
||||
}
|
||||
|
||||
fn process_full_diagnostics_report(
|
||||
diagnostics: &mut HashMap<lsp::Url, LspPullDiagnostics>,
|
||||
diagnostics: &mut HashMap<lsp::Uri, LspPullDiagnostics>,
|
||||
server_id: LanguageServerId,
|
||||
uri: lsp::Url,
|
||||
uri: lsp::Uri,
|
||||
report: lsp::FullDocumentDiagnosticReport,
|
||||
) {
|
||||
let result_id = report.result_id;
|
||||
@@ -4540,7 +4540,7 @@ mod tests {
|
||||
fn test_related_information() {
|
||||
let related_info = lsp::DiagnosticRelatedInformation {
|
||||
location: lsp::Location {
|
||||
uri: lsp::Url::parse("file:///test.rs").unwrap(),
|
||||
uri: lsp::Uri::from_str("file:///test.rs").unwrap(),
|
||||
range: lsp::Range {
|
||||
start: lsp::Position::new(1, 1),
|
||||
end: lsp::Position::new(1, 5),
|
||||
|
||||
@@ -79,7 +79,7 @@ use lsp::{
|
||||
LSP_REQUEST_TIMEOUT, LanguageServer, LanguageServerBinary, LanguageServerBinaryOptions,
|
||||
LanguageServerId, LanguageServerName, LanguageServerSelector, LspRequestFuture,
|
||||
MessageActionItem, MessageType, OneOf, RenameFilesParams, SymbolKind,
|
||||
TextDocumentSyncSaveOptions, TextEdit, WillRenameFiles, WorkDoneProgressCancelParams,
|
||||
TextDocumentSyncSaveOptions, TextEdit, Uri, WillRenameFiles, WorkDoneProgressCancelParams,
|
||||
WorkspaceFolder, notification::DidRenameFiles,
|
||||
};
|
||||
use node_runtime::read_package_installed_version;
|
||||
@@ -114,7 +114,7 @@ use std::{
|
||||
};
|
||||
use sum_tree::Dimensions;
|
||||
use text::{Anchor, BufferId, LineEnding, OffsetRangeExt};
|
||||
use url::Url;
|
||||
|
||||
use util::{
|
||||
ConnectionResult, ResultExt as _, debug_panic, defer, maybe, merge_json_value_into,
|
||||
paths::{PathExt, SanitizedPath},
|
||||
@@ -314,7 +314,7 @@ impl LocalLspStore {
|
||||
true,
|
||||
cx,
|
||||
);
|
||||
let pending_workspace_folders: Arc<Mutex<BTreeSet<Url>>> = Default::default();
|
||||
let pending_workspace_folders: Arc<Mutex<BTreeSet<Uri>>> = Default::default();
|
||||
|
||||
let pending_server = cx.spawn({
|
||||
let adapter = adapter.clone();
|
||||
@@ -2405,7 +2405,7 @@ impl LocalLspStore {
|
||||
|
||||
{
|
||||
let uri =
|
||||
Url::from_file_path(worktree.read(cx).abs_path().join(&path.path));
|
||||
Uri::from_file_path(worktree.read(cx).abs_path().join(&path.path));
|
||||
|
||||
let server_id = self.get_or_insert_language_server(
|
||||
&worktree,
|
||||
@@ -2565,7 +2565,7 @@ impl LocalLspStore {
|
||||
None => return,
|
||||
};
|
||||
|
||||
let Ok(file_url) = lsp::Url::from_file_path(old_path.as_path()) else {
|
||||
let Ok(file_url) = lsp::Uri::from_file_path(old_path.as_path()) else {
|
||||
debug_panic!(
|
||||
"`{}` is not parseable as an URI",
|
||||
old_path.to_string_lossy()
|
||||
@@ -2578,7 +2578,7 @@ impl LocalLspStore {
|
||||
pub(crate) fn unregister_buffer_from_language_servers(
|
||||
&mut self,
|
||||
buffer: &Entity<Buffer>,
|
||||
file_url: &lsp::Url,
|
||||
file_url: &lsp::Uri,
|
||||
cx: &mut App,
|
||||
) {
|
||||
buffer.update(cx, |buffer, cx| {
|
||||
@@ -4694,7 +4694,7 @@ impl LspStore {
|
||||
for node in nodes {
|
||||
let server_id = node.server_id_or_init(|disposition| {
|
||||
let path = &disposition.path;
|
||||
let uri = Url::from_file_path(worktree_root.join(&path.path));
|
||||
let uri = Uri::from_file_path(worktree_root.join(&path.path));
|
||||
let key = LanguageServerSeed {
|
||||
worktree_id,
|
||||
name: disposition.server_name.clone(),
|
||||
@@ -6578,7 +6578,7 @@ impl LspStore {
|
||||
File::from_dyn(buffer.file())
|
||||
.and_then(|file| {
|
||||
let abs_path = file.as_local()?.abs_path(cx);
|
||||
lsp::Url::from_file_path(abs_path).ok()
|
||||
lsp::Uri::from_file_path(abs_path).ok()
|
||||
})
|
||||
.is_none_or(|buffer_uri| {
|
||||
unchanged_buffers.contains(&buffer_uri)
|
||||
@@ -7179,7 +7179,7 @@ impl LspStore {
|
||||
let buffer = buffer.read(cx);
|
||||
let file = File::from_dyn(buffer.file())?;
|
||||
let abs_path = file.as_local()?.abs_path(cx);
|
||||
let uri = lsp::Url::from_file_path(abs_path).unwrap();
|
||||
let uri = lsp::Uri::from_file_path(abs_path).unwrap();
|
||||
let next_snapshot = buffer.text_snapshot();
|
||||
for language_server in language_servers {
|
||||
let language_server = language_server.clone();
|
||||
@@ -7816,7 +7816,7 @@ impl LspStore {
|
||||
};
|
||||
|
||||
let symbol_abs_path = resolve_path(&worktree_abs_path, &symbol.path.path);
|
||||
let symbol_uri = if let Ok(uri) = lsp::Url::from_file_path(symbol_abs_path) {
|
||||
let symbol_uri = if let Ok(uri) = lsp::Uri::from_file_path(symbol_abs_path) {
|
||||
uri
|
||||
} else {
|
||||
return Task::ready(Err(anyhow!("invalid symbol path")));
|
||||
@@ -7830,14 +7830,14 @@ impl LspStore {
|
||||
|
||||
pub(crate) fn open_local_buffer_via_lsp(
|
||||
&mut self,
|
||||
mut abs_path: lsp::Url,
|
||||
abs_path: lsp::Uri,
|
||||
language_server_id: LanguageServerId,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Task<Result<Entity<Buffer>>> {
|
||||
cx.spawn(async move |lsp_store, cx| {
|
||||
// Escape percent-encoded string.
|
||||
let current_scheme = abs_path.scheme().to_owned();
|
||||
let _ = abs_path.set_scheme("file");
|
||||
// Uri is immutable, so we can't modify the scheme
|
||||
|
||||
let abs_path = abs_path
|
||||
.to_file_path()
|
||||
@@ -9230,8 +9230,12 @@ impl LspStore {
|
||||
maybe!({
|
||||
let local_store = self.as_local()?;
|
||||
|
||||
let old_uri = lsp::Url::from_file_path(old_path).ok().map(String::from)?;
|
||||
let new_uri = lsp::Url::from_file_path(new_path).ok().map(String::from)?;
|
||||
let old_uri = lsp::Uri::from_file_path(old_path)
|
||||
.ok()
|
||||
.map(|uri| uri.to_string())?;
|
||||
let new_uri = lsp::Uri::from_file_path(new_path)
|
||||
.ok()
|
||||
.map(|uri| uri.to_string())?;
|
||||
|
||||
for language_server in local_store.language_servers_for_worktree(worktree_id) {
|
||||
let Some(filter) = local_store
|
||||
@@ -9264,8 +9268,12 @@ impl LspStore {
|
||||
is_dir: bool,
|
||||
cx: AsyncApp,
|
||||
) -> Task<ProjectTransaction> {
|
||||
let old_uri = lsp::Url::from_file_path(old_path).ok().map(String::from);
|
||||
let new_uri = lsp::Url::from_file_path(new_path).ok().map(String::from);
|
||||
let old_uri = lsp::Uri::from_file_path(old_path)
|
||||
.ok()
|
||||
.map(|uri| uri.to_string());
|
||||
let new_uri = lsp::Uri::from_file_path(new_path)
|
||||
.ok()
|
||||
.map(|uri| uri.to_string());
|
||||
cx.spawn(async move |cx| {
|
||||
let mut tasks = vec![];
|
||||
this.update(cx, |this, cx| {
|
||||
@@ -10878,7 +10886,7 @@ impl LspStore {
|
||||
language_server: Arc<LanguageServer>,
|
||||
server_id: LanguageServerId,
|
||||
key: LanguageServerSeed,
|
||||
workspace_folders: Arc<Mutex<BTreeSet<Url>>>,
|
||||
workspace_folders: Arc<Mutex<BTreeSet<Uri>>>,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
let Some(local) = self.as_local_mut() else {
|
||||
@@ -11038,7 +11046,7 @@ impl LspStore {
|
||||
let snapshot = versions.last().unwrap();
|
||||
let version = snapshot.version;
|
||||
let initial_snapshot = &snapshot.snapshot;
|
||||
let uri = lsp::Url::from_file_path(file.abs_path(cx)).unwrap();
|
||||
let uri = lsp::Uri::from_file_path(file.abs_path(cx)).unwrap();
|
||||
language_server.register_buffer(
|
||||
uri,
|
||||
adapter.language_id(&language.name()),
|
||||
@@ -11277,7 +11285,7 @@ impl LspStore {
|
||||
PathChange::AddedOrUpdated => lsp::FileChangeType::CHANGED,
|
||||
};
|
||||
Some(lsp::FileEvent {
|
||||
uri: lsp::Url::from_file_path(abs_path.join(path)).unwrap(),
|
||||
uri: lsp::Uri::from_file_path(abs_path.join(path)).unwrap(),
|
||||
typ,
|
||||
})
|
||||
})
|
||||
@@ -11689,7 +11697,7 @@ impl LspStore {
|
||||
File::from_dyn(buffer.file())
|
||||
.and_then(|file| {
|
||||
let abs_path = file.as_local()?.abs_path(cx);
|
||||
lsp::Url::from_file_path(abs_path).ok()
|
||||
lsp::Uri::from_file_path(abs_path).ok()
|
||||
})
|
||||
.is_none_or(|buffer_uri| {
|
||||
unchanged_buffers.contains(&buffer_uri)
|
||||
@@ -12821,7 +12829,7 @@ pub enum LanguageServerState {
|
||||
Starting {
|
||||
startup: Task<Option<Arc<LanguageServer>>>,
|
||||
/// List of language servers that will be added to the workspace once it's initialization completes.
|
||||
pending_workspace_folders: Arc<Mutex<BTreeSet<Url>>>,
|
||||
pending_workspace_folders: Arc<Mutex<BTreeSet<Uri>>>,
|
||||
},
|
||||
|
||||
Running {
|
||||
@@ -12833,7 +12841,7 @@ pub enum LanguageServerState {
|
||||
}
|
||||
|
||||
impl LanguageServerState {
|
||||
fn add_workspace_folder(&self, uri: Url) {
|
||||
fn add_workspace_folder(&self, uri: Uri) {
|
||||
match self {
|
||||
LanguageServerState::Starting {
|
||||
pending_workspace_folders,
|
||||
@@ -12846,7 +12854,7 @@ impl LanguageServerState {
|
||||
}
|
||||
}
|
||||
}
|
||||
fn _remove_workspace_folder(&self, uri: Url) {
|
||||
fn _remove_workspace_folder(&self, uri: Uri) {
|
||||
match self {
|
||||
LanguageServerState::Starting {
|
||||
pending_workspace_folders,
|
||||
|
||||
@@ -213,7 +213,7 @@ impl LspCommand for OpenDocs {
|
||||
) -> Result<OpenDocsParams> {
|
||||
Ok(OpenDocsParams {
|
||||
text_document: lsp::TextDocumentIdentifier {
|
||||
uri: lsp::Url::from_file_path(path).unwrap(),
|
||||
uri: lsp::Uri::from_file_path(path).unwrap(),
|
||||
},
|
||||
position: point_to_lsp(self.position),
|
||||
})
|
||||
|
||||
@@ -930,7 +930,7 @@ pub enum LspPullDiagnostics {
|
||||
/// The id of the language server that produced diagnostics.
|
||||
server_id: LanguageServerId,
|
||||
/// URI of the resource,
|
||||
uri: lsp::Url,
|
||||
uri: lsp::Uri,
|
||||
/// The diagnostics produced by this language server.
|
||||
diagnostics: PulledDiagnostics,
|
||||
},
|
||||
@@ -3599,7 +3599,7 @@ impl Project {
|
||||
|
||||
pub fn open_local_buffer_via_lsp(
|
||||
&mut self,
|
||||
abs_path: lsp::Url,
|
||||
abs_path: lsp::Uri,
|
||||
language_server_id: LanguageServerId,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Task<Result<Entity<Buffer>>> {
|
||||
|
||||
@@ -18,7 +18,6 @@ use git::{
|
||||
};
|
||||
use git2::RepositoryInitOptions;
|
||||
use gpui::{App, BackgroundExecutor, SemanticVersion, UpdateGlobal};
|
||||
use http_client::Url;
|
||||
use itertools::Itertools;
|
||||
use language::{
|
||||
Diagnostic, DiagnosticEntry, DiagnosticSet, DiagnosticSourceKind, DiskState, FakeLspAdapter,
|
||||
@@ -29,7 +28,7 @@ use language::{
|
||||
};
|
||||
use lsp::{
|
||||
DiagnosticSeverity, DocumentChanges, FileOperationFilter, NumberOrString, TextDocumentEdit,
|
||||
WillRenameFiles, notification::DidRenameFiles,
|
||||
Uri, WillRenameFiles, notification::DidRenameFiles,
|
||||
};
|
||||
use parking_lot::Mutex;
|
||||
use paths::{config_dir, tasks_file};
|
||||
@@ -701,7 +700,7 @@ async fn test_running_multiple_instances_of_a_single_server_in_one_worktree(
|
||||
assert_eq!(
|
||||
server.workspace_folders(),
|
||||
BTreeSet::from_iter(
|
||||
[Url::from_file_path(path!("/the-root/project-a")).unwrap()].into_iter()
|
||||
[Uri::from_file_path(path!("/the-root/project-a")).unwrap()].into_iter()
|
||||
)
|
||||
);
|
||||
|
||||
@@ -891,7 +890,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
|
||||
.await
|
||||
.text_document,
|
||||
lsp::TextDocumentItem {
|
||||
uri: lsp::Url::from_file_path(path!("/dir/test.rs")).unwrap(),
|
||||
uri: lsp::Uri::from_file_path(path!("/dir/test.rs")).unwrap(),
|
||||
version: 0,
|
||||
text: "const A: i32 = 1;".to_string(),
|
||||
language_id: "rust".to_string(),
|
||||
@@ -921,7 +920,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
|
||||
.await
|
||||
.text_document,
|
||||
lsp::VersionedTextDocumentIdentifier::new(
|
||||
lsp::Url::from_file_path(path!("/dir/test.rs")).unwrap(),
|
||||
lsp::Uri::from_file_path(path!("/dir/test.rs")).unwrap(),
|
||||
1
|
||||
)
|
||||
);
|
||||
@@ -942,7 +941,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
|
||||
.await
|
||||
.text_document,
|
||||
lsp::TextDocumentItem {
|
||||
uri: lsp::Url::from_file_path(path!("/dir/package.json")).unwrap(),
|
||||
uri: lsp::Uri::from_file_path(path!("/dir/package.json")).unwrap(),
|
||||
version: 0,
|
||||
text: "{\"a\": 1}".to_string(),
|
||||
language_id: "json".to_string(),
|
||||
@@ -992,7 +991,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
|
||||
.await
|
||||
.text_document,
|
||||
lsp::VersionedTextDocumentIdentifier::new(
|
||||
lsp::Url::from_file_path(path!("/dir/test2.rs")).unwrap(),
|
||||
lsp::Uri::from_file_path(path!("/dir/test2.rs")).unwrap(),
|
||||
1
|
||||
)
|
||||
);
|
||||
@@ -1008,7 +1007,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
|
||||
.await
|
||||
.text_document,
|
||||
lsp::TextDocumentIdentifier::new(
|
||||
lsp::Url::from_file_path(path!("/dir/Cargo.toml")).unwrap()
|
||||
lsp::Uri::from_file_path(path!("/dir/Cargo.toml")).unwrap()
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
@@ -1017,7 +1016,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
|
||||
.await
|
||||
.text_document,
|
||||
lsp::TextDocumentIdentifier::new(
|
||||
lsp::Url::from_file_path(path!("/dir/Cargo.toml")).unwrap()
|
||||
lsp::Uri::from_file_path(path!("/dir/Cargo.toml")).unwrap()
|
||||
)
|
||||
);
|
||||
|
||||
@@ -1034,7 +1033,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
|
||||
.receive_notification::<lsp::notification::DidCloseTextDocument>()
|
||||
.await
|
||||
.text_document,
|
||||
lsp::TextDocumentIdentifier::new(lsp::Url::from_file_path(path!("/dir/test2.rs")).unwrap()),
|
||||
lsp::TextDocumentIdentifier::new(lsp::Uri::from_file_path(path!("/dir/test2.rs")).unwrap()),
|
||||
);
|
||||
assert_eq!(
|
||||
fake_rust_server
|
||||
@@ -1042,7 +1041,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
|
||||
.await
|
||||
.text_document,
|
||||
lsp::TextDocumentItem {
|
||||
uri: lsp::Url::from_file_path(path!("/dir/test3.rs")).unwrap(),
|
||||
uri: lsp::Uri::from_file_path(path!("/dir/test3.rs")).unwrap(),
|
||||
version: 0,
|
||||
text: rust_buffer2.update(cx, |buffer, _| buffer.text()),
|
||||
language_id: "rust".to_string(),
|
||||
@@ -1084,7 +1083,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
|
||||
.receive_notification::<lsp::notification::DidCloseTextDocument>()
|
||||
.await
|
||||
.text_document,
|
||||
lsp::TextDocumentIdentifier::new(lsp::Url::from_file_path(path!("/dir/test3.rs")).unwrap()),
|
||||
lsp::TextDocumentIdentifier::new(lsp::Uri::from_file_path(path!("/dir/test3.rs")).unwrap()),
|
||||
);
|
||||
assert_eq!(
|
||||
fake_json_server
|
||||
@@ -1092,7 +1091,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
|
||||
.await
|
||||
.text_document,
|
||||
lsp::TextDocumentItem {
|
||||
uri: lsp::Url::from_file_path(path!("/dir/test3.json")).unwrap(),
|
||||
uri: lsp::Uri::from_file_path(path!("/dir/test3.json")).unwrap(),
|
||||
version: 0,
|
||||
text: rust_buffer2.update(cx, |buffer, _| buffer.text()),
|
||||
language_id: "json".to_string(),
|
||||
@@ -1118,7 +1117,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
|
||||
.await
|
||||
.text_document,
|
||||
lsp::VersionedTextDocumentIdentifier::new(
|
||||
lsp::Url::from_file_path(path!("/dir/test3.json")).unwrap(),
|
||||
lsp::Uri::from_file_path(path!("/dir/test3.json")).unwrap(),
|
||||
1
|
||||
)
|
||||
);
|
||||
@@ -1148,7 +1147,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
|
||||
.await
|
||||
.text_document,
|
||||
lsp::TextDocumentItem {
|
||||
uri: lsp::Url::from_file_path(path!("/dir/test.rs")).unwrap(),
|
||||
uri: lsp::Uri::from_file_path(path!("/dir/test.rs")).unwrap(),
|
||||
version: 0,
|
||||
text: rust_buffer.update(cx, |buffer, _| buffer.text()),
|
||||
language_id: "rust".to_string(),
|
||||
@@ -1169,13 +1168,13 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
|
||||
],
|
||||
[
|
||||
lsp::TextDocumentItem {
|
||||
uri: lsp::Url::from_file_path(path!("/dir/package.json")).unwrap(),
|
||||
uri: lsp::Uri::from_file_path(path!("/dir/package.json")).unwrap(),
|
||||
version: 0,
|
||||
text: json_buffer.update(cx, |buffer, _| buffer.text()),
|
||||
language_id: "json".to_string(),
|
||||
},
|
||||
lsp::TextDocumentItem {
|
||||
uri: lsp::Url::from_file_path(path!("/dir/test3.json")).unwrap(),
|
||||
uri: lsp::Uri::from_file_path(path!("/dir/test3.json")).unwrap(),
|
||||
version: 0,
|
||||
text: rust_buffer2.update(cx, |buffer, _| buffer.text()),
|
||||
language_id: "json".to_string(),
|
||||
@@ -1187,7 +1186,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
|
||||
cx.update(|_| drop(_json_handle));
|
||||
let close_message = lsp::DidCloseTextDocumentParams {
|
||||
text_document: lsp::TextDocumentIdentifier::new(
|
||||
lsp::Url::from_file_path(path!("/dir/package.json")).unwrap(),
|
||||
lsp::Uri::from_file_path(path!("/dir/package.json")).unwrap(),
|
||||
),
|
||||
};
|
||||
assert_eq!(
|
||||
@@ -1316,7 +1315,7 @@ async fn test_reporting_fs_changes_to_language_servers(cx: &mut gpui::TestAppCon
|
||||
let _out_of_worktree_buffer = project
|
||||
.update(cx, |project, cx| {
|
||||
project.open_local_buffer_via_lsp(
|
||||
lsp::Url::from_file_path(path!("/the-registry/dep1/src/dep1.rs")).unwrap(),
|
||||
lsp::Uri::from_file_path(path!("/the-registry/dep1/src/dep1.rs")).unwrap(),
|
||||
server_id,
|
||||
cx,
|
||||
)
|
||||
@@ -1476,23 +1475,23 @@ async fn test_reporting_fs_changes_to_language_servers(cx: &mut gpui::TestAppCon
|
||||
&*file_changes.lock(),
|
||||
&[
|
||||
lsp::FileEvent {
|
||||
uri: lsp::Url::from_file_path(path!("/the-root/Cargo.lock")).unwrap(),
|
||||
uri: lsp::Uri::from_file_path(path!("/the-root/Cargo.lock")).unwrap(),
|
||||
typ: lsp::FileChangeType::CHANGED,
|
||||
},
|
||||
lsp::FileEvent {
|
||||
uri: lsp::Url::from_file_path(path!("/the-root/src/b.rs")).unwrap(),
|
||||
uri: lsp::Uri::from_file_path(path!("/the-root/src/b.rs")).unwrap(),
|
||||
typ: lsp::FileChangeType::DELETED,
|
||||
},
|
||||
lsp::FileEvent {
|
||||
uri: lsp::Url::from_file_path(path!("/the-root/src/c.rs")).unwrap(),
|
||||
uri: lsp::Uri::from_file_path(path!("/the-root/src/c.rs")).unwrap(),
|
||||
typ: lsp::FileChangeType::CREATED,
|
||||
},
|
||||
lsp::FileEvent {
|
||||
uri: lsp::Url::from_file_path(path!("/the-root/target/y/out/y2.rs")).unwrap(),
|
||||
uri: lsp::Uri::from_file_path(path!("/the-root/target/y/out/y2.rs")).unwrap(),
|
||||
typ: lsp::FileChangeType::CREATED,
|
||||
},
|
||||
lsp::FileEvent {
|
||||
uri: lsp::Url::from_file_path(path!("/the/stdlib/src/string.rs")).unwrap(),
|
||||
uri: lsp::Uri::from_file_path(path!("/the/stdlib/src/string.rs")).unwrap(),
|
||||
typ: lsp::FileChangeType::CHANGED,
|
||||
},
|
||||
]
|
||||
@@ -1539,7 +1538,7 @@ async fn test_single_file_worktrees_diagnostics(cx: &mut gpui::TestAppContext) {
|
||||
.update_diagnostics(
|
||||
LanguageServerId(0),
|
||||
lsp::PublishDiagnosticsParams {
|
||||
uri: Url::from_file_path(path!("/dir/a.rs")).unwrap(),
|
||||
uri: Uri::from_file_path(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)),
|
||||
@@ -1558,7 +1557,7 @@ async fn test_single_file_worktrees_diagnostics(cx: &mut gpui::TestAppContext) {
|
||||
.update_diagnostics(
|
||||
LanguageServerId(0),
|
||||
lsp::PublishDiagnosticsParams {
|
||||
uri: Url::from_file_path(path!("/dir/b.rs")).unwrap(),
|
||||
uri: Uri::from_file_path(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)),
|
||||
@@ -1650,7 +1649,7 @@ async fn test_omitted_diagnostics(cx: &mut gpui::TestAppContext) {
|
||||
.update_diagnostics(
|
||||
server_id,
|
||||
lsp::PublishDiagnosticsParams {
|
||||
uri: Url::from_file_path(path!("/root/dir/b.rs")).unwrap(),
|
||||
uri: Uri::from_file_path(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)),
|
||||
@@ -1669,7 +1668,7 @@ async fn test_omitted_diagnostics(cx: &mut gpui::TestAppContext) {
|
||||
.update_diagnostics(
|
||||
server_id,
|
||||
lsp::PublishDiagnosticsParams {
|
||||
uri: Url::from_file_path(path!("/root/other.rs")).unwrap(),
|
||||
uri: Uri::from_file_path(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)),
|
||||
@@ -1813,7 +1812,7 @@ async fn test_disk_based_diagnostics_progress(cx: &mut gpui::TestAppContext) {
|
||||
);
|
||||
|
||||
fake_server.notify::<lsp::notification::PublishDiagnostics>(&lsp::PublishDiagnosticsParams {
|
||||
uri: Url::from_file_path(path!("/dir/a.rs")).unwrap(),
|
||||
uri: Uri::from_file_path(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)),
|
||||
@@ -1866,7 +1865,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: Url::from_file_path(path!("/dir/a.rs")).unwrap(),
|
||||
uri: Uri::from_file_path(path!("/dir/a.rs")).unwrap(),
|
||||
version: None,
|
||||
diagnostics: Default::default(),
|
||||
});
|
||||
@@ -1879,7 +1878,7 @@ async fn test_disk_based_diagnostics_progress(cx: &mut gpui::TestAppContext) {
|
||||
);
|
||||
|
||||
fake_server.notify::<lsp::notification::PublishDiagnostics>(&lsp::PublishDiagnosticsParams {
|
||||
uri: Url::from_file_path(path!("/dir/a.rs")).unwrap(),
|
||||
uri: Uri::from_file_path(path!("/dir/a.rs")).unwrap(),
|
||||
version: None,
|
||||
diagnostics: Default::default(),
|
||||
});
|
||||
@@ -2011,7 +2010,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: Url::from_file_path(path!("/dir/a.rs")).unwrap(),
|
||||
uri: Uri::from_file_path(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)),
|
||||
@@ -2092,7 +2091,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::Url::from_file_path(path!("/dir/a.rs")).unwrap(),
|
||||
uri: lsp::Uri::from_file_path(path!("/dir/a.rs")).unwrap(),
|
||||
version: Some(10000),
|
||||
diagnostics: Vec::new(),
|
||||
});
|
||||
@@ -2343,7 +2342,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::Url::from_file_path(path!("/dir/a.rs")).unwrap(),
|
||||
uri: lsp::Uri::from_file_path(path!("/dir/a.rs")).unwrap(),
|
||||
version: Some(open_notification.text_document.version),
|
||||
diagnostics: vec![
|
||||
lsp::Diagnostic {
|
||||
@@ -2431,7 +2430,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::Url::from_file_path(path!("/dir/a.rs")).unwrap(),
|
||||
uri: lsp::Uri::from_file_path(path!("/dir/a.rs")).unwrap(),
|
||||
version: Some(open_notification.text_document.version),
|
||||
diagnostics: vec![
|
||||
lsp::Diagnostic {
|
||||
@@ -2525,7 +2524,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::Url::from_file_path(path!("/dir/a.rs")).unwrap(),
|
||||
uri: lsp::Uri::from_file_path(path!("/dir/a.rs")).unwrap(),
|
||||
version: Some(change_notification_2.text_document.version),
|
||||
diagnostics: vec![
|
||||
lsp::Diagnostic {
|
||||
@@ -3206,7 +3205,7 @@ async fn test_definition(cx: &mut gpui::TestAppContext) {
|
||||
|
||||
Ok(Some(lsp::GotoDefinitionResponse::Scalar(
|
||||
lsp::Location::new(
|
||||
lsp::Url::from_file_path(path!("/dir/a.rs")).unwrap(),
|
||||
lsp::Uri::from_file_path(path!("/dir/a.rs")).unwrap(),
|
||||
lsp::Range::new(lsp::Position::new(0, 9), lsp::Position::new(0, 10)),
|
||||
),
|
||||
)))
|
||||
@@ -3765,7 +3764,7 @@ async fn test_apply_code_actions_with_commands(cx: &mut gpui::TestAppContext) {
|
||||
edit: lsp::WorkspaceEdit {
|
||||
changes: Some(
|
||||
[(
|
||||
lsp::Url::from_file_path(path!("/dir/a.ts")).unwrap(),
|
||||
lsp::Uri::from_file_path(path!("/dir/a.ts")).unwrap(),
|
||||
vec![lsp::TextEdit {
|
||||
range: lsp::Range::new(
|
||||
lsp::Position::new(0, 0),
|
||||
@@ -3904,7 +3903,7 @@ async fn test_save_file_spawns_language_server(cx: &mut gpui::TestAppContext) {
|
||||
.await
|
||||
.text_document,
|
||||
lsp::TextDocumentItem {
|
||||
uri: lsp::Url::from_file_path(path!("/dir/file.rs")).unwrap(),
|
||||
uri: lsp::Uri::from_file_path(path!("/dir/file.rs")).unwrap(),
|
||||
version: 0,
|
||||
text: "".to_string(),
|
||||
language_id: "rust".to_string(),
|
||||
@@ -4742,7 +4741,7 @@ async fn test_grouped_diagnostics(cx: &mut gpui::TestAppContext) {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let buffer_uri = Url::from_file_path(path!("/dir/a.rs")).unwrap();
|
||||
let buffer_uri = Uri::from_file_path(path!("/dir/a.rs")).unwrap();
|
||||
let message = lsp::PublishDiagnosticsParams {
|
||||
uri: buffer_uri.clone(),
|
||||
diagnostics: vec![
|
||||
@@ -5064,7 +5063,7 @@ async fn test_lsp_rename_notifications(cx: &mut gpui::TestAppContext) {
|
||||
new_text: "This is not a drill".to_owned(),
|
||||
})],
|
||||
text_document: lsp::OptionalVersionedTextDocumentIdentifier {
|
||||
uri: Url::from_str(uri!("file:///dir/two/two.rs")).unwrap(),
|
||||
uri: Uri::from_str(uri!("file:///dir/two/two.rs")).unwrap(),
|
||||
version: Some(1337),
|
||||
},
|
||||
}]
|
||||
@@ -5189,14 +5188,14 @@ async fn test_rename(cx: &mut gpui::TestAppContext) {
|
||||
changes: Some(
|
||||
[
|
||||
(
|
||||
lsp::Url::from_file_path(path!("/dir/one.rs")).unwrap(),
|
||||
lsp::Uri::from_file_path(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::Url::from_file_path(path!("/dir/two.rs")).unwrap(),
|
||||
lsp::Uri::from_file_path(path!("/dir/two.rs")).unwrap(),
|
||||
vec![
|
||||
lsp::TextEdit::new(
|
||||
lsp::Range::new(
|
||||
|
||||
Reference in New Issue
Block a user