fix(adapter): return valid json type to server

This commit is contained in:
kbwo 2024-12-24 17:11:06 +09:00
parent 91db91a229
commit 942f0b4ed1
8 changed files with 12 additions and 23 deletions

View file

@ -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<WorkerGuard, anyhow::Error> {

View file

@ -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)]

View file

@ -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)]

View file

@ -99,9 +99,7 @@ fn parse_diagnostics(
}
fn detect_workspaces(file_paths: Vec<String>) -> 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<Vec<TestItem>, LSError> {

View file

@ -77,9 +77,7 @@ fn parse_diagnostics(
}
fn detect_workspaces(file_paths: Vec<String>) -> 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<Vec<TestItem>, LSError> {

View file

@ -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(())
}

View file

@ -16,9 +16,7 @@ use super::util::{
};
fn detect_workspaces(file_paths: Vec<String>) -> 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<ResultFromXml, anyhow::Error> {

View file

@ -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<String, Vec<String>> {
) -> DetectWorkspaceResult {
let mut result_map: HashMap<String, Vec<String>> = 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<T>(value: &T) -> Result<(), LSError>