дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 09:11:10 +02:00
Plugin API 1.21: - run-started events, and run-exited for user-launched plugin configurations (plugins on API 1.21 only). - run.stop(id) for runs of the plugin's own configurations; run.upsert-configuration and run.open-edit-configurations for the plugin's own run configuration types. - prepareCommand receives the run/debug mode; plugin configurations can declare a loopback JDWP attach target. - runConfigTypes.ownsBeforeLaunch, log file tabs in the run console (plugin_run_log_tail, authorised by the plugin's project.read / fs.read grants), and the runConsole.toolbar menu in the Run and Debug consoles. Review fixes: RunView log tab state keyed by the string session id, tail chunks cut on a UTF-8 boundary, user-run exits gated to API 1.21. Co-authored-by: RuyimgByCN <[email protected]>
259 рядки
7.8 KiB
Rust
259 рядки
7.8 KiB
Rust
//! Runs, keyed terminals and plugin-owned content editors (API 1.4).
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
use specta::Type;
|
|
|
|
/// ContentAction data exchanged with the IDE.
|
|
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct ContentAction {
|
|
pub id: String,
|
|
pub label: String,
|
|
pub icon: Option<String>,
|
|
pub primary: bool,
|
|
pub save: bool,
|
|
}
|
|
|
|
/// ContentTab data exchanged with the IDE.
|
|
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct ContentTab {
|
|
pub key: String,
|
|
pub title: String,
|
|
pub file_name: Option<String>,
|
|
pub language: Option<String>,
|
|
pub content: String,
|
|
pub read_only: bool,
|
|
pub actions: Vec<ContentAction>,
|
|
}
|
|
|
|
/// ContentDiff data exchanged with the IDE.
|
|
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct ContentDiff {
|
|
pub left: String,
|
|
pub right: String,
|
|
pub left_label: Option<String>,
|
|
pub right_label: Option<String>,
|
|
pub title: Option<String>,
|
|
}
|
|
|
|
/// A diff opened by a plugin (API 1.10): `None` is a side where the file doesn't exist.
|
|
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct FileDiff {
|
|
pub left: Option<String>,
|
|
pub right: Option<String>,
|
|
pub left_label: Option<String>,
|
|
pub right_label: Option<String>,
|
|
pub title: Option<String>,
|
|
}
|
|
|
|
impl From<ContentDiff> for FileDiff {
|
|
fn from(v: ContentDiff) -> Self {
|
|
Self {
|
|
left: Some(v.left),
|
|
right: Some(v.right),
|
|
left_label: v.left_label,
|
|
right_label: v.right_label,
|
|
title: v.title,
|
|
}
|
|
}
|
|
}
|
|
|
|
/// ContentTabReply data exchanged with the IDE.
|
|
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct ContentTabReply {
|
|
pub content: Option<String>,
|
|
pub saved: Option<bool>,
|
|
pub read_only: Option<bool>,
|
|
pub status: Option<String>,
|
|
pub error: Option<String>,
|
|
pub diff: Option<ContentDiff>,
|
|
}
|
|
|
|
/// Output stream transport for a plugin-owned run configuration (API 1.18).
|
|
///
|
|
/// Ordinary pseudo-terminals combine stdout and stderr and can change
|
|
/// buffering, input handling, and terminal behavior.
|
|
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub enum PluginOutputMode {
|
|
/// Separate stdout and stderr pipes in the Run console (default).
|
|
#[default]
|
|
Pipes,
|
|
/// Pseudo-terminal ("Emulate terminal in output console").
|
|
Pty,
|
|
}
|
|
|
|
/// Per-launch options for `run.start-with-options` (API 1.18).
|
|
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct PluginRunStartOptions {
|
|
pub debug: bool,
|
|
pub output_mode: Option<PluginOutputMode>,
|
|
}
|
|
|
|
/// PluginRunConfiguration data exchanged with the IDE.
|
|
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct PluginRunConfiguration {
|
|
pub id: String,
|
|
pub name: String,
|
|
pub program: String,
|
|
pub args: Vec<String>,
|
|
pub cwd: Option<String>,
|
|
pub test: bool,
|
|
pub framework: Option<String>,
|
|
/// API 1.9: variables added to the run's environment.
|
|
#[serde(default)]
|
|
pub env: Vec<(String, String)>,
|
|
/// API 1.9: how Debug starts the configuration.
|
|
#[serde(default)]
|
|
pub debugger: Option<PluginDebugger>,
|
|
/// API 1.18: default output stream transport (`pipes` or `pty`).
|
|
#[serde(default)]
|
|
pub output_mode: PluginOutputMode,
|
|
}
|
|
|
|
/// How Debug starts a plugin configuration (API 1.9 `launch-configurations.debugger`).
|
|
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)]
|
|
#[serde(rename_all = "camelCase", tag = "type")]
|
|
pub enum PluginDebugger {
|
|
/// `program` under the debugger of this language id.
|
|
#[serde(rename_all = "camelCase")]
|
|
Launch { language: String },
|
|
/// Run, then attach to the first matching process the run starts.
|
|
#[serde(rename_all = "camelCase")]
|
|
AttachChild { kind: String, command_contains: Option<String> },
|
|
}
|
|
|
|
/// RunStarted data exchanged with the IDE (API 1.21).
|
|
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct RunStarted {
|
|
pub id: String,
|
|
pub config: String,
|
|
pub debug: bool,
|
|
}
|
|
|
|
/// Draft passed to `run.upsert-configuration` (API 1.21).
|
|
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct RunConfigDraft {
|
|
pub id: Option<String>,
|
|
pub type_id: String,
|
|
pub name: String,
|
|
pub command: Option<String>,
|
|
pub args: Vec<String>,
|
|
pub cwd: Option<String>,
|
|
pub env: Vec<(String, String)>,
|
|
pub params: Vec<(String, String)>,
|
|
pub allow_parallel: bool,
|
|
}
|
|
|
|
/// RunExited data exchanged with the IDE.
|
|
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct RunExited {
|
|
pub id: String,
|
|
pub config: String,
|
|
pub status: Option<i32>,
|
|
pub killed: bool,
|
|
}
|
|
|
|
/// TerminalExited data exchanged with the IDE.
|
|
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct TerminalExited {
|
|
pub id: String,
|
|
pub key: String,
|
|
pub status: Option<i32>,
|
|
pub closed: bool,
|
|
}
|
|
|
|
/// ContentTabAction data exchanged with the IDE.
|
|
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct ContentTabAction {
|
|
pub request_id: String,
|
|
pub key: String,
|
|
pub action: String,
|
|
pub content: String,
|
|
}
|
|
|
|
/// Incremental test tree data.
|
|
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct TestStart {
|
|
pub id: String,
|
|
pub parent: Option<String>,
|
|
pub name: String,
|
|
pub location: Option<crate::Location>,
|
|
}
|
|
|
|
/// Incremental test tree data.
|
|
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct TestPassed {
|
|
pub id: String,
|
|
pub duration_ms: Option<u32>,
|
|
}
|
|
|
|
/// Incremental test tree data.
|
|
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct TestFailed {
|
|
pub id: String,
|
|
pub duration_ms: Option<u32>,
|
|
pub message: String,
|
|
pub expected: Option<String>,
|
|
pub actual: Option<String>,
|
|
pub location: Option<crate::Location>,
|
|
}
|
|
|
|
/// Incremental test tree data.
|
|
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct TestSkipped {
|
|
pub id: String,
|
|
pub reason: Option<String>,
|
|
}
|
|
|
|
/// Incremental test tree data.
|
|
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct TestOutput {
|
|
pub id: String,
|
|
pub text: String,
|
|
}
|
|
|
|
/// A test update, carried by the optional test-results export.
|
|
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)]
|
|
#[serde(tag = "type", rename_all = "camelCase")]
|
|
pub enum PluginTestEvent {
|
|
SuiteStarted(TestStart),
|
|
TestStarted(TestStart),
|
|
Passed(TestPassed),
|
|
Failed(TestFailed),
|
|
Skipped(TestSkipped),
|
|
Output(TestOutput),
|
|
Other { kind: String, data: String },
|
|
}
|
|
|
|
/// Operation about to launch through a plugin-owned run target (API 1.5).
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
pub enum RunTargetOperation {
|
|
Run,
|
|
Test,
|
|
}
|
|
|
|
/// Launch metadata available to a target validator; arguments and environment are omitted.
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
pub struct RunTargetLaunch {
|
|
pub operation: RunTargetOperation,
|
|
pub program: String,
|
|
pub cwd: String,
|
|
}
|