//! 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, 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, pub language: Option, pub content: String, pub read_only: bool, pub actions: Vec, } /// 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, pub right_label: Option, pub title: Option, } /// 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, pub right: Option, pub left_label: Option, pub right_label: Option, pub title: Option, } impl From 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, pub saved: Option, pub read_only: Option, pub status: Option, pub error: Option, pub diff: Option, } /// 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, pub cwd: Option, pub test: bool, pub framework: Option, /// 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, } /// 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 }, } /// 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, 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, 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, pub name: String, pub location: Option, } /// 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, } /// 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, pub message: String, pub expected: Option, pub actual: Option, pub location: Option, } /// 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, } /// 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, }