mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 10:33:54 +00:00
refactor(lsp): changes for lsp_types 0.97.0 (#25169)
This commit is contained in:
parent
bbd3a7e637
commit
2ab4afc6b8
30 changed files with 633 additions and 548 deletions
|
@ -5,6 +5,7 @@ use super::lsp_custom::TestData;
|
|||
|
||||
use crate::lsp::client::TestingNotification;
|
||||
use crate::lsp::logging::lsp_warn;
|
||||
use crate::lsp::urls::url_to_uri;
|
||||
use crate::tools::test::TestDescription;
|
||||
use crate::tools::test::TestStepDescription;
|
||||
use crate::util::checksum;
|
||||
|
@ -147,7 +148,7 @@ impl TestModule {
|
|||
let label = self.label(maybe_root_uri);
|
||||
TestingNotification::Module(lsp_custom::TestModuleNotificationParams {
|
||||
text_document: lsp::TextDocumentIdentifier {
|
||||
uri: self.specifier.clone(),
|
||||
uri: url_to_uri(&self.specifier),
|
||||
},
|
||||
kind: lsp_custom::TestModuleNotificationKind::Replace,
|
||||
label,
|
||||
|
|
|
@ -12,6 +12,8 @@ use crate::lsp::client::Client;
|
|||
use crate::lsp::client::TestingNotification;
|
||||
use crate::lsp::config;
|
||||
use crate::lsp::logging::lsp_log;
|
||||
use crate::lsp::urls::uri_to_url;
|
||||
use crate::lsp::urls::url_to_uri;
|
||||
use crate::tools::test;
|
||||
use crate::tools::test::create_test_event_channel;
|
||||
use crate::tools::test::FailFastTracker;
|
||||
|
@ -30,9 +32,11 @@ use deno_core::ModuleSpecifier;
|
|||
use deno_runtime::deno_permissions::Permissions;
|
||||
use deno_runtime::tokio_util::create_and_run_current_thread;
|
||||
use indexmap::IndexMap;
|
||||
use lsp_types::Uri;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::HashSet;
|
||||
use std::num::NonZeroUsize;
|
||||
use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use std::time::Instant;
|
||||
|
@ -53,12 +57,12 @@ fn as_queue_and_filters(
|
|||
|
||||
if let Some(include) = ¶ms.include {
|
||||
for item in include {
|
||||
if let Some((test_definitions, _)) = tests.get(&item.text_document.uri) {
|
||||
queue.insert(item.text_document.uri.clone());
|
||||
let url = uri_to_url(&item.text_document.uri);
|
||||
if let Some((test_definitions, _)) = tests.get(&url) {
|
||||
queue.insert(url.clone());
|
||||
if let Some(id) = &item.id {
|
||||
if let Some(test) = test_definitions.get(id) {
|
||||
let filter =
|
||||
filters.entry(item.text_document.uri.clone()).or_default();
|
||||
let filter = filters.entry(url).or_default();
|
||||
if let Some(include) = filter.include.as_mut() {
|
||||
include.insert(test.id.clone(), test.clone());
|
||||
} else {
|
||||
|
@ -75,19 +79,19 @@ fn as_queue_and_filters(
|
|||
}
|
||||
|
||||
for item in ¶ms.exclude {
|
||||
if let Some((test_definitions, _)) = tests.get(&item.text_document.uri) {
|
||||
let url = uri_to_url(&item.text_document.uri);
|
||||
if let Some((test_definitions, _)) = tests.get(&url) {
|
||||
if let Some(id) = &item.id {
|
||||
// there is no way to exclude a test step
|
||||
if item.step_id.is_none() {
|
||||
if let Some(test) = test_definitions.get(id) {
|
||||
let filter =
|
||||
filters.entry(item.text_document.uri.clone()).or_default();
|
||||
let filter = filters.entry(url.clone()).or_default();
|
||||
filter.exclude.insert(test.id.clone(), test.clone());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// the entire test module is excluded
|
||||
queue.remove(&item.text_document.uri);
|
||||
queue.remove(&url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -193,7 +197,7 @@ impl TestRun {
|
|||
Vec::new()
|
||||
};
|
||||
lsp_custom::EnqueuedTestModule {
|
||||
text_document: lsp::TextDocumentIdentifier { uri: s.clone() },
|
||||
text_document: lsp::TextDocumentIdentifier { uri: url_to_uri(s) },
|
||||
ids,
|
||||
}
|
||||
})
|
||||
|
@ -523,7 +527,7 @@ impl LspTestDescription {
|
|||
&self,
|
||||
tests: &IndexMap<usize, LspTestDescription>,
|
||||
) -> lsp_custom::TestIdentifier {
|
||||
let uri = ModuleSpecifier::parse(&self.location().file_name).unwrap();
|
||||
let uri = Uri::from_str(&self.location().file_name).unwrap();
|
||||
let static_id = self.static_id();
|
||||
let mut root_desc = self;
|
||||
while let Some(parent_id) = root_desc.parent_id() {
|
||||
|
@ -598,7 +602,7 @@ impl LspTestReporter {
|
|||
.send_test_notification(TestingNotification::Module(
|
||||
lsp_custom::TestModuleNotificationParams {
|
||||
text_document: lsp::TextDocumentIdentifier {
|
||||
uri: test_module.specifier.clone(),
|
||||
uri: url_to_uri(&test_module.specifier),
|
||||
},
|
||||
kind: lsp_custom::TestModuleNotificationKind::Insert,
|
||||
label: test_module.label(self.maybe_root_uri.as_ref()),
|
||||
|
@ -711,7 +715,7 @@ impl LspTestReporter {
|
|||
.send_test_notification(TestingNotification::Module(
|
||||
lsp_custom::TestModuleNotificationParams {
|
||||
text_document: lsp::TextDocumentIdentifier {
|
||||
uri: test_module.specifier.clone(),
|
||||
uri: url_to_uri(&test_module.specifier),
|
||||
},
|
||||
kind: lsp_custom::TestModuleNotificationKind::Insert,
|
||||
label: test_module.label(self.maybe_root_uri.as_ref()),
|
||||
|
@ -796,14 +800,14 @@ mod tests {
|
|||
include: Some(vec![
|
||||
lsp_custom::TestIdentifier {
|
||||
text_document: lsp::TextDocumentIdentifier {
|
||||
uri: specifier.clone(),
|
||||
uri: url_to_uri(&specifier),
|
||||
},
|
||||
id: None,
|
||||
step_id: None,
|
||||
},
|
||||
lsp_custom::TestIdentifier {
|
||||
text_document: lsp::TextDocumentIdentifier {
|
||||
uri: non_test_specifier.clone(),
|
||||
uri: url_to_uri(&non_test_specifier),
|
||||
},
|
||||
id: None,
|
||||
step_id: None,
|
||||
|
@ -811,7 +815,7 @@ mod tests {
|
|||
]),
|
||||
exclude: vec![lsp_custom::TestIdentifier {
|
||||
text_document: lsp::TextDocumentIdentifier {
|
||||
uri: specifier.clone(),
|
||||
uri: url_to_uri(&specifier),
|
||||
},
|
||||
id: Some(
|
||||
"69d9fe87f64f5b66cb8b631d4fd2064e8224b8715a049be54276c42189ff8f9f"
|
||||
|
|
|
@ -10,6 +10,7 @@ use crate::lsp::config;
|
|||
use crate::lsp::documents::DocumentsFilter;
|
||||
use crate::lsp::language_server::StateSnapshot;
|
||||
use crate::lsp::performance::Performance;
|
||||
use crate::lsp::urls::url_to_uri;
|
||||
|
||||
use deno_core::error::AnyError;
|
||||
use deno_core::parking_lot::Mutex;
|
||||
|
@ -26,10 +27,12 @@ use tower_lsp::jsonrpc::Error as LspError;
|
|||
use tower_lsp::jsonrpc::Result as LspResult;
|
||||
use tower_lsp::lsp_types as lsp;
|
||||
|
||||
fn as_delete_notification(uri: ModuleSpecifier) -> TestingNotification {
|
||||
fn as_delete_notification(url: ModuleSpecifier) -> TestingNotification {
|
||||
TestingNotification::DeleteModule(
|
||||
lsp_custom::TestModuleDeleteNotificationParams {
|
||||
text_document: lsp::TextDocumentIdentifier { uri },
|
||||
text_document: lsp::TextDocumentIdentifier {
|
||||
uri: url_to_uri(&url),
|
||||
},
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue