From 942f0b4ed138eda1db086a6bd3ad0de98ba43da9 Mon Sep 17 00:00:00 2001 From: kbwo Date: Tue, 24 Dec 2024 17:11:06 +0900 Subject: [PATCH] fix(adapter): return valid json type to server --- crates/adapter/src/log.rs | 4 ++-- crates/adapter/src/runner/cargo_nextest.rs | 4 +--- crates/adapter/src/runner/cargo_test.rs | 4 +--- crates/adapter/src/runner/deno.rs | 4 +--- crates/adapter/src/runner/jest.rs | 4 +--- crates/adapter/src/runner/node_test.rs | 5 ++--- crates/adapter/src/runner/phpunit.rs | 4 +--- crates/adapter/src/runner/util.rs | 6 +++--- 8 files changed, 12 insertions(+), 23 deletions(-) diff --git a/crates/adapter/src/log.rs b/crates/adapter/src/log.rs index 6a17a5a..32ea729 100644 --- a/crates/adapter/src/log.rs +++ b/crates/adapter/src/log.rs @@ -8,8 +8,8 @@ pub struct Log; impl Log { fn log_dir() -> PathBuf { let home_dir = dirs::home_dir().unwrap(); - let log_path = home_dir.join(".config/testing_language_server/adapter/logs"); - log_path + + home_dir.join(".config/testing_language_server/adapter/logs") } pub fn init() -> Result { diff --git a/crates/adapter/src/runner/cargo_nextest.rs b/crates/adapter/src/runner/cargo_nextest.rs index 8948938..c6d1780 100644 --- a/crates/adapter/src/runner/cargo_nextest.rs +++ b/crates/adapter/src/runner/cargo_nextest.rs @@ -18,9 +18,7 @@ use super::util::parse_cargo_diagnostics; use super::util::write_result_log; fn detect_workspaces(file_paths: &[String]) -> DetectWorkspaceResult { - DetectWorkspaceResult { - data: detect_workspaces_from_file_list(file_paths, &["Cargo.toml".to_string()]), - } + detect_workspaces_from_file_list(file_paths, &["Cargo.toml".to_string()]) } #[derive(Eq, PartialEq, Hash, Debug)] diff --git a/crates/adapter/src/runner/cargo_test.rs b/crates/adapter/src/runner/cargo_test.rs index 914862c..e66eaec 100644 --- a/crates/adapter/src/runner/cargo_test.rs +++ b/crates/adapter/src/runner/cargo_test.rs @@ -18,9 +18,7 @@ use super::util::parse_cargo_diagnostics; use super::util::write_result_log; fn detect_workspaces(file_paths: &[String]) -> DetectWorkspaceResult { - DetectWorkspaceResult { - data: detect_workspaces_from_file_list(file_paths, &["Cargo.toml".to_string()]), - } + detect_workspaces_from_file_list(file_paths, &["Cargo.toml".to_string()]) } #[derive(Eq, PartialEq, Hash, Debug)] diff --git a/crates/adapter/src/runner/deno.rs b/crates/adapter/src/runner/deno.rs index 60a6b2e..270d61a 100644 --- a/crates/adapter/src/runner/deno.rs +++ b/crates/adapter/src/runner/deno.rs @@ -99,9 +99,7 @@ fn parse_diagnostics( } fn detect_workspaces(file_paths: Vec) -> DetectWorkspaceResult { - DetectWorkspaceResult { - data: detect_workspaces_from_file_list(&file_paths, &["deno.json".to_string()]), - } + detect_workspaces_from_file_list(&file_paths, &["deno.json".to_string()]) } fn discover(file_path: &str) -> Result, LSError> { diff --git a/crates/adapter/src/runner/jest.rs b/crates/adapter/src/runner/jest.rs index b33a4d9..e11c269 100644 --- a/crates/adapter/src/runner/jest.rs +++ b/crates/adapter/src/runner/jest.rs @@ -77,9 +77,7 @@ fn parse_diagnostics( } fn detect_workspaces(file_paths: Vec) -> DetectWorkspaceResult { - DetectWorkspaceResult { - data: detect_workspaces_from_file_list(&file_paths, &["package.json".to_string()]), - } + detect_workspaces_from_file_list(&file_paths, &["package.json".to_string()]) } fn discover(file_path: &str) -> Result, LSError> { diff --git a/crates/adapter/src/runner/node_test.rs b/crates/adapter/src/runner/node_test.rs index 6551361..81b63ad 100644 --- a/crates/adapter/src/runner/node_test.rs +++ b/crates/adapter/src/runner/node_test.rs @@ -215,9 +215,8 @@ impl Runner for NodeTestRunner { args: testing_language_server::spec::DetectWorkspaceArgs, ) -> Result<(), LSError> { let file_paths = args.file_paths; - let detect_result: DetectWorkspaceResult = DetectWorkspaceResult { - data: detect_workspaces_from_file_list(&file_paths, &["package.json".to_string()]), - }; + let detect_result: DetectWorkspaceResult = + detect_workspaces_from_file_list(&file_paths, &["package.json".to_string()]); send_stdout(&detect_result)?; Ok(()) } diff --git a/crates/adapter/src/runner/phpunit.rs b/crates/adapter/src/runner/phpunit.rs index ca03bcf..dcca31f 100644 --- a/crates/adapter/src/runner/phpunit.rs +++ b/crates/adapter/src/runner/phpunit.rs @@ -16,9 +16,7 @@ use super::util::{ }; fn detect_workspaces(file_paths: Vec) -> DetectWorkspaceResult { - DetectWorkspaceResult { - data: detect_workspaces_from_file_list(&file_paths, &["composer.json".to_string()]), - } + detect_workspaces_from_file_list(&file_paths, &["composer.json".to_string()]) } fn get_result_from_characters(characters: &str) -> Result { diff --git a/crates/adapter/src/runner/util.rs b/crates/adapter/src/runner/util.rs index d086e6f..ca540de 100644 --- a/crates/adapter/src/runner/util.rs +++ b/crates/adapter/src/runner/util.rs @@ -8,7 +8,7 @@ use std::sync::LazyLock; use lsp_types::{Diagnostic, DiagnosticSeverity, Position, Range}; use regex::Regex; use serde::Serialize; -use testing_language_server::spec::{FileDiagnostics, TestItem}; +use testing_language_server::spec::{DetectWorkspaceResult, FileDiagnostics, TestItem}; use testing_language_server::{error::LSError, spec::RunFileTestResult}; use tree_sitter::{Language, Point, Query, QueryCursor}; @@ -74,7 +74,7 @@ fn detect_workspace_from_file(file_path: PathBuf, file_names: &[String]) -> Opti pub fn detect_workspaces_from_file_list( target_file_paths: &[String], file_names: &[String], -) -> HashMap> { +) -> DetectWorkspaceResult { let mut result_map: HashMap> = HashMap::new(); let mut file_paths = target_file_paths.to_vec(); file_paths.sort_by_key(|b| b.len()); @@ -106,7 +106,7 @@ pub fn detect_workspaces_from_file_list( } } } - result_map + DetectWorkspaceResult { data: result_map } } pub fn send_stdout(value: &T) -> Result<(), LSError>