refactor(plugins): name the services pane export detail-provider (#1972)

Renamed before API 1.3 ships, so tree and list views outside Services can reuse the pane (#1950); behaviour unchanged.
Цей коміт міститься в:
l0ng-ai authored and GitHub committed 2026-11-07 19:06:42 +08:00
1 джерело b23b95ec00
коміт 7a9c72ca24
50 files changed
+82 -82

No files matched your search

+1 -1
Переглянути файл
@@ -60,7 +60,7 @@ use std::collections::BTreeSet;
use std::path::PathBuf;
/// A view whose tree shows in the Services tool window; the plugin's
/// `service-provider` renders the selected node's pane.
/// `detail-provider` renders the selected node's pane.
pub const SERVICES_LOCATION: &str = "services";
pub const MENUS: &str = "menus";
pub const KEYMAPS: &str = "keymaps";
+16 -16
Переглянути файл
@@ -16,8 +16,8 @@ use crate::types::{
ViewField, ViewListItem, ViewTable, ViewTreeItem, Viewport,
};
use crate::wit_host::{
bindings, commit_checks_bindings, hover_bindings, indexing_bindings, providers_bindings, semantic_bindings,
services_bindings, syntax_bindings, views_bindings,
bindings, commit_checks_bindings, details_bindings, hover_bindings, indexing_bindings, providers_bindings,
semantic_bindings, syntax_bindings, views_bindings,
};
use ide_core::CancellationToken;
use ide_core::ipc_path::to_ipc;
@@ -35,12 +35,12 @@ use wasmtime_wasi::{WasiCtx, WasiCtxView, WasiView};
use bindings::openidea::plugin::events as wit_events;
use bindings::openidea::plugin::types as wit_types;
use commit_checks_bindings::exports::openidea::plugin::commit_checker as wit_cc;
use details_bindings::exports::openidea::plugin::detail_provider as wit_detail;
use details_bindings::openidea::plugin::detail_types as wit_dt;
use hover_bindings::exports::openidea::plugin::hover_provider as wit_hover;
use indexing_bindings::exports::openidea::plugin::document_indexer as wit_index;
use providers_bindings::exports::openidea::plugin::providers as wit_prov;
use semantic_bindings::exports::openidea::plugin::semantic_tokens_provider as wit_sem;
use services_bindings::exports::openidea::plugin::service_provider as wit_svc;
use services_bindings::openidea::plugin::service_types as wit_st;
use syntax_bindings::exports::openidea::plugin::syntax_provider as wit_syntax;
use views_bindings::exports::openidea::plugin::view_provider as wit_view;
use views_bindings::openidea::plugin::view_types as wit_vt;
@@ -542,7 +542,7 @@ struct Exports {
indexer: Option<wit_index::Guest>,
views: Option<wit_view::Guest>,
semantic: Option<wit_sem::Guest>,
services: Option<wit_svc::Guest>,
details: Option<wit_detail::Guest>,
hover: Option<wit_hover::Guest>,
commit_checks: Option<wit_cc::Guest>,
}
@@ -625,7 +625,7 @@ impl Runtime {
let provider_indices = wit_prov::GuestIndices::new(&pre).ok();
let view_indices = wit_view::GuestIndices::new(&pre).ok();
let semantic_indices = wit_sem::GuestIndices::new(&pre).ok();
let service_indices = wit_svc::GuestIndices::new(&pre).ok();
let detail_indices = wit_detail::GuestIndices::new(&pre).ok();
let hover_indices = wit_hover::GuestIndices::new(&pre).ok();
let commit_check_indices = wit_cc::GuestIndices::new(&pre).ok();
let instance = pre.instantiate(&mut store).map_err(api_hint)?;
@@ -650,7 +650,7 @@ impl Runtime {
Some(indices) => Some(indices.load(&mut store, &instance).map_err(api_hint)?),
None => None,
};
let services = match service_indices {
let details = match detail_indices {
Some(indices) => Some(indices.load(&mut store, &instance).map_err(api_hint)?),
None => None,
};
@@ -664,7 +664,7 @@ impl Runtime {
};
Ok(Self {
store,
exports: Exports { plugin, syntax, providers, views, indexer, semantic, services, hover, commit_checks },
exports: Exports { plugin, syntax, providers, views, indexer, semantic, details, hover, commit_checks },
limits: setup.limits,
version: setup.version,
})
@@ -1017,13 +1017,13 @@ impl Runtime {
key: &str,
invocation: Invocation,
) -> Result<Vec<ServiceTab>, CallError> {
if self.exports.services.is_none() {
return Err(CallError::missing_export("service-provider"));
if self.exports.details.is_none() {
return Err(CallError::missing_export("detail-provider"));
}
let result = self.call(invocation, self.limits.timeout, |e, store| {
let ctx = store.data_mut().new_invocation()?;
let services = e.services.as_ref().expect("checked");
let r = services.call_detail(&mut *store, view, key, wasmtime::component::Resource::new_borrow(ctx.rep()));
let details = e.details.as_ref().expect("checked");
let r = details.call_detail(&mut *store, view, key, wasmtime::component::Resource::new_borrow(ctx.rep()));
store.data_mut().drop_invocation(ctx);
r
})?;
@@ -1270,11 +1270,11 @@ const MAX_LOG_TOGGLES: usize = 8;
const MAX_LOG_ARGS: usize = 256;
const MAX_LOG_ARG: usize = 4096;
fn service_tab_from_wit(t: wit_st::Tab) -> ServiceTab {
fn service_tab_from_wit(t: wit_dt::Tab) -> ServiceTab {
let body = match t.body {
wit_st::Pane::Message(m) => ServicePane::Message(clip(m, 16 << 10)),
wit_st::Pane::Text(text) => ServicePane::Text(clip(text, MAX_TEXT)),
wit_st::Pane::Log(log) => {
wit_dt::Pane::Message(m) => ServicePane::Message(clip(m, 16 << 10)),
wit_dt::Pane::Text(text) => ServicePane::Text(clip(text, MAX_TEXT)),
wit_dt::Pane::Log(log) => {
let args_fit = |args: &[String]| args.len() <= MAX_LOG_ARGS && args.iter().all(|a| a.len() <= MAX_LOG_ARG);
if args_fit(&log.args)
&& log.toggles.len() <= MAX_LOG_TOGGLES
+1 -1
Переглянути файл
@@ -545,7 +545,7 @@ pub struct View {
pub status: Option<String>,
}
/// A tab of the Services pane of a plugin's node (`service-provider.detail`).
/// A tab of the Services pane of a plugin's node (`detail-provider.detail`).
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)]
#[serde(rename_all = "camelCase")]
pub struct ServiceTab {
+3 -3
Переглянути файл
@@ -928,10 +928,10 @@ pub(crate) mod indexing_bindings {
});
}
/// The optional `service-provider` export.
pub(crate) mod services_bindings {
/// The optional `detail-provider` export.
pub(crate) mod details_bindings {
wasmtime::component::bindgen!({
world: "services", path: "../../wit",
world: "details", path: "../../wit",
with: {
"openidea:plugin/types": super::bindings::openidea::plugin::types,
"openidea:plugin/workspace": super::bindings::openidea::plugin::workspace,
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
83a1e3f362740752ed69c53da29ff950cf9c9de18125af6c98995ea490b31690
09a64c18ef137348f70121c088419040ee606089d9f27b0dbe63256d5de49cd6
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
a9f1e2ec87de32ef241fcb559d157cd05800dcf106ab27e906ba36468c0b39e5
8eba458c25d7722ffc1d396812bd83114a67c1176b9dd6fa3bfbbf02c0ca0976
+3 -3
Переглянути файл
@@ -1,7 +1,7 @@
//! Sample OpenIDEA plugin, written with the `openidea-plugin` SDK.
//! Build with `openidea-plugin build crates/ide-plugin/tests/fixtures/hello` (see plugins/README.md).
use openidea_plugin::services::{Pane, ProcessLog, Services, Tab};
use openidea_plugin::details::{Details, Pane, ProcessLog, Tab};
use openidea_plugin::views::{Body, Button, TreeItem, View, ViewEvent, Viewport, Views};
use openidea_plugin::{Context, Error, Invocation, LogLevel, NotificationLevel, Plugin, host, register_plugin};
use std::collections::BTreeSet;
@@ -98,14 +98,14 @@ impl Views for Hello {
}
/// As a services view (tests): a node's key is the `sh -c` script its Log tab runs.
impl Services for Hello {
impl Details for Hello {
fn detail(&mut self, view: &str, key: &str, _ctx: &Invocation) -> Result<Vec<Tab>, Error> {
let log = ProcessLog::new("sh", &["-c", key]).toggle("named", "Named", &["named"]);
Ok(vec![Tab::new("log", "Log", log), Tab::new("info", "Info", Pane::Text(format!("{view}: {key}")))])
}
}
register_plugin!(Hello, views, services);
register_plugin!(Hello, views, details);
/// Today's UTC date as `YYYY-MM-DD` (WASI wall clock).
fn today() -> String {
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
d065af9f54b5bd1ec2fbc31250c87153a55501a4e8bf4002fcc04c67c2d1e03e
5f7112055543becca6fc9ad9a33850c355efe38b3ab019ecb4fb26346f3ac9b5
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
dd57b09293deb0fdc3201978e350c118f428429df4beccc4f23665be0335a795
1f571177a22c2f07055b38385c0e5f44c063c520b9e1d7be3d528e4cfb3b8b43
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
436516e5f17a11f5a1225b854ab9fef703172a47d33bf3d840c721ad6d373e62
165f1dc7ebf47b3910fd8e23eb72cecfe47156c3498d2b06f5d6c39ecd299e2a
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
4e8118c9f4974385421d1e2ca0106fd658ad85124e1453c4114f60a164f72f68
5be61cbf46d28a7d06c73fb2562e81f3d1a86e16c5c6389d402cbeaf703e331a
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
b77e7e3d163995f0a9a3f3cb49dc6c4ea04b2eaa0a8b74b46c64e83908bae504
81db471a9be4aefb97d21c3937bc0afd637114cc2703fa2cc815b0ae61608467
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
9f2195fb83f16221e98313c095d57c293e79041ed8ae439fe2fb4f008a3a0921
cbb5a54e287ef3ed11391985c286e5d4e24646f2fd84b8b969fe825bbd44c350
+4 -4
Переглянути файл
@@ -629,13 +629,13 @@ optional = ["process:kubectl"]
The items of the view's `tree` are Services nodes: `render`, `handle` and the
toolbar work as in a tool window, the toolbar's buttons acting on the one
selected node, and `viewItem.context` menus give the nodes a right-click menu.
The pane beside the tree comes from the `service-provider` export: register
`register_plugin!(MyPlugin, views, services)` and implement
`openidea_plugin::services::Services`, which returns the selected node's tabs
The pane beside the tree comes from the `detail-provider` export: register
`register_plugin!(MyPlugin, views, details)` and implement
`openidea_plugin::details::Details`, which returns the selected node's tabs
(at most 8; asked again after `host::refresh_view("kube")`):
```rust
impl Services for MyPlugin {
impl Details for MyPlugin {
fn detail(&mut self, view: &str, key: &str, _ctx: &Invocation) -> Result<Vec<Tab>, Error> {
let pod = key.trim_start_matches("pod:");
let log = ProcessLog::new("kubectl", &["logs", "-f", "--tail=1000", pod])
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
a5cba00850ccde12896ed7a69ae336a1968e024e8f5fefb6a49f2adea10569e4
2e34ee9cb774344d4dedf1ec077d776a051abd08e435f6df3dca6c7d12fa94fb
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
27d61fcc109561aeea56f3a37da0aba7b6c56fdf01ff918f2e62d5732832ba3d
8ee84d6a4a835ec7104877fa105e593b47e8091339b3419690b018f3e8877b94
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
c86fae61f88b6903354b1fb706b0718f9036f82085653481d77ddc3f622b3a73
2af4ae2589bebf9703afa6b7b24bc073334344e6836b0ea29aab259338b38762
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
b4d059850083339f826223700eda7df0c8b655a40e4832d3acda36dc0f76db9a
a7d656941097113fdde3e64a07446d1780f045702a935a5e5153ac1f540d6b06
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
b2977b3b82ad26126125c614281cbbf888bb8151ece9a43fbaa5459c7a8b97cc
3f6549848f81cc999a42ba0fa04e0efb43640e09a67ab28d799d4f79832f6178
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
9f59f59b999475a8c4c626f1cfc3c77ef1b3c0684f0cbf9af148556c8f9d30c0
31ff37106dc0829e226de01b5148f6ee67b1d776acd6def4729edf4c63946219
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
0f175352e4fcfe3b07359afb7f4a20348a488a21012e89775c628d19277d8c8c
eb4d09a79172cb46857c7bb3e50e7fbd6f4b6be379bb1c79a41ea23a5643f875
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
d7e9b2801ca70df9a84ec458f0fc5c6b01b7d03c056807c53268e40ecbbb9d1a
4f2e5d5c877554b111bb454603d002e50bbafb3dca3cca5768c052fbc48f73ab
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
50524b5be85f6bc040521f97adba6030263045dcacfeae8dbcf73ce7234e2616
0cae1d9dd2075b1a107d894854f0d01ab81331b67793f2ad972835a8ab34d3a0
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
0c44311a5f9ddb1893be7c82d818297a05b15576d996a33ddc2389f9432c416c
13e34d174abf5187bf7c191736974305afb0af257fc103eec96fe8fa8edb8c88
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
3e4e23976ce0ddb1e83813269eefc24008521cdf22757e6b5249f6f219f344d2
7e010175c19a159a22c42a76ca07ebc663a27ce9143c21e742ca99435a538f83
+3 -3
Переглянути файл
@@ -1,7 +1,7 @@
//! The pane beside the Services tree for the nodes of the plugin's
//! `location = "services"` views (world `plugin-services`). The nodes, the
//! `location = "services"` views (world `plugin-details`). The nodes, the
//! toolbar and their events come from [`crate::views::Views`] as in any view;
//! register both: `register_plugin!(MyPlugin, views, services)`.
//! register both: `register_plugin!(MyPlugin, views, details)`.
use crate::{Error, Invocation};
@@ -65,7 +65,7 @@ impl Tab {
}
/// The detail pane of the nodes of the plugin's services views.
pub trait Services {
pub trait Details {
/// The tabs of node `key` of view `view` (at most 8), asked when the node is
/// selected and again after [`crate::host::refresh_view`] of the view.
fn detail(&mut self, view: &str, key: &str, ctx: &Invocation) -> Result<Vec<Tab>, Error>;
+16 -16
Переглянути файл
@@ -40,6 +40,7 @@
//! wasm32-wasip2`); see `plugins/README.md`.
pub mod commit;
pub mod details;
pub mod host;
pub mod hover;
pub mod indexing;
@@ -47,7 +48,6 @@ pub mod indexing;
pub mod mock;
pub mod providers;
pub mod semantic_tokens;
pub mod services;
pub mod syntax;
pub mod text;
mod types;
@@ -132,11 +132,11 @@ pub mod indexing_bindings {
#[cfg(target_arch = "wasm32")]
#[doc(hidden)]
pub mod services_bindings {
pub mod details_bindings {
wit_bindgen::generate!({
world: "services", path: "wit", pub_export_macro: true,
export_macro_name: "__export_services_world",
default_bindings_module: "openidea_plugin::services_bindings",
world: "details", path: "wit", pub_export_macro: true,
export_macro_name: "__export_details_world",
default_bindings_module: "openidea_plugin::details_bindings",
with: {
"openidea:plugin/[email protected]": crate::bindings::openidea::plugin::types,
"openidea:plugin/[email protected]": crate::bindings::openidea::plugin::workspace,
@@ -242,8 +242,8 @@ macro_rules! __optional_exports {
(semantic_tokens, $plugin:ty, $component:ident) => {
$crate::__semantic_tokens_exports!($plugin, $component);
};
(services, $plugin:ty, $component:ident) => {
$crate::__services_exports!($plugin, $component);
(details, $plugin:ty, $component:ident) => {
$crate::__details_exports!($plugin, $component);
};
(hover, $plugin:ty, $component:ident) => {
$crate::__hover_exports!($plugin, $component);
@@ -382,24 +382,24 @@ macro_rules! __indexing_exports {
};
}
/// `register_plugin!(T, services)`: `T` is also a [`services::Services`].
/// `register_plugin!(T, details)`: `T` is also a [`details::Details`].
#[doc(hidden)]
#[macro_export]
macro_rules! __services_exports {
macro_rules! __details_exports {
($plugin:ty, $component:ident) => {
impl $crate::services_bindings::exports::openidea::plugin::service_provider::Guest for $component {
impl $crate::details_bindings::exports::openidea::plugin::detail_provider::Guest for $component {
fn detail(
view: ::std::string::String,
key: ::std::string::String,
ctx: &$crate::bindings::openidea::plugin::invocation::Invocation,
) -> ::core::result::Result<
::std::vec::Vec<$crate::services_bindings::openidea::plugin::service_types::Tab>,
::std::vec::Vec<$crate::details_bindings::openidea::plugin::detail_types::Tab>,
$crate::bindings::openidea::plugin::types::Error,
> {
$crate::__rt::service_detail::<$plugin>(view, key, ctx)
}
}
$crate::services_bindings::__export_services_world!($component with_types_in $crate::services_bindings);
$crate::details_bindings::__export_details_world!($component with_types_in $crate::details_bindings);
};
}
@@ -811,13 +811,13 @@ pub mod __rt {
with::<T, _>(|p| p.render(&view, viewport, &ctx)).map(view_out).map_err(error_out)
}
pub fn service_detail<T: Plugin + crate::services::Services + Default>(
pub fn service_detail<T: Plugin + crate::details::Details + Default>(
view: String,
key: String,
ctx: &b::invocation::Invocation,
) -> Result<Vec<crate::services_bindings::openidea::plugin::service_types::Tab>, b::types::Error> {
use crate::services as s;
use crate::services_bindings::openidea::plugin::service_types as w;
) -> Result<Vec<crate::details_bindings::openidea::plugin::detail_types::Tab>, b::types::Error> {
use crate::details as s;
use crate::details_bindings::openidea::plugin::detail_types as w;
let ctx = Invocation::__new(ctx);
let tab = |t: s::Tab| w::Tab {
id: t.id,
+3 -3
Переглянути файл
@@ -1,7 +1,7 @@
package openidea:[email protected];
/// What the pane beside the Services tree shows for a plugin's node.
interface service-types {
interface detail-types {
/// A switch above a log; when on, `args` are appended and the program
/// starts again.
record log-toggle {
@@ -39,10 +39,10 @@ interface service-types {
/// The detail pane of the nodes of a plugin's `location = "services"` views.
/// The nodes themselves, the toolbar and their events come from
/// `view-provider` (`render` / `handle` of the view).
interface service-provider {
interface detail-provider {
use types.{error};
use invocation.{invocation};
use service-types.{tab};
use detail-types.{tab};
/// The tabs of node `key` of view `view` (at most 8), rendered when the
/// node is selected and again after `views.refresh(view)`.
+5 -5
Переглянути файл
@@ -69,9 +69,9 @@ world plugin-hover {
/// A plugin whose views show in the Services tool window
/// (`location = "services"`): their nodes' detail pane.
world plugin-services {
world plugin-details {
include plugin;
export service-provider;
export detail-provider;
}
/// A plugin with before-commit checks (`[[contributes.commitChecks]]`).
@@ -109,9 +109,9 @@ world hover {
export hover-provider;
}
/// Only the `service-provider` export, generated next to `plugin` like `syntax`.
world services {
export service-provider;
/// Only the `detail-provider` export, generated next to `plugin` like `syntax`.
world details {
export detail-provider;
}
/// Only the `commit-checker` export, generated next to `plugin` like `syntax`.
+3 -3
Переглянути файл
@@ -1,7 +1,7 @@
package openidea:[email protected];
/// What the pane beside the Services tree shows for a plugin's node.
interface service-types {
interface detail-types {
/// A switch above a log; when on, `args` are appended and the program
/// starts again.
record log-toggle {
@@ -39,10 +39,10 @@ interface service-types {
/// The detail pane of the nodes of a plugin's `location = "services"` views.
/// The nodes themselves, the toolbar and their events come from
/// `view-provider` (`render` / `handle` of the view).
interface service-provider {
interface detail-provider {
use types.{error};
use invocation.{invocation};
use service-types.{tab};
use detail-types.{tab};
/// The tabs of node `key` of view `view` (at most 8), rendered when the
/// node is selected and again after `views.refresh(view)`.
+5 -5
Переглянути файл
@@ -69,9 +69,9 @@ world plugin-hover {
/// A plugin whose views show in the Services tool window
/// (`location = "services"`): their nodes' detail pane.
world plugin-services {
world plugin-details {
include plugin;
export service-provider;
export detail-provider;
}
/// A plugin with before-commit checks (`[[contributes.commitChecks]]`).
@@ -109,9 +109,9 @@ world hover {
export hover-provider;
}
/// Only the `service-provider` export, generated next to `plugin` like `syntax`.
world services {
export service-provider;
/// Only the `detail-provider` export, generated next to `plugin` like `syntax`.
world details {
export detail-provider;
}
/// Only the `commit-checker` export, generated next to `plugin` like `syntax`.