mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-07 20:39:04 +03:00
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:
parent
479c5df491
commit
3a26a4809d
32
Cargo.lock
generated
32
Cargo.lock
generated
@ -4125,15 +4125,6 @@ version = "0.2.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7bad48618fdb549078c333a7a8528acb57af271d0433bdecd523eb620628364e"
|
checksum = "7bad48618fdb549078c333a7a8528acb57af271d0433bdecd523eb620628364e"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "fluent-uri"
|
|
||||||
version = "0.1.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "17c704e9dbe1ddd863da1e6ff3567795087b1eb201ce80d8fa81162e1516500d"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 1.3.2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "flume"
|
name = "flume"
|
||||||
version = "0.11.0"
|
version = "0.11.0"
|
||||||
@ -6171,7 +6162,6 @@ dependencies = [
|
|||||||
"log",
|
"log",
|
||||||
"lsp-types",
|
"lsp-types",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"pct-str",
|
|
||||||
"postage",
|
"postage",
|
||||||
"release_channel",
|
"release_channel",
|
||||||
"serde",
|
"serde",
|
||||||
@ -6183,14 +6173,14 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lsp-types"
|
name = "lsp-types"
|
||||||
version = "0.97.0"
|
version = "0.95.1"
|
||||||
source = "git+https://github.com/zed-industries/lsp-types?branch=zed-main#258db672ceab9e66c6da3883d37c4dcf1094c6ac"
|
source = "git+https://github.com/zed-industries/lsp-types?rev=72357d6f6d212bdffba3b5ef4b31d8ca856058e7#72357d6f6d212bdffba3b5ef4b31d8ca856058e7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.3.2",
|
"bitflags 1.3.2",
|
||||||
"fluent-uri",
|
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_repr",
|
"serde_repr",
|
||||||
|
"url",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -7431,16 +7421,6 @@ dependencies = [
|
|||||||
"hmac 0.12.1",
|
"hmac 0.12.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "pct-str"
|
|
||||||
version = "2.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "bf1bdcc492c285a50bed60860dfa00b50baf1f60c73c7d6b435b01a2a11fd6ff"
|
|
||||||
dependencies = [
|
|
||||||
"thiserror",
|
|
||||||
"utf8-decode",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "peeking_take_while"
|
name = "peeking_take_while"
|
||||||
version = "0.1.2"
|
version = "0.1.2"
|
||||||
@ -11704,12 +11684,6 @@ version = "0.7.6"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
|
checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "utf8-decode"
|
|
||||||
version = "1.0.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ca61eb27fa339aa08826a29f03e87b99b4d8f0fc2255306fd266bb1b6a9de498"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "utf8parse"
|
name = "utf8parse"
|
||||||
version = "0.2.1"
|
version = "0.2.1"
|
||||||
|
@ -344,7 +344,7 @@ async fn test_collaborating_with_completion(cx_a: &mut TestAppContext, cx_b: &mu
|
|||||||
.handle_request::<lsp::request::Completion, _, _>(|params, _| async move {
|
.handle_request::<lsp::request::Completion, _, _>(|params, _| async move {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
params.text_document_position.text_document.uri,
|
params.text_document_position.text_document.uri,
|
||||||
lsp::Uri::from_file_path("/a/main.rs").unwrap().into(),
|
lsp::Url::from_file_path("/a/main.rs").unwrap(),
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
params.text_document_position.position,
|
params.text_document_position.position,
|
||||||
@ -461,7 +461,7 @@ async fn test_collaborating_with_completion(cx_a: &mut TestAppContext, cx_b: &mu
|
|||||||
.handle_request::<lsp::request::Completion, _, _>(|params, _| async move {
|
.handle_request::<lsp::request::Completion, _, _>(|params, _| async move {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
params.text_document_position.text_document.uri,
|
params.text_document_position.text_document.uri,
|
||||||
lsp::Uri::from_file_path("/a/main.rs").unwrap().into(),
|
lsp::Url::from_file_path("/a/main.rs").unwrap(),
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
params.text_document_position.position,
|
params.text_document_position.position,
|
||||||
@ -585,7 +585,7 @@ async fn test_collaborating_with_code_actions(
|
|||||||
.handle_request::<lsp::request::CodeActionRequest, _, _>(|params, _| async move {
|
.handle_request::<lsp::request::CodeActionRequest, _, _>(|params, _| async move {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
params.text_document.uri,
|
params.text_document.uri,
|
||||||
lsp::Uri::from_file_path("/a/main.rs").unwrap().into(),
|
lsp::Url::from_file_path("/a/main.rs").unwrap(),
|
||||||
);
|
);
|
||||||
assert_eq!(params.range.start, lsp::Position::new(0, 0));
|
assert_eq!(params.range.start, lsp::Position::new(0, 0));
|
||||||
assert_eq!(params.range.end, lsp::Position::new(0, 0));
|
assert_eq!(params.range.end, lsp::Position::new(0, 0));
|
||||||
@ -607,7 +607,7 @@ async fn test_collaborating_with_code_actions(
|
|||||||
.handle_request::<lsp::request::CodeActionRequest, _, _>(|params, _| async move {
|
.handle_request::<lsp::request::CodeActionRequest, _, _>(|params, _| async move {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
params.text_document.uri,
|
params.text_document.uri,
|
||||||
lsp::Uri::from_file_path("/a/main.rs").unwrap().into(),
|
lsp::Url::from_file_path("/a/main.rs").unwrap(),
|
||||||
);
|
);
|
||||||
assert_eq!(params.range.start, lsp::Position::new(1, 31));
|
assert_eq!(params.range.start, lsp::Position::new(1, 31));
|
||||||
assert_eq!(params.range.end, lsp::Position::new(1, 31));
|
assert_eq!(params.range.end, lsp::Position::new(1, 31));
|
||||||
@ -619,7 +619,7 @@ async fn test_collaborating_with_code_actions(
|
|||||||
changes: Some(
|
changes: Some(
|
||||||
[
|
[
|
||||||
(
|
(
|
||||||
lsp::Uri::from_file_path("/a/main.rs").unwrap().into(),
|
lsp::Url::from_file_path("/a/main.rs").unwrap(),
|
||||||
vec![lsp::TextEdit::new(
|
vec![lsp::TextEdit::new(
|
||||||
lsp::Range::new(
|
lsp::Range::new(
|
||||||
lsp::Position::new(1, 22),
|
lsp::Position::new(1, 22),
|
||||||
@ -629,7 +629,7 @@ async fn test_collaborating_with_code_actions(
|
|||||||
)],
|
)],
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
lsp::Uri::from_file_path("/a/other.rs").unwrap().into(),
|
lsp::Url::from_file_path("/a/other.rs").unwrap(),
|
||||||
vec![lsp::TextEdit::new(
|
vec![lsp::TextEdit::new(
|
||||||
lsp::Range::new(
|
lsp::Range::new(
|
||||||
lsp::Position::new(0, 0),
|
lsp::Position::new(0, 0),
|
||||||
@ -689,7 +689,7 @@ async fn test_collaborating_with_code_actions(
|
|||||||
changes: Some(
|
changes: Some(
|
||||||
[
|
[
|
||||||
(
|
(
|
||||||
lsp::Uri::from_file_path("/a/main.rs").unwrap().into(),
|
lsp::Url::from_file_path("/a/main.rs").unwrap(),
|
||||||
vec![lsp::TextEdit::new(
|
vec![lsp::TextEdit::new(
|
||||||
lsp::Range::new(
|
lsp::Range::new(
|
||||||
lsp::Position::new(1, 22),
|
lsp::Position::new(1, 22),
|
||||||
@ -699,7 +699,7 @@ async fn test_collaborating_with_code_actions(
|
|||||||
)],
|
)],
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
lsp::Uri::from_file_path("/a/other.rs").unwrap().into(),
|
lsp::Url::from_file_path("/a/other.rs").unwrap(),
|
||||||
vec![lsp::TextEdit::new(
|
vec![lsp::TextEdit::new(
|
||||||
lsp::Range::new(
|
lsp::Range::new(
|
||||||
lsp::Position::new(0, 0),
|
lsp::Position::new(0, 0),
|
||||||
@ -897,14 +897,14 @@ async fn test_collaborating_with_renames(cx_a: &mut TestAppContext, cx_b: &mut T
|
|||||||
changes: Some(
|
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(
|
vec![lsp::TextEdit::new(
|
||||||
lsp::Range::new(lsp::Position::new(0, 6), lsp::Position::new(0, 9)),
|
lsp::Range::new(lsp::Position::new(0, 6), lsp::Position::new(0, 9)),
|
||||||
"THREE".to_string(),
|
"THREE".to_string(),
|
||||||
)],
|
)],
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
lsp::Uri::from_file_path("/dir/two.rs").unwrap().into(),
|
lsp::Url::from_file_path("/dir/two.rs").unwrap(),
|
||||||
vec![
|
vec![
|
||||||
lsp::TextEdit::new(
|
lsp::TextEdit::new(
|
||||||
lsp::Range::new(
|
lsp::Range::new(
|
||||||
@ -1314,7 +1314,7 @@ async fn test_on_input_format_from_host_to_guest(
|
|||||||
|params, _| async move {
|
|params, _| async move {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
params.text_document_position.text_document.uri,
|
params.text_document_position.text_document.uri,
|
||||||
lsp::Uri::from_file_path("/a/main.rs").unwrap().into(),
|
lsp::Url::from_file_path("/a/main.rs").unwrap(),
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
params.text_document_position.position,
|
params.text_document_position.position,
|
||||||
@ -1442,7 +1442,7 @@ async fn test_on_input_format_from_guest_to_host(
|
|||||||
.handle_request::<lsp::request::OnTypeFormatting, _, _>(|params, _| async move {
|
.handle_request::<lsp::request::OnTypeFormatting, _, _>(|params, _| async move {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
params.text_document_position.text_document.uri,
|
params.text_document_position.text_document.uri,
|
||||||
lsp::Uri::from_file_path("/a/main.rs").unwrap().into(),
|
lsp::Url::from_file_path("/a/main.rs").unwrap(),
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
params.text_document_position.position,
|
params.text_document_position.position,
|
||||||
@ -1611,7 +1611,7 @@ async fn test_mutual_editor_inlay_hint_cache_update(
|
|||||||
async move {
|
async move {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
params.text_document.uri,
|
params.text_document.uri,
|
||||||
lsp::Uri::from_file_path("/a/main.rs").unwrap().into(),
|
lsp::Url::from_file_path("/a/main.rs").unwrap(),
|
||||||
);
|
);
|
||||||
let edits_made = task_edits_made.load(atomic::Ordering::Acquire);
|
let edits_made = task_edits_made.load(atomic::Ordering::Acquire);
|
||||||
Ok(Some(vec![lsp::InlayHint {
|
Ok(Some(vec![lsp::InlayHint {
|
||||||
@ -1874,7 +1874,7 @@ async fn test_inlay_hint_refresh_is_forwarded(
|
|||||||
async move {
|
async move {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
params.text_document.uri,
|
params.text_document.uri,
|
||||||
lsp::Uri::from_file_path("/a/main.rs").unwrap().into(),
|
lsp::Url::from_file_path("/a/main.rs").unwrap(),
|
||||||
);
|
);
|
||||||
let other_hints = task_other_hints.load(atomic::Ordering::Acquire);
|
let other_hints = task_other_hints.load(atomic::Ordering::Acquire);
|
||||||
let character = if other_hints { 0 } else { 2 };
|
let character = if other_hints { 0 } else { 2 };
|
||||||
|
@ -3897,7 +3897,7 @@ async fn test_collaborating_with_diagnostics(
|
|||||||
.await;
|
.await;
|
||||||
fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
|
fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
|
||||||
lsp::PublishDiagnosticsParams {
|
lsp::PublishDiagnosticsParams {
|
||||||
uri: lsp::Uri::from_file_path("/a/a.rs").unwrap().into(),
|
uri: lsp::Url::from_file_path("/a/a.rs").unwrap(),
|
||||||
version: None,
|
version: None,
|
||||||
diagnostics: vec![lsp::Diagnostic {
|
diagnostics: vec![lsp::Diagnostic {
|
||||||
severity: Some(lsp::DiagnosticSeverity::WARNING),
|
severity: Some(lsp::DiagnosticSeverity::WARNING),
|
||||||
@ -3917,7 +3917,7 @@ async fn test_collaborating_with_diagnostics(
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
|
fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
|
||||||
lsp::PublishDiagnosticsParams {
|
lsp::PublishDiagnosticsParams {
|
||||||
uri: lsp::Uri::from_file_path("/a/a.rs").unwrap().into(),
|
uri: lsp::Url::from_file_path("/a/a.rs").unwrap(),
|
||||||
version: None,
|
version: None,
|
||||||
diagnostics: vec![lsp::Diagnostic {
|
diagnostics: vec![lsp::Diagnostic {
|
||||||
severity: Some(lsp::DiagnosticSeverity::ERROR),
|
severity: Some(lsp::DiagnosticSeverity::ERROR),
|
||||||
@ -3991,7 +3991,7 @@ async fn test_collaborating_with_diagnostics(
|
|||||||
// Simulate a language server reporting more errors for a file.
|
// Simulate a language server reporting more errors for a file.
|
||||||
fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
|
fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
|
||||||
lsp::PublishDiagnosticsParams {
|
lsp::PublishDiagnosticsParams {
|
||||||
uri: lsp::Uri::from_file_path("/a/a.rs").unwrap().into(),
|
uri: lsp::Url::from_file_path("/a/a.rs").unwrap(),
|
||||||
version: None,
|
version: None,
|
||||||
diagnostics: vec![
|
diagnostics: vec![
|
||||||
lsp::Diagnostic {
|
lsp::Diagnostic {
|
||||||
@ -4085,7 +4085,7 @@ async fn test_collaborating_with_diagnostics(
|
|||||||
// Simulate a language server reporting no errors for a file.
|
// Simulate a language server reporting no errors for a file.
|
||||||
fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
|
fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
|
||||||
lsp::PublishDiagnosticsParams {
|
lsp::PublishDiagnosticsParams {
|
||||||
uri: lsp::Uri::from_file_path("/a/a.rs").unwrap().into(),
|
uri: lsp::Url::from_file_path("/a/a.rs").unwrap(),
|
||||||
version: None,
|
version: None,
|
||||||
diagnostics: vec![],
|
diagnostics: vec![],
|
||||||
},
|
},
|
||||||
@ -4189,9 +4189,7 @@ async fn test_collaborating_with_lsp_progress_updates_and_diagnostics_ordering(
|
|||||||
for file_name in file_names {
|
for file_name in file_names {
|
||||||
fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
|
fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
|
||||||
lsp::PublishDiagnosticsParams {
|
lsp::PublishDiagnosticsParams {
|
||||||
uri: lsp::Uri::from_file_path(Path::new("/test").join(file_name))
|
uri: lsp::Url::from_file_path(Path::new("/test").join(file_name)).unwrap(),
|
||||||
.unwrap()
|
|
||||||
.into(),
|
|
||||||
version: None,
|
version: None,
|
||||||
diagnostics: vec![lsp::Diagnostic {
|
diagnostics: vec![lsp::Diagnostic {
|
||||||
severity: Some(lsp::DiagnosticSeverity::WARNING),
|
severity: Some(lsp::DiagnosticSeverity::WARNING),
|
||||||
@ -4609,7 +4607,7 @@ async fn test_definition(
|
|||||||
fake_language_server.handle_request::<lsp::request::GotoDefinition, _, _>(|_, _| async move {
|
fake_language_server.handle_request::<lsp::request::GotoDefinition, _, _>(|_, _| async move {
|
||||||
Ok(Some(lsp::GotoDefinitionResponse::Scalar(
|
Ok(Some(lsp::GotoDefinitionResponse::Scalar(
|
||||||
lsp::Location::new(
|
lsp::Location::new(
|
||||||
lsp::Uri::from_file_path("/root/dir-2/b.rs").unwrap().into(),
|
lsp::Url::from_file_path("/root/dir-2/b.rs").unwrap(),
|
||||||
lsp::Range::new(lsp::Position::new(0, 6), lsp::Position::new(0, 9)),
|
lsp::Range::new(lsp::Position::new(0, 6), lsp::Position::new(0, 9)),
|
||||||
),
|
),
|
||||||
)))
|
)))
|
||||||
@ -4638,7 +4636,7 @@ async fn test_definition(
|
|||||||
fake_language_server.handle_request::<lsp::request::GotoDefinition, _, _>(|_, _| async move {
|
fake_language_server.handle_request::<lsp::request::GotoDefinition, _, _>(|_, _| async move {
|
||||||
Ok(Some(lsp::GotoDefinitionResponse::Scalar(
|
Ok(Some(lsp::GotoDefinitionResponse::Scalar(
|
||||||
lsp::Location::new(
|
lsp::Location::new(
|
||||||
lsp::Uri::from_file_path("/root/dir-2/b.rs").unwrap().into(),
|
lsp::Url::from_file_path("/root/dir-2/b.rs").unwrap(),
|
||||||
lsp::Range::new(lsp::Position::new(1, 6), lsp::Position::new(1, 11)),
|
lsp::Range::new(lsp::Position::new(1, 6), lsp::Position::new(1, 11)),
|
||||||
),
|
),
|
||||||
)))
|
)))
|
||||||
@ -4674,7 +4672,7 @@ async fn test_definition(
|
|||||||
);
|
);
|
||||||
Ok(Some(lsp::GotoDefinitionResponse::Scalar(
|
Ok(Some(lsp::GotoDefinitionResponse::Scalar(
|
||||||
lsp::Location::new(
|
lsp::Location::new(
|
||||||
lsp::Uri::from_file_path("/root/dir-2/c.rs").unwrap().into(),
|
lsp::Url::from_file_path("/root/dir-2/c.rs").unwrap(),
|
||||||
lsp::Range::new(lsp::Position::new(0, 5), lsp::Position::new(0, 7)),
|
lsp::Range::new(lsp::Position::new(0, 5), lsp::Position::new(0, 7)),
|
||||||
),
|
),
|
||||||
)))
|
)))
|
||||||
@ -4786,21 +4784,15 @@ async fn test_references(
|
|||||||
lsp_response_tx
|
lsp_response_tx
|
||||||
.unbounded_send(Ok(Some(vec![
|
.unbounded_send(Ok(Some(vec![
|
||||||
lsp::Location {
|
lsp::Location {
|
||||||
uri: lsp::Uri::from_file_path("/root/dir-1/two.rs")
|
uri: lsp::Url::from_file_path("/root/dir-1/two.rs").unwrap(),
|
||||||
.unwrap()
|
|
||||||
.into(),
|
|
||||||
range: lsp::Range::new(lsp::Position::new(0, 24), lsp::Position::new(0, 27)),
|
range: lsp::Range::new(lsp::Position::new(0, 24), lsp::Position::new(0, 27)),
|
||||||
},
|
},
|
||||||
lsp::Location {
|
lsp::Location {
|
||||||
uri: lsp::Uri::from_file_path("/root/dir-1/two.rs")
|
uri: lsp::Url::from_file_path("/root/dir-1/two.rs").unwrap(),
|
||||||
.unwrap()
|
|
||||||
.into(),
|
|
||||||
range: lsp::Range::new(lsp::Position::new(0, 35), lsp::Position::new(0, 38)),
|
range: lsp::Range::new(lsp::Position::new(0, 35), lsp::Position::new(0, 38)),
|
||||||
},
|
},
|
||||||
lsp::Location {
|
lsp::Location {
|
||||||
uri: lsp::Uri::from_file_path("/root/dir-2/three.rs")
|
uri: lsp::Url::from_file_path("/root/dir-2/three.rs").unwrap(),
|
||||||
.unwrap()
|
|
||||||
.into(),
|
|
||||||
range: lsp::Range::new(lsp::Position::new(0, 37), lsp::Position::new(0, 40)),
|
range: lsp::Range::new(lsp::Position::new(0, 37), lsp::Position::new(0, 40)),
|
||||||
},
|
},
|
||||||
])))
|
])))
|
||||||
@ -5300,9 +5292,7 @@ async fn test_project_symbols(
|
|||||||
lsp::SymbolInformation {
|
lsp::SymbolInformation {
|
||||||
name: "TWO".into(),
|
name: "TWO".into(),
|
||||||
location: lsp::Location {
|
location: lsp::Location {
|
||||||
uri: lsp::Uri::from_file_path("/code/crate-2/two.rs")
|
uri: lsp::Url::from_file_path("/code/crate-2/two.rs").unwrap(),
|
||||||
.unwrap()
|
|
||||||
.into(),
|
|
||||||
range: lsp::Range::new(lsp::Position::new(0, 6), lsp::Position::new(0, 9)),
|
range: lsp::Range::new(lsp::Position::new(0, 6), lsp::Position::new(0, 9)),
|
||||||
},
|
},
|
||||||
kind: lsp::SymbolKind::CONSTANT,
|
kind: lsp::SymbolKind::CONSTANT,
|
||||||
@ -5392,7 +5382,7 @@ async fn test_open_buffer_while_getting_definition_pointing_to_it(
|
|||||||
fake_language_server.handle_request::<lsp::request::GotoDefinition, _, _>(|_, _| async move {
|
fake_language_server.handle_request::<lsp::request::GotoDefinition, _, _>(|_, _| async move {
|
||||||
Ok(Some(lsp::GotoDefinitionResponse::Scalar(
|
Ok(Some(lsp::GotoDefinitionResponse::Scalar(
|
||||||
lsp::Location::new(
|
lsp::Location::new(
|
||||||
lsp::Uri::from_file_path("/root/b.rs").unwrap().into(),
|
lsp::Url::from_file_path("/root/b.rs").unwrap(),
|
||||||
lsp::Range::new(lsp::Position::new(0, 6), lsp::Position::new(0, 9)),
|
lsp::Range::new(lsp::Position::new(0, 6), lsp::Position::new(0, 9)),
|
||||||
),
|
),
|
||||||
)))
|
)))
|
||||||
|
@ -1101,7 +1101,7 @@ impl RandomizedTest for ProjectCollaborationTest {
|
|||||||
files
|
files
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|file| lsp::Location {
|
.map(|file| lsp::Location {
|
||||||
uri: lsp::Uri::from_file_path(file).unwrap().into(),
|
uri: lsp::Url::from_file_path(file).unwrap(),
|
||||||
range: Default::default(),
|
range: Default::default(),
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
|
@ -188,7 +188,7 @@ impl Status {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct RegisteredBuffer {
|
struct RegisteredBuffer {
|
||||||
uri: lsp::RawUri,
|
uri: lsp::Url,
|
||||||
language_id: String,
|
language_id: String,
|
||||||
snapshot: BufferSnapshot,
|
snapshot: BufferSnapshot,
|
||||||
snapshot_version: i32,
|
snapshot_version: i32,
|
||||||
@ -644,7 +644,7 @@ impl Copilot {
|
|||||||
registered_buffers
|
registered_buffers
|
||||||
.entry(buffer.entity_id())
|
.entry(buffer.entity_id())
|
||||||
.or_insert_with(|| {
|
.or_insert_with(|| {
|
||||||
let uri = uri_for_buffer(buffer, cx);
|
let uri: lsp::Url = uri_for_buffer(buffer, cx);
|
||||||
let language_id = id_for_language(buffer.read(cx).language());
|
let language_id = id_for_language(buffer.read(cx).language());
|
||||||
let snapshot = buffer.read(cx).snapshot();
|
let snapshot = buffer.read(cx).snapshot();
|
||||||
server
|
server
|
||||||
@ -959,9 +959,9 @@ fn id_for_language(language: Option<&Arc<Language>>) -> String {
|
|||||||
.unwrap_or_else(|| "plaintext".to_string())
|
.unwrap_or_else(|| "plaintext".to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn uri_for_buffer(buffer: &Model<Buffer>, cx: &AppContext) -> lsp::RawUri {
|
fn uri_for_buffer(buffer: &Model<Buffer>, cx: &AppContext) -> lsp::Url {
|
||||||
if let Some(file) = buffer.read(cx).file().and_then(|file| file.as_local()) {
|
if let Some(file) = buffer.read(cx).file().and_then(|file| file.as_local()) {
|
||||||
lsp::Uri::from_file_path(file.abs_path(cx)).unwrap().into()
|
lsp::Url::from_file_path(file.abs_path(cx)).unwrap()
|
||||||
} else {
|
} else {
|
||||||
format!("buffer://{}", buffer.entity_id()).parse().unwrap()
|
format!("buffer://{}", buffer.entity_id()).parse().unwrap()
|
||||||
}
|
}
|
||||||
@ -1042,8 +1042,6 @@ async fn get_copilot_lsp(http: Arc<dyn HttpClient>) -> anyhow::Result<PathBuf> {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::str::FromStr;
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use gpui::TestAppContext;
|
use gpui::TestAppContext;
|
||||||
|
|
||||||
@ -1052,8 +1050,9 @@ mod tests {
|
|||||||
let (copilot, mut lsp) = Copilot::fake(cx);
|
let (copilot, mut lsp) = Copilot::fake(cx);
|
||||||
|
|
||||||
let buffer_1 = cx.new_model(|cx| Buffer::local("Hello", cx));
|
let buffer_1 = cx.new_model(|cx| Buffer::local("Hello", cx));
|
||||||
let buffer_1_uri =
|
let buffer_1_uri: lsp::Url = format!("buffer://{}", buffer_1.entity_id().as_u64())
|
||||||
lsp::RawUri::from_str(&format!("buffer://{}", buffer_1.entity_id().as_u64())).unwrap();
|
.parse()
|
||||||
|
.unwrap();
|
||||||
copilot.update(cx, |copilot, cx| copilot.register_buffer(&buffer_1, cx));
|
copilot.update(cx, |copilot, cx| copilot.register_buffer(&buffer_1, cx));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
lsp.receive_notification::<lsp::notification::DidOpenTextDocument>()
|
lsp.receive_notification::<lsp::notification::DidOpenTextDocument>()
|
||||||
@ -1069,8 +1068,9 @@ mod tests {
|
|||||||
);
|
);
|
||||||
|
|
||||||
let buffer_2 = cx.new_model(|cx| Buffer::local("Goodbye", cx));
|
let buffer_2 = cx.new_model(|cx| Buffer::local("Goodbye", cx));
|
||||||
let buffer_2_uri =
|
let buffer_2_uri: lsp::Url = format!("buffer://{}", buffer_2.entity_id().as_u64())
|
||||||
lsp::RawUri::from_str(&format!("buffer://{}", buffer_2.entity_id().as_u64())).unwrap();
|
.parse()
|
||||||
|
.unwrap();
|
||||||
copilot.update(cx, |copilot, cx| copilot.register_buffer(&buffer_2, cx));
|
copilot.update(cx, |copilot, cx| copilot.register_buffer(&buffer_2, cx));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
lsp.receive_notification::<lsp::notification::DidOpenTextDocument>()
|
lsp.receive_notification::<lsp::notification::DidOpenTextDocument>()
|
||||||
@ -1119,9 +1119,7 @@ mod tests {
|
|||||||
text_document: lsp::TextDocumentIdentifier::new(buffer_1_uri),
|
text_document: lsp::TextDocumentIdentifier::new(buffer_1_uri),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
let buffer_1_uri: lsp::RawUri = lsp::Uri::from_file_path("/root/child/buffer-1")
|
let buffer_1_uri = lsp::Url::from_file_path("/root/child/buffer-1").unwrap();
|
||||||
.unwrap()
|
|
||||||
.into();
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
lsp.receive_notification::<lsp::notification::DidOpenTextDocument>()
|
lsp.receive_notification::<lsp::notification::DidOpenTextDocument>()
|
||||||
.await,
|
.await,
|
||||||
|
@ -1121,10 +1121,7 @@ mod tests {
|
|||||||
cx.handle_request::<lsp::request::Completion, _, _>(move |url, params, _| {
|
cx.handle_request::<lsp::request::Completion, _, _>(move |url, params, _| {
|
||||||
let completions = completions.clone();
|
let completions = completions.clone();
|
||||||
async move {
|
async move {
|
||||||
assert_eq!(
|
assert_eq!(params.text_document_position.text_document.uri, url.clone());
|
||||||
params.text_document_position.text_document.uri,
|
|
||||||
url.clone().into()
|
|
||||||
);
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
params.text_document_position.position,
|
params.text_document_position.position,
|
||||||
complete_from_position
|
complete_from_position
|
||||||
|
@ -102,7 +102,7 @@ pub struct GetCompletionsDocument {
|
|||||||
pub tab_size: u32,
|
pub tab_size: u32,
|
||||||
pub indent_size: u32,
|
pub indent_size: u32,
|
||||||
pub insert_spaces: bool,
|
pub insert_spaces: bool,
|
||||||
pub uri: lsp::RawUri,
|
pub uri: lsp::Url,
|
||||||
pub relative_path: String,
|
pub relative_path: String,
|
||||||
pub position: lsp::Position,
|
pub position: lsp::Position,
|
||||||
pub version: usize,
|
pub version: usize,
|
||||||
|
@ -8971,7 +8971,7 @@ impl Editor {
|
|||||||
});
|
});
|
||||||
language_server_name.map(|language_server_name| {
|
language_server_name.map(|language_server_name| {
|
||||||
project.open_local_buffer_via_lsp(
|
project.open_local_buffer_via_lsp(
|
||||||
lsp::Uri::from(lsp_location.uri.clone()),
|
lsp_location.uri.clone(),
|
||||||
server_id,
|
server_id,
|
||||||
language_server_name,
|
language_server_name,
|
||||||
cx,
|
cx,
|
||||||
|
@ -5861,7 +5861,7 @@ async fn test_document_format_during_save(cx: &mut gpui::TestAppContext) {
|
|||||||
.handle_request::<lsp::request::Formatting, _, _>(move |params, _| async move {
|
.handle_request::<lsp::request::Formatting, _, _>(move |params, _| async move {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
params.text_document.uri,
|
params.text_document.uri,
|
||||||
lsp::Uri::from_file_path("/file.rs").unwrap().into()
|
lsp::Url::from_file_path("/file.rs").unwrap()
|
||||||
);
|
);
|
||||||
assert_eq!(params.options.tab_size, 4);
|
assert_eq!(params.options.tab_size, 4);
|
||||||
Ok(Some(vec![lsp::TextEdit::new(
|
Ok(Some(vec![lsp::TextEdit::new(
|
||||||
@ -5887,7 +5887,7 @@ async fn test_document_format_during_save(cx: &mut gpui::TestAppContext) {
|
|||||||
fake_server.handle_request::<lsp::request::Formatting, _, _>(move |params, _| async move {
|
fake_server.handle_request::<lsp::request::Formatting, _, _>(move |params, _| async move {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
params.text_document.uri,
|
params.text_document.uri,
|
||||||
lsp::Uri::from_file_path("/file.rs").unwrap().into()
|
lsp::Url::from_file_path("/file.rs").unwrap()
|
||||||
);
|
);
|
||||||
futures::future::pending::<()>().await;
|
futures::future::pending::<()>().await;
|
||||||
unreachable!()
|
unreachable!()
|
||||||
@ -5936,7 +5936,7 @@ async fn test_document_format_during_save(cx: &mut gpui::TestAppContext) {
|
|||||||
.handle_request::<lsp::request::Formatting, _, _>(move |params, _| async move {
|
.handle_request::<lsp::request::Formatting, _, _>(move |params, _| async move {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
params.text_document.uri,
|
params.text_document.uri,
|
||||||
lsp::Uri::from_file_path("/file.rs").unwrap().into()
|
lsp::Url::from_file_path("/file.rs").unwrap()
|
||||||
);
|
);
|
||||||
assert_eq!(params.options.tab_size, 8);
|
assert_eq!(params.options.tab_size, 8);
|
||||||
Ok(Some(vec![]))
|
Ok(Some(vec![]))
|
||||||
@ -6139,7 +6139,7 @@ async fn test_multibuffer_format_during_save(cx: &mut gpui::TestAppContext) {
|
|||||||
.on_request::<lsp::request::Formatting, _, _>(move |params, _| async move {
|
.on_request::<lsp::request::Formatting, _, _>(move |params, _| async move {
|
||||||
Ok(Some(vec![lsp::TextEdit::new(
|
Ok(Some(vec![lsp::TextEdit::new(
|
||||||
lsp::Range::new(lsp::Position::new(0, 3), lsp::Position::new(1, 0)),
|
lsp::Range::new(lsp::Position::new(0, 3), lsp::Position::new(1, 0)),
|
||||||
format!("[{} formatted]", params.text_document.uri.as_str()),
|
format!("[{} formatted]", params.text_document.uri),
|
||||||
)]))
|
)]))
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
@ -6213,7 +6213,7 @@ async fn test_range_format_during_save(cx: &mut gpui::TestAppContext) {
|
|||||||
.handle_request::<lsp::request::RangeFormatting, _, _>(move |params, _| async move {
|
.handle_request::<lsp::request::RangeFormatting, _, _>(move |params, _| async move {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
params.text_document.uri,
|
params.text_document.uri,
|
||||||
lsp::Uri::from_file_path("/file.rs").unwrap().into()
|
lsp::Url::from_file_path("/file.rs").unwrap()
|
||||||
);
|
);
|
||||||
assert_eq!(params.options.tab_size, 4);
|
assert_eq!(params.options.tab_size, 4);
|
||||||
Ok(Some(vec![lsp::TextEdit::new(
|
Ok(Some(vec![lsp::TextEdit::new(
|
||||||
@ -6239,7 +6239,7 @@ async fn test_range_format_during_save(cx: &mut gpui::TestAppContext) {
|
|||||||
move |params, _| async move {
|
move |params, _| async move {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
params.text_document.uri,
|
params.text_document.uri,
|
||||||
lsp::Uri::from_file_path("/file.rs").unwrap().into()
|
lsp::Url::from_file_path("/file.rs").unwrap()
|
||||||
);
|
);
|
||||||
futures::future::pending::<()>().await;
|
futures::future::pending::<()>().await;
|
||||||
unreachable!()
|
unreachable!()
|
||||||
@ -6289,7 +6289,7 @@ async fn test_range_format_during_save(cx: &mut gpui::TestAppContext) {
|
|||||||
.handle_request::<lsp::request::RangeFormatting, _, _>(move |params, _| async move {
|
.handle_request::<lsp::request::RangeFormatting, _, _>(move |params, _| async move {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
params.text_document.uri,
|
params.text_document.uri,
|
||||||
lsp::Uri::from_file_path("/file.rs").unwrap().into()
|
lsp::Url::from_file_path("/file.rs").unwrap()
|
||||||
);
|
);
|
||||||
assert_eq!(params.options.tab_size, 8);
|
assert_eq!(params.options.tab_size, 8);
|
||||||
Ok(Some(vec![]))
|
Ok(Some(vec![]))
|
||||||
@ -6363,7 +6363,7 @@ async fn test_document_format_manual_trigger(cx: &mut gpui::TestAppContext) {
|
|||||||
.handle_request::<lsp::request::Formatting, _, _>(move |params, _| async move {
|
.handle_request::<lsp::request::Formatting, _, _>(move |params, _| async move {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
params.text_document.uri,
|
params.text_document.uri,
|
||||||
lsp::Uri::from_file_path("/file.rs").unwrap().into()
|
lsp::Url::from_file_path("/file.rs").unwrap()
|
||||||
);
|
);
|
||||||
assert_eq!(params.options.tab_size, 4);
|
assert_eq!(params.options.tab_size, 4);
|
||||||
Ok(Some(vec![lsp::TextEdit::new(
|
Ok(Some(vec![lsp::TextEdit::new(
|
||||||
@ -6385,7 +6385,7 @@ async fn test_document_format_manual_trigger(cx: &mut gpui::TestAppContext) {
|
|||||||
fake_server.handle_request::<lsp::request::Formatting, _, _>(move |params, _| async move {
|
fake_server.handle_request::<lsp::request::Formatting, _, _>(move |params, _| async move {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
params.text_document.uri,
|
params.text_document.uri,
|
||||||
lsp::Uri::from_file_path("/file.rs").unwrap().into()
|
lsp::Url::from_file_path("/file.rs").unwrap()
|
||||||
);
|
);
|
||||||
futures::future::pending::<()>().await;
|
futures::future::pending::<()>().await;
|
||||||
unreachable!()
|
unreachable!()
|
||||||
@ -8028,7 +8028,7 @@ async fn go_to_prev_overlapping_diagnostic(
|
|||||||
.update_diagnostics(
|
.update_diagnostics(
|
||||||
LanguageServerId(0),
|
LanguageServerId(0),
|
||||||
lsp::PublishDiagnosticsParams {
|
lsp::PublishDiagnosticsParams {
|
||||||
uri: lsp::Uri::from_file_path("/root/file").unwrap().into(),
|
uri: lsp::Url::from_file_path("/root/file").unwrap(),
|
||||||
version: None,
|
version: None,
|
||||||
diagnostics: vec![
|
diagnostics: vec![
|
||||||
lsp::Diagnostic {
|
lsp::Diagnostic {
|
||||||
@ -8400,7 +8400,7 @@ async fn test_on_type_formatting_not_triggered(cx: &mut gpui::TestAppContext) {
|
|||||||
fake_server.handle_request::<lsp::request::OnTypeFormatting, _, _>(|params, _| async move {
|
fake_server.handle_request::<lsp::request::OnTypeFormatting, _, _>(|params, _| async move {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
params.text_document_position.text_document.uri,
|
params.text_document_position.text_document.uri,
|
||||||
lsp::Uri::from_file_path("/a/main.rs").unwrap().into(),
|
lsp::Url::from_file_path("/a/main.rs").unwrap(),
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
params.text_document_position.position,
|
params.text_document_position.position,
|
||||||
@ -12151,10 +12151,7 @@ pub fn handle_completion_request(
|
|||||||
let completions = completions.clone();
|
let completions = completions.clone();
|
||||||
counter.fetch_add(1, atomic::Ordering::Release);
|
counter.fetch_add(1, atomic::Ordering::Release);
|
||||||
async move {
|
async move {
|
||||||
assert_eq!(
|
assert_eq!(params.text_document_position.text_document.uri, url.clone());
|
||||||
params.text_document_position.text_document.uri,
|
|
||||||
url.clone().into()
|
|
||||||
);
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
params.text_document_position.position,
|
params.text_document_position.position,
|
||||||
complete_from_position
|
complete_from_position
|
||||||
|
@ -741,7 +741,7 @@ mod tests {
|
|||||||
Ok(Some(lsp::GotoTypeDefinitionResponse::Link(vec![
|
Ok(Some(lsp::GotoTypeDefinitionResponse::Link(vec![
|
||||||
lsp::LocationLink {
|
lsp::LocationLink {
|
||||||
origin_selection_range: Some(symbol_range),
|
origin_selection_range: Some(symbol_range),
|
||||||
target_uri: url.clone().into(),
|
target_uri: url.clone(),
|
||||||
target_range,
|
target_range,
|
||||||
target_selection_range: target_range,
|
target_selection_range: target_range,
|
||||||
},
|
},
|
||||||
@ -815,7 +815,7 @@ mod tests {
|
|||||||
Ok(Some(lsp::GotoDefinitionResponse::Link(vec![
|
Ok(Some(lsp::GotoDefinitionResponse::Link(vec![
|
||||||
lsp::LocationLink {
|
lsp::LocationLink {
|
||||||
origin_selection_range: Some(symbol_range),
|
origin_selection_range: Some(symbol_range),
|
||||||
target_uri: url.clone().into(),
|
target_uri: url.clone(),
|
||||||
target_range,
|
target_range,
|
||||||
target_selection_range: target_range,
|
target_selection_range: target_range,
|
||||||
},
|
},
|
||||||
@ -841,7 +841,7 @@ mod tests {
|
|||||||
Ok(Some(lsp::GotoDefinitionResponse::Link(vec![
|
Ok(Some(lsp::GotoDefinitionResponse::Link(vec![
|
||||||
lsp::LocationLink {
|
lsp::LocationLink {
|
||||||
origin_selection_range: Some(symbol_range),
|
origin_selection_range: Some(symbol_range),
|
||||||
target_uri: url.clone().into(),
|
target_uri: url.clone(),
|
||||||
target_range,
|
target_range,
|
||||||
target_selection_range: target_range,
|
target_selection_range: target_range,
|
||||||
},
|
},
|
||||||
@ -904,7 +904,7 @@ mod tests {
|
|||||||
Ok(Some(lsp::GotoDefinitionResponse::Link(vec![
|
Ok(Some(lsp::GotoDefinitionResponse::Link(vec![
|
||||||
lsp::LocationLink {
|
lsp::LocationLink {
|
||||||
origin_selection_range: Some(symbol_range),
|
origin_selection_range: Some(symbol_range),
|
||||||
target_uri: url.into(),
|
target_uri: url,
|
||||||
target_range,
|
target_range,
|
||||||
target_selection_range: target_range,
|
target_selection_range: target_range,
|
||||||
},
|
},
|
||||||
@ -980,7 +980,7 @@ mod tests {
|
|||||||
Ok(Some(lsp::GotoDefinitionResponse::Link(vec![
|
Ok(Some(lsp::GotoDefinitionResponse::Link(vec![
|
||||||
lsp::LocationLink {
|
lsp::LocationLink {
|
||||||
origin_selection_range: None,
|
origin_selection_range: None,
|
||||||
target_uri: url.into(),
|
target_uri: url,
|
||||||
target_range,
|
target_range,
|
||||||
target_selection_range: target_range,
|
target_selection_range: target_range,
|
||||||
},
|
},
|
||||||
@ -1008,7 +1008,7 @@ mod tests {
|
|||||||
Ok(Some(lsp::GotoDefinitionResponse::Link(vec![
|
Ok(Some(lsp::GotoDefinitionResponse::Link(vec![
|
||||||
lsp::LocationLink {
|
lsp::LocationLink {
|
||||||
origin_selection_range: None,
|
origin_selection_range: None,
|
||||||
target_uri: url.into(),
|
target_uri: url,
|
||||||
target_range,
|
target_range,
|
||||||
target_selection_range: target_range,
|
target_selection_range: target_range,
|
||||||
},
|
},
|
||||||
@ -1088,7 +1088,7 @@ mod tests {
|
|||||||
let hint_label = ": TestStruct";
|
let hint_label = ": TestStruct";
|
||||||
cx.lsp
|
cx.lsp
|
||||||
.handle_request::<lsp::request::InlayHintRequest, _, _>(move |params, _| {
|
.handle_request::<lsp::request::InlayHintRequest, _, _>(move |params, _| {
|
||||||
let expected_uri = expected_uri.clone().into();
|
let expected_uri = expected_uri.clone();
|
||||||
async move {
|
async move {
|
||||||
assert_eq!(params.text_document.uri, expected_uri);
|
assert_eq!(params.text_document.uri, expected_uri);
|
||||||
Ok(Some(vec![lsp::InlayHint {
|
Ok(Some(vec![lsp::InlayHint {
|
||||||
|
@ -1376,7 +1376,7 @@ mod tests {
|
|||||||
let closure_uri = uri.clone();
|
let closure_uri = uri.clone();
|
||||||
cx.lsp
|
cx.lsp
|
||||||
.handle_request::<lsp::request::InlayHintRequest, _, _>(move |params, _| {
|
.handle_request::<lsp::request::InlayHintRequest, _, _>(move |params, _| {
|
||||||
let task_uri = closure_uri.clone().into();
|
let task_uri = closure_uri.clone();
|
||||||
async move {
|
async move {
|
||||||
assert_eq!(params.text_document.uri, task_uri);
|
assert_eq!(params.text_document.uri, task_uri);
|
||||||
Ok(Some(vec![lsp::InlayHint {
|
Ok(Some(vec![lsp::InlayHint {
|
||||||
@ -1467,7 +1467,7 @@ mod tests {
|
|||||||
lsp::InlayHintLabelPart {
|
lsp::InlayHintLabelPart {
|
||||||
value: new_type_label.to_string(),
|
value: new_type_label.to_string(),
|
||||||
location: Some(lsp::Location {
|
location: Some(lsp::Location {
|
||||||
uri: task_uri.clone().into(),
|
uri: task_uri.clone(),
|
||||||
range: new_type_target_range,
|
range: new_type_target_range,
|
||||||
}),
|
}),
|
||||||
tooltip: Some(lsp::InlayHintLabelPartTooltip::String(format!(
|
tooltip: Some(lsp::InlayHintLabelPartTooltip::String(format!(
|
||||||
@ -1482,7 +1482,7 @@ mod tests {
|
|||||||
lsp::InlayHintLabelPart {
|
lsp::InlayHintLabelPart {
|
||||||
value: struct_label.to_string(),
|
value: struct_label.to_string(),
|
||||||
location: Some(lsp::Location {
|
location: Some(lsp::Location {
|
||||||
uri: task_uri.into(),
|
uri: task_uri,
|
||||||
range: struct_target_range,
|
range: struct_target_range,
|
||||||
}),
|
}),
|
||||||
tooltip: Some(lsp::InlayHintLabelPartTooltip::MarkupContent(
|
tooltip: Some(lsp::InlayHintLabelPartTooltip::MarkupContent(
|
||||||
|
@ -1307,7 +1307,7 @@ pub mod tests {
|
|||||||
async move {
|
async move {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
params.text_document.uri,
|
params.text_document.uri,
|
||||||
lsp::Uri::from_file_path(file_with_hints).unwrap().into(),
|
lsp::Url::from_file_path(file_with_hints).unwrap(),
|
||||||
);
|
);
|
||||||
let current_call_id =
|
let current_call_id =
|
||||||
Arc::clone(&task_lsp_request_count).fetch_add(1, Ordering::SeqCst);
|
Arc::clone(&task_lsp_request_count).fetch_add(1, Ordering::SeqCst);
|
||||||
@ -1439,7 +1439,7 @@ pub mod tests {
|
|||||||
async move {
|
async move {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
params.text_document.uri,
|
params.text_document.uri,
|
||||||
lsp::Uri::from_file_path(file_with_hints).unwrap().into(),
|
lsp::Url::from_file_path(file_with_hints).unwrap(),
|
||||||
);
|
);
|
||||||
let current_call_id =
|
let current_call_id =
|
||||||
Arc::clone(&task_lsp_request_count).fetch_add(1, Ordering::SeqCst);
|
Arc::clone(&task_lsp_request_count).fetch_add(1, Ordering::SeqCst);
|
||||||
@ -1613,7 +1613,7 @@ pub mod tests {
|
|||||||
async move {
|
async move {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
params.text_document.uri,
|
params.text_document.uri,
|
||||||
lsp::Uri::from_file_path("/a/main.rs").unwrap().into(),
|
lsp::Url::from_file_path("/a/main.rs").unwrap(),
|
||||||
);
|
);
|
||||||
let i = Arc::clone(&task_lsp_request_count).fetch_add(1, Ordering::SeqCst);
|
let i = Arc::clone(&task_lsp_request_count).fetch_add(1, Ordering::SeqCst);
|
||||||
Ok(Some(vec![lsp::InlayHint {
|
Ok(Some(vec![lsp::InlayHint {
|
||||||
@ -1666,7 +1666,7 @@ pub mod tests {
|
|||||||
async move {
|
async move {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
params.text_document.uri,
|
params.text_document.uri,
|
||||||
lsp::Uri::from_file_path("/a/other.md").unwrap().into(),
|
lsp::Url::from_file_path("/a/other.md").unwrap(),
|
||||||
);
|
);
|
||||||
let i = Arc::clone(&task_lsp_request_count).fetch_add(1, Ordering::SeqCst);
|
let i = Arc::clone(&task_lsp_request_count).fetch_add(1, Ordering::SeqCst);
|
||||||
Ok(Some(vec![lsp::InlayHint {
|
Ok(Some(vec![lsp::InlayHint {
|
||||||
@ -1790,7 +1790,7 @@ pub mod tests {
|
|||||||
Arc::clone(&task_lsp_request_count).fetch_add(1, Ordering::SeqCst);
|
Arc::clone(&task_lsp_request_count).fetch_add(1, Ordering::SeqCst);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
params.text_document.uri,
|
params.text_document.uri,
|
||||||
lsp::Uri::from_file_path(file_with_hints).unwrap().into(),
|
lsp::Url::from_file_path(file_with_hints).unwrap(),
|
||||||
);
|
);
|
||||||
Ok(Some(vec![
|
Ok(Some(vec![
|
||||||
lsp::InlayHint {
|
lsp::InlayHint {
|
||||||
@ -2136,7 +2136,7 @@ pub mod tests {
|
|||||||
let i = Arc::clone(&task_lsp_request_count).fetch_add(1, Ordering::SeqCst) + 1;
|
let i = Arc::clone(&task_lsp_request_count).fetch_add(1, Ordering::SeqCst) + 1;
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
params.text_document.uri,
|
params.text_document.uri,
|
||||||
lsp::Uri::from_file_path(file_with_hints).unwrap().into(),
|
lsp::Url::from_file_path(file_with_hints).unwrap(),
|
||||||
);
|
);
|
||||||
Ok(Some(vec![lsp::InlayHint {
|
Ok(Some(vec![lsp::InlayHint {
|
||||||
position: lsp::Position::new(0, i),
|
position: lsp::Position::new(0, i),
|
||||||
@ -2305,7 +2305,7 @@ pub mod tests {
|
|||||||
async move {
|
async move {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
params.text_document.uri,
|
params.text_document.uri,
|
||||||
lsp::Uri::from_file_path("/a/main.rs").unwrap().into(),
|
lsp::Url::from_file_path("/a/main.rs").unwrap(),
|
||||||
);
|
);
|
||||||
|
|
||||||
task_lsp_request_ranges.lock().push(params.range);
|
task_lsp_request_ranges.lock().push(params.range);
|
||||||
@ -2673,11 +2673,11 @@ pub mod tests {
|
|||||||
let task_editor_edited = Arc::clone(&closure_editor_edited);
|
let task_editor_edited = Arc::clone(&closure_editor_edited);
|
||||||
async move {
|
async move {
|
||||||
let hint_text = if params.text_document.uri
|
let hint_text = if params.text_document.uri
|
||||||
== lsp::Uri::from_file_path("/a/main.rs").unwrap().into()
|
== lsp::Url::from_file_path("/a/main.rs").unwrap()
|
||||||
{
|
{
|
||||||
"main hint"
|
"main hint"
|
||||||
} else if params.text_document.uri
|
} else if params.text_document.uri
|
||||||
== lsp::Uri::from_file_path("/a/other.rs").unwrap().into()
|
== lsp::Url::from_file_path("/a/other.rs").unwrap()
|
||||||
{
|
{
|
||||||
"other hint"
|
"other hint"
|
||||||
} else {
|
} else {
|
||||||
@ -2981,11 +2981,11 @@ pub mod tests {
|
|||||||
let task_editor_edited = Arc::clone(&closure_editor_edited);
|
let task_editor_edited = Arc::clone(&closure_editor_edited);
|
||||||
async move {
|
async move {
|
||||||
let hint_text = if params.text_document.uri
|
let hint_text = if params.text_document.uri
|
||||||
== lsp::Uri::from_file_path("/a/main.rs").unwrap().into()
|
== lsp::Url::from_file_path("/a/main.rs").unwrap()
|
||||||
{
|
{
|
||||||
"main hint"
|
"main hint"
|
||||||
} else if params.text_document.uri
|
} else if params.text_document.uri
|
||||||
== lsp::Uri::from_file_path("/a/other.rs").unwrap().into()
|
== lsp::Url::from_file_path("/a/other.rs").unwrap()
|
||||||
{
|
{
|
||||||
"other hint"
|
"other hint"
|
||||||
} else {
|
} else {
|
||||||
@ -3177,7 +3177,7 @@ pub mod tests {
|
|||||||
async move {
|
async move {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
params.text_document.uri,
|
params.text_document.uri,
|
||||||
lsp::Uri::from_file_path("/a/main.rs").unwrap().into(),
|
lsp::Url::from_file_path("/a/main.rs").unwrap(),
|
||||||
);
|
);
|
||||||
let query_start = params.range.start;
|
let query_start = params.range.start;
|
||||||
let i = Arc::clone(&task_lsp_request_count).fetch_add(1, Ordering::Release) + 1;
|
let i = Arc::clone(&task_lsp_request_count).fetch_add(1, Ordering::Release) + 1;
|
||||||
@ -3244,7 +3244,7 @@ pub mod tests {
|
|||||||
async move {
|
async move {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
params.text_document.uri,
|
params.text_document.uri,
|
||||||
lsp::Uri::from_file_path(file_with_hints).unwrap().into(),
|
lsp::Url::from_file_path(file_with_hints).unwrap(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let i = Arc::clone(&task_lsp_request_count).fetch_add(1, Ordering::SeqCst) + 1;
|
let i = Arc::clone(&task_lsp_request_count).fetch_add(1, Ordering::SeqCst) + 1;
|
||||||
|
@ -27,7 +27,7 @@ pub struct EditorLspTestContext {
|
|||||||
pub cx: EditorTestContext,
|
pub cx: EditorTestContext,
|
||||||
pub lsp: lsp::FakeLanguageServer,
|
pub lsp: lsp::FakeLanguageServer,
|
||||||
pub workspace: View<Workspace>,
|
pub workspace: View<Workspace>,
|
||||||
pub buffer_lsp_url: lsp::Uri,
|
pub buffer_lsp_url: lsp::Url,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EditorLspTestContext {
|
impl EditorLspTestContext {
|
||||||
@ -113,7 +113,7 @@ impl EditorLspTestContext {
|
|||||||
},
|
},
|
||||||
lsp,
|
lsp,
|
||||||
workspace,
|
workspace,
|
||||||
buffer_lsp_url: lsp::Uri::from_file_path(format!("/root/dir/{file_name}")).unwrap(),
|
buffer_lsp_url: lsp::Url::from_file_path(format!("/root/dir/{file_name}")).unwrap(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,7 +299,7 @@ impl EditorLspTestContext {
|
|||||||
where
|
where
|
||||||
T: 'static + request::Request,
|
T: 'static + request::Request,
|
||||||
T::Params: 'static + Send,
|
T::Params: 'static + Send,
|
||||||
F: 'static + Send + FnMut(lsp::Uri, T::Params, gpui::AsyncAppContext) -> Fut,
|
F: 'static + Send + FnMut(lsp::Url, T::Params, gpui::AsyncAppContext) -> Fut,
|
||||||
Fut: 'static + Send + Future<Output = Result<T::Result>>,
|
Fut: 'static + Send + Future<Output = Result<T::Result>>,
|
||||||
{
|
{
|
||||||
let url = self.buffer_lsp_url.clone();
|
let url = self.buffer_lsp_url.clone();
|
||||||
|
@ -533,7 +533,7 @@ mod tests {
|
|||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
async fn test_process_rust_diagnostics() {
|
async fn test_process_rust_diagnostics() {
|
||||||
let mut params = lsp::PublishDiagnosticsParams {
|
let mut params = lsp::PublishDiagnosticsParams {
|
||||||
uri: lsp::Uri::from_file_path("/a").unwrap().into(),
|
uri: lsp::Url::from_file_path("/a").unwrap(),
|
||||||
version: None,
|
version: None,
|
||||||
diagnostics: vec![
|
diagnostics: vec![
|
||||||
// no newlines
|
// no newlines
|
||||||
|
@ -22,9 +22,8 @@ collections.workspace = true
|
|||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
gpui.workspace = true
|
gpui.workspace = true
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
lsp-types = { git = "https://github.com/zed-industries/lsp-types", branch = "zed-main" }
|
lsp-types = { git = "https://github.com/zed-industries/lsp-types", rev = "72357d6f6d212bdffba3b5ef4b31d8ca856058e7" }
|
||||||
parking_lot.workspace = true
|
parking_lot.workspace = true
|
||||||
pct-str = "2.0"
|
|
||||||
postage.workspace = true
|
postage.workspace = true
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
|
@ -3,9 +3,7 @@ mod input_handler;
|
|||||||
pub use lsp_types::request::*;
|
pub use lsp_types::request::*;
|
||||||
pub use lsp_types::*;
|
pub use lsp_types::*;
|
||||||
|
|
||||||
pub use lsp_types::Uri as RawUri;
|
use anyhow::{anyhow, Context, Result};
|
||||||
|
|
||||||
use anyhow::{anyhow, bail, Context, Result};
|
|
||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
use futures::{channel::oneshot, io::BufWriter, select, AsyncRead, AsyncWrite, Future, FutureExt};
|
use futures::{channel::oneshot, io::BufWriter, select, AsyncRead, AsyncWrite, Future, FutureExt};
|
||||||
use gpui::{AppContext, AsyncAppContext, BackgroundExecutor, Task};
|
use gpui::{AppContext, AsyncAppContext, BackgroundExecutor, Task};
|
||||||
@ -23,13 +21,11 @@ use smol::{
|
|||||||
use smol::process::windows::CommandExt;
|
use smol::process::windows::CommandExt;
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
borrow::Cow,
|
|
||||||
ffi::OsString,
|
ffi::OsString,
|
||||||
fmt,
|
fmt,
|
||||||
io::Write,
|
io::Write,
|
||||||
path::PathBuf,
|
path::PathBuf,
|
||||||
pin::Pin,
|
pin::Pin,
|
||||||
str::FromStr,
|
|
||||||
sync::{
|
sync::{
|
||||||
atomic::{AtomicI32, Ordering::SeqCst},
|
atomic::{AtomicI32, Ordering::SeqCst},
|
||||||
Arc, Weak,
|
Arc, Weak,
|
||||||
@ -58,61 +54,6 @@ pub enum IoKind {
|
|||||||
StdErr,
|
StdErr,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Hash, PartialEq)]
|
|
||||||
pub struct Uri(lsp_types::Uri);
|
|
||||||
|
|
||||||
const FILE_SCHEME: &str = "file://";
|
|
||||||
impl Uri {
|
|
||||||
pub fn from_file_path<P: AsRef<Path>>(path: P) -> Result<Self> {
|
|
||||||
let mut uri = FILE_SCHEME.to_owned();
|
|
||||||
for part in path.as_ref().components() {
|
|
||||||
let part: Cow<_> = match part {
|
|
||||||
std::path::Component::Prefix(prefix) => prefix.as_os_str().to_string_lossy(),
|
|
||||||
std::path::Component::RootDir => "/".into(),
|
|
||||||
std::path::Component::CurDir => ".".into(),
|
|
||||||
std::path::Component::ParentDir => "..".into(),
|
|
||||||
std::path::Component::Normal(component) => {
|
|
||||||
let as_str = component.to_string_lossy();
|
|
||||||
pct_str::PctString::encode(as_str.chars(), pct_str::URIReserved)
|
|
||||||
.to_string()
|
|
||||||
.into()
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if !uri.ends_with('/') {
|
|
||||||
uri.push('/');
|
|
||||||
}
|
|
||||||
uri.push_str(&part);
|
|
||||||
}
|
|
||||||
Ok(lsp_types::Uri::from_str(&uri)?.into())
|
|
||||||
}
|
|
||||||
pub fn to_file_path(self) -> Result<PathBuf> {
|
|
||||||
if self
|
|
||||||
.0
|
|
||||||
.scheme()
|
|
||||||
.map_or(true, |scheme| !scheme.eq_lowercase("file"))
|
|
||||||
{
|
|
||||||
bail!("file path does not have a file scheme");
|
|
||||||
}
|
|
||||||
Ok(self.0.path().as_str().into())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PartialEq<lsp_types::Uri> for Uri {
|
|
||||||
fn eq(&self, other: &lsp_types::Uri) -> bool {
|
|
||||||
self.0.eq(other)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl From<lsp_types::Uri> for Uri {
|
|
||||||
fn from(uri: lsp_types::Uri) -> Self {
|
|
||||||
Self(uri)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<Uri> for lsp_types::Uri {
|
|
||||||
fn from(uri: Uri) -> Self {
|
|
||||||
uri.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// Represents a launchable language server. This can either be a standalone binary or the path
|
/// Represents a launchable language server. This can either be a standalone binary or the path
|
||||||
/// to a runtime with arguments to instruct it to launch the actual language server file.
|
/// to a runtime with arguments to instruct it to launch the actual language server file.
|
||||||
#[derive(Debug, Clone, Deserialize)]
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
@ -582,12 +523,12 @@ impl LanguageServer {
|
|||||||
options: Option<Value>,
|
options: Option<Value>,
|
||||||
cx: &AppContext,
|
cx: &AppContext,
|
||||||
) -> Task<Result<Arc<Self>>> {
|
) -> Task<Result<Arc<Self>>> {
|
||||||
let root_uri = Uri::from_file_path(&self.working_dir).unwrap();
|
let root_uri = Url::from_file_path(&self.working_dir).unwrap();
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
let params = InitializeParams {
|
let params = InitializeParams {
|
||||||
process_id: None,
|
process_id: None,
|
||||||
root_path: None,
|
root_path: None,
|
||||||
root_uri: Some(root_uri.clone().into()),
|
root_uri: Some(root_uri.clone()),
|
||||||
initialization_options: options,
|
initialization_options: options,
|
||||||
capabilities: ClientCapabilities {
|
capabilities: ClientCapabilities {
|
||||||
workspace: Some(WorkspaceClientCapabilities {
|
workspace: Some(WorkspaceClientCapabilities {
|
||||||
@ -714,11 +655,10 @@ impl LanguageServer {
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
}),
|
}),
|
||||||
general: None,
|
general: None,
|
||||||
notebook_document: None,
|
|
||||||
},
|
},
|
||||||
trace: None,
|
trace: None,
|
||||||
workspace_folders: Some(vec![WorkspaceFolder {
|
workspace_folders: Some(vec![WorkspaceFolder {
|
||||||
uri: root_uri.into(),
|
uri: root_uri,
|
||||||
name: Default::default(),
|
name: Default::default(),
|
||||||
}]),
|
}]),
|
||||||
client_info: release_channel::ReleaseChannel::try_global(cx).map(|release_channel| {
|
client_info: release_channel::ReleaseChannel::try_global(cx).map(|release_channel| {
|
||||||
@ -1384,6 +1324,7 @@ impl FakeLanguageServer {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use gpui::{SemanticVersion, TestAppContext};
|
use gpui::{SemanticVersion, TestAppContext};
|
||||||
|
use std::str::FromStr;
|
||||||
|
|
||||||
#[ctor::ctor]
|
#[ctor::ctor]
|
||||||
fn init_logger() {
|
fn init_logger() {
|
||||||
@ -1426,7 +1367,7 @@ mod tests {
|
|||||||
server
|
server
|
||||||
.notify::<notification::DidOpenTextDocument>(DidOpenTextDocumentParams {
|
.notify::<notification::DidOpenTextDocument>(DidOpenTextDocumentParams {
|
||||||
text_document: TextDocumentItem::new(
|
text_document: TextDocumentItem::new(
|
||||||
RawUri::from_str("file://a/b").unwrap(),
|
Url::from_str("file://a/b").unwrap(),
|
||||||
"rust".to_string(),
|
"rust".to_string(),
|
||||||
0,
|
0,
|
||||||
"".to_string(),
|
"".to_string(),
|
||||||
@ -1447,7 +1388,7 @@ mod tests {
|
|||||||
message: "ok".to_string(),
|
message: "ok".to_string(),
|
||||||
});
|
});
|
||||||
fake.notify::<notification::PublishDiagnostics>(PublishDiagnosticsParams {
|
fake.notify::<notification::PublishDiagnostics>(PublishDiagnosticsParams {
|
||||||
uri: RawUri::from_str("file://b/c").unwrap(),
|
uri: Url::from_str("file://b/c").unwrap(),
|
||||||
version: Some(5),
|
version: Some(5),
|
||||||
diagnostics: vec![],
|
diagnostics: vec![],
|
||||||
});
|
});
|
||||||
|
@ -187,7 +187,7 @@ impl LspCommand for PrepareRename {
|
|||||||
) -> lsp::TextDocumentPositionParams {
|
) -> lsp::TextDocumentPositionParams {
|
||||||
lsp::TextDocumentPositionParams {
|
lsp::TextDocumentPositionParams {
|
||||||
text_document: lsp::TextDocumentIdentifier {
|
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),
|
position: point_to_lsp(self.position),
|
||||||
}
|
}
|
||||||
@ -311,7 +311,7 @@ impl LspCommand for PerformRename {
|
|||||||
lsp::RenameParams {
|
lsp::RenameParams {
|
||||||
text_document_position: lsp::TextDocumentPositionParams {
|
text_document_position: lsp::TextDocumentPositionParams {
|
||||||
text_document: lsp::TextDocumentIdentifier {
|
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),
|
position: point_to_lsp(self.position),
|
||||||
},
|
},
|
||||||
@ -430,7 +430,7 @@ impl LspCommand for GetDefinition {
|
|||||||
lsp::GotoDefinitionParams {
|
lsp::GotoDefinitionParams {
|
||||||
text_document_position_params: lsp::TextDocumentPositionParams {
|
text_document_position_params: lsp::TextDocumentPositionParams {
|
||||||
text_document: lsp::TextDocumentIdentifier {
|
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),
|
position: point_to_lsp(self.position),
|
||||||
},
|
},
|
||||||
@ -523,7 +523,7 @@ impl LspCommand for GetImplementation {
|
|||||||
lsp::GotoImplementationParams {
|
lsp::GotoImplementationParams {
|
||||||
text_document_position_params: lsp::TextDocumentPositionParams {
|
text_document_position_params: lsp::TextDocumentPositionParams {
|
||||||
text_document: lsp::TextDocumentIdentifier {
|
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),
|
position: point_to_lsp(self.position),
|
||||||
},
|
},
|
||||||
@ -624,7 +624,7 @@ impl LspCommand for GetTypeDefinition {
|
|||||||
lsp::GotoTypeDefinitionParams {
|
lsp::GotoTypeDefinitionParams {
|
||||||
text_document_position_params: lsp::TextDocumentPositionParams {
|
text_document_position_params: lsp::TextDocumentPositionParams {
|
||||||
text_document: lsp::TextDocumentIdentifier {
|
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),
|
position: point_to_lsp(self.position),
|
||||||
},
|
},
|
||||||
@ -820,7 +820,7 @@ async fn location_links_from_lsp(
|
|||||||
let target_buffer_handle = project
|
let target_buffer_handle = project
|
||||||
.update(&mut cx, |this, cx| {
|
.update(&mut cx, |this, cx| {
|
||||||
this.open_local_buffer_via_lsp(
|
this.open_local_buffer_via_lsp(
|
||||||
target_uri.into(),
|
target_uri,
|
||||||
language_server.server_id(),
|
language_server.server_id(),
|
||||||
lsp_adapter.name.clone(),
|
lsp_adapter.name.clone(),
|
||||||
cx,
|
cx,
|
||||||
@ -927,7 +927,7 @@ impl LspCommand for GetReferences {
|
|||||||
lsp::ReferenceParams {
|
lsp::ReferenceParams {
|
||||||
text_document_position: lsp::TextDocumentPositionParams {
|
text_document_position: lsp::TextDocumentPositionParams {
|
||||||
text_document: lsp::TextDocumentIdentifier {
|
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),
|
position: point_to_lsp(self.position),
|
||||||
},
|
},
|
||||||
@ -956,7 +956,7 @@ impl LspCommand for GetReferences {
|
|||||||
let target_buffer_handle = project
|
let target_buffer_handle = project
|
||||||
.update(&mut cx, |this, cx| {
|
.update(&mut cx, |this, cx| {
|
||||||
this.open_local_buffer_via_lsp(
|
this.open_local_buffer_via_lsp(
|
||||||
lsp_location.uri.into(),
|
lsp_location.uri,
|
||||||
language_server.server_id(),
|
language_server.server_id(),
|
||||||
lsp_adapter.name.clone(),
|
lsp_adapter.name.clone(),
|
||||||
cx,
|
cx,
|
||||||
@ -1094,7 +1094,7 @@ impl LspCommand for GetDocumentHighlights {
|
|||||||
lsp::DocumentHighlightParams {
|
lsp::DocumentHighlightParams {
|
||||||
text_document_position_params: lsp::TextDocumentPositionParams {
|
text_document_position_params: lsp::TextDocumentPositionParams {
|
||||||
text_document: lsp::TextDocumentIdentifier {
|
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),
|
position: point_to_lsp(self.position),
|
||||||
},
|
},
|
||||||
@ -1241,7 +1241,7 @@ impl LspCommand for GetHover {
|
|||||||
lsp::HoverParams {
|
lsp::HoverParams {
|
||||||
text_document_position_params: lsp::TextDocumentPositionParams {
|
text_document_position_params: lsp::TextDocumentPositionParams {
|
||||||
text_document: lsp::TextDocumentIdentifier {
|
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),
|
position: point_to_lsp(self.position),
|
||||||
},
|
},
|
||||||
@ -1463,7 +1463,7 @@ impl LspCommand for GetCompletions {
|
|||||||
) -> lsp::CompletionParams {
|
) -> lsp::CompletionParams {
|
||||||
lsp::CompletionParams {
|
lsp::CompletionParams {
|
||||||
text_document_position: lsp::TextDocumentPositionParams::new(
|
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),
|
point_to_lsp(self.position),
|
||||||
),
|
),
|
||||||
context: Some(self.context.clone()),
|
context: Some(self.context.clone()),
|
||||||
@ -1768,7 +1768,7 @@ impl LspCommand for GetCodeActions {
|
|||||||
|
|
||||||
lsp::CodeActionParams {
|
lsp::CodeActionParams {
|
||||||
text_document: lsp::TextDocumentIdentifier::new(
|
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)),
|
range: range_to_lsp(self.range.to_point_utf16(buffer)),
|
||||||
work_done_progress_params: Default::default(),
|
work_done_progress_params: Default::default(),
|
||||||
@ -1940,7 +1940,7 @@ impl LspCommand for OnTypeFormatting {
|
|||||||
) -> lsp::DocumentOnTypeFormattingParams {
|
) -> lsp::DocumentOnTypeFormattingParams {
|
||||||
lsp::DocumentOnTypeFormattingParams {
|
lsp::DocumentOnTypeFormattingParams {
|
||||||
text_document_position: lsp::TextDocumentPositionParams::new(
|
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),
|
point_to_lsp(self.position),
|
||||||
),
|
),
|
||||||
ch: self.trigger.clone(),
|
ch: self.trigger.clone(),
|
||||||
@ -2282,9 +2282,8 @@ impl InlayHints {
|
|||||||
Some(((uri, range), server_id)) => Some((
|
Some(((uri, range), server_id)) => Some((
|
||||||
LanguageServerId(server_id as usize),
|
LanguageServerId(server_id as usize),
|
||||||
lsp::Location {
|
lsp::Location {
|
||||||
uri: lsp::Uri::from_file_path(&uri)
|
uri: lsp::Url::parse(&uri)
|
||||||
.context("invalid uri in hint part {part:?}")?
|
.context("invalid uri in hint part {part:?}")?,
|
||||||
.into(),
|
|
||||||
range: lsp::Range::new(
|
range: lsp::Range::new(
|
||||||
point_to_lsp(PointUtf16::new(
|
point_to_lsp(PointUtf16::new(
|
||||||
range.start.row,
|
range.start.row,
|
||||||
@ -2444,7 +2443,7 @@ impl LspCommand for InlayHints {
|
|||||||
) -> lsp::InlayHintParams {
|
) -> lsp::InlayHintParams {
|
||||||
lsp::InlayHintParams {
|
lsp::InlayHintParams {
|
||||||
text_document: lsp::TextDocumentIdentifier {
|
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)),
|
range: range_to_lsp(self.range.to_point_utf16(buffer)),
|
||||||
work_done_progress_params: Default::default(),
|
work_done_progress_params: Default::default(),
|
||||||
@ -2600,7 +2599,7 @@ impl LspCommand for LinkedEditingRange {
|
|||||||
let position = self.position.to_point_utf16(&buffer.snapshot());
|
let position = self.position.to_point_utf16(&buffer.snapshot());
|
||||||
lsp::LinkedEditingRangeParams {
|
lsp::LinkedEditingRangeParams {
|
||||||
text_document_position_params: lsp::TextDocumentPositionParams::new(
|
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),
|
point_to_lsp(position),
|
||||||
),
|
),
|
||||||
work_done_progress_params: Default::default(),
|
work_done_progress_params: Default::default(),
|
||||||
|
@ -58,7 +58,7 @@ impl LspCommand for ExpandMacro {
|
|||||||
) -> ExpandMacroParams {
|
) -> ExpandMacroParams {
|
||||||
ExpandMacroParams {
|
ExpandMacroParams {
|
||||||
text_document: lsp::TextDocumentIdentifier {
|
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),
|
position: point_to_lsp(self.position),
|
||||||
}
|
}
|
||||||
|
@ -61,8 +61,7 @@ use lsp::{
|
|||||||
CompletionContext, DiagnosticSeverity, DiagnosticTag, DidChangeWatchedFilesRegistrationOptions,
|
CompletionContext, DiagnosticSeverity, DiagnosticTag, DidChangeWatchedFilesRegistrationOptions,
|
||||||
DocumentHighlightKind, Edit, FileSystemWatcher, InsertTextFormat, LanguageServer,
|
DocumentHighlightKind, Edit, FileSystemWatcher, InsertTextFormat, LanguageServer,
|
||||||
LanguageServerBinary, LanguageServerId, LspRequestFuture, MessageActionItem, OneOf,
|
LanguageServerBinary, LanguageServerId, LspRequestFuture, MessageActionItem, OneOf,
|
||||||
ServerCapabilities, ServerHealthStatus, ServerStatus, TextEdit, Uri,
|
ServerCapabilities, ServerHealthStatus, ServerStatus, TextEdit, WorkDoneProgressCancelParams,
|
||||||
WorkDoneProgressCancelParams,
|
|
||||||
};
|
};
|
||||||
use lsp_command::*;
|
use lsp_command::*;
|
||||||
use node_runtime::NodeRuntime;
|
use node_runtime::NodeRuntime;
|
||||||
@ -2141,7 +2140,7 @@ impl Project {
|
|||||||
/// LanguageServerName is owned, because it is inserted into a map
|
/// LanguageServerName is owned, because it is inserted into a map
|
||||||
pub fn open_local_buffer_via_lsp(
|
pub fn open_local_buffer_via_lsp(
|
||||||
&mut self,
|
&mut self,
|
||||||
abs_path: lsp::Uri,
|
abs_path: lsp::Url,
|
||||||
language_server_id: LanguageServerId,
|
language_server_id: LanguageServerId,
|
||||||
language_server_name: LanguageServerName,
|
language_server_name: LanguageServerName,
|
||||||
cx: &mut ModelContext<Self>,
|
cx: &mut ModelContext<Self>,
|
||||||
@ -2441,15 +2440,13 @@ impl Project {
|
|||||||
cx.observe_release(buffer, |this, buffer, cx| {
|
cx.observe_release(buffer, |this, buffer, cx| {
|
||||||
if let Some(file) = File::from_dyn(buffer.file()) {
|
if let Some(file) = File::from_dyn(buffer.file()) {
|
||||||
if file.is_local() {
|
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) {
|
for server in this.language_servers_for_buffer(buffer, cx) {
|
||||||
server
|
server
|
||||||
.1
|
.1
|
||||||
.notify::<lsp::notification::DidCloseTextDocument>(
|
.notify::<lsp::notification::DidCloseTextDocument>(
|
||||||
lsp::DidCloseTextDocumentParams {
|
lsp::DidCloseTextDocumentParams {
|
||||||
text_document: lsp::TextDocumentIdentifier::new(
|
text_document: lsp::TextDocumentIdentifier::new(uri.clone()),
|
||||||
uri.clone().into(),
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.log_err();
|
.log_err();
|
||||||
@ -2481,7 +2478,7 @@ impl Project {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let abs_path = file.abs_path(cx);
|
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;
|
return;
|
||||||
};
|
};
|
||||||
let initial_snapshot = buffer.text_snapshot();
|
let initial_snapshot = buffer.text_snapshot();
|
||||||
@ -2519,7 +2516,7 @@ impl Project {
|
|||||||
.notify::<lsp::notification::DidOpenTextDocument>(
|
.notify::<lsp::notification::DidOpenTextDocument>(
|
||||||
lsp::DidOpenTextDocumentParams {
|
lsp::DidOpenTextDocumentParams {
|
||||||
text_document: lsp::TextDocumentItem::new(
|
text_document: lsp::TextDocumentItem::new(
|
||||||
uri.clone().into(),
|
uri.clone(),
|
||||||
adapter.language_id(&language),
|
adapter.language_id(&language),
|
||||||
0,
|
0,
|
||||||
initial_snapshot.text(),
|
initial_snapshot.text(),
|
||||||
@ -2577,14 +2574,12 @@ impl Project {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.buffer_snapshots.remove(&buffer.remote_id());
|
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) {
|
for (_, language_server) in self.language_servers_for_buffer(buffer, cx) {
|
||||||
language_server
|
language_server
|
||||||
.notify::<lsp::notification::DidCloseTextDocument>(
|
.notify::<lsp::notification::DidCloseTextDocument>(
|
||||||
lsp::DidCloseTextDocumentParams {
|
lsp::DidCloseTextDocumentParams {
|
||||||
text_document: lsp::TextDocumentIdentifier::new(
|
text_document: lsp::TextDocumentIdentifier::new(file_url.clone()),
|
||||||
file_url.clone().into(),
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.log_err();
|
.log_err();
|
||||||
@ -2743,7 +2738,7 @@ impl Project {
|
|||||||
let buffer = buffer.read(cx);
|
let buffer = buffer.read(cx);
|
||||||
let file = File::from_dyn(buffer.file())?;
|
let file = File::from_dyn(buffer.file())?;
|
||||||
let abs_path = file.as_local()?.abs_path(cx);
|
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 next_snapshot = buffer.text_snapshot();
|
||||||
|
|
||||||
let language_servers: Vec<_> = self
|
let language_servers: Vec<_> = self
|
||||||
@ -2824,7 +2819,7 @@ impl Project {
|
|||||||
.notify::<lsp::notification::DidChangeTextDocument>(
|
.notify::<lsp::notification::DidChangeTextDocument>(
|
||||||
lsp::DidChangeTextDocumentParams {
|
lsp::DidChangeTextDocumentParams {
|
||||||
text_document: lsp::VersionedTextDocumentIdentifier::new(
|
text_document: lsp::VersionedTextDocumentIdentifier::new(
|
||||||
uri.clone().into(),
|
uri.clone(),
|
||||||
next_version,
|
next_version,
|
||||||
),
|
),
|
||||||
content_changes,
|
content_changes,
|
||||||
@ -2839,7 +2834,7 @@ impl Project {
|
|||||||
let worktree_id = file.worktree_id(cx);
|
let worktree_id = file.worktree_id(cx);
|
||||||
let abs_path = file.as_local()?.abs_path(cx);
|
let abs_path = file.as_local()?.abs_path(cx);
|
||||||
let text_document = lsp::TextDocumentIdentifier {
|
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) {
|
for (_, _, server) in self.language_servers_for_worktree(worktree_id) {
|
||||||
@ -3879,11 +3874,11 @@ impl Project {
|
|||||||
let snapshot = versions.last().unwrap();
|
let snapshot = versions.last().unwrap();
|
||||||
let version = snapshot.version;
|
let version = snapshot.version;
|
||||||
let initial_snapshot = &snapshot.snapshot;
|
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>(
|
language_server.notify::<lsp::notification::DidOpenTextDocument>(
|
||||||
lsp::DidOpenTextDocumentParams {
|
lsp::DidOpenTextDocumentParams {
|
||||||
text_document: lsp::TextDocumentItem::new(
|
text_document: lsp::TextDocumentItem::new(
|
||||||
uri.into(),
|
uri,
|
||||||
adapter.language_id(&language),
|
adapter.language_id(&language),
|
||||||
version,
|
version,
|
||||||
initial_snapshot.text(),
|
initial_snapshot.text(),
|
||||||
@ -4507,13 +4502,10 @@ impl Project {
|
|||||||
lsp::OneOf::Left(workspace_folder) => &workspace_folder.uri,
|
lsp::OneOf::Left(workspace_folder) => &workspace_folder.uri,
|
||||||
lsp::OneOf::Right(base_uri) => base_uri,
|
lsp::OneOf::Right(base_uri) => base_uri,
|
||||||
};
|
};
|
||||||
lsp::Uri::from(base_uri.clone())
|
base_uri.to_file_path().ok().and_then(|file_path| {
|
||||||
.to_file_path()
|
(file_path.to_str() == Some(abs_path))
|
||||||
.ok()
|
.then_some(rp.pattern.as_str())
|
||||||
.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 {
|
if let Some(relative_glob_pattern) = relative_glob_pattern {
|
||||||
@ -4602,9 +4594,10 @@ impl Project {
|
|||||||
disk_based_sources: &[String],
|
disk_based_sources: &[String],
|
||||||
cx: &mut ModelContext<Self>,
|
cx: &mut ModelContext<Self>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let abs_path = Uri::from(params.uri.clone())
|
let abs_path = params
|
||||||
|
.uri
|
||||||
.to_file_path()
|
.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 diagnostics = Vec::default();
|
||||||
let mut primary_diagnostic_group_ids = HashMap::default();
|
let mut primary_diagnostic_group_ids = HashMap::default();
|
||||||
let mut sources_by_group_id = HashMap::default();
|
let mut sources_by_group_id = HashMap::default();
|
||||||
@ -5285,9 +5278,9 @@ impl Project {
|
|||||||
tab_size: NonZeroU32,
|
tab_size: NonZeroU32,
|
||||||
cx: &mut AsyncAppContext,
|
cx: &mut AsyncAppContext,
|
||||||
) -> Result<Vec<(Range<Anchor>, String)>> {
|
) -> 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"))?;
|
.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 capabilities = &language_server.capabilities();
|
||||||
|
|
||||||
let formatting_provider = capabilities.document_formatting_provider.as_ref();
|
let formatting_provider = capabilities.document_formatting_provider.as_ref();
|
||||||
@ -5592,8 +5585,7 @@ impl Project {
|
|||||||
lsp_symbols
|
lsp_symbols
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|(symbol_name, symbol_kind, symbol_location)| {
|
.filter_map(|(symbol_name, symbol_kind, symbol_location)| {
|
||||||
let abs_path: lsp::Uri = symbol_location.uri.into();
|
let abs_path = symbol_location.uri.to_file_path().ok()?;
|
||||||
let abs_path = abs_path.to_file_path().ok()?;
|
|
||||||
let source_worktree = source_worktree.upgrade()?;
|
let source_worktree = source_worktree.upgrade()?;
|
||||||
let source_worktree_id = source_worktree.read(cx).id();
|
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_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
|
uri
|
||||||
} else {
|
} else {
|
||||||
return Task::ready(Err(anyhow!("invalid symbol path")));
|
return Task::ready(Err(anyhow!("invalid symbol path")));
|
||||||
@ -6628,7 +6620,8 @@ impl Project {
|
|||||||
for operation in operations {
|
for operation in operations {
|
||||||
match operation {
|
match operation {
|
||||||
lsp::DocumentChangeOperation::Op(lsp::ResourceOp::Create(op)) => {
|
lsp::DocumentChangeOperation::Op(lsp::ResourceOp::Create(op)) => {
|
||||||
let abs_path = Uri::from(op.uri)
|
let abs_path = op
|
||||||
|
.uri
|
||||||
.to_file_path()
|
.to_file_path()
|
||||||
.map_err(|_| anyhow!("can't convert URI to path"))?;
|
.map_err(|_| anyhow!("can't convert URI to path"))?;
|
||||||
|
|
||||||
@ -6652,10 +6645,12 @@ impl Project {
|
|||||||
}
|
}
|
||||||
|
|
||||||
lsp::DocumentChangeOperation::Op(lsp::ResourceOp::Rename(op)) => {
|
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()
|
.to_file_path()
|
||||||
.map_err(|_| anyhow!("can't convert URI to 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()
|
.to_file_path()
|
||||||
.map_err(|_| anyhow!("can't convert URI to path"))?;
|
.map_err(|_| anyhow!("can't convert URI to path"))?;
|
||||||
fs.rename(
|
fs.rename(
|
||||||
@ -6672,7 +6667,8 @@ impl Project {
|
|||||||
}
|
}
|
||||||
|
|
||||||
lsp::DocumentChangeOperation::Op(lsp::ResourceOp::Delete(op)) => {
|
lsp::DocumentChangeOperation::Op(lsp::ResourceOp::Delete(op)) => {
|
||||||
let abs_path: PathBuf = Uri::from(op.uri)
|
let abs_path = op
|
||||||
|
.uri
|
||||||
.to_file_path()
|
.to_file_path()
|
||||||
.map_err(|_| anyhow!("can't convert URI to path"))?;
|
.map_err(|_| anyhow!("can't convert URI to path"))?;
|
||||||
let options = op
|
let options = op
|
||||||
@ -6693,7 +6689,7 @@ impl Project {
|
|||||||
let buffer_to_edit = this
|
let buffer_to_edit = this
|
||||||
.update(cx, |this, cx| {
|
.update(cx, |this, cx| {
|
||||||
this.open_local_buffer_via_lsp(
|
this.open_local_buffer_via_lsp(
|
||||||
op.text_document.uri.clone().into(),
|
op.text_document.uri.clone(),
|
||||||
language_server.server_id(),
|
language_server.server_id(),
|
||||||
lsp_adapter.name.clone(),
|
lsp_adapter.name.clone(),
|
||||||
cx,
|
cx,
|
||||||
@ -8008,9 +8004,7 @@ impl Project {
|
|||||||
PathChange::AddedOrUpdated => lsp::FileChangeType::CHANGED,
|
PathChange::AddedOrUpdated => lsp::FileChangeType::CHANGED,
|
||||||
};
|
};
|
||||||
Some(lsp::FileEvent {
|
Some(lsp::FileEvent {
|
||||||
uri: lsp::Uri::from_file_path(abs_path.join(path))
|
uri: lsp::Url::from_file_path(abs_path.join(path)).unwrap(),
|
||||||
.unwrap()
|
|
||||||
.into(),
|
|
||||||
typ,
|
typ,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -378,9 +378,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
|
|||||||
.await
|
.await
|
||||||
.text_document,
|
.text_document,
|
||||||
lsp::TextDocumentItem {
|
lsp::TextDocumentItem {
|
||||||
uri: lsp::Uri::from_file_path("/the-root/test.rs")
|
uri: lsp::Url::from_file_path("/the-root/test.rs").unwrap(),
|
||||||
.unwrap()
|
|
||||||
.into(),
|
|
||||||
version: 0,
|
version: 0,
|
||||||
text: "const A: i32 = 1;".to_string(),
|
text: "const A: i32 = 1;".to_string(),
|
||||||
language_id: "rust".to_string(),
|
language_id: "rust".to_string(),
|
||||||
@ -406,9 +404,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
|
|||||||
.await
|
.await
|
||||||
.text_document,
|
.text_document,
|
||||||
lsp::VersionedTextDocumentIdentifier::new(
|
lsp::VersionedTextDocumentIdentifier::new(
|
||||||
lsp::Uri::from_file_path("/the-root/test.rs")
|
lsp::Url::from_file_path("/the-root/test.rs").unwrap(),
|
||||||
.unwrap()
|
|
||||||
.into(),
|
|
||||||
1
|
1
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -429,9 +425,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
|
|||||||
.await
|
.await
|
||||||
.text_document,
|
.text_document,
|
||||||
lsp::TextDocumentItem {
|
lsp::TextDocumentItem {
|
||||||
uri: lsp::Uri::from_file_path("/the-root/package.json")
|
uri: lsp::Url::from_file_path("/the-root/package.json").unwrap(),
|
||||||
.unwrap()
|
|
||||||
.into(),
|
|
||||||
version: 0,
|
version: 0,
|
||||||
text: "{\"a\": 1}".to_string(),
|
text: "{\"a\": 1}".to_string(),
|
||||||
language_id: "json".to_string(),
|
language_id: "json".to_string(),
|
||||||
@ -470,9 +464,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
|
|||||||
.await
|
.await
|
||||||
.text_document,
|
.text_document,
|
||||||
lsp::VersionedTextDocumentIdentifier::new(
|
lsp::VersionedTextDocumentIdentifier::new(
|
||||||
lsp::Uri::from_file_path("/the-root/test2.rs")
|
lsp::Url::from_file_path("/the-root/test2.rs").unwrap(),
|
||||||
.unwrap()
|
|
||||||
.into(),
|
|
||||||
1
|
1
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -487,22 +479,14 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
|
|||||||
.receive_notification::<lsp::notification::DidSaveTextDocument>()
|
.receive_notification::<lsp::notification::DidSaveTextDocument>()
|
||||||
.await
|
.await
|
||||||
.text_document,
|
.text_document,
|
||||||
lsp::TextDocumentIdentifier::new(
|
lsp::TextDocumentIdentifier::new(lsp::Url::from_file_path("/the-root/Cargo.toml").unwrap())
|
||||||
lsp::Uri::from_file_path("/the-root/Cargo.toml")
|
|
||||||
.unwrap()
|
|
||||||
.into()
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
fake_json_server
|
fake_json_server
|
||||||
.receive_notification::<lsp::notification::DidSaveTextDocument>()
|
.receive_notification::<lsp::notification::DidSaveTextDocument>()
|
||||||
.await
|
.await
|
||||||
.text_document,
|
.text_document,
|
||||||
lsp::TextDocumentIdentifier::new(
|
lsp::TextDocumentIdentifier::new(lsp::Url::from_file_path("/the-root/Cargo.toml").unwrap())
|
||||||
lsp::Uri::from_file_path("/the-root/Cargo.toml")
|
|
||||||
.unwrap()
|
|
||||||
.into()
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Renames are reported only to servers matching the buffer's language.
|
// 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>()
|
.receive_notification::<lsp::notification::DidCloseTextDocument>()
|
||||||
.await
|
.await
|
||||||
.text_document,
|
.text_document,
|
||||||
lsp::TextDocumentIdentifier::new(
|
lsp::TextDocumentIdentifier::new(lsp::Url::from_file_path("/the-root/test2.rs").unwrap()),
|
||||||
lsp::Uri::from_file_path("/the-root/test2.rs")
|
|
||||||
.unwrap()
|
|
||||||
.into()
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
fake_rust_server
|
fake_rust_server
|
||||||
@ -530,9 +510,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
|
|||||||
.await
|
.await
|
||||||
.text_document,
|
.text_document,
|
||||||
lsp::TextDocumentItem {
|
lsp::TextDocumentItem {
|
||||||
uri: lsp::Uri::from_file_path("/the-root/test3.rs")
|
uri: lsp::Url::from_file_path("/the-root/test3.rs").unwrap(),
|
||||||
.unwrap()
|
|
||||||
.into(),
|
|
||||||
version: 0,
|
version: 0,
|
||||||
text: rust_buffer2.update(cx, |buffer, _| buffer.text()),
|
text: rust_buffer2.update(cx, |buffer, _| buffer.text()),
|
||||||
language_id: "rust".to_string(),
|
language_id: "rust".to_string(),
|
||||||
@ -574,11 +552,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
|
|||||||
.receive_notification::<lsp::notification::DidCloseTextDocument>()
|
.receive_notification::<lsp::notification::DidCloseTextDocument>()
|
||||||
.await
|
.await
|
||||||
.text_document,
|
.text_document,
|
||||||
lsp::TextDocumentIdentifier::new(
|
lsp::TextDocumentIdentifier::new(lsp::Url::from_file_path("/the-root/test3.rs").unwrap(),),
|
||||||
lsp::Uri::from_file_path("/the-root/test3.rs")
|
|
||||||
.unwrap()
|
|
||||||
.into(),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
fake_json_server
|
fake_json_server
|
||||||
@ -586,9 +560,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
|
|||||||
.await
|
.await
|
||||||
.text_document,
|
.text_document,
|
||||||
lsp::TextDocumentItem {
|
lsp::TextDocumentItem {
|
||||||
uri: lsp::Uri::from_file_path("/the-root/test3.json")
|
uri: lsp::Url::from_file_path("/the-root/test3.json").unwrap(),
|
||||||
.unwrap()
|
|
||||||
.into(),
|
|
||||||
version: 0,
|
version: 0,
|
||||||
text: rust_buffer2.update(cx, |buffer, _| buffer.text()),
|
text: rust_buffer2.update(cx, |buffer, _| buffer.text()),
|
||||||
language_id: "json".to_string(),
|
language_id: "json".to_string(),
|
||||||
@ -614,9 +586,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
|
|||||||
.await
|
.await
|
||||||
.text_document,
|
.text_document,
|
||||||
lsp::VersionedTextDocumentIdentifier::new(
|
lsp::VersionedTextDocumentIdentifier::new(
|
||||||
lsp::Uri::from_file_path("/the-root/test3.json")
|
lsp::Url::from_file_path("/the-root/test3.json").unwrap(),
|
||||||
.unwrap()
|
|
||||||
.into(),
|
|
||||||
1
|
1
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -645,9 +615,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
|
|||||||
.await
|
.await
|
||||||
.text_document,
|
.text_document,
|
||||||
lsp::TextDocumentItem {
|
lsp::TextDocumentItem {
|
||||||
uri: lsp::Uri::from_file_path("/the-root/test.rs")
|
uri: lsp::Url::from_file_path("/the-root/test.rs").unwrap(),
|
||||||
.unwrap()
|
|
||||||
.into(),
|
|
||||||
version: 0,
|
version: 0,
|
||||||
text: rust_buffer.update(cx, |buffer, _| buffer.text()),
|
text: rust_buffer.update(cx, |buffer, _| buffer.text()),
|
||||||
language_id: "rust".to_string(),
|
language_id: "rust".to_string(),
|
||||||
@ -668,17 +636,13 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
lsp::TextDocumentItem {
|
lsp::TextDocumentItem {
|
||||||
uri: lsp::Uri::from_file_path("/the-root/package.json")
|
uri: lsp::Url::from_file_path("/the-root/package.json").unwrap(),
|
||||||
.unwrap()
|
|
||||||
.into(),
|
|
||||||
version: 0,
|
version: 0,
|
||||||
text: json_buffer.update(cx, |buffer, _| buffer.text()),
|
text: json_buffer.update(cx, |buffer, _| buffer.text()),
|
||||||
language_id: "json".to_string(),
|
language_id: "json".to_string(),
|
||||||
},
|
},
|
||||||
lsp::TextDocumentItem {
|
lsp::TextDocumentItem {
|
||||||
uri: lsp::Uri::from_file_path("/the-root/test3.json")
|
uri: lsp::Url::from_file_path("/the-root/test3.json").unwrap(),
|
||||||
.unwrap()
|
|
||||||
.into(),
|
|
||||||
version: 0,
|
version: 0,
|
||||||
text: rust_buffer2.update(cx, |buffer, _| buffer.text()),
|
text: rust_buffer2.update(cx, |buffer, _| buffer.text()),
|
||||||
language_id: "json".to_string(),
|
language_id: "json".to_string(),
|
||||||
@ -690,9 +654,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
|
|||||||
cx.update(|_| drop(json_buffer));
|
cx.update(|_| drop(json_buffer));
|
||||||
let close_message = lsp::DidCloseTextDocumentParams {
|
let close_message = lsp::DidCloseTextDocumentParams {
|
||||||
text_document: lsp::TextDocumentIdentifier::new(
|
text_document: lsp::TextDocumentIdentifier::new(
|
||||||
lsp::Uri::from_file_path("/the-root/package.json")
|
lsp::Url::from_file_path("/the-root/package.json").unwrap(),
|
||||||
.unwrap()
|
|
||||||
.into(),
|
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@ -882,21 +844,15 @@ async fn test_reporting_fs_changes_to_language_servers(cx: &mut gpui::TestAppCon
|
|||||||
&*file_changes.lock(),
|
&*file_changes.lock(),
|
||||||
&[
|
&[
|
||||||
lsp::FileEvent {
|
lsp::FileEvent {
|
||||||
uri: lsp::Uri::from_file_path("/the-root/src/b.rs")
|
uri: lsp::Url::from_file_path("/the-root/src/b.rs").unwrap(),
|
||||||
.unwrap()
|
|
||||||
.into(),
|
|
||||||
typ: lsp::FileChangeType::DELETED,
|
typ: lsp::FileChangeType::DELETED,
|
||||||
},
|
},
|
||||||
lsp::FileEvent {
|
lsp::FileEvent {
|
||||||
uri: lsp::Uri::from_file_path("/the-root/src/c.rs")
|
uri: lsp::Url::from_file_path("/the-root/src/c.rs").unwrap(),
|
||||||
.unwrap()
|
|
||||||
.into(),
|
|
||||||
typ: lsp::FileChangeType::CREATED,
|
typ: lsp::FileChangeType::CREATED,
|
||||||
},
|
},
|
||||||
lsp::FileEvent {
|
lsp::FileEvent {
|
||||||
uri: lsp::Uri::from_file_path("/the-root/target/y/out/y2.rs")
|
uri: lsp::Url::from_file_path("/the-root/target/y/out/y2.rs").unwrap(),
|
||||||
.unwrap()
|
|
||||||
.into(),
|
|
||||||
typ: lsp::FileChangeType::CREATED,
|
typ: lsp::FileChangeType::CREATED,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@ -933,7 +889,7 @@ async fn test_single_file_worktrees_diagnostics(cx: &mut gpui::TestAppContext) {
|
|||||||
.update_diagnostics(
|
.update_diagnostics(
|
||||||
LanguageServerId(0),
|
LanguageServerId(0),
|
||||||
lsp::PublishDiagnosticsParams {
|
lsp::PublishDiagnosticsParams {
|
||||||
uri: Uri::from_file_path("/dir/a.rs").unwrap().into(),
|
uri: Url::from_file_path("/dir/a.rs").unwrap(),
|
||||||
version: None,
|
version: None,
|
||||||
diagnostics: vec![lsp::Diagnostic {
|
diagnostics: vec![lsp::Diagnostic {
|
||||||
range: lsp::Range::new(lsp::Position::new(0, 4), lsp::Position::new(0, 5)),
|
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(
|
.update_diagnostics(
|
||||||
LanguageServerId(0),
|
LanguageServerId(0),
|
||||||
lsp::PublishDiagnosticsParams {
|
lsp::PublishDiagnosticsParams {
|
||||||
uri: Uri::from_file_path("/dir/b.rs").unwrap().into(),
|
uri: Url::from_file_path("/dir/b.rs").unwrap(),
|
||||||
version: None,
|
version: None,
|
||||||
diagnostics: vec![lsp::Diagnostic {
|
diagnostics: vec![lsp::Diagnostic {
|
||||||
range: lsp::Range::new(lsp::Position::new(0, 4), lsp::Position::new(0, 5)),
|
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(
|
.update_diagnostics(
|
||||||
server_id,
|
server_id,
|
||||||
lsp::PublishDiagnosticsParams {
|
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,
|
version: None,
|
||||||
diagnostics: vec![lsp::Diagnostic {
|
diagnostics: vec![lsp::Diagnostic {
|
||||||
range: lsp::Range::new(lsp::Position::new(0, 4), lsp::Position::new(0, 5)),
|
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(
|
.update_diagnostics(
|
||||||
server_id,
|
server_id,
|
||||||
lsp::PublishDiagnosticsParams {
|
lsp::PublishDiagnosticsParams {
|
||||||
uri: Uri::from_file_path("/root/other.rs").unwrap().into(),
|
uri: Url::from_file_path("/root/other.rs").unwrap(),
|
||||||
version: None,
|
version: None,
|
||||||
diagnostics: vec![lsp::Diagnostic {
|
diagnostics: vec![lsp::Diagnostic {
|
||||||
range: lsp::Range::new(lsp::Position::new(0, 8), lsp::Position::new(0, 9)),
|
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 {
|
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,
|
version: None,
|
||||||
diagnostics: vec![lsp::Diagnostic {
|
diagnostics: vec![lsp::Diagnostic {
|
||||||
range: lsp::Range::new(lsp::Position::new(0, 9), lsp::Position::new(0, 10)),
|
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.
|
// Ensure publishing empty diagnostics twice only results in one update event.
|
||||||
fake_server.notify::<lsp::notification::PublishDiagnostics>(lsp::PublishDiagnosticsParams {
|
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,
|
version: None,
|
||||||
diagnostics: Default::default(),
|
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 {
|
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,
|
version: None,
|
||||||
diagnostics: Default::default(),
|
diagnostics: Default::default(),
|
||||||
});
|
});
|
||||||
@ -1365,7 +1321,7 @@ async fn test_restarting_server_with_diagnostics_published(cx: &mut gpui::TestAp
|
|||||||
// Publish diagnostics
|
// Publish diagnostics
|
||||||
let fake_server = fake_servers.next().await.unwrap();
|
let fake_server = fake_servers.next().await.unwrap();
|
||||||
fake_server.notify::<lsp::notification::PublishDiagnostics>(lsp::PublishDiagnosticsParams {
|
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,
|
version: None,
|
||||||
diagnostics: vec![lsp::Diagnostic {
|
diagnostics: vec![lsp::Diagnostic {
|
||||||
range: lsp::Range::new(lsp::Position::new(0, 0), lsp::Position::new(0, 0)),
|
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.
|
// Before restarting the server, report diagnostics with an unknown buffer version.
|
||||||
let fake_server = fake_servers.next().await.unwrap();
|
let fake_server = fake_servers.next().await.unwrap();
|
||||||
fake_server.notify::<lsp::notification::PublishDiagnostics>(lsp::PublishDiagnosticsParams {
|
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),
|
version: Some(10000),
|
||||||
diagnostics: Vec::new(),
|
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
|
// Report some diagnostics for the initial version of the buffer
|
||||||
fake_server.notify::<lsp::notification::PublishDiagnostics>(lsp::PublishDiagnosticsParams {
|
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),
|
version: Some(open_notification.text_document.version),
|
||||||
diagnostics: vec![
|
diagnostics: vec![
|
||||||
lsp::Diagnostic {
|
lsp::Diagnostic {
|
||||||
@ -1770,7 +1726,7 @@ async fn test_transforming_diagnostics(cx: &mut gpui::TestAppContext) {
|
|||||||
|
|
||||||
// Ensure overlapping diagnostics are highlighted correctly.
|
// Ensure overlapping diagnostics are highlighted correctly.
|
||||||
fake_server.notify::<lsp::notification::PublishDiagnostics>(lsp::PublishDiagnosticsParams {
|
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),
|
version: Some(open_notification.text_document.version),
|
||||||
diagnostics: vec![
|
diagnostics: vec![
|
||||||
lsp::Diagnostic {
|
lsp::Diagnostic {
|
||||||
@ -1862,7 +1818,7 @@ async fn test_transforming_diagnostics(cx: &mut gpui::TestAppContext) {
|
|||||||
|
|
||||||
// Handle out-of-order diagnostics
|
// Handle out-of-order diagnostics
|
||||||
fake_server.notify::<lsp::notification::PublishDiagnostics>(lsp::PublishDiagnosticsParams {
|
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),
|
version: Some(change_notification_2.text_document.version),
|
||||||
diagnostics: vec![
|
diagnostics: vec![
|
||||||
lsp::Diagnostic {
|
lsp::Diagnostic {
|
||||||
@ -2456,14 +2412,14 @@ async fn test_definition(cx: &mut gpui::TestAppContext) {
|
|||||||
fake_server.handle_request::<lsp::request::GotoDefinition, _, _>(|params, _| async move {
|
fake_server.handle_request::<lsp::request::GotoDefinition, _, _>(|params, _| async move {
|
||||||
let params = params.text_document_position_params;
|
let params = params.text_document_position_params;
|
||||||
assert_eq!(
|
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"),
|
Path::new("/dir/b.rs"),
|
||||||
);
|
);
|
||||||
assert_eq!(params.position, lsp::Position::new(0, 22));
|
assert_eq!(params.position, lsp::Position::new(0, 22));
|
||||||
|
|
||||||
Ok(Some(lsp::GotoDefinitionResponse::Scalar(
|
Ok(Some(lsp::GotoDefinitionResponse::Scalar(
|
||||||
lsp::Location::new(
|
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)),
|
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 {
|
edit: lsp::WorkspaceEdit {
|
||||||
changes: Some(
|
changes: Some(
|
||||||
[(
|
[(
|
||||||
lsp::Uri::from_file_path("/dir/a.ts").unwrap().into(),
|
lsp::Url::from_file_path("/dir/a.ts").unwrap(),
|
||||||
vec![lsp::TextEdit {
|
vec![lsp::TextEdit {
|
||||||
range: lsp::Range::new(
|
range: lsp::Range::new(
|
||||||
lsp::Position::new(0, 0),
|
lsp::Position::new(0, 0),
|
||||||
@ -3604,9 +3560,9 @@ async fn test_grouped_diagnostics(cx: &mut gpui::TestAppContext) {
|
|||||||
.await
|
.await
|
||||||
.unwrap();
|
.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 {
|
let message = lsp::PublishDiagnosticsParams {
|
||||||
uri: buffer_uri.clone().into(),
|
uri: buffer_uri.clone(),
|
||||||
diagnostics: vec![
|
diagnostics: vec![
|
||||||
lsp::Diagnostic {
|
lsp::Diagnostic {
|
||||||
range: lsp::Range::new(lsp::Position::new(1, 8), lsp::Position::new(1, 9)),
|
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(),
|
message: "error 1".to_string(),
|
||||||
related_information: Some(vec![lsp::DiagnosticRelatedInformation {
|
related_information: Some(vec![lsp::DiagnosticRelatedInformation {
|
||||||
location: lsp::Location {
|
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)),
|
range: lsp::Range::new(lsp::Position::new(1, 8), lsp::Position::new(1, 9)),
|
||||||
},
|
},
|
||||||
message: "error 1 hint 1".to_string(),
|
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(),
|
message: "error 1 hint 1".to_string(),
|
||||||
related_information: Some(vec![lsp::DiagnosticRelatedInformation {
|
related_information: Some(vec![lsp::DiagnosticRelatedInformation {
|
||||||
location: lsp::Location {
|
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)),
|
range: lsp::Range::new(lsp::Position::new(1, 8), lsp::Position::new(1, 9)),
|
||||||
},
|
},
|
||||||
message: "original diagnostic".to_string(),
|
message: "original diagnostic".to_string(),
|
||||||
@ -3641,7 +3597,7 @@ async fn test_grouped_diagnostics(cx: &mut gpui::TestAppContext) {
|
|||||||
related_information: Some(vec![
|
related_information: Some(vec![
|
||||||
lsp::DiagnosticRelatedInformation {
|
lsp::DiagnosticRelatedInformation {
|
||||||
location: lsp::Location {
|
location: lsp::Location {
|
||||||
uri: buffer_uri.clone().into(),
|
uri: buffer_uri.clone(),
|
||||||
range: lsp::Range::new(
|
range: lsp::Range::new(
|
||||||
lsp::Position::new(1, 13),
|
lsp::Position::new(1, 13),
|
||||||
lsp::Position::new(1, 15),
|
lsp::Position::new(1, 15),
|
||||||
@ -3651,7 +3607,7 @@ async fn test_grouped_diagnostics(cx: &mut gpui::TestAppContext) {
|
|||||||
},
|
},
|
||||||
lsp::DiagnosticRelatedInformation {
|
lsp::DiagnosticRelatedInformation {
|
||||||
location: lsp::Location {
|
location: lsp::Location {
|
||||||
uri: buffer_uri.clone().into(),
|
uri: buffer_uri.clone(),
|
||||||
range: lsp::Range::new(
|
range: lsp::Range::new(
|
||||||
lsp::Position::new(1, 13),
|
lsp::Position::new(1, 13),
|
||||||
lsp::Position::new(1, 15),
|
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(),
|
message: "error 2 hint 1".to_string(),
|
||||||
related_information: Some(vec![lsp::DiagnosticRelatedInformation {
|
related_information: Some(vec![lsp::DiagnosticRelatedInformation {
|
||||||
location: lsp::Location {
|
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)),
|
range: lsp::Range::new(lsp::Position::new(2, 8), lsp::Position::new(2, 17)),
|
||||||
},
|
},
|
||||||
message: "original diagnostic".to_string(),
|
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(),
|
message: "error 2 hint 2".to_string(),
|
||||||
related_information: Some(vec![lsp::DiagnosticRelatedInformation {
|
related_information: Some(vec![lsp::DiagnosticRelatedInformation {
|
||||||
location: lsp::Location {
|
location: lsp::Location {
|
||||||
uri: buffer_uri.into(),
|
uri: buffer_uri,
|
||||||
range: lsp::Range::new(lsp::Position::new(2, 8), lsp::Position::new(2, 17)),
|
range: lsp::Range::new(lsp::Position::new(2, 8), lsp::Position::new(2, 17)),
|
||||||
},
|
},
|
||||||
message: "original diagnostic".to_string(),
|
message: "original diagnostic".to_string(),
|
||||||
@ -3899,14 +3855,14 @@ async fn test_rename(cx: &mut gpui::TestAppContext) {
|
|||||||
changes: Some(
|
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(
|
vec![lsp::TextEdit::new(
|
||||||
lsp::Range::new(lsp::Position::new(0, 6), lsp::Position::new(0, 9)),
|
lsp::Range::new(lsp::Position::new(0, 6), lsp::Position::new(0, 9)),
|
||||||
"THREE".to_string(),
|
"THREE".to_string(),
|
||||||
)],
|
)],
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
lsp::Uri::from_file_path("/dir/two.rs").unwrap().into(),
|
lsp::Url::from_file_path("/dir/two.rs").unwrap(),
|
||||||
vec![
|
vec![
|
||||||
lsp::TextEdit::new(
|
lsp::TextEdit::new(
|
||||||
lsp::Range::new(
|
lsp::Range::new(
|
||||||
|
@ -412,7 +412,7 @@ mod tests {
|
|||||||
deprecated: None,
|
deprecated: None,
|
||||||
container_name: None,
|
container_name: None,
|
||||||
location: lsp::Location::new(
|
location: lsp::Location::new(
|
||||||
lsp::Uri::from_file_path(path.as_ref()).unwrap().into(),
|
lsp::Url::from_file_path(path.as_ref()).unwrap(),
|
||||||
lsp::Range::new(lsp::Position::new(0, 0), lsp::Position::new(0, 0)),
|
lsp::Range::new(lsp::Position::new(0, 0), lsp::Position::new(0, 0)),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
@ -893,7 +893,7 @@ async fn test_rename(cx: &mut gpui::TestAppContext) {
|
|||||||
Ok(Some(lsp::WorkspaceEdit {
|
Ok(Some(lsp::WorkspaceEdit {
|
||||||
changes: Some(
|
changes: Some(
|
||||||
[(
|
[(
|
||||||
url.clone().into(),
|
url.clone(),
|
||||||
vec![
|
vec![
|
||||||
lsp::TextEdit::new(def_range, params.new_name.clone()),
|
lsp::TextEdit::new(def_range, params.new_name.clone()),
|
||||||
lsp::TextEdit::new(tgt_range, params.new_name),
|
lsp::TextEdit::new(tgt_range, params.new_name),
|
||||||
|
Loading…
Reference in New Issue
Block a user