chore: Bump lsp-types to 0.97.0 (#12928)

This also includes https://github.com/gluon-lang/lsp-types/pull/287,
which should significantly reduce the time it takes for us to
deserialize completion lists.


Release Notes:
- N/A
This commit is contained in:
Piotr Osiewicz 2024-06-13 13:48:12 +02:00 committed by GitHub
parent 21764c38dd
commit 7798f64d1b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 344 additions and 191 deletions

View file

@ -7,7 +7,6 @@ use language::{
tree_sitter_rust, tree_sitter_typescript, Diagnostic, FakeLspAdapter, LanguageConfig,
LanguageMatcher, LineEnding, OffsetRangeExt, Point, ToPoint,
};
use lsp::Url;
use parking_lot::Mutex;
use pretty_assertions::assert_eq;
use serde_json::json;
@ -379,7 +378,9 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
.await
.text_document,
lsp::TextDocumentItem {
uri: lsp::Url::from_file_path("/the-root/test.rs").unwrap(),
uri: lsp::Uri::from_file_path("/the-root/test.rs")
.unwrap()
.into(),
version: 0,
text: "const A: i32 = 1;".to_string(),
language_id: "rust".to_string(),
@ -405,7 +406,9 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
.await
.text_document,
lsp::VersionedTextDocumentIdentifier::new(
lsp::Url::from_file_path("/the-root/test.rs").unwrap(),
lsp::Uri::from_file_path("/the-root/test.rs")
.unwrap()
.into(),
1
)
);
@ -426,7 +429,9 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
.await
.text_document,
lsp::TextDocumentItem {
uri: lsp::Url::from_file_path("/the-root/package.json").unwrap(),
uri: lsp::Uri::from_file_path("/the-root/package.json")
.unwrap()
.into(),
version: 0,
text: "{\"a\": 1}".to_string(),
language_id: "json".to_string(),
@ -465,7 +470,9 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
.await
.text_document,
lsp::VersionedTextDocumentIdentifier::new(
lsp::Url::from_file_path("/the-root/test2.rs").unwrap(),
lsp::Uri::from_file_path("/the-root/test2.rs")
.unwrap()
.into(),
1
)
);
@ -480,14 +487,22 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
.receive_notification::<lsp::notification::DidSaveTextDocument>()
.await
.text_document,
lsp::TextDocumentIdentifier::new(lsp::Url::from_file_path("/the-root/Cargo.toml").unwrap())
lsp::TextDocumentIdentifier::new(
lsp::Uri::from_file_path("/the-root/Cargo.toml")
.unwrap()
.into()
)
);
assert_eq!(
fake_json_server
.receive_notification::<lsp::notification::DidSaveTextDocument>()
.await
.text_document,
lsp::TextDocumentIdentifier::new(lsp::Url::from_file_path("/the-root/Cargo.toml").unwrap())
lsp::TextDocumentIdentifier::new(
lsp::Uri::from_file_path("/the-root/Cargo.toml")
.unwrap()
.into()
)
);
// Renames are reported only to servers matching the buffer's language.
@ -503,7 +518,11 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
.receive_notification::<lsp::notification::DidCloseTextDocument>()
.await
.text_document,
lsp::TextDocumentIdentifier::new(lsp::Url::from_file_path("/the-root/test2.rs").unwrap()),
lsp::TextDocumentIdentifier::new(
lsp::Uri::from_file_path("/the-root/test2.rs")
.unwrap()
.into()
),
);
assert_eq!(
fake_rust_server
@ -511,7 +530,9 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
.await
.text_document,
lsp::TextDocumentItem {
uri: lsp::Url::from_file_path("/the-root/test3.rs").unwrap(),
uri: lsp::Uri::from_file_path("/the-root/test3.rs")
.unwrap()
.into(),
version: 0,
text: rust_buffer2.update(cx, |buffer, _| buffer.text()),
language_id: "rust".to_string(),
@ -553,7 +574,11 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
.receive_notification::<lsp::notification::DidCloseTextDocument>()
.await
.text_document,
lsp::TextDocumentIdentifier::new(lsp::Url::from_file_path("/the-root/test3.rs").unwrap(),),
lsp::TextDocumentIdentifier::new(
lsp::Uri::from_file_path("/the-root/test3.rs")
.unwrap()
.into(),
),
);
assert_eq!(
fake_json_server
@ -561,7 +586,9 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
.await
.text_document,
lsp::TextDocumentItem {
uri: lsp::Url::from_file_path("/the-root/test3.json").unwrap(),
uri: lsp::Uri::from_file_path("/the-root/test3.json")
.unwrap()
.into(),
version: 0,
text: rust_buffer2.update(cx, |buffer, _| buffer.text()),
language_id: "json".to_string(),
@ -587,7 +614,9 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
.await
.text_document,
lsp::VersionedTextDocumentIdentifier::new(
lsp::Url::from_file_path("/the-root/test3.json").unwrap(),
lsp::Uri::from_file_path("/the-root/test3.json")
.unwrap()
.into(),
1
)
);
@ -616,7 +645,9 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
.await
.text_document,
lsp::TextDocumentItem {
uri: lsp::Url::from_file_path("/the-root/test.rs").unwrap(),
uri: lsp::Uri::from_file_path("/the-root/test.rs")
.unwrap()
.into(),
version: 0,
text: rust_buffer.update(cx, |buffer, _| buffer.text()),
language_id: "rust".to_string(),
@ -637,13 +668,17 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
],
[
lsp::TextDocumentItem {
uri: lsp::Url::from_file_path("/the-root/package.json").unwrap(),
uri: lsp::Uri::from_file_path("/the-root/package.json")
.unwrap()
.into(),
version: 0,
text: json_buffer.update(cx, |buffer, _| buffer.text()),
language_id: "json".to_string(),
},
lsp::TextDocumentItem {
uri: lsp::Url::from_file_path("/the-root/test3.json").unwrap(),
uri: lsp::Uri::from_file_path("/the-root/test3.json")
.unwrap()
.into(),
version: 0,
text: rust_buffer2.update(cx, |buffer, _| buffer.text()),
language_id: "json".to_string(),
@ -655,7 +690,9 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
cx.update(|_| drop(json_buffer));
let close_message = lsp::DidCloseTextDocumentParams {
text_document: lsp::TextDocumentIdentifier::new(
lsp::Url::from_file_path("/the-root/package.json").unwrap(),
lsp::Uri::from_file_path("/the-root/package.json")
.unwrap()
.into(),
),
};
assert_eq!(
@ -845,15 +882,21 @@ async fn test_reporting_fs_changes_to_language_servers(cx: &mut gpui::TestAppCon
&*file_changes.lock(),
&[
lsp::FileEvent {
uri: lsp::Url::from_file_path("/the-root/src/b.rs").unwrap(),
uri: lsp::Uri::from_file_path("/the-root/src/b.rs")
.unwrap()
.into(),
typ: lsp::FileChangeType::DELETED,
},
lsp::FileEvent {
uri: lsp::Url::from_file_path("/the-root/src/c.rs").unwrap(),
uri: lsp::Uri::from_file_path("/the-root/src/c.rs")
.unwrap()
.into(),
typ: lsp::FileChangeType::CREATED,
},
lsp::FileEvent {
uri: lsp::Url::from_file_path("/the-root/target/y/out/y2.rs").unwrap(),
uri: lsp::Uri::from_file_path("/the-root/target/y/out/y2.rs")
.unwrap()
.into(),
typ: lsp::FileChangeType::CREATED,
},
]
@ -890,7 +933,7 @@ async fn test_single_file_worktrees_diagnostics(cx: &mut gpui::TestAppContext) {
.update_diagnostics(
LanguageServerId(0),
lsp::PublishDiagnosticsParams {
uri: Url::from_file_path("/dir/a.rs").unwrap(),
uri: Uri::from_file_path("/dir/a.rs").unwrap().into(),
version: None,
diagnostics: vec![lsp::Diagnostic {
range: lsp::Range::new(lsp::Position::new(0, 4), lsp::Position::new(0, 5)),
@ -907,7 +950,7 @@ async fn test_single_file_worktrees_diagnostics(cx: &mut gpui::TestAppContext) {
.update_diagnostics(
LanguageServerId(0),
lsp::PublishDiagnosticsParams {
uri: Url::from_file_path("/dir/b.rs").unwrap(),
uri: Uri::from_file_path("/dir/b.rs").unwrap().into(),
version: None,
diagnostics: vec![lsp::Diagnostic {
range: lsp::Range::new(lsp::Position::new(0, 4), lsp::Position::new(0, 5)),
@ -996,7 +1039,7 @@ async fn test_omitted_diagnostics(cx: &mut gpui::TestAppContext) {
.update_diagnostics(
server_id,
lsp::PublishDiagnosticsParams {
uri: Url::from_file_path("/root/dir/b.rs").unwrap(),
uri: Uri::from_file_path("/root/dir/b.rs").unwrap().into(),
version: None,
diagnostics: vec![lsp::Diagnostic {
range: lsp::Range::new(lsp::Position::new(0, 4), lsp::Position::new(0, 5)),
@ -1013,7 +1056,7 @@ async fn test_omitted_diagnostics(cx: &mut gpui::TestAppContext) {
.update_diagnostics(
server_id,
lsp::PublishDiagnosticsParams {
uri: Url::from_file_path("/root/other.rs").unwrap(),
uri: Uri::from_file_path("/root/other.rs").unwrap().into(),
version: None,
diagnostics: vec![lsp::Diagnostic {
range: lsp::Range::new(lsp::Position::new(0, 8), lsp::Position::new(0, 9)),
@ -1148,7 +1191,7 @@ async fn test_disk_based_diagnostics_progress(cx: &mut gpui::TestAppContext) {
);
fake_server.notify::<lsp::notification::PublishDiagnostics>(lsp::PublishDiagnosticsParams {
uri: Url::from_file_path("/dir/a.rs").unwrap(),
uri: Uri::from_file_path("/dir/a.rs").unwrap().into(),
version: None,
diagnostics: vec![lsp::Diagnostic {
range: lsp::Range::new(lsp::Position::new(0, 9), lsp::Position::new(0, 10)),
@ -1200,7 +1243,7 @@ async fn test_disk_based_diagnostics_progress(cx: &mut gpui::TestAppContext) {
// Ensure publishing empty diagnostics twice only results in one update event.
fake_server.notify::<lsp::notification::PublishDiagnostics>(lsp::PublishDiagnosticsParams {
uri: Url::from_file_path("/dir/a.rs").unwrap(),
uri: Uri::from_file_path("/dir/a.rs").unwrap().into(),
version: None,
diagnostics: Default::default(),
});
@ -1213,7 +1256,7 @@ async fn test_disk_based_diagnostics_progress(cx: &mut gpui::TestAppContext) {
);
fake_server.notify::<lsp::notification::PublishDiagnostics>(lsp::PublishDiagnosticsParams {
uri: Url::from_file_path("/dir/a.rs").unwrap(),
uri: Uri::from_file_path("/dir/a.rs").unwrap().into(),
version: None,
diagnostics: Default::default(),
});
@ -1322,7 +1365,7 @@ async fn test_restarting_server_with_diagnostics_published(cx: &mut gpui::TestAp
// Publish diagnostics
let fake_server = fake_servers.next().await.unwrap();
fake_server.notify::<lsp::notification::PublishDiagnostics>(lsp::PublishDiagnosticsParams {
uri: Url::from_file_path("/dir/a.rs").unwrap(),
uri: Uri::from_file_path("/dir/a.rs").unwrap().into(),
version: None,
diagnostics: vec![lsp::Diagnostic {
range: lsp::Range::new(lsp::Position::new(0, 0), lsp::Position::new(0, 0)),
@ -1402,7 +1445,7 @@ async fn test_restarted_server_reporting_invalid_buffer_version(cx: &mut gpui::T
// Before restarting the server, report diagnostics with an unknown buffer version.
let fake_server = fake_servers.next().await.unwrap();
fake_server.notify::<lsp::notification::PublishDiagnostics>(lsp::PublishDiagnosticsParams {
uri: lsp::Url::from_file_path("/dir/a.rs").unwrap(),
uri: lsp::Uri::from_file_path("/dir/a.rs").unwrap().into(),
version: Some(10000),
diagnostics: Vec::new(),
});
@ -1578,7 +1621,7 @@ async fn test_transforming_diagnostics(cx: &mut gpui::TestAppContext) {
// Report some diagnostics for the initial version of the buffer
fake_server.notify::<lsp::notification::PublishDiagnostics>(lsp::PublishDiagnosticsParams {
uri: lsp::Url::from_file_path("/dir/a.rs").unwrap(),
uri: lsp::Uri::from_file_path("/dir/a.rs").unwrap().into(),
version: Some(open_notification.text_document.version),
diagnostics: vec![
lsp::Diagnostic {
@ -1664,7 +1707,7 @@ async fn test_transforming_diagnostics(cx: &mut gpui::TestAppContext) {
// Ensure overlapping diagnostics are highlighted correctly.
fake_server.notify::<lsp::notification::PublishDiagnostics>(lsp::PublishDiagnosticsParams {
uri: lsp::Url::from_file_path("/dir/a.rs").unwrap(),
uri: lsp::Uri::from_file_path("/dir/a.rs").unwrap().into(),
version: Some(open_notification.text_document.version),
diagnostics: vec![
lsp::Diagnostic {
@ -1756,7 +1799,7 @@ async fn test_transforming_diagnostics(cx: &mut gpui::TestAppContext) {
// Handle out-of-order diagnostics
fake_server.notify::<lsp::notification::PublishDiagnostics>(lsp::PublishDiagnosticsParams {
uri: lsp::Url::from_file_path("/dir/a.rs").unwrap(),
uri: lsp::Uri::from_file_path("/dir/a.rs").unwrap().into(),
version: Some(change_notification_2.text_document.version),
diagnostics: vec![
lsp::Diagnostic {
@ -2350,14 +2393,14 @@ async fn test_definition(cx: &mut gpui::TestAppContext) {
fake_server.handle_request::<lsp::request::GotoDefinition, _, _>(|params, _| async move {
let params = params.text_document_position_params;
assert_eq!(
params.text_document.uri.to_file_path().unwrap(),
Uri::from(params.text_document.uri).to_file_path().unwrap(),
Path::new("/dir/b.rs"),
);
assert_eq!(params.position, lsp::Position::new(0, 22));
Ok(Some(lsp::GotoDefinitionResponse::Scalar(
lsp::Location::new(
lsp::Url::from_file_path("/dir/a.rs").unwrap(),
lsp::Uri::from_file_path("/dir/a.rs").unwrap().into(),
lsp::Range::new(lsp::Position::new(0, 9), lsp::Position::new(0, 10)),
),
)))
@ -2665,7 +2708,7 @@ async fn test_apply_code_actions_with_commands(cx: &mut gpui::TestAppContext) {
edit: lsp::WorkspaceEdit {
changes: Some(
[(
lsp::Url::from_file_path("/dir/a.ts").unwrap(),
lsp::Uri::from_file_path("/dir/a.ts").unwrap().into(),
vec![lsp::TextEdit {
range: lsp::Range::new(
lsp::Position::new(0, 0),
@ -3496,9 +3539,9 @@ async fn test_grouped_diagnostics(cx: &mut gpui::TestAppContext) {
.await
.unwrap();
let buffer_uri = Url::from_file_path("/the-dir/a.rs").unwrap();
let buffer_uri = Uri::from_file_path("/the-dir/a.rs").unwrap();
let message = lsp::PublishDiagnosticsParams {
uri: buffer_uri.clone(),
uri: buffer_uri.clone().into(),
diagnostics: vec![
lsp::Diagnostic {
range: lsp::Range::new(lsp::Position::new(1, 8), lsp::Position::new(1, 9)),
@ -3506,7 +3549,7 @@ async fn test_grouped_diagnostics(cx: &mut gpui::TestAppContext) {
message: "error 1".to_string(),
related_information: Some(vec![lsp::DiagnosticRelatedInformation {
location: lsp::Location {
uri: buffer_uri.clone(),
uri: buffer_uri.clone().into(),
range: lsp::Range::new(lsp::Position::new(1, 8), lsp::Position::new(1, 9)),
},
message: "error 1 hint 1".to_string(),
@ -3519,7 +3562,7 @@ async fn test_grouped_diagnostics(cx: &mut gpui::TestAppContext) {
message: "error 1 hint 1".to_string(),
related_information: Some(vec![lsp::DiagnosticRelatedInformation {
location: lsp::Location {
uri: buffer_uri.clone(),
uri: buffer_uri.clone().into(),
range: lsp::Range::new(lsp::Position::new(1, 8), lsp::Position::new(1, 9)),
},
message: "original diagnostic".to_string(),
@ -3533,7 +3576,7 @@ async fn test_grouped_diagnostics(cx: &mut gpui::TestAppContext) {
related_information: Some(vec![
lsp::DiagnosticRelatedInformation {
location: lsp::Location {
uri: buffer_uri.clone(),
uri: buffer_uri.clone().into(),
range: lsp::Range::new(
lsp::Position::new(1, 13),
lsp::Position::new(1, 15),
@ -3543,7 +3586,7 @@ async fn test_grouped_diagnostics(cx: &mut gpui::TestAppContext) {
},
lsp::DiagnosticRelatedInformation {
location: lsp::Location {
uri: buffer_uri.clone(),
uri: buffer_uri.clone().into(),
range: lsp::Range::new(
lsp::Position::new(1, 13),
lsp::Position::new(1, 15),
@ -3560,7 +3603,7 @@ async fn test_grouped_diagnostics(cx: &mut gpui::TestAppContext) {
message: "error 2 hint 1".to_string(),
related_information: Some(vec![lsp::DiagnosticRelatedInformation {
location: lsp::Location {
uri: buffer_uri.clone(),
uri: buffer_uri.clone().into(),
range: lsp::Range::new(lsp::Position::new(2, 8), lsp::Position::new(2, 17)),
},
message: "original diagnostic".to_string(),
@ -3573,7 +3616,7 @@ async fn test_grouped_diagnostics(cx: &mut gpui::TestAppContext) {
message: "error 2 hint 2".to_string(),
related_information: Some(vec![lsp::DiagnosticRelatedInformation {
location: lsp::Location {
uri: buffer_uri,
uri: buffer_uri.into(),
range: lsp::Range::new(lsp::Position::new(2, 8), lsp::Position::new(2, 17)),
},
message: "original diagnostic".to_string(),
@ -3790,14 +3833,14 @@ async fn test_rename(cx: &mut gpui::TestAppContext) {
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(