mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-22 00:03:02 +00:00
feat(plugins): diffs with a missing side for added and deleted files (API 1.10) (#3827)
views.open-diff takes exactly two texts, so a plugin could not tell the IDE that a file does not exist on one side, and the diff drew an empty pane next to it. API 1.10 adds views.open-file-diff with a file-diff record whose left / right are option<string> (none: the file does not exist there; both none is invalid); the SDK adds host::open_file_diff with a mock, and web views may send null for a missing side. A missing side maps to the same absent text side the VCS diffs use, so the existing side shows alone. open-diff and content-diff are unchanged. The WIT package, ENGINE_VERSION and API_VERSION move to 1.10.0, with the checked-in components rebuilt. Closes #3780 Co-authored-by: bertyhell <1710840+bertyhell@users.noreply.github.com>
This commit is contained in:
co-authored by
bertyhell
parent
0ff491cce8
commit
64ee712401
@@ -34,7 +34,7 @@ use std::path::{Component, Path, PathBuf};
|
||||
|
||||
pub const MANIFEST_FILE: &str = "plugin.toml";
|
||||
/// The plugin API (engine) version this host implements.
|
||||
pub const ENGINE_VERSION: &str = "1.9.0";
|
||||
pub const ENGINE_VERSION: &str = "1.10.0";
|
||||
/// The 0.1 API, still accepted for contribution-only packages and 0.1 components.
|
||||
pub const LEGACY_API: &str = "0.1";
|
||||
/// Marketplace categories, in the order they are shown.
|
||||
|
||||
@@ -1551,13 +1551,8 @@ impl HostApi for PluginApi {
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
fn open_diff(
|
||||
&self,
|
||||
client: &str,
|
||||
diff: ide_plugin::ContentDiff,
|
||||
file_name: Option<String>,
|
||||
) -> Result<(), HostError> {
|
||||
super::execution::validate_diff(&diff)?;
|
||||
fn open_diff(&self, client: &str, diff: ide_plugin::FileDiff, file_name: Option<String>) -> Result<(), HostError> {
|
||||
super::execution::validate_file_diff(&diff)?;
|
||||
if let Some(name) = &file_name {
|
||||
super::execution::label(name, 256)?;
|
||||
}
|
||||
|
||||
@@ -91,12 +91,31 @@ fn diff_side(value: &str, side: &str) -> Result<(), HostError> {
|
||||
}
|
||||
|
||||
pub(super) fn validate_diff(diff: &ide_plugin::ContentDiff) -> Result<(), HostError> {
|
||||
diff_side(&diff.left, "left")?;
|
||||
diff_side(&diff.right, "right")?;
|
||||
for value in [&diff.left_label, &diff.right_label].into_iter().flatten() {
|
||||
validate_diff_parts([Some(&diff.left), Some(&diff.right)], [&diff.left_label, &diff.right_label], &diff.title)
|
||||
}
|
||||
|
||||
/// A `None` side doesn't exist (an added or deleted file); at least one side does.
|
||||
pub(super) fn validate_file_diff(diff: &ide_plugin::FileDiff) -> Result<(), HostError> {
|
||||
validate_diff_parts([diff.left.as_ref(), diff.right.as_ref()], [&diff.left_label, &diff.right_label], &diff.title)
|
||||
}
|
||||
|
||||
fn validate_diff_parts(
|
||||
sides: [Option<&String>; 2],
|
||||
labels: [&Option<String>; 2],
|
||||
title: &Option<String>,
|
||||
) -> Result<(), HostError> {
|
||||
if sides.iter().all(Option::is_none) {
|
||||
return Err(HostError::Invalid("a diff needs at least one side".into()));
|
||||
}
|
||||
for (value, side) in sides.into_iter().zip(["left", "right"]) {
|
||||
if let Some(value) = value {
|
||||
diff_side(value, side)?;
|
||||
}
|
||||
}
|
||||
for value in labels.into_iter().flatten() {
|
||||
label(value, 128)?;
|
||||
}
|
||||
if let Some(title) = &diff.title {
|
||||
if let Some(title) = title {
|
||||
label(title, 256)?;
|
||||
}
|
||||
Ok(())
|
||||
@@ -713,6 +732,28 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_file_diff_may_miss_one_side_but_not_both() {
|
||||
let side = |left: Option<&str>, right: Option<&str>| ide_plugin::FileDiff {
|
||||
left: left.map(Into::into),
|
||||
right: right.map(Into::into),
|
||||
..Default::default()
|
||||
};
|
||||
assert!(validate_file_diff(&side(None, Some("added\n"))).is_ok());
|
||||
assert!(validate_file_diff(&side(Some("deleted\n"), None)).is_ok());
|
||||
assert!(validate_file_diff(&side(Some(""), Some(""))).is_ok());
|
||||
assert!(
|
||||
matches!(validate_file_diff(&side(None, None)), Err(HostError::Invalid(m)) if m == "a diff needs at least one side")
|
||||
);
|
||||
let huge = "y".repeat(MAX_DIFF_SIDE + 1);
|
||||
assert!(
|
||||
matches!(validate_file_diff(&side(None, Some(&huge))), Err(HostError::Invalid(m)) if m == "diff too large: the right side is over 8 MiB")
|
||||
);
|
||||
assert!(
|
||||
matches!(validate_file_diff(&side(Some("a\0"), None)), Err(HostError::Invalid(m)) if m.contains("NUL"))
|
||||
);
|
||||
}
|
||||
|
||||
fn launch(
|
||||
env: Vec<(&str, &str)>,
|
||||
debugger: Option<ide_plugin::PluginDebugger>,
|
||||
|
||||
@@ -220,7 +220,7 @@ pub enum PluginEvent {
|
||||
ContentTabReply { plugin_id: String, request_id: String, reply: ide_plugin::ContentTabReply },
|
||||
/// Open two texts in this window's diff viewer.
|
||||
#[serde(rename_all = "camelCase")]
|
||||
OpenDiff { plugin_id: String, diff: ide_plugin::ContentDiff, file_name: Option<String> },
|
||||
OpenDiff { plugin_id: String, diff: ide_plugin::FileDiff, file_name: Option<String> },
|
||||
|
||||
/// Plugins, their status or their contributions changed: re-fetch `plugin_list`.
|
||||
CommandsChanged,
|
||||
|
||||
@@ -6518,8 +6518,8 @@ fn a_plugin_command_opens_a_diff_in_its_window() {
|
||||
client.as_deref() == Some("main")
|
||||
&& matches!(event, PluginEvent::OpenDiff { plugin_id, diff, file_name }
|
||||
if plugin_id == "execution"
|
||||
&& diff.left == "before\n"
|
||||
&& diff.right == "after\n"
|
||||
&& diff.left.as_deref() == Some("before\n")
|
||||
&& diff.right.as_deref() == Some("after\n")
|
||||
&& diff.title.as_deref() == Some("Review")
|
||||
&& file_name.as_deref() == Some("src/review.rs"))
|
||||
})
|
||||
|
||||
@@ -38,6 +38,29 @@ pub struct ContentDiff {
|
||||
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")]
|
||||
|
||||
@@ -56,7 +56,7 @@ use views_bindings::exports::openidea::plugin::view_provider as wit_view;
|
||||
use views_bindings::openidea::plugin::view_types as wit_vt;
|
||||
|
||||
/// The API version of the world above, `major.minor` of [`host_api`].
|
||||
pub const API_VERSION: &str = "1.9";
|
||||
pub const API_VERSION: &str = "1.10";
|
||||
const EPOCH_TICK: Duration = Duration::from_millis(10);
|
||||
pub(crate) const MAX_TEXT: usize = 1 << 20;
|
||||
pub(crate) const MAX_TITLE: usize = 256;
|
||||
@@ -188,8 +188,8 @@ pub trait HostApi: Send + Sync {
|
||||
let _ = (client, tab, cancel, timeout);
|
||||
Err(HostError::Failed("content tabs unavailable".into()))
|
||||
}
|
||||
/// Opens a diff of two texts in the invoking window.
|
||||
fn open_diff(&self, client: &str, diff: crate::ContentDiff, file_name: Option<String>) -> Result<(), HostError> {
|
||||
/// Opens a diff of two texts in the invoking window; a `None` side doesn't exist.
|
||||
fn open_diff(&self, client: &str, diff: crate::FileDiff, file_name: Option<String>) -> Result<(), HostError> {
|
||||
let _ = (client, diff, file_name);
|
||||
Err(HostError::Failed("diffs unavailable".into()))
|
||||
}
|
||||
|
||||
@@ -1782,6 +1782,13 @@ impl views::Host for StoreData {
|
||||
.map_err(to_wit))
|
||||
}
|
||||
fn open_diff(&mut self, diff: views::ContentDiff, file_name: Option<String>) -> Fallible<()> {
|
||||
if let Err(e) = self.require_window() {
|
||||
return Ok(Err(e));
|
||||
}
|
||||
let diff = crate::FileDiff::from(crate::ContentDiff::from(diff));
|
||||
Ok(self.host.open_diff(self.invocation.client.as_deref().unwrap(), diff, file_name).map_err(to_wit))
|
||||
}
|
||||
fn open_file_diff(&mut self, diff: views::FileDiff, file_name: Option<String>) -> Fallible<()> {
|
||||
if let Err(e) = self.require_window() {
|
||||
return Ok(Err(e));
|
||||
}
|
||||
@@ -2146,6 +2153,12 @@ impl From<bindings::openidea::plugin::views::ContentDiff> for crate::ContentDiff
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bindings::openidea::plugin::views::FileDiff> for crate::FileDiff {
|
||||
fn from(v: bindings::openidea::plugin::views::FileDiff) -> Self {
|
||||
Self { left: v.left, right: v.right, left_label: v.left_label, right_label: v.right_label, title: v.title }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bindings::openidea::plugin::views::ContentTabReply> for crate::ContentTabReply {
|
||||
fn from(v: bindings::openidea::plugin::views::ContentTabReply) -> Self {
|
||||
Self {
|
||||
|
||||
@@ -91,15 +91,15 @@ fn the_sdk_carries_the_hosts_wit() {
|
||||
|
||||
#[test]
|
||||
fn the_version_check_runs_compatible_components_and_explains_the_rest() {
|
||||
let host = v("1.9.0");
|
||||
for ok in ["1.0.0", "1.3.0", "1.4.7", "1.5.0", "1.6.0", "1.7.0", "1.8.0", "1.9.0", "1.0.0-rc.1"] {
|
||||
let host = v("1.10.0");
|
||||
for ok in ["1.0.0", "1.3.0", "1.4.7", "1.5.0", "1.6.0", "1.7.0", "1.8.0", "1.9.0", "1.10.0", "1.0.0-rc.1"] {
|
||||
assert_eq!(check_api(&v(ok), &host), Ok(()), "{ok}");
|
||||
}
|
||||
let newer = check_api(&v("1.10.0"), &host).unwrap_err();
|
||||
assert!(newer.contains("1.10") && newer.contains("update OpenIDEA"), "{newer}");
|
||||
let newer = check_api(&v("1.11.0"), &host).unwrap_err();
|
||||
assert!(newer.contains("1.11") && newer.contains("update OpenIDEA"), "{newer}");
|
||||
assert!(check_api(&v("2.0.0"), &host).unwrap_err().contains("update OpenIDEA"));
|
||||
let older = check_api(&v("0.2.0"), &host).unwrap_err();
|
||||
assert!(older.contains("rebuild it with the 1.9 SDK"), "{older}");
|
||||
assert!(older.contains("rebuild it with the 1.10 SDK"), "{older}");
|
||||
// 0.x: every minor is its own API.
|
||||
assert_eq!(check_api(&v("0.2.0"), &v("0.2.5")), Ok(()));
|
||||
assert!(check_api(&v("0.1.0"), &v("0.2.0")).is_err());
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
75123cf60f87ec9bdd36e0b7f75efb69d000136d74c3e9da893ecd1534bdf534
|
||||
47eb797508a8b7c4f2b8de276656a936cb7b603edf6d5cb0997fd55f06c18d74
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
60d66ec578e3adc7adaebbcd01aa92a74a8a7e4cfd4d1aa778f9b033c75234a6
|
||||
baabfa459d287fe78389fc5d71951248942902b9cf029ab3782cc929c1ca7bf3
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
df55973ed77e734e48fe1d2b7bb5d1e4eb68153b17452e4385599145427292b6
|
||||
e86a42a3716d37a7e5034d922a097487f3659691dc8879ad16e4efa63e4e030f
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
94f1c4a8192e15961bd136cf9dc3416fca7b295bce0d563608a3ee9fdf81c28e
|
||||
d5f2d8b20bfbd0f2dbd566dae490645f6f266f0dd87498e5476ead56ca1fe09e
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
db140480eaf4352fa8db8d87aab95cb07944e19c28d2cc08e299b37c5deb4230
|
||||
65748dfb8348c17e464c2378e6b66ae0e30883aee0e1b27130078e3b970c3bf7
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
5fd76f6168d3a7b3259281171f375cf01da6ceabdf4ffd382c5fe7034b2e94f2
|
||||
2f25d04ba6260c54e1010b310b696428672975c3c0986aab952f534be2783847
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
5d9049fa006194e92e06de47ab933d249118706a8ba92100493318a1582f2b65
|
||||
f2bcf27e33c50fcffd3dcb3a9f7029f4774105b143d881e78b5b1c80b10f04f3
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
c723d915b69292740a863b3a94db6f6f8c218ecda46c527229d621084f2df3b1
|
||||
88d11e9fc45c98000f296e46e8105cc83e7fbe6c248a993d82f333caab51e152
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
2dbab98cfc473650675b2691c7d0f2d5b088ffd6208e31ef30aaa54dd3b1b4b0
|
||||
52768373487be5388e5de2cc577d9c3d74eb0877ecd78a0b641188aed2d18004
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
1fa1515aae810e588f2c1d25728755c25fd51c78d35d96d823583052372c34dd
|
||||
63368e7ba560204b6913261bc631579387e42a178cd39d106985ef114a88e54a
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
69eaf24b0ed3260a6b3656563b1d0b8b268de81899f05bc984c668b0765e361f
|
||||
6466e46285c132256a03dee9814d3a8f899eab1aaedd389a7087601d2f236bcc
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
c6bd0a45a6cc3b09114be55c8b63563bea4ca6b748ee27c7843bb4ab05d7ce26
|
||||
e9fa2ec856fd9c3b19a1a0b233ce55b6e844d0a6f0909018062814eff63c7d6b
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
f870210add7c920df42e276a4cefcd1eaf01b3869f238c0a366beeb052e4adc3
|
||||
26893acfd5486f2df35efb28a1719bf3306118a10b1ad346ad74e4b3318f8258
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
3a3c0d4e5a1564eaa2ca35b698cd4b553722476cf68995495b9f277631b08266
|
||||
b6ebe9a4c121e4a1f6d2b4d932c8e6a89e52ab3bb957dc241fb6087130c9fe56
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
aab9d674d5d94b7488fe088e5c355511403edf7878c6fe124e2a2be86598ead6
|
||||
a6d0fe560d3492db63fb58a1f898d7090860f2c9dd4dc4e8b97079cd7a97c0b1
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
391ce453aa40de84ca4a6ed5f5b8ee88f5d659e8699029fa3a8940dac7d6dc9b
|
||||
3eee2fe2eab305a66a5650dcc9892fed7cc028538d31ab31ed448edbdfa0cdf9
|
||||
|
||||
Binary file not shown.
+1
-1
@@ -1 +1 @@
|
||||
ccbb5abb90a0bb49c0f51d0e2865d1c4092e28e9168e4c57e5f7b6ea971721ac
|
||||
3d76b858a8fbf868c36d19897cf85c72e516340eb3e47f27c59b8323dc53b8a3
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
6a36bd56db7148032c1fe101bec8c38e326528b1de1ee26b5d7c5b9dd80b3e94
|
||||
8d80e89b4b5025c874e467abbea578da52f61a48eeea4573645d362c530fef70
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
9b5d0e40e7fef9e48e1a894549e4b96853b8217ad7d12fe29d238a599772a329
|
||||
f052bab94de44b140f957d360f16e6c8dd2bc5d80dd7732b62536b6e74f4e868
|
||||
|
||||
+3
-3
@@ -5,9 +5,9 @@ wit_bindgen::generate!({
|
||||
inline: "
|
||||
package fixture:misbehave;
|
||||
world misbehave {
|
||||
include openidea:plugin/plugin-syntax@1.9.0;
|
||||
export openidea:plugin/providers@1.9.0;
|
||||
export openidea:plugin/file-actions@1.9.0;
|
||||
include openidea:plugin/plugin-syntax@1.10.0;
|
||||
export openidea:plugin/providers@1.10.0;
|
||||
export openidea:plugin/file-actions@1.10.0;
|
||||
}
|
||||
",
|
||||
path: "../../../../../wit",
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
a11bc7b7151a62e98d665a6459b3c84e4cb836b734fd23e7bad3adc533655f81
|
||||
f9c4279e7972e89fdc0bc1849ed84b72b983b2230526b492110c4de87a843ed0
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
aad4871073c7c7f22ab84f1e7965d1a861b7e5ddd9f86408e95eba4c3c021411
|
||||
ae0aa9ed34eb508f388fc43b92544ebdd91c3dfcace3c281d0c32b4947ab09ce
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
f2e0df07f6d7a501e96caf43efcfdaa0596aa2b9dad5c46ef71f5ad2eddc505b
|
||||
d75dcfcdb4c2f49e391e21bba9f58567937c8fbc739a853bfed8fce58cd6c753
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
253f93d1254310669150f6fd629ae88223d7d6f1cd642803ec57382e5acd4451
|
||||
a25338eaf06fcd417cbd851e8447666ba25214e424c4ba7ee06919d563ff2e88
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
9351d3248252ca35a40ce557ada29e8aa4f3135273e988235bc22ebcfd0505ec
|
||||
aa9072503d07f0963b115a7ac3b5cdee008d9369263375c9621ba19259647db6
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
7f4ad5bc15d70de0ae7a0e96c584edcd6caef1cb18b5450685a83d8a8de16d24
|
||||
ea3b652f16052305b8cfd45216651da96af6603a1c9018bdcb61897e287a6be6
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
7d18591aa915fd6dd71fd8f8a4a0c7d8abb2cc5ff9252a56fb0d6b7458562466
|
||||
b62841f3469339fcdd3d718963ca3a4a0971a98d770c625334ebb558613f0eb4
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
55e59a27457e8f25e9bd0e727ebbc6276b0f45d210732a88ede4954ec2dc777f
|
||||
535501e8df328c2d340b967de4cf0e9099d2d7ac1186a67b6cc45a88c033b2eb
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
8ce7d4a12f8bd393b8b32e695d3dd2994c30ba27fb8419b8af900a550cb2da7c
|
||||
29f72aaff35386bb1d340638234f7c63535b5fb2b447d19da53ed703cfa4ab8e
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
f654b73781d88c25dddddcdb25e8c02195b36dc9e008dd9eafafd632a11c48c5
|
||||
e28ef416c0034a8006692fab43df24eb14fd43ac6f783e4a36ba223eac1dbff5
|
||||
|
||||
@@ -287,6 +287,7 @@ With `engines.openidea = "^1.3"`, a page can send JSON messages through
|
||||
| `open-log-tab` | A read-only editor tab following a program's output, with argument toggles. |
|
||||
| `open-content-tab` | An editor tab on content the plugin supplies, with toolbar actions answered by `content-tab-reply`. |
|
||||
| `open-diff` | API 1.7: the diff viewer on two texts (`left`, `right`, optional labels, `title` and `fileName` for highlighting). |
|
||||
| `open-diff` with a `null` side | API 1.10: the file doesn't exist on that side (added or deleted); the diff viewer shows the other side alone. |
|
||||
|
||||
The message fields and limits are in the
|
||||
[plugin guide](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#web-frame-ptys-api-13);
|
||||
@@ -353,6 +354,7 @@ These are called from a command or event of a window:
|
||||
| `host::open_log_tab(key, title, &log)` | API 1.3: the read-only log tab, from a `ProcessLog`. At most 32 per window; not yet in remote projects. |
|
||||
| `host::open_content_tab(&ContentTab { .. })` | API 1.4: a content editor tab without a web view; actions arrive as `content-tab-action` events, answered with `host::reply_content_tab`. |
|
||||
| `host::open_diff(&ContentDiff { .. }, file_name)` | API 1.7: the diff viewer on two texts, such as a review's file before and after; `file_name` picks the syntax highlighting. |
|
||||
| `host::open_file_diff(&diff, file_name)` | API 1.10: the same with a `FileDiff`, whose `None` side is a file that doesn't exist there; an added or deleted file shows alone. |
|
||||
| `host::output_append(channel, text)` | API 1.4: a read-only **Output** tab per channel (32 channels, 1 MiB each); `output_clear`, `output_reveal`. |
|
||||
|
||||
```rust
|
||||
|
||||
@@ -256,6 +256,7 @@ Vite + React 页面由 `plugins/build.sh official/graphviz` 构建到 `web/`,
|
||||
| `open-log-tab` | 只读编辑器标签页,持续显示程序输出,可带参数开关。 |
|
||||
| `open-content-tab` | 内容由插件提供的编辑器标签页,带工具栏操作,用 `content-tab-reply` 回复。 |
|
||||
| `open-diff` | API 1.7:在差异查看器中对比两段文本(`left`、`right`,可选标签、`title`,以及用于高亮的 `fileName`)。 |
|
||||
| `open-diff` 某一侧为 `null` | API 1.10:该侧文件不存在(新增或删除),差异查看器只显示另一侧。 |
|
||||
|
||||
消息字段和限制见 [插件指南](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#web-frame-ptys-api-13);
|
||||
`crates/ide-plugin/tests/fixtures/` 下已构建的 `web-pty`、`web-log`、`web-content` 测试插件演示了这些协议。
|
||||
@@ -315,6 +316,7 @@ impl Details for MyPlugin {
|
||||
| `host::open_log_tab(key, title, &log)` | API 1.3:基于 `ProcessLog` 的只读日志标签页。每个窗口最多 32 个;暂不支持远程项目。 |
|
||||
| `host::open_content_tab(&ContentTab { .. })` | API 1.4:不依赖网页视图的内容编辑器标签页;操作以 `content-tab-action` 事件送达,用 `host::reply_content_tab` 回复。 |
|
||||
| `host::open_diff(&ContentDiff { .. }, file_name)` | API 1.7:在差异查看器中对比两段文本,例如评审中某个文件的修改前后;`file_name` 决定语法高亮。 |
|
||||
| `host::open_file_diff(&diff, file_name)` | API 1.10:同上,参数为 `FileDiff`,某一侧为 `None` 表示该侧文件不存在;新增或删除的文件只显示存在的一侧。 |
|
||||
| `host::output_append(channel, text)` | API 1.4:每个通道一个只读 **输出** 标签页(32 个通道,各 1 MiB);另有 `output_clear`、`output_reveal`。 |
|
||||
|
||||
```rust
|
||||
|
||||
+16
-3
@@ -36,7 +36,7 @@ sdk/rust/openidea-plugin/ # the Rust SDK (host API, Plugin trait, mock host)
|
||||
crates/ide-plugin/tests/fixtures/ # test plugins: hello, jobs, language-toy, misbehave, semantic-tokens, hover, commit, inlay-hints
|
||||
```
|
||||
|
||||
The plugin API is defined in [`wit/`](../wit/) (`openidea:plugin@1.8.0`, world
|
||||
The plugin API is defined in [`wit/`](../wit/) (`openidea:plugin@1.10.0`, world
|
||||
`plugin`).
|
||||
|
||||
## 1. Quick start
|
||||
@@ -421,9 +421,21 @@ are always available. Calling a gated function without its capability returns
|
||||
|
||||
## 3. Writing code (Rust SDK)
|
||||
|
||||
### API 1.10
|
||||
|
||||
API 1.10.0 is in development on `main`. Use `engines.openidea = "^1.10"` and the
|
||||
matching SDK. Released 1.9 plugins keep working. New in 1.10:
|
||||
|
||||
- `host::open_file_diff(&FileDiff { .. }, file_name)` (`views.open-file-diff`) is
|
||||
`open_diff` for a file that doesn't exist on one side: a `None` side (`left` of
|
||||
an added file, `right` of a deleted one) makes the diff viewer show the other
|
||||
side alone, as for the IDE's own added and deleted files, instead of next to an
|
||||
empty text. Both `None` is `Invalid`. Web views send `null` for that side in
|
||||
`{ op: "open-diff", ... }`.
|
||||
|
||||
### API 1.9
|
||||
|
||||
API 1.9.0 is in development on `main`. Use `engines.openidea = "^1.9"` and the
|
||||
API 1.9.0 shipped with OpenIDEA 0.1.46. Use `engines.openidea = "^1.9"` and the
|
||||
matching SDK. Released 1.8 plugins keep working. New in 1.9:
|
||||
|
||||
- The `launch-configurations` export (`LaunchConfigurations`, registration
|
||||
@@ -695,6 +707,7 @@ then run `openidea-plugin check`.
|
||||
| `host::open_content_tab(tab)` | `views.open-content-tab` | API 1.4: the shared content editor protocol, without a web view; actions arrive as `content-tab-action`. |
|
||||
| `host::reply_content_tab(request_id, reply)` | `views.reply-content-tab` | API 1.4: reply to an owned action in the originating window. No capability; commands/events only. |
|
||||
| `host::open_diff(diff, file_name)` | `views.open-diff` | API 1.7: two texts in the invoking window's diff viewer; `file_name` (at most 256 characters) picks the highlighting. Commands/events only; each side at most 8 MiB (earlier hosts: 1 MiB), a larger side fails with `Invalid("diff too large: …")`. |
|
||||
| `host::open_file_diff(diff, file_name)` | `views.open-file-diff` | API 1.10: `open_diff` where a side may be `None` (the file doesn't exist there: added or deleted); the viewer shows the other side alone. Both `None` fails with `Invalid`. |
|
||||
| `RunConfigurations::configurations(root)` | export `run-configurations.configurations` | API 1.4: optional `plugin-run-configurations` world; SDK registration `run_configurations`. Full project list, refreshed on configuration listing. |
|
||||
| `LaunchConfigurations::launch_configurations(root)` | export `launch-configurations` | API 1.9: optional `plugin-launch-configurations` world; SDK registration `launch_configurations`. The same list with `env` and `debugger`; preferred over `run-configurations`. |
|
||||
| `TestResults::parse(config, chunk)` | export `test-results.parse` | API 1.4: optional `plugin-test-results` world; SDK registration `test_results`. Bounded output batches for `framework = "plugin"`; failures use built-in parsers. |
|
||||
@@ -2642,7 +2655,7 @@ the API itself follows _Evolving the plugin API_ below.
|
||||
|
||||
Released versions are frozen: 1.0.0 shipped with OpenIDEA 0.1.36, 1.1.0
|
||||
with 0.1.37, 1.2.0 with 0.1.38, 1.3.0 with 0.1.39 and 1.4.0 with 0.1.40.
|
||||
API 1.5.0 shipped with 0.1.41, 1.6.0 with 0.1.43, 1.7.0 with 0.1.44 and 1.8.0 with 0.1.45; API 1.9.0 is in development on `main`. wasmtime decides what stays compatible: it resolves interface names
|
||||
API 1.5.0 shipped with 0.1.41, 1.6.0 with 0.1.43, 1.7.0 with 0.1.44 and 1.8.0 with 0.1.45 and 1.9.0 with 0.1.46; API 1.10.0 is in development on `main`. wasmtime decides what stays compatible: it resolves interface names
|
||||
by semver (a component importing `openidea:plugin/x@1.0.0` links against a
|
||||
host defining `@1.1.0`, and the host finds its exports the same way), but
|
||||
function types must match exactly — a record with another field count, or a
|
||||
|
||||
BIN
Binary file not shown.
+1
-1
@@ -1 +1 @@
|
||||
4ed77982187f1c454e8567fa3a1a74ba17c5fa24bdc3a14f163df091cad547b1
|
||||
8e875bb7ed12f235be46b32ec1377f251474b0c6b663a066c36fbadc6a7fefb3
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
5083b261592e2969f1eea008420e6397d5dca09f7f51c2a91f65a7762ca63275
|
||||
75b4e1267fbf4a93d62963481021970e3eace3442023182e84cd9357744242c9
|
||||
|
||||
BIN
Binary file not shown.
+1
-1
@@ -1 +1 @@
|
||||
bdd55768110eae5de8ff26b34af194edb4a32a06dfcffe9c222ff579851bf2ad
|
||||
63ad90e231b3cf22ed47710822022f4f80fbdb621b1116998e2599dab7a9b87b
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
ce8a51723724726fbe5b4eb832a152e9519ffb52cbc8ad957d6f2bad23fb58ea
|
||||
bfd7039bb90e1a4352b7961bbbf83e3af276ba86945fbc23bc34cbf1e3b8c272
|
||||
|
||||
BIN
Binary file not shown.
+1
-1
@@ -1 +1 @@
|
||||
8a09e07fa34ca56bcb4b27a883ea58ea6b1a7a5465ac9d57231f9205c5b80be4
|
||||
0ff9eddb3f6fa47c4afd8375471b882cd323631a383a5da97b25271cdd2850a7
|
||||
|
||||
BIN
Binary file not shown.
+1
-1
@@ -1 +1 @@
|
||||
d402a7d7c57362ded611270ae804e2af4480663536feaa33475049d84e563dda
|
||||
471ddce51119b0fd9caa46c24248f368d48beb8953b5ad6253ba0cfc2c5aa141
|
||||
|
||||
BIN
Binary file not shown.
+1
-1
@@ -1 +1 @@
|
||||
51c22339fc7d2f17abc9e019f93f4e19fffd9f6bb91721404f49668ec7818bc1
|
||||
4fc818b0af1abfd9d9d0cdaf4c56cce02cc7e05be501de59b1cbea4672aa91b3
|
||||
|
||||
BIN
Binary file not shown.
+1
-1
@@ -1 +1 @@
|
||||
c8769d91ae5b81446e9f3a4fb7875d0082769c1496703dd60d67a55a1a07e2cd
|
||||
d701b0d87cb4f0ff428bb663cb899c1ad85a3c2f10bc97b97ddbc67cdb88e07b
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
d8f9249fa4c805baa2a8599724651a80448a71d780c6c81ee51cd584adec6b28
|
||||
72e8802492777bf94f686ce6c09a4a24b16d06dfb0802c56e83a2170cf27393a
|
||||
|
||||
BIN
Binary file not shown.
+1
-1
@@ -1 +1 @@
|
||||
f18ba63197e8aa37df249fa05da679543b4978e9284ebae0f1786f16ffaeb02f
|
||||
594995ca3941ed3ec89625e51b43bfa45d4b5b70248c22787ed7a3291ed07678
|
||||
|
||||
BIN
Binary file not shown.
+1
-1
@@ -1 +1 @@
|
||||
33eb1da1fca89e4aa673dd330dd508b88e7994daab0cd3ab6ff9420cdc75c4a8
|
||||
2caaf82921e6b942ad043e91e02a8fa59c59ec497bb5d2c84b2f6c156b134e69
|
||||
|
||||
BIN
Binary file not shown.
+1
-1
@@ -1 +1 @@
|
||||
fbc688bb595055bc4cc7aa2f9e70526a52f53083650c51e17d44090ea6f1594e
|
||||
9d4fbc2a435f718863198609928018e0120abfbbd62937cfe8da4c861839ce0d
|
||||
|
||||
BIN
Binary file not shown.
+1
-1
@@ -1 +1 @@
|
||||
4da47cebf0815b7ca417e4d63da0413c4eb4bf4eab012f8cac05649619c2c4fe
|
||||
71b7187c3187e932d5416dd7acff60d60470015ee74b3be9f8d5d5e1469e01d8
|
||||
|
||||
BIN
Binary file not shown.
+1
-1
@@ -1 +1 @@
|
||||
ae0baafe6f1f96fe2895c16856e524daff6e99f660ed02c84d01d3de404be06c
|
||||
de457dec1dca333f217ea499c92eba4d23c0a72729b22de4106cec513396bd96
|
||||
|
||||
BIN
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user