Skip to content

Commit

Permalink
chore: Bump lsp-types to 0.97.0 (zed-industries#12928)
Browse files Browse the repository at this point in the history
This also includes gluon-lang/lsp-types#287,
which should significantly reduce the time it takes for us to
deserialize completion lists.


Release Notes:
- N/A
  • Loading branch information
osiewicz authored and fallenwood committed Jun 18, 2024
1 parent 96d7ee1 commit 8cfd7e9
Show file tree
Hide file tree
Showing 22 changed files with 344 additions and 191 deletions.
32 changes: 29 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 14 additions & 14 deletions crates/collab/src/tests/editor_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
assert_eq!(
params.text_document_position.text_document.uri,
lsp::Url::from_file_path("/a/main.rs").unwrap(),
lsp::Uri::from_file_path("/a/main.rs").unwrap().into(),
);
assert_eq!(
params.text_document_position.position,
Expand Down Expand Up @@ -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 {
assert_eq!(
params.text_document_position.text_document.uri,
lsp::Url::from_file_path("/a/main.rs").unwrap(),
lsp::Uri::from_file_path("/a/main.rs").unwrap().into(),
);
assert_eq!(
params.text_document_position.position,
Expand Down Expand Up @@ -585,7 +585,7 @@ async fn test_collaborating_with_code_actions(
.handle_request::<lsp::request::CodeActionRequest, _, _>(|params, _| async move {
assert_eq!(
params.text_document.uri,
lsp::Url::from_file_path("/a/main.rs").unwrap(),
lsp::Uri::from_file_path("/a/main.rs").unwrap().into(),
);
assert_eq!(params.range.start, lsp::Position::new(0, 0));
assert_eq!(params.range.end, lsp::Position::new(0, 0));
Expand All @@ -607,7 +607,7 @@ async fn test_collaborating_with_code_actions(
.handle_request::<lsp::request::CodeActionRequest, _, _>(|params, _| async move {
assert_eq!(
params.text_document.uri,
lsp::Url::from_file_path("/a/main.rs").unwrap(),
lsp::Uri::from_file_path("/a/main.rs").unwrap().into(),
);
assert_eq!(params.range.start, lsp::Position::new(1, 31));
assert_eq!(params.range.end, lsp::Position::new(1, 31));
Expand All @@ -619,7 +619,7 @@ async fn test_collaborating_with_code_actions(
changes: Some(
[
(
lsp::Url::from_file_path("/a/main.rs").unwrap(),
lsp::Uri::from_file_path("/a/main.rs").unwrap().into(),
vec![lsp::TextEdit::new(
lsp::Range::new(
lsp::Position::new(1, 22),
Expand All @@ -629,7 +629,7 @@ async fn test_collaborating_with_code_actions(
)],
),
(
lsp::Url::from_file_path("/a/other.rs").unwrap(),
lsp::Uri::from_file_path("/a/other.rs").unwrap().into(),
vec![lsp::TextEdit::new(
lsp::Range::new(
lsp::Position::new(0, 0),
Expand Down Expand Up @@ -689,7 +689,7 @@ async fn test_collaborating_with_code_actions(
changes: Some(
[
(
lsp::Url::from_file_path("/a/main.rs").unwrap(),
lsp::Uri::from_file_path("/a/main.rs").unwrap().into(),
vec![lsp::TextEdit::new(
lsp::Range::new(
lsp::Position::new(1, 22),
Expand All @@ -699,7 +699,7 @@ async fn test_collaborating_with_code_actions(
)],
),
(
lsp::Url::from_file_path("/a/other.rs").unwrap(),
lsp::Uri::from_file_path("/a/other.rs").unwrap().into(),
vec![lsp::TextEdit::new(
lsp::Range::new(
lsp::Position::new(0, 0),
Expand Down Expand Up @@ -897,14 +897,14 @@ async fn test_collaborating_with_renames(cx_a: &mut TestAppContext, cx_b: &mut T
changes: Some(
[
(
lsp::Url::from_file_path("/dir/one.rs").unwrap(),
lsp::Uri::from_file_path("/dir/one.rs").unwrap().into(),
vec![lsp::TextEdit::new(
lsp::Range::new(lsp::Position::new(0, 6), lsp::Position::new(0, 9)),
"THREE".to_string(),
)],
),
(
lsp::Url::from_file_path("/dir/two.rs").unwrap(),
lsp::Uri::from_file_path("/dir/two.rs").unwrap().into(),
vec![
lsp::TextEdit::new(
lsp::Range::new(
Expand Down Expand Up @@ -1313,7 +1313,7 @@ async fn test_on_input_format_from_host_to_guest(
|params, _| async move {
assert_eq!(
params.text_document_position.text_document.uri,
lsp::Url::from_file_path("/a/main.rs").unwrap(),
lsp::Uri::from_file_path("/a/main.rs").unwrap().into(),
);
assert_eq!(
params.text_document_position.position,
Expand Down Expand Up @@ -1441,7 +1441,7 @@ async fn test_on_input_format_from_guest_to_host(
.handle_request::<lsp::request::OnTypeFormatting, _, _>(|params, _| async move {
assert_eq!(
params.text_document_position.text_document.uri,
lsp::Url::from_file_path("/a/main.rs").unwrap(),
lsp::Uri::from_file_path("/a/main.rs").unwrap().into(),
);
assert_eq!(
params.text_document_position.position,
Expand Down Expand Up @@ -1610,7 +1610,7 @@ async fn test_mutual_editor_inlay_hint_cache_update(
async move {
assert_eq!(
params.text_document.uri,
lsp::Url::from_file_path("/a/main.rs").unwrap(),
lsp::Uri::from_file_path("/a/main.rs").unwrap().into(),
);
let edits_made = task_edits_made.load(atomic::Ordering::Acquire);
Ok(Some(vec![lsp::InlayHint {
Expand Down Expand Up @@ -1873,7 +1873,7 @@ async fn test_inlay_hint_refresh_is_forwarded(
async move {
assert_eq!(
params.text_document.uri,
lsp::Url::from_file_path("/a/main.rs").unwrap(),
lsp::Uri::from_file_path("/a/main.rs").unwrap().into(),
);
let other_hints = task_other_hints.load(atomic::Ordering::Acquire);
let character = if other_hints { 0 } else { 2 };
Expand Down
36 changes: 23 additions & 13 deletions crates/collab/src/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3897,7 +3897,7 @@ async fn test_collaborating_with_diagnostics(
.await;
fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
lsp::PublishDiagnosticsParams {
uri: lsp::Url::from_file_path("/a/a.rs").unwrap(),
uri: lsp::Uri::from_file_path("/a/a.rs").unwrap().into(),
version: None,
diagnostics: vec![lsp::Diagnostic {
severity: Some(lsp::DiagnosticSeverity::WARNING),
Expand All @@ -3917,7 +3917,7 @@ async fn test_collaborating_with_diagnostics(
.unwrap();
fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
lsp::PublishDiagnosticsParams {
uri: lsp::Url::from_file_path("/a/a.rs").unwrap(),
uri: lsp::Uri::from_file_path("/a/a.rs").unwrap().into(),
version: None,
diagnostics: vec![lsp::Diagnostic {
severity: Some(lsp::DiagnosticSeverity::ERROR),
Expand Down Expand Up @@ -3991,7 +3991,7 @@ async fn test_collaborating_with_diagnostics(
// Simulate a language server reporting more errors for a file.
fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
lsp::PublishDiagnosticsParams {
uri: lsp::Url::from_file_path("/a/a.rs").unwrap(),
uri: lsp::Uri::from_file_path("/a/a.rs").unwrap().into(),
version: None,
diagnostics: vec![
lsp::Diagnostic {
Expand Down Expand Up @@ -4085,7 +4085,7 @@ async fn test_collaborating_with_diagnostics(
// Simulate a language server reporting no errors for a file.
fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
lsp::PublishDiagnosticsParams {
uri: lsp::Url::from_file_path("/a/a.rs").unwrap(),
uri: lsp::Uri::from_file_path("/a/a.rs").unwrap().into(),
version: None,
diagnostics: vec![],
},
Expand Down Expand Up @@ -4189,7 +4189,9 @@ async fn test_collaborating_with_lsp_progress_updates_and_diagnostics_ordering(
for file_name in file_names {
fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
lsp::PublishDiagnosticsParams {
uri: lsp::Url::from_file_path(Path::new("/test").join(file_name)).unwrap(),
uri: lsp::Uri::from_file_path(Path::new("/test").join(file_name))
.unwrap()
.into(),
version: None,
diagnostics: vec![lsp::Diagnostic {
severity: Some(lsp::DiagnosticSeverity::WARNING),
Expand Down Expand Up @@ -4607,7 +4609,7 @@ async fn test_definition(
fake_language_server.handle_request::<lsp::request::GotoDefinition, _, _>(|_, _| async move {
Ok(Some(lsp::GotoDefinitionResponse::Scalar(
lsp::Location::new(
lsp::Url::from_file_path("/root/dir-2/b.rs").unwrap(),
lsp::Uri::from_file_path("/root/dir-2/b.rs").unwrap().into(),
lsp::Range::new(lsp::Position::new(0, 6), lsp::Position::new(0, 9)),
),
)))
Expand Down Expand Up @@ -4636,7 +4638,7 @@ async fn test_definition(
fake_language_server.handle_request::<lsp::request::GotoDefinition, _, _>(|_, _| async move {
Ok(Some(lsp::GotoDefinitionResponse::Scalar(
lsp::Location::new(
lsp::Url::from_file_path("/root/dir-2/b.rs").unwrap(),
lsp::Uri::from_file_path("/root/dir-2/b.rs").unwrap().into(),
lsp::Range::new(lsp::Position::new(1, 6), lsp::Position::new(1, 11)),
),
)))
Expand Down Expand Up @@ -4672,7 +4674,7 @@ async fn test_definition(
);
Ok(Some(lsp::GotoDefinitionResponse::Scalar(
lsp::Location::new(
lsp::Url::from_file_path("/root/dir-2/c.rs").unwrap(),
lsp::Uri::from_file_path("/root/dir-2/c.rs").unwrap().into(),
lsp::Range::new(lsp::Position::new(0, 5), lsp::Position::new(0, 7)),
),
)))
Expand Down Expand Up @@ -4784,15 +4786,21 @@ async fn test_references(
lsp_response_tx
.unbounded_send(Ok(Some(vec![
lsp::Location {
uri: lsp::Url::from_file_path("/root/dir-1/two.rs").unwrap(),
uri: lsp::Uri::from_file_path("/root/dir-1/two.rs")
.unwrap()
.into(),
range: lsp::Range::new(lsp::Position::new(0, 24), lsp::Position::new(0, 27)),
},
lsp::Location {
uri: lsp::Url::from_file_path("/root/dir-1/two.rs").unwrap(),
uri: lsp::Uri::from_file_path("/root/dir-1/two.rs")
.unwrap()
.into(),
range: lsp::Range::new(lsp::Position::new(0, 35), lsp::Position::new(0, 38)),
},
lsp::Location {
uri: lsp::Url::from_file_path("/root/dir-2/three.rs").unwrap(),
uri: lsp::Uri::from_file_path("/root/dir-2/three.rs")
.unwrap()
.into(),
range: lsp::Range::new(lsp::Position::new(0, 37), lsp::Position::new(0, 40)),
},
])))
Expand Down Expand Up @@ -5292,7 +5300,9 @@ async fn test_project_symbols(
lsp::SymbolInformation {
name: "TWO".into(),
location: lsp::Location {
uri: lsp::Url::from_file_path("/code/crate-2/two.rs").unwrap(),
uri: lsp::Uri::from_file_path("/code/crate-2/two.rs")
.unwrap()
.into(),
range: lsp::Range::new(lsp::Position::new(0, 6), lsp::Position::new(0, 9)),
},
kind: lsp::SymbolKind::CONSTANT,
Expand Down Expand Up @@ -5382,7 +5392,7 @@ async fn test_open_buffer_while_getting_definition_pointing_to_it(
fake_language_server.handle_request::<lsp::request::GotoDefinition, _, _>(|_, _| async move {
Ok(Some(lsp::GotoDefinitionResponse::Scalar(
lsp::Location::new(
lsp::Url::from_file_path("/root/b.rs").unwrap(),
lsp::Uri::from_file_path("/root/b.rs").unwrap().into(),
lsp::Range::new(lsp::Position::new(0, 6), lsp::Position::new(0, 9)),
),
)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,7 @@ impl RandomizedTest for ProjectCollaborationTest {
files
.into_iter()
.map(|file| lsp::Location {
uri: lsp::Url::from_file_path(file).unwrap(),
uri: lsp::Uri::from_file_path(file).unwrap().into(),
range: Default::default(),
})
.collect(),
Expand Down
24 changes: 13 additions & 11 deletions crates/copilot/src/copilot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ impl Status {
}

struct RegisteredBuffer {
uri: lsp::Url,
uri: lsp::RawUri,
language_id: String,
snapshot: BufferSnapshot,
snapshot_version: i32,
Expand Down Expand Up @@ -644,7 +644,7 @@ impl Copilot {
registered_buffers
.entry(buffer.entity_id())
.or_insert_with(|| {
let uri: lsp::Url = uri_for_buffer(buffer, cx);
let uri = uri_for_buffer(buffer, cx);
let language_id = id_for_language(buffer.read(cx).language());
let snapshot = buffer.read(cx).snapshot();
server
Expand Down Expand Up @@ -959,9 +959,9 @@ fn id_for_language(language: Option<&Arc<Language>>) -> String {
.unwrap_or_else(|| "plaintext".to_string())
}

fn uri_for_buffer(buffer: &Model<Buffer>, cx: &AppContext) -> lsp::Url {
fn uri_for_buffer(buffer: &Model<Buffer>, cx: &AppContext) -> lsp::RawUri {
if let Some(file) = buffer.read(cx).file().and_then(|file| file.as_local()) {
lsp::Url::from_file_path(file.abs_path(cx)).unwrap()
lsp::Uri::from_file_path(file.abs_path(cx)).unwrap().into()
} else {
format!("buffer://{}", buffer.entity_id()).parse().unwrap()
}
Expand Down Expand Up @@ -1042,6 +1042,8 @@ async fn get_copilot_lsp(http: Arc<dyn HttpClient>) -> anyhow::Result<PathBuf> {

#[cfg(test)]
mod tests {
use std::str::FromStr;

use super::*;
use gpui::TestAppContext;

Expand All @@ -1050,9 +1052,8 @@ mod tests {
let (copilot, mut lsp) = Copilot::fake(cx);

let buffer_1 = cx.new_model(|cx| Buffer::local("Hello", cx));
let buffer_1_uri: lsp::Url = format!("buffer://{}", buffer_1.entity_id().as_u64())
.parse()
.unwrap();
let buffer_1_uri =
lsp::RawUri::from_str(&format!("buffer://{}", buffer_1.entity_id().as_u64())).unwrap();
copilot.update(cx, |copilot, cx| copilot.register_buffer(&buffer_1, cx));
assert_eq!(
lsp.receive_notification::<lsp::notification::DidOpenTextDocument>()
Expand All @@ -1068,9 +1069,8 @@ mod tests {
);

let buffer_2 = cx.new_model(|cx| Buffer::local("Goodbye", cx));
let buffer_2_uri: lsp::Url = format!("buffer://{}", buffer_2.entity_id().as_u64())
.parse()
.unwrap();
let buffer_2_uri =
lsp::RawUri::from_str(&format!("buffer://{}", buffer_2.entity_id().as_u64())).unwrap();
copilot.update(cx, |copilot, cx| copilot.register_buffer(&buffer_2, cx));
assert_eq!(
lsp.receive_notification::<lsp::notification::DidOpenTextDocument>()
Expand Down Expand Up @@ -1119,7 +1119,9 @@ mod tests {
text_document: lsp::TextDocumentIdentifier::new(buffer_1_uri),
}
);
let buffer_1_uri = lsp::Url::from_file_path("/root/child/buffer-1").unwrap();
let buffer_1_uri: lsp::RawUri = lsp::Uri::from_file_path("/root/child/buffer-1")
.unwrap()
.into();
assert_eq!(
lsp.receive_notification::<lsp::notification::DidOpenTextDocument>()
.await,
Expand Down
Loading

0 comments on commit 8cfd7e9

Please sign in to comment.