mirror of
https://github.com/kbwo/testing-language-server.git
synced 2025-08-01 22:32:14 +00:00
change adapter specification
This commit is contained in:
parent
a3eaa5ce67
commit
4a4f5411e4
5 changed files with 16 additions and 37 deletions
25
Cargo.lock
generated
25
Cargo.lock
generated
|
@ -520,7 +520,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "testing-language-server"
|
||||
version = "0.0.1"
|
||||
version = "0.0.2"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
|
@ -538,27 +538,6 @@ dependencies = [
|
|||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "testing-language-server"
|
||||
version = "0.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bb5189196366a4603fcd66cabd68576ac13b9594186dab4348f3e0381b3fab23"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
"dirs",
|
||||
"lsp-types",
|
||||
"once_cell",
|
||||
"regex",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"strum",
|
||||
"thiserror",
|
||||
"tracing",
|
||||
"tracing-appender",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "testing-ls-adapter"
|
||||
version = "0.0.1"
|
||||
|
@ -570,7 +549,7 @@ dependencies = [
|
|||
"serde",
|
||||
"serde_json",
|
||||
"tempfile",
|
||||
"testing-language-server 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"testing-language-server",
|
||||
"tree-sitter",
|
||||
"tree-sitter-javascript",
|
||||
"tree-sitter-rust",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "testing-language-server"
|
||||
version = "0.0.1"
|
||||
version = "0.0.2"
|
||||
edition = "2021"
|
||||
author = "Kodai Kabasawa <kabaaa1126@gmail.com>"
|
||||
description = "LSP server for testing"
|
||||
|
@ -8,7 +8,7 @@ license = "MIT"
|
|||
|
||||
[workspace]
|
||||
members = [ "crates/adapter"]
|
||||
exclude = ["test_proj/rust"]
|
||||
exclude = ["test_proj"]
|
||||
|
||||
[[bin]]
|
||||
name = "testing-language-server"
|
||||
|
|
|
@ -8,7 +8,8 @@ license = "MIT"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
testing-language-server = "0.0.1"
|
||||
# testing-language-server = "0.0.1"
|
||||
testing-language-server = { path = "../../" }
|
||||
lsp-types = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::error::LSError;
|
||||
use crate::spec::AdapterConfiguration;
|
||||
use crate::spec::AdapterId;
|
||||
use crate::spec::DetectWorkspaceRootResult;
|
||||
use crate::spec::DetectWorkspaceResult;
|
||||
use crate::spec::DiscoverResult;
|
||||
use crate::spec::RunFileTestResult;
|
||||
use crate::spec::RunFileTestResultItem;
|
||||
|
@ -272,7 +272,7 @@ impl TestingLS {
|
|||
args_file_path.push(file_path);
|
||||
});
|
||||
let output = adapter_command
|
||||
.arg("detect-workspace-root")
|
||||
.arg("detect-workspace")
|
||||
.args(args_file_path)
|
||||
.arg("--")
|
||||
.args(extra_args)
|
||||
|
@ -281,8 +281,7 @@ impl TestingLS {
|
|||
.map_err(|err| LSError::Adapter(err.to_string()))?;
|
||||
let adapter_result = String::from_utf8(output.stdout)
|
||||
.map_err(|err| LSError::Adapter(err.to_string()))?;
|
||||
let workspace_root: DetectWorkspaceRootResult =
|
||||
serde_json::from_str(&adapter_result)?;
|
||||
let workspace_root: DetectWorkspaceResult = serde_json::from_str(&adapter_result)?;
|
||||
self.workspace_root_cache
|
||||
.push(WorkspaceAnalysis::new(adapter.clone(), workspace_root))
|
||||
}
|
||||
|
@ -342,7 +341,7 @@ impl TestingLS {
|
|||
let mut diagnostics: Vec<(String, Vec<Diagnostic>)> = vec![];
|
||||
let cwd = PathBuf::from(workspace_root);
|
||||
let adapter_command = adapter_command.current_dir(&cwd);
|
||||
let mut args: Vec<&str> = vec!["--workspace-root", cwd.to_str().unwrap()];
|
||||
let mut args: Vec<&str> = vec!["--workspace", cwd.to_str().unwrap()];
|
||||
paths.iter().for_each(|path| {
|
||||
args.push("--file-paths");
|
||||
args.push(path);
|
||||
|
|
12
src/spec.rs
12
src/spec.rs
|
@ -9,7 +9,7 @@ use std::collections::HashMap;
|
|||
pub enum AdapterCommands {
|
||||
Discover(DiscoverArgs),
|
||||
RunFileTest(RunFileTestArgs),
|
||||
DetectWorkspaceRoot(DetectWorkspaceRootArgs),
|
||||
DetectWorkspace(DetectWorkspaceArgs),
|
||||
}
|
||||
|
||||
#[derive(clap::Args, Debug)]
|
||||
|
@ -36,7 +36,7 @@ pub struct RunFileTestArgs {
|
|||
|
||||
#[derive(clap::Args, Debug)]
|
||||
#[command(version, about, long_about = None)]
|
||||
pub struct DetectWorkspaceRootArgs {
|
||||
pub struct DetectWorkspaceArgs {
|
||||
#[arg(short, long)]
|
||||
pub file_paths: Vec<String>,
|
||||
#[arg(last = true)]
|
||||
|
@ -45,18 +45,18 @@ pub struct DetectWorkspaceRootArgs {
|
|||
|
||||
pub(crate) type AdapterId = String;
|
||||
pub(crate) type FilePath = String;
|
||||
pub(crate) type WorkspaceRootFilePath = String;
|
||||
pub(crate) type WorkspaceFilePath = String;
|
||||
|
||||
#[derive(Debug, Serialize, Clone)]
|
||||
pub struct WorkspaceAnalysis {
|
||||
pub adapter_config: AdapterConfiguration,
|
||||
pub workspace_roots: DetectWorkspaceRootResult,
|
||||
pub workspace_roots: DetectWorkspaceResult,
|
||||
}
|
||||
|
||||
impl WorkspaceAnalysis {
|
||||
pub fn new(
|
||||
adapter_config: AdapterConfiguration,
|
||||
workspace_roots: DetectWorkspaceRootResult,
|
||||
workspace_roots: DetectWorkspaceResult,
|
||||
) -> Self {
|
||||
Self {
|
||||
adapter_config,
|
||||
|
@ -76,7 +76,7 @@ pub struct AdapterConfiguration {
|
|||
pub exclude_patterns: Vec<String>,
|
||||
}
|
||||
|
||||
pub type DetectWorkspaceRootResult = HashMap<WorkspaceRootFilePath, Vec<FilePath>>;
|
||||
pub type DetectWorkspaceResult = HashMap<WorkspaceFilePath, Vec<FilePath>>;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Eq, PartialEq, Clone)]
|
||||
pub struct RunFileTestResultItem {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue