feat(plugins): read the Maven / Gradle dependency graph (API 1.10) (#3829)

Plugins had to run mvn dependency:tree / gradlew dependencies themselves or parse build files. A new build interface in wit/workspace.wit, build.dependencies(project, module), returns the graph the Dependency Analyzer has as a flat list of dependency-node records (group, artifact, version, scope, status, requested version, parent), each module a root, behind the low-risk build.read capability in trusted projects. Nothing is resolved by the call: Maven returns the trees cached by the last Reload (declared dependencies before one); Gradle dependency reports, which only lived in the frontend, are now saved per project and configuration in the build cache and dropped on a build-file change. Capped at 100,000 nodes per call. SDK: Project::build_dependencies with a mock; checked-in components rebuilt.

Closes #3715

Co-authored-by: bertyhell <1710840+bertyhell@users.noreply.github.com>
This commit is contained in:
Bert Verhelst
2026-11-17 03:29:39 +08:00
committed by GitHub
co-authored by bertyhell
parent 2b69d64055
commit e6daffae76
124 changed files with 1509 additions and 77 deletions
+83 -1
View File
@@ -1,13 +1,16 @@
//! A Gradle project's resolved dependencies for the Dependency Analyzer:
//! `gradle <project>:dependencies --configuration <name>`, parsed from its tree report.
//! The reports it read are kept per build ([`save_gradle_report`]) until a build file
//! changes, for readers that must not run Gradle themselves (plugins).
use crate::gradle;
use crate::process;
use crate::sync::{SyncOptions, error_summary};
use crate::sync::{self, SyncOptions, error_summary};
use ide_core::{CancellationToken, IdeError, IdeResult};
use serde::{Deserialize, Serialize};
use specta::Type;
use std::path::Path;
use std::sync::Mutex;
/// One line of the report: an occurrence of a dependency where it is requested.
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)]
@@ -158,6 +161,54 @@ pub fn gradle_dependencies(
Ok(parse_report(&out.text))
}
/// A `dependencies` report of one project of a build for one configuration.
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct GradleReport {
/// Gradle path of the project (`:`, `:app`).
pub project: String,
pub configuration: String,
pub dependencies: Vec<GradleDependency>,
}
#[derive(Default, Serialize, Deserialize)]
struct ReportCache {
/// The build files the reports were read with ([`sync::hash_gradle_files`]).
hash: String,
reports: Vec<GradleReport>,
}
const REPORT_CACHE: &str = "gradle-dependencies.json";
/// Keeps `report` with the build's other reports (`cache_dir` is the build's cache
/// directory), replacing an earlier one of the same project and configuration. Reports
/// read before a build file changed are dropped.
pub fn save_gradle_report(
root: &Path,
cache_dir: &Path,
model: &gradle::GradleModel,
report: &GradleReport,
) -> IdeResult<()> {
// Reports of several configurations may finish together: one read-modify-write at a time.
static SAVING: Mutex<()> = Mutex::new(());
let _saving = SAVING.lock().unwrap_or_else(|e| e.into_inner());
let hash = sync::hash_gradle_files(&gradle::build_files(root, model));
let mut cache = sync::read_cache::<ReportCache>(cache_dir, REPORT_CACHE)
.filter(|c| c.hash == hash)
.unwrap_or_else(|| ReportCache { hash, reports: Vec::new() });
cache.reports.retain(|r| (&r.project, &r.configuration) != (&report.project, &report.configuration));
cache.reports.push(report.clone());
sync::write_cache(cache_dir, REPORT_CACHE, &cache)
}
/// The reports kept for the build, unless a build file changed since they were read.
pub fn gradle_reports(root: &Path, cache_dir: &Path, model: &gradle::GradleModel) -> Vec<GradleReport> {
let Some(cache) = sync::read_cache::<ReportCache>(cache_dir, REPORT_CACHE) else { return Vec::new() };
if cache.hash != sync::hash_gradle_files(&gradle::build_files(root, model)) {
return Vec::new();
}
cache.reports
}
#[cfg(test)]
mod tests {
use super::*;
@@ -234,6 +285,37 @@ runtimeClasspath - Runtime classpath of source set 'main'.
);
}
#[test]
fn reports_are_kept_per_project_and_configuration_until_a_build_file_changes() {
let tmp = tempfile::tempdir().unwrap();
let root = tmp.path();
let cache = root.join("cache");
std::fs::write(root.join("settings.gradle"), "include 'app'").unwrap();
std::fs::write(root.join("build.gradle"), "").unwrap();
let model = gradle::load(root).unwrap();
assert!(gradle_reports(root, &cache, &model).is_empty());
let report = |project: &str, configuration: &str, version: &str| GradleReport {
project: project.into(),
configuration: configuration.into(),
dependencies: vec![dep("org.a", "b", Some(version))],
};
save_gradle_report(root, &cache, &model, &report(":app", "runtimeClasspath", "1.0")).unwrap();
save_gradle_report(root, &cache, &model, &report(":app", "compileClasspath", "1.0")).unwrap();
// Reading a report again replaces what was read before.
save_gradle_report(root, &cache, &model, &report(":app", "runtimeClasspath", "2.0")).unwrap();
assert_eq!(
gradle_reports(root, &cache, &model),
[report(":app", "compileClasspath", "1.0"), report(":app", "runtimeClasspath", "2.0")]
);
// A comment changes nothing Gradle reads; a dependency does.
std::fs::write(root.join("build.gradle"), "// notes").unwrap();
assert_eq!(gradle_reports(root, &cache, &model).len(), 2);
std::fs::write(root.join("build.gradle"), "dependencies { implementation 'org.a:b:3.0' }").unwrap();
assert!(gradle_reports(root, &cache, &model).is_empty());
save_gradle_report(root, &cache, &model, &report(":", "compileClasspath", "3.0")).unwrap();
assert_eq!(gradle_reports(root, &cache, &model), [report(":", "compileClasspath", "3.0")]);
}
#[cfg(unix)]
#[test]
fn runs_the_report_of_the_project_and_configuration() {
+1 -1
View File
@@ -19,7 +19,7 @@ pub mod web;
mod xml;
pub use gradle::{GradleModel, GradleProject, GradleTask};
pub use gradle_deps::{GradleDependency, gradle_dependencies};
pub use gradle_deps::{GradleDependency, GradleReport, gradle_dependencies, gradle_reports, save_gradle_report};
pub use maven::{MavenDependency, MavenModel, MavenPlugin, MavenProfile, MavenProject, Omission};
pub use sbt::{SbtBuild, SbtProject};
pub use sync::{
+3 -3
View File
@@ -136,11 +136,11 @@ pub fn save_maven_profiles(cache_dir: &Path, profiles: &[String]) -> IdeResult<b
Ok(true)
}
fn read_cache<T: DeserializeOwned>(dir: &Path, name: &str) -> Option<T> {
pub(crate) fn read_cache<T: DeserializeOwned>(dir: &Path, name: &str) -> Option<T> {
serde_json::from_slice(&std::fs::read(dir.join(name)).ok()?).ok()
}
fn write_cache<T: Serialize>(dir: &Path, name: &str, value: &T) -> IdeResult<()> {
pub(crate) fn write_cache<T: Serialize>(dir: &Path, name: &str, value: &T) -> IdeResult<()> {
std::fs::create_dir_all(dir)?;
let json = serde_json::to_vec(value).map_err(|e| IdeError::internal(e.to_string()))?;
let tmp = dir.join(format!("{name}.tmp"));
@@ -156,7 +156,7 @@ fn hash_files(files: &[PathBuf]) -> String {
/// Like IDEA's auto-import CRC: editing a comment or reformatting a build script
/// does not make the last sync stale.
fn hash_gradle_files(files: &[PathBuf]) -> String {
pub(crate) fn hash_gradle_files(files: &[PathBuf]) -> String {
hash_contents(files, |f| {
let text = std::fs::read_to_string(f).unwrap_or_default();
let script = f.extension().is_some_and(|e| e == "gradle" || e == "kts");
+10 -1
View File
@@ -26,6 +26,8 @@ pub enum Capability {
DatabaseSources,
VcsRead,
VcsWrite,
/// The Maven / Gradle dependency graph the IDE resolved.
BuildRead,
/// The plugin's own key-value store and data directory.
Storage,
/// The plugin's own secrets (kept in the client's OS keychain).
@@ -75,7 +77,9 @@ pub enum Risk {
impl Capability {
pub fn risk(&self) -> Risk {
match self {
Self::ProjectRead | Self::EditorRead | Self::Storage | Self::Events | Self::VcsRead => Risk::Low,
Self::ProjectRead | Self::EditorRead | Self::Storage | Self::Events | Self::VcsRead | Self::BuildRead => {
Risk::Low
}
Self::EditorWrite
| Self::DatabaseSources
| Self::VcsWrite
@@ -115,6 +119,7 @@ impl Capability {
Self::IdeCommands => "Run any IDE action or other plugins' commands as if you chose them, including running programs, committing and pushing".into(),
Self::VcsRead => "Read version control state".into(),
Self::VcsWrite => "Change version control state (commit, fetch, checkout)".into(),
Self::BuildRead => "Read the project's resolved Maven and Gradle dependencies".into(),
Self::Storage => "Store its own data".into(),
Self::Secrets => "Store secrets in the system keychain".into(),
Self::Events => "Observe editor, filesystem and version control events".into(),
@@ -251,6 +256,7 @@ impl fmt::Display for Capability {
Self::DatabaseSources => f.write_str("database.sources"),
Self::VcsRead => f.write_str("vcs.read"),
Self::VcsWrite => f.write_str("vcs.write"),
Self::BuildRead => f.write_str("build.read"),
Self::Storage => f.write_str("storage"),
Self::Secrets => f.write_str("secrets"),
Self::Events => f.write_str("events"),
@@ -336,6 +342,7 @@ impl FromStr for Capability {
"database.sources" => Self::DatabaseSources,
"vcs.read" => Self::VcsRead,
"vcs.write" => Self::VcsWrite,
"build.read" => Self::BuildRead,
"storage" => Self::Storage,
"secrets" => Self::Secrets,
"events" => Self::Events,
@@ -390,6 +397,7 @@ mod tests {
"editor.write",
"project.write",
"vcs.write",
"build.read",
"storage",
"secrets",
"events",
@@ -433,6 +441,7 @@ mod tests {
assert_eq!(Capability::Clipboard.risk(), Risk::Medium);
assert_eq!(Capability::Process("cargo".into()).risk(), Risk::High);
assert_eq!(Capability::Lsp("phoxite".into()).risk(), Risk::High);
assert_eq!(Capability::BuildRead.risk(), Risk::Low);
assert!(!Capability::Lsp("phoxite".into()).covers(&Capability::Lsp("intelephense".into())));
assert!(Capability::Storage.auto_migrates() && !Capability::EditorWrite.auto_migrates());
assert_eq!(Capability::JavaAgent.risk(), Risk::High);
+11
View File
@@ -360,6 +360,9 @@ impl Manifest {
if matches!(cap, Capability::Lsp(_)) {
self.needs_api(&format!("capability `{cap}`"), 9)?;
}
if matches!(cap, Capability::BuildRead) {
self.needs_api(&format!("capability `{cap}`"), 10)?;
}
if matches!(cap, Capability::JavaAgent) {
return Err(
"`java.agent` comes from `[[contributes.javaAgents]]`: remove it from [capabilities]".into()
@@ -735,6 +738,14 @@ required = [\"lsp:phoxite\"]
assert_eq!(m.capabilities.required, [Capability::Lsp("phoxite".into())]);
}
#[test]
fn the_build_capability_needs_api_1_10() {
let caps = "[capabilities]\noptional = [\"build.read\"]\n";
assert!(err(&format!("{}{caps}", BASE.replace("^1.2", "^1.9"))).contains("new in plugin API 1.10"));
let m = Manifest::parse(&format!("{}{caps}", BASE.replace("^1.2", "^1.10"))).unwrap();
assert_eq!(m.capabilities.optional, [Capability::BuildRead]);
}
#[test]
fn java_agent_capability_is_not_declared() {
for list in ["required", "optional"] {
+43 -1
View File
@@ -467,7 +467,15 @@ pub async fn gradle_dependencies(
gradle_command: Some(gradle.command.clone()),
..Default::default()
};
ide_build::gradle_dependencies(&scope.root, gradle, &options, &gradle_path, &configuration, &token)
let dependencies =
ide_build::gradle_dependencies(&scope.root, gradle, &options, &gradle_path, &configuration, &token)?;
// What plugins read of the build (`build.dependencies`) instead of running Gradle.
let report = ide_build::GradleReport { project: gradle_path, configuration, dependencies };
let cache = ide_build::gradle::cache_dir(&scope.cache, &gradle.dir);
if let Err(e) = ide_build::save_gradle_report(&scope.root, &cache, gradle, &report) {
tracing::debug!("keeping the dependencies report of {}: {e}", report.project);
}
Ok(report.dependencies)
})
.await
.map_err(join_err);
@@ -475,6 +483,40 @@ pub async fn gradle_dependencies(
result?
}
/// What the Dependency Analyzer has of the builds of `project` at `root` (the project, or one
/// of its workspace members), without running a build tool: the Maven modules as last synced
/// and the Gradle reports read since the build files last changed.
pub(crate) fn analyzed_dependencies(
project: &Project,
config: &Path,
root: &Path,
) -> IdeResult<crate::plugins::BuildGraph> {
let mut graph = crate::plugins::BuildGraph::default();
for scope in workspace::scopes(project, config)?.iter().filter(|s| root == project.root || s.root == root) {
let settings = &scope.settings;
let model = ide_build::load_linked(
&scope.root,
&scope.cache,
ide_sdk::apply::maven_local_repository(&scope.root, settings),
&settings.languages.java.maven,
&settings.languages.java.gradle,
);
graph.maven.extend(model.maven.into_iter().flat_map(|m| m.projects));
for build in &model.gradle {
let reports =
ide_build::gradle_reports(&scope.root, &ide_build::gradle::cache_dir(&scope.cache, &build.dir), build);
// buildSrc can't be analyzed from the build, as in the Dependency Analyzer.
for p in build.projects.iter().filter(|p| !p.build.as_deref().is_some_and(|b| b.ends_with(":buildSrc"))) {
graph.gradle.push(crate::plugins::GradleModule {
path: p.path.clone(),
reports: reports.iter().filter(|r| r.project == p.path).cloned().collect(),
});
}
}
}
Ok(graph)
}
/// Where the direct dependency `dependency` of the Maven module `pom` is declared.
pub async fn maven_dependency_declaration(
host: &Host,
+26
View File
@@ -112,6 +112,11 @@ pub trait PluginWorkspace: Send + Sync {
) -> Result<serde_json::Value, HostError> {
Err(HostError::NotFound(format!("no language server `{server}` is running for this project")))
}
/// What the IDE has resolved of the Maven / Gradle builds of the project at `root`;
/// never runs a build tool.
fn build_graph(&self, _root: &Path) -> Result<super::BuildGraph, HostError> {
Ok(super::BuildGraph::default())
}
/// Current index of the project rooted at `root`; never reads disk or calls LSP.
fn symbols(
&self,
@@ -2224,6 +2229,20 @@ impl HostApi for PluginApi {
Ok(result.to_string())
}
fn build_dependencies(
&self,
root: &Path,
module: Option<&str>,
) -> Result<Vec<ide_plugin::DependencyNode>, HostError> {
self.require_api("`build`", 10)?;
let workspace = self.shared.workspace().ok_or_else(|| HostError::NotFound("no project is open".into()))?;
// The graph comes from running the project's build, as `vcs.read` does git.
if !workspace.trusted(root) {
return Err(HostError::Denied("project is not trusted".into()));
}
super::build_graph::dependency_nodes(&workspace.build_graph(root)?, module)
}
fn find_files(&self, root: &Path, glob: &str, limit: usize) -> Result<Vec<String>, HostError> {
let matcher = globset::GlobBuilder::new(glob)
.literal_separator(true)
@@ -3374,6 +3393,13 @@ impl PluginWorkspace for HostWorkspace {
})
}
fn build_graph(&self, root: &Path) -> Result<super::BuildGraph, HostError> {
let host = self.0.upgrade().ok_or(HostError::Cancelled)?;
let project = HostWorkspace::project_covering(self, root)
.ok_or_else(|| HostError::NotFound("the project is no longer open".into()))?;
crate::ops::build::analyzed_dependencies(&project, &host.config_dir, root).map_err(failed)
}
fn trusted(&self, root: &Path) -> bool {
// A workspace member is as trusted as the group's project it was opened with.
HostWorkspace::project_covering(self, root).is_some_and(|p| p.is_trusted())
+337
View File
@@ -0,0 +1,337 @@
//! `build.dependencies`: the Dependency Analyzer's Maven / Gradle trees as the flat
//! list the plugin API passes (records can't nest), each module a root.
use ide_build::{GradleDependency, GradleReport, MavenDependency, MavenProject, Omission};
use ide_plugin::{DependencyNode, DependencyStatus, HostError};
/// Most nodes one call returns.
const MAX_NODES: usize = 100_000;
/// What the IDE has resolved of a project's builds, without running a build tool.
#[derive(Clone, Debug, Default)]
pub struct BuildGraph {
/// Maven modules with their dependencies (with the transitive ones after a sync).
pub maven: Vec<MavenProject>,
pub gradle: Vec<GradleModule>,
}
/// A Gradle project and the reports the Dependency Analyzer read for it.
#[derive(Clone, Debug, Default)]
pub struct GradleModule {
/// Gradle path (`:`, `:app`).
pub path: String,
/// One per configuration read.
pub reports: Vec<GradleReport>,
}
/// The graph of `module` (a Maven `groupId:artifactId` or a Gradle path), or of every module.
pub fn dependency_nodes(graph: &BuildGraph, module: Option<&str>) -> Result<Vec<DependencyNode>, HostError> {
let mut out = Nodes(Vec::new());
let mut found = false;
for p in graph.maven.iter().filter(|p| module.is_none_or(|m| m == p.key())) {
found = true;
let root = out.push(DependencyNode {
group: p.group_id.clone(),
artifact: p.artifact_id.clone(),
version: p.version.clone(),
scope: String::new(),
status: DependencyStatus::Resolved,
requested_version: None,
parent: None,
})?;
out.maven(&p.dependencies, root)?;
}
for g in graph.gradle.iter().filter(|g| module.is_none_or(|m| m == g.path)) {
found = true;
let root = out.push(DependencyNode {
group: String::new(),
artifact: g.path.clone(),
version: String::new(),
scope: String::new(),
status: DependencyStatus::Resolved,
requested_version: None,
parent: None,
})?;
for report in &g.reports {
out.gradle(&report.dependencies, &report.configuration, root)?;
}
}
match module {
Some(m) if !found => Err(HostError::NotFound(format!("no Maven or Gradle module `{m}` in this project"))),
_ => Ok(out.0),
}
}
struct Nodes(Vec<DependencyNode>);
impl Nodes {
fn push(&mut self, node: DependencyNode) -> Result<u32, HostError> {
if self.0.len() >= MAX_NODES {
return Err(HostError::Failed(format!(
"the dependency graph has more than {MAX_NODES} nodes; ask for one module"
)));
}
self.0.push(node);
Ok((self.0.len() - 1) as u32)
}
fn maven(&mut self, deps: &[MavenDependency], parent: u32) -> Result<(), HostError> {
for d in deps {
let version = d.version.clone().unwrap_or_default();
let (status, version, requested) = match d.omitted {
// `version` lost to `conflict_with`.
Some(Omission::Conflict) => (
DependencyStatus::OmittedForConflict,
d.conflict_with.clone().unwrap_or_else(|| version.clone()),
Some(version),
),
Some(Omission::Duplicate | Omission::Cycle) => {
(DependencyStatus::OmittedForDuplicate, version, d.managed_from.clone())
}
None if d.managed_from.is_some() => (DependencyStatus::VersionManaged, version, d.managed_from.clone()),
None => (DependencyStatus::Resolved, version, None),
};
let index = self.push(DependencyNode {
group: d.group_id.clone(),
artifact: d.artifact_id.clone(),
requested_version: requested.filter(|r| *r != version),
version,
scope: d.scope.clone(),
status,
parent: Some(parent),
})?;
self.maven(&d.children, index)?;
}
Ok(())
}
fn gradle(&mut self, deps: &[GradleDependency], configuration: &str, parent: u32) -> Result<(), HostError> {
// A constraint is not a dependency: it occurs as one elsewhere in the tree.
for d in deps.iter().filter(|d| !d.constraint) {
let (status, version, requested) = if d.project || d.unresolved {
(DependencyStatus::Resolved, String::new(), None)
} else {
match (&d.requested, &d.selected) {
(_, None) => (DependencyStatus::Resolved, d.requested.clone().unwrap_or_default(), None),
// A platform or a constraint supplies the version.
(None, Some(selected)) => (DependencyStatus::VersionManaged, selected.clone(), None),
// Conflict resolution picked another version than this exact request.
(Some(requested), Some(selected)) if exact_version(requested) => {
(DependencyStatus::OmittedForConflict, selected.clone(), Some(requested.clone()))
}
// A range or a rich version (`1.+`, `{strictly 2.0}`) resolved as asked.
(Some(requested), Some(selected)) => {
(DependencyStatus::Resolved, selected.clone(), Some(requested.clone()))
}
}
};
let status = if d.repeated && status == DependencyStatus::Resolved {
DependencyStatus::OmittedForDuplicate
} else {
status
};
let index = self.push(DependencyNode {
group: d.group.clone(),
artifact: d.name.clone(),
requested_version: requested.filter(|r| *r != version),
version,
scope: configuration.to_owned(),
status,
parent: Some(parent),
})?;
self.gradle(&d.children, configuration, index)?;
}
Ok(())
}
}
/// `1.2.3`, not a range, dynamic or rich version (`[1,2)`, `1.+`, `latest.release`, `{strictly 1}`).
fn exact_version(v: &str) -> bool {
!v.is_empty() && !v.starts_with("latest.") && !v.contains(['[', ']', '(', ')', ',', '+', '{', '}', ' '])
}
#[cfg(test)]
mod tests {
use super::*;
fn maven(group: &str, artifact: &str, version: &str, scope: &str) -> MavenDependency {
MavenDependency {
group_id: group.into(),
artifact_id: artifact.into(),
version: Some(version.into()),
kind: "jar".into(),
scope: scope.into(),
..Default::default()
}
}
fn gradle(group: &str, name: &str, requested: Option<&str>, selected: Option<&str>) -> GradleDependency {
GradleDependency {
group: group.into(),
name: name.into(),
requested: requested.map(Into::into),
selected: selected.map(Into::into),
..Default::default()
}
}
/// (group, artifact, version, scope, status, requested, parent) of every node.
type Row<'a> = (&'a str, &'a str, &'a str, &'a str, DependencyStatus, Option<&'a str>, Option<u32>);
fn rows(nodes: &[DependencyNode]) -> Vec<Row<'_>> {
nodes
.iter()
.map(|n| {
(
n.group.as_str(),
n.artifact.as_str(),
n.version.as_str(),
n.scope.as_str(),
n.status,
n.requested_version.as_deref(),
n.parent,
)
})
.collect()
}
fn graph() -> BuildGraph {
let mut lang3_lost = maven("org.apache.commons", "commons-lang3", "3.12.0", "compile");
lang3_lost.omitted = Some(Omission::Conflict);
lang3_lost.conflict_with = Some("3.14.0".into());
let mut text = maven("org.apache.commons", "commons-text", "1.11.0", "compile");
text.children = vec![lang3_lost];
let mut logging = maven("commons-logging", "commons-logging", "1.3.0", "compile");
logging.managed_from = Some("1.2".into());
let mut junit_again = maven("junit", "junit", "4.13.2", "test");
junit_again.omitted = Some(Omission::Duplicate);
let mut hamcrest = maven("org.hamcrest", "hamcrest", "2.2", "test");
hamcrest.children = vec![junit_again];
let app = MavenProject {
group_id: "com.example".into(),
artifact_id: "app".into(),
version: "1.0".into(),
dependencies: vec![
maven("org.apache.commons", "commons-lang3", "3.14.0", "compile"),
text,
logging,
hamcrest,
],
..Default::default()
};
let mut databind = gradle("com.fasterxml.jackson.core", "jackson-databind", Some("2.15.0"), Some("2.15.3"));
databind.repeated = true;
let mut web = gradle("org.springframework.boot", "spring-boot-starter-web", None, Some("3.2.0"));
web.children = vec![databind];
let mut constraint = gradle("com.google.guava", "guava", Some("32.1.3-jre"), None);
constraint.constraint = true;
let mut core = gradle("", ":core", None, None);
core.project = true;
core.children = vec![constraint];
let mut failed = gradle("org.missing", "gone", Some("9"), None);
failed.unresolved = true;
let report = GradleReport {
project: ":web".into(),
configuration: "runtimeClasspath".into(),
dependencies: vec![
web,
core,
gradle("org.slf4j", "slf4j-api", Some("2.+"), Some("2.0.13")),
gradle("org.yaml", "snakeyaml", Some("2.2"), None),
failed,
],
};
BuildGraph {
maven: vec![app],
gradle: vec![
GradleModule { path: ":web".into(), reports: vec![report] },
GradleModule { path: ":".into(), reports: Vec::new() },
],
}
}
#[test]
fn modules_are_roots_with_their_trees_flattened_under_them() {
use DependencyStatus::*;
let nodes = dependency_nodes(&graph(), None).unwrap();
assert_eq!(
rows(&nodes),
[
("com.example", "app", "1.0", "", Resolved, None, None),
("org.apache.commons", "commons-lang3", "3.14.0", "compile", Resolved, None, Some(0)),
("org.apache.commons", "commons-text", "1.11.0", "compile", Resolved, None, Some(0)),
(
"org.apache.commons",
"commons-lang3",
"3.14.0",
"compile",
OmittedForConflict,
Some("3.12.0"),
Some(2)
),
("commons-logging", "commons-logging", "1.3.0", "compile", VersionManaged, Some("1.2"), Some(0)),
("org.hamcrest", "hamcrest", "2.2", "test", Resolved, None, Some(0)),
("junit", "junit", "4.13.2", "test", OmittedForDuplicate, None, Some(5)),
("", ":web", "", "", Resolved, None, None),
(
"org.springframework.boot",
"spring-boot-starter-web",
"3.2.0",
"runtimeClasspath",
VersionManaged,
None,
Some(7)
),
(
"com.fasterxml.jackson.core",
"jackson-databind",
"2.15.3",
"runtimeClasspath",
OmittedForConflict,
Some("2.15.0"),
Some(8)
),
("", ":core", "", "runtimeClasspath", Resolved, None, Some(7)),
("org.slf4j", "slf4j-api", "2.0.13", "runtimeClasspath", Resolved, Some("2.+"), Some(7)),
("org.yaml", "snakeyaml", "2.2", "runtimeClasspath", Resolved, None, Some(7)),
("org.missing", "gone", "", "runtimeClasspath", Resolved, None, Some(7)),
("", ":", "", "", Resolved, None, None),
]
);
}
#[test]
fn one_module_by_its_maven_key_or_gradle_path() {
let maven = dependency_nodes(&graph(), Some("com.example:app")).unwrap();
assert_eq!((maven.len(), maven[0].artifact.as_str()), (7, "app"));
let gradle = dependency_nodes(&graph(), Some(":web")).unwrap();
assert_eq!((gradle.len(), gradle[0].artifact.as_str(), gradle[1].parent), (7, ":web", Some(0)));
// A Gradle project with no report read yet is known, with nothing under it.
assert_eq!(dependency_nodes(&graph(), Some(":")).unwrap().len(), 1);
let err = dependency_nodes(&graph(), Some("app")).unwrap_err();
assert!(matches!(err, HostError::NotFound(_)), "{err:?}");
assert!(dependency_nodes(&BuildGraph::default(), None).unwrap().is_empty());
}
#[test]
fn a_graph_too_large_for_one_call_fails() {
let app = MavenProject {
group_id: "g".into(),
artifact_id: "a".into(),
dependencies: vec![maven("g", "d", "1", "compile"); MAX_NODES],
..Default::default()
};
let graph = BuildGraph { maven: vec![app], gradle: Vec::new() };
assert!(matches!(dependency_nodes(&graph, None), Err(HostError::Failed(_))));
}
#[test]
fn exact_versions() {
for v in ["1.0", "32.1.3-jre", "2.15.0"] {
assert!(exact_version(v), "{v}");
}
for v in ["", "1.+", "[1.0,2.0)", "latest.release", "{strictly 1.0}"] {
assert!(!exact_version(v), "{v}");
}
}
}
+2
View File
@@ -17,6 +17,7 @@
mod api;
mod auth;
mod build_graph;
pub mod commands;
pub mod commit;
mod database;
@@ -59,6 +60,7 @@ pub mod web;
mod websocket;
pub use api::{FileSecretStore, HostWorkspace, PluginWorkspace, SecretStore};
pub use build_graph::{BuildGraph, GradleModule};
pub(crate) use hover::merge as merge_hover;
pub use icons::{
MAX_PLUGIN_ICON, map_asset as icon_theme_map_asset, plugin_icon, sanitize_svg, svg_prefix as icon_theme_svg_prefix,
+88
View File
@@ -196,6 +196,41 @@ impl PluginWorkspace for TestWorkspace {
self.server_messages.lock().push((method.into(), params.clone(), notify));
Ok(if notify { serde_json::Value::Null } else { serde_json::json!({ "method": method, "params": params }) })
}
/// A Maven module with a lost version conflict, and a Gradle project with one report.
fn build_graph(&self, _root: &Path) -> Result<BuildGraph, HostError> {
let dep = |artifact: &str, version: &str| ide_build::MavenDependency {
group_id: "org.apache.commons".into(),
artifact_id: artifact.into(),
version: Some(version.into()),
scope: "compile".into(),
..Default::default()
};
let mut text = dep("commons-text", "1.11.0");
text.children = vec![ide_build::MavenDependency {
omitted: Some(ide_build::Omission::Conflict),
conflict_with: Some("3.14.0".into()),
..dep("commons-lang3", "3.12.0")
}];
let app = ide_build::MavenProject {
group_id: "com.example".into(),
artifact_id: "app".into(),
version: "1.0".into(),
dependencies: vec![text],
..Default::default()
};
let snakeyaml = ide_build::GradleDependency {
group: "org.yaml".into(),
name: "snakeyaml".into(),
requested: Some("2.2".into()),
..Default::default()
};
let report = ide_build::GradleReport {
project: ":web".into(),
configuration: "runtimeClasspath".into(),
dependencies: vec![snakeyaml],
};
Ok(BuildGraph { maven: vec![app], gradle: vec![GradleModule { path: ":web".into(), reports: vec![report] }] })
}
fn project_windows(&self, root: &Path) -> Vec<String> {
// `main` shows the fixture project; other open roots have no window left.
if root == self.root { vec!["closing".into(), "main".into()] } else { Vec::new() }
@@ -7076,6 +7111,59 @@ fn the_language_server_grant_needs_api_1_9() {
assert!(err.message.contains("new in plugin API 1.9"), "{err:?}");
}
/// `build.dependencies` hands a plugin the resolved Maven / Gradle graph as a flat list, each
/// module a root, with `build.read` in a trusted project (API 1.10).
#[test]
fn build_dependencies_need_the_grant_and_a_trusted_project() {
let f = fixture(Limits::default());
let id = "test.build-graph";
let info = f.install(&sample("build-graph"));
assert!(info.capabilities.iter().any(|c| c.id == "build.read" && c.granted && c.risk == ide_extension::Risk::Low));
// `parent group:artifact:version scope status requested`, as the fixture prints them.
assert_eq!(
f.run(id, "dependencies", None).unwrap().unwrap(),
"- com.example:app:1.0 resolved -\n\
0 org.apache.commons:commons-text:1.11.0 compile resolved -\n\
1 org.apache.commons:commons-lang3:3.14.0 compile conflict 3.12.0\n\
- ::web: resolved -\n\
3 org.yaml:snakeyaml:2.2 runtimeClasspath resolved -"
);
assert_eq!(
f.run(id, "dependencies", Some(":web")).unwrap().unwrap(),
"- ::web: resolved -\n0 org.yaml:snakeyaml:2.2 runtimeClasspath resolved -"
);
let err = f.host.run_command(id, "dependencies", Some("app"), f.inv()).unwrap_err();
assert_eq!(err.kind, ErrorKind::NotFound, "{err:?}");
f.host.set_capability(id, "build.read", false).unwrap();
let err = f.host.run_command(id, "dependencies", None, f.inv()).unwrap_err();
assert_eq!(err.kind, ErrorKind::PermissionDenied, "{err:?}");
assert!(err.message.contains("build.read"), "{err:?}");
f.host.set_capability(id, "build.read", true).unwrap();
// The graph comes from running the project's build: not in an untrusted project.
let mut untrusted = TestWorkspace::new(&f.project);
Arc::get_mut(&mut untrusted).unwrap().trusted = false;
f.host.set_workspace(Some(untrusted));
let err = f.host.run_command(id, "dependencies", None, f.inv()).unwrap_err();
assert_eq!(err.kind, ErrorKind::PermissionDenied, "{err:?}");
assert_eq!(f.host.info_of(id).unwrap().stats.crashes, 0);
}
/// The grant is new in API 1.10: an older `engines.openidea` can't ask for it.
#[test]
fn the_build_grant_needs_api_1_10() {
let f = fixture(Limits::default());
let tmp = tempfile::tempdir().unwrap();
let pkg = tmp.path().join("build-graph");
copy_dir(&sample("build-graph"), &pkg);
let manifest = std::fs::read_to_string(pkg.join("plugin.toml")).unwrap();
std::fs::write(pkg.join("plugin.toml"), manifest.replace("\"^1.10\"", "\"^1.9\"")).unwrap();
let err = f.host.install_from_dir(&pkg, &Consent::all()).unwrap_err();
assert!(err.message.contains("new in plugin API 1.10"), "{err:?}");
}
/// The UI's synthetic post-install `SettingsChanged([])` reaches a plugin that
/// subscribes to `on-event:settings-changed`, though it carries no keys.
#[test]
+7
View File
@@ -117,6 +117,13 @@ pub trait HostApi: Send + Sync {
let _ = (root, method, params, notify, cancel, timeout);
Err(HostError::NotFound(format!("no language server `{server}` is running for this project")))
}
/// The flat dependency graph of the Maven / Gradle builds of the project at `root`
/// (of the module `module` only, when given), as the IDE last resolved it; never runs
/// a build tool.
fn build_dependencies(&self, root: &Path, module: Option<&str>) -> Result<Vec<crate::DependencyNode>, HostError> {
let _ = (root, module);
Err(HostError::Failed("build data is unavailable on this host".into()))
}
/// Stdio argv only; no URL or bearer token.
fn mcp_stdio_command(&self, client: &str) -> Option<Vec<String>> {
let _ = client;
+22
View File
@@ -959,6 +959,28 @@ pub struct BlameLine {
pub summary: String,
}
/// How an occurrence in a build's dependency graph was resolved (API 1.10).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum DependencyStatus {
Resolved,
OmittedForConflict,
OmittedForDuplicate,
VersionManaged,
}
/// One occurrence in the flat dependency graph of `build.dependencies` (API 1.10);
/// `parent` indexes the list.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct DependencyNode {
pub group: String,
pub artifact: String,
pub version: String,
pub scope: String,
pub status: DependencyStatus,
pub requested_version: Option<String>,
pub parent: Option<u32>,
}
/// Non-secret settings of a plugin-owned project database source (API 1.4).
#[derive(Clone, Debug, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
+43 -2
View File
@@ -48,6 +48,7 @@ pub(crate) mod syntax_bindings {
"openidea:plugin/decorations": super::bindings::openidea::plugin::decorations,
"openidea:plugin/invocation": super::bindings::openidea::plugin::invocation,
"openidea:plugin/vcs": super::bindings::openidea::plugin::vcs,
"openidea:plugin/build": super::bindings::openidea::plugin::build,
"openidea:plugin/commit": super::bindings::openidea::plugin::commit,
"openidea:plugin/events": super::bindings::openidea::plugin::events,
"openidea:plugin/tasks": super::bindings::openidea::plugin::tasks,
@@ -87,6 +88,7 @@ pub(crate) mod providers_bindings {
"openidea:plugin/decorations": super::bindings::openidea::plugin::decorations,
"openidea:plugin/invocation": super::bindings::openidea::plugin::invocation,
"openidea:plugin/vcs": super::bindings::openidea::plugin::vcs,
"openidea:plugin/build": super::bindings::openidea::plugin::build,
"openidea:plugin/commit": super::bindings::openidea::plugin::commit,
"openidea:plugin/events": super::bindings::openidea::plugin::events,
"openidea:plugin/tasks": super::bindings::openidea::plugin::tasks,
@@ -126,6 +128,7 @@ pub(crate) mod views_bindings {
"openidea:plugin/decorations": super::bindings::openidea::plugin::decorations,
"openidea:plugin/invocation": super::bindings::openidea::plugin::invocation,
"openidea:plugin/vcs": super::bindings::openidea::plugin::vcs,
"openidea:plugin/build": super::bindings::openidea::plugin::build,
"openidea:plugin/commit": super::bindings::openidea::plugin::commit,
"openidea:plugin/events": super::bindings::openidea::plugin::events,
"openidea:plugin/tasks": super::bindings::openidea::plugin::tasks,
@@ -150,8 +153,8 @@ pub(crate) mod views_bindings {
}
use bindings::openidea::plugin::{
commit, detail_types, diagnostics, editor, events, fs, invocation, ipc, log, net, process, secrets, settings,
storage, tasks, types as wit, ui, vcs, views, workspace,
build, commit, detail_types, diagnostics, editor, events, fs, invocation, ipc, log, net, process, secrets,
settings, storage, tasks, types as wit, ui, vcs, views, workspace,
};
/// A project handle: its root.
@@ -1192,6 +1195,44 @@ impl vcs::Host for StoreData {
}
}
impl build::Host for StoreData {
fn dependencies(
&mut self,
project: Resource<ProjectRes>,
module: Option<String>,
) -> Fallible<Vec<build::DependencyNode>> {
if let Err(e) = self.require(Capability::BuildRead) {
return Ok(Err(e));
}
let root = self.table.get(&project)?.root.clone();
Ok(self
.host
.build_dependencies(&root, module.as_deref())
.map(|nodes| {
nodes
.into_iter()
.map(|n| build::DependencyNode {
group: n.group,
artifact: n.artifact,
version: n.version,
scope: n.scope,
status: match n.status {
crate::DependencyStatus::Resolved => build::DependencyStatus::Resolved,
crate::DependencyStatus::OmittedForConflict => build::DependencyStatus::OmittedForConflict,
crate::DependencyStatus::OmittedForDuplicate => {
build::DependencyStatus::OmittedForDuplicate
}
crate::DependencyStatus::VersionManaged => build::DependencyStatus::VersionManaged,
},
requested_version: n.requested_version,
parent: n.parent,
})
.collect()
})
.map_err(to_wit))
}
}
impl commit::Host for StoreData {
fn pending_commit(&mut self) -> Fallible<Option<commit::CommitDraft>> {
if let Err(e) = self.require(Capability::VcsRead) {
Binary file not shown.
@@ -1 +1 @@
47eb797508a8b7c4f2b8de276656a936cb7b603edf6d5cb0997fd55f06c18d74
f6069ad2d31b629e4c99fbb800b3bf389ffb87ca7f24fc9cf7803fef68997ef5
+336
View File
@@ -0,0 +1,336 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "anyhow"
version = "1.0.104"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470"
[[package]]
name = "bitflags"
version = "2.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"
[[package]]
name = "equivalent"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826"
[[package]]
name = "foldhash"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb"
[[package]]
name = "hashbrown"
version = "0.17.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
dependencies = [
"foldhash",
]
[[package]]
name = "heck"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
name = "id-arena"
version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954"
[[package]]
name = "indexmap"
version = "2.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855"
dependencies = [
"equivalent",
"hashbrown",
"serde",
"serde_core",
]
[[package]]
name = "itoa"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
[[package]]
name = "leb128fmt"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2"
[[package]]
name = "log"
version = "0.4.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c"
[[package]]
name = "macro-string"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e7b3a5bbb2f63aaa223a671ea1bd0e7bc16bd30ce387324cf63995deaddbbd2"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "memchr"
version = "2.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
[[package]]
name = "openidea-plugin"
version = "0.1.0"
dependencies = [
"serde",
"serde_json",
"wit-bindgen",
]
[[package]]
name = "openidea-test-build-graph"
version = "0.1.0"
dependencies = [
"openidea-plugin",
]
[[package]]
name = "prettyplease"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bfe0f4c752e450fc2faf62654f1c134747922825d5b04ca717b8874f41a40c0"
dependencies = [
"proc-macro2",
"syn",
]
[[package]]
name = "proc-macro2"
version = "1.0.107"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
dependencies = [
"proc-macro2",
]
[[package]]
name = "semver"
version = "1.0.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd"
[[package]]
name = "serde"
version = "1.0.229"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
dependencies = [
"serde_core",
"serde_derive",
]
[[package]]
name = "serde_core"
version = "1.0.229"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.229"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "serde_json"
version = "1.0.154"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6"
dependencies = [
"itoa",
"memchr",
"serde",
"serde_core",
"zmij",
]
[[package]]
name = "syn"
version = "3.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "unicode-ident"
version = "1.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
[[package]]
name = "wasm-encoder"
version = "0.262.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4495a6f85dd94c411c749303efcbc5defade0b0cbdbc0541495241ab917a9b5a"
dependencies = [
"leb128fmt",
"wasmparser",
]
[[package]]
name = "wasm-metadata"
version = "0.262.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c86ff6668190d9fb70372b306b4f9fe8930f0e2f57ce72e4922bf2f117900949"
dependencies = [
"anyhow",
"indexmap",
"wasm-encoder",
"wasmparser",
]
[[package]]
name = "wasmparser"
version = "0.262.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "974d643b125b272607e2fff8012ea14a8328acd7621e4bafa7afb32500052b1b"
dependencies = [
"bitflags",
"hashbrown",
"indexmap",
"semver",
]
[[package]]
name = "wit-bindgen"
version = "0.63.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b85a987ab61d365382d25c7d47e26edd48941b3bf6e3fbf76eff918bc71dab06"
dependencies = [
"bitflags",
"wit-bindgen-rust-macro",
]
[[package]]
name = "wit-bindgen-core"
version = "0.63.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "775e122e390603abfacd548027016cd0113a6e2bf2f8ce6bdd3658b013456ea8"
dependencies = [
"anyhow",
"heck",
"wit-parser",
]
[[package]]
name = "wit-bindgen-rust"
version = "0.63.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84e26e13b9d972026778d2ffb7985736de116026fdc8d9464f966e12df2eb240"
dependencies = [
"anyhow",
"heck",
"indexmap",
"prettyplease",
"syn",
"wasm-metadata",
"wit-bindgen-core",
"wit-component",
]
[[package]]
name = "wit-bindgen-rust-macro"
version = "0.63.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16a008a0d6b4840677326beb4edbeb210a2f1b7d0183fb7cc33f466b90fd7fb6"
dependencies = [
"anyhow",
"macro-string",
"prettyplease",
"proc-macro2",
"quote",
"syn",
"wit-bindgen-core",
"wit-bindgen-rust",
]
[[package]]
name = "wit-component"
version = "0.262.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "078def49fdb49cab405c3006e05793b3fdaf7069126ba6b9c97d01ec8c98fe4c"
dependencies = [
"anyhow",
"bitflags",
"indexmap",
"log",
"serde",
"serde_derive",
"serde_json",
"wasm-encoder",
"wasm-metadata",
"wasmparser",
"wit-parser",
]
[[package]]
name = "wit-parser"
version = "0.262.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00f0dc051466ffe46787721fca3d088536f158ae400be044f1b1c386ba9397ad"
dependencies = [
"anyhow",
"hashbrown",
"id-arena",
"indexmap",
"log",
"semver",
"serde",
"serde_derive",
"serde_json",
"unicode-ident",
"wasmparser",
]
[[package]]
name = "zmij"
version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
+20
View File
@@ -0,0 +1,20 @@
[package]
name = "openidea-test-build-graph"
version = "0.1.0"
edition = "2024"
publish = false
[workspace]
[lib]
crate-type = ["cdylib", "rlib"]
[dependencies]
openidea-plugin = { path = "../../../../../sdk/rust/openidea-plugin" }
[profile.release]
opt-level = "s"
lto = true
strip = true
codegen-units = 1
panic = "abort"
Binary file not shown.
@@ -0,0 +1 @@
178a2dd60891bfa56a02be322b47dfdbbf22f6e0a50ac56a4b7e4ae1520a821a
@@ -0,0 +1,12 @@
id = "test.build-graph"
name = "Build dependency graph fixture"
version = "0.1.0"
engines.openidea = "^1.10"
wasm = "dist/plugin.wasm"
[capabilities]
optional = ["build.read"]
[[contributes.commands]]
id = "dependencies"
title = "List the dependency graph of a module, or of every module"
+32
View File
@@ -0,0 +1,32 @@
use openidea_plugin::{DependencyStatus, Error, Invocation, Plugin, register_plugin};
#[derive(Default)]
struct BuildGraph;
impl Plugin for BuildGraph {
fn run_command(&mut self, id: &str, inv: &Invocation, arg: Option<&str>) -> Result<Option<String>, Error> {
if id != "dependencies" {
return Err(Error::NotFound(id.into()));
}
let project = inv.project().ok_or("no project")?;
// One line per node: `parent group:artifact:version scope status requested`.
let lines: Vec<String> = project
.build_dependencies(arg.filter(|m| !m.is_empty()))?
.into_iter()
.map(|n| {
let status = match n.status {
DependencyStatus::Resolved => "resolved",
DependencyStatus::OmittedForConflict => "conflict",
DependencyStatus::OmittedForDuplicate => "duplicate",
DependencyStatus::VersionManaged => "managed",
};
let parent = n.parent.map_or("-".into(), |p| p.to_string());
let requested = n.requested_version.unwrap_or_else(|| "-".into());
format!("{parent} {}:{}:{} {} {status} {requested}", n.group, n.artifact, n.version, n.scope)
})
.collect();
Ok(Some(lines.join("\n")))
}
}
register_plugin!(BuildGraph);
Binary file not shown.
@@ -1 +1 @@
baabfa459d287fe78389fc5d71951248942902b9cf029ab3782cc929c1ca7bf3
c39252e48882cb605286f95d1115a3293c191538d7762d1d3ce3afb1bfad814b
Binary file not shown.
@@ -1 +1 @@
e86a42a3716d37a7e5034d922a097487f3659691dc8879ad16e4efa63e4e030f
0809519ebb56f31b1f00d1e256a6d1af4e1c357990226ef949ac61f1e61989d6
Binary file not shown.
@@ -1 +1 @@
d5f2d8b20bfbd0f2dbd566dae490645f6f266f0dd87498e5476ead56ca1fe09e
9a9ace3a2818a4cee15f6a20cb0bab96d908090cdcf98a708b4e3558006e224a
Binary file not shown.
@@ -1 +1 @@
65748dfb8348c17e464c2378e6b66ae0e30883aee0e1b27130078e3b970c3bf7
910123140c7d4b354c820088df9adde69916051ebc6cc732bc7847f6d7eb5f52
Binary file not shown.
@@ -1 +1 @@
2f25d04ba6260c54e1010b310b696428672975c3c0986aab952f534be2783847
067039e5e40e0c0586277641797557c3f454b44909cd2b008ea46b3b81963686
Binary file not shown.
@@ -1 +1 @@
f2bcf27e33c50fcffd3dcb3a9f7029f4774105b143d881e78b5b1c80b10f04f3
93bda7983e8597f6b90b9a2877de8e4217451a2cdf47436c525490554f2168d2
Binary file not shown.
@@ -1 +1 @@
88d11e9fc45c98000f296e46e8105cc83e7fbe6c248a993d82f333caab51e152
7e27dfe47fa8bd6bf35f0dadf34b66cb84cfcc88f08031c2587d52387611dece
Binary file not shown.
@@ -1 +1 @@
52768373487be5388e5de2cc577d9c3d74eb0877ecd78a0b641188aed2d18004
a9ac8f8c212694d1c5cf8fe50772014d5a5dec6a814ef1db9de2178c61263f7f
Binary file not shown.
@@ -1 +1 @@
63368e7ba560204b6913261bc631579387e42a178cd39d106985ef114a88e54a
20539c87dcf133733139bce6f82971051a6d0c82feac7e9ffe877ac4fc166d94
Binary file not shown.
@@ -1 +1 @@
6466e46285c132256a03dee9814d3a8f899eab1aaedd389a7087601d2f236bcc
0461c86372899d127238640aa300010111d75a29026a5201ce0f48e77bac26d4
Binary file not shown.
@@ -1 +1 @@
e9fa2ec856fd9c3b19a1a0b233ce55b6e844d0a6f0909018062814eff63c7d6b
d140f25d43a59de5a067fb24ce4831ca01b3f3f83f33d6640fa81d0baa48713e
Binary file not shown.
@@ -1 +1 @@
26893acfd5486f2df35efb28a1719bf3306118a10b1ad346ad74e4b3318f8258
37dbfaef6f29c8f6801d180e8083d650ec801a3a550ed1c73fec670dc130143d
Binary file not shown.
@@ -1 +1 @@
b6ebe9a4c121e4a1f6d2b4d932c8e6a89e52ab3bb957dc241fb6087130c9fe56
01b54df0ad274b7f39d0a2d80fdf9ceec4460d6d360b43323d9e74899cccd99d
Binary file not shown.
@@ -1 +1 @@
a6d0fe560d3492db63fb58a1f898d7090860f2c9dd4dc4e8b97079cd7a97c0b1
f9ccdb66148b31773199af87956e9564b471ffd987b651f74cbf8430631dc77b
Binary file not shown.
@@ -1 +1 @@
3eee2fe2eab305a66a5650dcc9892fed7cc028538d31ab31ed448edbdfa0cdf9
e14b08260fc0a97300a3b2d2e267e44f0dd85abea3169c9ae1980d0a4f0a63b4
@@ -1 +1 @@
3d76b858a8fbf868c36d19897cf85c72e516340eb3e47f27c59b8323dc53b8a3
fed687bad8c67d8868f94e0cd207541031599e7316150bf0b13d78740e5d0216
Binary file not shown.
@@ -1 +1 @@
8d80e89b4b5025c874e467abbea578da52f61a48eeea4573645d362c530fef70
9a1d344d693d7a3ff1f81778f6f7dc2de211c3213b442aeb65a75b582d5f0019
Binary file not shown.
@@ -1 +1 @@
f052bab94de44b140f957d360f16e6c8dd2bc5d80dd7732b62536b6e74f4e868
082645a9941796e029e4bc6e400a0b1bdcb8a87b5c2faa0df396359186935093
Binary file not shown.
@@ -1 +1 @@
f9c4279e7972e89fdc0bc1849ed84b72b983b2230526b492110c4de87a843ed0
f9c0cb4fca66ede5adcb1951dd05c3938c218224cb61e63a574ba08a93f4a041
Binary file not shown.
@@ -1 +1 @@
ae0aa9ed34eb508f388fc43b92544ebdd91c3dfcace3c281d0c32b4947ab09ce
43ab17ff2a31fcfe01bd64a068a007a2102ddc2e99010d74c8f640ee65bd064c
Binary file not shown.
@@ -1 +1 @@
d75dcfcdb4c2f49e391e21bba9f58567937c8fbc739a853bfed8fce58cd6c753
751cd3c2403777c8547c9f5081366463e0e8d10428e0319d33ab65c1091c793f
Binary file not shown.
@@ -1 +1 @@
a25338eaf06fcd417cbd851e8447666ba25214e424c4ba7ee06919d563ff2e88
7e4a38d17faaccdfd34869f9fa6436a909e08bcf0eb381a45278c72604f33b6b
Binary file not shown.
@@ -1 +1 @@
aa9072503d07f0963b115a7ac3b5cdee008d9369263375c9621ba19259647db6
9bfc5a75f0604912a338b2130bd3923f4c11c016caa7c5904fefc29ce7520688
Binary file not shown.
@@ -1 +1 @@
ea3b652f16052305b8cfd45216651da96af6603a1c9018bdcb61897e287a6be6
2ac1d012c8130eeb8a816ab0071f4c3c7d13f264f16dd3bd805f9ec1c22def76
Binary file not shown.
@@ -1 +1 @@
b62841f3469339fcdd3d718963ca3a4a0971a98d770c625334ebb558613f0eb4
c40bfcba9df10c261e09ec9d3dfe23644da76faa0c1db49327cfbfd8febf0d72
Binary file not shown.
@@ -1 +1 @@
535501e8df328c2d340b967de4cf0e9099d2d7ac1186a67b6cc45a88c033b2eb
6bc5c35c8638750a5332a02bbe0d1e8e13b27fc5ebeb6c336113261ead7b6bbe
Binary file not shown.
@@ -1 +1 @@
29f72aaff35386bb1d340638234f7c63535b5fb2b447d19da53ed703cfa4ab8e
e1405f2e787193f28ce6da05aa6f57fe7ce42ad82e9c68ca11390ff07b252ae6
Binary file not shown.
@@ -1 +1 @@
e28ef416c0034a8006692fab43df24eb14fd43ac6f783e4a36ba223eac1dbff5
74b7933d8b192a44726b457bdefdd7eb9f3e5fe7cb22f6991f90112fae41c154
+1
View File
@@ -33,6 +33,7 @@ The plugin calls these. Most are gated by a [capability](/en/plugins/capabilitie
| `editor` | [workspace.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/workspace.wit) | Text editors: document, selections, versioned edits, reveal; open editors and opening files |
| `invocation` | [workspace.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/workspace.wit) | Where a command or event came from: its project, editor and selected paths |
| `vcs` | [workspace.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/workspace.wit) | Git for a project's repository: status, remotes, fetch, log, blame, diff |
| `build` | [workspace.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/workspace.wit) | The Maven / Gradle dependency graph the IDE resolved, flat, with conflict and omission status (API 1.10, `build.read`) |
| `fs` | [fs.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/fs.wit) | Files outside the open projects (`fs.read:` / `fs.write:`) and the plugin's private directory |
| `decorations` | [decorations.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/decorations.wit) | Editor annotations and project-tree badges (API 1.4) |
| `commit` | [commit.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/commit.wit) | The commit being prepared and its message |
+1
View File
@@ -39,6 +39,7 @@ Later:
| `editor.write` | Medium | `TextEditor::apply_edits` | 1.0 |
| `vcs.read` | Low | `vcs_status`, `vcs_remotes`, `vcs_log`, `vcs_blame`, `vcs_diff`, the pending commit, before-commit checks | 1.0 |
| `vcs.write` | Medium | `vcs_fetch` (trusted projects only), `host::set_commit_message` | 1.0 |
| `build.read` | Low | `build_dependencies`: the Maven / Gradle dependency graph the IDE resolved; trusted projects only | 1.10 |
| `storage` | Low | `host::storage`, 64 MiB per plugin | 1.0 |
| `events` | Low | File opened, closed and saved, files changed, editor focused, repository changed, settings changed | 1.0 |
| `events.input` | Medium | `action-performed` and `input-mode-changed` events (keystrokes and editor input) | 1.0 |
+14 -12
View File
@@ -3,7 +3,7 @@ title: "API versions and compatibility"
description: "engines.openidea, the plugin API versions from 1.0 to 1.6, and the rules that keep released plugins loading in newer IDEs."
---
The plugin API has one version number: the version of the WIT package in [`wit/`](https://github.com/l0ng-ai/openidea/tree/main/wit) (`openidea:plugin@1.8.0` on `main`). The host's engine version and the SDK's `API_VERSION` always agree with it, and the SDK carries an identical copy of the WIT files.
The plugin API has one version number: the version of the WIT package in [`wit/`](https://github.com/l0ng-ai/openidea/tree/main/wit) (`openidea:plugin@1.10.0` on `main`). The host's engine version and the SDK's `API_VERSION` always agree with it, and the SDK carries an identical copy of the WIT files.
<Note>
The plugin system is a preview. The compatibility rules below hold for released 1.x versions; what is still unreleased
@@ -12,17 +12,19 @@ The plugin API has one version number: the version of the WIT package in [`wit/`
## Versions
| API | Shipped with | Highlights |
| ----- | ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 1.0.0 | OpenIDEA 0.1.36 | The base API: commands, events, storage, tasks, project and editor access, VCS, diagnostics, network and secrets, processes, declarative views and custom editors, settings, editor providers, syntax provider |
| 1.1.0 | OpenIDEA 0.1.37 | `vcs.remotes`, `ui.copy-to-clipboard`, `ui.open-url`, opening a project file at a line from a view |
| 1.2.0 | OpenIDEA 0.1.38 | Background document indexers, pickers, input boxes and confirmations, plugin context keys for `when` clauses, the files selected in the Project view, a manifest `icon`, the `viewItem.context` menu |
| 1.3.0 | OpenIDEA 0.1.39 | Commit message and before-commit checks, Services detail panes, diagnostics while typing, hover, inlay hints, semantic tokens, file-changing code actions, HTTP endpoints, files outside the project (`fs.read`/`fs.write`, `project.write`, private plugin directory), batched `files-changed` events and path filters, workspace symbols, long-running processes, notifications with buttons, translations, multi-page settings, file template variables, web view PTYs, log tabs and content tabs |
| 1.4.0 | OpenIDEA 0.1.40 | `net.http:`, `ipc:`, `ide.commands` and `database.sources` capabilities; editor and project snapshots, decorations, text search, Problems, Git log/blame/diff; output channels; OAuth loopback; runs, terminal sessions, run configurations, test result parsing and run targets; formatting and other language features; embedded languages; snippets; more menu locations; database sources; MCP tools |
| 1.5.0 | OpenIDEA 0.1.41 | `Project::notify` (a notification in one project's window), the `net:ask` capability, run target validation, per-command run target working-directory arguments |
| 1.6.0 | OpenIDEA 0.1.43 | Bounded, project-bound background WebSockets for event-stream plugins |
| 1.7.0 | OpenIDEA 0.1.44 | `views.open-diff`: two texts in the diff viewer, such as a review's file before and after |
| 1.8.0 | In development on `main` | The `problems-changed` workbench event: the host keeps every producer's diagnostics per file, so an annotation follows the file rather than the invoking window |
| API | Shipped with | Highlights |
| ------ | ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 1.0.0 | OpenIDEA 0.1.36 | The base API: commands, events, storage, tasks, project and editor access, VCS, diagnostics, network and secrets, processes, declarative views and custom editors, settings, editor providers, syntax provider |
| 1.1.0 | OpenIDEA 0.1.37 | `vcs.remotes`, `ui.copy-to-clipboard`, `ui.open-url`, opening a project file at a line from a view |
| 1.2.0 | OpenIDEA 0.1.38 | Background document indexers, pickers, input boxes and confirmations, plugin context keys for `when` clauses, the files selected in the Project view, a manifest `icon`, the `viewItem.context` menu |
| 1.3.0 | OpenIDEA 0.1.39 | Commit message and before-commit checks, Services detail panes, diagnostics while typing, hover, inlay hints, semantic tokens, file-changing code actions, HTTP endpoints, files outside the project (`fs.read`/`fs.write`, `project.write`, private plugin directory), batched `files-changed` events and path filters, workspace symbols, long-running processes, notifications with buttons, translations, multi-page settings, file template variables, web view PTYs, log tabs and content tabs |
| 1.4.0 | OpenIDEA 0.1.40 | `net.http:`, `ipc:`, `ide.commands` and `database.sources` capabilities; editor and project snapshots, decorations, text search, Problems, Git log/blame/diff; output channels; OAuth loopback; runs, terminal sessions, run configurations, test result parsing and run targets; formatting and other language features; embedded languages; snippets; more menu locations; database sources; MCP tools |
| 1.5.0 | OpenIDEA 0.1.41 | `Project::notify` (a notification in one project's window), the `net:ask` capability, run target validation, per-command run target working-directory arguments |
| 1.6.0 | OpenIDEA 0.1.43 | Bounded, project-bound background WebSockets for event-stream plugins |
| 1.7.0 | OpenIDEA 0.1.44 | `views.open-diff`: two texts in the diff viewer, such as a review's file before and after |
| 1.8.0 | OpenIDEA 0.1.45 | The `problems-changed` workbench event: the host keeps every producer's diagnostics per file, so an annotation follows the file rather than the invoking window |
| 1.9.0 | OpenIDEA 0.1.46 | Run configurations with an environment and a debugger, requests to a running language server (`lsp:<server>`), server commands routed to plugins, editor panels |
| 1.10.0 | In development on `main` | `build.dependencies`: the Maven / Gradle dependency graph the IDE resolved (`build.read`) |
The full list of what each version added is in [`plugins/README.md`](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md).
+1
View File
@@ -33,6 +33,7 @@ description: "openidea:plugin WIT 包中的每个 interface:一句话说明及
| `editor` | [workspace.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/workspace.wit) | 文本编辑器:文档、选区、带版本号的编辑、滚动定位;已打开的编辑器和打开文件 |
| `invocation` | [workspace.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/workspace.wit) | 命令或事件的来源:所在项目、编辑器和选中的路径 |
| `vcs` | [workspace.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/workspace.wit) | 项目所在仓库的 Git:状态、远程、fetch、log、blame、diff |
| `build` | [workspace.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/workspace.wit) | IDE 已解析的 Maven / Gradle 依赖图,扁平列表,带冲突与省略状态(API 1.10,`build.read`) |
| `fs` | [fs.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/fs.wit) | 打开的项目以外的文件(`fs.read:` / `fs.write:`),以及插件私有目录 |
| `decorations` | [decorations.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/decorations.wit) | 编辑器标注和项目树徽标(API 1.4) |
| `commit` | [commit.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/commit.wit) | 正在准备的提交及其提交信息 |
+1
View File
@@ -39,6 +39,7 @@ optional = ["net:api.example.com", "secrets"]
| `editor.write` | 中 | `TextEditor::apply_edits` | 1.0 |
| `vcs.read` | 低 | `vcs_status`、`vcs_remotes`、`vcs_log`、`vcs_blame`、`vcs_diff`、待提交的内容、提交前检查 | 1.0 |
| `vcs.write` | 中 | `vcs_fetch`(仅受信任项目)、`host::set_commit_message` | 1.0 |
| `build.read` | 低 | `build_dependencies`:IDE 已解析的 Maven / Gradle 依赖图;仅限受信任的项目 | 1.10 |
| `storage` | 低 | `host::storage`,每个插件 64 MiB | 1.0 |
| `events` | 低 | 文件打开、关闭、保存,文件变化,编辑器焦点变化,仓库变化,设置变化 | 1.0 |
| `events.input` | 中 | `action-performed` 和 `input-mode-changed` 事件(按键和编辑器输入) | 1.0 |
+14 -12
View File
@@ -3,23 +3,25 @@ title: "API 版本与兼容"
description: "engines.openidea、插件 API 从 1.0 到 1.6 的各个版本,以及让已发布插件在新 IDE 中继续加载的规则。"
---
插件 API 只有一个版本号:[`wit/`](https://github.com/l0ng-ai/openidea/tree/main/wit) 中 WIT 包的版本(`main` 上是 `openidea:plugin@1.8.0`)。宿主的引擎版本和 SDK 的 `API_VERSION` 始终与它一致,SDK 里也带着一份完全相同的 WIT 文件。
插件 API 只有一个版本号:[`wit/`](https://github.com/l0ng-ai/openidea/tree/main/wit) 中 WIT 包的版本(`main` 上是 `openidea:plugin@1.10.0`)。宿主的引擎版本和 SDK 的 `API_VERSION` 始终与它一致,SDK 里也带着一份完全相同的 WIT 文件。
<Note>插件系统目前是预览版。下面的兼容规则适用于已发布的 1.x 版本;`main` 上尚未发布的内容在发布前仍可能变化。</Note>
## 版本历史
| API | 随哪个版本发布 | 主要内容 |
| ----- | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 1.0.0 | OpenIDEA 0.1.36 | 基础 API:命令、事件、存储、任务、项目和编辑器访问、VCS、诊断、网络与密钥、进程、声明式视图和自定义编辑器、设置、编辑器 provider、syntax provider |
| 1.1.0 | OpenIDEA 0.1.37 | `vcs.remotes`、`ui.copy-to-clipboard`、`ui.open-url`,从视图中打开项目文件的指定行 |
| 1.2.0 | OpenIDEA 0.1.38 | 后台文档索引器;选择器、输入框和确认框;插件自定义的 `when` 上下文键;项目视图中选中的文件;清单 `icon`;`viewItem.context` 菜单 |
| 1.3.0 | OpenIDEA 0.1.39 | 提交信息和提交前检查、Services 详情面板、输入时诊断、悬停、内嵌提示、语义 token、改动文件的代码操作、HTTP 端点、项目外文件(`fs.read`/`fs.write`、`project.write`、插件私有目录)、批量 `files-changed` 事件和路径过滤、工作区符号、长时间运行的进程、带按钮的通知、翻译、多页设置、文件模板变量、Web 视图 PTY、日志标签页和内容标签页 |
| 1.4.0 | OpenIDEA 0.1.40 | `net.http:`、`ipc:`、`ide.commands` 和 `database.sources` 能力;编辑器与项目快照、装饰、文本搜索、问题视图、Git log/blame/diff;输出通道;OAuth 回环;运行、终端会话、运行配置、测试结果解析和运行目标;格式化等语言功能;嵌入语言;代码片段;更多菜单位置;数据库数据源;MCP 工具 |
| 1.5.0 | OpenIDEA 0.1.41 | `Project::notify`(只在某个项目的窗口中显示通知)、`net:ask` 能力、运行目标启动前校验、运行目标按命令设置工作目录参数 |
| 1.6.0 | OpenIDEA 0.1.43 | 面向事件流插件、受容量限制且绑定项目的后台 WebSocket |
| 1.7.0 | OpenIDEA 0.1.44 | `views.open-diff`:在差异查看器中对比两段文本,例如评审中某个文件的修改前后 |
| 1.8.0 | `main` 上开发中 | `problems-changed` 工作台事件:宿主按文件保存每个生产者的诊断,注解跟着文件走,而不是跟着调用它的窗口 |
| API | 随哪个版本发布 | 主要内容 |
| ------ | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 1.0.0 | OpenIDEA 0.1.36 | 基础 API:命令、事件、存储、任务、项目和编辑器访问、VCS、诊断、网络与密钥、进程、声明式视图和自定义编辑器、设置、编辑器 provider、syntax provider |
| 1.1.0 | OpenIDEA 0.1.37 | `vcs.remotes`、`ui.copy-to-clipboard`、`ui.open-url`,从视图中打开项目文件的指定行 |
| 1.2.0 | OpenIDEA 0.1.38 | 后台文档索引器;选择器、输入框和确认框;插件自定义的 `when` 上下文键;项目视图中选中的文件;清单 `icon`;`viewItem.context` 菜单 |
| 1.3.0 | OpenIDEA 0.1.39 | 提交信息和提交前检查、Services 详情面板、输入时诊断、悬停、内嵌提示、语义 token、改动文件的代码操作、HTTP 端点、项目外文件(`fs.read`/`fs.write`、`project.write`、插件私有目录)、批量 `files-changed` 事件和路径过滤、工作区符号、长时间运行的进程、带按钮的通知、翻译、多页设置、文件模板变量、Web 视图 PTY、日志标签页和内容标签页 |
| 1.4.0 | OpenIDEA 0.1.40 | `net.http:`、`ipc:`、`ide.commands` 和 `database.sources` 能力;编辑器与项目快照、装饰、文本搜索、问题视图、Git log/blame/diff;输出通道;OAuth 回环;运行、终端会话、运行配置、测试结果解析和运行目标;格式化等语言功能;嵌入语言;代码片段;更多菜单位置;数据库数据源;MCP 工具 |
| 1.5.0 | OpenIDEA 0.1.41 | `Project::notify`(只在某个项目的窗口中显示通知)、`net:ask` 能力、运行目标启动前校验、运行目标按命令设置工作目录参数 |
| 1.6.0 | OpenIDEA 0.1.43 | 面向事件流插件、受容量限制且绑定项目的后台 WebSocket |
| 1.7.0 | OpenIDEA 0.1.44 | `views.open-diff`:在差异查看器中对比两段文本,例如评审中某个文件的修改前后 |
| 1.8.0 | OpenIDEA 0.1.45 | `problems-changed` 工作台事件:宿主按文件保存每个生产者的诊断,注解跟着文件走,而不是跟着调用它的窗口 |
| 1.9.0 | OpenIDEA 0.1.46 | 带环境变量和调试器的运行配置、向正在运行的语言服务器发送请求(`lsp:<server>`)、交给插件处理的服务器命令、编辑器面板 |
| 1.10.0 | `main` 上开发中 | `build.dependencies`:IDE 已解析的 Maven / Gradle 依赖图(`build.read`) |
每个版本新增内容的完整列表见 [`plugins/README.md`](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md)。
+63
View File
@@ -355,6 +355,7 @@ machine. Users can revoke optional capabilities in Settings › Plugins.
| `editor.write` | medium | `TextEditor::apply_edits` |
| `vcs.read` | low | `Project::vcs_status`, `vcs_remotes`, `vcs_log`, `vcs_blame`, `vcs_diff` (new reads require trust), `host::pending_commit`, before-commit checks |
| `vcs.write` | medium | `Project::vcs_fetch` (trusted projects only), `host::set_commit_message` |
| `build.read` | low | API 1.10: `Project::build_dependencies`, the Maven / Gradle dependency graph the IDE resolved; trusted projects only |
| `storage` | low | `host::storage` (64 MiB per plugin, counting UTF-8 bytes of keys and values) |
| `events` | low | file opened/saved, editor focused, repository changed events |
| `events.input` | medium | `action-performed` and `input-mode-changed` events |
@@ -438,6 +439,10 @@ matching SDK. Released 1.9 plugins keep working. New in 1.10:
- **`[[contributes.javaAgents]]`** loads a Java agent from the package into the
JVM of Application, Spring Boot and JAR Application configurations, behind the
high-risk `java.agent` capability. See _Java agents_.
- **The build dependency graph.** `Project::build_dependencies(module)` (WIT
`build.dependencies`) returns the Maven / Gradle graph the Dependency Analyzer
has, as a flat list with conflict and omission status, behind the low-risk
`build.read` capability. No build tool runs. See _Build dependency graph_.
### API 1.9
@@ -665,6 +670,7 @@ then run `openidea-plugin check`.
| `host::problems(path)` | `diagnostics.problems` | API 1.4: project Problems reports grouped by file/source, optional file filter. Requires `project.read` and an invoking window. Empty for remote projects. |
| `Project::vcs_log(path, limit)` | `vcs.log` | API 1.4: newest first, at most 1000 commits, optional file history. Requires `vcs.read` and trust. |
| `Project::vcs_blame(path)` | `vcs.blame` | API 1.4: attribution including unsaved editor text. Requires `vcs.read` and trust. |
| `Project::build_dependencies(module)` | `build.dependencies` | API 1.10: the Maven / Gradle dependency graph the IDE resolved, flat, each module a root; nothing is resolved for the call. Requires `build.read` and trust. |
| `Project::vcs_diff(path, against)` | `vcs.diff` | API 1.4: disk working tree against HEAD/revision, optionally one file. None outside Git; fails above 4 MiB. Requires `vcs.read` and trust. |
| `TextEditor::apply_edits(version, edits)` | `editor.text-editor.apply-edits` | One undoable change, only if the document is still at `version` — else `Error::Stale` and nothing changes. `transform_selections` retries once. |
| `Project::root()`, `read_file(path)` | `workspace.project` | Absolute or project-relative; `..`/symlinks escaping the root are rejected; UTF-8 only, ≤ 16 MiB; unsaved editor contents win; a missing path is `Error::NotFound`. |
@@ -839,6 +845,63 @@ In tests, `MockHost::set_language_server_response(server, method, json)` makes
a server run and answer, and `language_server_requests()` /
`language_server_notifications()` list what the plugin sent.
### Build dependency graph (API 1.10)
A plugin can read the Maven / Gradle dependency graph the IDE already resolved
for its Dependency Analyzer: resolved versions, conflicts, omitted duplicates
and managed versions, and so "why is this artifact here". Declare `build.read`
(low risk):
```toml
engines.openidea = "^1.10"
[capabilities]
required = ["build.read"]
```
```rust
let project = inv.project().ok_or("no project")?;
let graph = project.build_dependencies(Some("com.example:app"))?; // or None: every module
for (i, node) in graph.iter().enumerate() {
if node.status == DependencyStatus::OmittedForConflict {
// Walk `parent` up to the module to see who asked for the losing version.
let path: Vec<_> = std::iter::successors(Some(i), |&i| graph[i].parent.map(|p| p as usize))
.map(|i| format!("{}:{}", graph[i].group, graph[i].artifact))
.collect();
host::log(LogLevel::Info, &path.join(" <- "));
}
}
```
| SDK | WIT | Notes |
| ------------------------------------- | ------------------------------------- | --------------------------------------------- |
| `Project::build_dependencies(module)` | `build.dependencies(project, module)` | A flat `list<dependency-node>`, modules first |
- WIT records can't nest, so the graph is a flat list. Each module is a root
(`parent` none, empty `scope`) — a Maven module by its `groupId:artifactId`, a
Gradle project by its path (`:app`, `group` empty) — followed by its tree;
`parent` is the index of the occurrence that brings a node in.
- `module` is a Maven module's `groupId:artifactId` or a Gradle project's path
(`:` for the root project); `None` returns every module of the project's
builds. An unknown module is `not-found`.
- `status`: `resolved`; `omitted-for-conflict` (`version` is the version that
won, `requested-version` the one this occurrence asked for);
`omitted-for-duplicate` (listed with its dependencies elsewhere: Maven's
duplicates and cycles, Gradle's `(*)`); `version-managed` (Maven
`<dependencyManagement>`, a Gradle platform or constraint supplies the
version; `requested-version` is the declared one, if any). `scope` is the
Maven scope or the Gradle configuration.
- Nothing is resolved for the call. Maven trees are those of the last Reload in
the Maven tool window (with the occurrences Maven omitted); before one, or
after a POM changed, only the declared dependencies. Gradle trees are the
configurations the Dependency Analyzer has read for that project, kept until a
build file changes; before that the module has only its own node.
- At most 100,000 nodes per call (else `failed`: ask for one module). The
project must be trusted; otherwise the call is `denied`.
In tests, `MockHost::set_build_dependencies(nodes)` sets the graph that
`build_dependencies(None)` returns; a module narrows it as the IDE does.
### Database sources (API 1.4)
Declare `database.sources` (medium risk). All five calls require it and a
Binary file not shown.
+1 -1
View File
@@ -1 +1 @@
8e875bb7ed12f235be46b32ec1377f251474b0c6b663a066c36fbadc6a7fefb3
7b31c3eb3541c1766ca63b4e2ecc4475fc6c7ed0db7436cbdc1fba60ec3a7e4c
Binary file not shown.
@@ -1 +1 @@
75b4e1267fbf4a93d62963481021970e3eace3442023182e84cd9357744242c9
055939da8a1db35911b8ecfded94ab1778be7f86f545f46e9b377a0d20fe3572
Binary file not shown.
+1 -1
View File
@@ -1 +1 @@
63ad90e231b3cf22ed47710822022f4f80fbdb621b1116998e2599dab7a9b87b
a98b68f34d7a33ccf67b3770008c0817a5515475e49471456e73d18a133d2e3c
Binary file not shown.
+1 -1
View File
@@ -1 +1 @@
bfd7039bb90e1a4352b7961bbbf83e3af276ba86945fbc23bc34cbf1e3b8c272
9ae1c4497b986c6722c15d28e38bac2a905c7f9ee3bf4b6e235f924be8798d16
Binary file not shown.
+1 -1
View File
@@ -1 +1 @@
0ff9eddb3f6fa47c4afd8375471b882cd323631a383a5da97b25271cdd2850a7
51dcb30b1762236f6cc3fb3c35830c3ce2ec51e92fda6b6a95a849771f3b2592
Binary file not shown.
+1 -1
View File
@@ -1 +1 @@
471ddce51119b0fd9caa46c24248f368d48beb8953b5ad6253ba0cfc2c5aa141
2134d13e021969e0dbd889d9ba29d51a4cb4f6ee162310338762dd3260f1b316
Binary file not shown.
+1 -1
View File
@@ -1 +1 @@
4fc818b0af1abfd9d9d0cdaf4c56cce02cc7e05be501de59b1cbea4672aa91b3
b818149b051bae73a9bcb460438200799eb6a41b73139722225aeca731a826f7
Binary file not shown.
+1 -1
View File
@@ -1 +1 @@
d701b0d87cb4f0ff428bb663cb899c1ad85a3c2f10bc97b97ddbc67cdb88e07b
cba8d5dc822a4f48ceeb2002bbbe8dbc5a36375dbcbd034052a0d62d2884db75

Some files were not shown because too many files have changed in this diff Show More