Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions rust/crates/build/src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,18 @@ impl BuildSystemDeclaration {
self.run.iter().any(|run| run.entrypoints)
}

/// Whether any provider application needs the registry attach feature in
/// `buildSystems` 2. Existing service declarations work in earlier versions.
pub fn has_application_connection_debug(&self) -> bool {
self.run.iter().any(|run| {
run.execution.unwrap_or(BuildExecution::Application) == BuildExecution::Application
&& run
.debug
.as_ref()
.is_some_and(|debug| debug.configuration_type.is_some())
})
}

/// Folder names every workspace hides at any depth while the plugin is
/// enabled (`layout.hiddenDirectoryNames`), sorted and unique once validated.
pub fn hidden_directory_names(&self) -> &[String] {
Expand Down
4 changes: 2 additions & 2 deletions rust/crates/build/src/manifest/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ impl BuildSystemDeclaration {
}
(None, Some(kind))
if crate::run_preparation::valid_configuration_type(kind)
&& run.execution == Some(BuildExecution::Service) => {}
&& run.execution != Some(BuildExecution::Task) => {}
_ => return Err(invalid(&field,
"Debug requires a same-package native adapter, or one registry configurationType for a service.")),
"Debug requires a same-package native adapter, or one registry configurationType for an application or service.")),
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions rust/crates/build/src/manifest/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,17 @@ impl BuildSystemDeclaration {
|| !run.extension.is_empty()
|| run.execution.unwrap_or(BuildExecution::Application)
!= BuildExecution::Application
|| run.debug.is_some()
|| run
.debug
.as_ref()
.is_some_and(|debug| debug.adapter.is_some())
|| run.name.as_ref().is_some_and(|name| {
name.trim().is_empty() || name.len() > MAX_TEXT || name.contains("${")
})
{
return Err(invalid(
&field,
"Entrypoint runs are provider applications without targets, templates or debug.",
"Entrypoint runs are provider applications without targets, templates or native debug preparation.",
));
}
continue;
Expand Down
2 changes: 1 addition & 1 deletion rust/crates/build/src/run_preparation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl LaunchOptions {
debug.target.kind != "connection"
|| debug.target.host != "127.0.0.1"
|| debug.target.port == 0
|| self.execution != BuildExecution::Service
|| self.execution == BuildExecution::Task
|| !valid_configuration_type(&debug.configuration_type)
|| !debug
.adapter_id
Expand Down
48 changes: 48 additions & 0 deletions rust/crates/core/src/tests/build_systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3330,6 +3330,54 @@ fn provider_run_options_refuse_explicit_cwd_symlinks_outside_workspace() {
assert_eq!(result["error"]["code"], "plugin.build.invalidOutput");
}

/// Source entrypoints support registry attach without rewriting existing
/// application configurations or giving the provider a remote endpoint.
#[test]
fn provider_application_entrypoints_support_connection_debug_with_build_systems_v2() {
let mut manifest: Value = serde_json::from_str(contract_file!(
"fixtures/build-providers/build-provider-run-entrypoints.plugin.json"
))
.unwrap();
let mut request = serde_json::from_str::<Value>(contract_file!(
"fixtures/build-providers/build-run-entrypoints.json"
))
.unwrap()["prepareRun"]
.clone();
let debug = serde_json::from_str::<Value>(contract_file!(
"fixtures/build-providers/build-connection-debug-options.json"
))
.unwrap()["launchOptions"]["debug"]
.clone();
let workspace = TemporaryWorkspace::new("entrypoint-attach");
workspace.write("app/src/main/java/example/Tool.java", "class Tool {}");
request["workspaceRoot"] = json!(workspace.root());
let plan = |request: &Value, manifest: &Value| {
build_prepare_run_plan_command::<Manifest>(super::support::trusted_payload(
json!({"manifest":manifest,"buildSystemID":"gradle","request":request}),
))
.unwrap()
};
assert_eq!(plan(&request, &manifest)["status"], "ok");
request["launchOptions"]["debug"] = debug;
assert_eq!(plan(&request, &manifest)["status"], "rejected");

manifest["buildSystems"][0]["run"][1]["debug"] = json!({"configurationType":"java"});
assert_eq!(
validate(manifest.clone())["error"]["field"],
"requires.buildSystems"
);
manifest["requires"]["buildSystems"] = json!(2);
assert_eq!(validate(manifest.clone())["status"], "ok");
let planned = plan(&request, &manifest);
assert_eq!(planned["status"], "ok", "{planned}");
let params = &planned["plan"]["provider"]["params"];
assert!(params.get("target").is_none());
assert_eq!(params["launchOptions"], request["launchOptions"]);

request["launchOptions"]["debug"]["target"]["host"] = json!("remote.example");
assert_eq!(plan(&request, &manifest)["status"], "rejected");
}

/// Model-supplied default choices and exclusion prefixes let a build tool's
/// profiles or features show default-active entries, deactivate them on CLI
/// even before the model reloads, and clear the local override once the user
Expand Down
14 changes: 14 additions & 0 deletions rust/crates/plugin-manifest/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,20 @@ impl DeclarativePluginManifest {
"Entrypoint runs need buildProviders 1.",
));
}
if self
.build_systems
.iter()
.any(|system| system.has_application_connection_debug())
&& self
.requires
.get(capabilities::BUILD_SYSTEMS)
.is_none_or(|version| *version < 2)
{
return Err(invalid(
"requires.buildSystems",
"Registry connection debugging for applications needs buildSystems 2.",
));
}
if self
.build_systems
.iter()
Expand Down
5 changes: 3 additions & 2 deletions rust/crates/plugin-model/src/capabilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ pub const SOURCE_SETTINGS: &str = "sourceSettings";
/// settings regions, and commands.
pub const UI: &str = "ui";
/// Declarative build detection, models, and command plans.
/// Version 1 adds command-based test discovery.
/// Version 1 adds command-based test discovery. Version 2 adds registry
/// connection debugging for provider applications.
pub const BUILD_SYSTEMS: &str = "buildSystems";
/// `buildSystems[].provider`, whether it owns or shares a language server process.
/// Version 1 adds runs with `entrypoints: true`, which start an entrypoint the
Expand Down Expand Up @@ -131,7 +132,7 @@ pub const SUPPORTED_CAPABILITIES: &[(&str, &[u32])] = &[
(BEFORE_LAUNCH_TASKS, &[0]),
(BUILD_MODEL_INPUTS, &[0]),
(BUILD_PROVIDERS, &[0, 1]),
(BUILD_SYSTEMS, &[0, 1]),
(BUILD_SYSTEMS, &[0, 1, 2]),
(COMMAND_INSTALLERS, &[0, 1]),
(DEBUG_ADAPTERS, &[0]),
(EXECUTION_PROVIDERS, &[0]),
Expand Down
17 changes: 11 additions & 6 deletions shared/plugins/contract/v1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2529,8 +2529,9 @@ A provider run may declare `entrypoints: true` instead of `fromTargets`. It is
an application that starts an entrypoint the provider names, such as a class
with a `main` method, in one of its projects. It requires `source: "provider"`
and `buildProviders` 1 in `requires`; `fromTargets`, `fromTasks`, `arguments`,
`extension`, `debug`, and a `service` or `task` execution are refused. It
applies to no target, so the host never lists it per target: the user starts
`extension`, a native `debug.adapter`, and a `service` or `task` execution
are refused. A registry `debug.configurationType` requires `buildSystems` 2.
It applies to no target, so the host never lists it per target: the user starts
it from a source file.

`build.runEntrypointsPlan` takes the common plan fields, optional `refresh`
Expand Down Expand Up @@ -2567,8 +2568,12 @@ and `fixtures/build-providers/build-run-entrypoints.json`.

#### Registry connection debugging

A provider service run may declare
`debug: {"configurationType":"example"}`. This is a public DebugAdapter Registry
A provider service run may declare `debug: {"configurationType":"example"}`.
With `buildSystems` 2, a provider application (including an entrypoint run)
may make the same declaration. Saved application configurations keep
`execution: "application"` for Run and Debug. Debug sends the existing
connection fields in `launchOptions.debug`, with no change to the
negotiated `litheBuild` version. The declaration names a public DebugAdapter Registry
alias, not another plugin's private language server or a local adapter ID.
The host selects one currently enabled adapter advertising the type and `attach`,
respecting an explicit qualified adapter selection. Missing or ambiguous entries
Expand All @@ -2581,9 +2586,9 @@ fail before starting the provider process. It sends:

These are the exact three debug fields and three target fields. The host owns
the port (integer 1–65535), process, readiness and cleanup. Explicit null, unknown
fields, remote hosts and application/task execution are rejected. The type must
fields, remote hosts and task execution are rejected. The type must
match the selected run declaration. The provider uses its
upstream engine to suspend the service until attachment; it owns runtime-specific
upstream engine to suspend the debuggee until attachment; it owns runtime-specific
flags and fails if it cannot honor the request. It returns the ordinary portable
Run process plan, without selecting an endpoint or returning DAP arguments.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@
"edits": [{ "op": "set", "path": "/requires/buildSystems", "value": 5 }],
"expectedCode": "plugin.api.unsupported"
},
{"name": "capability version 2 is not defined", "base": "build-static-file.plugin.json", "edits": [{"op": "set", "path": "/requires/buildSystems", "value": 2}], "expectedCode": "plugin.api.unsupported", "expectedField": "requires.buildSystems"},
{"name": "capability version 3 is not defined", "base": "build-static-file.plugin.json", "edits": [{"op": "set", "path": "/requires/buildSystems", "value": 3}], "expectedCode": "plugin.api.unsupported", "expectedField": "requires.buildSystems"},
{
"name": "used capability missing from requires",
"base": "build-provider-language-server.plugin.json",
Expand Down
6 changes: 3 additions & 3 deletions shared/plugins/contract/v1/plugin-manifest.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"beforeLaunchTasks": { "description": "Required exactly when any buildSystems[].beforeLaunchTasks is non-empty: kinds of step a run configuration's Before Launch list runs first, offered in its Add New Task menu, drawn from declared fields and run through a declared command line. Needs buildSystems.", "enum": [0] },
"buildModelInputs": {"description": "Optional public model sharing between already enabled workspace plugins; no installation, private function, or process authority. Required exactly when modelSharing or modelInputs is used. Consumers require buildProviders. A producer cannot also consume inputs.", "enum": [0]},
"buildProviders": { "description": "Required exactly when any buildSystems[].provider is present, including own-process and shared language-server providers. Declares host support for Provider orchestration (task execution, test execution and discovery, run preparation, native debug preparation, optional read-only model inputs, non-sensitive native configuration sources, inline test reports, opaque semantic test selectors, typed run options and service/task preparation, registry-selected adapters and host-owned connection targets for service debugging), independent of declarative buildSystems. Version 1 adds entrypoint runs (lithe/build/runEntrypoints).", "enum": [0, 1] },
"buildSystems": { "description": "Declarative build detection, models, and command plans. Version 1 adds command-based test discovery. Neither version implies buildProviders support.", "enum": [0, 1] },
"buildSystems": { "description": "Declarative build detection, models, and command plans. Version 1 adds command-based test discovery. Version 2 adds registry connection debugging for provider applications. These versions do not imply buildProviders support.", "enum": [0, 1, 2] },
"commandInstallers": { "description": "Required exactly when commandInstallers is non-empty: installations of bare commands that systemCommand launches name, run by the host only after the user confirms them. Version 1 adds download installers: pinned per-platform archives the host downloads, checks and extracts into the plugin's managed directory.", "enum": [0, 1] },
"debugAdapters": { "description": "Required exactly when debugAdapters is non-empty. Covers bounded target argument and environment bindings and debugAdapters[].features and defaults. The DAP session itself is negotiated by the adapter in initialize.", "enum": [0] },
"executionProviders": { "enum": [0] },
Expand Down Expand Up @@ -3413,7 +3413,7 @@
],
"properties": {
"debug": {
"description": "Same-package native launch adapter, or a public registry configurationType for connection attach (service runs).",
"description": "Same-package native launch adapter, or a public registry configurationType for connection attach (services and, with buildSystems 2, applications).",
"type": "object", "additionalProperties": false,
"oneOf": [{"required": ["adapter"]}, {"required": ["configurationType"]}],
"properties": {
Expand Down Expand Up @@ -3491,7 +3491,7 @@
}
},
"entrypoints": {
"description": "buildProviders 1: a provider application that starts an entrypoint lithe/build/runEntrypoints names in a source file, in its project and without a target. Requires source provider; refuses fromTargets, fromTasks, arguments, extension, debug and a service or task execution.",
"description": "buildProviders 1: a provider application that starts an entrypoint lithe/build/runEntrypoints names in a source file, in its project and without a target. Requires source provider; refuses fromTargets, fromTasks, arguments, extension, native debug and a service or task execution. Registry connection debugging requires buildSystems 2.",
"type": "boolean"
}
},
Expand Down
2 changes: 2 additions & 0 deletions shared/plugins/reference/capabilities-and-versions.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Core 列以本仓库 `main` 上的 Core 源码为准([`capabilities.rs`](https
| `ui` `0` | [`ui`](../contract/v1/README.md#host-owned-workbench-ui):文本、[包内网页](../contract/v1/README.md#web-content)和[插件视图](../contract/v1/README.md#plugin-views)的工具窗口、设置区域里的插件视图、命令,以及[不打开工具窗口的后端命令](../contract/v1/README.md#backend-only-commands);视图函数的结果由 Core 命令 `plugins.ui.applyResult` 校验,形状见 [`plugin-ui.schema.json`](../contract/v1/plugin-ui.schema.json) | ✅ | ✅¹ | [界面](domains/ui.md) |
| `buildSystems` `0` | 不带 `provider` 的 [`buildSystems[]`](../contract/v1/README.md#build-systems):检测、选项、项目模型、任务、运行入口、测试、诊断、依赖、同步和[声明式项目准备](../contract/v1/README.md#declarative-project-preparation) | ✅ | ✅¹ | [声明式构建系统](domains/build-systems.md) |
| `buildSystems` `1` | 新增 [命令式测试发现](../contract/v1/README.md#test-discovery),复用声明的构建工具和测试选择器 | ✅ | 待宿主声明 | [声明式构建系统](domains/build-systems.md) |
| `buildSystems` `2` | 构建提供者的应用运行声明可使用 `debug.configurationType`,包括按源文件发现的入口 | ✅ | 待宿主接入 | [构建提供者](domains/build-providers.md) |
| `buildProviders` `0` | `buildSystems[].provider`:[构建提供者](../contract/v1/README.md#build-providers),可以是自有进程或共享语言服务器;说 `litheBuild`,包含任务执行、测试执行与发现、运行准备、原生调试准备、原生配置、内联测试报告、语义测试选择器、类型化运行选项和注册表连接调试 | ✅ | ✅¹ | [构建提供者](domains/build-providers.md) |
| `buildProviders` `1` | 在 `0` 之上加:运行声明 `entrypoints: true`(入口运行,不需要目标),提供者用 `lithe/build/runEntrypoints` 回答一个源文件里可运行的入口,宿主把它保存为运行配置并按入口启动 | ✅ | ✅ | [Run entrypoints](../contract/v1/README.md#run-entrypoints-buildproviders-1) |
| `buildModelInputs` `0` | `buildSystems[].modelSharing` 与 `modelInputs`:[已启用工作区插件之间共享的只读模型输入](../contract/v1/README.md#optional-read-only-model-inputs)(可选) | ✅ | 未声明 | [构建提供者](domains/build-providers.md) |
Expand Down Expand Up @@ -166,6 +167,7 @@ Each row is one capability. `requires` lists **exactly** the capabilities a mani
| `ui` `0` | [`ui`](../contract/v1/README.md#host-owned-workbench-ui): text, [web](../contract/v1/README.md#web-content), and [plugin view](../contract/v1/README.md#plugin-views) tool windows, plugin views in settings regions, commands, and [backend-only commands](../contract/v1/README.md#backend-only-commands) without a tool window; the Core command `plugins.ui.applyResult` checks view function results, shaped as in [`plugin-ui.schema.json`](../contract/v1/plugin-ui.schema.json) | ✅ | ✅¹ | [UI](domains/ui.md) |
| `buildSystems` `0` | [`buildSystems[]`](../contract/v1/README.md#build-systems) without `provider`: detection, options, project model, tasks, run entries, tests, diagnostics, dependencies, sync, and [declarative preparation](../contract/v1/README.md#declarative-project-preparation) | ✅ | ✅¹ | [Declarative build systems](domains/build-systems.md) |
| `buildSystems` `1` | Adds [command test discovery](../contract/v1/README.md#test-discovery) using the declared build tool and the existing test selectors | ✅ | Pending host declaration | [Declarative build systems](domains/build-systems.md) |
| `buildSystems` `2` | Allows build provider application runs to declare `debug.configurationType`, including source entrypoints | ✅ | Pending host integration | [Build providers](domains/build-providers.md) |
| `buildProviders` `0` | `buildSystems[].provider`: [build providers](../contract/v1/README.md#build-providers), in their own process or a shared language server; they speak `litheBuild`, which covers task execution, test execution and discovery, run preparation, native debug preparation, native configuration, inline test reports, semantic test selectors, typed run options, and registry connection debugging | ✅ | ✅¹ | [Build providers](domains/build-providers.md) |
| `buildProviders` `1` | Adds to `0`: run declarations with `entrypoints: true` (entrypoint runs, without a target); the provider answers `lithe/build/runEntrypoints` with the runnable entrypoints of one source file, which the host saves as run configurations and starts | ✅ | ✅ | [Run entrypoints](../contract/v1/README.md#run-entrypoints-buildproviders-1) |
| `buildModelInputs` `0` | `buildSystems[].modelSharing` and `modelInputs`: [optional read-only model inputs](../contract/v1/README.md#optional-read-only-model-inputs) shared between enabled workspace plugins | ✅ | Not declared | [Build providers](domains/build-providers.md) |
Expand Down
Loading
Loading