mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-22 09:39:27 -10:00
Compare commits
18
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
679c905621 | ||
|
|
3103ec19f9 | ||
|
|
026ef8794f | ||
|
|
7e77c270b7 | ||
|
|
9abca932d1 | ||
|
|
ce6c61aa5e | ||
|
|
9e8722feb6 | ||
|
|
f2950defcf | ||
|
|
0130847bc0 | ||
|
|
b9f9e2668a | ||
|
|
1f39eb8e63 | ||
|
|
a4db4a9e3f | ||
|
|
c209e189e0 | ||
|
|
0b83b3ffbc | ||
|
|
7caec95fee | ||
|
|
3d56af936d | ||
|
|
0a3eac8652 | ||
|
|
70702934d1 |
No files matched your search
@@ -80,6 +80,7 @@ Shared agent skills live in `.agents/skills/` (`.claude/skills/` links to them):
|
||||
this worktree's running MCP bridges and actual ports.
|
||||
- `pnpm build` — typecheck + bundle frontend.
|
||||
- `pnpm dogfood:build` / `pnpm dogfood:install` (or `mise run dogfood:build` / `mise run dogfood:install`) — build and locally install the grey-icon dogfood desktop app sharing release settings and data.
|
||||
- `pnpm dogfood:remote <remote_name> [--restart | --no-restart] [--clean]` (or `mise run dogfood:remote <remote_name>`) — sync backend sources to a host from **Tools › SSH Configurations**, build `openidea-server`, and stage it for Remote Development.
|
||||
- `cargo nextest run --workspace` (or `cargo test`), `cargo clippy --workspace --all-targets -- -D warnings`, `cargo fmt --all`.
|
||||
- `cargo test -p ide-host --test language_smoke -- --ignored --exact <language>` — code intelligence
|
||||
on `fixtures/` with that language's real server installed (CI: `Language smoke`, pinned versions).
|
||||
|
||||
Generated
+1
@@ -4846,6 +4846,7 @@ dependencies = [
|
||||
name = "ide-sdk"
|
||||
version = "0.1.50"
|
||||
dependencies = [
|
||||
"dirs 6.0.0",
|
||||
"dunce",
|
||||
"flate2",
|
||||
"ide-core",
|
||||
|
||||
@@ -948,6 +948,12 @@ pub struct AgentSkill {
|
||||
/// True when frontmatter sets `disable-model-invocation: true` (defaults to `slashOnly`).
|
||||
#[serde(default)]
|
||||
pub disable_model_invocation: bool,
|
||||
/// True when frontmatter sets `context: fork` (passed through natively to supporting CLIs).
|
||||
#[serde(default)]
|
||||
pub context_fork: bool,
|
||||
/// Optional `paths` / `globs` patterns from frontmatter (passed through natively to supporting CLIs).
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub paths: Vec<String>,
|
||||
/// The `SKILL.md` passes validation (`name` matches its folder, `description` present).
|
||||
pub valid: bool,
|
||||
/// What validation found (`name` mismatch, missing or over-long description…).
|
||||
|
||||
@@ -125,10 +125,9 @@ fn file_name(path: &Path) -> Option<String> {
|
||||
path.file_name()?.to_str().map(str::to_owned)
|
||||
}
|
||||
|
||||
/// The `key: value` lines between the leading `---` fences (folded `>` / `|` values joined).
|
||||
struct Frontmatter {
|
||||
fields: Vec<(String, String)>,
|
||||
/// Where the body starts.
|
||||
lists: Vec<(String, Vec<String>)>,
|
||||
body: usize,
|
||||
}
|
||||
|
||||
@@ -138,22 +137,42 @@ impl Frontmatter {
|
||||
let mut lines = text.split_inclusive('\n');
|
||||
let mut offset = 0;
|
||||
let mut fields: Vec<(String, String)> = Vec::new();
|
||||
let mut lists: Vec<(String, Vec<String>)> = Vec::new();
|
||||
match lines.next() {
|
||||
Some(first) if first.trim_end() == "---" => offset += first.len(),
|
||||
_ => return Self { fields, body: 0 },
|
||||
_ => return Self { fields, lists, body: 0 },
|
||||
}
|
||||
for line in lines {
|
||||
offset += line.len();
|
||||
let line = line.trim_end();
|
||||
if line == "---" {
|
||||
return Self { fields, body: offset };
|
||||
return Self { fields, lists, body: offset };
|
||||
}
|
||||
if line.starts_with([' ', '\t']) {
|
||||
let unindented_list_item = (line == "-" || line.starts_with("- ") || line.starts_with("-\t"))
|
||||
&& fields.last().is_some_and(|(_, v)| v.is_empty());
|
||||
if line.starts_with([' ', '\t']) || unindented_list_item {
|
||||
let trimmed = line.trim();
|
||||
if let Some(rest) = trimmed.strip_prefix('-')
|
||||
&& (rest.is_empty() || rest.starts_with([' ', '\t']))
|
||||
&& let Some((key, _)) = fields.last()
|
||||
{
|
||||
let item = unquote(rest.trim());
|
||||
if !item.is_empty() {
|
||||
if let Some((_, existing)) = lists.iter_mut().find(|(k, _)| k == key) {
|
||||
existing.push(item.to_owned());
|
||||
} else {
|
||||
lists.push((key.clone(), vec![item.to_owned()]));
|
||||
}
|
||||
}
|
||||
if unindented_list_item {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if let Some((_, value)) = fields.last_mut() {
|
||||
if !value.is_empty() {
|
||||
value.push(' ');
|
||||
}
|
||||
value.push_str(line.trim());
|
||||
value.push_str(trimmed);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -164,11 +183,15 @@ impl Frontmatter {
|
||||
}
|
||||
}
|
||||
// No closing fence: not frontmatter.
|
||||
Self { fields: Vec::new(), body: 0 }
|
||||
Self { fields: Vec::new(), lists: Vec::new(), body: 0 }
|
||||
}
|
||||
|
||||
fn get(&self, key: &str) -> Option<&str> {
|
||||
self.fields.iter().find(|(k, _)| k == key).map(|(_, v)| v.as_str())
|
||||
self.fields.iter().find(|(k, _)| k.eq_ignore_ascii_case(key)).map(|(_, v)| v.as_str())
|
||||
}
|
||||
|
||||
fn list(&self, key: &str) -> Option<&[String]> {
|
||||
self.lists.iter().find(|(k, _)| k.eq_ignore_ascii_case(key)).map(|(_, v)| v.as_slice())
|
||||
}
|
||||
|
||||
/// `description`, else the body's first line.
|
||||
@@ -505,6 +528,8 @@ fn parse_skill_file(dir: &Path, folder: &str, text: &str, source: AgentSkillSour
|
||||
let hint = meta.get("argument-hint").map(|h| strip_ansi(h).trim().to_owned()).filter(|h| !h.is_empty());
|
||||
let user_invocable = !meta.get("user-invocable").is_some_and(|v| v.eq_ignore_ascii_case("false"));
|
||||
let disable_model_invocation = meta.get("disable-model-invocation").is_some_and(|v| v.eq_ignore_ascii_case("true"));
|
||||
let context_fork = meta.get("context").is_some_and(|v| strip_ansi(v).trim().eq_ignore_ascii_case("fork"));
|
||||
let paths = parse_skill_paths(&meta);
|
||||
AgentSkill {
|
||||
name,
|
||||
description: truncate(&description),
|
||||
@@ -514,11 +539,35 @@ fn parse_skill_file(dir: &Path, folder: &str, text: &str, source: AgentSkillSour
|
||||
also_in: Vec::new(),
|
||||
user_invocable,
|
||||
disable_model_invocation,
|
||||
context_fork,
|
||||
paths,
|
||||
valid: warnings.is_empty(),
|
||||
warnings,
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_skill_paths(meta: &Frontmatter) -> Vec<String> {
|
||||
for key in ["paths", "globs"] {
|
||||
if let Some(items) = meta.list(key) {
|
||||
let cleaned: Vec<String> =
|
||||
items.iter().map(|s| strip_ansi(s).trim().to_owned()).filter(|s| !s.is_empty()).collect();
|
||||
if !cleaned.is_empty() {
|
||||
return cleaned;
|
||||
}
|
||||
}
|
||||
if let Some(raw) = meta.get(key) {
|
||||
let trimmed = strip_ansi(raw);
|
||||
let inner = trimmed.trim().strip_prefix('[').and_then(|s| s.strip_suffix(']')).unwrap_or(trimmed.trim());
|
||||
let cleaned: Vec<String> =
|
||||
inner.split(',').map(|p| unquote(p.trim()).trim().to_owned()).filter(|p| !p.is_empty()).collect();
|
||||
if !cleaned.is_empty() {
|
||||
return cleaned;
|
||||
}
|
||||
}
|
||||
}
|
||||
Vec::new()
|
||||
}
|
||||
|
||||
/// A skill's mode, as one policy layer of the settings has it.
|
||||
type Policies = BTreeMap<String, AgentSkillPolicy>;
|
||||
|
||||
@@ -1034,6 +1083,8 @@ mod tests {
|
||||
also_in: Vec::new(),
|
||||
user_invocable: true,
|
||||
disable_model_invocation: false,
|
||||
context_fork: false,
|
||||
paths: Vec::new(),
|
||||
valid: true,
|
||||
warnings: Vec::new(),
|
||||
}
|
||||
@@ -1435,4 +1486,40 @@ mod tests {
|
||||
let _ = stage(&farm, "claude", &off_states, &ws, Some(&home)).unwrap();
|
||||
assert!(!farm.join(".claude/skills/release-notes").exists());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_context_fork_and_paths_frontmatter_and_preserves_file_on_stage() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let root = dunce::canonicalize(tmp.path()).unwrap();
|
||||
let ws = root.join("ws");
|
||||
let raw_md = "---\n\
|
||||
name: verify-ux\n\
|
||||
description: Verify UX layouts in an isolated subagent\n\
|
||||
context: fork\n\
|
||||
paths:\n\
|
||||
- \"src/**/*.tsx\"\n\
|
||||
- crates/ide-agent/**/*.rs\n\
|
||||
---\n\nRun visual checks.\n";
|
||||
write(&ws.join(".openidea/skills/verify-ux/SKILL.md"), raw_md);
|
||||
write(
|
||||
&ws.join(".agents/skills/inline-globs/SKILL.md"),
|
||||
"---\nname: inline-globs\ndescription: Scoped by globs\nglobs: [\"e2e/*.spec.ts\", \"src/ui/*.tsx\"]\n---\n",
|
||||
);
|
||||
|
||||
let found = discover_skills(&ws, None);
|
||||
let verify = found.iter().find(|s| s.name == "verify-ux").unwrap();
|
||||
assert!(verify.context_fork);
|
||||
assert_eq!(verify.paths, ["src/**/*.tsx", "crates/ide-agent/**/*.rs"]);
|
||||
|
||||
let inline = found.iter().find(|s| s.name == "inline-globs").unwrap();
|
||||
assert!(!inline.context_fork);
|
||||
assert_eq!(inline.paths, ["e2e/*.spec.ts", "src/ui/*.tsx"]);
|
||||
|
||||
// Staging passes `SKILL.md` through untouched so native CLIs execute `context: fork` / `paths`.
|
||||
let states = resolve(found, None, &BTreeMap::new(), &BTreeMap::new(), true);
|
||||
let farm = farm_dir(&root.join("store"), "fork-passthrough");
|
||||
let _ = stage(&farm, "copilot", &states, &ws, None).unwrap();
|
||||
let staged_md = std::fs::read_to_string(farm.join("copilot/verify-ux/SKILL.md")).unwrap();
|
||||
assert_eq!(staged_md, raw_md);
|
||||
}
|
||||
}
|
||||
@@ -1206,6 +1206,7 @@ pub struct LanguagesSettings {
|
||||
pub typescript: TypeScriptSettings,
|
||||
pub prettier: ExternalFormatterSettings,
|
||||
pub oxfmt: ExternalFormatterSettings,
|
||||
pub biome: ExternalFormatterSettings,
|
||||
pub ruff: ExternalFormatterSettings,
|
||||
pub java: JavaSettings,
|
||||
pub ruby: RubySettings,
|
||||
@@ -1226,6 +1227,10 @@ impl Default for LanguagesSettings {
|
||||
typescript: TypeScriptSettings::default(),
|
||||
prettier: ExternalFormatterSettings::default(),
|
||||
oxfmt: ExternalFormatterSettings::default(),
|
||||
biome: ExternalFormatterSettings {
|
||||
languages: BIOME_LANGUAGES.iter().map(|&l| l.into()).collect(),
|
||||
..ExternalFormatterSettings::default()
|
||||
},
|
||||
ruff: ExternalFormatterSettings {
|
||||
languages: vec!["python".into()],
|
||||
..ExternalFormatterSettings::default()
|
||||
@@ -1297,6 +1302,7 @@ impl LanguagesSettings {
|
||||
match tool {
|
||||
ExternalFormatter::Prettier => &self.prettier,
|
||||
ExternalFormatter::Oxfmt => &self.oxfmt,
|
||||
ExternalFormatter::Biome => &self.biome,
|
||||
ExternalFormatter::Ruff => &self.ruff,
|
||||
}
|
||||
}
|
||||
@@ -1308,6 +1314,7 @@ impl LanguagesSettings {
|
||||
pub enum ExternalFormatter {
|
||||
Prettier,
|
||||
Oxfmt,
|
||||
Biome,
|
||||
Ruff,
|
||||
}
|
||||
|
||||
@@ -1317,16 +1324,21 @@ impl ExternalFormatter {
|
||||
match self {
|
||||
Self::Prettier => "prettier",
|
||||
Self::Oxfmt => "oxfmt",
|
||||
Self::Biome => "biome",
|
||||
Self::Ruff => "ruff",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// An external formatter (Prettier, oxfmt, Ruff) and the languages it formats.
|
||||
/// The languages Biome formats (of those Prettier formats).
|
||||
pub const BIOME_LANGUAGES: [&str; 8] =
|
||||
["css", "graphql", "javascript", "javascriptreact", "typescript", "typescriptreact", "json", "jsonc"];
|
||||
|
||||
/// An external formatter (Prettier, oxfmt, Biome, Ruff) and the languages it formats.
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)]
|
||||
#[serde(default, rename_all = "camelCase")]
|
||||
pub struct ExternalFormatterSettings {
|
||||
/// Empty path: project node_modules (Prettier/oxfmt), managed installation, then PATH.
|
||||
/// Empty path: project node_modules (Prettier/oxfmt/Biome), managed installation, then PATH.
|
||||
pub path: String,
|
||||
/// Ruff only: directory containing its configuration, or a configuration file.
|
||||
pub configuration_directory: String,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
use crate::Host;
|
||||
use ide_core::event::NotifyLevel;
|
||||
use ide_core::settings::{ExternalFormatter, LanguagesSettings, Settings};
|
||||
use ide_core::settings::{BIOME_LANGUAGES, ExternalFormatter, LanguagesSettings, Settings};
|
||||
use ide_core::{ChangeSet, DocId, IdeError, IdeEvent, IdeResult, LanguageId, Pos, Range, TextEdit};
|
||||
use ide_language::{LanguageConfig, PhpAlignment, Syntax};
|
||||
use ide_lsp::types::FormatOptions;
|
||||
@@ -10,9 +10,28 @@ use ide_tools::{Tools, formatter};
|
||||
use std::path::Path;
|
||||
|
||||
const OXFMT_CONFIGS: [&str; 4] = [".oxfmtrc.json", ".oxfmtrc.jsonc", "oxfmt.config.ts", "oxfmt.config.mts"];
|
||||
/// A Biome configuration, or Biome installed as a project dependency (it then uses its defaults).
|
||||
const BIOME_MARKERS: [&str; 3] = ["biome.json", "biome.jsonc", "node_modules/@biomejs/biome/package.json"];
|
||||
|
||||
/// Reformat Code uses Biome below a Biome configuration or installation, unless the nearest
|
||||
/// configuration turns its formatter off (Biome lints, another tool formats).
|
||||
fn biome_formats(file: &Path) -> bool {
|
||||
let config = ["biome.json", "biome.jsonc"]
|
||||
.iter()
|
||||
.filter_map(|name| formatter::find_up(file, Path::new(name)))
|
||||
.max_by_key(|path| path.components().count());
|
||||
match config {
|
||||
Some(config) => !std::fs::read_to_string(&config)
|
||||
.ok()
|
||||
.and_then(|text| serde_json::from_str::<serde_json::Value>(&ide_core::jsonc::strip(&text)).ok())
|
||||
.is_some_and(|v| v.pointer("/formatter/enabled") == Some(&serde_json::Value::Bool(false))),
|
||||
None => BIOME_MARKERS.iter().any(|name| formatter::find_up(file, Path::new(name)).is_some()),
|
||||
}
|
||||
}
|
||||
|
||||
fn supports_external_format(language: &LanguageConfig, tool: ExternalFormatter) -> bool {
|
||||
match language.formatter.as_ref().map(|f| f.tool.as_str()) {
|
||||
Some("prettier") if tool == ExternalFormatter::Biome => BIOME_LANGUAGES.contains(&language.id.as_str()),
|
||||
Some("prettier") => matches!(tool, ExternalFormatter::Prettier | ExternalFormatter::Oxfmt),
|
||||
Some("ruff") => tool == ExternalFormatter::Ruff,
|
||||
_ => false,
|
||||
@@ -20,9 +39,9 @@ fn supports_external_format(language: &LanguageConfig, tool: ExternalFormatter)
|
||||
}
|
||||
|
||||
/// The external formatter of a file, for a language with an external formatter.
|
||||
/// `forced` names the tool (Reformat with Prettier, oxfmt, or Ruff). Ruff is
|
||||
/// the base formatter for Python; oxfmt can replace Prettier for its languages
|
||||
/// when configured or selected. A tool that cannot format the language is
|
||||
/// `forced` names the tool (Reformat with Prettier, oxfmt, Biome, or Ruff). Ruff is
|
||||
/// the base formatter for Python; Biome, then oxfmt, can replace Prettier for their
|
||||
/// languages when configured or selected. A tool that cannot format the language is
|
||||
/// rejected even when explicitly requested.
|
||||
fn external_tool(
|
||||
forced: Option<ExternalFormatter>,
|
||||
@@ -30,7 +49,7 @@ fn external_tool(
|
||||
file: &Path,
|
||||
settings: &LanguagesSettings,
|
||||
) -> IdeResult<Option<ExternalFormatter>> {
|
||||
use ExternalFormatter::{Oxfmt, Prettier, Ruff};
|
||||
use ExternalFormatter::{Biome, Oxfmt, Prettier, Ruff};
|
||||
let Some(language) = language.filter(|l| l.formatter.is_some()) else {
|
||||
return match forced {
|
||||
Some(tool) => Err(IdeError::invalid(format!(
|
||||
@@ -56,8 +75,11 @@ fn external_tool(
|
||||
if language.formatter.as_ref().is_some_and(|f| f.tool == "ruff") {
|
||||
return Ok(enabled(Ruff).then_some(Ruff));
|
||||
}
|
||||
let oxfmt_config = || OXFMT_CONFIGS.iter().any(|name| formatter::find_up(file, Path::new(name)).is_some());
|
||||
Ok(if enabled(Oxfmt) && (settings.oxfmt.prefer || oxfmt_config()) {
|
||||
let found = |names: &[&str]| names.iter().any(|name| formatter::find_up(file, Path::new(name)).is_some());
|
||||
let biome = enabled(Biome) && supports_external_format(language, Biome);
|
||||
Ok(if biome && (settings.biome.prefer || biome_formats(file)) {
|
||||
Some(Biome)
|
||||
} else if enabled(Oxfmt) && (settings.oxfmt.prefer || found(&OXFMT_CONFIGS)) {
|
||||
Some(Oxfmt)
|
||||
} else {
|
||||
enabled(Prettier).then_some(Prettier)
|
||||
@@ -385,7 +407,7 @@ async fn provider_edits(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use ExternalFormatter::{Oxfmt, Prettier, Ruff};
|
||||
use ExternalFormatter::{Biome, Oxfmt, Prettier, Ruff};
|
||||
use ide_core::LanguageId;
|
||||
use ide_language::LanguageRegistry;
|
||||
|
||||
@@ -428,6 +450,40 @@ mod tests {
|
||||
assert_eq!(prettier.message, "Prettier cannot format Python files");
|
||||
let oxfmt = tool(Some(Oxfmt), "python", file, &settings).unwrap_err();
|
||||
assert_eq!(oxfmt.message, "oxfmt cannot format Python files");
|
||||
let biome = tool(Some(Biome), "python", file, &settings).unwrap_err();
|
||||
assert_eq!(biome.message, "Biome cannot format Python files");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn biome_config_or_dependency_selects_biome_for_its_languages() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let root = dir.path();
|
||||
std::fs::create_dir_all(root.join("web/src")).unwrap();
|
||||
let (web, api, readme) = (root.join("web/src/app.ts"), root.join("api/main.ts"), root.join("web/README.md"));
|
||||
let mut settings = LanguagesSettings::default();
|
||||
for marker in BIOME_MARKERS {
|
||||
let path = root.join("web").join(marker);
|
||||
std::fs::create_dir_all(path.parent().unwrap()).unwrap();
|
||||
std::fs::write(&path, "{}").unwrap();
|
||||
assert_eq!(tool(None, "typescript", &web, &settings).unwrap(), Some(Biome), "{marker}");
|
||||
assert_eq!(tool(None, "typescript", &api, &settings).unwrap(), Some(Prettier), "{marker}");
|
||||
// Biome doesn't format Markdown: Prettier keeps it.
|
||||
assert_eq!(tool(None, "markdown", &readme, &settings).unwrap(), Some(Prettier), "{marker}");
|
||||
std::fs::remove_file(&path).unwrap();
|
||||
}
|
||||
std::fs::write(root.join("web/biome.json"), "{}").unwrap();
|
||||
std::fs::write(root.join("web/.oxfmtrc.json"), "{}").unwrap();
|
||||
assert_eq!(tool(None, "css", &web, &settings).unwrap(), Some(Biome));
|
||||
settings.biome.languages.retain(|l| l != "css");
|
||||
assert_eq!(tool(None, "css", &web, &settings).unwrap(), Some(Oxfmt));
|
||||
// Biome only lints here: Prettier keeps formatting.
|
||||
std::fs::remove_file(root.join("web/.oxfmtrc.json")).unwrap();
|
||||
std::fs::write(root.join("web/biome.json"), r#"{ "formatter": { "enabled": false } }"#).unwrap();
|
||||
assert_eq!(tool(None, "typescript", &web, &settings).unwrap(), Some(Prettier));
|
||||
settings.biome.prefer = true;
|
||||
assert_eq!(tool(None, "typescript", &api, &settings).unwrap(), Some(Biome));
|
||||
let markdown = tool(Some(Biome), "markdown", &readme, &settings).unwrap_err();
|
||||
assert_eq!(markdown.message, "Biome cannot format Markdown files");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -906,6 +906,7 @@ pub async fn build_run(
|
||||
let detected = project.detected_roots.read().clone();
|
||||
let config_dir = host.config_dir.clone();
|
||||
let token = host.begin_project_request(window, request);
|
||||
let launch_project = project.clone();
|
||||
let result = tokio::task::spawn_blocking(move || {
|
||||
// Fast path (#2476): an unchanged single-project Maven build skips
|
||||
// Maven entirely. Previous diagnostics stay: nothing changed, so they
|
||||
@@ -1003,7 +1004,12 @@ pub async fn build_run(
|
||||
};
|
||||
let result = compile::run(&root, &plan, &token, &|e| {
|
||||
let _ = on_event.send(e);
|
||||
})?;
|
||||
});
|
||||
if kind == BuildKind::Rebuild {
|
||||
// The clean removed outputs that earlier launch snapshots still hold.
|
||||
launch_project.java_launch_snapshots.lock().forget_reusable_snapshots();
|
||||
}
|
||||
let result = result?;
|
||||
if result.success && single && kind == BuildKind::Build {
|
||||
let model = with_profiles(load(&root, &cache, &settings), &cache);
|
||||
compile::record_menu_build(&cache, &root, &model, file.as_deref(), &token);
|
||||
|
||||
@@ -135,6 +135,16 @@ impl Session {
|
||||
}
|
||||
}
|
||||
|
||||
/// Build › Rebuild replaced the module outputs. The recorded snapshots were copied from
|
||||
/// the outputs before the clean and may hold classes it removed (a class moved to another
|
||||
/// package leaves its old file behind when jdtls wrote it), so none of them is reused:
|
||||
/// the next launch copies the rebuilt outputs.
|
||||
pub(crate) fn forget_reusable_snapshots(&mut self) {
|
||||
if let Err(error) = forget_reusable_snapshots(&self.cache) {
|
||||
tracing::warn!(%error, "Cannot invalidate Java launch snapshots");
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn build(
|
||||
&mut self,
|
||||
root: &Path,
|
||||
@@ -341,6 +351,32 @@ impl Drop for Session {
|
||||
}
|
||||
}
|
||||
|
||||
/// Clears the fingerprint of every launch record under `cache`, so no snapshot matches the
|
||||
/// sources any more. The records stay: their modules keep delegating to Maven.
|
||||
fn forget_reusable_snapshots(cache: &Path) -> std::io::Result<()> {
|
||||
let records = cache.join("java-launch/records");
|
||||
if !records.try_exists()? {
|
||||
return Ok(());
|
||||
}
|
||||
let mut pending = vec![records];
|
||||
while let Some(dir) = pending.pop() {
|
||||
for entry in fs::read_dir(dir)? {
|
||||
let entry = entry?;
|
||||
let kind = entry.file_type()?;
|
||||
if kind.is_dir() {
|
||||
pending.push(entry.path());
|
||||
} else if kind.is_file() && entry.path().extension().is_some_and(|ext| ext == "json") {
|
||||
let outputs: Option<Outputs> = serde_json::from_slice(&fs::read(entry.path())?).unwrap_or(None);
|
||||
if let Some(mut outputs) = outputs.filter(|o| o.fingerprint.is_some()) {
|
||||
outputs.fingerprint = None;
|
||||
write_record(&entry.path(), &outputs).map_err(|e| std::io::Error::other(e.message))?;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn referenced_snapshots(cache: &Path) -> std::io::Result<HashSet<PathBuf>> {
|
||||
let mut referenced = HashSet::new();
|
||||
let records = cache.join("java-launch/records");
|
||||
@@ -610,6 +646,34 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_menu_rebuild_stops_reusing_snapshots_that_hold_removed_classes() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let root = dir.path();
|
||||
let model = fixture(root);
|
||||
let cancel = CancellationToken::new();
|
||||
// A class jdtls wrote for a source since moved to another package; an incremental
|
||||
// Maven build leaves it in target/classes.
|
||||
fs::create_dir_all(root.join("target/classes")).unwrap();
|
||||
fs::write(root.join("target/classes/Stale.class"), "stale").unwrap();
|
||||
let mut session = Session::new(root.join("cache"));
|
||||
let first = session.build(root, &model, root, BuildOptions::default(), None, &cancel).unwrap();
|
||||
assert!(first.snapshot.join("0/Stale.class").is_file());
|
||||
let reused = session.build(root, &model, root, BuildOptions::default(), None, &cancel).unwrap();
|
||||
assert_eq!(reused.snapshot, first.snapshot);
|
||||
|
||||
// Build › Rebuild cleans the outputs and compiles again.
|
||||
fs::remove_file(root.join("target/classes/Stale.class")).unwrap();
|
||||
session.forget_reusable_snapshots();
|
||||
assert!(has_record(root, &root.join("cache"), root));
|
||||
let next = session.build(root, &model, root, BuildOptions::default(), None, &cancel).unwrap();
|
||||
assert_ne!(next.snapshot, first.snapshot);
|
||||
assert!(!next.snapshot.join("0/Stale.class").exists());
|
||||
assert!(next.snapshot.join("0/Main.class").is_file());
|
||||
let again = session.build(root, &model, root, BuildOptions::default(), None, &cancel).unwrap();
|
||||
assert_eq!(again.snapshot, next.snapshot);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn jdt_errors_reuse_an_unchanged_snapshot_and_rebuild_only_on_a_cache_miss() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
|
||||
@@ -286,6 +286,10 @@ impl Host {
|
||||
lombok.jar(),
|
||||
);
|
||||
ide_sdk::apply::configure_gradle_runtime(cfg, root, server_root, &effective);
|
||||
let gradle_dirs: Vec<_> = std::iter::once(data_dir.join("gradle"))
|
||||
.chain(dirs::cache_dir().map(|dir| dir.join("openidea").join("gradle")))
|
||||
.collect();
|
||||
ide_sdk::apply::configure_gradle_classpath(cfg, &gradle_dirs);
|
||||
ide_sdk::apply::configure_maven_sources(cfg, &effective);
|
||||
ide_sdk::jdtls::launch_directly(cfg);
|
||||
}
|
||||
|
||||
@@ -156,7 +156,8 @@ pub struct LanguageServerConfig {
|
||||
pub requires_env: Vec<String>,
|
||||
/// Files whose presence marks a workspace root, e.g. `Cargo.toml`;
|
||||
/// `file#table` requires the TOML file to contain that dotted table, e.g.
|
||||
/// `pyproject.toml#tool.ruff`.
|
||||
/// `pyproject.toml#tool.ruff`, or the JSON file that dotted key, e.g.
|
||||
/// `package.json#devDependencies.tailwindcss`.
|
||||
#[serde(default)]
|
||||
pub root_markers: Vec<String>,
|
||||
/// Serve only files below a root marker, not the whole project: a framework's
|
||||
|
||||
@@ -58,11 +58,12 @@ pub fn arduino_sketch_root(project: &Path, path: &Path) -> Option<PathBuf> {
|
||||
|
||||
/// `dir` contains `marker`: a relative path, a file name pattern with one
|
||||
/// `*` (`*.csproj`), or a TOML or JSON file name (no pattern) and a dotted table
|
||||
/// it must contain (`pyproject.toml#tool.ruff`, `package.json#eslintConfig`).
|
||||
/// or JSON key it must contain (`pyproject.toml#tool.ruff`, `package.json#eslintConfig`,
|
||||
/// `package.json#devDependencies.tailwindcss`).
|
||||
fn has_marker(dir: &Path, marker: &str) -> bool {
|
||||
if let Some((file, table)) = marker.split_once('#') {
|
||||
return if file.ends_with(".json") {
|
||||
has_json_object(&dir.join(file), table)
|
||||
has_json_key(&dir.join(file), table)
|
||||
} else {
|
||||
has_toml_table(&dir.join(file), table)
|
||||
};
|
||||
@@ -88,11 +89,12 @@ fn has_toml_table(file: &Path, table: &str) -> bool {
|
||||
table.split('.').try_fold(&value, |v, key| v.get(key)).is_some_and(toml::Value::is_table)
|
||||
}
|
||||
|
||||
/// `file` parses as JSON and has the dotted object `key` (`eslintConfig`).
|
||||
fn has_json_object(file: &Path, key: &str) -> bool {
|
||||
/// `file` parses as JSON and has the dotted `key` with a value other than `null`:
|
||||
/// an object (`eslintConfig`) or a dependency's version (`dependencies.tailwindcss`).
|
||||
fn has_json_key(file: &Path, key: &str) -> bool {
|
||||
let Ok(text) = std::fs::read_to_string(file) else { return false };
|
||||
let Ok(value) = serde_json::from_str::<serde_json::Value>(&text) else { return false };
|
||||
key.split('.').try_fold(&value, |v, key| v.get(key)).is_some_and(serde_json::Value::is_object)
|
||||
key.split('.').try_fold(&value, |v, key| v.get(key)).is_some_and(|v| !v.is_null())
|
||||
}
|
||||
|
||||
/// `path` is (or, after its creation or removal, was) a root marker of the
|
||||
@@ -177,6 +179,20 @@ mod tests {
|
||||
assert!(!is_marker_path(&root.join("svc/setup.cfg"), "pyproject.toml#tool.ruff"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn json_markers_need_their_key() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let dir = tmp.path();
|
||||
let marker = "package.json#devDependencies.tailwindcss";
|
||||
std::fs::write(dir.join("package.json"), r#"{"devDependencies": {"vite": "^7.0.0"}}"#).unwrap();
|
||||
assert!(!has_marker(dir, marker));
|
||||
std::fs::write(dir.join("package.json"), r#"{"devDependencies": {"tailwindcss": "^4.1.0"}}"#).unwrap();
|
||||
assert!(has_marker(dir, marker) && !has_marker(dir, "package.json#dependencies.tailwindcss"));
|
||||
std::fs::write(dir.join("package.json"), r#"{"eslintConfig": null}"#).unwrap();
|
||||
assert!(!has_marker(dir, "package.json#eslintConfig"));
|
||||
assert!(is_marker_path(&dir.join("package.json"), marker));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn patterns_match_file_names() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
|
||||
@@ -715,9 +715,20 @@ mod tests {
|
||||
// it); before the HTML server (hover, rename and symbols take the first).
|
||||
assert_eq!(
|
||||
names("typescript"),
|
||||
["vtsls", "typescript-language-server", "angular-language-server", "oxlint", "eslint"]
|
||||
[
|
||||
"vtsls",
|
||||
"typescript-language-server",
|
||||
"angular-language-server",
|
||||
"oxlint",
|
||||
"eslint",
|
||||
"biome",
|
||||
"tailwindcss-language-server"
|
||||
]
|
||||
);
|
||||
assert_eq!(
|
||||
names("html"),
|
||||
["angular-language-server", "vscode-html-language-server", "tailwindcss-language-server"]
|
||||
);
|
||||
assert_eq!(names("html"), ["angular-language-server", "vscode-html-language-server"]);
|
||||
for lang in ["typescript", "html"] {
|
||||
let cfg = reg.get(&LanguageId::new(lang)).unwrap();
|
||||
let angular = cfg.language_servers.iter().find(|s| s.name == "angular-language-server").unwrap();
|
||||
@@ -744,6 +755,34 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn biome_lints_files_below_its_config_or_installation() {
|
||||
let reg = reg();
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let root = tmp.path();
|
||||
for dir in ["apps/web/src", "apps/admin/node_modules/@biomejs/biome", "apps/api"] {
|
||||
std::fs::create_dir_all(root.join(dir)).unwrap();
|
||||
}
|
||||
std::fs::write(root.join("apps/web/biome.jsonc"), "{}").unwrap();
|
||||
for lang in
|
||||
["javascript", "javascriptreact", "typescript", "typescriptreact", "json", "jsonc", "css", "graphql"]
|
||||
{
|
||||
let cfg = reg.get(&LanguageId::new(lang)).unwrap();
|
||||
let biome = cfg.language_servers.iter().find(|s| s.name == "biome").unwrap();
|
||||
assert_eq!(
|
||||
(biome.command.as_str(), biome.args.as_slice()),
|
||||
("biome", ["lsp-proxy".to_string()].as_slice())
|
||||
);
|
||||
assert!(biome.require_root_marker && !biome.fallback, "{lang}");
|
||||
// Reformat Code runs `biome format`: the server's formatting would race the language's own.
|
||||
assert_eq!(biome.features, ["code-action", "diagnostics"], "{lang}");
|
||||
let served = |file: &str| crate::marked_root(Some(root), &root.join(file), &biome.root_markers);
|
||||
assert_eq!(served("apps/web/src/main.ts"), Some(root.join("apps/web")), "{lang}");
|
||||
assert_eq!(served("apps/admin/main.ts"), Some(root.join("apps/admin")), "{lang}");
|
||||
assert_eq!(served("apps/api/main.ts"), None, "{lang}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn eslint_serves_js_files_only_below_its_config() {
|
||||
let reg = reg();
|
||||
@@ -771,6 +810,33 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tailwind_serves_web_files_only_in_tailwind_projects() {
|
||||
let reg = reg();
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let root = tmp.path();
|
||||
for dir in ["v3/src", "v4/src", "plain/src"] {
|
||||
std::fs::create_dir_all(root.join(dir)).unwrap();
|
||||
}
|
||||
std::fs::write(root.join("v3/tailwind.config.js"), "module.exports = {};").unwrap();
|
||||
std::fs::write(root.join("v4/package.json"), r#"{"devDependencies": {"tailwindcss": "^4.1.0"}}"#).unwrap();
|
||||
std::fs::write(root.join("plain/package.json"), r#"{"devDependencies": {"vite": "^7.0.0"}}"#).unwrap();
|
||||
for lang in
|
||||
["html", "css", "javascript", "javascriptreact", "typescript", "typescriptreact", "vue", "svelte", "astro"]
|
||||
{
|
||||
let cfg = reg.get(&LanguageId::new(lang)).unwrap();
|
||||
// Last: the language's own servers answer hover first.
|
||||
let tailwind = cfg.language_servers.last().unwrap();
|
||||
assert_eq!(tailwind.name, "tailwindcss-language-server", "{lang}");
|
||||
assert_eq!(tailwind.args, ["--stdio"], "{lang}");
|
||||
assert!(tailwind.require_root_marker && !tailwind.fallback, "{lang}");
|
||||
let served = |file: &str| crate::marked_root(Some(root), &root.join(file), &tailwind.root_markers);
|
||||
assert_eq!(served("v3/src/app.css"), Some(root.join("v3")), "{lang}");
|
||||
assert_eq!(served("v4/src/app.css"), Some(root.join("v4")), "{lang}");
|
||||
assert_eq!(served("plain/src/app.css"), None, "{lang}: package.json without tailwindcss");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn laravel_lsp_serves_php_files_only_below_artisan() {
|
||||
let reg = reg();
|
||||
|
||||
@@ -947,6 +947,73 @@ async fn angular_language_server_end_to_end() {
|
||||
tokio::time::timeout(Duration::from_secs(10), mgr.shutdown_all()).await.unwrap();
|
||||
}
|
||||
|
||||
/// The Tailwind CSS server on `fixtures/tailwind-app` (Tailwind 4, `@theme` colours), with
|
||||
/// the built-in definitions: class completion in JSX and `@apply`, hover with the generated
|
||||
/// CSS, and the class conflict warning. Set `OPENIDEA_TEST_NPM_TOOLS` to a dir with
|
||||
/// `npm i @tailwindcss/language-server`; the fixture's own `tailwindcss` isn't needed.
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
#[ignore = "requires @tailwindcss/language-server (OPENIDEA_TEST_NPM_TOOLS)"]
|
||||
async fn tailwindcss_language_server_end_to_end() {
|
||||
let tools = std::path::PathBuf::from(std::env::var("OPENIDEA_TEST_NPM_TOOLS").expect("OPENIDEA_TEST_NPM_TOOLS"));
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let root = dir.path().canonicalize().unwrap();
|
||||
let fixture = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/tailwind-app");
|
||||
for file in ["package.json", "index.html", "src/app.css", "src/App.tsx"] {
|
||||
std::fs::create_dir_all(root.join(file).parent().unwrap()).unwrap();
|
||||
std::fs::copy(fixture.join(file), root.join(file)).unwrap();
|
||||
}
|
||||
let builtin = LanguageRegistry::load(None).unwrap();
|
||||
let languages = ["typescriptreact", "css"].map(|id| {
|
||||
let mut cfg = builtin.get(&LanguageId::new(id)).unwrap();
|
||||
cfg.language_servers.retain(|s| s.name == "tailwindcss-language-server");
|
||||
let bin = tools.join("node_modules/.bin/tailwindcss-language-server");
|
||||
cfg.language_servers[0].command = bin.to_string_lossy().into_owned();
|
||||
cfg
|
||||
});
|
||||
let (mgr, events) = manager(&root, LanguageRegistry::from_configs(languages.to_vec()));
|
||||
let (tsx, css) = (DocId::next(), DocId::next());
|
||||
let tsx_path = root.join("src/App.tsx");
|
||||
let css_path = root.join("src/app.css");
|
||||
let tsx_text = std::fs::read_to_string(&tsx_path).unwrap();
|
||||
let css_text = std::fs::read_to_string(&css_path).unwrap();
|
||||
mgr.did_open(tsx, &tsx_path, &LanguageId::new("typescriptreact"), 1, &tsx_text);
|
||||
mgr.did_open(css, &css_path, &LanguageId::new("css"), 1, &css_text);
|
||||
let at = |text: &str, needle: &str, offset: usize| {
|
||||
let (line, l) = text.lines().enumerate().find(|(_, l)| l.contains(needle)).unwrap();
|
||||
Pos::new(line as u32, (l.find(needle).unwrap() + offset) as u32)
|
||||
};
|
||||
|
||||
// The project's own `@theme` colour, in `className` and after `@apply`.
|
||||
let in_class = at(&tsx_text, "className=\"flex flex-col", "className=\"".len());
|
||||
let in_apply = at(&css_text, "@apply rounded-md", "@apply ".len());
|
||||
for (doc, pos) in [(tsx, in_class), (css, in_apply)] {
|
||||
retry("class completion", Duration::from_secs(60), || {
|
||||
let mgr = mgr.clone();
|
||||
async move {
|
||||
let list = mgr.completion(doc, pos, None, Default::default()).await.ok()?;
|
||||
list.items.iter().any(|i| i.label == "bg-brand-500").then_some(())
|
||||
}
|
||||
})
|
||||
.await;
|
||||
}
|
||||
let hover = mgr.hover(tsx, at(&tsx_text, "bg-white", 1), Default::default()).await.unwrap().unwrap();
|
||||
assert!(hover.contents.value.contains("background-color"), "{}", hover.contents.value);
|
||||
let hover = mgr.hover(tsx, at(&tsx_text, "text-brand-700", 1), Default::default()).await.unwrap().unwrap();
|
||||
assert!(hover.contents.value.contains("--color-brand-700"), "{}", hover.contents.value);
|
||||
|
||||
// `flex block`: both set `display`.
|
||||
retry("class conflict", Duration::from_secs(30), || {
|
||||
let found = events.lock().iter().any(|e| {
|
||||
matches!(e, IdeEvent::Diagnostics { path, items, .. }
|
||||
if path.ends_with("src/App.tsx")
|
||||
&& items.iter().any(|d| d.message.contains("applies the same CSS properties")))
|
||||
});
|
||||
async move { found.then_some(()) }
|
||||
})
|
||||
.await;
|
||||
tokio::time::timeout(Duration::from_secs(10), mgr.shutdown_all()).await.unwrap();
|
||||
}
|
||||
|
||||
/// A notebook's code cells on basedpyright and Ruff (LSP 3.17 notebook sync): names flow from
|
||||
/// earlier cells, IPython magics parse, and locations and diagnostics name the cells.
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
|
||||
@@ -244,13 +244,16 @@ pub(crate) fn is_test_script(name: &str) -> bool {
|
||||
}
|
||||
|
||||
/// The test runner a `package.json` script starts, when its output and test selection differ
|
||||
/// from Jest / Vitest's: `playwright test`, or `node --test` (`tsx --test`) with Node's own
|
||||
/// from Jest / Vitest's: `playwright test`, `mocha`, or `node --test` (`tsx --test`) with Node's own
|
||||
/// reporters (the IDE adds its reporter next to them, which a reporter chosen here would clash with).
|
||||
fn script_test_runner(script: &str) -> Option<&'static str> {
|
||||
let tokens: Vec<&str> = script.split(|c: char| c.is_whitespace() || matches!(c, '&' | '|' | ';')).collect();
|
||||
if tokens.windows(2).any(|w| w[0] == "playwright" && w[1] == "test") {
|
||||
return Some("playwright");
|
||||
}
|
||||
if tokens.iter().any(|t| matches!(t.rsplit('/').next(), Some("mocha" | "_mocha"))) {
|
||||
return Some("mocha");
|
||||
}
|
||||
let node = tokens.iter().position(|t| matches!(*t, "node" | "tsx"))?;
|
||||
// Node's own options: up to the script (`node server.js --test` passes `--test` to the program).
|
||||
let mut options = Vec::new();
|
||||
|
||||
@@ -92,6 +92,20 @@ fn node_test_scripts() {
|
||||
assert_eq!(find(&c, "npm:start").extras.test_runner, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mocha_scripts() {
|
||||
let dir = project(&[(
|
||||
"package.json",
|
||||
r#"{"scripts":{"spec":"mocha --recursive","test":"nyc ./node_modules/.bin/mocha","lint":"eslint mocha.config.js"}}"#,
|
||||
)]);
|
||||
let c = detect(dir.path());
|
||||
let spec = find(&c, "npm:spec");
|
||||
assert!(spec.is_test);
|
||||
assert_eq!(spec.extras.test_runner.as_deref(), Some("mocha"));
|
||||
assert_eq!(find(&c, "npm:test").extras.test_runner.as_deref(), Some("mocha"));
|
||||
assert!(!find(&c, "npm:lint").is_test);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn package_manager_selection() {
|
||||
for (lock, pm) in [("yarn.lock", "yarn"), ("bun.lockb", "bun"), ("bun.lock", "bun"), ("package-lock.json", "npm")] {
|
||||
|
||||
@@ -6,6 +6,7 @@ edition.workspace = true
|
||||
license.workspace = true
|
||||
|
||||
[dependencies]
|
||||
dirs.workspace = true
|
||||
dunce.workspace = true
|
||||
ignore.workspace = true
|
||||
ide-core.workspace = true
|
||||
|
||||
@@ -537,6 +537,42 @@ pub fn configure_gradle_runtime(cfg: &mut LanguageServerConfig, root: &Path, bui
|
||||
merge(cfg.settings.get_or_insert_with(|| json!({})), json!({"java": {"import": {"gradle": gradle}}}));
|
||||
}
|
||||
|
||||
/// Gradle's Eclipse model, which jdtls imports the build through, leaves out project dependencies
|
||||
/// a source set only compiles against (`compileOnly(project(":a"))`) and marks some as test-only,
|
||||
/// so their classes don't resolve in the editor although Gradle compiles. jdtls's Gradle import
|
||||
/// runs an init script that adds them, written to the first of `dirs` whose path has no
|
||||
/// whitespace: Buildship stores the import's arguments joined by spaces and splits them again,
|
||||
/// so `Application Support` would break the path. The name carries the script's hash, so
|
||||
/// releases running side by side never overwrite each other's script.
|
||||
pub fn configure_gradle_classpath(cfg: &mut LanguageServerConfig, dirs: &[PathBuf]) {
|
||||
const SCRIPT: &str = include_str!("gradle-classpath.init.gradle");
|
||||
if cfg.name != "jdtls" {
|
||||
return;
|
||||
}
|
||||
let mut hash = 0xcbf29ce484222325u64;
|
||||
for byte in SCRIPT.bytes() {
|
||||
hash = (hash ^ u64::from(byte)).wrapping_mul(0x100000001b3);
|
||||
}
|
||||
let name = format!("openidea-classpath-{hash:016x}.init.gradle");
|
||||
let Some(script) = dirs
|
||||
.iter()
|
||||
.map(|dir| dir.join(&name))
|
||||
.filter(|script| !script.to_string_lossy().contains(char::is_whitespace))
|
||||
.find(|script| {
|
||||
std::fs::read(script).ok().as_deref() == Some(SCRIPT.as_bytes())
|
||||
|| script.parent().is_some_and(|dir| std::fs::create_dir_all(dir).is_ok())
|
||||
&& std::fs::write(script, SCRIPT).is_ok()
|
||||
})
|
||||
else {
|
||||
tracing::warn!("no directory without spaces for the Gradle classpath init script: {dirs:?}");
|
||||
return;
|
||||
};
|
||||
merge(
|
||||
cfg.settings.get_or_insert_with(|| json!({})),
|
||||
json!({"java": {"import": {"gradle": {"arguments": ["--init-script", script.to_string_lossy()]}}}}),
|
||||
);
|
||||
}
|
||||
|
||||
/// Settings › Build Tools › Maven › Automatically download sources and Always update
|
||||
/// snapshots → jdtls `java.maven.downloadSources` / `java.maven.updateSnapshots`.
|
||||
pub fn configure_maven_sources(cfg: &mut LanguageServerConfig, s: &Settings) {
|
||||
@@ -1424,6 +1460,14 @@ pub fn configure_server(cfg: &mut LanguageServerConfig, root: &Path, server_root
|
||||
if name == astro::SERVER {
|
||||
astro::configure(cfg, root, server_root, s);
|
||||
}
|
||||
// Biome lints with the project's own version (its configuration follows that version's
|
||||
// schema); an explicit executable setting still wins.
|
||||
if name == "biome"
|
||||
&& cfg.command == "biome"
|
||||
&& let Some(bin) = crate::npm::project_bin("biome", root, server_root)
|
||||
{
|
||||
cfg.command = bin.to_string_lossy().into_owned();
|
||||
}
|
||||
if name == crate::arduino::SERVER {
|
||||
crate::arduino::configure(cfg, root, server_root, s);
|
||||
}
|
||||
@@ -2521,6 +2565,33 @@ mod maven_linkage_tests {
|
||||
assert_eq!(gradle["user"]["home"], resolved("/caches/gradle"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gradle_import_adds_the_projects_a_source_set_compiles_against() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
let spaced = temp.path().join("Application Support").join("gradle");
|
||||
let plain = temp.path().join("cache").join("gradle");
|
||||
let mut cfg = custom_server("jdtls", &LanguageServerSettings::default());
|
||||
cfg.settings = Some(json!({"java": {"import": {"gradle": {"enabled": true}}}}));
|
||||
configure_gradle_classpath(&mut cfg, &[spaced.clone(), plain.clone()]);
|
||||
let gradle = &cfg.settings.as_ref().unwrap()["java"]["import"]["gradle"];
|
||||
assert_eq!(gradle["enabled"], json!(true), "merged, not replaced");
|
||||
let args = gradle["arguments"].as_array().unwrap();
|
||||
assert_eq!(args[0], json!("--init-script"));
|
||||
let script = PathBuf::from(args[1].as_str().unwrap());
|
||||
assert_eq!(script.parent(), Some(plain.as_path()), "Buildship splits arguments at spaces");
|
||||
assert!(!spaced.exists());
|
||||
let text = std::fs::read_to_string(&script).unwrap();
|
||||
assert!(text.contains("compileClasspath") && text.contains("whenMerged"));
|
||||
|
||||
let mut other = custom_server("pyright", &LanguageServerSettings::default());
|
||||
configure_gradle_classpath(&mut other, &[plain]);
|
||||
assert!(other.settings.is_none(), "only jdtls imports Gradle builds");
|
||||
|
||||
let mut nowhere = custom_server("jdtls", &LanguageServerSettings::default());
|
||||
configure_gradle_classpath(&mut nowhere, &[spaced]);
|
||||
assert!(nowhere.settings.is_none(), "no usable directory: the import runs without it");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gradle_import_of_a_gradle_build_runs_on_the_project_jdk_like_the_ides_builds() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
@@ -2743,3 +2814,42 @@ mod conda_activation_tests {
|
||||
assert_eq!(conda_activation(&plain.join("bin").join("python"), "bash", Some(conda), None), None);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod biome_tests {
|
||||
use super::*;
|
||||
|
||||
fn binary(dir: &Path) -> PathBuf {
|
||||
let bin = dir.join(if cfg!(windows) { "biome.cmd" } else { "biome" });
|
||||
std::fs::create_dir_all(dir).unwrap();
|
||||
std::fs::write(&bin, "").unwrap();
|
||||
#[cfg(unix)]
|
||||
std::fs::set_permissions(&bin, std::os::unix::fs::PermissionsExt::from_mode(0o755)).unwrap();
|
||||
bin
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn biome_runs_the_projects_own_biome_unless_an_executable_is_set() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let root = tmp.path().join("project");
|
||||
let web = root.join("apps/web");
|
||||
let configured = |s: &Settings, server_root: &Path| {
|
||||
let mut cfg = custom_server("biome", &LanguageServerSettings::default());
|
||||
cfg.command = "biome".into();
|
||||
configure_server(&mut cfg, &root, server_root, s);
|
||||
PathBuf::from(cfg.command)
|
||||
};
|
||||
let workspace = binary(&root.join("node_modules/.bin"));
|
||||
assert_eq!(configured(&Settings::default(), &web), workspace);
|
||||
let member = binary(&web.join("node_modules/.bin"));
|
||||
assert_eq!(configured(&Settings::default(), &web), member);
|
||||
// Outside the project: not the project's installation.
|
||||
binary(&tmp.path().join("node_modules/.bin"));
|
||||
assert_eq!(configured(&Settings::default(), &tmp.path().join("other")), PathBuf::from("biome"));
|
||||
let custom = binary(&tmp.path().join("custom"));
|
||||
let mut s = Settings::default();
|
||||
s.tools
|
||||
.insert("biome".into(), ide_core::settings::ToolSettings { path: custom.to_string_lossy().into_owned() });
|
||||
assert_eq!(configured(&s, &web), custom);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Astro (Volar) requires a TypeScript language-service library at initialize.
|
||||
|
||||
use crate::apply::{merge_init_options, setting_path, tsdk};
|
||||
use crate::npm::{has_ts_api, own_typescript, package_dir};
|
||||
use crate::npm::{has_ts_api, own_typescript, package_dir, project_bin};
|
||||
use ide_core::settings::Settings;
|
||||
use ide_core::tool_path::{find_command, search_path};
|
||||
use ide_language::LanguageServerConfig;
|
||||
@@ -20,10 +20,7 @@ pub(crate) fn configure(cfg: &mut LanguageServerConfig, root: &Path, server_root
|
||||
// A project's installation wins over managed / global tools. Explicit
|
||||
// executable settings still win, as they do for other language servers.
|
||||
if cfg.command == SERVER
|
||||
&& let Some(bin) = server_root
|
||||
.ancestors()
|
||||
.take_while(|dir| dir.starts_with(root))
|
||||
.find_map(|dir| find_command(SERVER, dir.join("node_modules/.bin").as_os_str(), server_root))
|
||||
&& let Some(bin) = project_bin(SERVER, root, server_root)
|
||||
{
|
||||
cfg.command = bin.to_string_lossy().into_owned();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
// Gradle's Eclipse model leaves out project dependencies a source set only compiles against
|
||||
// (compileOnly, compileOnlyApi), and marks some as test-only. Add each project the main or test
|
||||
// compile classpath names, so Java code sees the classes it compiles against.
|
||||
allprojects {
|
||||
plugins.withId('java') {
|
||||
apply plugin: 'eclipse'
|
||||
eclipse.classpath.file.whenMerged { classpath ->
|
||||
def projectOf = { dep ->
|
||||
def path
|
||||
try { path = dep.path } catch (MissingPropertyException ignored) { path = dep.dependencyProject.path }
|
||||
rootProject.findProject(path)
|
||||
}
|
||||
def wanted = [:]
|
||||
['testCompileClasspath', 'compileClasspath'].each { name ->
|
||||
def configuration = configurations.findByName(name)
|
||||
if (configuration == null) return
|
||||
configuration.allDependencies.withType(ProjectDependency).each { dep ->
|
||||
def target = projectOf(dep)
|
||||
if (target == null || target == project) return
|
||||
def eclipseName = target.extensions.findByName('eclipse')?.project?.name ?: target.name
|
||||
wanted['/' + eclipseName] = name == 'compileClasspath'
|
||||
}
|
||||
}
|
||||
def existing = classpath.entries.findAll { it instanceof org.gradle.plugins.ide.eclipse.model.ProjectDependency }
|
||||
wanted.each { path, main ->
|
||||
def entry = existing.find { it.path == path }
|
||||
if (entry == null) {
|
||||
entry = new org.gradle.plugins.ide.eclipse.model.ProjectDependency(path)
|
||||
entry.entryAttributes['without_test_code'] = 'true'
|
||||
classpath.entries.add(entry)
|
||||
}
|
||||
if (main) entry.entryAttributes.remove('test')
|
||||
else if (!entry.entryAttributes.containsKey('test')) entry.entryAttributes['test'] = 'true'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -287,8 +287,8 @@ pub fn launch_directly(cfg: &mut LanguageServerConfig) {
|
||||
return;
|
||||
}
|
||||
let Some(script) = script_for(cfg) else { return };
|
||||
let Some(install) =
|
||||
jdtls_home(&script).and_then(|h| find_install(&h, std::env::consts::OS, std::env::consts::ARCH))
|
||||
let home = jdtls_home(&script);
|
||||
let Some(install) = home.as_deref().and_then(|h| find_install(h, std::env::consts::OS, std::env::consts::ARCH))
|
||||
else {
|
||||
return;
|
||||
};
|
||||
@@ -307,14 +307,60 @@ pub fn launch_directly(cfg: &mut LanguageServerConfig) {
|
||||
cfg.launch_error = Some(error);
|
||||
return;
|
||||
}
|
||||
let area = home.as_deref().and_then(|home| configuration_area(home, &cfg.args, dirs::cache_dir()));
|
||||
cfg.args = java_args(&install, jdk.major, &cfg.args);
|
||||
if let Some(area) = area
|
||||
&& let Some(jar) = cfg.args.iter().position(|a| a == "-jar")
|
||||
{
|
||||
cfg.args.insert(jar, format!("-Dosgi.configuration.area={}", area.to_string_lossy()));
|
||||
}
|
||||
cfg.command = java.to_string_lossy().into_owned();
|
||||
}
|
||||
|
||||
/// Equinox extracts bundle files, jdtls's Gradle init scripts among them, into its writable
|
||||
/// configuration area, `<home>/configuration` unless the launch names one. jdtls passes those
|
||||
/// scripts to every Gradle import as `--init-script` arguments, and Buildship stores a build's
|
||||
/// arguments joined by spaces and splits them again. Under a home with spaces (macOS's
|
||||
/// `Application Support`) each import that sets a Gradle JDK, user home or argument then fails
|
||||
/// with "The specified initialization script '…/Application' does not exist". Such a home
|
||||
/// gets an area without spaces in the user's cache directory, one per install.
|
||||
fn configuration_area(home: &Path, args: &[String], cache: Option<PathBuf>) -> Option<PathBuf> {
|
||||
let parsed = split_script_args(args);
|
||||
let named = parsed.jvm.iter().any(|a| a.starts_with("-Dosgi.configuration.area="))
|
||||
|| parsed.rest.iter().any(|a| a == "-configuration");
|
||||
if named || !home.join("configuration").to_string_lossy().contains(char::is_whitespace) {
|
||||
return None;
|
||||
}
|
||||
let mut hash = 0xcbf29ce484222325u64;
|
||||
for byte in home.to_string_lossy().bytes() {
|
||||
hash = (hash ^ u64::from(byte)).wrapping_mul(0x100000001b3);
|
||||
}
|
||||
Some(cache?.join("openidea").join("jdtls-configuration").join(format!("{hash:016x}")))
|
||||
.filter(|area| !area.to_string_lossy().contains(char::is_whitespace))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn a_home_with_spaces_gets_a_configuration_area_without_them() {
|
||||
let cache = Some(PathBuf::from("/cache"));
|
||||
let spaced = Path::new("/Users/me/Library/Application Support/openidea/tools/jdtls");
|
||||
let area = configuration_area(spaced, &[], cache.clone()).unwrap();
|
||||
assert!(area.starts_with("/cache/openidea/jdtls-configuration"));
|
||||
assert_eq!(configuration_area(spaced, &[], cache.clone()), Some(area), "one per install");
|
||||
assert_ne!(
|
||||
configuration_area(Path::new("/opt/My Tools/jdtls"), &[], cache.clone()),
|
||||
configuration_area(spaced, &[], cache.clone())
|
||||
);
|
||||
assert_eq!(configuration_area(Path::new("/opt/jdtls"), &[], cache.clone()), None, "the default is fine");
|
||||
let own = strings(&["--jvm-arg=-Dosgi.configuration.area=/mine"]);
|
||||
assert_eq!(configuration_area(spaced, &own, cache.clone()), None, "the user's area stays");
|
||||
assert_eq!(configuration_area(spaced, &strings(&["-configuration", "/mine"]), cache), None);
|
||||
assert_eq!(configuration_area(spaced, &[], Some(PathBuf::from("/My Cache"))), None);
|
||||
}
|
||||
|
||||
fn strings(args: &[&str]) -> Vec<String> {
|
||||
args.iter().map(|s| s.to_string()).collect()
|
||||
}
|
||||
|
||||
@@ -10,6 +10,13 @@ pub(crate) fn has_ts_api(lib: &Path) -> bool {
|
||||
lib.join("typescript.js").is_file()
|
||||
}
|
||||
|
||||
/// `command` installed in the project: the nearest `node_modules/.bin` from `server_root` up to `root`.
|
||||
pub(crate) fn project_bin(command: &str, root: &Path, server_root: &Path) -> Option<PathBuf> {
|
||||
server_root.ancestors().take_while(|dir| dir.starts_with(root)).find_map(|dir| {
|
||||
ide_core::tool_path::find_command(command, dir.join("node_modules/.bin").as_os_str(), server_root)
|
||||
})
|
||||
}
|
||||
|
||||
/// The native executable of TypeScript 7 (`typescript` 7+, whose `tsc` is native, or
|
||||
/// `@typescript/native-preview`'s `tsgo`), from its package directory or its `lib`.
|
||||
/// These packages have no JavaScript API (`lib/typescript.js`); their platform package
|
||||
|
||||
@@ -62,13 +62,22 @@ fn package_bin(package: &Path, tool: &str) -> IdeResult<PathBuf> {
|
||||
Ok(path)
|
||||
}
|
||||
|
||||
/// Prettier and Ruff format ranges for some languages (`config.range`); oxfmt formats whole files only.
|
||||
/// Prettier and Ruff format ranges for some languages (`config.range`); oxfmt and Biome format whole files only.
|
||||
pub fn supports_range(tool: &str, config: &FormatterConfig) -> bool {
|
||||
matches!(tool, "prettier" | "ruff") && config.range
|
||||
}
|
||||
|
||||
fn is_formatter(tool: &str) -> bool {
|
||||
crate::registry::find(tool).is_some_and(|t| t.kind == crate::ToolKind::Formatter || t.name == "ruff")
|
||||
crate::registry::find(tool)
|
||||
.is_some_and(|t| t.kind == crate::ToolKind::Formatter || matches!(t.name, "ruff" | "biome"))
|
||||
}
|
||||
|
||||
/// The npm package that provides `tool`'s CLI.
|
||||
fn npm_package(tool: &str) -> &str {
|
||||
match tool {
|
||||
"biome" => "@biomejs/biome",
|
||||
_ => tool,
|
||||
}
|
||||
}
|
||||
|
||||
impl Tools {
|
||||
@@ -81,7 +90,7 @@ impl Tools {
|
||||
if !is_formatter(tool) {
|
||||
return Err(IdeError::unavailable(format!("Unknown external formatter: {tool}")));
|
||||
}
|
||||
let package = Path::new("node_modules").join(tool);
|
||||
let package = Path::new("node_modules").join(npm_package(tool));
|
||||
let manifest = package.join("package.json");
|
||||
let (path, node) = if let Some(custom) = custom.filter(|p| p.is_dir()) {
|
||||
(package_bin(custom, tool)?, true)
|
||||
@@ -108,7 +117,7 @@ impl Tools {
|
||||
}
|
||||
|
||||
/// Every tool resolves its configuration itself. Prettier's project configuration
|
||||
/// overrides the editor indentation passed here; oxfmt and Ruff read their own
|
||||
/// overrides the editor indentation passed here; oxfmt, Biome and Ruff read their own
|
||||
/// configuration files. Ruff also discovers the nearest `pyproject.toml`,
|
||||
/// `ruff.toml`, or `.ruff.toml` from the stdin filename.
|
||||
pub fn arguments(
|
||||
@@ -137,6 +146,12 @@ pub fn arguments(
|
||||
}
|
||||
return args;
|
||||
}
|
||||
if tool == "biome" {
|
||||
// Biome finds its `biome.json` and ignore files from the file's path itself.
|
||||
let mut path = OsString::from("--stdin-file-path=");
|
||||
path.push(file);
|
||||
return vec!["format".into(), path];
|
||||
}
|
||||
if tool == "prettier" {
|
||||
let parser = if config.parser == "markdown" && file.extension().is_some_and(|s| s == "mdx") {
|
||||
"mdx"
|
||||
@@ -323,6 +338,38 @@ mod tests {
|
||||
assert!(unknown.message.contains("Unknown external formatter"), "{}", unknown.message);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn biome_runs_the_nearest_biomejs_package_with_the_file_path() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let root = dir.path();
|
||||
let package = root.join("node_modules/@biomejs/biome");
|
||||
std::fs::create_dir_all(package.join("bin")).unwrap();
|
||||
std::fs::write(package.join("package.json"), r#"{"bin":{"biome":"bin/biome"}}"#).unwrap();
|
||||
std::fs::write(package.join("bin/biome"), "").unwrap();
|
||||
std::fs::write(root.join(".prettierignore"), "dist").unwrap();
|
||||
let file = root.join("packages/web/src/app.ts");
|
||||
let path = std::env::var_os("PATH").unwrap_or_default();
|
||||
let tools = Tools::with_paths(root.join("tools"), path, crate::platform::Platform::current());
|
||||
|
||||
let command = tools.formatter_command("biome", &file, None).unwrap();
|
||||
let program = Path::new(command.get_program()).file_stem().unwrap().to_string_lossy().into_owned();
|
||||
assert_eq!(program, "node");
|
||||
let script: Vec<_> = command.get_args().collect();
|
||||
assert_eq!(
|
||||
Path::new(&script[0]).components().collect::<Vec<_>>(),
|
||||
package.join("bin/biome").components().collect::<Vec<_>>()
|
||||
);
|
||||
|
||||
let config = FormatterConfig { tool: "prettier".into(), parser: "typescript".into(), range: true };
|
||||
let range =
|
||||
Some(FormatRange { start_offset: 3, end_offset: 9, start_line: 1, start_col: 1, end_line: 1, end_col: 7 });
|
||||
let mut stdin_path = OsString::from("--stdin-file-path=");
|
||||
stdin_path.push(&file);
|
||||
// No Prettier ignore files or indentation: Biome reads its own configuration.
|
||||
assert_eq!(arguments("biome", &config, &file, 4, false, range, None), ["format".into(), stdin_path]);
|
||||
assert!(!supports_range("biome", &config));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ruff_formats_stdin_and_uses_its_config_and_range_flags() {
|
||||
let config = FormatterConfig { tool: "ruff".into(), parser: "python".into(), range: true };
|
||||
|
||||
@@ -201,6 +201,18 @@ pub static TOOLS: &[ToolSpec] = &[
|
||||
needs: NODE,
|
||||
homepage: "https://oxc.rs/docs/guide/usage/linter",
|
||||
},
|
||||
// Linter and formatter: `biome lsp-proxy` lints, and Reformat Code runs `biome format`.
|
||||
ToolSpec {
|
||||
name: "biome",
|
||||
display: "Biome",
|
||||
kind: LanguageServer,
|
||||
commands: &["biome"],
|
||||
method: Method::Npm { packages: &["@biomejs/biome"] },
|
||||
fallback: None,
|
||||
version: ver("biome"),
|
||||
needs: NODE,
|
||||
homepage: "https://biomejs.dev",
|
||||
},
|
||||
ToolSpec {
|
||||
name: "eslint",
|
||||
display: "ESLint Language Server",
|
||||
@@ -444,6 +456,18 @@ pub static TOOLS: &[ToolSpec] = &[
|
||||
homepage: "https://angular.dev/tools/language-service",
|
||||
needs: &[],
|
||||
},
|
||||
ToolSpec {
|
||||
name: "tailwindcss-language-server",
|
||||
display: "Tailwind CSS Language Server",
|
||||
kind: LanguageServer,
|
||||
commands: &["tailwindcss-language-server"],
|
||||
// Brings Tailwind CSS 3 and 4 for projects whose own `tailwindcss` isn't installed yet.
|
||||
method: Method::Npm { packages: &["@tailwindcss/language-server"] },
|
||||
fallback: None,
|
||||
version: V,
|
||||
homepage: "https://github.com/tailwindlabs/tailwindcss-intellisense",
|
||||
needs: NODE,
|
||||
},
|
||||
ToolSpec {
|
||||
name: "graphql-lsp",
|
||||
display: "GraphQL Language Server",
|
||||
@@ -1286,7 +1310,7 @@ mod tests {
|
||||
known.insert((d.adapter.clone(), d.command.clone()));
|
||||
}
|
||||
}
|
||||
// The host selects the formatter of each file (Prettier or oxfmt) and runs its own CLIs.
|
||||
// The host selects the formatter of each file (Prettier, oxfmt or Biome) and runs its own CLIs.
|
||||
for t in TOOLS.iter().filter(|t| !matches!(t.kind, Plugin | Formatter | Cli)) {
|
||||
assert!(
|
||||
known.contains(&(t.name.to_string(), t.commands[0].to_string())),
|
||||
|
||||
@@ -67,7 +67,7 @@ mise run dev
|
||||
|
||||
`setup` runs `pnpm install` in this worktree. `dev` and `dev:app` use the same worktree-aware launchers as the direct commands. No shell activation is needed for `mise run`.
|
||||
|
||||
Run `mise tasks` to list all tasks. `mise run build` builds the frontend (not a desktop installer); `mise run dogfood:build` and `mise run dogfood:install` build and locally install a grey-icon dogfood desktop app that shares settings and data with the release app. Only one of the two apps runs at a time, since they share one instance; settings written by the newer dogfood build can make an older release ignore the settings file. The dogfood app never updates itself: run `dogfood:install` again to pick up new changes. `mise run test` runs Vitest and `cargo test --workspace`; `mise run check` runs the format, lint, type and unused-code checks, then both test suites. Neither requires nextest or the plugin WASM target.
|
||||
Run `mise tasks` to list all tasks. `mise run build` builds the frontend (not a desktop installer); `mise run dogfood:build` and `mise run dogfood:install` build and locally install a grey-icon dogfood desktop app that shares settings and data with the release app. Only one of the two apps runs at a time, since they share one instance; settings written by the newer dogfood build can make an older release ignore the settings file. The dogfood app never updates itself: run `dogfood:install` again to pick up new changes. `mise run dogfood:remote <remote_name>` builds and stages `openidea-server` on an SSH host configured in **Tools › SSH Configurations** (`--clean` removes the override). `mise run test` runs Vitest and `cargo test --workspace`; `mise run check` runs the format, lint, type and unused-code checks, then both test suites. Neither requires nextest or the plugin WASM target.
|
||||
|
||||
## Worktrees
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ All folding commands are also in **Code › Folding**. Fold regions come from th
|
||||
| **Auto-Indent Lines** | `⌃⌥I` | `Ctrl+Alt+I` |
|
||||
| **Optimize Imports** | `⌃⌥O` | `Ctrl+Alt+O` |
|
||||
|
||||
**Reformat Code** formats the selection, or the whole file when nothing is selected, as one undo step. The formatting comes from the file's language server or from the formatter the language is configured with (for example Ruff for Python, Prettier or oxfmt for web languages; find their commands as **Reformat with …** in Find Action). **Reformat File…** also lets you choose the scope and optimize imports.
|
||||
**Reformat Code** formats the selection, or the whole file when nothing is selected, as one undo step. The formatting comes from the file's language server or from the formatter the language is configured with (for example Ruff for Python, Prettier, oxfmt or Biome for web languages; find their commands as **Reformat with …** in Find Action). **Reformat File…** also lets you choose the scope and optimize imports.
|
||||
|
||||
Indentation and other style options are under **Settings › Editor › Code Style**, with a page per language. `.editorconfig` files in the project are read too.
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ Detected test configurations show results in the tree automatically. For your ow
|
||||
| **Rerun** (in the Run tool window) | `⌘R` | `Ctrl+F5` |
|
||||
| **Rerun Failed Tests** | — | — |
|
||||
|
||||
**Rerun Failed Tests** (in the Run tool window toolbar and Find Action) runs only the tests that failed in the last run, using each tool's filter syntax. It works for Cargo, Jest / Vitest, Playwright, `node --test`, pytest, Django, PHPUnit, Go, Maven / Gradle and .NET runs, and for plugin test frameworks.
|
||||
**Rerun Failed Tests** (in the Run tool window toolbar and Find Action) runs only the tests that failed in the last run, using each tool's filter syntax. It works for Cargo, Jest / Vitest, Playwright, `node --test`, Mocha, pytest, Django, PHPUnit, Go, Maven / Gradle and .NET runs, and for plugin test frameworks.
|
||||
|
||||
## Navigate between code and tests
|
||||
|
||||
|
||||
+87
-87
@@ -34,7 +34,7 @@ For a recognized file, support comes in layers:
|
||||
A language can list more than one server:
|
||||
|
||||
- **Alternatives** (shown as `a → b` in the table below): only the first one that is installed runs. Python, for example, uses basedpyright, and falls back to pyright, ty or pyrefly only when basedpyright is missing. In **Settings › Languages & Frameworks › Language Servers** you can pick one of them or set the choice to **Automatic** (the first one available).
|
||||
- **Additions** (shown as `+ b`): run next to the main server, usually only in projects that use them. Ruff joins basedpyright in projects with a Ruff configuration; oxlint joins vtsls in projects with an oxlint configuration; the Angular and Laravel servers join in Angular and Laravel projects.
|
||||
- **Additions** (shown as `+ b`): run next to the main server, usually only in projects that use them. Ruff joins basedpyright in projects with a Ruff configuration; oxlint joins vtsls in projects with an oxlint configuration; Biome joins the JavaScript, TypeScript, JSON, CSS and GraphQL servers in projects with a Biome configuration or installation; the Angular, Laravel and Tailwind CSS servers join in Angular, Laravel and Tailwind CSS projects.
|
||||
|
||||
## Installing language servers and debuggers
|
||||
|
||||
@@ -91,92 +91,92 @@ Selecting a language server on the Language Servers page shows its settings, whi
|
||||
|
||||
The table lists every built-in language definition. Server and debugger names in **bold** can be installed from the IDE; the others you install yourself (the install hint in the IDE says how). "Highlighting" and "Tree-sitter" mark instant highlighting and the bundled grammar for outline and folding.
|
||||
|
||||
| Language | ID | Files | Highlighting | Tree-sitter | Language servers | Debugger |
|
||||
| ------------------- | ------------------ | ----------------------------------------------------------- | ------------ | ----------- | ------------------------------------------------------------------------------------- | ------------------------ |
|
||||
| .env | `dotenv` | `.env` | Yes | — | — | — |
|
||||
| Arduino | `arduino` | `.ino` | Yes | Yes | arduino-language-server | — |
|
||||
| AsciiDoc | `asciidoc` | `.adoc`, `.asciidoc` | Yes | — | — | — |
|
||||
| Astro | `astro` | `.astro` | Yes | — | **astro-ls** + **oxlint** | — |
|
||||
| Batch | `bat` | `.bat`, `.cmd` | Yes | — | — | — |
|
||||
| C | `c` | `.c`, `.h` | Yes | Yes | **clangd** | lldb-dap |
|
||||
| C# | `csharp` | `.cs`, `.csx` | Yes | Yes | **csharp-ls** | **netcoredbg** |
|
||||
| C++ | `cpp` | `.cpp`, `.cc`, `.cxx`, `.c++`, `.hpp`, … | Yes | Yes | **clangd** | lldb-dap |
|
||||
| Clojure | `clojure` | `.clj`, `.cljs`, `.cljc`, `.cljd`, `.edn`, … | Yes | — | **clojure-lsp** | — |
|
||||
| CMake | `cmake` | `.cmake` | Yes | Yes | **neocmakelsp** → cmake-language-server | — |
|
||||
| CSS | `css` | `.css`, `.pcss`, `.postcss` | Yes | Yes | **vscode-css-language-server** | — |
|
||||
| D | `d` | `.d`, `.di` | Yes | — | serve-d | — |
|
||||
| Dart | `dart` | `.dart` | Yes | Yes | dart | dart |
|
||||
| Diff | `diff` | `.diff`, `.patch`, `.rej` | Yes | — | — | — |
|
||||
| Django Template | `django-html` | `.djhtml`, `templates/*.html`, `*.txt` | Yes | Yes | **vscode-html-language-server**, **djlsp** | — |
|
||||
| Dockerfile | `dockerfile` | `.dockerfile`, `.containerfile` | Yes | — | **dockerfile-language-server** | — |
|
||||
| Elixir | `elixir` | `.ex`, `.exs` | Yes | Yes | **elixir-ls** | **elixir-ls-debugger** |
|
||||
| ERB | `erb` | `.erb`, `.html.erb`, `.rhtml`, `.js.erb`, `.text.erb`, … | Yes | — | — | — |
|
||||
| Erlang | `erlang` | `.erl`, `.hrl`, `.escript`, `.app.src` | Yes | — | elp | — |
|
||||
| F# | `fsharp` | `.fs`, `.fsi`, `.fsx` | Yes | — | **fsautocomplete** | **netcoredbg** |
|
||||
| GDScript | `gdscript` | `.gd` | Yes | Yes | godot | godot |
|
||||
| Git Attributes | `gitattributes` | `.gitattributes` | — | — | — | — |
|
||||
| Go | `go` | `.go` | Yes | Yes | **gopls** | **delve** |
|
||||
| Go Module | `go.mod` | `go.mod` | Yes | — | **gopls** | — |
|
||||
| Go Workspace | `go.work` | `go.work` | Yes | — | **gopls** | — |
|
||||
| Godot Resource | `godot-resource` | `.tscn`, `.tres`, `.godot`, `.import` | Yes | — | — | — |
|
||||
| Godot Shader | `gdshader` | `.gdshader`, `.gdshaderinc` | Yes | — | — | — |
|
||||
| GraphQL | `graphql` | `.graphql`, `.graphqls`, `.gql` | Yes | Yes | **graphql-lsp** | — |
|
||||
| Groovy | `groovy` | `.groovy`, `.gradle`, `.gvy`, `.gy`, `.gsh` | Yes | — | groovy-language-server | — |
|
||||
| Haskell | `haskell` | `.hs`, `.hs-boot`, `.hsig` | Yes | Yes | haskell-language-server | — |
|
||||
| HCL | `hcl` | `.hcl`, `.nomad`, `.pkr.hcl` | Yes | Yes | — | — |
|
||||
| HTML | `html` | `.html`, `.htm`, `.xhtml`, `.shtml`, `.html.tmpl` | Yes | Yes | **vscode-html-language-server** + **angular-language-server** | — |
|
||||
| HTTP Request | `http` | `.http`, `.rest` | Yes | — | — | — |
|
||||
| Ignore File | `ignore` | `.gitignore`, `.dockerignore` | — | — | — | — |
|
||||
| INI | `ini` | `.ini`, `.cfg`, `.conf`, `.cnf`, `.inf`, … | Yes | — | — | — |
|
||||
| Java | `java` | `.java` | Yes | Yes | **jdtls** → **java-analyzer** → **kmp-lsp** | **java-debug** |
|
||||
| JavaScript | `javascript` | `.js`, `.mjs`, `.cjs` | Yes | Yes | **vtsls** → **typescript-language-server** + **oxlint** | **js-debug** |
|
||||
| JavaScript JSX | `javascriptreact` | `.jsx` | Yes | Yes | **vtsls** → **typescript-language-server** + **oxlint** | **js-debug** |
|
||||
| JSON | `json` | `.json`, `.geojson`, `.topojson`, `.webmanifest`, `.har`, … | Yes | Yes | **vscode-json-language-server** | — |
|
||||
| JSON with Comments | `jsonc` | `.jsonc`, `.code-workspace`, `.code-snippets` | Yes | Yes | **vscode-json-language-server** | — |
|
||||
| JSP | `jsp` | `.jsp`, `.jspx`, `.jspf`, `.jsph`, `.tag`, … | Yes | — | — | — |
|
||||
| Julia | `julia` | `.jl` | Yes | — | julia-languageserver | — |
|
||||
| Kotlin | `kotlin` | `.kt`, `.kts` | Yes | Yes | **kotlin-lsp** → **kotlin-language-server** → **kmp-lsp** | **kotlin-debug-adapter** |
|
||||
| LaTeX | `latex` | `.tex`, `.ltx`, `.sty`, `.cls`, `.dtx`, … | Yes | — | **texlab** | — |
|
||||
| Less | `less` | `.less` | Yes | — | **vscode-css-language-server** | — |
|
||||
| Log | `log` | `.log` | Yes | — | — | — |
|
||||
| Lua | `lua` | `.lua`, `.luau`, `.rockspec` | Yes | Yes | **lua-language-server** | — |
|
||||
| Makefile | `makefile` | `.mk`, `.mak`, `.make` | Yes | Yes | — | — |
|
||||
| Markdown | `markdown` | `.md`, `.markdown`, `.mdown`, `.mkd`, `.mkdn`, … | Yes | Yes | **marksman** | — |
|
||||
| Nix | `nix` | `.nix` | Yes | Yes | nil → nixd | — |
|
||||
| Objective-C | `objective-c` | `.m` | Yes | — | **clangd** | lldb-dap |
|
||||
| Objective-C++ | `objective-cpp` | `.mm` | Yes | — | **clangd** | lldb-dap |
|
||||
| OCaml | `ocaml` | `.ml`, `.mll`, `.mly` | Yes | Yes | ocamllsp | ocamlearlybird |
|
||||
| OCaml Interface | `ocaml.interface` | `.mli` | Yes | Yes | ocamllsp | — |
|
||||
| Perl | `perl` | `.pl`, `.pm`, `.pod`, `.psgi`, `.cgi` | Yes | — | **perlnavigator** | — |
|
||||
| PHP | `php` | `.php`, `.phtml`, `.php3`, `.php4`, `.php5`, … | Yes | Yes | **intelephense** → phpactor → **phoxite** + **laravel-lsp** | **php-debug** |
|
||||
| Plain Text | `plaintext` | `.txt`, `.text` | — | — | — | — |
|
||||
| PowerShell | `powershell` | `.ps1`, `.psm1`, `.psd1`, `.pssc`, `.psrc` | Yes | — | powershell-editor-services | — |
|
||||
| Prisma | `prisma` | `.prisma` | Yes | Yes | **prisma-language-server** | — |
|
||||
| Properties | `properties` | `.properties`, `.prefs` | Yes | — | — | — |
|
||||
| Protocol Buffers | `proto` | `.proto` | Yes | Yes | **buf** | — |
|
||||
| Python | `python` | `.py`, `.pyi`, `.pyw` | Yes | Yes | **basedpyright** → **pyright** → **ty** → **pyrefly** + **ruff** | **debugpy** |
|
||||
| R | `r` | `.r`, `.rprofile` | Yes | — | r-languageserver | — |
|
||||
| reStructuredText | `restructuredtext` | `.rst` | Yes | — | — | — |
|
||||
| Ruby | `ruby` | `.rb`, `.rake`, `.gemspec`, `.ru`, `.rbi`, … | Yes | Yes | **ruby-lsp** → **solargraph** | rdbg |
|
||||
| Rust | `rust` | `.rs` | Yes | Yes | **rust-analyzer** | **codelldb** |
|
||||
| Sass | `sass` | `.sass` | Yes | — | — | — |
|
||||
| Scala | `scala` | `.scala`, `.sc`, `.sbt`, `.mill` | Yes | Yes | metals | — |
|
||||
| SCSS | `scss` | `.scss` | Yes | — | **vscode-css-language-server** | — |
|
||||
| Shell Script | `shellscript` | `.sh`, `.bash`, `.zsh`, `.ksh`, `.ash`, … | Yes | Yes | **bash-language-server** | **bash-debug** |
|
||||
| Slint | `slint` | `.slint` | Yes | — | **slint-lsp** | — |
|
||||
| SQL | `sql` | `.sql`, `.ddl`, `.dml`, `.psql`, `.pgsql`, … | Yes | — | **sqls** | — |
|
||||
| Svelte | `svelte` | `.svelte` | Yes | — | **svelte-language-server** + **oxlint** | — |
|
||||
| Swift | `swift` | `.swift`, `.swiftinterface` | Yes | Yes | sourcekit-lsp | lldb-dap |
|
||||
| Terraform | `terraform` | `.tf`, `.tofu`, `.tftest.hcl` | Yes | Yes | **terraform-ls** | — |
|
||||
| Terraform Variables | `terraform-vars` | `.tfvars` | Yes | Yes | **terraform-ls** | — |
|
||||
| TOML | `toml` | `.toml` | Yes | Yes | **taplo** | — |
|
||||
| TypeScript | `typescript` | `.ts`, `.mts`, `.cts` | Yes | Yes | **vtsls** → **typescript-language-server** + **angular-language-server** + **oxlint** | **js-debug** |
|
||||
| TypeScript JSX | `typescriptreact` | `.tsx` | Yes | Yes | **vtsls** → **typescript-language-server** + **oxlint** | **js-debug** |
|
||||
| Typst | `typst` | `.typ` | — | — | **tinymist** | — |
|
||||
| Vue | `vue` | `.vue` | Yes | — | **vue-language-server**, **vtsls** + **oxlint** | — |
|
||||
| XML | `xml` | `.xml`, `.xsd`, `.xsl`, `.xslt`, `.svg`, … | Yes | Yes | **lemminx** | — |
|
||||
| YAML | `yaml` | `.yaml`, `.yml` | Yes | Yes | **yaml-language-server** | — |
|
||||
| Zig | `zig` | `.zig`, `.zon` | Yes | Yes | **zls** | **codelldb** |
|
||||
| Language | ID | Files | Highlighting | Tree-sitter | Language servers | Debugger |
|
||||
| ------------------- | ------------------ | ----------------------------------------------------------- | ------------ | ----------- | ------------------------------------------------------------------------------------------------- | ------------------------ |
|
||||
| .env | `dotenv` | `.env` | Yes | — | — | — |
|
||||
| Arduino | `arduino` | `.ino` | Yes | Yes | arduino-language-server | — |
|
||||
| AsciiDoc | `asciidoc` | `.adoc`, `.asciidoc` | Yes | — | — | — |
|
||||
| Astro | `astro` | `.astro` | Yes | — | **astro-ls** + **oxlint** | — |
|
||||
| Batch | `bat` | `.bat`, `.cmd` | Yes | — | — | — |
|
||||
| C | `c` | `.c`, `.h` | Yes | Yes | **clangd** | lldb-dap |
|
||||
| C# | `csharp` | `.cs`, `.csx` | Yes | Yes | **csharp-ls** | **netcoredbg** |
|
||||
| C++ | `cpp` | `.cpp`, `.cc`, `.cxx`, `.c++`, `.hpp`, … | Yes | Yes | **clangd** | lldb-dap |
|
||||
| Clojure | `clojure` | `.clj`, `.cljs`, `.cljc`, `.cljd`, `.edn`, … | Yes | — | **clojure-lsp** | — |
|
||||
| CMake | `cmake` | `.cmake` | Yes | Yes | **neocmakelsp** → cmake-language-server | — |
|
||||
| CSS | `css` | `.css`, `.pcss`, `.postcss` | Yes | Yes | **vscode-css-language-server** + **biome** | — |
|
||||
| D | `d` | `.d`, `.di` | Yes | — | serve-d | — |
|
||||
| Dart | `dart` | `.dart` | Yes | Yes | dart | dart |
|
||||
| Diff | `diff` | `.diff`, `.patch`, `.rej` | Yes | — | — | — |
|
||||
| Django Template | `django-html` | `.djhtml`, `templates/*.html`, `*.txt` | Yes | Yes | **vscode-html-language-server**, **djlsp** | — |
|
||||
| Dockerfile | `dockerfile` | `.dockerfile`, `.containerfile` | Yes | — | **dockerfile-language-server** | — |
|
||||
| Elixir | `elixir` | `.ex`, `.exs` | Yes | Yes | **elixir-ls** | **elixir-ls-debugger** |
|
||||
| ERB | `erb` | `.erb`, `.html.erb`, `.rhtml`, `.js.erb`, `.text.erb`, … | Yes | — | — | — |
|
||||
| Erlang | `erlang` | `.erl`, `.hrl`, `.escript`, `.app.src` | Yes | — | elp | — |
|
||||
| F# | `fsharp` | `.fs`, `.fsi`, `.fsx` | Yes | — | **fsautocomplete** | **netcoredbg** |
|
||||
| GDScript | `gdscript` | `.gd` | Yes | Yes | godot | godot |
|
||||
| Git Attributes | `gitattributes` | `.gitattributes` | — | — | — | — |
|
||||
| Go | `go` | `.go` | Yes | Yes | **gopls** | **delve** |
|
||||
| Go Module | `go.mod` | `go.mod` | Yes | — | **gopls** | — |
|
||||
| Go Workspace | `go.work` | `go.work` | Yes | — | **gopls** | — |
|
||||
| Godot Resource | `godot-resource` | `.tscn`, `.tres`, `.godot`, `.import` | Yes | — | — | — |
|
||||
| Godot Shader | `gdshader` | `.gdshader`, `.gdshaderinc` | Yes | — | — | — |
|
||||
| GraphQL | `graphql` | `.graphql`, `.graphqls`, `.gql` | Yes | Yes | **graphql-lsp** + **biome** | — |
|
||||
| Groovy | `groovy` | `.groovy`, `.gradle`, `.gvy`, `.gy`, `.gsh` | Yes | — | groovy-language-server | — |
|
||||
| Haskell | `haskell` | `.hs`, `.hs-boot`, `.hsig` | Yes | Yes | haskell-language-server | — |
|
||||
| HCL | `hcl` | `.hcl`, `.nomad`, `.pkr.hcl` | Yes | Yes | — | — |
|
||||
| HTML | `html` | `.html`, `.htm`, `.xhtml`, `.shtml`, `.html.tmpl` | Yes | Yes | **vscode-html-language-server** + **angular-language-server** | — |
|
||||
| HTTP Request | `http` | `.http`, `.rest` | Yes | — | — | — |
|
||||
| Ignore File | `ignore` | `.gitignore`, `.dockerignore` | — | — | — | — |
|
||||
| INI | `ini` | `.ini`, `.cfg`, `.conf`, `.cnf`, `.inf`, … | Yes | — | — | — |
|
||||
| Java | `java` | `.java` | Yes | Yes | **jdtls** → **java-analyzer** → **kmp-lsp** | **java-debug** |
|
||||
| JavaScript | `javascript` | `.js`, `.mjs`, `.cjs` | Yes | Yes | **vtsls** → **typescript-language-server** + **oxlint** + **biome** | **js-debug** |
|
||||
| JavaScript JSX | `javascriptreact` | `.jsx` | Yes | Yes | **vtsls** → **typescript-language-server** + **oxlint** + **biome** | **js-debug** |
|
||||
| JSON | `json` | `.json`, `.geojson`, `.topojson`, `.webmanifest`, `.har`, … | Yes | Yes | **vscode-json-language-server** + **biome** | — |
|
||||
| JSON with Comments | `jsonc` | `.jsonc`, `.code-workspace`, `.code-snippets` | Yes | Yes | **vscode-json-language-server** + **biome** | — |
|
||||
| JSP | `jsp` | `.jsp`, `.jspx`, `.jspf`, `.jsph`, `.tag`, … | Yes | — | — | — |
|
||||
| Julia | `julia` | `.jl` | Yes | — | julia-languageserver | — |
|
||||
| Kotlin | `kotlin` | `.kt`, `.kts` | Yes | Yes | **kotlin-lsp** → **kotlin-language-server** → **kmp-lsp** | **kotlin-debug-adapter** |
|
||||
| LaTeX | `latex` | `.tex`, `.ltx`, `.sty`, `.cls`, `.dtx`, … | Yes | — | **texlab** | — |
|
||||
| Less | `less` | `.less` | Yes | — | **vscode-css-language-server** | — |
|
||||
| Log | `log` | `.log` | Yes | — | — | — |
|
||||
| Lua | `lua` | `.lua`, `.luau`, `.rockspec` | Yes | Yes | **lua-language-server** | — |
|
||||
| Makefile | `makefile` | `.mk`, `.mak`, `.make` | Yes | Yes | — | — |
|
||||
| Markdown | `markdown` | `.md`, `.markdown`, `.mdown`, `.mkd`, `.mkdn`, … | Yes | Yes | **marksman** | — |
|
||||
| Nix | `nix` | `.nix` | Yes | Yes | nil → nixd | — |
|
||||
| Objective-C | `objective-c` | `.m` | Yes | — | **clangd** | lldb-dap |
|
||||
| Objective-C++ | `objective-cpp` | `.mm` | Yes | — | **clangd** | lldb-dap |
|
||||
| OCaml | `ocaml` | `.ml`, `.mll`, `.mly` | Yes | Yes | ocamllsp | ocamlearlybird |
|
||||
| OCaml Interface | `ocaml.interface` | `.mli` | Yes | Yes | ocamllsp | — |
|
||||
| Perl | `perl` | `.pl`, `.pm`, `.pod`, `.psgi`, `.cgi` | Yes | — | **perlnavigator** | — |
|
||||
| PHP | `php` | `.php`, `.phtml`, `.php3`, `.php4`, `.php5`, … | Yes | Yes | **intelephense** → phpactor → **phoxite** + **laravel-lsp** | **php-debug** |
|
||||
| Plain Text | `plaintext` | `.txt`, `.text` | — | — | — | — |
|
||||
| PowerShell | `powershell` | `.ps1`, `.psm1`, `.psd1`, `.pssc`, `.psrc` | Yes | — | powershell-editor-services | — |
|
||||
| Prisma | `prisma` | `.prisma` | Yes | Yes | **prisma-language-server** | — |
|
||||
| Properties | `properties` | `.properties`, `.prefs` | Yes | — | — | — |
|
||||
| Protocol Buffers | `proto` | `.proto` | Yes | Yes | **buf** | — |
|
||||
| Python | `python` | `.py`, `.pyi`, `.pyw` | Yes | Yes | **basedpyright** → **pyright** → **ty** → **pyrefly** + **ruff** | **debugpy** |
|
||||
| R | `r` | `.r`, `.rprofile` | Yes | — | r-languageserver | — |
|
||||
| reStructuredText | `restructuredtext` | `.rst` | Yes | — | — | — |
|
||||
| Ruby | `ruby` | `.rb`, `.rake`, `.gemspec`, `.ru`, `.rbi`, … | Yes | Yes | **ruby-lsp** → **solargraph** | rdbg |
|
||||
| Rust | `rust` | `.rs` | Yes | Yes | **rust-analyzer** | **codelldb** |
|
||||
| Sass | `sass` | `.sass` | Yes | — | — | — |
|
||||
| Scala | `scala` | `.scala`, `.sc`, `.sbt`, `.mill` | Yes | Yes | metals | — |
|
||||
| SCSS | `scss` | `.scss` | Yes | — | **vscode-css-language-server** | — |
|
||||
| Shell Script | `shellscript` | `.sh`, `.bash`, `.zsh`, `.ksh`, `.ash`, … | Yes | Yes | **bash-language-server** | **bash-debug** |
|
||||
| Slint | `slint` | `.slint` | Yes | — | **slint-lsp** | — |
|
||||
| SQL | `sql` | `.sql`, `.ddl`, `.dml`, `.psql`, `.pgsql`, … | Yes | — | **sqls** | — |
|
||||
| Svelte | `svelte` | `.svelte` | Yes | — | **svelte-language-server** + **oxlint** | — |
|
||||
| Swift | `swift` | `.swift`, `.swiftinterface` | Yes | Yes | sourcekit-lsp | lldb-dap |
|
||||
| Terraform | `terraform` | `.tf`, `.tofu`, `.tftest.hcl` | Yes | Yes | **terraform-ls** | — |
|
||||
| Terraform Variables | `terraform-vars` | `.tfvars` | Yes | Yes | **terraform-ls** | — |
|
||||
| TOML | `toml` | `.toml` | Yes | Yes | **taplo** | — |
|
||||
| TypeScript | `typescript` | `.ts`, `.mts`, `.cts` | Yes | Yes | **vtsls** → **typescript-language-server** + **angular-language-server** + **oxlint** + **biome** | **js-debug** |
|
||||
| TypeScript JSX | `typescriptreact` | `.tsx` | Yes | Yes | **vtsls** → **typescript-language-server** + **oxlint** + **biome** | **js-debug** |
|
||||
| Typst | `typst` | `.typ` | — | — | **tinymist** | — |
|
||||
| Vue | `vue` | `.vue` | Yes | — | **vue-language-server**, **vtsls** + **oxlint** | — |
|
||||
| XML | `xml` | `.xml`, `.xsd`, `.xsl`, `.xslt`, `.svg`, … | Yes | Yes | **lemminx** | — |
|
||||
| YAML | `yaml` | `.yaml`, `.yml` | Yes | Yes | **yaml-language-server** | — |
|
||||
| Zig | `zig` | `.zig`, `.zon` | Yes | Yes | **zls** | **codelldb** |
|
||||
|
||||
Notes:
|
||||
|
||||
|
||||
@@ -7,16 +7,18 @@ OpenIDEA edits JavaScript (`.js`, `.mjs`, `.cjs`, `.jsx`) and TypeScript (`.ts`,
|
||||
|
||||
## Language servers
|
||||
|
||||
| Files | Server | Notes |
|
||||
| ------------------------------- | ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| JS, JSX, TS, TSX | `vtsls` | Default TypeScript server. |
|
||||
| JS, JSX, TS, TSX | `typescript-language-server` | Fallback: used only while `vtsls` is not installed. |
|
||||
| `.vue` | `vue-language-server` + `vtsls` | Vue's hybrid mode: TypeScript inside `.vue` files comes from `vtsls` with `@vue/typescript-plugin`. |
|
||||
| `.svelte` | `svelte-language-server` | |
|
||||
| `.astro` | `astro-ls` | Needs Node.js and a TypeScript library. |
|
||||
| TS and HTML in Angular projects | `angular-language-server` (`ngserver`) | Only below `angular.json` or `node_modules/@angular/core`. |
|
||||
| All of the above | `oxlint` | Only below an `.oxlintrc.json`, `.oxlintrc.jsonc`, `oxlint.config.ts` or `oxlint.config.mts`. |
|
||||
| All of the above | `vscode-eslint-language-server` (ESLint) | Only below an ESLint configuration (`eslint.config.*`, `.eslintrc*` or `eslintConfig` in `package.json`); runs the project's own `eslint`. |
|
||||
| Files | Server | Notes |
|
||||
| ------------------------------- | -------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| JS, JSX, TS, TSX | `vtsls` | Default TypeScript server. |
|
||||
| JS, JSX, TS, TSX | `typescript-language-server` | Fallback: used only while `vtsls` is not installed. |
|
||||
| `.vue` | `vue-language-server` + `vtsls` | Vue's hybrid mode: TypeScript inside `.vue` files comes from `vtsls` with `@vue/typescript-plugin`. |
|
||||
| `.svelte` | `svelte-language-server` | |
|
||||
| `.astro` | `astro-ls` | Needs Node.js and a TypeScript library. |
|
||||
| TS and HTML in Angular projects | `angular-language-server` (`ngserver`) | Only below `angular.json` or `node_modules/@angular/core`. |
|
||||
| All of the above | `oxlint` | Only below an `.oxlintrc.json`, `.oxlintrc.jsonc`, `oxlint.config.ts` or `oxlint.config.mts`. |
|
||||
| All of the above | `vscode-eslint-language-server` (ESLint) | Only below an ESLint configuration (`eslint.config.*`, `.eslintrc*` or `eslintConfig` in `package.json`); runs the project's own `eslint`. |
|
||||
| JS, JSX, TS, TSX, JSON, CSS | `biome lsp-proxy` (Biome) | Only below a `biome.json` / `biome.jsonc` or an installed `@biomejs/biome`; runs the project's own `biome`. |
|
||||
| All of the above, HTML and CSS | `tailwindcss-language-server` (Tailwind CSS) | Only below a `tailwind.config.*` or a `package.json` that depends on `tailwindcss`: class completion, hover with the generated CSS, and class diagnostics. |
|
||||
|
||||
The TypeScript servers start for a workspace marked by `tsconfig.json`, `jsconfig.json` or `package.json`. Files outside any `tsconfig.json` / `jsconfig.json` are still registered with tsserver, so loose scripts get code insight too.
|
||||
|
||||
@@ -47,7 +49,8 @@ All servers, debuggers and formatters are listed in **Settings › Languages & F
|
||||
| `vtsls`, `typescript-language-server` | npm (`@vtsls/language-server`; `typescript-language-server` + `typescript@6`) |
|
||||
| `vue-language-server`, `svelte-language-server`, `astro-ls`, `angular-language-server` | npm |
|
||||
| `oxlint` | npm |
|
||||
| Prettier, oxfmt | npm |
|
||||
| `tailwindcss-language-server` | npm (`@tailwindcss/language-server`) |
|
||||
| Prettier, oxfmt, Biome | npm |
|
||||
| JavaScript Debugger (vscode-js-debug) | GitHub release (`microsoft/vscode-js-debug`) |
|
||||
|
||||
The Astro and Angular servers also run from the project's own `node_modules/.bin` when it has them.
|
||||
@@ -67,14 +70,19 @@ The Astro and Angular servers also run from the project's own `node_modules/.bin
|
||||
|
||||
- **Prettier** (**Settings › Languages & Frameworks › Prettier**) formats JavaScript, JSX, TypeScript, TSX, JSON, Vue, HTML, CSS, SCSS, Less, GraphQL, YAML and Markdown by default. The executable is found in the project's `node_modules`, then the managed installation, then `PATH`, unless you set **Prettier path**.
|
||||
- **oxfmt** (**Settings › Languages & Frameworks › oxfmt**) replaces Prettier for an enabled language in files below an oxfmt configuration (`.oxfmtrc.json`, `oxfmt.config.ts`), or when it is the selected provider.
|
||||
- **Biome** (**Settings › Languages & Frameworks › Biome**) replaces Prettier and oxfmt for JavaScript, JSX, TypeScript, TSX, JSON, CSS and GraphQL in files below a `biome.json` / `biome.jsonc` or an installed `@biomejs/biome` (unless the configuration sets `formatter.enabled` to `false`), or when it is the selected provider. It formats whole files and reads its own configuration.
|
||||
|
||||
On both pages, **Formatting provider** chooses between **Automatic (language server first)** and the tool itself, **Run on save** formats on save, and **Enabled languages** limits which languages the tool handles.
|
||||
On these pages, **Formatting provider** chooses between **Automatic (language server first)** and the tool itself, **Run on save** formats on save, and **Enabled languages** limits which languages the tool handles.
|
||||
|
||||
### Biome lint
|
||||
|
||||
In a Biome project, Biome's diagnostics show in the editor and the Problems tool window, and `⌥⏎` / `Alt+Enter` offers its quick fixes and suppressions. Biome's safe fixes (`source.fixAll.biome`) run with **Code › Code Cleanup** and, when **Settings › Tools › Actions on Save › Run code cleanup** is on, on save. When Biome's formatter is enabled, its fix-all formats the file too.
|
||||
|
||||
## Run and test
|
||||
|
||||
OpenIDEA detects run configurations when the project opens:
|
||||
|
||||
- One configuration per `package.json` script (`npm run build`, `pnpm run dev`, …), for the root package, nested packages and workspace members. Scripts named `test`, `jest`, `vitest` or `test:*`, and scripts that run `playwright test` or `node --test`, are test configurations.
|
||||
- One configuration per `package.json` script (`npm run build`, `pnpm run dev`, …), for the root package, nested packages and workspace members. Scripts named `test`, `jest`, `vitest` or `test:*`, and scripts that run `playwright test`, `node --test` or `mocha`, are test configurations.
|
||||
- `playwright test` (through `npx`) for a package with a `playwright.config.*` that no script runs.
|
||||
- One per task in `deno.json` / `deno.jsonc` (`deno task <name>`).
|
||||
|
||||
@@ -86,7 +94,7 @@ In `package.json`, the gutter shows run icons on each `scripts` entry to run or
|
||||
- Any other `.js` file runs with `node` (with `deno run` or `bun run` in a project with `deno.json` or `bun.lock`).
|
||||
- A `.ts` file runs with Node.js directly on 22.18+ / 23.6+, with `--experimental-strip-types` on 22.6–22.17 and 23.0–23.5, else through `tsx` or `ts-node`.
|
||||
|
||||
Jest, Vitest, Playwright Test and `node --test` output is turned into the test tree, with **Rerun Failed Tests**. Playwright runs report through its `list` reporter unless the configuration names another; a test in the gutter runs by its line (`file:line`), and runs with several projects show each project under its file. `node --test` runs report through the IDE's reporter next to `spec`, added to `NODE_OPTIONS` (a script that chooses its own `--test-reporter` runs without the tree); single tests and reruns are selected by full name (`--test-name-pattern`). **Run with Coverage** works for scripts that run `vitest` or `jest` (Vitest needs a coverage provider such as `@vitest/coverage-v8`; the IDE offers to add it) and for `node` / `tsx` / `ts-node` runs through `c8`. See [Testing](/en/guide/testing) and [Coverage](/en/guide/coverage).
|
||||
Jest, Vitest, Playwright Test, `node --test` and Mocha output is turned into the test tree, with **Rerun Failed Tests**. Playwright runs report through its `list` reporter unless the configuration names another; a test in the gutter runs by its line (`file:line`), and runs with several projects show each project under its file. `node --test` runs report through the IDE's reporter next to `spec`, added to `NODE_OPTIONS` (a script that chooses its own `--test-reporter` runs without the tree); single tests and reruns are selected by full name (`--test-name-pattern`). Mocha runs keep their reporter and load an IDE hook through `NODE_OPTIONS` that reports each test with its line; single tests and reruns use `--grep`, and in projects that test with Mocha or `node --test`, tests in `test/` get gutter icons whatever their file name. **Run with Coverage** works for scripts that run `vitest` or `jest` (Vitest needs a coverage provider such as `@vitest/coverage-v8`; the IDE offers to add it) and for `node` / `tsx` / `ts-node` runs through `c8`. See [Testing](/en/guide/testing) and [Coverage](/en/guide/coverage).
|
||||
|
||||
## Debugging
|
||||
|
||||
|
||||
@@ -297,14 +297,14 @@ launching as before.
|
||||
|
||||
## Running programs
|
||||
|
||||
| Function | What it does |
|
||||
| ------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------- |
|
||||
| `Project::run_process(program, &args, stdin)` | Runs the pinned program in the project root and waits: `{ status, stdout, stderr }`, 4 MiB each. |
|
||||
| `host::run_command(&Command, Some(&project), stdin)` | API 1.3: the same, with environment variables added by `Command::env`. |
|
||||
| `host::run_captured(&Command, Some(&project), stdin, options)` | API 1.15: configurable output limit (up to 128 MiB per stream); errors explicitly if either stdout or stderr overflows. |
|
||||
| `host::start(&Command, Some(&project))` | API 1.3: a `Child` left running: `poll`, `write`, `close_stdin`, `wait`, `kill`. At most 8. |
|
||||
| `host::start_stream(&Command, Some(&project), options)` | API 1.15: lossless streaming with backpressure and bounded buffer, terminating with an explicit error on total overflow.|
|
||||
| `host::open_terminal(title, program, &args)` | A Terminal tab running the program (see [Views](/en/plugins/guides/views)). |
|
||||
| Function | What it does |
|
||||
| -------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `Project::run_process(program, &args, stdin)` | Runs the pinned program in the project root and waits: `{ status, stdout, stderr }`, 4 MiB each. |
|
||||
| `host::run_command(&Command, Some(&project), stdin)` | API 1.3: the same, with environment variables added by `Command::env`. |
|
||||
| `host::run_captured(&Command, Some(&project), stdin, options)` | API 1.15: configurable output limit (up to 128 MiB per stream); errors explicitly if either stdout or stderr overflows. |
|
||||
| `host::start(&Command, Some(&project))` | API 1.3: a `Child` left running: `poll`, `write`, `close_stdin`, `wait`, `kill`. At most 8. |
|
||||
| `host::start_stream(&Command, Some(&project), options)` | API 1.15: lossless streaming with backpressure and bounded buffer, terminating with an explicit error on total overflow. |
|
||||
| `host::open_terminal(title, program, &args)` | A Terminal tab running the program (see [Views](/en/plugins/guides/views)). |
|
||||
|
||||
```rust
|
||||
use openidea_plugin::host::{self, Command};
|
||||
|
||||
@@ -55,7 +55,7 @@ exclude = ["**/.git", "**/node_modules", "**/target", "**/dist"]
|
||||
| Plugins | Plugins |
|
||||
| Version Control | Commit; Confirmation; Directory Mappings; Issue Navigation; Log; Shelf; Git; GitHub |
|
||||
| Build, Execution, Deployment | CMake; Gradle; Maven; Console; Debugger (Data Views, Stepping); Python Debugger; Run/Debug; Run Targets; Deployment (Options) |
|
||||
| Languages & Frameworks | Language Servers; Go (Build Tags, Go Modules); Java; Markdown; Node.js; PHP; Python Interpreter; Prettier; oxfmt; Ruff; Ruby; Rust; TypeScript |
|
||||
| Languages & Frameworks | Language Servers; Go (Build Tags, Go Modules); Java; Markdown; Node.js; PHP; Python Interpreter; Prettier; oxfmt; Biome; Ruff; Ruby; Rust; TypeScript |
|
||||
| Tools | Agents (Chat); Terminal; Actions on Save; External Tools; SSH Configurations; MCP Server |
|
||||
| Security | Project Trust |
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ mise run dev
|
||||
|
||||
`setup` 在当前 worktree 中执行 `pnpm install`。`dev` 和 `dev:app` 都沿用原来的启动脚本,保留 worktree 隔离。使用 `mise run` 不需要在 shell 中激活 mise。
|
||||
|
||||
运行 `mise tasks` 可以查看全部任务。`mise run build` 构建前端,不生成桌面安装包;`mise run dogfood:build` 和 `mise run dogfood:install` 用于构建并在本地安装灰色图标的 dogfood 桌面版(与正式版共享设置和数据)。两者共用同一个实例,同一时间只能运行一个;较新的 dogfood 版写入的设置可能让较旧的正式版忽略整个设置文件。dogfood 版不会自动更新,需要更新时重新运行 `dogfood:install`。`mise run test` 运行 Vitest 和 `cargo test --workspace`;`mise run check` 先检查格式、代码规范、类型和未使用的代码,再运行这两套测试。两者都不需要 nextest 或插件的 WASM 目标。
|
||||
运行 `mise tasks` 可以查看全部任务。`mise run build` 构建前端,不生成桌面安装包;`mise run dogfood:build` 和 `mise run dogfood:install` 用于构建并在本地安装灰色图标的 dogfood 桌面版(与正式版共享设置和数据)。两者共用同一个实例,同一时间只能运行一个;较新的 dogfood 版写入的设置可能让较旧的正式版忽略整个设置文件。dogfood 版不会自动更新,需要更新时重新运行 `dogfood:install`。`mise run dogfood:remote <remote_name>` 在 **工具 › SSH 配置** 中指定的远程主机上构建并部署 `openidea-server`(`--clean` 可移除覆盖)。`mise run test` 运行 Vitest 和 `cargo test --workspace`;`mise run check` 先检查格式、代码规范、类型和未使用的代码,再运行这两套测试。两者都不需要 nextest 或插件的 WASM 目标。
|
||||
|
||||
## Worktree
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ description: "多光标与选区、行编辑、剪贴板历史、代码折叠、
|
||||
| **自动缩进行** | `⌃⌥I` | `Ctrl+Alt+I` |
|
||||
| **优化导入** | `⌃⌥O` | `Ctrl+Alt+O` |
|
||||
|
||||
**重新格式化代码** 格式化选区,没有选区时格式化整个文件,整体算一步撤销。格式化由文件的语言服务器或该语言配置的格式化工具完成(例如 Python 用 Ruff,Web 语言用 Prettier 或 oxfmt;在查找操作里搜 **使用 … 重新格式化** 可以指定工具)。**重新格式化文件…** 还能选择范围并顺便优化导入。
|
||||
**重新格式化代码** 格式化选区,没有选区时格式化整个文件,整体算一步撤销。格式化由文件的语言服务器或该语言配置的格式化工具完成(例如 Python 用 Ruff,Web 语言用 Prettier、oxfmt 或 Biome;在查找操作里搜 **使用 … 重新格式化** 可以指定工具)。**重新格式化文件…** 还能选择范围并顺便优化导入。
|
||||
|
||||
缩进等代码风格选项在 **设置 › 编辑器 › 代码样式** 中,每种语言一个页面。项目里的 `.editorconfig` 也会生效。
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ RSpec 有自己的配置类型(**RSpec 测试**)和检测到的 `rspec` 配
|
||||
| **重新运行**(在“运行”工具窗口中) | `⌘R` | `Ctrl+F5` |
|
||||
| **重新运行失败的测试** | — | — |
|
||||
|
||||
**重新运行失败的测试**(在“运行”工具窗口工具栏和“查找操作”中)只运行上一次失败的测试,会按各个工具自己的过滤语法生成命令。支持 Cargo、Jest / Vitest、Playwright、`node --test`、pytest、Django、PHPUnit、Go、Maven / Gradle 和 .NET,以及插件接入的测试框架。
|
||||
**重新运行失败的测试**(在“运行”工具窗口工具栏和“查找操作”中)只运行上一次失败的测试,会按各个工具自己的过滤语法生成命令。支持 Cargo、Jest / Vitest、Playwright、`node --test`、Mocha、pytest、Django、PHPUnit、Go、Maven / Gradle 和 .NET,以及插件接入的测试框架。
|
||||
|
||||
## 在代码和测试之间跳转
|
||||
|
||||
|
||||
+87
-87
@@ -32,7 +32,7 @@ OpenIDEA 用一个小的定义文件 `languages/<id>.toml` 描述每种语言:
|
||||
一种语言可以配置多个服务器:
|
||||
|
||||
- **备选**(下表中写作 `a → b`):只运行第一个已安装的。例如 Python 默认用 basedpyright,只有它缺失时才退回 pyright、ty 或 pyrefly。在 **设置 › 语言和框架 › 语言服务器** 中可以指定其中一个,或选 **自动**(使用第一个可用的)。
|
||||
- **附加**(写作 `+ b`):和主服务器同时运行,通常只在用到它的项目中启用。带 Ruff 配置的项目里 Ruff 与 basedpyright 一起运行;带 oxlint 配置的项目里 oxlint 与 vtsls 一起运行;Angular 和 Laravel 项目里分别加上 Angular 和 Laravel 的服务器。
|
||||
- **附加**(写作 `+ b`):和主服务器同时运行,通常只在用到它的项目中启用。带 Ruff 配置的项目里 Ruff 与 basedpyright 一起运行;带 oxlint 配置的项目里 oxlint 与 vtsls 一起运行;带 Biome 配置或安装了 Biome 的项目里 Biome 与 JavaScript、TypeScript、JSON、CSS 和 GraphQL 的服务器一起运行;Angular、Laravel 和 Tailwind CSS 项目里分别加上 Angular、Laravel 和 Tailwind CSS 的服务器。
|
||||
|
||||
## 安装语言服务器和调试器
|
||||
|
||||
@@ -86,92 +86,92 @@ IDE 安装工具从不需要 `sudo`。工具装在本地数据目录下 IDE 自
|
||||
|
||||
下表列出全部内置语言定义。**加粗** 的服务器和调试器可以在 IDE 中一键安装,其余需要自行安装(IDE 中的安装提示会说明方法)。"高亮"和"Tree-sitter"两列分别表示是否有即时高亮,以及是否有用于大纲和折叠的内置语法。
|
||||
|
||||
| 语言 | ID | 文件 | 高亮 | Tree-sitter | 语言服务器 | 调试器 |
|
||||
| ------------------- | ------------------ | ----------------------------------------------------------- | ---- | ----------- | ------------------------------------------------------------------------------------- | ------------------------ |
|
||||
| .env | `dotenv` | `.env` | 是 | — | — | — |
|
||||
| Arduino | `arduino` | `.ino` | 是 | 是 | arduino-language-server | — |
|
||||
| AsciiDoc | `asciidoc` | `.adoc`, `.asciidoc` | 是 | — | — | — |
|
||||
| Astro | `astro` | `.astro` | 是 | — | **astro-ls** + **oxlint** | — |
|
||||
| Batch | `bat` | `.bat`, `.cmd` | 是 | — | — | — |
|
||||
| C | `c` | `.c`, `.h` | 是 | 是 | **clangd** | lldb-dap |
|
||||
| C# | `csharp` | `.cs`, `.csx` | 是 | 是 | **csharp-ls** | **netcoredbg** |
|
||||
| C++ | `cpp` | `.cpp`, `.cc`, `.cxx`, `.c++`, `.hpp`, … | 是 | 是 | **clangd** | lldb-dap |
|
||||
| Clojure | `clojure` | `.clj`, `.cljs`, `.cljc`, `.cljd`, `.edn`, … | 是 | — | **clojure-lsp** | — |
|
||||
| CMake | `cmake` | `.cmake` | 是 | 是 | **neocmakelsp** → cmake-language-server | — |
|
||||
| CSS | `css` | `.css`, `.pcss`, `.postcss` | 是 | 是 | **vscode-css-language-server** | — |
|
||||
| D | `d` | `.d`, `.di` | 是 | — | serve-d | — |
|
||||
| Dart | `dart` | `.dart` | 是 | 是 | dart | dart |
|
||||
| Diff | `diff` | `.diff`, `.patch`, `.rej` | 是 | — | — | — |
|
||||
| Django Template | `django-html` | `.djhtml`, `templates/*.html`, `*.txt` | 是 | 是 | **vscode-html-language-server**, **djlsp** | — |
|
||||
| Dockerfile | `dockerfile` | `.dockerfile`, `.containerfile` | 是 | — | **dockerfile-language-server** | — |
|
||||
| Elixir | `elixir` | `.ex`, `.exs` | 是 | 是 | **elixir-ls** | **elixir-ls-debugger** |
|
||||
| ERB | `erb` | `.erb`, `.html.erb`, `.rhtml`, `.js.erb`, `.text.erb`, … | 是 | — | — | — |
|
||||
| Erlang | `erlang` | `.erl`, `.hrl`, `.escript`, `.app.src` | 是 | — | elp | — |
|
||||
| F# | `fsharp` | `.fs`, `.fsi`, `.fsx` | 是 | — | **fsautocomplete** | **netcoredbg** |
|
||||
| GDScript | `gdscript` | `.gd` | 是 | 是 | godot | godot |
|
||||
| Git Attributes | `gitattributes` | `.gitattributes` | — | — | — | — |
|
||||
| Go | `go` | `.go` | 是 | 是 | **gopls** | **delve** |
|
||||
| Go Module | `go.mod` | `go.mod` | 是 | — | **gopls** | — |
|
||||
| Go Workspace | `go.work` | `go.work` | 是 | — | **gopls** | — |
|
||||
| Godot Resource | `godot-resource` | `.tscn`, `.tres`, `.godot`, `.import` | 是 | — | — | — |
|
||||
| Godot Shader | `gdshader` | `.gdshader`, `.gdshaderinc` | 是 | — | — | — |
|
||||
| GraphQL | `graphql` | `.graphql`, `.graphqls`, `.gql` | 是 | 是 | **graphql-lsp** | — |
|
||||
| Groovy | `groovy` | `.groovy`, `.gradle`, `.gvy`, `.gy`, `.gsh` | 是 | — | groovy-language-server | — |
|
||||
| Haskell | `haskell` | `.hs`, `.hs-boot`, `.hsig` | 是 | 是 | haskell-language-server | — |
|
||||
| HCL | `hcl` | `.hcl`, `.nomad`, `.pkr.hcl` | 是 | 是 | — | — |
|
||||
| HTML | `html` | `.html`, `.htm`, `.xhtml`, `.shtml`, `.html.tmpl` | 是 | 是 | **vscode-html-language-server** + **angular-language-server** | — |
|
||||
| HTTP Request | `http` | `.http`, `.rest` | 是 | — | — | — |
|
||||
| Ignore File | `ignore` | `.gitignore`, `.dockerignore` | — | — | — | — |
|
||||
| INI | `ini` | `.ini`, `.cfg`, `.conf`, `.cnf`, `.inf`, … | 是 | — | — | — |
|
||||
| Java | `java` | `.java` | 是 | 是 | **jdtls** → **java-analyzer** → **kmp-lsp** | **java-debug** |
|
||||
| JavaScript | `javascript` | `.js`, `.mjs`, `.cjs` | 是 | 是 | **vtsls** → **typescript-language-server** + **oxlint** | **js-debug** |
|
||||
| JavaScript JSX | `javascriptreact` | `.jsx` | 是 | 是 | **vtsls** → **typescript-language-server** + **oxlint** | **js-debug** |
|
||||
| JSON | `json` | `.json`, `.geojson`, `.topojson`, `.webmanifest`, `.har`, … | 是 | 是 | **vscode-json-language-server** | — |
|
||||
| JSON with Comments | `jsonc` | `.jsonc`, `.code-workspace`, `.code-snippets` | 是 | 是 | **vscode-json-language-server** | — |
|
||||
| JSP | `jsp` | `.jsp`, `.jspx`, `.jspf`, `.jsph`, `.tag`, … | 是 | — | — | — |
|
||||
| Julia | `julia` | `.jl` | 是 | — | julia-languageserver | — |
|
||||
| Kotlin | `kotlin` | `.kt`, `.kts` | 是 | 是 | **kotlin-lsp** → **kotlin-language-server** → **kmp-lsp** | **kotlin-debug-adapter** |
|
||||
| LaTeX | `latex` | `.tex`, `.ltx`, `.sty`, `.cls`, `.dtx`, … | 是 | — | **texlab** | — |
|
||||
| Less | `less` | `.less` | 是 | — | **vscode-css-language-server** | — |
|
||||
| Log | `log` | `.log` | 是 | — | — | — |
|
||||
| Lua | `lua` | `.lua`, `.luau`, `.rockspec` | 是 | 是 | **lua-language-server** | — |
|
||||
| Makefile | `makefile` | `.mk`, `.mak`, `.make` | 是 | 是 | — | — |
|
||||
| Markdown | `markdown` | `.md`, `.markdown`, `.mdown`, `.mkd`, `.mkdn`, … | 是 | 是 | **marksman** | — |
|
||||
| Nix | `nix` | `.nix` | 是 | 是 | nil → nixd | — |
|
||||
| Objective-C | `objective-c` | `.m` | 是 | — | **clangd** | lldb-dap |
|
||||
| Objective-C++ | `objective-cpp` | `.mm` | 是 | — | **clangd** | lldb-dap |
|
||||
| OCaml | `ocaml` | `.ml`, `.mll`, `.mly` | 是 | 是 | ocamllsp | ocamlearlybird |
|
||||
| OCaml Interface | `ocaml.interface` | `.mli` | 是 | 是 | ocamllsp | — |
|
||||
| Perl | `perl` | `.pl`, `.pm`, `.pod`, `.psgi`, `.cgi` | 是 | — | **perlnavigator** | — |
|
||||
| PHP | `php` | `.php`, `.phtml`, `.php3`, `.php4`, `.php5`, … | 是 | 是 | **intelephense** → phpactor → **phoxite** + **laravel-lsp** | **php-debug** |
|
||||
| Plain Text | `plaintext` | `.txt`, `.text` | — | — | — | — |
|
||||
| PowerShell | `powershell` | `.ps1`, `.psm1`, `.psd1`, `.pssc`, `.psrc` | 是 | — | powershell-editor-services | — |
|
||||
| Prisma | `prisma` | `.prisma` | 是 | 是 | **prisma-language-server** | — |
|
||||
| Properties | `properties` | `.properties`, `.prefs` | 是 | — | — | — |
|
||||
| Protocol Buffers | `proto` | `.proto` | 是 | 是 | **buf** | — |
|
||||
| Python | `python` | `.py`, `.pyi`, `.pyw` | 是 | 是 | **basedpyright** → **pyright** → **ty** → **pyrefly** + **ruff** | **debugpy** |
|
||||
| R | `r` | `.r`, `.rprofile` | 是 | — | r-languageserver | — |
|
||||
| reStructuredText | `restructuredtext` | `.rst` | 是 | — | — | — |
|
||||
| Ruby | `ruby` | `.rb`, `.rake`, `.gemspec`, `.ru`, `.rbi`, … | 是 | 是 | **ruby-lsp** → **solargraph** | rdbg |
|
||||
| Rust | `rust` | `.rs` | 是 | 是 | **rust-analyzer** | **codelldb** |
|
||||
| Sass | `sass` | `.sass` | 是 | — | — | — |
|
||||
| Scala | `scala` | `.scala`, `.sc`, `.sbt`, `.mill` | 是 | 是 | metals | — |
|
||||
| SCSS | `scss` | `.scss` | 是 | — | **vscode-css-language-server** | — |
|
||||
| Shell Script | `shellscript` | `.sh`, `.bash`, `.zsh`, `.ksh`, `.ash`, … | 是 | 是 | **bash-language-server** | **bash-debug** |
|
||||
| Slint | `slint` | `.slint` | 是 | — | **slint-lsp** | — |
|
||||
| SQL | `sql` | `.sql`, `.ddl`, `.dml`, `.psql`, `.pgsql`, … | 是 | — | **sqls** | — |
|
||||
| Svelte | `svelte` | `.svelte` | 是 | — | **svelte-language-server** + **oxlint** | — |
|
||||
| Swift | `swift` | `.swift`, `.swiftinterface` | 是 | 是 | sourcekit-lsp | lldb-dap |
|
||||
| Terraform | `terraform` | `.tf`, `.tofu`, `.tftest.hcl` | 是 | 是 | **terraform-ls** | — |
|
||||
| Terraform Variables | `terraform-vars` | `.tfvars` | 是 | 是 | **terraform-ls** | — |
|
||||
| TOML | `toml` | `.toml` | 是 | 是 | **taplo** | — |
|
||||
| TypeScript | `typescript` | `.ts`, `.mts`, `.cts` | 是 | 是 | **vtsls** → **typescript-language-server** + **angular-language-server** + **oxlint** | **js-debug** |
|
||||
| TypeScript JSX | `typescriptreact` | `.tsx` | 是 | 是 | **vtsls** → **typescript-language-server** + **oxlint** | **js-debug** |
|
||||
| Typst | `typst` | `.typ` | — | — | **tinymist** | — |
|
||||
| Vue | `vue` | `.vue` | 是 | — | **vue-language-server**, **vtsls** + **oxlint** | — |
|
||||
| XML | `xml` | `.xml`, `.xsd`, `.xsl`, `.xslt`, `.svg`, … | 是 | 是 | **lemminx** | — |
|
||||
| YAML | `yaml` | `.yaml`, `.yml` | 是 | 是 | **yaml-language-server** | — |
|
||||
| Zig | `zig` | `.zig`, `.zon` | 是 | 是 | **zls** | **codelldb** |
|
||||
| 语言 | ID | 文件 | 高亮 | Tree-sitter | 语言服务器 | 调试器 |
|
||||
| ------------------- | ------------------ | ----------------------------------------------------------- | ---- | ----------- | ------------------------------------------------------------------------------------------------- | ------------------------ |
|
||||
| .env | `dotenv` | `.env` | 是 | — | — | — |
|
||||
| Arduino | `arduino` | `.ino` | 是 | 是 | arduino-language-server | — |
|
||||
| AsciiDoc | `asciidoc` | `.adoc`, `.asciidoc` | 是 | — | — | — |
|
||||
| Astro | `astro` | `.astro` | 是 | — | **astro-ls** + **oxlint** | — |
|
||||
| Batch | `bat` | `.bat`, `.cmd` | 是 | — | — | — |
|
||||
| C | `c` | `.c`, `.h` | 是 | 是 | **clangd** | lldb-dap |
|
||||
| C# | `csharp` | `.cs`, `.csx` | 是 | 是 | **csharp-ls** | **netcoredbg** |
|
||||
| C++ | `cpp` | `.cpp`, `.cc`, `.cxx`, `.c++`, `.hpp`, … | 是 | 是 | **clangd** | lldb-dap |
|
||||
| Clojure | `clojure` | `.clj`, `.cljs`, `.cljc`, `.cljd`, `.edn`, … | 是 | — | **clojure-lsp** | — |
|
||||
| CMake | `cmake` | `.cmake` | 是 | 是 | **neocmakelsp** → cmake-language-server | — |
|
||||
| CSS | `css` | `.css`, `.pcss`, `.postcss` | 是 | 是 | **vscode-css-language-server** + **biome** | — |
|
||||
| D | `d` | `.d`, `.di` | 是 | — | serve-d | — |
|
||||
| Dart | `dart` | `.dart` | 是 | 是 | dart | dart |
|
||||
| Diff | `diff` | `.diff`, `.patch`, `.rej` | 是 | — | — | — |
|
||||
| Django Template | `django-html` | `.djhtml`, `templates/*.html`, `*.txt` | 是 | 是 | **vscode-html-language-server**, **djlsp** | — |
|
||||
| Dockerfile | `dockerfile` | `.dockerfile`, `.containerfile` | 是 | — | **dockerfile-language-server** | — |
|
||||
| Elixir | `elixir` | `.ex`, `.exs` | 是 | 是 | **elixir-ls** | **elixir-ls-debugger** |
|
||||
| ERB | `erb` | `.erb`, `.html.erb`, `.rhtml`, `.js.erb`, `.text.erb`, … | 是 | — | — | — |
|
||||
| Erlang | `erlang` | `.erl`, `.hrl`, `.escript`, `.app.src` | 是 | — | elp | — |
|
||||
| F# | `fsharp` | `.fs`, `.fsi`, `.fsx` | 是 | — | **fsautocomplete** | **netcoredbg** |
|
||||
| GDScript | `gdscript` | `.gd` | 是 | 是 | godot | godot |
|
||||
| Git Attributes | `gitattributes` | `.gitattributes` | — | — | — | — |
|
||||
| Go | `go` | `.go` | 是 | 是 | **gopls** | **delve** |
|
||||
| Go Module | `go.mod` | `go.mod` | 是 | — | **gopls** | — |
|
||||
| Go Workspace | `go.work` | `go.work` | 是 | — | **gopls** | — |
|
||||
| Godot Resource | `godot-resource` | `.tscn`, `.tres`, `.godot`, `.import` | 是 | — | — | — |
|
||||
| Godot Shader | `gdshader` | `.gdshader`, `.gdshaderinc` | 是 | — | — | — |
|
||||
| GraphQL | `graphql` | `.graphql`, `.graphqls`, `.gql` | 是 | 是 | **graphql-lsp** + **biome** | — |
|
||||
| Groovy | `groovy` | `.groovy`, `.gradle`, `.gvy`, `.gy`, `.gsh` | 是 | — | groovy-language-server | — |
|
||||
| Haskell | `haskell` | `.hs`, `.hs-boot`, `.hsig` | 是 | 是 | haskell-language-server | — |
|
||||
| HCL | `hcl` | `.hcl`, `.nomad`, `.pkr.hcl` | 是 | 是 | — | — |
|
||||
| HTML | `html` | `.html`, `.htm`, `.xhtml`, `.shtml`, `.html.tmpl` | 是 | 是 | **vscode-html-language-server** + **angular-language-server** | — |
|
||||
| HTTP Request | `http` | `.http`, `.rest` | 是 | — | — | — |
|
||||
| Ignore File | `ignore` | `.gitignore`, `.dockerignore` | — | — | — | — |
|
||||
| INI | `ini` | `.ini`, `.cfg`, `.conf`, `.cnf`, `.inf`, … | 是 | — | — | — |
|
||||
| Java | `java` | `.java` | 是 | 是 | **jdtls** → **java-analyzer** → **kmp-lsp** | **java-debug** |
|
||||
| JavaScript | `javascript` | `.js`, `.mjs`, `.cjs` | 是 | 是 | **vtsls** → **typescript-language-server** + **oxlint** + **biome** | **js-debug** |
|
||||
| JavaScript JSX | `javascriptreact` | `.jsx` | 是 | 是 | **vtsls** → **typescript-language-server** + **oxlint** + **biome** | **js-debug** |
|
||||
| JSON | `json` | `.json`, `.geojson`, `.topojson`, `.webmanifest`, `.har`, … | 是 | 是 | **vscode-json-language-server** + **biome** | — |
|
||||
| JSON with Comments | `jsonc` | `.jsonc`, `.code-workspace`, `.code-snippets` | 是 | 是 | **vscode-json-language-server** + **biome** | — |
|
||||
| JSP | `jsp` | `.jsp`, `.jspx`, `.jspf`, `.jsph`, `.tag`, … | 是 | — | — | — |
|
||||
| Julia | `julia` | `.jl` | 是 | — | julia-languageserver | — |
|
||||
| Kotlin | `kotlin` | `.kt`, `.kts` | 是 | 是 | **kotlin-lsp** → **kotlin-language-server** → **kmp-lsp** | **kotlin-debug-adapter** |
|
||||
| LaTeX | `latex` | `.tex`, `.ltx`, `.sty`, `.cls`, `.dtx`, … | 是 | — | **texlab** | — |
|
||||
| Less | `less` | `.less` | 是 | — | **vscode-css-language-server** | — |
|
||||
| Log | `log` | `.log` | 是 | — | — | — |
|
||||
| Lua | `lua` | `.lua`, `.luau`, `.rockspec` | 是 | 是 | **lua-language-server** | — |
|
||||
| Makefile | `makefile` | `.mk`, `.mak`, `.make` | 是 | 是 | — | — |
|
||||
| Markdown | `markdown` | `.md`, `.markdown`, `.mdown`, `.mkd`, `.mkdn`, … | 是 | 是 | **marksman** | — |
|
||||
| Nix | `nix` | `.nix` | 是 | 是 | nil → nixd | — |
|
||||
| Objective-C | `objective-c` | `.m` | 是 | — | **clangd** | lldb-dap |
|
||||
| Objective-C++ | `objective-cpp` | `.mm` | 是 | — | **clangd** | lldb-dap |
|
||||
| OCaml | `ocaml` | `.ml`, `.mll`, `.mly` | 是 | 是 | ocamllsp | ocamlearlybird |
|
||||
| OCaml Interface | `ocaml.interface` | `.mli` | 是 | 是 | ocamllsp | — |
|
||||
| Perl | `perl` | `.pl`, `.pm`, `.pod`, `.psgi`, `.cgi` | 是 | — | **perlnavigator** | — |
|
||||
| PHP | `php` | `.php`, `.phtml`, `.php3`, `.php4`, `.php5`, … | 是 | 是 | **intelephense** → phpactor → **phoxite** + **laravel-lsp** | **php-debug** |
|
||||
| Plain Text | `plaintext` | `.txt`, `.text` | — | — | — | — |
|
||||
| PowerShell | `powershell` | `.ps1`, `.psm1`, `.psd1`, `.pssc`, `.psrc` | 是 | — | powershell-editor-services | — |
|
||||
| Prisma | `prisma` | `.prisma` | 是 | 是 | **prisma-language-server** | — |
|
||||
| Properties | `properties` | `.properties`, `.prefs` | 是 | — | — | — |
|
||||
| Protocol Buffers | `proto` | `.proto` | 是 | 是 | **buf** | — |
|
||||
| Python | `python` | `.py`, `.pyi`, `.pyw` | 是 | 是 | **basedpyright** → **pyright** → **ty** → **pyrefly** + **ruff** | **debugpy** |
|
||||
| R | `r` | `.r`, `.rprofile` | 是 | — | r-languageserver | — |
|
||||
| reStructuredText | `restructuredtext` | `.rst` | 是 | — | — | — |
|
||||
| Ruby | `ruby` | `.rb`, `.rake`, `.gemspec`, `.ru`, `.rbi`, … | 是 | 是 | **ruby-lsp** → **solargraph** | rdbg |
|
||||
| Rust | `rust` | `.rs` | 是 | 是 | **rust-analyzer** | **codelldb** |
|
||||
| Sass | `sass` | `.sass` | 是 | — | — | — |
|
||||
| Scala | `scala` | `.scala`, `.sc`, `.sbt`, `.mill` | 是 | 是 | metals | — |
|
||||
| SCSS | `scss` | `.scss` | 是 | — | **vscode-css-language-server** | — |
|
||||
| Shell Script | `shellscript` | `.sh`, `.bash`, `.zsh`, `.ksh`, `.ash`, … | 是 | 是 | **bash-language-server** | **bash-debug** |
|
||||
| Slint | `slint` | `.slint` | 是 | — | **slint-lsp** | — |
|
||||
| SQL | `sql` | `.sql`, `.ddl`, `.dml`, `.psql`, `.pgsql`, … | 是 | — | **sqls** | — |
|
||||
| Svelte | `svelte` | `.svelte` | 是 | — | **svelte-language-server** + **oxlint** | — |
|
||||
| Swift | `swift` | `.swift`, `.swiftinterface` | 是 | 是 | sourcekit-lsp | lldb-dap |
|
||||
| Terraform | `terraform` | `.tf`, `.tofu`, `.tftest.hcl` | 是 | 是 | **terraform-ls** | — |
|
||||
| Terraform Variables | `terraform-vars` | `.tfvars` | 是 | 是 | **terraform-ls** | — |
|
||||
| TOML | `toml` | `.toml` | 是 | 是 | **taplo** | — |
|
||||
| TypeScript | `typescript` | `.ts`, `.mts`, `.cts` | 是 | 是 | **vtsls** → **typescript-language-server** + **angular-language-server** + **oxlint** + **biome** | **js-debug** |
|
||||
| TypeScript JSX | `typescriptreact` | `.tsx` | 是 | 是 | **vtsls** → **typescript-language-server** + **oxlint** + **biome** | **js-debug** |
|
||||
| Typst | `typst` | `.typ` | — | — | **tinymist** | — |
|
||||
| Vue | `vue` | `.vue` | 是 | — | **vue-language-server**, **vtsls** + **oxlint** | — |
|
||||
| XML | `xml` | `.xml`, `.xsd`, `.xsl`, `.xslt`, `.svg`, … | 是 | 是 | **lemminx** | — |
|
||||
| YAML | `yaml` | `.yaml`, `.yml` | 是 | 是 | **yaml-language-server** | — |
|
||||
| Zig | `zig` | `.zig`, `.zon` | 是 | 是 | **zls** | **codelldb** |
|
||||
|
||||
说明:
|
||||
|
||||
|
||||
@@ -7,16 +7,18 @@ OpenIDEA 打开 JavaScript(`.js`、`.mjs`、`.cjs`、`.jsx`)和 TypeScript
|
||||
|
||||
## 语言服务器
|
||||
|
||||
| 文件 | 服务器 | 说明 |
|
||||
| --------------------------- | ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| JS、JSX、TS、TSX | `vtsls` | 默认的 TypeScript 服务器。 |
|
||||
| JS、JSX、TS、TSX | `typescript-language-server` | 备选:仅在未安装 `vtsls` 时使用。 |
|
||||
| `.vue` | `vue-language-server` + `vtsls` | Vue 的 hybrid 模式:`.vue` 中的 TypeScript 由加载了 `@vue/typescript-plugin` 的 `vtsls` 处理。 |
|
||||
| `.svelte` | `svelte-language-server` | |
|
||||
| `.astro` | `astro-ls` | 需要 Node.js 和 TypeScript 库。 |
|
||||
| Angular 项目中的 TS 和 HTML | `angular-language-server`(`ngserver`) | 只在 `angular.json` 或 `node_modules/@angular/core` 所在目录之下启用。 |
|
||||
| 以上全部 | `oxlint` | 只在存在 `.oxlintrc.json`、`.oxlintrc.jsonc`、`oxlint.config.ts` 或 `oxlint.config.mts` 的目录之下启用。 |
|
||||
| 以上全部 | `vscode-eslint-language-server`(ESLint) | 只在 ESLint 配置(`eslint.config.*`、`.eslintrc*` 或 `package.json` 中的 `eslintConfig`)所在目录之下启用,运行项目自己的 `eslint`。 |
|
||||
| 文件 | 服务器 | 说明 |
|
||||
| --------------------------- | --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| JS、JSX、TS、TSX | `vtsls` | 默认的 TypeScript 服务器。 |
|
||||
| JS、JSX、TS、TSX | `typescript-language-server` | 备选:仅在未安装 `vtsls` 时使用。 |
|
||||
| `.vue` | `vue-language-server` + `vtsls` | Vue 的 hybrid 模式:`.vue` 中的 TypeScript 由加载了 `@vue/typescript-plugin` 的 `vtsls` 处理。 |
|
||||
| `.svelte` | `svelte-language-server` | |
|
||||
| `.astro` | `astro-ls` | 需要 Node.js 和 TypeScript 库。 |
|
||||
| Angular 项目中的 TS 和 HTML | `angular-language-server`(`ngserver`) | 只在 `angular.json` 或 `node_modules/@angular/core` 所在目录之下启用。 |
|
||||
| 以上全部 | `oxlint` | 只在存在 `.oxlintrc.json`、`.oxlintrc.jsonc`、`oxlint.config.ts` 或 `oxlint.config.mts` 的目录之下启用。 |
|
||||
| 以上全部 | `vscode-eslint-language-server`(ESLint) | 只在 ESLint 配置(`eslint.config.*`、`.eslintrc*` 或 `package.json` 中的 `eslintConfig`)所在目录之下启用,运行项目自己的 `eslint`。 |
|
||||
| JS、JSX、TS、TSX、JSON、CSS | `biome lsp-proxy`(Biome) | 只在 `biome.json` / `biome.jsonc` 所在目录或安装了 `@biomejs/biome` 的项目之下启用,运行项目自己的 `biome`。 |
|
||||
| 以上全部及 HTML、CSS | `tailwindcss-language-server`(Tailwind CSS) | 只在 `tailwind.config.*` 或依赖了 `tailwindcss` 的 `package.json` 所在目录之下启用:类名补全、悬停显示生成的 CSS、类名诊断。 |
|
||||
|
||||
TypeScript 服务器以 `tsconfig.json`、`jsconfig.json` 或 `package.json` 所在目录为工作区根。不属于任何 `tsconfig.json` / `jsconfig.json` 的文件也会注册给 tsserver,零散脚本同样有代码智能。
|
||||
|
||||
@@ -47,7 +49,9 @@ Vue、Astro 和 Angular 服务器也会使用这里选择的版本。TypeScript
|
||||
| `vtsls`、`typescript-language-server` | npm(`@vtsls/language-server`;`typescript-language-server` + `typescript@6`) |
|
||||
| `vue-language-server`、`svelte-language-server`、`astro-ls`、`angular-language-server` | npm |
|
||||
| `oxlint` | npm |
|
||||
| `tailwindcss-language-server` | npm(`@tailwindcss/language-server`) |
|
||||
| Prettier、oxfmt | npm |
|
||||
| Prettier、oxfmt、Biome | npm |
|
||||
| JavaScript 调试器(vscode-js-debug) | GitHub release(`microsoft/vscode-js-debug`) |
|
||||
|
||||
如果项目自己的 `node_modules/.bin` 里有 Astro 或 Angular 服务器,会优先使用项目里的。
|
||||
@@ -67,14 +71,19 @@ Vue、Astro 和 Angular 服务器也会使用这里选择的版本。TypeScript
|
||||
|
||||
- **Prettier**(**设置 › 语言和框架 › Prettier**)默认处理 JavaScript、JSX、TypeScript、TSX、JSON、Vue、HTML、CSS、SCSS、Less、GraphQL、YAML 和 Markdown。未设置 **Prettier 路径** 时,依次查找项目 `node_modules`、IDE 管理的安装、`PATH`。
|
||||
- **oxfmt**(**设置 › 语言和框架 › oxfmt**)在 oxfmt 配置文件(`.oxfmtrc.json`、`oxfmt.config.ts`)所在目录之下,或被选为格式化工具时,替代 Prettier 处理已启用的语言。
|
||||
- **Biome**(**设置 › 语言和框架 › Biome**)在 `biome.json` / `biome.jsonc` 所在目录或安装了 `@biomejs/biome` 的项目之下(配置里 `formatter.enabled` 为 `false` 时除外),或被选为格式化工具时,替代 Prettier 和 oxfmt 处理 JavaScript、JSX、TypeScript、TSX、JSON、CSS 和 GraphQL。它总是格式化整个文件,并读取自己的配置。
|
||||
|
||||
两个页面上,**格式化工具** 可选 **自动(优先语言服务器)** 或工具本身,**保存时运行** 控制保存时格式化,**启用的语言** 限定工具处理哪些语言。
|
||||
这些页面上,**格式化工具** 可选 **自动(优先语言服务器)** 或工具本身,**保存时运行** 控制保存时格式化,**启用的语言** 限定工具处理哪些语言。
|
||||
|
||||
### Biome 检查
|
||||
|
||||
在 Biome 项目中,Biome 的诊断显示在编辑器和“问题”工具窗口里,`⌥⏎` / `Alt+Enter` 提供它的快速修复和抑制。Biome 的安全修复(`source.fixAll.biome`)随 **代码 › 代码清理** 运行;开启 **设置 › 工具 › 保存时操作 › 运行代码清理** 后,保存时也会运行。Biome 的格式化器开启时,它的全部修复也会格式化文件。
|
||||
|
||||
## 运行与测试
|
||||
|
||||
打开项目时,OpenIDEA 会自动检测运行配置:
|
||||
|
||||
- 每个 `package.json` 脚本一个配置(`npm run build`、`pnpm run dev` 等),覆盖根包、嵌套包和 workspace 成员。名为 `test`、`jest`、`vitest` 或 `test:*` 的脚本,以及运行 `playwright test` 或 `node --test` 的脚本,是测试配置。
|
||||
- 每个 `package.json` 脚本一个配置(`npm run build`、`pnpm run dev` 等),覆盖根包、嵌套包和 workspace 成员。名为 `test`、`jest`、`vitest` 或 `test:*` 的脚本,以及运行 `playwright test`、`node --test` 或 `mocha` 的脚本,是测试配置。
|
||||
- 有 `playwright.config.*` 但没有脚本运行它的包:通过 `npx` 运行的 `playwright test`。
|
||||
- `deno.json` / `deno.jsonc` 中每个 task 一个配置(`deno task <name>`)。
|
||||
|
||||
@@ -86,7 +95,7 @@ Vue、Astro 和 Angular 服务器也会使用这里选择的版本。TypeScript
|
||||
- 其他 `.js` 文件用 `node` 运行(项目含 `deno.json` 或 `bun.lock` 时改用 `deno run` 或 `bun run`)。
|
||||
- `.ts` 文件在 Node.js 22.18+ / 23.6+ 上直接运行,在 22.6–22.17 和 23.0–23.5 上加 `--experimental-strip-types`,更早的版本则通过 `tsx` 或 `ts-node` 运行。
|
||||
|
||||
Jest、Vitest、Playwright Test 和 `node --test` 的输出会解析成测试树,支持 **重新运行失败的测试**。Playwright 运行时使用它的 `list` 报告器(配置里指定了其他报告器时除外);从行号栏运行单个测试时按行号选择(`file:line`),有多个 project 的运行会在文件下按 project 分组。`node --test` 运行时,IDE 通过 `NODE_OPTIONS` 在 `spec` 旁加上自己的报告器(脚本自己指定了 `--test-reporter` 时不显示测试树);单个测试和重新运行按完整名称选择(`--test-name-pattern`)。**使用覆盖率运行** 支持调用 `vitest` 或 `jest` 的脚本(Vitest 需要 `@vitest/coverage-v8` 之类的覆盖率 provider,缺失时 IDE 会提示添加),以及通过 `c8` 运行的 `node` / `tsx` / `ts-node`。详见[测试](/zh/guide/testing)和[覆盖率](/zh/guide/coverage)。
|
||||
Jest、Vitest、Playwright Test、`node --test` 和 Mocha 的输出会解析成测试树,支持 **重新运行失败的测试**。Playwright 运行时使用它的 `list` 报告器(配置里指定了其他报告器时除外);从行号栏运行单个测试时按行号选择(`file:line`),有多个 project 的运行会在文件下按 project 分组。`node --test` 运行时,IDE 通过 `NODE_OPTIONS` 在 `spec` 旁加上自己的报告器(脚本自己指定了 `--test-reporter` 时不显示测试树);单个测试和重新运行按完整名称选择(`--test-name-pattern`)。Mocha 运行保留它自己的报告器,并通过 `NODE_OPTIONS` 加载 IDE 的钩子,逐个报告测试及其所在行;单个测试和重新运行使用 `--grep`,在用 Mocha 或 `node --test` 测试的项目里,`test/` 目录下的测试不论文件名都有行号栏图标。**使用覆盖率运行** 支持调用 `vitest` 或 `jest` 的脚本(Vitest 需要 `@vitest/coverage-v8` 之类的覆盖率 provider,缺失时 IDE 会提示添加),以及通过 `c8` 运行的 `node` / `tsx` / `ts-node`。详见[测试](/zh/guide/testing)和[覆盖率](/zh/guide/coverage)。
|
||||
|
||||
## 调试
|
||||
|
||||
|
||||
@@ -254,14 +254,14 @@ register_plugin!(MyPlugin, run_target_validation);
|
||||
|
||||
## 运行程序
|
||||
|
||||
| 函数 | 作用 |
|
||||
| ------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------- |
|
||||
| `Project::run_process(program, &args, stdin)` | 在项目根目录运行已固定的程序并等待结束:`{ status, stdout, stderr }`,各 4 MiB。 |
|
||||
| `host::run_command(&Command, Some(&project), stdin)` | API 1.3:同上,可用 `Command::env` 追加环境变量。 |
|
||||
| `host::run_captured(&Command, Some(&project), stdin, options)` | API 1.15:可配置输出上限(每个流最高 128 MiB),stdout 或 stderr 溢出时明确报错。 |
|
||||
| `host::start(&Command, Some(&project))` | API 1.3:保持运行的 `Child`:`poll`、`write`、`close_stdin`、`wait`、`kill`。最多 8 个。 |
|
||||
| `host::start_stream(&Command, Some(&project), options)` | API 1.15:基于管道背压的有界无损流式传输,超出总预算时明确报错并终止进程。 |
|
||||
| `host::open_terminal(title, program, &args)` | 运行该程序的终端标签页(见 [视图](/zh/plugins/guides/views))。 |
|
||||
| 函数 | 作用 |
|
||||
| -------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
|
||||
| `Project::run_process(program, &args, stdin)` | 在项目根目录运行已固定的程序并等待结束:`{ status, stdout, stderr }`,各 4 MiB。 |
|
||||
| `host::run_command(&Command, Some(&project), stdin)` | API 1.3:同上,可用 `Command::env` 追加环境变量。 |
|
||||
| `host::run_captured(&Command, Some(&project), stdin, options)` | API 1.15:可配置输出上限(每个流最高 128 MiB),stdout 或 stderr 溢出时明确报错。 |
|
||||
| `host::start(&Command, Some(&project))` | API 1.3:保持运行的 `Child`:`poll`、`write`、`close_stdin`、`wait`、`kill`。最多 8 个。 |
|
||||
| `host::start_stream(&Command, Some(&project), options)` | API 1.15:基于管道背压的有界无损流式传输,超出总预算时明确报错并终止进程。 |
|
||||
| `host::open_terminal(title, program, &args)` | 运行该程序的终端标签页(见 [视图](/zh/plugins/guides/views))。 |
|
||||
|
||||
```rust
|
||||
use openidea_plugin::host::{self, Command};
|
||||
|
||||
@@ -55,7 +55,7 @@ exclude = ["**/.git", "**/node_modules", "**/target", "**/dist"]
|
||||
| 插件 | 插件 |
|
||||
| 版本控制 | 提交;确认;目录映射;问题导航;日志;搁置;Git;GitHub |
|
||||
| 构建、执行、部署 | CMake;Gradle;Maven;控制台;调试器(数据视图、单步执行);Python 调试器;运行/调试;运行目标;部署(选项) |
|
||||
| 语言和框架 | 语言服务器;Go(构建标签、Go 模块);Java;Markdown;Node.js;PHP;Python 解释器;Prettier;oxfmt;Ruff;Ruby;Rust;TypeScript |
|
||||
| 语言和框架 | 语言服务器;Go(构建标签、Go 模块);Java;Markdown;Node.js;PHP;Python 解释器;Prettier;oxfmt;Biome;Ruff;Ruby;Rust;TypeScript |
|
||||
| 工具 | 智能体(聊天);终端;保存时操作;外部工具;SSH 配置;MCP 服务器 |
|
||||
| 安全 | 项目信任 |
|
||||
|
||||
|
||||
@@ -73,6 +73,8 @@ const initialSkills: AgentSkillState[] = [
|
||||
alsoIn: ["claudeWorkspace"],
|
||||
userInvocable: true,
|
||||
disableModelInvocation: false,
|
||||
contextFork: true,
|
||||
paths: ["src/**/*.tsx", "e2e/*.spec.ts"],
|
||||
valid: true,
|
||||
warnings: [],
|
||||
},
|
||||
@@ -326,6 +328,8 @@ test("manages multi-level skills in Settings and per-session overrides via Compo
|
||||
const sessionPopup = page.getByRole("dialog", { name: "Session Skills" });
|
||||
await expect(sessionPopup).toBeVisible();
|
||||
await expect(sessionPopup).toContainText("verify");
|
||||
await expect(sessionPopup).toContainText("fork");
|
||||
await expect(sessionPopup).toContainText("paths");
|
||||
await expect(sessionPopup).toContainText("impeccable");
|
||||
await expect(sessionPopup).toContainText("Plugins");
|
||||
await expect(sessionPopup).toContainText("release-notes");
|
||||
@@ -352,9 +356,12 @@ test("manages multi-level skills in Settings and per-session overrides via Compo
|
||||
await expect(settingsDialog).toBeVisible();
|
||||
await expect(settingsDialog.getByRole("heading", { name: "Skills" })).toBeVisible();
|
||||
await expect(settingsDialog.getByTitle(".claude/skills").first()).toHaveText("Claude Code");
|
||||
await expect(settingsDialog.getByText("context: fork")).toBeVisible();
|
||||
await expect(settingsDialog.getByText("paths (2)")).toBeVisible();
|
||||
|
||||
await settingsDialog.getByRole("button", { name: /^verify/ }).click();
|
||||
await expect(settingsDialog.getByText("Claude Code (.claude/skills)")).toBeVisible();
|
||||
await expect(settingsDialog.getByText("src/**/*.tsx, e2e/*.spec.ts")).toBeVisible();
|
||||
await expect(settingsDialog.getByText("SKILL.md is valid")).toBeVisible();
|
||||
|
||||
await settingsDialog.getByRole("tab", { name: /Plugins/ }).click();
|
||||
|
||||
@@ -62,59 +62,3 @@ test("keeps values and their full-value action readable in a narrow debugger", a
|
||||
.poll(() => routing.getByText(routingValue, { exact: true }).evaluate((el) => el.scrollWidth <= el.clientWidth + 1))
|
||||
.toBe(true);
|
||||
});
|
||||
|
||||
test("keeps a decimal value legible beside a long runtime type", async ({ workbench: page }) => {
|
||||
const name = "dailySettlementTotal";
|
||||
const type = "ExactSettlementAmountForCrossBorderReconciliation";
|
||||
const value = "12486245.8067";
|
||||
const countName = "pendingInvoices";
|
||||
await page.setViewportSize({ width: 1100, height: 720 });
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(
|
||||
async ({ name, type, value, countName }) => {
|
||||
const debugModule = "/src/features/debugger/state.ts";
|
||||
const layoutModule = "/src/workbench/toolwindows/store.ts";
|
||||
const serviceModule = "/src/workbench/contributions.ts";
|
||||
const { adoptSession } = await import(/* @vite-ignore */ debugModule);
|
||||
const { moveToolWindow, setToolWindowSize } = await import(/* @vite-ignore */ layoutModule);
|
||||
const { toolWindowService } = await import(/* @vite-ignore */ serviceModule);
|
||||
window.__ipc.handlers.debug_scopes = () => [{ name: "Locals", variablesReference: 100, expensive: false }];
|
||||
window.__ipc.handlers.debug_variables = () => [
|
||||
{ name, value, typeName: type, variablesReference: 0, evaluateName: name },
|
||||
{ name: countName, value: "327", typeName: "int", variablesReference: 0, evaluateName: countName },
|
||||
];
|
||||
adoptSession(92, {
|
||||
name: "Settlement",
|
||||
adapter: "debugpy",
|
||||
status: "paused",
|
||||
selectedFrame: 11,
|
||||
frames: [{ id: 11, name: "settle", path: null, line: 0, column: 0, presentationHint: null }],
|
||||
});
|
||||
moveToolWindow("debug", "right");
|
||||
setToolWindowSize("right", 280);
|
||||
toolWindowService().show("debug", true);
|
||||
},
|
||||
{ name, type, value, countName },
|
||||
);
|
||||
const debug = page.getByRole("region", { name: "Debug", exact: true });
|
||||
await debug.getByRole("tab", { name: "Threads & Variables", exact: true }).click();
|
||||
const variable = debug.getByRole("treeitem").filter({ hasText: name });
|
||||
const amount = variable.getByText(value, { exact: true });
|
||||
const annotation = variable.getByTitle(`{${type}}`, { exact: true });
|
||||
await expect(amount).toBeVisible();
|
||||
await expect.poll(() => amount.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
|
||||
await expect(variable.getByTitle("Show", { exact: true })).toBeHidden();
|
||||
await expect(annotation).toBeVisible();
|
||||
|
||||
const shortValueName = debug.getByText(countName, { exact: true });
|
||||
await expect.poll(() => shortValueName.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
|
||||
|
||||
await page.setViewportSize({ width: 1440, height: 760 });
|
||||
await page.evaluate(async () => {
|
||||
const layoutModule = "/src/workbench/toolwindows/store.ts";
|
||||
const { moveToolWindow, setToolWindowSize } = await import(/* @vite-ignore */ layoutModule);
|
||||
moveToolWindow("debug", "bottom");
|
||||
setToolWindowSize("bottom", 310);
|
||||
});
|
||||
await expect.poll(() => annotation.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
|
||||
});
|
||||
+1
-1
@@ -526,7 +526,7 @@ test("Markdown preview keeps following find and edits after scrolling the source
|
||||
await content.focus();
|
||||
await page.keyboard.press("Meta+a");
|
||||
await page.keyboard.insertText("- **$`v_0`$ Flat wings.**");
|
||||
await expect(preview.locator("strong .katex annotation")).toHaveText("v_0");
|
||||
await expect(preview.locator("strong [data-math-svg] > svg")).toHaveAttribute("aria-label", "v_0");
|
||||
});
|
||||
|
||||
test("Markdown preview aligns Mermaid diagrams to their container align attribute", async ({ workbench: page }) => {
|
||||
|
||||
@@ -320,3 +320,88 @@ test("the Paths filter replaces the repository filter and can be cleared from ov
|
||||
await picker.getByRole("button", { name: "OK" }).click();
|
||||
await expect(firstCommit.getByText("Commit 1", { exact: true })).toBeVisible();
|
||||
});
|
||||
|
||||
test("the Git Log path tree resizes and keeps selected paths reachable in a short window", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 1000, height: 720 });
|
||||
const longName = "reconcile-invoices-and-export-the-complete-quarterly-settlement-audit.ts";
|
||||
await page.evaluate(async (longName) => {
|
||||
const logPath = "/src/features/vcs/logStore.ts";
|
||||
const optionsPath = "/src/features/vcs/logOptions.ts";
|
||||
const { setLogFilters } = await import(/* @vite-ignore */ logPath);
|
||||
const { setLogOptions } = await import(/* @vite-ignore */ optionsPath);
|
||||
const root = "/dev/acme-api";
|
||||
const selected = Array.from({ length: 9 }, (_, i) => `entry-${i + 1}.ts`);
|
||||
const entry = (name: string, kind: "dir" | "file") => ({
|
||||
name,
|
||||
path: `${root}/${name}`,
|
||||
kind,
|
||||
size: 0,
|
||||
mtimeMs: 0,
|
||||
});
|
||||
window.__ipc.handlers.fs_read_dir = ({ path }) =>
|
||||
path === root
|
||||
? [entry("src", "dir"), entry(longName, "file"), ...selected.map((name) => entry(name, "file"))]
|
||||
: [];
|
||||
setLogOptions({ showBranches: false, showDetails: false });
|
||||
setLogFilters({ paths: selected.map((name) => `${root}/${name}`) });
|
||||
}, longName);
|
||||
|
||||
const toolbar = page.getByRole("toolbar", { name: "Log filters" });
|
||||
const openTree = async () => {
|
||||
await toolbar.getByRole("button", { name: "More Filters" }).click();
|
||||
await page.getByRole("menuitem", { name: /^Paths:/ }).click();
|
||||
await page.getByRole("menuitem", { name: "Select in Tree…" }).click();
|
||||
};
|
||||
await openTree();
|
||||
const dialog = page.getByRole("dialog", { name: "Filter by Paths" });
|
||||
const tree = dialog.getByRole("tree", { name: "Files and folders" });
|
||||
const resize = dialog.locator('[class*="_resizeGrip_"]');
|
||||
await expect(tree).toBeVisible();
|
||||
await expect(resize).toBeVisible();
|
||||
await tree.getByRole("treeitem", { name: "acme-api", exact: true }).locator("[data-tree-toggle]").click();
|
||||
const folder = tree.getByRole("checkbox", { name: "src", exact: true });
|
||||
const file = tree.getByRole("checkbox", { name: longName, exact: true });
|
||||
await expect(folder.locator("xpath=ancestor::label").locator("svg")).toHaveCount(1);
|
||||
const title = file.locator("xpath=ancestor::label").getByTitle(longName);
|
||||
await expect(title).toHaveCSS("font-size", "13px");
|
||||
await expect(title).toHaveCSS("text-overflow", "ellipsis");
|
||||
|
||||
const originalTreeHeight = (await tree.boundingBox())!.height;
|
||||
const grip = (await resize.boundingBox())!;
|
||||
const x = grip.x + grip.width / 2;
|
||||
const y = grip.y + grip.height / 2;
|
||||
await page.mouse.move(x, y);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(x + 30, y + 65, { steps: 5 });
|
||||
await page.mouse.up();
|
||||
await expect.poll(async () => (await tree.boundingBox())!.height).toBeGreaterThan(originalTreeHeight + 40);
|
||||
|
||||
await dialog.getByRole("button", { name: "Cancel" }).click();
|
||||
await page.setViewportSize({ width: 420, height: 325 });
|
||||
await openTree();
|
||||
await tree.getByRole("treeitem", { name: "acme-api", exact: true }).locator("[data-tree-toggle]").click();
|
||||
const selected = dialog.getByRole("group", { name: "Selected paths" });
|
||||
await expect(selected).toBeVisible();
|
||||
await expect.poll(() => selected.evaluate((node) => node.scrollHeight - node.clientHeight)).toBeGreaterThan(1);
|
||||
await expect
|
||||
.poll(() => dialog.locator("[data-dialog-body]").evaluate((node) => node.scrollHeight - node.clientHeight))
|
||||
.toBeLessThanOrEqual(1);
|
||||
await expect.poll(() => title.evaluate((node) => node.scrollWidth - node.clientWidth)).toBeGreaterThan(1);
|
||||
const removed = selected.getByRole("checkbox", { name: "acme-api/entry-9.ts", exact: true });
|
||||
await removed.click();
|
||||
await expect(removed).toHaveCount(0);
|
||||
await file.check();
|
||||
await expect(selected.getByRole("checkbox", { name: `acme-api/${longName}`, exact: true })).toBeChecked();
|
||||
await expect(dialog.getByRole("button", { name: "OK" })).toBeInViewport({ ratio: 1 });
|
||||
await dialog.getByRole("button", { name: "OK" }).click();
|
||||
await expect(dialog).toBeHidden();
|
||||
const applied = await page.evaluate(async () => {
|
||||
const path = "/src/features/vcs/logStore.ts";
|
||||
const { useGitLog } = await import(/* @vite-ignore */ path);
|
||||
return useGitLog.getState().filters.paths;
|
||||
});
|
||||
expect(applied).toContain(`/dev/acme-api/${longName}`);
|
||||
expect(applied).not.toContain("/dev/acme-api/entry-9.ts");
|
||||
});
|
||||
+4
-1
@@ -11,6 +11,7 @@ something to show.
|
||||
| `ts-app/` | Node 22+, pnpm/npm | `pnpm start` | `pnpm test` (vitest) | `OPENIDEA_FAIL=1 pnpm test` | unused function in `src/index.ts` |
|
||||
| `playwright-app/` | Node 22+, npm (Playwright Test, no browser needed) | — | `npm test` | `OPENIDEA_FAIL=1 npm test` | unused function in `src/checkout.ts` |
|
||||
| `node-test-app/` | Node 22+, npm (no dependencies) | — | `npm test` (node:test) | `OPENIDEA_FAIL=1 npm test` | unused constant in `src/inventory.js` |
|
||||
| `mocha-app/` | Node 22+, npm | — | `npm test` (Mocha) | `OPENIDEA_FAIL=1 npm test` | unused constant in `src/pricing.js` |
|
||||
| `python-app/` | Python 3.10+, pytest | `python -m tasks.cli` (from `src/`) | `pytest` | `OPENIDEA_FAIL=1 pytest` | unused imports in `models.py` |
|
||||
| `go-app/` | Go 1.22+ | `go run ./cmd/server` | `go test ./...` | `OPENIDEA_FAIL=1 go test ./...` | unused `fmt.Sprintf` result in `internal/store/store.go` |
|
||||
| `kotlin-gradle/` | JDK 21, Gradle 8 (no wrapper) | `gradle run` | `gradle test` | `gradle test -PopenideaFail` | unused variable in `App.kt` |
|
||||
@@ -18,7 +19,9 @@ something to show.
|
||||
| `c-app/` | gcc / g++ 12+, make, GDB 14+ | `make all` | — | — | — |
|
||||
| `php-app/` | PHP 8.5, Composer | `composer quote` | `vendor/bin/pest` | `OPENIDEA_FAIL=1 vendor/bin/pest` | unused variable in `ThresholdCustoms.php` |
|
||||
| `django-app/` | Python 3.10+, Django 5.2+ | `python manage.py runserver` | `python manage.py test` | `OPENIDEA_FAIL=1 python manage.py test` | unused import in `shop/views.py` |
|
||||
| `tailwind-app/` | Node 22+, pnpm/npm, Tailwind CSS 4, React | `pnpm dev` | — | — | `flex` conflicting with `block` in `src/App.tsx` |
|
||||
| `zig-app/` | Zig 0.17 | `zig build run` | `zig build test` | — | — |
|
||||
| `biome-app/` | Node 22+, `@biomejs/biome` (`npm install`) | `npm start` | — | — | `let` never reassigned, `==` and a duplicate CSS `color` (Biome) |
|
||||
| `polyglot/` | Go, TS, Python, C, shell, SQL, TOML/YAML/JSON, proto, Terraform | `make` | `make test` | — | unused variable in `native/hash.c` |
|
||||
|
||||
The fixtures are standalone: `rust-app` declares its own `[workspace]` and
|
||||
@@ -41,7 +44,7 @@ git init -q && git add -A && git commit -qm "initial" # for the VCS checks
|
||||
```
|
||||
|
||||
Then open the folder with **File › Open…** (`⌘⇧⌥O`) or from the Welcome screen.
|
||||
For `ts-app` / `playwright-app` / `polyglot/web` run `pnpm install` first; for `python-app` create a
|
||||
For `ts-app` / `playwright-app` / `mocha-app` / `polyglot/web` run `pnpm install` first (`npm install` for `biome-app`); for `python-app` create a
|
||||
venv (`python3 -m venv .venv && .venv/bin/pip install -e '.[dev]'`); for
|
||||
`php-app` run `composer install` (debugging it needs Xdebug in the PHP on `PATH`).
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"$schema": "https://biomejs.dev/schemas/2.6.8/schema.json",
|
||||
"files": {
|
||||
"includes": ["**", "!node_modules"]
|
||||
},
|
||||
"formatter": {
|
||||
"enabled": true,
|
||||
"indentStyle": "space",
|
||||
"indentWidth": 2,
|
||||
"lineWidth": 100
|
||||
},
|
||||
"javascript": {
|
||||
"formatter": {
|
||||
"quoteStyle": "single"
|
||||
}
|
||||
},
|
||||
"linter": {
|
||||
"enabled": true,
|
||||
"rules": {
|
||||
"preset": "recommended",
|
||||
"style": {
|
||||
"useConst": "error",
|
||||
"useTemplate": "warn"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "openidea-fixture-biome",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"description": "OpenIDEA QA fixture: Biome lint diagnostics, fixes and formatting",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "node --experimental-strip-types src/index.ts",
|
||||
"lint": "biome lint",
|
||||
"format": "biome format --write",
|
||||
"check": "biome check"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "2.6.8"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
export interface Item {
|
||||
name: string
|
||||
price: number
|
||||
quantity: number
|
||||
}
|
||||
|
||||
export function total(items: Item[]): number {
|
||||
let sum = 0
|
||||
for (const item of items) sum += item.price * item.quantity
|
||||
return sum
|
||||
}
|
||||
|
||||
// Intentional Biome problems: `let` never reassigned (useConst, safe fix),
|
||||
// string concatenation (useTemplate) and `==` (noDoubleEquals).
|
||||
export function describe(items: Item[]): string {
|
||||
let label = "Cart: " + items.length + " items"
|
||||
if (items.length == 0) {
|
||||
return "Cart is empty"
|
||||
}
|
||||
return label
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
{ "currency": "EUR",
|
||||
"discounts": [ 5, 10,15 ] }
|
||||
@@ -0,0 +1,9 @@
|
||||
import { describe, total, type Item } from "./cart.ts"
|
||||
|
||||
const items: Item[] = [
|
||||
{ name: "Notebook", price: 4.5, quantity: 2 },
|
||||
{ name: "Pen", price: 1.25, quantity: 4 },
|
||||
]
|
||||
|
||||
// Set a breakpoint here
|
||||
console.log(describe(items), "-", total(items).toFixed(2))
|
||||
@@ -0,0 +1,6 @@
|
||||
/* Intentional Biome problem: `color` is declared twice (noDuplicateProperties). */
|
||||
.cart {
|
||||
color: #333;
|
||||
padding:4px 8px;
|
||||
color: #444;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
node_modules
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "openidea-fixture-pricing",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"description": "OpenIDEA QA fixture: Mocha specs for a small pricing module",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "^10.8.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
export function withTax(net, rate) {
|
||||
if (rate < 0) throw new RangeError("tax rate must not be negative");
|
||||
return Math.round(net * (1 + rate) * 100) / 100;
|
||||
}
|
||||
|
||||
export function bulkDiscount(quantity) {
|
||||
// TODO: read the tiers from the catalog instead of hard-coding them
|
||||
if (quantity >= 100) return 0.15;
|
||||
if (quantity >= 10) return 0.05;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// An intentional warning: never used.
|
||||
const CURRENCY = "EUR";
|
||||
@@ -0,0 +1,29 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { bulkDiscount, withTax } from "../src/pricing.js";
|
||||
|
||||
describe("pricing", function () {
|
||||
describe("withTax", function () {
|
||||
it("adds the rate", function () {
|
||||
assert.equal(withTax(100, 0.2), 120);
|
||||
});
|
||||
|
||||
it("rejects a negative rate", function () {
|
||||
assert.throws(() => withTax(100, -0.1), RangeError);
|
||||
});
|
||||
});
|
||||
|
||||
describe("bulkDiscount", function () {
|
||||
it("has no discount for a few items", function () {
|
||||
assert.equal(bulkDiscount(3), 0);
|
||||
});
|
||||
|
||||
it("discounts large orders", function () {
|
||||
assert.equal(bulkDiscount(250), 0.15);
|
||||
});
|
||||
});
|
||||
|
||||
it("intentionally fails (set OPENIDEA_FAIL=1)", function () {
|
||||
if (!process.env.OPENIDEA_FAIL) this.skip();
|
||||
assert.equal(withTax(10, 0.1), 11.5);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,2 @@
|
||||
node_modules
|
||||
dist
|
||||
@@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Tailwind fixture</title>
|
||||
<link rel="stylesheet" href="/src/app.css" />
|
||||
</head>
|
||||
<body class="min-h-screen bg-slate-50 text-slate-900">
|
||||
<div id="root" class="mx-auto max-w-2xl p-8"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "openidea-fixture-tailwind",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"description": "OpenIDEA QA fixture: a Tailwind CSS 4 page with React",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc -p . && vite build"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "^19.0.0",
|
||||
"react-dom": "^19.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/vite": "^4.1.0",
|
||||
"@types/react": "^19.0.0",
|
||||
"@types/react-dom": "^19.0.0",
|
||||
"@vitejs/plugin-react": "^5.0.0",
|
||||
"tailwindcss": "^4.1.0",
|
||||
"typescript": "^5.6.0",
|
||||
"vite": "^7.0.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { useState } from "react";
|
||||
|
||||
export function App() {
|
||||
const [count, setCount] = useState(0);
|
||||
return (
|
||||
<main className="flex flex-col gap-4 rounded-xl bg-white p-6 shadow-sm">
|
||||
<h1 className="text-2xl font-semibold text-brand-700">Tailwind CSS fixture</h1>
|
||||
{/* Intentional warning: `flex` and `block` both set `display`. */}
|
||||
<p className="flex block text-slate-600">Clicked {count} times.</p>
|
||||
<button type="button" className="btn self-start" onClick={() => setCount(count + 1)}>
|
||||
Click me
|
||||
</button>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
@import "tailwindcss";
|
||||
|
||||
@theme {
|
||||
--color-brand-500: oklch(0.62 0.19 259);
|
||||
--color-brand-700: oklch(0.49 0.17 262);
|
||||
}
|
||||
|
||||
.btn {
|
||||
@apply rounded-md bg-brand-500 px-4 py-2 font-medium text-white hover:bg-brand-700;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { StrictMode } from "react";
|
||||
import { createRoot } from "react-dom/client";
|
||||
import { App } from "./App";
|
||||
|
||||
createRoot(document.getElementById("root")!).render(
|
||||
<StrictMode>
|
||||
<App />
|
||||
</StrictMode>,
|
||||
);
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"jsx": "react-jsx",
|
||||
"strict": true,
|
||||
"noEmit": true,
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"include": ["src", "vite.config.ts"]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import tailwindcss from "@tailwindcss/vite";
|
||||
import react from "@vitejs/plugin-react";
|
||||
import { defineConfig } from "vite";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react(), tailwindcss()],
|
||||
});
|
||||
@@ -45,6 +45,17 @@ codeAction = { disableRuleComment = { enable = true, location = "separateLine" }
|
||||
# No `rules`: an empty list there means no rule gets fixed.
|
||||
codeActionOnSave = { mode = "all" }
|
||||
|
||||
# Tailwind CSS: class completion, hover and diagnostics, only in a project that uses Tailwind
|
||||
# (`tailwind.config.*` or `tailwindcss` in package.json). After the language's own servers,
|
||||
# which answer hover first.
|
||||
[[language-servers]]
|
||||
name = "tailwindcss-language-server"
|
||||
command = "tailwindcss-language-server"
|
||||
args = ["--stdio"]
|
||||
root-markers = ["tailwind.config.*", "package.json#dependencies.tailwindcss", "package.json#devDependencies.tailwindcss"]
|
||||
require-root-marker = true
|
||||
install-hint = "npm i -g @tailwindcss/language-server"
|
||||
|
||||
# Components run in the browser: breakpoints in them are hit by a JavaScript Debug configuration.
|
||||
[debugger]
|
||||
adapter = "js-debug"
|
||||
|
||||
@@ -13,3 +13,25 @@ command = "vscode-css-language-server"
|
||||
args = ["--stdio"]
|
||||
initialization-options = { provideFormatter = true, css = {}, scss = {}, less = {} }
|
||||
install-hint = "npm i -g vscode-langservers-extracted"
|
||||
|
||||
# Biome: lint diagnostics, quick fixes and fix-all below a Biome configuration or installation,
|
||||
# from the project's own biome. Formatting is Reformat Code's (Settings › Biome).
|
||||
[[language-servers]]
|
||||
name = "biome"
|
||||
command = "biome"
|
||||
args = ["lsp-proxy"]
|
||||
root-markers = ["biome.json", "biome.jsonc", "node_modules/@biomejs/biome"]
|
||||
require-root-marker = true
|
||||
features = ["code-action", "diagnostics"]
|
||||
install-hint = "npm i -D @biomejs/biome"
|
||||
|
||||
# Tailwind CSS: class completion, hover and diagnostics, only in a project that uses Tailwind
|
||||
# (`tailwind.config.*` or `tailwindcss` in package.json). After the language's own servers,
|
||||
# which answer hover first.
|
||||
[[language-servers]]
|
||||
name = "tailwindcss-language-server"
|
||||
command = "tailwindcss-language-server"
|
||||
args = ["--stdio"]
|
||||
root-markers = ["tailwind.config.*", "package.json#dependencies.tailwindcss", "package.json#devDependencies.tailwindcss"]
|
||||
require-root-marker = true
|
||||
install-hint = "npm i -g @tailwindcss/language-server"
|
||||
@@ -12,3 +12,14 @@ command = "graphql-lsp"
|
||||
args = ["server", "-m", "stream"]
|
||||
root-markers = [".graphqlrc", ".graphqlrc.yml", ".graphqlrc.yaml", ".graphqlrc.json", "graphql.config.js", "graphql.config.ts", "graphql.config.yml", "graphql.config.yaml", "graphql.config.json"]
|
||||
install-hint = "npm i -g graphql-language-service-cli"
|
||||
|
||||
# Biome: lint diagnostics, quick fixes and fix-all below a Biome configuration or installation,
|
||||
# from the project's own biome. Formatting is Reformat Code's (Settings › Biome).
|
||||
[[language-servers]]
|
||||
name = "biome"
|
||||
command = "biome"
|
||||
args = ["lsp-proxy"]
|
||||
root-markers = ["biome.json", "biome.jsonc", "node_modules/@biomejs/biome"]
|
||||
require-root-marker = true
|
||||
features = ["code-action", "diagnostics"]
|
||||
install-hint = "npm i -D @biomejs/biome"
|
||||
@@ -41,6 +41,17 @@ args = ["--stdio"]
|
||||
initialization-options = { provideFormatter = true, embeddedLanguages = { css = true, javascript = true } }
|
||||
install-hint = "npm i -g vscode-langservers-extracted"
|
||||
|
||||
# Tailwind CSS: class completion, hover and diagnostics, only in a project that uses Tailwind
|
||||
# (`tailwind.config.*` or `tailwindcss` in package.json). After the language's own servers,
|
||||
# which answer hover first.
|
||||
[[language-servers]]
|
||||
name = "tailwindcss-language-server"
|
||||
command = "tailwindcss-language-server"
|
||||
args = ["--stdio"]
|
||||
root-markers = ["tailwind.config.*", "package.json#dependencies.tailwindcss", "package.json#devDependencies.tailwindcss"]
|
||||
require-root-marker = true
|
||||
install-hint = "npm i -g @tailwindcss/language-server"
|
||||
|
||||
# Scripts in a page run in the browser: breakpoints in them are hit by a JavaScript Debug configuration.
|
||||
[debugger]
|
||||
adapter = "js-debug"
|
||||
|
||||
@@ -106,6 +106,28 @@ codeAction = { disableRuleComment = { enable = true, location = "separateLine" }
|
||||
# No `rules`: an empty list there means no rule gets fixed.
|
||||
codeActionOnSave = { mode = "all" }
|
||||
|
||||
# Biome: lint diagnostics, quick fixes and fix-all below a Biome configuration or installation,
|
||||
# from the project's own biome. Formatting is Reformat Code's (Settings › Biome).
|
||||
[[language-servers]]
|
||||
name = "biome"
|
||||
command = "biome"
|
||||
args = ["lsp-proxy"]
|
||||
root-markers = ["biome.json", "biome.jsonc", "node_modules/@biomejs/biome"]
|
||||
require-root-marker = true
|
||||
features = ["code-action", "diagnostics"]
|
||||
install-hint = "npm i -D @biomejs/biome"
|
||||
|
||||
# Tailwind CSS: class completion, hover and diagnostics, only in a project that uses Tailwind
|
||||
# (`tailwind.config.*` or `tailwindcss` in package.json). After the language's own servers,
|
||||
# which answer hover first.
|
||||
[[language-servers]]
|
||||
name = "tailwindcss-language-server"
|
||||
command = "tailwindcss-language-server"
|
||||
args = ["--stdio"]
|
||||
root-markers = ["tailwind.config.*", "package.json#dependencies.tailwindcss", "package.json#devDependencies.tailwindcss"]
|
||||
require-root-marker = true
|
||||
install-hint = "npm i -g @tailwindcss/language-server"
|
||||
|
||||
[debugger]
|
||||
adapter = "js-debug"
|
||||
command = "js-debug-adapter"
|
||||
|
||||
@@ -109,6 +109,28 @@ codeAction = { disableRuleComment = { enable = true, location = "separateLine" }
|
||||
# No `rules`: an empty list there means no rule gets fixed.
|
||||
codeActionOnSave = { mode = "all" }
|
||||
|
||||
# Biome: lint diagnostics, quick fixes and fix-all below a Biome configuration or installation,
|
||||
# from the project's own biome. Formatting is Reformat Code's (Settings › Biome).
|
||||
[[language-servers]]
|
||||
name = "biome"
|
||||
command = "biome"
|
||||
args = ["lsp-proxy"]
|
||||
root-markers = ["biome.json", "biome.jsonc", "node_modules/@biomejs/biome"]
|
||||
require-root-marker = true
|
||||
features = ["code-action", "diagnostics"]
|
||||
install-hint = "npm i -D @biomejs/biome"
|
||||
|
||||
# Tailwind CSS: class completion, hover and diagnostics, only in a project that uses Tailwind
|
||||
# (`tailwind.config.*` or `tailwindcss` in package.json). After the language's own servers,
|
||||
# which answer hover first.
|
||||
[[language-servers]]
|
||||
name = "tailwindcss-language-server"
|
||||
command = "tailwindcss-language-server"
|
||||
args = ["--stdio"]
|
||||
root-markers = ["tailwind.config.*", "package.json#dependencies.tailwindcss", "package.json#devDependencies.tailwindcss"]
|
||||
require-root-marker = true
|
||||
install-hint = "npm i -g @tailwindcss/language-server"
|
||||
|
||||
[debugger]
|
||||
adapter = "js-debug"
|
||||
command = "js-debug-adapter"
|
||||
|
||||
@@ -58,3 +58,14 @@ url = "https://swc.rs/schema.json"
|
||||
[[language-servers.settings.json.schemas]]
|
||||
fileMatch = ["composer.json"]
|
||||
url = "https://getcomposer.org/schema.json"
|
||||
|
||||
# Biome: lint diagnostics, quick fixes and fix-all below a Biome configuration or installation,
|
||||
# from the project's own biome. Formatting is Reformat Code's (Settings › Biome).
|
||||
[[language-servers]]
|
||||
name = "biome"
|
||||
command = "biome"
|
||||
args = ["lsp-proxy"]
|
||||
root-markers = ["biome.json", "biome.jsonc", "node_modules/@biomejs/biome"]
|
||||
require-root-marker = true
|
||||
features = ["code-action", "diagnostics"]
|
||||
install-hint = "npm i -D @biomejs/biome"
|
||||
@@ -60,3 +60,14 @@ url = "https://swc.rs/schema.json"
|
||||
[[language-servers.settings.json.schemas]]
|
||||
fileMatch = ["composer.json"]
|
||||
url = "https://getcomposer.org/schema.json"
|
||||
|
||||
# Biome: lint diagnostics, quick fixes and fix-all below a Biome configuration or installation,
|
||||
# from the project's own biome. Formatting is Reformat Code's (Settings › Biome).
|
||||
[[language-servers]]
|
||||
name = "biome"
|
||||
command = "biome"
|
||||
args = ["lsp-proxy"]
|
||||
root-markers = ["biome.json", "biome.jsonc", "node_modules/@biomejs/biome"]
|
||||
require-root-marker = true
|
||||
features = ["code-action", "diagnostics"]
|
||||
install-hint = "npm i -D @biomejs/biome"
|
||||
@@ -51,6 +51,17 @@ codeAction = { disableRuleComment = { enable = true, location = "separateLine" }
|
||||
# No `rules`: an empty list there means no rule gets fixed.
|
||||
codeActionOnSave = { mode = "all" }
|
||||
|
||||
# Tailwind CSS: class completion, hover and diagnostics, only in a project that uses Tailwind
|
||||
# (`tailwind.config.*` or `tailwindcss` in package.json). After the language's own servers,
|
||||
# which answer hover first.
|
||||
[[language-servers]]
|
||||
name = "tailwindcss-language-server"
|
||||
command = "tailwindcss-language-server"
|
||||
args = ["--stdio"]
|
||||
root-markers = ["tailwind.config.*", "package.json#dependencies.tailwindcss", "package.json#devDependencies.tailwindcss"]
|
||||
require-root-marker = true
|
||||
install-hint = "npm i -g @tailwindcss/language-server"
|
||||
|
||||
# Components run in the browser: breakpoints in them are hit by a JavaScript Debug configuration.
|
||||
[debugger]
|
||||
adapter = "js-debug"
|
||||
|
||||
@@ -124,6 +124,28 @@ codeAction = { disableRuleComment = { enable = true, location = "separateLine" }
|
||||
# No `rules`: an empty list there means no rule gets fixed.
|
||||
codeActionOnSave = { mode = "all" }
|
||||
|
||||
# Biome: lint diagnostics, quick fixes and fix-all below a Biome configuration or installation,
|
||||
# from the project's own biome. Formatting is Reformat Code's (Settings › Biome).
|
||||
[[language-servers]]
|
||||
name = "biome"
|
||||
command = "biome"
|
||||
args = ["lsp-proxy"]
|
||||
root-markers = ["biome.json", "biome.jsonc", "node_modules/@biomejs/biome"]
|
||||
require-root-marker = true
|
||||
features = ["code-action", "diagnostics"]
|
||||
install-hint = "npm i -D @biomejs/biome"
|
||||
|
||||
# Tailwind CSS: class completion, hover and diagnostics, only in a project that uses Tailwind
|
||||
# (`tailwind.config.*` or `tailwindcss` in package.json). After the language's own servers,
|
||||
# which answer hover first.
|
||||
[[language-servers]]
|
||||
name = "tailwindcss-language-server"
|
||||
command = "tailwindcss-language-server"
|
||||
args = ["--stdio"]
|
||||
root-markers = ["tailwind.config.*", "package.json#dependencies.tailwindcss", "package.json#devDependencies.tailwindcss"]
|
||||
require-root-marker = true
|
||||
install-hint = "npm i -g @tailwindcss/language-server"
|
||||
|
||||
[debugger]
|
||||
adapter = "js-debug"
|
||||
command = "js-debug-adapter"
|
||||
|
||||
@@ -110,6 +110,28 @@ codeAction = { disableRuleComment = { enable = true, location = "separateLine" }
|
||||
# No `rules`: an empty list there means no rule gets fixed.
|
||||
codeActionOnSave = { mode = "all" }
|
||||
|
||||
# Biome: lint diagnostics, quick fixes and fix-all below a Biome configuration or installation,
|
||||
# from the project's own biome. Formatting is Reformat Code's (Settings › Biome).
|
||||
[[language-servers]]
|
||||
name = "biome"
|
||||
command = "biome"
|
||||
args = ["lsp-proxy"]
|
||||
root-markers = ["biome.json", "biome.jsonc", "node_modules/@biomejs/biome"]
|
||||
require-root-marker = true
|
||||
features = ["code-action", "diagnostics"]
|
||||
install-hint = "npm i -D @biomejs/biome"
|
||||
|
||||
# Tailwind CSS: class completion, hover and diagnostics, only in a project that uses Tailwind
|
||||
# (`tailwind.config.*` or `tailwindcss` in package.json). After the language's own servers,
|
||||
# which answer hover first.
|
||||
[[language-servers]]
|
||||
name = "tailwindcss-language-server"
|
||||
command = "tailwindcss-language-server"
|
||||
args = ["--stdio"]
|
||||
root-markers = ["tailwind.config.*", "package.json#dependencies.tailwindcss", "package.json#devDependencies.tailwindcss"]
|
||||
require-root-marker = true
|
||||
install-hint = "npm i -g @tailwindcss/language-server"
|
||||
|
||||
[debugger]
|
||||
adapter = "js-debug"
|
||||
command = "js-debug-adapter"
|
||||
|
||||
@@ -88,6 +88,17 @@ codeAction = { disableRuleComment = { enable = true, location = "separateLine" }
|
||||
# No `rules`: an empty list there means no rule gets fixed.
|
||||
codeActionOnSave = { mode = "all" }
|
||||
|
||||
# Tailwind CSS: class completion, hover and diagnostics, only in a project that uses Tailwind
|
||||
# (`tailwind.config.*` or `tailwindcss` in package.json). After the language's own servers,
|
||||
# which answer hover first.
|
||||
[[language-servers]]
|
||||
name = "tailwindcss-language-server"
|
||||
command = "tailwindcss-language-server"
|
||||
args = ["--stdio"]
|
||||
root-markers = ["tailwind.config.*", "package.json#dependencies.tailwindcss", "package.json#devDependencies.tailwindcss"]
|
||||
require-root-marker = true
|
||||
install-hint = "npm i -g @tailwindcss/language-server"
|
||||
|
||||
# Components run in the browser: breakpoints in them are hit by a JavaScript Debug configuration.
|
||||
[debugger]
|
||||
adapter = "js-debug"
|
||||
|
||||
@@ -29,6 +29,10 @@ description = "Build and install the local dogfood desktop app"
|
||||
depends = ["dogfood:build"]
|
||||
run = "pnpm dogfood:install --no-build"
|
||||
|
||||
[tasks."dogfood:remote"]
|
||||
description = "Build and install a local dogfood openidea-server on a configured SSH remote"
|
||||
run = "pnpm dogfood:remote"
|
||||
|
||||
[tasks.test]
|
||||
description = "Run the frontend and Rust workspace tests"
|
||||
run = ["pnpm test", "cargo test --workspace"]
|
||||
|
||||
+5
-1
@@ -35,7 +35,8 @@
|
||||
"eval": "node evals/run.ts",
|
||||
"release:prepare": "node scripts/release-prepare.ts",
|
||||
"dogfood:build": "node scripts/dogfood.ts build",
|
||||
"dogfood:install": "node scripts/dogfood.ts install"
|
||||
"dogfood:install": "node scripts/dogfood.ts install",
|
||||
"dogfood:remote": "node scripts/dogfood-remote.ts"
|
||||
},
|
||||
"simple-git-hooks": {
|
||||
"pre-commit": "pnpm lint-staged"
|
||||
@@ -69,6 +70,8 @@
|
||||
"@lezer/common": "^1.5.3",
|
||||
"@lezer/highlight": "^1.2.5",
|
||||
"@lezer/lr": "^1.4.11",
|
||||
"@mathjax/mathjax-tex-font": "4.1.3",
|
||||
"@mathjax/src": "4.1.3",
|
||||
"@plutojl/lang-julia": "^1.2.0",
|
||||
"@replit/codemirror-vim": "6.4.0",
|
||||
"@tanstack/react-virtual": "^3.14.21",
|
||||
@@ -94,6 +97,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@lezer/generator": "^1.8.1",
|
||||
"@noble/hashes": "^2.4.0",
|
||||
"@playwright/test": "^1.64.1",
|
||||
"@tauri-apps/cli": "^2",
|
||||
"@testing-library/jest-dom": "^7.0.1",
|
||||
|
||||
Generated
+170
-19
@@ -84,6 +84,12 @@ importers:
|
||||
'@lezer/lr':
|
||||
specifier: ^1.4.11
|
||||
version: 1.4.11(patch_hash=1561ac9e9bbbc302f48ea274ae33602e598a7833edaadd7031559c893c7853b8)
|
||||
'@mathjax/mathjax-tex-font':
|
||||
specifier: 4.1.3
|
||||
version: 4.1.3
|
||||
'@mathjax/src':
|
||||
specifier: 4.1.3
|
||||
version: 4.1.3
|
||||
'@plutojl/lang-julia':
|
||||
specifier: ^1.2.0
|
||||
version: 1.2.0
|
||||
@@ -154,6 +160,9 @@ importers:
|
||||
'@lezer/generator':
|
||||
specifier: ^1.8.1
|
||||
version: 1.8.1
|
||||
'@noble/hashes':
|
||||
specifier: ^2.4.0
|
||||
version: 2.4.0
|
||||
'@playwright/test':
|
||||
specifier: ^1.64.1
|
||||
version: 1.64.1
|
||||
@@ -162,7 +171,7 @@ importers:
|
||||
version: 2.12.3
|
||||
'@testing-library/jest-dom':
|
||||
specifier: ^7.0.1
|
||||
version: 7.0.1(@testing-library/[email protected])([email protected](@types/[email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])))
|
||||
version: 7.0.1(@testing-library/[email protected])([email protected](@types/[email protected])([email protected](@noble/[email protected]))([email protected](@types/[email protected])([email protected])([email protected])))
|
||||
'@testing-library/react':
|
||||
specifier: ^16.3.3
|
||||
version: 16.3.3(@testing-library/[email protected])(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])
|
||||
@@ -183,7 +192,7 @@ importers:
|
||||
version: 6.1.2([email protected](@types/[email protected])([email protected])([email protected]))
|
||||
jsdom:
|
||||
specifier: ^30.1.3
|
||||
version: 30.1.3
|
||||
version: 30.1.3(@noble/[email protected])
|
||||
knip:
|
||||
specifier: ^6.43.0
|
||||
version: 6.43.0
|
||||
@@ -210,7 +219,7 @@ importers:
|
||||
version: 8.3.4(@types/[email protected])([email protected])([email protected])
|
||||
vitest:
|
||||
specifier: ^5.0.5
|
||||
version: 5.0.5(@types/[email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected]))
|
||||
version: 5.0.5(@types/[email protected])([email protected](@noble/[email protected]))([email protected](@types/[email protected])([email protected])([email protected]))
|
||||
yaml:
|
||||
specifier: ^2.9.1
|
||||
version: 2.9.1
|
||||
@@ -451,6 +460,9 @@ packages:
|
||||
'@iconify/[email protected]':
|
||||
resolution: {integrity: sha512-JZHlwdID+dy+lTgbYC8NEC4zeugqeYsc6jewvzb4c58kHauJn+X7rNwQjxz5p2qSjqaEeQoLkCIQ9v/H4PK0/w==}
|
||||
|
||||
'@isaacs/[email protected]':
|
||||
resolution: {integrity: sha512-GPm/Dbvk5RLmhRnxXIa7nTpK0xtl4E0wj0MslsuNiJ1FIROU+2+9lgUC/dgF7Ey4QCWhfEsgxilMRMCdHPfDfw==}
|
||||
|
||||
'@jridgewell/[email protected]':
|
||||
resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==}
|
||||
engines: {node: '>=6.0.0'}
|
||||
@@ -519,6 +531,15 @@ packages:
|
||||
'@marijn/[email protected]':
|
||||
resolution: {integrity: sha512-Wy0V7+SGUjnF9/TkiM1hKVDPj7jKXduPNboMVtHTA8dySMURWqfg/JZ9E2Sq8JgSJmkl7k7Qe9FLeMSrSraWmQ==}
|
||||
|
||||
'@mathjax/[email protected]':
|
||||
resolution: {integrity: sha512-gzAB3dFHilHX1l5x2xUqRL+1jDQt3Fyza1DkEMVXWC4E8SvsGdlgEza47HYi2WhVcgfkvf4zgUGzuhbq3Pjlew==}
|
||||
|
||||
'@mathjax/[email protected]':
|
||||
resolution: {integrity: sha512-9B78brBEmmAwyumaREIyM1gF2HgDamDIXA36UyeXWxX7XrpLdmoSB5NLIf/c6tEA4L6xNrIdMxfgY6YX/kcSNw==}
|
||||
|
||||
'@mathjax/[email protected]':
|
||||
resolution: {integrity: sha512-rIrWquuBSoJuoMBdC/1qD+AUHTorlccPicoVy6P2xbUgnuDBpCcpbHtOAsB8L3hdCHtNBg92lF8e3Fz+pkcQbw==}
|
||||
|
||||
'@mermaid-js/[email protected]':
|
||||
resolution: {integrity: sha512-j37dj/h6p6pots1L7pLPPNuABEEu9WP4OYg9pW1g+nYG331j0+3canE9OagtYdytYvdSAMG+2fKU5cxep6LgjA==}
|
||||
engines: {node: '>=22.12.0'}
|
||||
@@ -530,6 +551,10 @@ packages:
|
||||
'@emnapi/core': ^1.7.1 || 2.0.0-beta.2
|
||||
'@emnapi/runtime': ^1.7.1 || 2.0.0-beta.2
|
||||
|
||||
'@noble/[email protected]':
|
||||
resolution: {integrity: sha512-X5XaVWZIBCT7HHZGm5I7ZQXDwLG+bGXuSrMQAW+7Zvl87h1kmc1ZB1VSRJcpUfoUrGQp4Fkoxm5kZ+Ms+aW+eA==}
|
||||
engines: {node: '>= 20.19.0'}
|
||||
|
||||
'@oxc-parser/[email protected]':
|
||||
resolution: {integrity: sha512-A6xv7hDtnTm+xlZ7utn6rRQpRMJHRhVr3gjRGqlx0RUX84mNk0pAsy6YN/wWhuOTkaZhRrrzaLxf0NfbH77j2w==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
@@ -598,6 +623,7 @@ packages:
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@oxc-parser/[email protected]':
|
||||
resolution: {integrity: sha512-JSlhgoK+/g1TGJI5NuADx2+6syhxnQNLCWLXyO5QLFyetomcr/vIxSdiNlmyAv963YXUzCuwAwRG6npZ5xyJ1A==}
|
||||
@@ -1075,6 +1101,7 @@ packages:
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@rolldown/[email protected]':
|
||||
resolution: {integrity: sha512-4+Kl8daPV8NDHaD7mfCcc1pRM+Qg7ab8DyMm5FG5WoZgv4h2i3KFN1CybYBNbQqmuYm7ftJLvmMI1eHYJ22S/Q==}
|
||||
@@ -1088,12 +1115,14 @@ packages:
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [s390x]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rolldown/[email protected]':
|
||||
resolution: {integrity: sha512-WxalXzgrLVpKC93xfpaJ3gCXUWzeCr+FRCbDVD2mUAy4L6Vo3lNVz0epUEUpxPWJkLNYUwM4OSIikv36OJ9mLg==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rolldown/[email protected]':
|
||||
resolution: {integrity: sha512-3G3tnAmTpdk9jO3GQtyHXqeFD2SlecfTws/Y3M2mmj9nMBwwuLT4kur8sZKeu7ENUHSpVO3cIsm5A52LEWWwlg==}
|
||||
@@ -1456,6 +1485,10 @@ packages:
|
||||
'@vitest/[email protected]':
|
||||
resolution: {integrity: sha512-lwJRExuH417257Q5wv9QYugN9IMJkoxcrKrYxGPQkBzl7wlNpTUxD/5yNX4ESKVUIShKPgkGchYPFMWOOk0wzw==}
|
||||
|
||||
'@xmldom/[email protected]':
|
||||
resolution: {integrity: sha512-5AXjrcMClTryPe9LgZrygpB1lj7s0S9E0+W+AHaVKAVyHanafK86iPSvG5xHVSp/jC+VH1UXu0TAEmY279xH7A==}
|
||||
engines: {node: '>=14.6'}
|
||||
|
||||
'@xterm/[email protected]':
|
||||
resolution: {integrity: sha512-fIFQHJ15PER9KhAG24IhA5vF4ysHEKrJgImt/ZqRcahvNUGF1T3WnpJ6bLvlvnsft7bVT0ofBWySx6nxFNAXkA==}
|
||||
peerDependencies:
|
||||
@@ -1491,9 +1524,17 @@ packages:
|
||||
resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==}
|
||||
engines: {node: 18 || 20 || >=22}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-fX1Onk0tdVPC7obPWB5EbJ1z7NVhLq4m2xZLq2YXBkxzMXIGRpNMU88n0EPgWseKl12J7zXs7qrDxPK4sRs2fg==}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-Vh3dmFbc4wZeox7M9I/0L9GfFd83Su4+yCck/OF9Gi/P/dAHn0RT7X4K9R7gMNMhDck3DvhR6QXsnQdjjgwNvQ==}
|
||||
engines: {node: 20 || >=22}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-XWAtwJ6OHO+tj0EKCs0Y2UamnyOxseZWltU4x2U2wh8g4AigdjwvtUjvLP2tqkA/avxHEtzxNaqGq/YGNwckKg==}
|
||||
engines: {node: '>=18'}
|
||||
@@ -1506,6 +1547,10 @@ packages:
|
||||
resolution: {integrity: sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-H+y0Jo/T1RZ9qPP4Eh1pkcQcLRglraJaSLoyOtHxu6AapkjWVCy2Sit1QQ4x3Dng8qDlSsZEet7g5Pq06MvTgw==}
|
||||
engines: {node: '>=20'}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-cgnQ88TRrWcC7pVq46RzJVRMktu3W2RcbnoidnfBsl1bmDCBwJS/udcIZpKoCrbAYYaCqsz1yZCVIgbIaU3ddQ==}
|
||||
engines: {node: '>=22.12.0'}
|
||||
@@ -1767,6 +1812,10 @@ packages:
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-++QEw4DIY7WGoukz+/+A/8dGYPT9l9yIadnmSgZ8Rjr3YVSVDipQSO9CdnJo9ePqFqUUqh+wk9uIaoiAwsiPkA==}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-OwXjVP2svY5EyLY75Vek96C8qK43gqrt4xsZ+qSILdnaEiJPXkd62mcfUSNx/TQErQRdu5uM5kF67sfONragKw==}
|
||||
engines: {node: 18 || 20 || >=22}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-3GKBOn+m2LX9iq+JC1064cSFprJY4jL1jCXTcpnfER5HYE2l/4EfWSGzkPa/ZDBmYI0ZOEj5VHV/eKnPGkHuOg==}
|
||||
|
||||
@@ -1871,6 +1920,7 @@ packages:
|
||||
engines: {node: '>= 12.0.0'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==}
|
||||
@@ -1884,12 +1934,14 @@ packages:
|
||||
engines: {node: '>= 12.0.0'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==}
|
||||
engines: {node: '>= 12.0.0'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==}
|
||||
@@ -1943,10 +1995,24 @@ packages:
|
||||
resolution: {integrity: sha512-wlVCp+8eTupfCeeFvoZNNiTuHrvag0P2jz/ILgb/f/6jkVokUefOcujefi8qUe/j2asHiSePncVsz/xzzA80LQ==}
|
||||
engines: {node: '>=22.12.0'}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-kYmyrCirqJf3zZ9t/0wGgRZ4/ZJw//VwaRVGA75C4nhE60vtnIzhl9J9ndkX/h6hxSN7pjg/cE0VxbnNM+bnDQ==}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==}
|
||||
engines: {node: '>=4'}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-KCFkfyjqerNlSstjlhIGNXIKZGA/6O4V4RlhZ+Dsr621SPPw0mzlypE9D9ZOoPiVefHID+j7/XuMMlqfD/F60Q==}
|
||||
engines: {node: 20 || >=22}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==}
|
||||
engines: {node: '>=16 || 14 >=14.17'}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-OSgBFQRCVhrZwRa9lhqnKcJU92dd/YXgBjup0uyeuj9bOaVsf4myOyrjU4PfhYkdDk6AqVUTov7v5uFMvIbduA==}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==}
|
||||
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
|
||||
@@ -1992,6 +2058,9 @@ packages:
|
||||
vite-plus:
|
||||
optional: true
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-zAMfbta9nPA8AKkA4WdmNAT8R8s6Dk0/xwPsqNnRidMFcLo1YkLuPDTgs2f64XdzS8vbLNnoJ+uUIkgbz7oRHA==}
|
||||
|
||||
@@ -2001,6 +2070,10 @@ packages:
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-NOnmBpt5Y2RWbuv0LMzsayp3lVylAHLPUTut412ZA3l+C4uw4ZVkQbjShYCQ8TCpUMdPapr4YjUqLYD6v68j+w==}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-1pTbQqH1wIwMi/eleQ5leFTTCkzFsPcgXNjwOA8YGGW/W4/kHT3dssE7Z6NH+zuqNLOzOB0uaD61yl7cAcVhgg==}
|
||||
engines: {node: 18 || 20 || >=22}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==}
|
||||
|
||||
@@ -2071,6 +2144,11 @@ packages:
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-Fk3reQDVPZUMbEm7Zwxz03BWQMW3V5buSk9aU8OckTrO8A1nQtbqvYsAantGNermwsIsXcuOBqcoJ3HuMELctw==}
|
||||
engines: {node: 20 || >=22}
|
||||
hasBin: true
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-NS3levdsRIUOmiJ8FZWCP7LG3QpJyrs/TE0Zpf1yvZu8cAJJ6QMW92H1c7kWpdIHo8RvmLxN/o2JXTKHp74lUA==}
|
||||
|
||||
@@ -2107,6 +2185,10 @@ packages:
|
||||
resolution: {integrity: sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-3dFcH2QtQNhtvUUc09TxoaEK4WG03B9Z57krFG9jocrKykKGu35BhIkWr0vgEAxZZomEWkeluff69y/EbYzP4Q==}
|
||||
hasBin: true
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-OtU/EgQ1kIm5KwqQpBC6ZEMXrZRui11w8zgfTWp8cdO9B8OaPsbA8bTHO2P+HNo1VlUTGMVBwPhydu6poeXiag==}
|
||||
|
||||
@@ -2303,6 +2385,9 @@ packages:
|
||||
engines: {node: '>=20.11'}
|
||||
hasBin: true
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-Gd9+TUn5nXdwj/hFsPVx5cuHHiF5Bwuc30jZ4+ronF1qHK5O7HD0sgmXWSEgwKquT3ClLoKPVbO6qGwVwLzvAw==}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==}
|
||||
engines: {node: '>=18'}
|
||||
@@ -2703,7 +2788,9 @@ snapshots:
|
||||
tslib: 2.8.1
|
||||
optional: true
|
||||
|
||||
'@exodus/[email protected]': {}
|
||||
'@exodus/[email protected](@noble/[email protected])':
|
||||
optionalDependencies:
|
||||
'@noble/hashes': 2.4.0
|
||||
|
||||
'@floating-ui/[email protected]':
|
||||
dependencies:
|
||||
@@ -2734,6 +2821,8 @@ snapshots:
|
||||
'@iconify/types': 2.0.0
|
||||
import-meta-resolve: 4.2.0
|
||||
|
||||
'@isaacs/[email protected]': {}
|
||||
|
||||
'@jridgewell/[email protected]': {}
|
||||
|
||||
'@jridgewell/[email protected]': {}
|
||||
@@ -2843,6 +2932,17 @@ snapshots:
|
||||
|
||||
'@marijn/[email protected]': {}
|
||||
|
||||
'@mathjax/[email protected]': {}
|
||||
|
||||
'@mathjax/[email protected]': {}
|
||||
|
||||
'@mathjax/[email protected]':
|
||||
dependencies:
|
||||
'@mathjax/mathjax-newcm-font': 4.1.3
|
||||
mhchemparser: 4.2.1
|
||||
mj-context-menu: 1.0.0
|
||||
speech-rule-engine: 5.0.0-rc.4
|
||||
|
||||
'@mermaid-js/[email protected]':
|
||||
dependencies:
|
||||
'@chevrotain/types': 13.2.0
|
||||
@@ -2854,6 +2954,8 @@ snapshots:
|
||||
'@tybys/wasm-util': 0.10.4
|
||||
optional: true
|
||||
|
||||
'@noble/[email protected]': {}
|
||||
|
||||
'@oxc-parser/[email protected]':
|
||||
optional: true
|
||||
|
||||
@@ -3241,7 +3343,7 @@ snapshots:
|
||||
picocolors: 1.1.1
|
||||
pretty-format: 27.5.1
|
||||
|
||||
'@testing-library/[email protected](@testing-library/[email protected])([email protected](@types/[email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])))':
|
||||
'@testing-library/[email protected](@testing-library/[email protected])([email protected](@types/[email protected])([email protected](@noble/[email protected]))([email protected](@types/[email protected])([email protected])([email protected])))':
|
||||
dependencies:
|
||||
'@adobe/css-tools': 4.5.0
|
||||
'@testing-library/dom': 10.4.2
|
||||
@@ -3251,7 +3353,7 @@ snapshots:
|
||||
picocolors: 1.1.1
|
||||
redent: 3.0.0
|
||||
optionalDependencies:
|
||||
vitest: 5.0.5(@types/[email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected]))
|
||||
vitest: 5.0.5(@types/[email protected])([email protected](@noble/[email protected]))([email protected](@types/[email protected])([email protected])([email protected]))
|
||||
|
||||
'@testing-library/[email protected](@testing-library/[email protected])(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected]([email protected]))([email protected])':
|
||||
dependencies:
|
||||
@@ -3459,6 +3561,8 @@ snapshots:
|
||||
|
||||
'@vitest/[email protected]': {}
|
||||
|
||||
'@xmldom/[email protected]': {}
|
||||
|
||||
'@xterm/[email protected](@xterm/[email protected])':
|
||||
dependencies:
|
||||
'@xterm/xterm': 6.1.0-beta.338
|
||||
@@ -3483,10 +3587,16 @@ snapshots:
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]:
|
||||
dependencies:
|
||||
require-from-string: 2.0.2
|
||||
|
||||
[email protected]:
|
||||
dependencies:
|
||||
balanced-match: 4.0.4
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]:
|
||||
@@ -3499,6 +3609,8 @@ snapshots:
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]: {}
|
||||
@@ -3706,10 +3818,10 @@ snapshots:
|
||||
d3: 7.9.0
|
||||
lodash-es: 4.18.1
|
||||
|
||||
[email protected]:
|
||||
[email protected](@noble/[email protected]):
|
||||
dependencies:
|
||||
whatwg-mimetype: 5.0.0
|
||||
whatwg-url: 17.3.0
|
||||
whatwg-url: 17.3.0(@noble/[email protected])
|
||||
transitivePeerDependencies:
|
||||
- '@noble/hashes'
|
||||
|
||||
@@ -3772,11 +3884,17 @@ snapshots:
|
||||
dependencies:
|
||||
resolve-pkg-maps: 1.0.0
|
||||
|
||||
[email protected]:
|
||||
dependencies:
|
||||
minimatch: 11.0.9
|
||||
minipass: 7.1.3
|
||||
path-scurry: 3.0.0
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]:
|
||||
[email protected](@noble/[email protected]):
|
||||
dependencies:
|
||||
'@exodus/bytes': 1.16.0
|
||||
'@exodus/bytes': 1.16.0(@noble/[email protected])
|
||||
transitivePeerDependencies:
|
||||
- '@noble/hashes'
|
||||
|
||||
@@ -3800,17 +3918,17 @@ snapshots:
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]:
|
||||
[email protected](@noble/[email protected]):
|
||||
dependencies:
|
||||
'@asamuzakjp/css-color': 7.1.7
|
||||
'@asamuzakjp/dom-selector': 10.0.4
|
||||
'@bramus/specificity': 2.4.3
|
||||
'@csstools/css-syntax-patches-for-csstree': 1.1.15([email protected])
|
||||
'@exodus/bytes': 1.16.0
|
||||
'@exodus/bytes': 1.16.0(@noble/[email protected])
|
||||
css-tree: 3.2.1
|
||||
data-urls: 8.0.0
|
||||
data-urls: 8.0.0(@noble/[email protected])
|
||||
decimal.js: 10.6.0
|
||||
html-encoding-sniffer: 7.0.0
|
||||
html-encoding-sniffer: 7.0.0(@noble/[email protected])
|
||||
is-potential-custom-element-name: 1.0.1
|
||||
lru-cache: 11.5.3
|
||||
parse5: 8.0.1
|
||||
@@ -3820,7 +3938,7 @@ snapshots:
|
||||
w3c-xmlserializer: 6.0.0
|
||||
webidl-conversions: 8.0.1
|
||||
whatwg-mimetype: 5.0.0
|
||||
whatwg-url: 17.3.0
|
||||
whatwg-url: 17.3.0(@noble/[email protected])
|
||||
xml-name-validator: 5.0.0
|
||||
transitivePeerDependencies:
|
||||
- '@noble/hashes'
|
||||
@@ -3953,8 +4071,21 @@ snapshots:
|
||||
ts-dedent: 2.3.0
|
||||
uuid: 14.0.3
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]:
|
||||
dependencies:
|
||||
'@isaacs/nonrecursive-glob-match': 1.1.0
|
||||
brace-expansion: 5.0.13
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]:
|
||||
dependencies:
|
||||
rimraf: 6.1.4
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]: {}
|
||||
@@ -4051,6 +4182,8 @@ snapshots:
|
||||
'@oxlint/binding-win32-ia32-msvc': 1.89.0
|
||||
'@oxlint/binding-win32-x64-msvc': 1.89.0
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]:
|
||||
@@ -4059,6 +4192,11 @@ snapshots:
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]:
|
||||
dependencies:
|
||||
lru-cache: 11.5.3
|
||||
minipass: 7.1.3
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]: {}
|
||||
@@ -4118,6 +4256,11 @@ snapshots:
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]:
|
||||
dependencies:
|
||||
glob: 14.0.6
|
||||
package-json-from-dist: 1.0.1
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]:
|
||||
@@ -4164,6 +4307,12 @@ snapshots:
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]:
|
||||
dependencies:
|
||||
'@xmldom/xmldom': 0.9.12
|
||||
commander: 14.0.3
|
||||
wicked-good-xpath: 1.3.0
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]: {}
|
||||
@@ -4241,7 +4390,7 @@ snapshots:
|
||||
jiti: 2.7.0
|
||||
yaml: 2.9.1
|
||||
|
||||
[email protected](@types/[email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])):
|
||||
[email protected](@types/[email protected])([email protected](@noble/[email protected]))([email protected](@types/[email protected])([email protected])([email protected])):
|
||||
dependencies:
|
||||
'@types/chai': 5.2.3
|
||||
'@vitest/mocker': 5.0.5([email protected](@types/[email protected])([email protected])([email protected]))
|
||||
@@ -4259,7 +4408,7 @@ snapshots:
|
||||
why-is-node-running: 3.2.1
|
||||
optionalDependencies:
|
||||
'@types/node': 26.6.5
|
||||
jsdom: 30.1.3
|
||||
jsdom: 30.1.3(@noble/[email protected])
|
||||
transitivePeerDependencies:
|
||||
- msw
|
||||
|
||||
@@ -4275,9 +4424,9 @@ snapshots:
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]:
|
||||
[email protected](@noble/[email protected]):
|
||||
dependencies:
|
||||
'@exodus/bytes': 1.16.0
|
||||
'@exodus/bytes': 1.16.0(@noble/[email protected])
|
||||
tr46: 7.0.0
|
||||
webidl-conversions: 8.0.1
|
||||
transitivePeerDependencies:
|
||||
@@ -4285,6 +4434,8 @@ snapshots:
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
@@ -0,0 +1,225 @@
|
||||
// @vitest-environment node
|
||||
import { createHash } from "node:crypto";
|
||||
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
BIN_MARK,
|
||||
blake3Hex16,
|
||||
buildSshArgs,
|
||||
cleanLocalDogfoodServers,
|
||||
extractFramedBinary,
|
||||
formatSshConnectionError,
|
||||
isRustVersionAtLeast,
|
||||
loadSshConfigs,
|
||||
normalizeRemotePlatform,
|
||||
parseDogfoodRemoteArgs,
|
||||
parseRunningServerPids,
|
||||
parseToml,
|
||||
readWorkspaceMetadata,
|
||||
resolveAppDirs,
|
||||
resolveSshConfig,
|
||||
stageLocalDogfoodServer,
|
||||
workspaceTarArgs,
|
||||
} from "./dogfood-remote.ts";
|
||||
|
||||
function blake3TestInput(length: number): Uint8Array {
|
||||
const buf = new Uint8Array(length);
|
||||
for (let i = 0; i < length; i++) {
|
||||
buf[i] = i % 251;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
describe("dogfood:remote", () => {
|
||||
it("computes the 16-character BLAKE3 build_id expected by remote_dev::ensure_server", () => {
|
||||
// Reference vector (input[i] = i % 251, 2049 bytes -> multi-chunk tree) matching `blake3::hash(bytes).to_hex()[..16]`.
|
||||
expect(blake3Hex16(blake3TestInput(2049))).toBe("5f4d72f40d7a5f82");
|
||||
});
|
||||
|
||||
it("parses both UI inline-table and [[ssh.configs]] TOML settings formats", () => {
|
||||
const temp = mkdtempSync(join(tmpdir(), "openidea-dogfood-remote-"));
|
||||
try {
|
||||
const configDir = join(temp, "config");
|
||||
mkdirSync(configDir, { recursive: true });
|
||||
writeFileSync(
|
||||
join(configDir, "settings.toml"),
|
||||
[
|
||||
"# Global settings written by Settings › Tools › SSH Configurations",
|
||||
"[appearance]",
|
||||
'locale = "en"',
|
||||
"",
|
||||
"[ssh]",
|
||||
'configs = [{ id = "cfg-1", name = "my-remote", host = "remote-host.example.com", port = 2222, user = "alice", auth = "keyPair", keyFile = "~/.ssh/id_ed25519", saveSecret = false }]',
|
||||
"",
|
||||
].join("\n"),
|
||||
);
|
||||
|
||||
const loaded = loadSshConfigs(configDir);
|
||||
expect(loaded).toEqual([
|
||||
{
|
||||
id: "cfg-1",
|
||||
name: "my-remote",
|
||||
host: "remote-host.example.com",
|
||||
port: 2222,
|
||||
user: "alice",
|
||||
auth: "keyPair",
|
||||
keyFile: "~/.ssh/id_ed25519",
|
||||
},
|
||||
]);
|
||||
|
||||
const resolved = resolveSshConfig(loaded, "my-remote");
|
||||
expect(buildSshArgs(resolved, ["StrictHostKeyChecking=no"], "/Users/alice")).toEqual([
|
||||
"-p",
|
||||
"2222",
|
||||
"-l",
|
||||
"alice",
|
||||
"-i",
|
||||
join("/Users/alice", ".ssh", "id_ed25519"),
|
||||
"-o",
|
||||
"ConnectTimeout=10",
|
||||
"-o",
|
||||
"StrictHostKeyChecking=no",
|
||||
"--",
|
||||
"remote-host.example.com",
|
||||
]);
|
||||
|
||||
expect(() => resolveSshConfig(loaded, "missing-box")).toThrow(/Available SSH configurations: my-remote/);
|
||||
|
||||
const tableDoc = parseToml(
|
||||
["[[ssh.configs]]", 'name = "alt-remote"', 'host = "alt.example.com"', 'user = "bob"', 'auth = "openSsh"'].join(
|
||||
"\n",
|
||||
),
|
||||
);
|
||||
expect(tableDoc).toEqual({
|
||||
ssh: {
|
||||
configs: [{ name: "alt-remote", host: "alt.example.com", user: "bob", auth: "openSsh" }],
|
||||
},
|
||||
});
|
||||
} finally {
|
||||
rmSync(temp, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
it("resolves config and custom local-data directories like ide_host::data_dirs", () => {
|
||||
const temp = mkdtempSync(join(tmpdir(), "openidea-dirs-"));
|
||||
try {
|
||||
const cfgRoot = join(temp, "cfg");
|
||||
const customLocalRoot = join(temp, "custom-caches");
|
||||
mkdirSync(join(cfgRoot, "ai.l0ng.openidea"), { recursive: true });
|
||||
writeFileSync(join(cfgRoot, "ai.l0ng.openidea", "local-data-dir.txt"), `${customLocalRoot}\n`);
|
||||
|
||||
expect(
|
||||
resolveAppDirs({
|
||||
platform: "darwin",
|
||||
env: { OPENIDEA_CONFIG_DIR: cfgRoot },
|
||||
home: "/Users/alice",
|
||||
}),
|
||||
).toEqual({
|
||||
configDir: join(cfgRoot, "ai.l0ng.openidea"),
|
||||
localDataDir: join(customLocalRoot, "ai.l0ng.openidea"),
|
||||
});
|
||||
} finally {
|
||||
rmSync(temp, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
it("parses CLI flags and normalizes remote uname platforms", () => {
|
||||
expect(
|
||||
parseDogfoodRemoteArgs(["--", "my-remote", "--install-rust", "--restart", "--ssh-opt", "Port=2222"]),
|
||||
).toEqual({
|
||||
remoteName: "my-remote",
|
||||
clean: false,
|
||||
installRust: true,
|
||||
restart: "always",
|
||||
sshOpts: ["Port=2222"],
|
||||
});
|
||||
expect(parseDogfoodRemoteArgs(["--clean"])).toEqual({
|
||||
remoteName: undefined,
|
||||
clean: true,
|
||||
installRust: false,
|
||||
restart: "prompt",
|
||||
sshOpts: [],
|
||||
});
|
||||
expect(() => parseDogfoodRemoteArgs(["my-remote", "--restart", "--no-restart"])).toThrow(/Cannot pass both/);
|
||||
expect(() => parseDogfoodRemoteArgs([])).toThrow(/Usage:/);
|
||||
expect(normalizeRemotePlatform("Linux x86_64\n")).toEqual({ os: "linux", arch: "x86_64" });
|
||||
expect(normalizeRemotePlatform("Linux aarch64")).toEqual({ os: "linux", arch: "aarch64" });
|
||||
expect(normalizeRemotePlatform("Darwin arm64")).toEqual({ os: "macos", arch: "aarch64" });
|
||||
});
|
||||
|
||||
it("handles connection errors, Rust version checks, and running openidea-server PID detection", () => {
|
||||
const repoRoot = join(import.meta.dirname, "..");
|
||||
const meta = readWorkspaceMetadata(repoRoot);
|
||||
expect(meta.version).toMatch(/^\d+\.\d+\.\d+/);
|
||||
expect(meta.rustVersion).toMatch(/^\d+\.\d+/);
|
||||
|
||||
expect(isRustVersionAtLeast("rustc 1.96.0 (0000000 2026-06-01)", "1.96")).toBe(true);
|
||||
expect(isRustVersionAtLeast("rustc 1.100.0-nightly (abcdef0 2026-11-01)", "1.96")).toBe(true);
|
||||
expect(isRustVersionAtLeast("rustc 1.75.0 (82e1608df 2023-12-21)", "1.96")).toBe(false);
|
||||
expect(isRustVersionAtLeast("no-rustc", "1.96")).toBe(false);
|
||||
|
||||
const errMsg = formatSshConnectionError(
|
||||
"my-remote",
|
||||
"[email protected]:22",
|
||||
"Warning: Permanently added 'remote-host.example.com' (ED25519) to the list of known hosts.\nssh: connect to host remote-host.example.com port 22: Connection refused\n",
|
||||
255,
|
||||
);
|
||||
expect(errMsg).toContain("Cannot connect to SSH remote 'my-remote' ([email protected]:22)");
|
||||
expect(errMsg).toContain("Connection refused");
|
||||
expect(errMsg).not.toContain("Permanently added");
|
||||
|
||||
const psText = [
|
||||
" 101 /bin/bash",
|
||||
" 4321 /home/alice/.openidea/server/0.1.50/42bd8ae098588d22/openidea-server --stdio",
|
||||
" 4399 openidea-server --stdio",
|
||||
" 4500 grep openidea-server",
|
||||
].join("\n");
|
||||
expect(parseRunningServerPids(psText)).toEqual([4321, 4399]);
|
||||
});
|
||||
|
||||
it("backs up an existing cached release server on stage and restores it on --clean", () => {
|
||||
const temp = mkdtempSync(join(tmpdir(), "openidea-stage-"));
|
||||
try {
|
||||
const serverDir = join(temp, "server", "0.1.50", "linux-aarch64");
|
||||
mkdirSync(serverDir, { recursive: true });
|
||||
const binPath = join(serverDir, "openidea-server");
|
||||
writeFileSync(binPath, "official-release-binary");
|
||||
|
||||
const dogfoodBytes = Buffer.from("dogfood-server-binary-v1");
|
||||
const id1 = blake3Hex16(dogfoodBytes);
|
||||
stageLocalDogfoodServer(temp, "0.1.50", "linux", "aarch64", dogfoodBytes, id1);
|
||||
expect(readFileSync(binPath, "utf8")).toBe("dogfood-server-binary-v1");
|
||||
|
||||
// A second dogfood build must keep the original release backup intact.
|
||||
const dogfoodBytes2 = Buffer.from("dogfood-server-binary-v2");
|
||||
const id2 = blake3Hex16(dogfoodBytes2);
|
||||
stageLocalDogfoodServer(temp, "0.1.50", "linux", "aarch64", dogfoodBytes2, id2);
|
||||
expect(readFileSync(binPath, "utf8")).toBe("dogfood-server-binary-v2");
|
||||
|
||||
const cleaned = cleanLocalDogfoodServers(temp, "0.1.50", "linux-aarch64");
|
||||
expect(cleaned).toEqual([{ platformKey: "linux-aarch64", buildId: id2, restoredRelease: true }]);
|
||||
expect(existsSync(binPath)).toBe(true);
|
||||
expect(readFileSync(binPath, "utf8")).toBe("official-release-binary");
|
||||
} finally {
|
||||
rmSync(temp, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
it("strips login shell banners before the framed binary stream and verifies SHA-256", () => {
|
||||
const payload = Buffer.from([0x7f, 0x45, 0x4c, 0x46, 1, 2, 3, 4]);
|
||||
const sha = createHash("sha256").update(payload).digest("hex");
|
||||
const framed = Buffer.concat([Buffer.from(`Welcome to Ubuntu!\n${BIN_MARK}${sha}\n`, "utf8"), payload]);
|
||||
expect(extractFramedBinary(framed)).toEqual(payload);
|
||||
expect(() => extractFramedBinary(Buffer.from(`${BIN_MARK}${"0".repeat(64)}\ncorrupt`))).toThrow(/SHA-256 mismatch/);
|
||||
});
|
||||
|
||||
it("anchors tar Cargo target exclusions so nested source folders like crates/ide-ssh/src/target stay included", () => {
|
||||
const args = workspaceTarArgs();
|
||||
expect(args).not.toContain("--exclude=target");
|
||||
expect(args).toContain("--exclude=plugins/target");
|
||||
expect(args).toContain("crates");
|
||||
expect(args).toContain("generators");
|
||||
});
|
||||
});
|
||||
File diff suppressed because it is too large.
Load diff
@@ -89,6 +89,17 @@ const CASES: Record<string, Case | Case[]> = {
|
||||
file: "test/inventory.test.js",
|
||||
},
|
||||
},
|
||||
{
|
||||
fixture: "mocha-app",
|
||||
setup: npmInstall,
|
||||
tests: {
|
||||
config: "npm:test",
|
||||
failing: (c) => env(c, { OPENIDEA_FAIL: "1" }),
|
||||
passed: 4,
|
||||
failed: "intentionally fails (set OPENIDEA_FAIL=1)",
|
||||
file: "test/pricing.spec.js",
|
||||
},
|
||||
},
|
||||
],
|
||||
python: {
|
||||
fixture: "python-app",
|
||||
|
||||
+12
-3
@@ -2904,6 +2904,10 @@ export type AgentSkill_Deserialize = {
|
||||
userInvocable?: boolean,
|
||||
/** True when frontmatter sets `disable-model-invocation: true` (defaults to `slashOnly`). */
|
||||
disableModelInvocation?: boolean,
|
||||
/** True when frontmatter sets `context: fork` (passed through natively to supporting CLIs). */
|
||||
contextFork?: boolean,
|
||||
/** Optional `paths` / `globs` patterns from frontmatter (passed through natively to supporting CLIs). */
|
||||
paths?: string[],
|
||||
/** The `SKILL.md` passes validation (`name` matches its folder, `description` present). */
|
||||
valid: boolean,
|
||||
/** What validation found (`name` mismatch, missing or over-long description…). */
|
||||
@@ -2926,6 +2930,10 @@ export type AgentSkill_Serialize = {
|
||||
userInvocable: boolean,
|
||||
/** True when frontmatter sets `disable-model-invocation: true` (defaults to `slashOnly`). */
|
||||
disableModelInvocation: boolean,
|
||||
/** True when frontmatter sets `context: fork` (passed through natively to supporting CLIs). */
|
||||
contextFork: boolean,
|
||||
/** Optional `paths` / `globs` patterns from frontmatter (passed through natively to supporting CLIs). */
|
||||
paths?: string[],
|
||||
/** The `SKILL.md` passes validation (`name` matches its folder, `description` present). */
|
||||
valid: boolean,
|
||||
/** What validation found (`name` mismatch, missing or over-long description…). */
|
||||
@@ -6259,11 +6267,11 @@ export type ExternalDiffSide = {
|
||||
};
|
||||
|
||||
/** A formatter that runs outside the language servers, with its own settings group. */
|
||||
export type ExternalFormatter = "prettier" | "oxfmt" | "ruff";
|
||||
export type ExternalFormatter = "prettier" | "oxfmt" | "biome" | "ruff";
|
||||
|
||||
/** An external formatter (Prettier, oxfmt, Ruff) and the languages it formats. */
|
||||
/** An external formatter (Prettier, oxfmt, Biome, Ruff) and the languages it formats. */
|
||||
export type ExternalFormatterSettings = {
|
||||
/** Empty path: project node_modules (Prettier/oxfmt), managed installation, then PATH. */
|
||||
/** Empty path: project node_modules (Prettier/oxfmt/Biome), managed installation, then PATH. */
|
||||
path?: string,
|
||||
/** Ruff only: directory containing its configuration, or a configuration file. */
|
||||
configurationDirectory?: string,
|
||||
@@ -8341,6 +8349,7 @@ export type LanguagesSettings = {
|
||||
typescript?: TypeScriptSettings,
|
||||
prettier?: ExternalFormatterSettings,
|
||||
oxfmt?: ExternalFormatterSettings,
|
||||
biome?: ExternalFormatterSettings,
|
||||
ruff?: ExternalFormatterSettings,
|
||||
java?: JavaSettings,
|
||||
ruby?: RubySettings,
|
||||
|
||||
@@ -195,10 +195,10 @@ function editorAction(
|
||||
|
||||
/** Whether saving a `language` file formats it: Format on save, or Run on save of an external formatter. */
|
||||
export function formatsOnSave(settings: Settings | null, language: string): boolean {
|
||||
const { prettier, oxfmt, ruff } = validateLanguages(settings?.languages);
|
||||
const { prettier, oxfmt, biome, ruff } = validateLanguages(settings?.languages);
|
||||
return (
|
||||
!!settings?.editor?.formatOnSave ||
|
||||
[prettier, oxfmt, ruff].some((formatter) => formatter.runOnSave && formatter.languages.includes(language))
|
||||
[prettier, oxfmt, biome, ruff].some((formatter) => formatter.runOnSave && formatter.languages.includes(language))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -275,6 +275,13 @@ export function registerLspActions(): () => void {
|
||||
(v) => formatDocument(v, { explicit: true, tool: "oxfmt" }),
|
||||
{ keywords: ["format", "oxfmt", "oxc"] },
|
||||
),
|
||||
editorAction(
|
||||
"code.reformatWithBiome",
|
||||
"Reformat with Biome",
|
||||
"Code",
|
||||
(v) => formatDocument(v, { explicit: true, tool: "biome" }),
|
||||
{ keywords: ["format", "biome"] },
|
||||
),
|
||||
editorAction(
|
||||
"code.reformatWithRuff",
|
||||
"Reformat with Ruff",
|
||||
|
||||
@@ -173,13 +173,15 @@ describe("format on save provider isolation", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("formats on save for the languages whose Prettier or oxfmt Run on save is on", () => {
|
||||
it("formats on save for the languages whose Prettier, oxfmt or Biome Run on save is on", () => {
|
||||
const settings = (languages: Settings["languages"], formatOnSave = false) =>
|
||||
({ editor: { formatOnSave }, languages }) as Settings;
|
||||
const oxfmt = settings({ oxfmt: { runOnSave: true, languages: ["typescript"] } });
|
||||
expect(formatsOnSave(oxfmt, "typescript")).toBe(true);
|
||||
expect(formatsOnSave(oxfmt, "markdown")).toBe(false);
|
||||
expect(formatsOnSave(settings({ prettier: { runOnSave: true } }), "markdown")).toBe(true);
|
||||
expect(formatsOnSave(settings({ biome: { runOnSave: true } }), "json")).toBe(true);
|
||||
expect(formatsOnSave(settings({ biome: { runOnSave: true } }), "markdown")).toBe(false);
|
||||
expect(formatsOnSave(settings({ ruff: { runOnSave: true } }), "python")).toBe(true);
|
||||
expect(formatsOnSave(settings({ ruff: { runOnSave: true } }), "typescript")).toBe(false);
|
||||
expect(formatsOnSave(settings({}), "typescript")).toBe(false);
|
||||
|
||||
@@ -96,7 +96,7 @@ interface FormatDocumentOptions {
|
||||
explicit: boolean;
|
||||
selectionOnly?: boolean;
|
||||
onSave?: boolean;
|
||||
/** Runs this external formatter whatever the settings select (Reformat with Prettier/oxfmt). */
|
||||
/** Runs this external formatter whatever the settings select (Reformat with Prettier/oxfmt/Biome). */
|
||||
tool?: ExternalFormatter;
|
||||
/** Formats only these ranges, e.g. the text changed since the last commit; an empty list formats nothing. */
|
||||
ranges?: readonly OffsetRange[];
|
||||
@@ -176,6 +176,7 @@ async function format(view: EditorView, opts: FormatDocumentOptions): Promise<Fo
|
||||
? {
|
||||
prettier: { failed: "Prettier formatting failed", timedOut: "Prettier formatting timed out" },
|
||||
oxfmt: { failed: "oxfmt formatting failed", timedOut: "oxfmt formatting timed out" },
|
||||
biome: { failed: "Biome formatting failed", timedOut: "Biome formatting timed out" },
|
||||
ruff: { failed: "Ruff formatting failed", timedOut: "Ruff formatting timed out" },
|
||||
}[e.data.tool]
|
||||
: undefined;
|
||||
|
||||
@@ -44,9 +44,9 @@ afterEach(() => {
|
||||
_resetI18nForTests();
|
||||
});
|
||||
|
||||
describe.each(["prettier", "oxfmt", "ruff"])("%s formatter errors", (name) => {
|
||||
describe.each(["prettier", "oxfmt", "biome", "ruff"])("%s formatter errors", (name) => {
|
||||
const tool = { type: "tool", tool: name, missing: false } as const;
|
||||
const display = name === "prettier" ? "Prettier" : name === "ruff" ? "Ruff" : name;
|
||||
const display = ({ prettier: "Prettier", biome: "Biome", ruff: "Ruff" } as Record<string, string>)[name] ?? name;
|
||||
it("uses structured missing-tool information to request the shared install prompt", async () => {
|
||||
const prompt = vi.fn();
|
||||
const dispose = registerAction({
|
||||
@@ -130,6 +130,7 @@ describe("Reformat with an external formatter", () => {
|
||||
it.each([
|
||||
["code.reformatWithPrettier", "prettier"],
|
||||
["code.reformatWithOxfmt", "oxfmt"],
|
||||
["code.reformatWithBiome", "biome"],
|
||||
["code.reformatWithRuff", "ruff"],
|
||||
])("%s asks the backend for %s whatever the settings select", async (id, tool) => {
|
||||
vi.spyOn(lsp, "lspRequest").mockImplementation(async (request) => {
|
||||
|
||||
@@ -277,4 +277,20 @@ describe("SkillsPage", () => {
|
||||
);
|
||||
await waitFor(() => expect(screen.getByText("deploy-script")).toBeInTheDocument());
|
||||
});
|
||||
|
||||
it("displays context: fork and paths badges and expands paths in the inspector", async () => {
|
||||
const forked = [
|
||||
state("verify-ux", "workspace", "auto", {
|
||||
contextFork: true,
|
||||
paths: ["src/**/*.tsx", "e2e/*.spec.ts"],
|
||||
}),
|
||||
];
|
||||
render(<SkillsPage backend={{ list: vi.fn(async () => forked), setMode: vi.fn(async () => forked) }} />);
|
||||
|
||||
await waitFor(() => expect(screen.getByText("verify-ux")).toBeInTheDocument());
|
||||
expect(screen.getByText("context: fork")).toBeInTheDocument();
|
||||
expect(screen.getByText("paths (2)")).toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole("button", { name: /^verify-ux/ }));
|
||||
expect(await screen.findByText("src/**/*.tsx, e2e/*.spec.ts")).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
@@ -362,6 +362,16 @@ function SkillCard({
|
||||
{skill.alsoIn?.map((s) => tx(SKILL_SOURCE_GROUPS[s].label)).join(", ")}
|
||||
</span>
|
||||
)}
|
||||
{skill.contextFork && (
|
||||
<span className={page.tag} title={tx("Runs in a subagent where supported (context: fork)")}>
|
||||
context: fork
|
||||
</span>
|
||||
)}
|
||||
{(skill.paths?.length ?? 0) > 0 && (
|
||||
<span className={page.tag} title={skill.paths?.join(", ")}>
|
||||
{formatMessage(tx("paths ({count})"), { count: skill.paths?.length ?? 0 })}
|
||||
</span>
|
||||
)}
|
||||
{!skill.valid && (
|
||||
<span className={clsx(page.tag, page.tagWarning)}>
|
||||
<T>Invalid SKILL.md</T>
|
||||
@@ -426,6 +436,14 @@ function SkillCard({
|
||||
</span>
|
||||
</>
|
||||
)}
|
||||
{(skill.paths?.length ?? 0) > 0 && (
|
||||
<>
|
||||
<span className={page.metaLabel}>
|
||||
<T>Paths</T>
|
||||
</span>
|
||||
<span className={page.metaValue}>{skill.paths?.join(", ")}</span>
|
||||
</>
|
||||
)}
|
||||
<span className={page.metaLabel}>
|
||||
<T>Validation</T>
|
||||
</span>
|
||||
|
||||
@@ -165,6 +165,31 @@ describe("SkillsPicker", () => {
|
||||
await waitFor(() => expect(screen.getByRole("button", { name: "Skills" })).toHaveTextContent("Skills3/5"));
|
||||
});
|
||||
|
||||
it("shows fork and paths pills on skills with context: fork and paths frontmatter", async () => {
|
||||
const richSkills: AgentSkillState[] = [
|
||||
{
|
||||
skill: {
|
||||
name: "verify-ux",
|
||||
description: "Verify UX layouts",
|
||||
path: "/ws/.agents/skills/verify-ux",
|
||||
source: "workspace",
|
||||
contextFork: true,
|
||||
paths: ["src/**/*.tsx", "e2e/*.spec.ts"],
|
||||
valid: true,
|
||||
warnings: [],
|
||||
},
|
||||
mode: "auto",
|
||||
origin: "none",
|
||||
},
|
||||
];
|
||||
render(<Harness skills={richSkills} />);
|
||||
|
||||
fireEvent.click(screen.getByRole("button", { name: "Skills" }));
|
||||
expect(await screen.findByText("fork")).toBeInTheDocument();
|
||||
expect(screen.getByText("paths")).toBeInTheDocument();
|
||||
expect(screen.getByTitle("Verify UX layouts · src/**/*.tsx, e2e/*.spec.ts")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("shows an empty state without skills", async () => {
|
||||
render(<Harness skills={[]} />);
|
||||
|
||||
|
||||
@@ -154,7 +154,8 @@ function GroupRows({
|
||||
|
||||
function SessionSkillRow({ item, onToggle }: { item: SessionSkillItem; onToggle: (enabled: boolean) => void }) {
|
||||
const tx = useTx();
|
||||
const description = item.state.skill.description;
|
||||
const { skill } = item.state;
|
||||
const description = skill.description;
|
||||
return (
|
||||
<PickerRow
|
||||
name={item.name}
|
||||
@@ -162,10 +163,12 @@ function SessionSkillRow({ item, onToggle }: { item: SessionSkillItem; onToggle:
|
||||
<>
|
||||
<ModePill mode={item.mode} />
|
||||
{item.overridden && <PickerSessionPill />}
|
||||
{skill.contextFork && <PickerPill>fork</PickerPill>}
|
||||
{(skill.paths?.length ?? 0) > 0 && <PickerPill>paths</PickerPill>}
|
||||
</>
|
||||
}
|
||||
sub={description || undefined}
|
||||
subTitle={description}
|
||||
subTitle={skill.paths?.length ? `${description} · ${skill.paths.join(", ")}` : description}
|
||||
controls={
|
||||
item.locked ? (
|
||||
<PickerPill>
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { useEffect } from "react";
|
||||
import { createRoot, type Root } from "react-dom/client";
|
||||
import type { EditorView } from "@codemirror/view";
|
||||
import { RgbaColorPicker } from "react-colorful";
|
||||
import { useTx } from "@/platform/i18n";
|
||||
import { Button, IconButton, Popup, T } from "@/ui";
|
||||
import { fromHex, toHex8, type Rgba } from "./colors";
|
||||
import styles from "./ColorPicker.module.css";
|
||||
import { ColorPicker, rememberColor } from "@/ui/ColorPicker";
|
||||
import type { Rgba } from "@/ui/colorPickerValues";
|
||||
|
||||
interface PickerRequest {
|
||||
view: EditorView;
|
||||
@@ -20,47 +17,13 @@ let root: Root | null = null;
|
||||
let host: HTMLElement | null = null;
|
||||
let active: (PickerRequest & { initial: Rgba }) | null = null;
|
||||
let sequence = 0;
|
||||
const RECENT_KEY = "openidea.colorPicker.recent.v1";
|
||||
const MAX_RECENT = 20;
|
||||
|
||||
function readRecent(): string[] {
|
||||
try {
|
||||
const value: unknown = JSON.parse(localStorage.getItem(RECENT_KEY) ?? "[]");
|
||||
return Array.isArray(value)
|
||||
? value.filter((item): item is string => typeof item === "string" && fromHex(item) !== null).slice(0, MAX_RECENT)
|
||||
: [];
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
function rememberColor(value: Rgba) {
|
||||
const hex = toHex8(value);
|
||||
const recent = [hex, ...readRecent().filter((item) => item.toLowerCase() !== hex)].slice(0, MAX_RECENT);
|
||||
try {
|
||||
localStorage.setItem(RECENT_KEY, JSON.stringify(recent));
|
||||
} catch {
|
||||
// Storage can be unavailable in a restricted WebView.
|
||||
}
|
||||
}
|
||||
|
||||
interface EyeDropperResult {
|
||||
sRGBHex: string;
|
||||
}
|
||||
|
||||
interface EyeDropperInstance {
|
||||
open(): Promise<EyeDropperResult>;
|
||||
}
|
||||
|
||||
type EyeDropperWindow = Window & { EyeDropper?: new () => EyeDropperInstance };
|
||||
|
||||
function render() {
|
||||
if (!root) {
|
||||
host = document.createElement("div");
|
||||
document.body.append(host);
|
||||
root = createRoot(host);
|
||||
}
|
||||
root.render(active ? <Picker key={sequence} id={sequence} request={active} /> : null);
|
||||
root.render(active ? <EditorPicker key={sequence} id={sequence} request={active} /> : null);
|
||||
}
|
||||
|
||||
export function openColorPicker(request: PickerRequest) {
|
||||
@@ -100,54 +63,7 @@ export function disposeColorPicker() {
|
||||
host = null;
|
||||
}
|
||||
|
||||
function Field({
|
||||
label,
|
||||
name,
|
||||
value,
|
||||
maxLength,
|
||||
inputMode,
|
||||
isValid,
|
||||
onValid,
|
||||
}: {
|
||||
label: string;
|
||||
name: string;
|
||||
value: string;
|
||||
maxLength: number;
|
||||
inputMode: "numeric" | "text";
|
||||
isValid: (text: string) => boolean;
|
||||
onValid: (text: string) => void;
|
||||
}) {
|
||||
const [draft, setDraft] = useState<string | null>(null);
|
||||
const t = useTx();
|
||||
const shown = draft ?? value;
|
||||
return (
|
||||
<label className={styles.field}>
|
||||
<span>{label}</span>
|
||||
<input
|
||||
aria-label={t(name)}
|
||||
aria-invalid={shown !== "" && !isValid(shown)}
|
||||
inputMode={inputMode}
|
||||
maxLength={maxLength}
|
||||
spellCheck={false}
|
||||
value={shown}
|
||||
onChange={(event) => {
|
||||
const next = event.currentTarget.value;
|
||||
setDraft(next);
|
||||
if (isValid(next)) onValid(next);
|
||||
}}
|
||||
onBlur={() => setDraft(null)}
|
||||
onFocus={(event) => event.currentTarget.select()}
|
||||
/>
|
||||
</label>
|
||||
);
|
||||
}
|
||||
|
||||
function Picker({ id, request }: { id: number; request: PickerRequest }) {
|
||||
const [value, setValue] = useState<Rgba>(request.value);
|
||||
const [recent] = useState(readRecent);
|
||||
const [sampling, setSampling] = useState(false);
|
||||
const t = useTx();
|
||||
const eyeDropper = (window as EyeDropperWindow).EyeDropper;
|
||||
function EditorPicker({ id, request }: { id: number; request: PickerRequest }) {
|
||||
useEffect(() => {
|
||||
const close = () => {
|
||||
if (sequence === id) closeColorPicker();
|
||||
@@ -156,154 +72,18 @@ function Picker({ id, request }: { id: number; request: PickerRequest }) {
|
||||
return () => request.view.scrollDOM.removeEventListener("scroll", close);
|
||||
}, [id, request.view]);
|
||||
|
||||
const update = (next: Rgba) => {
|
||||
if (sequence !== id || !active) return;
|
||||
setValue(next);
|
||||
active = { ...active, value: next };
|
||||
request.onChange?.(next);
|
||||
};
|
||||
const channel = (index: 0 | 1 | 2, text: string) => {
|
||||
const number = Number(text);
|
||||
const next: Rgba = [...value];
|
||||
next[index] = number;
|
||||
update(next);
|
||||
};
|
||||
const alpha = (text: string) => {
|
||||
const number = Number(text);
|
||||
update([value[0], value[1], value[2], number / 100]);
|
||||
};
|
||||
const hex = (text: string) => {
|
||||
const next = fromHex(text);
|
||||
if (next) update(next);
|
||||
};
|
||||
const numeric = (max: number) => (text: string) => /^\d{1,3}$/.test(text) && Number(text) <= max;
|
||||
const sampleScreen = async () => {
|
||||
if (!eyeDropper || sampling) return;
|
||||
setSampling(true);
|
||||
try {
|
||||
const result = await new eyeDropper().open();
|
||||
const next = fromHex(result.sRGBHex);
|
||||
if (next && sequence === id && active) update(next);
|
||||
} catch (error) {
|
||||
if (!(error instanceof DOMException && error.name === "AbortError")) console.warn(error);
|
||||
} finally {
|
||||
if (sequence === id && active) setSampling(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Popup
|
||||
open
|
||||
<ColorPicker
|
||||
anchor={request.anchor}
|
||||
placement="bottom-start"
|
||||
offset={4}
|
||||
onClose={(reason) => closeColorPicker(reason !== "escape")}
|
||||
aria-label={t("Color picker")}
|
||||
className={styles.popup}
|
||||
trapFocus
|
||||
closeOnDeactivate={false}
|
||||
>
|
||||
<form
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
if (!event.currentTarget.querySelector('[aria-invalid="true"]')) closeColorPicker(true);
|
||||
}}
|
||||
>
|
||||
<div className={styles.pickerArea}>
|
||||
<RgbaColorPicker
|
||||
className={styles.control}
|
||||
color={{ r: value[0], g: value[1], b: value[2], a: value[3] }}
|
||||
onChange={({ r, g, b, a }) => update([r, g, b, a])}
|
||||
/>
|
||||
<div className={styles.sampleRow}>
|
||||
<IconButton
|
||||
icon="eyedropper"
|
||||
title="Pick screen color"
|
||||
size="small"
|
||||
disabled={!eyeDropper || sampling}
|
||||
onClick={() => void sampleScreen()}
|
||||
/>
|
||||
<div className={styles.preview} role="img" aria-label={t("Current color")}>
|
||||
<span style={{ backgroundColor: `rgba(${value.join(", ")})` }} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles.fields}>
|
||||
<Field
|
||||
label="R"
|
||||
name="Red"
|
||||
value={String(value[0])}
|
||||
maxLength={3}
|
||||
inputMode="numeric"
|
||||
isValid={numeric(255)}
|
||||
onValid={(v) => channel(0, v)}
|
||||
/>
|
||||
<Field
|
||||
label="G"
|
||||
name="Green"
|
||||
value={String(value[1])}
|
||||
maxLength={3}
|
||||
inputMode="numeric"
|
||||
isValid={numeric(255)}
|
||||
onValid={(v) => channel(1, v)}
|
||||
/>
|
||||
<Field
|
||||
label="B"
|
||||
name="Blue"
|
||||
value={String(value[2])}
|
||||
maxLength={3}
|
||||
inputMode="numeric"
|
||||
isValid={numeric(255)}
|
||||
onValid={(v) => channel(2, v)}
|
||||
/>
|
||||
<Field
|
||||
label="A%"
|
||||
name="Alpha percent"
|
||||
value={String(Math.round(value[3] * 100))}
|
||||
maxLength={3}
|
||||
inputMode="numeric"
|
||||
isValid={numeric(100)}
|
||||
onValid={alpha}
|
||||
/>
|
||||
<Field
|
||||
label={t("HEX")}
|
||||
name="Hexadecimal"
|
||||
value={toHex8(value).slice(1).toUpperCase()}
|
||||
maxLength={9}
|
||||
inputMode="text"
|
||||
isValid={(v) => fromHex(v) !== null}
|
||||
onValid={hex}
|
||||
/>
|
||||
</div>
|
||||
{recent.length > 0 && (
|
||||
<div className={styles.recent} role="group" aria-label={t("Recent colors")}>
|
||||
{recent.map((hex) => (
|
||||
<button
|
||||
key={hex}
|
||||
type="button"
|
||||
title={hex.toUpperCase()}
|
||||
aria-label={`${t("Recent color")} ${hex.toUpperCase()}`}
|
||||
aria-pressed={hex.toLowerCase() === toHex8(value)}
|
||||
className={styles.recentColor}
|
||||
onClick={() => {
|
||||
const next = fromHex(hex);
|
||||
if (next) update(next);
|
||||
}}
|
||||
>
|
||||
<span style={{ backgroundColor: hex }} />
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
<div className={styles.actions}>
|
||||
<Button size="small" onClick={() => closeColorPicker()}>
|
||||
<T>Cancel</T>
|
||||
</Button>
|
||||
<Button type="submit" variant="primary" size="small">
|
||||
<T>Apply</T>
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
</Popup>
|
||||
initial={request.value}
|
||||
onChange={(value) => {
|
||||
if (sequence !== id || !active) return;
|
||||
active = { ...active, value };
|
||||
request.onChange?.(value);
|
||||
}}
|
||||
onFinish={(commit) => {
|
||||
if (sequence === id) closeColorPicker(commit);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
import { hex2, toHex6, type Rgba } from "@/ui/colorPickerValues";
|
||||
export { fromHex, toHex6, toHex8, type Rgba } from "@/ui/colorPickerValues";
|
||||
|
||||
/**
|
||||
* Color literals of a line for the gutter's color preview: `#rgb` / `#rrggbb` (with alpha),
|
||||
* `rgb()` / `rgba()` / `hsl()` / `hsla()`, and CSS named colors in style sheets. Pure; the
|
||||
@@ -14,9 +17,6 @@ export interface ColorMatch {
|
||||
format: ColorFormat;
|
||||
}
|
||||
|
||||
/** Red, green, blue 0–255 and alpha 0–1. */
|
||||
export type Rgba = [number, number, number, number];
|
||||
|
||||
/** Style sheet languages: named colors and unquoted hex values are colors there. */
|
||||
const STYLE_SHEETS = new Set(["css", "scss", "sass", "less", "stylus", "postcss"]);
|
||||
/** Markup that embeds style sheets (`<style>`, `style="…"`): unquoted hex values too. */
|
||||
@@ -72,34 +72,8 @@ export function findColors(line: string, language: string, isColorName: (word: s
|
||||
}
|
||||
|
||||
const clamp = (v: number, lo: number, hi: number) => Math.min(hi, Math.max(lo, v));
|
||||
const hex2 = (v: number) =>
|
||||
Math.round(clamp(v, 0, 255))
|
||||
.toString(16)
|
||||
.padStart(2, "0");
|
||||
const round = (v: number, digits = 2) => String(Number(v.toFixed(digits)));
|
||||
|
||||
/** `#rrggbb` of `rgba`, as `<input type=color>` takes it. */
|
||||
export function toHex6([r, g, b]: Rgba): string {
|
||||
return `#${hex2(r)}${hex2(g)}${hex2(b)}`;
|
||||
}
|
||||
|
||||
export function toHex8(rgba: Rgba): string {
|
||||
return `${toHex6(rgba)}${hex2(rgba[3] * 255)}`;
|
||||
}
|
||||
|
||||
/** Six-digit hex is opaque; eight-digit hex carries its own alpha. */
|
||||
export function fromHex(hex: string): Rgba | null {
|
||||
const m = /^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})?$/i.exec(hex);
|
||||
return m
|
||||
? [
|
||||
Number.parseInt(m[1]!, 16),
|
||||
Number.parseInt(m[2]!, 16),
|
||||
Number.parseInt(m[3]!, 16),
|
||||
m[4] ? Number.parseInt(m[4], 16) / 255 : 1,
|
||||
]
|
||||
: null;
|
||||
}
|
||||
|
||||
/** Components of the browser's computed color (`rgb(1, 2, 3)` / `rgba(1, 2, 3, 0.5)`), null for other spaces. */
|
||||
export function parseComputed(color: string): Rgba | null {
|
||||
const m = /^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:\s*[,/]\s*([\d.]+%?))?\s*\)$/.exec(color.trim());
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { LaunchConfig } from "@/platform/ipc";
|
||||
import { useProject } from "@/platform/project";
|
||||
import { handleDebugEvent, resetSessions, startSession, useDebug } from "../state";
|
||||
|
||||
const ipc = vi.hoisted(() => {
|
||||
let next = 0;
|
||||
return {
|
||||
/** A backend process numbers its sessions from 1. */
|
||||
restart: () => (next = 0),
|
||||
debugStart: vi.fn(async (_launch: unknown) => ({ status: "ok", data: ++next })),
|
||||
debugStop: vi.fn(async (_id: number) => ({ status: "ok", data: null })),
|
||||
};
|
||||
});
|
||||
vi.mock("@/platform/ipc", async (original) => {
|
||||
const real = await original<typeof import("@/platform/ipc")>();
|
||||
const { restart: _restart, ...commands } = ipc;
|
||||
return { ...real, isTauri: () => true, commands: { ...real.commands, ...commands } };
|
||||
});
|
||||
|
||||
const launch: LaunchConfig = {
|
||||
name: "pricing > withTax > adds the rate",
|
||||
adapter: "js-debug",
|
||||
request: "launch",
|
||||
program: null,
|
||||
args: [],
|
||||
cwd: "/p",
|
||||
env: {},
|
||||
extraJson: JSON.stringify({ type: "pwa-node", runtimeExecutable: "npm", runtimeArgs: ["run", "test"] }),
|
||||
};
|
||||
|
||||
/** js-debug's session for a process the debuggee started (`startDebugging`). */
|
||||
const child = (id: number, parent: number, name: string) =>
|
||||
handleDebugEvent(id, { kind: "started", name, adapter: "js-debug", parent });
|
||||
const breakpoint = (id: number) =>
|
||||
handleDebugEvent(id, {
|
||||
kind: "stopped",
|
||||
threadId: 1,
|
||||
reason: "breakpoint",
|
||||
description: null,
|
||||
allThreadsStopped: false,
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
useDebug.setState({ sessions: {}, active: null });
|
||||
resetSessions();
|
||||
ipc.restart();
|
||||
useProject.setState({
|
||||
project: { root: "/p" } as ReturnType<typeof useProject.getState>["project"],
|
||||
settings: null,
|
||||
});
|
||||
});
|
||||
|
||||
describe("sessions of a window whose backend changes", () => {
|
||||
it("adopts the children of a new session although an earlier backend used their ids", async () => {
|
||||
// The first backend: `npm run test` and the process js-debug attached to under it.
|
||||
expect(await startSession(launch)).toBe(1);
|
||||
child(2, 1, "npm-cli.js [100]");
|
||||
expect(useDebug.getState().sessions[2]?.parent).toBe(1);
|
||||
|
||||
// The window reopens its project on another backend (a remote reconnect): ids start over.
|
||||
resetSessions();
|
||||
ipc.restart();
|
||||
expect(await startSession(launch)).toBe(1);
|
||||
child(2, 1, "npm-cli.js [200]");
|
||||
child(3, 2, "mocha.js [201]");
|
||||
breakpoint(3);
|
||||
|
||||
const { sessions, active } = useDebug.getState();
|
||||
expect([sessions[2]?.name, sessions[2]?.parent]).toEqual(["npm-cli.js [200]", 1]);
|
||||
expect([sessions[3]?.name, sessions[3]?.parent, sessions[3]?.status]).toEqual(["mocha.js [201]", 2, "paused"]);
|
||||
expect(active).toBe(3);
|
||||
});
|
||||
|
||||
it("still ignores late events of the sessions it forgot", async () => {
|
||||
await startSession(launch);
|
||||
child(2, 1, "npm-cli.js [100]");
|
||||
resetSessions();
|
||||
|
||||
breakpoint(2);
|
||||
handleDebugEvent(1, { kind: "output", category: "stdout", output: "late\n" });
|
||||
expect(useDebug.getState().sessions).toEqual({});
|
||||
expect(useDebug.getState().console).toEqual({});
|
||||
});
|
||||
});
|
||||
@@ -307,7 +307,9 @@ function ownSession(id: DebugSessionId, event: DebugEvent): DebugSession | null
|
||||
const st = useDebug.getState();
|
||||
const existing = st.sessions[id];
|
||||
if (existing) return existing;
|
||||
if (owned.has(id)) return null;
|
||||
// `started` is a session's first event, sent once when the backend creates it: never a late event
|
||||
// of a forgotten session, though its id may be one (another backend numbers from 1 again).
|
||||
if (owned.has(id) && event.kind !== "started") return null;
|
||||
if (event.kind === "started" && event.parent != null) {
|
||||
if (!st.sessions[event.parent]) return null;
|
||||
return adoptSession(id, { name: event.name, adapter: event.adapter, parent: event.parent });
|
||||
|
||||
@@ -55,8 +55,7 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1);
|
||||
/* Cap the automatic flex minimum at the space needed for a short preview. */
|
||||
width: min(14ch, 50%);
|
||||
min-width: min(8ch, 45%);
|
||||
flex: 1 1 0;
|
||||
}
|
||||
|
||||
@@ -136,8 +135,9 @@
|
||||
}
|
||||
|
||||
.type {
|
||||
min-width: min(3ch, 10%);
|
||||
flex: 0 4 auto;
|
||||
min-width: 0;
|
||||
max-width: 25%;
|
||||
flex: 0 1 auto;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
color: var(--fg-subtle);
|
||||
|
||||
@@ -221,6 +221,8 @@ export function testBasesFor(relPath: string, configs: RunConfig[], content?: st
|
||||
// Configurations produced from a test or file are results of narrowing, never bases for it.
|
||||
const candidates = configs
|
||||
.filter((c) => c.isTest && kinds.includes(c.kind) && !c.id.startsWith("context:"))
|
||||
// `node` configurations run a file of their own; only Playwright's (`npx playwright test`) take a test file.
|
||||
.filter((c) => c.kind !== "node" || frameworkFor(c) === "playwright")
|
||||
.sort((a, b) => kinds.indexOf(a.kind) - kinds.indexOf(b.kind));
|
||||
const best = allClosest(candidates, relPath);
|
||||
if (best.length) return content === undefined ? best : byRunner(best, content);
|
||||
|
||||
@@ -32,7 +32,15 @@ import { firstTopLevelType, scanJvmTargets, simpleClassName } from "./jvmTargets
|
||||
import { isWindows } from "./jvmTypes";
|
||||
import { inheritedRunTargets } from "./inheritedMain";
|
||||
import { withMavenTests } from "./mavenTests";
|
||||
import { detectRunTargets, goFuzzConfig, targetConfig, targetLanguage, zigTargets, type RunTarget } from "./targets";
|
||||
import {
|
||||
detectRunTargets,
|
||||
goFuzzConfig,
|
||||
targetConfig,
|
||||
targetLanguage,
|
||||
testsInTestDirectory,
|
||||
zigTargets,
|
||||
type RunTarget,
|
||||
} from "./targets";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
export interface LocatedTool {
|
||||
@@ -1137,7 +1145,7 @@ export function fileTargets(
|
||||
(t) => t.kind === "main" && (!t.className || /\.(java|kt)$/.test(input.path)),
|
||||
);
|
||||
}
|
||||
const targets = detectRunTargets(content, s.rel, hasDjangoTests(input.configs));
|
||||
const targets = detectRunTargets(content, s.rel, hasDjangoTests(input.configs), testsInTestDirectory(input.configs));
|
||||
return /\.java$/.test(input.path) ? [...targets, ...inheritedRunTargets(input.path, content)] : targets;
|
||||
}
|
||||
|
||||
|
||||
@@ -714,8 +714,8 @@ function newRuntime(config: RunConfig): SessionRuntime {
|
||||
if (tests && parser) tests.apply(parser.feed(line));
|
||||
};
|
||||
const framework = tests && parser ? frameworkFor(config) : null;
|
||||
// PHPUnit `--teamcity` and Gradle's test init script report through service messages, Minitest and
|
||||
// node:test through the IDE's own reporters (RSpec has none: its progress dots must show as they come).
|
||||
// PHPUnit `--teamcity` and Gradle's test init script report through service messages, Minitest,
|
||||
// node:test and Mocha through the IDE's own reporters (RSpec has none: its progress dots must show as they come).
|
||||
const stdout =
|
||||
framework === "go"
|
||||
? new GoTestOutput(feed)
|
||||
@@ -723,7 +723,7 @@ function newRuntime(config: RunConfig): SessionRuntime {
|
||||
? new TeamcityOutput(feed)
|
||||
: framework === "ruby" && config.kind !== "rspec"
|
||||
? new RubyTestOutput(feed)
|
||||
: framework === "node-test"
|
||||
: framework === "node-test" || framework === "mocha"
|
||||
? new RecordsOutput(feed)
|
||||
: null;
|
||||
const runtime: SessionRuntime = {
|
||||
|
||||
@@ -134,9 +134,9 @@ function rustTargets(lines: string[], relPath: string): RunTarget[] {
|
||||
);
|
||||
}
|
||||
|
||||
/** Jest / Vitest `describe` / `test` / `it`, and Playwright's `test.describe` and modifiers. */
|
||||
/** Jest / Vitest `describe` / `test` / `it` (Mocha's `specify` too), and Playwright's `test.describe` and modifiers. */
|
||||
const JS_RE =
|
||||
/^(\s*)(test\.describe|describe|suite|context|test|it)\b(?:\.(?:only|skip|todo|concurrent|failing|sequential|fixme|fail|serial|parallel))*(\.each\s*(?:\(.*?\)|`[^`]*`))?\s*\(\s*(['"`])((?:\\.|(?!\4).)*)\4/;
|
||||
/^(\s*)(test\.describe|describe|suite|context|test|it|specify)\b(?:\.(?:only|skip|todo|concurrent|failing|sequential|fixme|fail|serial|parallel))*(\.each\s*(?:\(.*?\)|`[^`]*`))?\s*\(\s*(['"`])((?:\\.|(?!\4).)*)\4/;
|
||||
|
||||
function jsTargets(lines: string[]): RunTarget[] {
|
||||
const out: RunTarget[] = [];
|
||||
@@ -352,10 +352,6 @@ function jvmTargets(lines: string[], relPath: string): RunTarget[] {
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run targets of a file (relative path picks the language). `django`: a Django project, where
|
||||
* `tests.py` (Django's default test module) holds tests too.
|
||||
*/
|
||||
/** Zig: a top-level `pub fn main` and `test "name" {` / `test name {` blocks, nested ones too. */
|
||||
export function zigTargets(content: string): RunTarget[] {
|
||||
if (content.length > MAX_SCAN) return [];
|
||||
@@ -372,7 +368,17 @@ export function zigTargets(content: string): RunTarget[] {
|
||||
return out;
|
||||
}
|
||||
|
||||
export function detectRunTargets(text: string, relPath: string, django = false): RunTarget[] {
|
||||
/** Whether the project tests with Mocha or `node --test`, which look in `test/` by default, whatever a file's name. */
|
||||
export function testsInTestDirectory(configs: readonly RunConfig[]): boolean {
|
||||
return configs.some((c) => c.isTest && ["mocha", "node-test"].includes(frameworkFor(c)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Run targets of a file (relative path picks the language). `django`: a Django project, where
|
||||
* `tests.py` (Django's default test module) holds tests too. `testDirectory`: JS files in `test/`
|
||||
* hold tests whatever their name (`testsInTestDirectory`).
|
||||
*/
|
||||
export function detectRunTargets(text: string, relPath: string, django = false, testDirectory = false): RunTarget[] {
|
||||
if (text.length > MAX_SCAN) return [];
|
||||
const lines = text.split("\n");
|
||||
switch (targetLanguage(relPath)) {
|
||||
@@ -381,7 +387,10 @@ export function detectRunTargets(text: string, relPath: string, django = false):
|
||||
case "rust":
|
||||
return rustTargets(lines, relPath);
|
||||
case "js":
|
||||
return /\.(test|spec)\.[cm]?[jt]sx?$|(^|\/)__tests__\//.test(relPath) ? jsTargets(lines) : [];
|
||||
return /\.(test|spec)\.[cm]?[jt]sx?$|(^|\/)__tests__\//.test(relPath) ||
|
||||
(testDirectory && /(^|\/)test\//.test(relPath))
|
||||
? jsTargets(lines)
|
||||
: [];
|
||||
case "python":
|
||||
return pythonTargets(lines).filter(
|
||||
(t) =>
|
||||
@@ -477,6 +486,7 @@ export function targetConfig(
|
||||
// node:test selects by full name, through NODE_OPTIONS (see `nodeTest.ts`).
|
||||
if (frameworkFor(file) === "node-test")
|
||||
return { ...named(file.args), env: withNodeTestNamePattern(file.env, jsNamePattern(target)) };
|
||||
if (frameworkFor(file) === "mocha") return named([...file.args, "--grep", jsNamePattern(target)]);
|
||||
switch (file.kind) {
|
||||
case "dotnet-test": {
|
||||
const methods =
|
||||
|
||||
@@ -4,6 +4,7 @@ import { cargoParser } from "./cargo";
|
||||
import { goParser } from "./go";
|
||||
import { jsParser } from "./js";
|
||||
import { jvmParser } from "./jvm";
|
||||
import { withMochaHook } from "./mocha";
|
||||
import { withNodeTestReporter } from "./nodeTest";
|
||||
import { recordsParser } from "./records";
|
||||
import { phpunitParser, withTeamcity } from "./phpunit";
|
||||
@@ -45,6 +46,7 @@ export type Framework =
|
||||
| "js"
|
||||
| "playwright"
|
||||
| "node-test"
|
||||
| "mocha"
|
||||
| "pytest"
|
||||
| "unittest"
|
||||
| "phpunit"
|
||||
@@ -63,6 +65,7 @@ export function frameworkFor(config: FrameworkConfig): Framework {
|
||||
if (config.testRunner === "playwright" || /\bplaywright\s+test\b/.test(cmd)) return "playwright";
|
||||
if (config.testRunner === "node-test" || /(^|[\s/\\])(node|tsx)(\.exe)?(\s+-\S*)*\s+--test(\s|$)/.test(cmd))
|
||||
return "node-test";
|
||||
if (config.testRunner === "mocha" || /(^|[\s/\\])_?mocha(\.cmd|\.js)?(\s|$)/.test(cmd)) return "mocha";
|
||||
switch (config.kind) {
|
||||
case "dotnet-test":
|
||||
return "dotnet";
|
||||
@@ -127,6 +130,7 @@ function rubyVerbose<T extends Pick<RunConfig, "kind" | "command" | "args">>(con
|
||||
*/
|
||||
export function withTestReporting<T extends FrameworkConfig>(config: T): T {
|
||||
if (frameworkFor(config) === "node-test") return { ...config, env: withNodeTestReporter(config.env ?? {}) };
|
||||
if (frameworkFor(config) === "mocha") return { ...config, env: withMochaHook(config.env ?? {}) };
|
||||
if (frameworkFor(config) === "playwright") {
|
||||
// The list reporter prints a line per test; a project's own (`html`, `dot` on CI) may print none.
|
||||
const chosen = config.args.some((a) => a === "--reporter" || a.startsWith("--reporter="));
|
||||
@@ -170,6 +174,7 @@ export function createTestParser(config: FrameworkConfig): TestOutputParser {
|
||||
case "playwright":
|
||||
return playwrightParser();
|
||||
case "node-test":
|
||||
case "mocha":
|
||||
return recordsParser();
|
||||
case "pytest":
|
||||
return pytestParser();
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { RunConfig } from "@/platform/ipc";
|
||||
import { detectRunTargets, targetConfig, testsInTestDirectory } from "../targets";
|
||||
import { createTestParser, frameworkFor, nodeOutput, parseAll, TestResults, withTestReporting } from "./index";
|
||||
import { failedTestPaths, rerunFailedConfigs } from "./rerun";
|
||||
|
||||
const cfg = (over: Partial<RunConfig> & { id: string; kind: string }): RunConfig => ({
|
||||
name: over.id,
|
||||
command: over.kind,
|
||||
args: [],
|
||||
cwd: null,
|
||||
env: {},
|
||||
detected: true,
|
||||
isTest: true,
|
||||
debugAdapter: "js-debug",
|
||||
...over,
|
||||
});
|
||||
|
||||
/** `npm run test` whose script is `mocha` (detection records the runner). */
|
||||
const script = cfg({ id: "npm:test", kind: "npm", command: "npm", args: ["run", "test"], testRunner: "mocha" });
|
||||
|
||||
// `mocha` (10.8, spec reporter) with the IDE's hook, as printed.
|
||||
const OUTPUT = String.raw`
|
||||
|
||||
pricing
|
||||
withTax
|
||||
✔ adds the rate
|
||||
@@openidea:test@@{"path":["test/pricing.spec.js","pricing","withTax","adds the rate"],"status":"passed","ms":0,"line":6,"col":5}
|
||||
1) intentionally fails (set OPENIDEA_FAIL=1)
|
||||
@@openidea:test@@{"path":["test/pricing.spec.js","pricing","intentionally fails (set OPENIDEA_FAIL=1)"],"status":"failed","ms":1,"line":25,"col":3,"error":"AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:\n\n11 !== 11.5\n\n at Context.<anonymous> (file:///work/shop/test/pricing.spec.js:27:12)"}
|
||||
- later
|
||||
@@openidea:test@@{"path":["test/pricing.spec.js","pricing","later"],"status":"skipped","line":29,"col":3}
|
||||
|
||||
1 passing (3ms)
|
||||
1 pending
|
||||
1 failing
|
||||
`;
|
||||
|
||||
function results(text: string) {
|
||||
const r = new TestResults();
|
||||
r.apply(parseAll(createTestParser(script), text));
|
||||
return r;
|
||||
}
|
||||
|
||||
describe("Mocha runs", () => {
|
||||
it("are recognised by the recorded runner or the command line", () => {
|
||||
expect(frameworkFor(script)).toBe("mocha");
|
||||
expect(frameworkFor(cfg({ id: "x", kind: "node", command: "npx", args: ["mocha", "--recursive"] }))).toBe("mocha");
|
||||
expect(frameworkFor(cfg({ id: "x", kind: "shell", command: "./node_modules/.bin/_mocha", args: [] }))).toBe(
|
||||
"mocha",
|
||||
);
|
||||
expect(frameworkFor(cfg({ id: "x", kind: "node", command: "node", args: ["mocha.config.js"] }))).not.toBe("mocha");
|
||||
});
|
||||
|
||||
it("load the IDE's hook through NODE_OPTIONS, once", () => {
|
||||
const launched = withTestReporting({ ...script, env: { NODE_OPTIONS: "--enable-source-maps" } });
|
||||
const [own, hook] = launched.env.NODE_OPTIONS!.split(" ");
|
||||
expect(own).toBe("--enable-source-maps");
|
||||
expect(hook).toMatch(/^--import=data:text\/javascript;base64,/);
|
||||
expect(withTestReporting(launched).env).toEqual(launched.env);
|
||||
expect(launched.args).toEqual(script.args);
|
||||
});
|
||||
|
||||
it("build the tree from the hook's records, with declaration lines and failures", () => {
|
||||
const r = results(OUTPUT);
|
||||
expect(r.counts()).toMatchObject({ passed: 1, failed: 1, skipped: 1 });
|
||||
const adds = r.get(["test/pricing.spec.js", "pricing", "withTax", "adds the rate"].join("\u0000"))!;
|
||||
expect(adds.location).toEqual({ path: "test/pricing.spec.js", line: 6, col: 5, resolve: "path" });
|
||||
expect(nodeOutput(r.firstFailure()!).join("\n")).toContain("11 !== 11.5");
|
||||
});
|
||||
|
||||
it("rerun failed tests by file and full title with --grep", async () => {
|
||||
const [rerun] = await rerunFailedConfigs(
|
||||
{ ...script, args: ["run", "test", "--", "--grep", "old"] },
|
||||
failedTestPaths(results(OUTPUT)),
|
||||
);
|
||||
expect(rerun!.args).toEqual([
|
||||
"run",
|
||||
"test",
|
||||
"--",
|
||||
"test/pricing.spec.js",
|
||||
"--grep",
|
||||
"^(?:pricing intentionally fails \\(set OPENIDEA_FAIL=1\\))$",
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Mocha gutter targets", () => {
|
||||
const src = [
|
||||
"describe('pricing', function () {", // 0
|
||||
" specify('adds tax', function () {});", // 1
|
||||
" context('bulk', function () {", // 2
|
||||
" it('discounts', function () {});", // 3
|
||||
" });",
|
||||
"});",
|
||||
].join("\n");
|
||||
|
||||
it("are found in test/ whatever the file's name in Mocha projects, `specify` included", () => {
|
||||
expect(testsInTestDirectory([script])).toBe(true);
|
||||
expect(
|
||||
detectRunTargets(src, "test/pricing.js", false, true).map((t) => [t.line, t.kind, t.path.join("/")]),
|
||||
).toEqual([
|
||||
[0, "suite", "pricing"],
|
||||
[1, "test", "pricing/adds tax"],
|
||||
[2, "suite", "pricing/bulk"],
|
||||
[3, "test", "pricing/bulk/discounts"],
|
||||
]);
|
||||
expect(detectRunTargets(src, "lib/pricing.js", false, true)).toEqual([]);
|
||||
});
|
||||
|
||||
it("are not looked for in test/ of a Jest or Vitest project", () => {
|
||||
const vitest = cfg({ id: "npm:test", kind: "npm", command: "npm", args: ["run", "test"] });
|
||||
expect(testsInTestDirectory([vitest])).toBe(false);
|
||||
expect(detectRunTargets(src, "test/pricing.js")).toEqual([]);
|
||||
expect(detectRunTargets(src, "test/pricing.test.js")).toHaveLength(4);
|
||||
});
|
||||
|
||||
it("run by file and full title", () => {
|
||||
const targets = detectRunTargets(src, "test/pricing.js", false, true);
|
||||
expect(targetConfig(targets[3]!, "test/pricing.js", [script], src)?.args).toEqual([
|
||||
"run",
|
||||
"test",
|
||||
"--",
|
||||
"test/pricing.js",
|
||||
"--grep",
|
||||
"^pricing bulk discounts$",
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Mocha: the IDE's hook (`mochaHook.js`), imported through `NODE_OPTIONS`, prints a record per
|
||||
* finished test (`records.ts`) next to the run's own reporter, whichever it is. Tests are selected
|
||||
* with Mocha's own `--grep`.
|
||||
*/
|
||||
import HOOK_SOURCE from "./mochaHook.js?raw";
|
||||
|
||||
const HOOK = `--import=data:text/javascript;base64,${btoa(HOOK_SOURCE)}`;
|
||||
|
||||
/** `NODE_OPTIONS` with the IDE's hook added (once). */
|
||||
export function withMochaHook(env: Record<string, string>): Record<string, string> {
|
||||
const options = env.NODE_OPTIONS ?? "";
|
||||
if (options.includes(HOOK)) return env;
|
||||
return { ...env, NODE_OPTIONS: [options, HOOK].filter(Boolean).join(" ") };
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
// The IDE's Mocha hook (`--import`, passed as a data: URL through NODE_OPTIONS): once Mocha is
|
||||
// loaded, every test a run reports also prints a record (`records.ts`) next to the run's own
|
||||
// reporter, with the line the test is declared on (Mocha reports none). Runs in the user's
|
||||
// Node (20+), so plain ESM without dependencies; reporting must never break a test run.
|
||||
import Module from "node:module";
|
||||
import { relative, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const MARK = "@@openidea:test@@";
|
||||
const DECLARED = Symbol("openidea.declared");
|
||||
const FRAME = /(?:\(|\s)((?:file:\/\/\/?)?(?:[A-Za-z]:)?[^:()]+):(\d+):(\d+)\)?$/;
|
||||
|
||||
const fileOf = (path) => relative(process.cwd(), path).split("\\").join("/");
|
||||
|
||||
/** Where in `file` the code running now was called from: a test's declaration while Mocha loads the file. */
|
||||
function declaredIn(file) {
|
||||
for (const frame of (new Error().stack ?? "").split("\n").slice(1)) {
|
||||
const m = FRAME.exec(frame);
|
||||
if (!m) continue;
|
||||
const path = m[1].startsWith("file:") ? fileURLToPath(m[1]) : m[1];
|
||||
if (resolve(path) === file) return { line: Number(m[2]), col: Number(m[3]) };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function report(test, status, error) {
|
||||
try {
|
||||
if (!test.file) return;
|
||||
const at = test[DECLARED];
|
||||
const record = {
|
||||
path: [fileOf(test.file), ...test.titlePath()],
|
||||
status,
|
||||
ms: test.duration,
|
||||
line: at?.line,
|
||||
col: at?.col,
|
||||
error: error === undefined ? undefined : String((error && error.stack) || error),
|
||||
};
|
||||
process.stdout.write(`${MARK}${JSON.stringify(record)}\n`);
|
||||
} catch {
|
||||
// A test object without its usual shape (a plugin's): no record.
|
||||
}
|
||||
}
|
||||
|
||||
function watch(Mocha) {
|
||||
const addTest = Mocha.Suite.prototype.addTest;
|
||||
Mocha.Suite.prototype.addTest = function (test) {
|
||||
try {
|
||||
if (test && test.file) test[DECLARED] = declaredIn(resolve(test.file));
|
||||
} catch {
|
||||
// No declaration line.
|
||||
}
|
||||
return addTest.call(this, test);
|
||||
};
|
||||
const run = Mocha.Runner.prototype.run;
|
||||
Mocha.Runner.prototype.run = function (...args) {
|
||||
this.on("pass", (test) => report(test, "passed"));
|
||||
this.on("pending", (test) => report(test, "skipped"));
|
||||
// A failing hook fails the test it ran for, or reports as itself.
|
||||
this.on("fail", (runnable, error) =>
|
||||
report(runnable.type === "hook" ? (runnable.ctx?.currentTest ?? runnable) : runnable, "failed", error),
|
||||
);
|
||||
return run.apply(this, args);
|
||||
};
|
||||
}
|
||||
|
||||
const load = Module._load;
|
||||
let watching = false;
|
||||
Module._load = function (...args) {
|
||||
const exports = load.apply(this, args);
|
||||
if (!watching && typeof exports === "function" && exports.Runner && exports.Suite && exports.reporters) {
|
||||
watching = true;
|
||||
try {
|
||||
watch(exports);
|
||||
} catch {
|
||||
// Another Mocha than expected: the run goes on without records.
|
||||
}
|
||||
}
|
||||
return exports;
|
||||
};
|
||||
Loaded 100 of 140 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user