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
22 changed files with 189 additions and 344 deletions
|
@ -8971,7 +8971,7 @@ impl Editor {
|
|||
});
|
||||
language_server_name.map(|language_server_name| {
|
||||
project.open_local_buffer_via_lsp(
|
||||
lsp::Uri::from(lsp_location.uri.clone()),
|
||||
lsp_location.uri.clone(),
|
||||
server_id,
|
||||
language_server_name,
|
||||
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 {
|
||||
assert_eq!(
|
||||
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);
|
||||
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 {
|
||||
assert_eq!(
|
||||
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;
|
||||
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 {
|
||||
assert_eq!(
|
||||
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);
|
||||
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 {
|
||||
Ok(Some(vec![lsp::TextEdit::new(
|
||||
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();
|
||||
|
@ -6213,7 +6213,7 @@ async fn test_range_format_during_save(cx: &mut gpui::TestAppContext) {
|
|||
.handle_request::<lsp::request::RangeFormatting, _, _>(move |params, _| async move {
|
||||
assert_eq!(
|
||||
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);
|
||||
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 {
|
||||
assert_eq!(
|
||||
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;
|
||||
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 {
|
||||
assert_eq!(
|
||||
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);
|
||||
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 {
|
||||
assert_eq!(
|
||||
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);
|
||||
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 {
|
||||
assert_eq!(
|
||||
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;
|
||||
unreachable!()
|
||||
|
@ -8028,7 +8028,7 @@ async fn go_to_prev_overlapping_diagnostic(
|
|||
.update_diagnostics(
|
||||
LanguageServerId(0),
|
||||
lsp::PublishDiagnosticsParams {
|
||||
uri: lsp::Uri::from_file_path("/root/file").unwrap().into(),
|
||||
uri: lsp::Url::from_file_path("/root/file").unwrap(),
|
||||
version: None,
|
||||
diagnostics: vec![
|
||||
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 {
|
||||
assert_eq!(
|
||||
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!(
|
||||
params.text_document_position.position,
|
||||
|
@ -12151,10 +12151,7 @@ pub fn handle_completion_request(
|
|||
let completions = completions.clone();
|
||||
counter.fetch_add(1, atomic::Ordering::Release);
|
||||
async move {
|
||||
assert_eq!(
|
||||
params.text_document_position.text_document.uri,
|
||||
url.clone().into()
|
||||
);
|
||||
assert_eq!(params.text_document_position.text_document.uri, url.clone());
|
||||
assert_eq!(
|
||||
params.text_document_position.position,
|
||||
complete_from_position
|
||||
|
|
|
@ -741,7 +741,7 @@ mod tests {
|
|||
Ok(Some(lsp::GotoTypeDefinitionResponse::Link(vec![
|
||||
lsp::LocationLink {
|
||||
origin_selection_range: Some(symbol_range),
|
||||
target_uri: url.clone().into(),
|
||||
target_uri: url.clone(),
|
||||
target_range,
|
||||
target_selection_range: target_range,
|
||||
},
|
||||
|
@ -815,7 +815,7 @@ mod tests {
|
|||
Ok(Some(lsp::GotoDefinitionResponse::Link(vec![
|
||||
lsp::LocationLink {
|
||||
origin_selection_range: Some(symbol_range),
|
||||
target_uri: url.clone().into(),
|
||||
target_uri: url.clone(),
|
||||
target_range,
|
||||
target_selection_range: target_range,
|
||||
},
|
||||
|
@ -841,7 +841,7 @@ mod tests {
|
|||
Ok(Some(lsp::GotoDefinitionResponse::Link(vec![
|
||||
lsp::LocationLink {
|
||||
origin_selection_range: Some(symbol_range),
|
||||
target_uri: url.clone().into(),
|
||||
target_uri: url.clone(),
|
||||
target_range,
|
||||
target_selection_range: target_range,
|
||||
},
|
||||
|
@ -904,7 +904,7 @@ mod tests {
|
|||
Ok(Some(lsp::GotoDefinitionResponse::Link(vec![
|
||||
lsp::LocationLink {
|
||||
origin_selection_range: Some(symbol_range),
|
||||
target_uri: url.into(),
|
||||
target_uri: url,
|
||||
target_range,
|
||||
target_selection_range: target_range,
|
||||
},
|
||||
|
@ -980,7 +980,7 @@ mod tests {
|
|||
Ok(Some(lsp::GotoDefinitionResponse::Link(vec![
|
||||
lsp::LocationLink {
|
||||
origin_selection_range: None,
|
||||
target_uri: url.into(),
|
||||
target_uri: url,
|
||||
target_range,
|
||||
target_selection_range: target_range,
|
||||
},
|
||||
|
@ -1008,7 +1008,7 @@ mod tests {
|
|||
Ok(Some(lsp::GotoDefinitionResponse::Link(vec![
|
||||
lsp::LocationLink {
|
||||
origin_selection_range: None,
|
||||
target_uri: url.into(),
|
||||
target_uri: url,
|
||||
target_range,
|
||||
target_selection_range: target_range,
|
||||
},
|
||||
|
@ -1088,7 +1088,7 @@ mod tests {
|
|||
let hint_label = ": TestStruct";
|
||||
cx.lsp
|
||||
.handle_request::<lsp::request::InlayHintRequest, _, _>(move |params, _| {
|
||||
let expected_uri = expected_uri.clone().into();
|
||||
let expected_uri = expected_uri.clone();
|
||||
async move {
|
||||
assert_eq!(params.text_document.uri, expected_uri);
|
||||
Ok(Some(vec![lsp::InlayHint {
|
||||
|
|
|
@ -1376,7 +1376,7 @@ mod tests {
|
|||
let closure_uri = uri.clone();
|
||||
cx.lsp
|
||||
.handle_request::<lsp::request::InlayHintRequest, _, _>(move |params, _| {
|
||||
let task_uri = closure_uri.clone().into();
|
||||
let task_uri = closure_uri.clone();
|
||||
async move {
|
||||
assert_eq!(params.text_document.uri, task_uri);
|
||||
Ok(Some(vec![lsp::InlayHint {
|
||||
|
@ -1467,7 +1467,7 @@ mod tests {
|
|||
lsp::InlayHintLabelPart {
|
||||
value: new_type_label.to_string(),
|
||||
location: Some(lsp::Location {
|
||||
uri: task_uri.clone().into(),
|
||||
uri: task_uri.clone(),
|
||||
range: new_type_target_range,
|
||||
}),
|
||||
tooltip: Some(lsp::InlayHintLabelPartTooltip::String(format!(
|
||||
|
@ -1482,7 +1482,7 @@ mod tests {
|
|||
lsp::InlayHintLabelPart {
|
||||
value: struct_label.to_string(),
|
||||
location: Some(lsp::Location {
|
||||
uri: task_uri.into(),
|
||||
uri: task_uri,
|
||||
range: struct_target_range,
|
||||
}),
|
||||
tooltip: Some(lsp::InlayHintLabelPartTooltip::MarkupContent(
|
||||
|
|
|
@ -1307,7 +1307,7 @@ pub mod tests {
|
|||
async move {
|
||||
assert_eq!(
|
||||
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 =
|
||||
Arc::clone(&task_lsp_request_count).fetch_add(1, Ordering::SeqCst);
|
||||
|
@ -1439,7 +1439,7 @@ pub mod tests {
|
|||
async move {
|
||||
assert_eq!(
|
||||
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 =
|
||||
Arc::clone(&task_lsp_request_count).fetch_add(1, Ordering::SeqCst);
|
||||
|
@ -1613,7 +1613,7 @@ pub mod tests {
|
|||
async move {
|
||||
assert_eq!(
|
||||
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);
|
||||
Ok(Some(vec![lsp::InlayHint {
|
||||
|
@ -1666,7 +1666,7 @@ pub mod tests {
|
|||
async move {
|
||||
assert_eq!(
|
||||
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);
|
||||
Ok(Some(vec![lsp::InlayHint {
|
||||
|
@ -1790,7 +1790,7 @@ pub mod tests {
|
|||
Arc::clone(&task_lsp_request_count).fetch_add(1, Ordering::SeqCst);
|
||||
assert_eq!(
|
||||
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 {
|
||||
|
@ -2136,7 +2136,7 @@ pub mod tests {
|
|||
let i = Arc::clone(&task_lsp_request_count).fetch_add(1, Ordering::SeqCst) + 1;
|
||||
assert_eq!(
|
||||
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 {
|
||||
position: lsp::Position::new(0, i),
|
||||
|
@ -2305,7 +2305,7 @@ pub mod tests {
|
|||
async move {
|
||||
assert_eq!(
|
||||
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);
|
||||
|
@ -2673,11 +2673,11 @@ pub mod tests {
|
|||
let task_editor_edited = Arc::clone(&closure_editor_edited);
|
||||
async move {
|
||||
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"
|
||||
} 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"
|
||||
} else {
|
||||
|
@ -2981,11 +2981,11 @@ pub mod tests {
|
|||
let task_editor_edited = Arc::clone(&closure_editor_edited);
|
||||
async move {
|
||||
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"
|
||||
} 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"
|
||||
} else {
|
||||
|
@ -3177,7 +3177,7 @@ pub mod tests {
|
|||
async move {
|
||||
assert_eq!(
|
||||
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 i = Arc::clone(&task_lsp_request_count).fetch_add(1, Ordering::Release) + 1;
|
||||
|
@ -3244,7 +3244,7 @@ pub mod tests {
|
|||
async move {
|
||||
assert_eq!(
|
||||
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;
|
||||
|
|
|
@ -27,7 +27,7 @@ pub struct EditorLspTestContext {
|
|||
pub cx: EditorTestContext,
|
||||
pub lsp: lsp::FakeLanguageServer,
|
||||
pub workspace: View<Workspace>,
|
||||
pub buffer_lsp_url: lsp::Uri,
|
||||
pub buffer_lsp_url: lsp::Url,
|
||||
}
|
||||
|
||||
impl EditorLspTestContext {
|
||||
|
@ -113,7 +113,7 @@ impl EditorLspTestContext {
|
|||
},
|
||||
lsp,
|
||||
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
|
||||
T: 'static + request::Request,
|
||||
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>>,
|
||||
{
|
||||
let url = self.buffer_lsp_url.clone();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue