diff --git a/crates/ide-extension/src/manifest.rs b/crates/ide-extension/src/manifest.rs index 47e17c0c5..7c0900028 100644 --- a/crates/ide-extension/src/manifest.rs +++ b/crates/ide-extension/src/manifest.rs @@ -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.13.0"; +pub const ENGINE_VERSION: &str = "1.14.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. diff --git a/crates/ide-host/src/ops/lsp.rs b/crates/ide-host/src/ops/lsp.rs index d0533f590..9566c3099 100644 --- a/crates/ide-host/src/ops/lsp.rs +++ b/crates/ide-host/src/ops/lsp.rs @@ -1976,6 +1976,7 @@ pub struct PluginLanguageVisuals { pub injections: Vec, pub colors: Vec<(String, ide_plugin::language_features::ColorInfo)>, pub gutter_actions: Vec<(String, ide_plugin::language_features::GutterAction)>, + pub hover_actions: Vec<(String, ide_plugin::language_features::HoverAction)>, } #[command(trust = trusted)] pub async fn plugin_language_visuals(host: &Host, window: &str, doc: DocId) -> IdeResult { @@ -1989,14 +1990,20 @@ pub async fn plugin_language_visuals(host: &Host, window: &str, doc: DocId) -> I version: u64::from(snap.version), text: snap.text, }; - let mut out = - PluginLanguageVisuals { version: d.version, injections: vec![], colors: vec![], gutter_actions: vec![] }; + let mut out = PluginLanguageVisuals { + version: d.version, + injections: vec![], + colors: vec![], + gutter_actions: vec![], + hover_actions: vec![], + }; if d.text.len() <= crate::plugins::navigation::MAX_DOCUMENT_BYTES && let Some(plugins) = crate::plugins::editor_plugin_host() { out.injections = plugins.provide_injections(&d); out.colors = plugins.language_colors(&d); out.gutter_actions = plugins.language_gutter_actions(&d); + out.hover_actions = plugins.language_hover_actions(&d); } project.lsp.set_injections_at( doc, diff --git a/crates/ide-host/src/plugins/language_features.rs b/crates/ide-host/src/plugins/language_features.rs index 5f42e190e..36b5cf2c5 100644 --- a/crates/ide-host/src/plugins/language_features.rs +++ b/crates/ide-host/src/plugins/language_features.rs @@ -276,6 +276,34 @@ impl PluginHost { } out } + /// Optional API 1.14 hover actions. Only plugins declaring the + /// `hover-actions` provider kind are asked; the released language-features + /// export remains unchanged. + pub fn language_hover_actions(&self, doc: &ProviderDocument) -> Vec<(String, HoverAction)> { + let mut out = Vec::new(); + for (d, _bounds) in self.feature_documents(doc, None) { + let snapshot = d.clone(); + let text = ide_text::Document::new(&snapshot.text); + let d = Arc::new(d); + let results = self + .document_calls(ProviderKind::HoverActions, &snapshot, move |rt, t| rt.language_hover_actions(&d, t)); + for (p, items) in results { + let commands: std::collections::HashSet<_> = + self.ui.items(super::COMMANDS, Some(p.id())).into_iter().map(|c| c.key).collect(); + for i in items { + let lines = text.line_count(); + let anchor_ok = i.line < lines; + let range_ok = i.start_line <= i.end_line && i.end_line < lines; + let contains_anchor = i.start_line <= i.line && i.line <= i.end_line; + if anchor_ok && range_ok && contains_anchor && commands.contains(&i.command) { + out.push((p.id().to_owned(), i)); + } + } + } + } + out + } + pub fn language_gutter_actions(&self, doc: &ProviderDocument) -> Vec<(String, GutterAction)> { let mut out = Vec::new(); for (d, bounds) in self.feature_documents(doc, None) { diff --git a/crates/ide-host/src/plugins/providers.rs b/crates/ide-host/src/plugins/providers.rs index 9cc38128a..392f49203 100644 --- a/crates/ide-host/src/plugins/providers.rs +++ b/crates/ide-host/src/plugins/providers.rs @@ -54,6 +54,7 @@ pub enum ProviderKind { Implementation, TypeDefinition, GutterActions, + HoverActions, Injections, } @@ -204,11 +205,15 @@ impl ExtensionPoint for ProvidersPoint { | ProviderKind::Implementation | ProviderKind::TypeDefinition | ProviderKind::GutterActions + | ProviderKind::HoverActions | ProviderKind::Injections ) }) { pkg.manifest.needs_api("contributes.providers: language features and injections", 4)?; } + if d.kinds.contains(&ProviderKind::HoverActions) { + pkg.manifest.needs_api("contributes.providers: hover-actions", 14)?; + } for l in &d.languages { if l != "*" && (l.is_empty() diff --git a/crates/ide-host/tests/plugin_language_features.rs b/crates/ide-host/tests/plugin_language_features.rs index 6283ef5db..ccb6346ef 100644 --- a/crates/ide-host/tests/plugin_language_features.rs +++ b/crates/ide-host/tests/plugin_language_features.rs @@ -152,6 +152,9 @@ async fn editor_ops_merge_the_fixture_format_selection_and_execute_owned_command let visuals = ops::lsp::plugin_language_visuals(&host, "main", doc.id).await.unwrap(); assert_eq!(visuals.colors.len(), 1); assert_eq!(visuals.gutter_actions.len(), 1); + assert_eq!(visuals.hover_actions.len(), 1); + assert_eq!(visuals.hover_actions[0].1.command, "run"); + assert_eq!(visuals.hover_actions[0].1.end_line, 2); assert_eq!( ops::lsp::plugin_color_presentations(&host, "main", doc.id, ID.into(), visuals.colors[0].1.clone()) .await diff --git a/crates/ide-plugin/src/language_features.rs b/crates/ide-plugin/src/language_features.rs index 7530054d8..e13ac00fd 100644 --- a/crates/ide-plugin/src/language_features.rs +++ b/crates/ide-plugin/src/language_features.rs @@ -100,6 +100,22 @@ pub struct GutterAction { pub command: String, pub argument: Option, } +/// An action rendered at the left edge of a line and revealed by hover. +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] +#[serde(rename_all = "camelCase")] +pub struct HoverAction { + /// The line the button is drawn on; normally the declaration line. + pub line: u32, + /// First line whose leftmost strip reveals this action, inclusive. + pub start_line: u32, + /// Last line whose leftmost strip reveals this action, inclusive. + pub end_line: u32, + pub icon: Option, + pub label: String, + pub tooltip: Option, + pub command: String, + pub argument: Option, +} /// Injection data. #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] diff --git a/crates/ide-plugin/src/runtime.rs b/crates/ide-plugin/src/runtime.rs index 65557ab88..449e992eb 100644 --- a/crates/ide-plugin/src/runtime.rs +++ b/crates/ide-plugin/src/runtime.rs @@ -16,6 +16,7 @@ use crate::types::{ FieldValue, ServiceLog, ServiceLogToggle, ServicePane, ServiceTab, TableSort, View, ViewBody, ViewButton, ViewEvent, ViewField, ViewListItem, ViewTable, ViewTreeItem, Viewport, }; +use crate::wit_host::hover_actions_bindings::exports::openidea::plugin::hover_actions as wit_hia; use crate::wit_host::injections_bindings::exports::openidea::plugin::injections as wit_inj; use crate::wit_host::language_features_bindings::exports::openidea::plugin::language_features as wit_lf; use crate::wit_host::run_target_validation_bindings::exports::openidea::plugin::run_target_validation as wit_rtv; @@ -57,7 +58,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.13"; +pub const API_VERSION: &str = "1.14"; const EPOCH_TICK: Duration = Duration::from_millis(10); pub(crate) const MAX_TEXT: usize = 1 << 20; /// The most text, and the most PNG bytes, `ui.read-clipboard` returns. @@ -1049,6 +1050,7 @@ struct Exports { inlay: Option, endpoints: Option, search: Option, + hover_actions: Option, run_configurations: Option, launch_configurations: Option, test_results: Option, @@ -1190,6 +1192,7 @@ impl Runtime { let inlay_indices = wit_inlay::GuestIndices::new(&pre).ok(); let endpoint_indices = wit_endpoints::GuestIndices::new(&pre).ok(); let search_indices = wit_search::GuestIndices::new(&pre).ok(); + let hover_actions_indices = wit_hia::GuestIndices::new(&pre).ok(); let configs_indices = wit_configs::GuestIndices::new(&pre).ok(); let launch_indices = wit_launch::GuestIndices::new(&pre).ok(); let tests_indices = wit_tests::GuestIndices::new(&pre).ok(); @@ -1255,6 +1258,8 @@ impl Runtime { None => None, }; let search = search_indices.map(|i| i.load(&mut store, &instance)).transpose().map_err(api_hint)?; + let hover_actions = + hover_actions_indices.map(|i| i.load(&mut store, &instance)).transpose().map_err(api_hint)?; let endpoints = match endpoint_indices { Some(indices) => Some(indices.load(&mut store, &instance).map_err(api_hint)?), None => None, @@ -1278,6 +1283,7 @@ impl Runtime { inlay, endpoints, search, + hover_actions, run_configurations, launch_configurations, test_results, @@ -2616,6 +2622,19 @@ fn gutter_action_from(v: wit_lf::GutterAction) -> crate::language_features::Gutt argument: v.argument.map(|v| crate::runtime::clip(v, 65536)), } } +fn hover_action_from(v: wit_hia::HoverAction) -> crate::language_features::HoverAction { + crate::language_features::HoverAction { + line: v.line, + start_line: v.start_line, + end_line: v.end_line, + icon: v.icon.map(|v| crate::runtime::clip(v, 65536)), + label: crate::runtime::clip(v.label, 65536), + tooltip: v.tooltip.map(|v| crate::runtime::clip(v, 65536)), + command: crate::runtime::clip(v.command, 65536), + argument: v.argument.map(|v| crate::runtime::clip(v, 65536)), + } +} + fn parameter_label_from(v: wit_lf::ParameterLabel) -> crate::language_features::ParameterLabel { use crate::language_features::ParameterLabel as P; match v { @@ -2844,6 +2863,30 @@ impl Runtime { let result = self.language_feature_call(timeout, |p, s| p.call_gutter_actions(s, &d))?; Ok(result.into_iter().take(10000).map(gutter_action_from).collect()) } + pub fn has_hover_actions(&self) -> bool { + self.exports.hover_actions.is_some() + } + + pub fn language_hover_actions( + &mut self, + doc: &ProviderDocument, + timeout: Duration, + ) -> Result, CallError> { + if self.exports.hover_actions.is_none() { + return Err(CallError::missing_export("hover-actions")); + } + let d = wit_hia::Document { + path: to_ipc(&doc.path), + language: doc.language.clone(), + version: doc.version, + text: doc.text.clone(), + }; + let result = self.call(Invocation::default(), timeout, |exports, store| { + exports.hover_actions.as_ref().expect("checked").call_hover_actions(store, &d) + })?; + Ok(result.into_iter().take(10_000).map(hover_action_from).collect()) + } + pub fn provide_injections( &mut self, doc: &ProviderDocument, diff --git a/crates/ide-plugin/src/wit_host.rs b/crates/ide-plugin/src/wit_host.rs index d28fa49b8..f5fbfb4cc 100644 --- a/crates/ide-plugin/src/wit_host.rs +++ b/crates/ide-plugin/src/wit_host.rs @@ -72,6 +72,46 @@ pub(crate) mod syntax_bindings { }); } +/// The optional `hover-actions` export, bound on its own when present. +pub(crate) mod hover_actions_bindings { + wasmtime::component::bindgen!({ + world: "plugin-hover-actions", + path: "../../wit", + imports: { default: trappable }, + with: { + "openidea:plugin/types": super::bindings::openidea::plugin::types, + "openidea:plugin/log": super::bindings::openidea::plugin::log, + "openidea:plugin/ui": super::bindings::openidea::plugin::ui, + "openidea:plugin/storage": super::bindings::openidea::plugin::storage, + "openidea:plugin/workspace": super::bindings::openidea::plugin::workspace, + "openidea:plugin/editor": super::bindings::openidea::plugin::editor, + "openidea:plugin/decorations": super::bindings::openidea::plugin::decorations, + "openidea:plugin/invocation": super::bindings::openidea::plugin::invocation, + "openidea:plugin/vcs": super::bindings::openidea::plugin::vcs, + "openidea:plugin/build": super::bindings::openidea::plugin::build, + "openidea:plugin/commit": super::bindings::openidea::plugin::commit, + "openidea:plugin/events": super::bindings::openidea::plugin::events, + "openidea:plugin/tasks": super::bindings::openidea::plugin::tasks, + "openidea:plugin/diagnostics": super::bindings::openidea::plugin::diagnostics, + "openidea:plugin/net": super::bindings::openidea::plugin::net, + "openidea:plugin/secrets": super::bindings::openidea::plugin::secrets, + "openidea:plugin/run": super::bindings::openidea::plugin::run, + "openidea:plugin/process": super::bindings::openidea::plugin::process, + "openidea:plugin/output": super::bindings::openidea::plugin::output, + "openidea:plugin/auth": super::bindings::openidea::plugin::auth, + "openidea:plugin/command-runner": super::bindings::openidea::plugin::command_runner, + "openidea:plugin/language-servers": super::bindings::openidea::plugin::language_servers, + "openidea:plugin/ipc": super::bindings::openidea::plugin::ipc, + "openidea:plugin/fs": super::bindings::openidea::plugin::fs, + "openidea:plugin/views": super::bindings::openidea::plugin::views, + "openidea:plugin/settings": super::bindings::openidea::plugin::settings, + "openidea:plugin/database": super::bindings::openidea::plugin::database, + "openidea:plugin/mcp": super::bindings::openidea::plugin::mcp, + "openidea:plugin/extensions": super::bindings::openidea::plugin::extensions, + }, + }); +} + /// The optional `providers` export. pub(crate) mod providers_bindings { wasmtime::component::bindgen!({ diff --git a/crates/ide-plugin/tests/api_compat.rs b/crates/ide-plugin/tests/api_compat.rs index 884625965..46993b6b9 100644 --- a/crates/ide-plugin/tests/api_compat.rs +++ b/crates/ide-plugin/tests/api_compat.rs @@ -33,6 +33,7 @@ fn components() -> Vec { repo().join("crates/ide-plugin/tests/fixtures/diagnostics/dist/plugin.wasm"), repo().join("crates/ide-plugin/tests/fixtures/inlay-hints/dist/plugin.wasm"), repo().join("crates/ide-plugin/tests/fixtures/language-features/dist/plugin.wasm"), + repo().join("crates/ide-plugin/tests/fixtures/hover-actions/dist/plugin.wasm"), repo().join("crates/ide-plugin/tests/fixtures/symbols/dist/plugin.wasm"), repo().join("crates/ide-plugin/tests/fixtures/api14/dist/plugin.wasm"), repo().join("crates/ide-plugin/tests/fixtures/execution/dist/plugin.wasm"), @@ -92,7 +93,7 @@ fn the_sdk_carries_the_hosts_wit() { #[test] fn the_version_check_runs_compatible_components_and_explains_the_rest() { - let host = v("1.13.0"); + let host = v("1.14.0"); for ok in [ "1.0.0", "1.3.0", @@ -106,15 +107,16 @@ fn the_version_check_runs_compatible_components_and_explains_the_rest() { "1.11.0", "1.12.0", "1.13.0", + "1.14.0", "1.0.0-rc.1", ] { assert_eq!(check_api(&v(ok), &host), Ok(()), "{ok}"); } - let newer = check_api(&v("1.14.0"), &host).unwrap_err(); - assert!(newer.contains("1.13") && newer.contains("update OpenIDEA"), "{newer}"); + let newer = check_api(&v("1.15.0"), &host).unwrap_err(); + assert!(newer.contains("1.15") && 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.13 SDK"), "{older}"); + assert!(older.contains("rebuild it with the 1.14 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()); @@ -141,6 +143,21 @@ fn shipped_components_are_built_for_this_api() { } } +#[test] +fn a_1_14_component_exports_the_optional_hover_actions_world() { + let engine = PluginEngine::new().unwrap(); + let component = + engine.compile(&repo().join("crates/ide-plugin/tests/fixtures/hover-actions/dist/plugin.wasm")).unwrap(); + let exports: Vec = + component.component_type().exports(engine.engine()).map(|(name, _)| name.to_owned()).collect(); + assert!(exports.iter().any(|name| name.starts_with("openidea:plugin/hover-actions@1.14.0")), "{exports:?}"); + // A 1.13-compatible plugin that does not export the new world stays valid. + let old = engine.compile(&repo().join("plugins/official/test-runner/dist/plugin.wasm")).unwrap(); + let old_exports: Vec = + old.component_type().exports(engine.engine()).map(|(name, _)| name.to_owned()).collect(); + assert!(!old_exports.iter().any(|name| name.starts_with("openidea:plugin/hover-actions"))); +} + // --- a later host, simulated ------------------------------------------------------------- struct Data { diff --git a/crates/ide-plugin/tests/fixtures/api14/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/api14/dist/plugin.wasm index 0c1172f02..e2a28053c 100644 Binary files a/crates/ide-plugin/tests/fixtures/api14/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/api14/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/api14/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/api14/dist/plugin.wasm.sources index 74860d620..c70a09941 100644 --- a/crates/ide-plugin/tests/fixtures/api14/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/api14/dist/plugin.wasm.sources @@ -1 +1 @@ -1e2844d1172750841afd4ba2a8b811522e90522588b1330474207468cbf2a3df +ffc03214c22ab2e732255f56e7d434adb8119094ad706bc395c4c045c4057053 diff --git a/crates/ide-plugin/tests/fixtures/build-graph/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/build-graph/dist/plugin.wasm index d6ddb571c..b5d3a9184 100644 Binary files a/crates/ide-plugin/tests/fixtures/build-graph/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/build-graph/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/build-graph/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/build-graph/dist/plugin.wasm.sources index 32fb23ad4..11f69ba3c 100644 --- a/crates/ide-plugin/tests/fixtures/build-graph/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/build-graph/dist/plugin.wasm.sources @@ -1 +1 @@ -c4d00fe3170a0159e56af61fe715ffb892755cce17cdae5ecb1355fd8e90189e +8eaf0a89d176151d71eccd2b67c9793d68c254c5f82fdc70fc8d31e78b4f977b diff --git a/crates/ide-plugin/tests/fixtures/clipboard/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/clipboard/dist/plugin.wasm index 737728c26..3b196f252 100644 Binary files a/crates/ide-plugin/tests/fixtures/clipboard/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/clipboard/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/clipboard/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/clipboard/dist/plugin.wasm.sources index 9b9e0bb18..e22dde008 100644 --- a/crates/ide-plugin/tests/fixtures/clipboard/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/clipboard/dist/plugin.wasm.sources @@ -1 +1 @@ -ce791decf9a771b43872777a5c97050d9b7b48f5dd0ba0342ad0580bceb93d8c +a65bcaee7be6c24e14e2a0d4daa7d6d9ee2785680c09f35e93696b25fc4d0625 diff --git a/crates/ide-plugin/tests/fixtures/commit/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/commit/dist/plugin.wasm index e2b441230..422fe2326 100644 Binary files a/crates/ide-plugin/tests/fixtures/commit/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/commit/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/commit/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/commit/dist/plugin.wasm.sources index e60c3f334..f4dd3db77 100644 --- a/crates/ide-plugin/tests/fixtures/commit/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/commit/dist/plugin.wasm.sources @@ -1 +1 @@ -f8e768db576e717ec00696098faa3434e9cea0680a1770f303bc071206727607 +799abbd34c0faa68a4ea16c0d5b8e18a6df667b18d47c5467d78921ba8d1903a diff --git a/crates/ide-plugin/tests/fixtures/data-tools/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/data-tools/dist/plugin.wasm index a47399818..2a1f8f69b 100644 Binary files a/crates/ide-plugin/tests/fixtures/data-tools/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/data-tools/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/data-tools/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/data-tools/dist/plugin.wasm.sources index 4b5bafbf3..80772ddad 100644 --- a/crates/ide-plugin/tests/fixtures/data-tools/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/data-tools/dist/plugin.wasm.sources @@ -1 +1 @@ -2bd0f9e7f3ca03410389d0b125372eb322fae411272b597795cbd77ea894076d +0dcd6097bf7c0c89dc334b3acf203bf4c5611914beb201413f148d58a1cb32ff diff --git a/crates/ide-plugin/tests/fixtures/detail-views/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/detail-views/dist/plugin.wasm index d2f7854c0..60df05d24 100644 Binary files a/crates/ide-plugin/tests/fixtures/detail-views/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/detail-views/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/detail-views/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/detail-views/dist/plugin.wasm.sources index d43607f77..ffed40e4a 100644 --- a/crates/ide-plugin/tests/fixtures/detail-views/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/detail-views/dist/plugin.wasm.sources @@ -1 +1 @@ -30dee06cb90e54e7d930996569a3d44e9c9013077c2439880f99e1c99e15cf58 +d1671c61724b2b56902b4476d831ccb41bdff2da644d00ca3b8fff962bdf529b diff --git a/crates/ide-plugin/tests/fixtures/diagnostics/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/diagnostics/dist/plugin.wasm index e253a77ea..a893f3438 100644 Binary files a/crates/ide-plugin/tests/fixtures/diagnostics/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/diagnostics/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/diagnostics/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/diagnostics/dist/plugin.wasm.sources index 40546b5de..1b5646a7e 100644 --- a/crates/ide-plugin/tests/fixtures/diagnostics/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/diagnostics/dist/plugin.wasm.sources @@ -1 +1 @@ -63772fa0f67274c5326a162340aa773c54bd08d0233c726213feedc827bd1a6c +82c878059800ffd425adabb88a273b0e877ca7046b621235762f4db31488e5d6 diff --git a/crates/ide-plugin/tests/fixtures/endpoints/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/endpoints/dist/plugin.wasm index 201dc31c0..d46439fb5 100644 Binary files a/crates/ide-plugin/tests/fixtures/endpoints/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/endpoints/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/endpoints/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/endpoints/dist/plugin.wasm.sources index 6c0862112..4dcfc025f 100644 --- a/crates/ide-plugin/tests/fixtures/endpoints/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/endpoints/dist/plugin.wasm.sources @@ -1 +1 @@ -910d62d7f53480961b8c25b5e8d6300bee3fc0e413f35d3b7d78d6e238c65387 +88f90bb030b3e58ae52cdb7c665e254bda12fce812944e0ebd952923ad380834 diff --git a/crates/ide-plugin/tests/fixtures/execution/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/execution/dist/plugin.wasm index 9286e455c..9a007a0d1 100644 Binary files a/crates/ide-plugin/tests/fixtures/execution/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/execution/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/execution/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/execution/dist/plugin.wasm.sources index a2db30ddd..2259af9ca 100644 --- a/crates/ide-plugin/tests/fixtures/execution/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/execution/dist/plugin.wasm.sources @@ -1 +1 @@ -b05e1146eb97d5c787c826206b0d2257d1390f21a87501efa8901de3f5cb6017 +8e04459a5e453c4bc8746bfb5d13317b6a56d09aec28f6025be36421f79e6865 diff --git a/crates/ide-plugin/tests/fixtures/ext-owner/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/ext-owner/dist/plugin.wasm index 9cbd0bf55..c310b5694 100644 Binary files a/crates/ide-plugin/tests/fixtures/ext-owner/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/ext-owner/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/ext-owner/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/ext-owner/dist/plugin.wasm.sources index f082f2417..c3740ec77 100644 --- a/crates/ide-plugin/tests/fixtures/ext-owner/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/ext-owner/dist/plugin.wasm.sources @@ -1 +1 @@ -aa14bcafa1009b014ba2ca754711fc3b19149ff05dfefddd10edb94d16551c3d +c0aea41383801b3ed39ed1177ffcb40b818e6e259c577a90f1a689332be37195 diff --git a/crates/ide-plugin/tests/fixtures/file-templates/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/file-templates/dist/plugin.wasm index 8ecaf6d4d..3959c3058 100644 Binary files a/crates/ide-plugin/tests/fixtures/file-templates/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/file-templates/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/file-templates/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/file-templates/dist/plugin.wasm.sources index d5ca323ce..d81957668 100644 --- a/crates/ide-plugin/tests/fixtures/file-templates/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/file-templates/dist/plugin.wasm.sources @@ -1 +1 @@ -3c0d0aa400e83c2f8e77fbec32277a23af290d4469d62d5c0046923ee7ae2c49 +2ec59dc4be1d8f50e24e9e179c37ae95176d85f0feed49741bfdbb9c457b9343 diff --git a/crates/ide-plugin/tests/fixtures/files-events/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/files-events/dist/plugin.wasm index cb1d9a6aa..aba41085a 100644 Binary files a/crates/ide-plugin/tests/fixtures/files-events/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/files-events/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/files-events/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/files-events/dist/plugin.wasm.sources index d4d7ac768..b42676919 100644 --- a/crates/ide-plugin/tests/fixtures/files-events/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/files-events/dist/plugin.wasm.sources @@ -1 +1 @@ -a1a3f1691d6d7e837f893580f75935bf83a6c0ae9224ac832c9401885f9ef504 +73d82deae2acdccf346cc8a78670abd6076b79d13b5a32a0b72d6fc337707672 diff --git a/crates/ide-plugin/tests/fixtures/grouped-views/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/grouped-views/dist/plugin.wasm index bcd8c9d47..694953fa4 100644 Binary files a/crates/ide-plugin/tests/fixtures/grouped-views/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/grouped-views/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/grouped-views/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/grouped-views/dist/plugin.wasm.sources index c9558979f..812d4e98e 100644 --- a/crates/ide-plugin/tests/fixtures/grouped-views/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/grouped-views/dist/plugin.wasm.sources @@ -1 +1 @@ -97f80158eda60e5b34e4760607cfdf5c8f22debf49e438a4b3fffaf7184ad59e +28d198f98b792316019f0c03873274938f961edbafd625babe31cb5dccb40db5 diff --git a/crates/ide-plugin/tests/fixtures/hello/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/hello/dist/plugin.wasm index 6446aaa0b..d1f374137 100644 Binary files a/crates/ide-plugin/tests/fixtures/hello/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/hello/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/hello/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/hello/dist/plugin.wasm.sources index bde24385d..9ca184a9e 100644 --- a/crates/ide-plugin/tests/fixtures/hello/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/hello/dist/plugin.wasm.sources @@ -1 +1 @@ -7eff77b3997303adab7b8ef7999b563325e333f0696c63e1a6505579a2a41070 +c9145df209a7a969c17a041f30d4fe2ffc12e4ce941b318212c904c47e90edef diff --git a/crates/ide-plugin/tests/fixtures/hover-actions/Cargo.lock b/crates/ide-plugin/tests/fixtures/hover-actions/Cargo.lock new file mode 100644 index 000000000..bfaa20622 --- /dev/null +++ b/crates/ide-plugin/tests/fixtures/hover-actions/Cargo.lock @@ -0,0 +1,336 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "anyhow" +version = "1.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" + +[[package]] +name = "bitflags" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" + +[[package]] +name = "equivalent" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826" + +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + +[[package]] +name = "hashbrown" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" +dependencies = [ + "foldhash", +] + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "id-arena" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" + +[[package]] +name = "indexmap" +version = "2.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" +dependencies = [ + "equivalent", + "hashbrown", + "serde", + "serde_core", +] + +[[package]] +name = "itoa" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4" + +[[package]] +name = "leb128fmt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" + +[[package]] +name = "log" +version = "0.4.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c" + +[[package]] +name = "macro-string" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e7b3a5bbb2f63aaa223a671ea1bd0e7bc16bd30ce387324cf63995deaddbbd2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "openidea-plugin" +version = "0.1.0" +dependencies = [ + "serde", + "serde_json", + "wit-bindgen", +] + +[[package]] +name = "openidea-test-hover-actions" +version = "0.1.0" +dependencies = [ + "openidea-plugin", +] + +[[package]] +name = "prettyplease" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bfe0f4c752e450fc2faf62654f1c134747922825d5b04ca717b8874f41a40c0" +dependencies = [ + "proc-macro2", + "syn", +] + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "semver" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "syn" +version = "3.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" + +[[package]] +name = "wasm-encoder" +version = "0.262.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4495a6f85dd94c411c749303efcbc5defade0b0cbdbc0541495241ab917a9b5a" +dependencies = [ + "leb128fmt", + "wasmparser", +] + +[[package]] +name = "wasm-metadata" +version = "0.262.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c86ff6668190d9fb70372b306b4f9fe8930f0e2f57ce72e4922bf2f117900949" +dependencies = [ + "anyhow", + "indexmap", + "wasm-encoder", + "wasmparser", +] + +[[package]] +name = "wasmparser" +version = "0.262.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "974d643b125b272607e2fff8012ea14a8328acd7621e4bafa7afb32500052b1b" +dependencies = [ + "bitflags", + "hashbrown", + "indexmap", + "semver", +] + +[[package]] +name = "wit-bindgen" +version = "0.63.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b85a987ab61d365382d25c7d47e26edd48941b3bf6e3fbf76eff918bc71dab06" +dependencies = [ + "bitflags", + "wit-bindgen-rust-macro", +] + +[[package]] +name = "wit-bindgen-core" +version = "0.63.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "775e122e390603abfacd548027016cd0113a6e2bf2f8ce6bdd3658b013456ea8" +dependencies = [ + "anyhow", + "heck", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.63.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84e26e13b9d972026778d2ffb7985736de116026fdc8d9464f966e12df2eb240" +dependencies = [ + "anyhow", + "heck", + "indexmap", + "prettyplease", + "syn", + "wasm-metadata", + "wit-bindgen-core", + "wit-component", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.63.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16a008a0d6b4840677326beb4edbeb210a2f1b7d0183fb7cc33f466b90fd7fb6" +dependencies = [ + "anyhow", + "macro-string", + "prettyplease", + "proc-macro2", + "quote", + "syn", + "wit-bindgen-core", + "wit-bindgen-rust", +] + +[[package]] +name = "wit-component" +version = "0.262.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "078def49fdb49cab405c3006e05793b3fdaf7069126ba6b9c97d01ec8c98fe4c" +dependencies = [ + "anyhow", + "bitflags", + "indexmap", + "log", + "serde", + "serde_derive", + "serde_json", + "wasm-encoder", + "wasm-metadata", + "wasmparser", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.262.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00f0dc051466ffe46787721fca3d088536f158ae400be044f1b1c386ba9397ad" +dependencies = [ + "anyhow", + "hashbrown", + "id-arena", + "indexmap", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-ident", + "wasmparser", +] + +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" diff --git a/crates/ide-plugin/tests/fixtures/hover-actions/Cargo.toml b/crates/ide-plugin/tests/fixtures/hover-actions/Cargo.toml new file mode 100644 index 000000000..b97d7003f --- /dev/null +++ b/crates/ide-plugin/tests/fixtures/hover-actions/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "openidea-test-hover-actions" +version = "0.1.0" +edition = "2024" +publish = false + +[workspace] + +[lib] +crate-type = ["cdylib", "rlib"] + +[dependencies] +openidea-plugin = { path = "../../../../../sdk/rust/openidea-plugin" } + +[profile.release] +opt-level = "s" +lto = true +strip = true +codegen-units = 1 +panic = "abort" diff --git a/crates/ide-plugin/tests/fixtures/hover-actions/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/hover-actions/dist/plugin.wasm new file mode 100644 index 000000000..4009ba6a1 Binary files /dev/null and b/crates/ide-plugin/tests/fixtures/hover-actions/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/hover-actions/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/hover-actions/dist/plugin.wasm.sources new file mode 100644 index 000000000..7b800f894 --- /dev/null +++ b/crates/ide-plugin/tests/fixtures/hover-actions/dist/plugin.wasm.sources @@ -0,0 +1 @@ +ef50da6bb4eb37f1e81055212e7e8ffb0587bd24a9cbcbe0b318e5847c11e0b3 diff --git a/crates/ide-plugin/tests/fixtures/hover-actions/plugin.toml b/crates/ide-plugin/tests/fixtures/hover-actions/plugin.toml new file mode 100644 index 000000000..f6460d39c --- /dev/null +++ b/crates/ide-plugin/tests/fixtures/hover-actions/plugin.toml @@ -0,0 +1,14 @@ +id = "test.hover-actions" +name = "Hover actions fixture" +version = "0.1.0" +engines.openidea = "^1.14" +wasm = "dist/plugin.wasm" + +[[contributes.providers]] +kinds = ["hover-actions"] +languages = ["plaintext", "text"] + +[[contributes.commands]] +id = "run" +title = "Run hover action" +icon = "run" diff --git a/crates/ide-plugin/tests/fixtures/hover-actions/src/lib.rs b/crates/ide-plugin/tests/fixtures/hover-actions/src/lib.rs new file mode 100644 index 000000000..91e9efedf --- /dev/null +++ b/crates/ide-plugin/tests/fixtures/hover-actions/src/lib.rs @@ -0,0 +1,32 @@ +//! Minimal API 1.13 fixture for the optional `hover-actions` export. +use openidea_plugin::language_features::Document; +use openidea_plugin::{Error, HoverAction, HoverActions, Invocation, Plugin, register_plugin}; + +#[derive(Default)] +struct Fixture; + +impl Plugin for Fixture { + fn run_command(&mut self, id: &str, _: &Invocation, arg: Option<&str>) -> Result, Error> { + match id { + "run" => Ok(arg.map(str::to_owned)), + _ => Err(Error::NotFound(id.into())), + } + } +} + +impl HoverActions for Fixture { + fn hover_actions(&mut self, _: &Document) -> Vec { + vec![HoverAction { + line: 0, + start_line: 0, + end_line: 2, + icon: Some("run".into()), + label: "Run hover action".into(), + tooltip: Some("Run hover action".into()), + command: "run".into(), + argument: Some("hover".into()), + }] + } +} + +register_plugin!(Fixture, hover_actions); diff --git a/crates/ide-plugin/tests/fixtures/hover/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/hover/dist/plugin.wasm index 3bd8902fc..b61026993 100644 Binary files a/crates/ide-plugin/tests/fixtures/hover/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/hover/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/hover/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/hover/dist/plugin.wasm.sources index d0a2bc87a..82175c9a3 100644 --- a/crates/ide-plugin/tests/fixtures/hover/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/hover/dist/plugin.wasm.sources @@ -1 +1 @@ -507827131b48fc6c679d8c2558c2e519e03e77ebbdeaaf25d9322f36d721201e +0807c0c1cf4b9ab340ca5991c9ca4d74b7ae9917de527b4be0a118ac778cf857 diff --git a/crates/ide-plugin/tests/fixtures/indexer/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/indexer/dist/plugin.wasm index 7e1359e16..68ed17489 100644 Binary files a/crates/ide-plugin/tests/fixtures/indexer/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/indexer/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/indexer/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/indexer/dist/plugin.wasm.sources index a4b7bf9a9..e1c1d4af3 100644 --- a/crates/ide-plugin/tests/fixtures/indexer/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/indexer/dist/plugin.wasm.sources @@ -1 +1 @@ -ba97c6ec41ee0e2996ddd1d1c9432fad2ea0afb4c237f67c2ffb61cd25b4296c +7a69d58846ddb5dfad48fd2c5dc87cd026a0971b24f8ff743e45c59f33160fbe diff --git a/crates/ide-plugin/tests/fixtures/inlay-hints/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/inlay-hints/dist/plugin.wasm index e6052a734..d4f2d9e7e 100644 Binary files a/crates/ide-plugin/tests/fixtures/inlay-hints/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/inlay-hints/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/inlay-hints/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/inlay-hints/dist/plugin.wasm.sources index 906cc8274..12cd8dae6 100644 --- a/crates/ide-plugin/tests/fixtures/inlay-hints/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/inlay-hints/dist/plugin.wasm.sources @@ -1 +1 @@ -2db9659a4a5fee1cf7179fc5f66ee7ea93f98fa8e844db4213be8cb280998b62 +7024ae9d20f7b0ca6ce1ff77d9b3913ade91288016c07ac74602c96db766df1b diff --git a/crates/ide-plugin/tests/fixtures/jobs/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/jobs/dist/plugin.wasm index 51c1059aa..e620ac362 100644 Binary files a/crates/ide-plugin/tests/fixtures/jobs/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/jobs/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/jobs/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/jobs/dist/plugin.wasm.sources index cdb833061..c4c31a495 100644 --- a/crates/ide-plugin/tests/fixtures/jobs/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/jobs/dist/plugin.wasm.sources @@ -1 +1 @@ -f6ca5c93b202794571b09d0882b6809e28cd54be61765265565e991c49f9b021 +312b8299192e159d8008b2ad7217abc442b9f7a95951fc60c4f95b81dee0dfd9 diff --git a/crates/ide-plugin/tests/fixtures/language-features/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/language-features/dist/plugin.wasm index 96138e718..80f019fa3 100644 Binary files a/crates/ide-plugin/tests/fixtures/language-features/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/language-features/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/language-features/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/language-features/dist/plugin.wasm.sources index 214b6210f..65a4a67a2 100644 --- a/crates/ide-plugin/tests/fixtures/language-features/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/language-features/dist/plugin.wasm.sources @@ -1 +1 @@ -ef28c6f306a3adfc7d9fc7e6ec057845b2dc159866cd07745e949436de8a2107 +f43c8b7790393f6c55c626882a5a5815de49a29301d67d8ff6164dc51970c3bf diff --git a/crates/ide-plugin/tests/fixtures/language-features/plugin.toml b/crates/ide-plugin/tests/fixtures/language-features/plugin.toml index 0b77ae880..1145e6e06 100644 --- a/crates/ide-plugin/tests/fixtures/language-features/plugin.toml +++ b/crates/ide-plugin/tests/fixtures/language-features/plugin.toml @@ -1,11 +1,11 @@ id = "test.language-features" name = "Language features fixture" version = "0.1.0" -engines.openidea = "^1.4" +engines.openidea = "^1.14" wasm = "dist/plugin.wasm" [[contributes.providers]] -kinds = ["formatting", "signature-help", "document-highlights", "document-links", "code-lenses", "selection-ranges", "folding", "colors", "document-symbols", "implementation", "type-definition", "gutter-actions", "injections"] +kinds = ["formatting", "signature-help", "document-highlights", "document-links", "code-lenses", "selection-ranges", "folding", "colors", "document-symbols", "implementation", "type-definition", "gutter-actions", "hover-actions", "injections"] languages = ["plaintext", "text", "sql"] [[contributes.providers]] diff --git a/crates/ide-plugin/tests/fixtures/language-features/src/lib.rs b/crates/ide-plugin/tests/fixtures/language-features/src/lib.rs index db7190a63..22165f67c 100644 --- a/crates/ide-plugin/tests/fixtures/language-features/src/lib.rs +++ b/crates/ide-plugin/tests/fixtures/language-features/src/lib.rs @@ -1,6 +1,7 @@ use openidea_plugin::language_features::*; use openidea_plugin::{ - Diagnostic, Error, Invocation, Location, Plugin, Position, Range, Severity, TextEdit, register_plugin, text, + Diagnostic, Error, HoverAction, HoverActions, Invocation, Location, Plugin, Position, Range, Severity, TextEdit, + register_plugin, text, }; #[derive(Default)] struct Fixture { @@ -102,6 +103,20 @@ impl LanguageFeatures for Fixture { }] } } +impl HoverActions for Fixture { + fn hover_actions(&mut self, _: &Document) -> Vec { + vec![HoverAction { + line: 0, + start_line: 0, + end_line: 2, + icon: Some("run".into()), + label: "Run fixture".into(), + tooltip: Some("Run fixture".into()), + command: "run".into(), + argument: Some("inline".into()), + }] + } +} impl Injections for Fixture { fn injections(&mut self, d: &Document) -> Vec { if d.language == "sql" { @@ -141,4 +156,4 @@ impl openidea_plugin::diagnostics::DiagnosticsProvider for Fixture { ] } } -register_plugin!(Fixture, language_features, injections, providers, hover, diagnostics); +register_plugin!(Fixture, language_features, hover_actions, injections, providers, hover, diagnostics); diff --git a/crates/ide-plugin/tests/fixtures/lsp-requests/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/lsp-requests/dist/plugin.wasm index e1c81636f..9cd38c543 100644 Binary files a/crates/ide-plugin/tests/fixtures/lsp-requests/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/lsp-requests/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/lsp-requests/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/lsp-requests/dist/plugin.wasm.sources index db291a1fc..f0f96c02e 100644 --- a/crates/ide-plugin/tests/fixtures/lsp-requests/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/lsp-requests/dist/plugin.wasm.sources @@ -1 +1 @@ -abcb633eb89a522e4659cb21770517bb51e889d55c80854d6adc55d0ba33c41b +6534015874177fa3bdad1d6fa4dbf571b83572635632c2b0294ca9594346520d diff --git a/crates/ide-plugin/tests/fixtures/misbehave/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/misbehave/dist/plugin.wasm index 80a493d42..7c9f5afae 100644 Binary files a/crates/ide-plugin/tests/fixtures/misbehave/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/misbehave/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/misbehave/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/misbehave/dist/plugin.wasm.sources index 7edee709e..f69bff4fc 100644 --- a/crates/ide-plugin/tests/fixtures/misbehave/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/misbehave/dist/plugin.wasm.sources @@ -1 +1 @@ -d696eacb402c81a04c42440593363fafe67d11487905a18151976253544415df +9b1fb340840109da9efa88a1b41d00b1f0b9eb162c5029cf0b647d39a1dc8c36 diff --git a/crates/ide-plugin/tests/fixtures/misbehave/src/lib.rs b/crates/ide-plugin/tests/fixtures/misbehave/src/lib.rs index dc270b81f..e4b49b02f 100644 --- a/crates/ide-plugin/tests/fixtures/misbehave/src/lib.rs +++ b/crates/ide-plugin/tests/fixtures/misbehave/src/lib.rs @@ -5,9 +5,9 @@ wit_bindgen::generate!({ inline: " package fixture:misbehave; world misbehave { - include openidea:plugin/plugin-syntax@1.13.0; - export openidea:plugin/providers@1.13.0; - export openidea:plugin/file-actions@1.13.0; + include openidea:plugin/plugin-syntax@1.14.0; + export openidea:plugin/providers@1.14.0; + export openidea:plugin/file-actions@1.14.0; } ", path: "../../../../../wit", diff --git a/crates/ide-plugin/tests/fixtures/path-events/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/path-events/dist/plugin.wasm index 23ca9a1c4..26a16258d 100644 Binary files a/crates/ide-plugin/tests/fixtures/path-events/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/path-events/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/path-events/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/path-events/dist/plugin.wasm.sources index c0d4eb05d..ffc948881 100644 --- a/crates/ide-plugin/tests/fixtures/path-events/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/path-events/dist/plugin.wasm.sources @@ -1 +1 @@ -fe55436cf32ce58ba8f8a681617e3e6d7fb94aaac1ce52eb4be620450f68b588 +4bde4785c0c30aeb5236a164e813b33b29cafc8c663a25a6621c2b4485a50f42 diff --git a/crates/ide-plugin/tests/fixtures/private-dir/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/private-dir/dist/plugin.wasm index 1f4673364..5ce50ac3a 100644 Binary files a/crates/ide-plugin/tests/fixtures/private-dir/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/private-dir/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/private-dir/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/private-dir/dist/plugin.wasm.sources index 1f5c0c8db..ffa533a3f 100644 --- a/crates/ide-plugin/tests/fixtures/private-dir/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/private-dir/dist/plugin.wasm.sources @@ -1 +1 @@ -e6b23695cff3baf9e6d522b778799c937aff0df9037c62b14b96ad0ad2721225 +f3258dd48ae2468f9b513df27373224dc6b32284de0956642f11509d91adf1fd diff --git a/crates/ide-plugin/tests/fixtures/search/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/search/dist/plugin.wasm index 0d4e98779..0ffabd960 100644 Binary files a/crates/ide-plugin/tests/fixtures/search/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/search/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/search/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/search/dist/plugin.wasm.sources index 2ae3307bd..7a2b70470 100644 --- a/crates/ide-plugin/tests/fixtures/search/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/search/dist/plugin.wasm.sources @@ -1 +1 @@ -c66907db0638d971126a5dd70a9b2e6a18af3d29f2c2fa2d860a726be9b76f75 +91ef32f574c389d6ab1d38e3570c763a695b0e0006b82a2957b8ab3042cd7415 diff --git a/crates/ide-plugin/tests/fixtures/search/plugin.toml b/crates/ide-plugin/tests/fixtures/search/plugin.toml index cc5386415..76df1af18 100644 --- a/crates/ide-plugin/tests/fixtures/search/plugin.toml +++ b/crates/ide-plugin/tests/fixtures/search/plugin.toml @@ -1,7 +1,7 @@ id = "test.search" name = "Search fixture" version = "0.1.0" -engines.openidea = "^1.13" +engines.openidea = "^1.14" wasm = "dist/plugin.wasm" capabilities.required = ["project.read"] diff --git a/crates/ide-plugin/tests/fixtures/semantic-tokens/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/semantic-tokens/dist/plugin.wasm index 688e70bd3..ea5112a18 100644 Binary files a/crates/ide-plugin/tests/fixtures/semantic-tokens/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/semantic-tokens/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/semantic-tokens/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/semantic-tokens/dist/plugin.wasm.sources index d8ebf07a2..d230e5c9a 100644 --- a/crates/ide-plugin/tests/fixtures/semantic-tokens/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/semantic-tokens/dist/plugin.wasm.sources @@ -1 +1 @@ -a5c854e0ddb90ffddc600c196a78efc4e318b675ef8f7ef9c1059d05bbdc6de6 +4fdc7ecd459008c8f6457ff9985807c4808eaaca541e4efad5da2d445ba1552f diff --git a/crates/ide-plugin/tests/fixtures/settings-pages/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/settings-pages/dist/plugin.wasm index 90fb698ec..34f038c78 100644 Binary files a/crates/ide-plugin/tests/fixtures/settings-pages/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/settings-pages/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/settings-pages/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/settings-pages/dist/plugin.wasm.sources index 6bf51e3ac..25daf0b7e 100644 --- a/crates/ide-plugin/tests/fixtures/settings-pages/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/settings-pages/dist/plugin.wasm.sources @@ -1 +1 @@ -496e2cb9969f14ef82b2b5982e96c14bf5f586716f15141d5b80b025c4860ef0 +958eefe7f24c581db9bfcf64c59c2108dc3ec56d99cc2ae0d9dac087449cac60 diff --git a/crates/ide-plugin/tests/fixtures/storage/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/storage/dist/plugin.wasm index 89e056bb6..42cd6b933 100644 Binary files a/crates/ide-plugin/tests/fixtures/storage/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/storage/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/storage/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/storage/dist/plugin.wasm.sources index 267b2df7d..796ec8f6e 100644 --- a/crates/ide-plugin/tests/fixtures/storage/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/storage/dist/plugin.wasm.sources @@ -1 +1 @@ -6b790c68221c7a4071e99ba2794a3f156e90109185814bf6b21cf4f5ef907642 +3aacbd38fd26c73b252dac1f580d1890dcb9feb61ef89275617b47609aa7be5e diff --git a/crates/ide-plugin/tests/fixtures/symbols/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/symbols/dist/plugin.wasm index 9ef011e89..a5ca951cd 100644 Binary files a/crates/ide-plugin/tests/fixtures/symbols/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/symbols/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/symbols/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/symbols/dist/plugin.wasm.sources index 4564f2074..822b77182 100644 --- a/crates/ide-plugin/tests/fixtures/symbols/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/symbols/dist/plugin.wasm.sources @@ -1 +1 @@ -e7974d1c1b09578664869857cfa9ab05080540096c5a2b8601adb2ee30649d6f +2768e1b2e434b9e3e51544879b14ccb24bb03790cb97c30faa6c8cd2f410e702 diff --git a/crates/ide-plugin/tests/fixtures/tables/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/tables/dist/plugin.wasm index fa51b0a92..e68d8b67d 100644 Binary files a/crates/ide-plugin/tests/fixtures/tables/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/tables/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/tables/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/tables/dist/plugin.wasm.sources index a0b48a2e1..81e2cbe6b 100644 --- a/crates/ide-plugin/tests/fixtures/tables/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/tables/dist/plugin.wasm.sources @@ -1 +1 @@ -9563467036c1a365aa6df01cc7fbdb50c4b8b66656bb0d3b5864da58a3b8763d +760f11fff96302bc212c31ac82a18126cac2392c2547ddaf0fa5a358de43f6aa diff --git a/crates/ide-plugin/tests/fixtures/web-content/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/web-content/dist/plugin.wasm index e3265e4d8..237474ca3 100644 Binary files a/crates/ide-plugin/tests/fixtures/web-content/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/web-content/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/web-content/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/web-content/dist/plugin.wasm.sources index 7fadc1bce..580a182e9 100644 --- a/crates/ide-plugin/tests/fixtures/web-content/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/web-content/dist/plugin.wasm.sources @@ -1 +1 @@ -17d352320df9d4ccb67f80a4b6a7e8b13c7c1402375e1d1cf86154ce9026c9dd +d65bc6dfd172ed545ac96d9197ca5af39f97362ad3a0b5967cac4f4e6c56b3a2 diff --git a/crates/ide-plugin/tests/fixtures/web-log/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/web-log/dist/plugin.wasm index 9f4514e8d..0bd53998e 100644 Binary files a/crates/ide-plugin/tests/fixtures/web-log/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/web-log/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/web-log/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/web-log/dist/plugin.wasm.sources index 83f4c42bb..37c6b078b 100644 --- a/crates/ide-plugin/tests/fixtures/web-log/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/web-log/dist/plugin.wasm.sources @@ -1 +1 @@ -f3f3ea4688f068e1b2913bdaa6d2a4ec9f91f441caa5a6f50205fcec0bf6b565 +67610a3d7d09813deaf1152f1b5b5a7ced9de089ab24c285b9d2f9763242e648 diff --git a/crates/ide-plugin/tests/fixtures/web-pty/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/web-pty/dist/plugin.wasm index ad368b14b..2053f2916 100644 Binary files a/crates/ide-plugin/tests/fixtures/web-pty/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/web-pty/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/web-pty/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/web-pty/dist/plugin.wasm.sources index 5325f0821..39ad3a4df 100644 --- a/crates/ide-plugin/tests/fixtures/web-pty/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/web-pty/dist/plugin.wasm.sources @@ -1 +1 @@ -d0d9887dea30561a313bb45e3ae7520bb49b0e6eef353fd91c0487c498265dc6 +d4653877beb8d12faac30170b99cbe48f08c883155aaa588031c1e60586b1e93 diff --git a/docs/en/plugins/api/index.mdx b/docs/en/plugins/api/index.mdx index 9d9330468..6d38ffdde 100644 --- a/docs/en/plugins/api/index.mdx +++ b/docs/en/plugins/api/index.mdx @@ -69,13 +69,14 @@ The IDE calls these. The first three are in every code plugin; the rest are opti | `language-features` | [language-features.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/language-features.wit) | Formatting, signature help, highlights, links, code lenses, folds, colours, symbols, gutter actions and more (API 1.4) | | `injections` | [injections.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/injections.wit) | Ranges of embedded languages inside a document (API 1.4) | | `hover-provider` | [hover.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/hover.wit) | Markdown added to the hover of any language | +| `hover-actions` | [hover-actions.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/hover-actions.wit) | Hover-revealed line actions at the left edge of a line (API 1.14): anchor line and inclusive trigger line range | | `inlay-hints-provider` | [inlay.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/inlay.wit) | Inline hints in any language | | `semantic-tokens-provider` | [semantic.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/semantic.wit) | Semantic colouring in any language | | `diagnostics-provider` | [diagnostics.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/diagnostics.wit) | Problems in the current, possibly unsaved document | | `file-actions` | [file-actions.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/file-actions.wit) | Quick fixes and refactorings that create, rename or delete files | | `document-indexer` | [indexing.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/indexing.wit) | Cross-file definitions, references and gutter markers, indexed in the background | | `endpoints-provider` | [endpoints.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/endpoints.wit) | A project's HTTP endpoints for Search Everywhere and the HTTP client | -| `search-provider` | [search.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/search.wit) | Cancellable queries for a plugin-defined Search Everywhere tab (API 1.13) | +| `search-provider` | [search.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/search.wit) | Cancellable queries for a plugin-defined Search Everywhere tab (API 1.14) | | `view-provider` | [views.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/views.wit) | Content and events of declared views and custom editors | | `detail-provider` | [details.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/details.wit) | The detail pane of the plugin's nodes in the Services tool window | | `commit-checker` | [commit.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/commit.wit) | Before-commit checks | diff --git a/docs/en/plugins/guides/language-features.mdx b/docs/en/plugins/guides/language-features.mdx index 76ab95d0f..428d4efa9 100644 --- a/docs/en/plugins/guides/language-features.mdx +++ b/docs/en/plugins/guides/language-features.mdx @@ -228,6 +228,7 @@ Declare any of these kinds with `engines.openidea = "^1.4"`, implement | `implementation` | `implementation(doc, at)` | Merged with the server's implementations. | | `type-definition` | `type_definition(doc, at)` | Merged with the server's type declarations. | | `gutter-actions` | `gutter_actions(doc)` | Gutter buttons that run one of the plugin's declared commands, with an optional argument. | +| `hover-actions` | `hover_actions(doc)` | Actions at the left edge of a line, revealed while the pointer is in the first four editing-area columns for any line in `start-line..=end-line`; the button is anchored to `line` and never covers text (API 1.14). | A code lens that offers a command, from the [Blame Annotations](https://github.com/l0ng-ai/openidea/tree/main/plugins/official/blame-annotations) diff --git a/docs/en/plugins/versioning.mdx b/docs/en/plugins/versioning.mdx index 19cc221a5..63fe02740 100644 --- a/docs/en/plugins/versioning.mdx +++ b/docs/en/plugins/versioning.mdx @@ -27,7 +27,8 @@ The plugin API has one version number: the version of the WIT package in [`wit/` | 1.10.0 | OpenIDEA 0.1.47 | `build.dependencies`: the Maven / Gradle dependency graph the IDE resolved (`build.read`) | | 1.11.0 | In development on `main` | `ui.read-clipboard`: the clipboard's text and image in commands the user ran (`clipboard.read`) | | 1.12.0 | In development on `main` | `ui.set-console-rules`: highlight rules (regex, palette colours, styles) for Run and Debug console output | -| 1.13.0 | In development on `main` | Optional `search-provider` export and `searchCategories`: custom Search Everywhere tabs with cancellable queries | +| 1.13.0 | OpenIDEA 0.1.49 | Optional `search-provider` export and `searchCategories`: custom Search Everywhere tabs with cancellable queries | +| 1.14.0 | In development on `main` | Optional `hover-actions` export: left-edge line actions revealed by line-edge hover, with an anchor line and inclusive trigger range | The full list of what each version added is in [`plugins/README.md`](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md). diff --git a/docs/zh/plugins/api/index.mdx b/docs/zh/plugins/api/index.mdx index e2c10d596..2003cdb20 100644 --- a/docs/zh/plugins/api/index.mdx +++ b/docs/zh/plugins/api/index.mdx @@ -69,13 +69,14 @@ description: "openidea:plugin WIT 包中的每个 interface:一句话说明及 | `language-features` | [language-features.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/language-features.wit) | 格式化、签名帮助、高亮、链接、代码透镜、折叠、颜色、符号、装订区操作等(API 1.4) | | `injections` | [injections.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/injections.wit) | 文档中嵌入语言的范围(API 1.4) | | `hover-provider` | [hover.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/hover.wit) | 向任意语言的悬停追加 Markdown | +| `hover-actions` | [hover-actions.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/hover-actions.wit) | 行左侧边缘的 hover 操作(API 1.14):锚定行和包含式触发行范围 | | `inlay-hints-provider` | [inlay.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/inlay.wit) | 任意语言中的内嵌提示 | | `semantic-tokens-provider` | [semantic.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/semantic.wit) | 任意语言中的语义着色 | | `diagnostics-provider` | [diagnostics.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/diagnostics.wit) | 当前文档(可能未保存)中的问题 | | `file-actions` | [file-actions.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/file-actions.wit) | 创建、重命名或删除文件的快速修复和重构 | | `document-indexer` | [indexing.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/indexing.wit) | 在后台索引的跨文件定义、引用和装订区标记 | | `endpoints-provider` | [endpoints.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/endpoints.wit) | 项目的 HTTP 端点,供 随处搜索 和 HTTP 客户端使用 | -| `search-provider` | [search.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/search.wit) | 插件自定义全局搜索分类的可取消查询(API 1.13) | +| `search-provider` | [search.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/search.wit) | 插件自定义全局搜索分类的可取消查询(API 1.14) | | `view-provider` | [views.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/views.wit) | 声明的视图和自定义编辑器的内容与事件 | | `detail-provider` | [details.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/details.wit) | Services 工具窗口中插件节点的详情面板 | | `commit-checker` | [commit.wit](https://github.com/l0ng-ai/openidea/blob/main/wit/commit.wit) | 提交前检查 | diff --git a/docs/zh/plugins/guides/language-features.mdx b/docs/zh/plugins/guides/language-features.mdx index 4ead8412d..b9a611002 100644 --- a/docs/zh/plugins/guides/language-features.mdx +++ b/docs/zh/plugins/guides/language-features.mdx @@ -209,6 +209,7 @@ impl InlayHints for MyPlugin { | `implementation` | `implementation(doc, at)` | 与服务器的实现结果合并。 | | `type-definition` | `type_definition(doc, at)` | 与服务器的类型声明结果合并。 | | `gutter-actions` | `gutter_actions(doc)` | 行号槽按钮,执行插件声明的命令,可带参数。 | +| `hover-actions` | `hover_actions(doc)` | 行左侧边缘的操作,在 `start-line..=end-line` 内任意一行的编辑区前四列悬浮时显示;按钮锚定到 `line`,不覆盖文本(API 1.14)。 | 下面是 [Blame Annotations](https://github.com/l0ng-ai/openidea/tree/main/plugins/official/blame-annotations) 示例中提供命令入口的代码透镜: diff --git a/docs/zh/plugins/versioning.mdx b/docs/zh/plugins/versioning.mdx index 8c7e49b52..a26f95b6e 100644 --- a/docs/zh/plugins/versioning.mdx +++ b/docs/zh/plugins/versioning.mdx @@ -24,7 +24,8 @@ description: "engines.openidea、插件 API 从 1.0 到 1.13 的各个版本, | 1.10.0 | OpenIDEA 0.1.47 | `build.dependencies`:IDE 已解析的 Maven / Gradle 依赖图(`build.read`) | | 1.11.0 | `main` 上开发中 | `ui.read-clipboard`:在用户运行的命令中读取剪贴板的文本和图片(`clipboard.read`) | | 1.12.0 | `main` 上开发中 | `ui.set-console-rules`:Run/Debug 控制台输出的高亮规则(正则、调色板颜色、文本样式) | -| 1.13.0 | `main` 上开发中 | 新增 `search-provider` 导出和 `searchCategories` 贡献点:可取消查询的全局搜索自定义分类 | +| 1.13.0 | OpenIDEA 0.1.49 | 新增 `search-provider` 导出和 `searchCategories` 贡献点:可取消查询的全局搜索自定义分类 | +| 1.14.0 | `main` 上开发中 | 可选 `hover-actions` 导出:行内侧 hover 显示的左侧操作,带锚定行和包含式触发行范围 | 每个版本新增内容的完整列表见 [`plugins/README.md`](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md)。 diff --git a/plugins/README.md b/plugins/README.md index d42fee9b2..d355ce17f 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -426,6 +426,44 @@ are always available. Calling a gated function without its capability returns ## 3. Writing code (Rust SDK) +### API 1.14 + +API 1.14.0 is in development on `main`. Use `engines.openidea = "^1.14"` and the +matching SDK. Plugins for 1.13 and earlier keep working. New in 1.14: + +- **Hover-revealed line actions.** The optional `hover-actions` export + (world `plugin-hover-actions`, SDK `HoverActions`, registration + `register_plugin!(Plugin, hover_actions)`) contributes clickable actions at + the left edge of an editor line. Declare `kinds = ["hover-actions"]` under + `[[contributes.providers]]`. The host reveals an action while the pointer is + in the first four character columns of the editing area for any line in its + `start-line`/`end-line` range, anchors it to `line`, and never covers the + code text. The released `language-features` interfaces stay unchanged. + +Example: + +```rust +#[derive(Default)] +struct MyPlugin; +impl openidea_plugin::HoverActions for MyPlugin { + fn hover_actions(&mut self, doc: &openidea_plugin::language_features::Document) + -> Vec + { + vec![openidea_plugin::HoverAction { + line: 0, + start_line: 0, + end_line: 10, + icon: Some("run".into()), + label: "Call this method".into(), + tooltip: Some("Call this method".into()), + command: "call".into(), + argument: None, + }] + } +} +openidea_plugin::register_plugin!(MyPlugin, hover_actions); +``` + ### API 1.13 API 1.13.0 is in development on `main`. Use `engines.openidea = "^1.13"` and the @@ -1578,6 +1616,7 @@ and register `register_plugin!(MyPlugin, language_features)`: | `implementation` | `implementation(doc, at)` | Merged with LSP Go to Implementation, deduplicated by location. | | `type-definition` | `type_definition(doc, at)` | Merged with LSP Go to Type Declaration, deduplicated by location. | | `gutter-actions` | `gutter_actions(doc)` | Buttons beside line markers. Clicks invoke only the returning plugin's declared command, with its optional string argument and the editor window/project context. Icons accept the same names, aliases and declared marker SVG paths as line markers. | +| `hover-actions` | `hover_actions(doc)` | Left-edge actions revealed by line-edge hover, with an anchor line and an inclusive trigger line range (API 1.14). | The optional WIT interface is `language-features`, in worlds `plugin-language-features` / `editor-language-features`. Its own `document` diff --git a/plugins/official/ai-completion/dist/plugin.wasm b/plugins/official/ai-completion/dist/plugin.wasm index 426ea62c5..b72a15cd3 100644 Binary files a/plugins/official/ai-completion/dist/plugin.wasm and b/plugins/official/ai-completion/dist/plugin.wasm differ diff --git a/plugins/official/ai-completion/dist/plugin.wasm.sources b/plugins/official/ai-completion/dist/plugin.wasm.sources index 9f774f42c..ac8929466 100644 --- a/plugins/official/ai-completion/dist/plugin.wasm.sources +++ b/plugins/official/ai-completion/dist/plugin.wasm.sources @@ -1 +1 @@ -68087f0299ec1cef65d1527a9198f31665f6a428edbbc3e37a33262e4984b96a +aa4cc3efbfe6f26930e1f448f00361df453ff6aedc3a6223786c2946add2c20f diff --git a/plugins/official/blame-annotations/dist/plugin.wasm b/plugins/official/blame-annotations/dist/plugin.wasm index 85ab5b4e0..960cd16bd 100644 Binary files a/plugins/official/blame-annotations/dist/plugin.wasm and b/plugins/official/blame-annotations/dist/plugin.wasm differ diff --git a/plugins/official/blame-annotations/dist/plugin.wasm.sources b/plugins/official/blame-annotations/dist/plugin.wasm.sources index 73cb7a70f..13e85fd8d 100644 --- a/plugins/official/blame-annotations/dist/plugin.wasm.sources +++ b/plugins/official/blame-annotations/dist/plugin.wasm.sources @@ -1 +1 @@ -7b48ea8b3724072605e979d47c501aa221f78213b5028383f55c517e00925b8f +086dd13f1510b06064e399f463fc719e41fed90eadaa8d151826aed3efc29d84 diff --git a/plugins/official/checkstyle/dist/plugin.wasm b/plugins/official/checkstyle/dist/plugin.wasm index ddf1921f5..d5c167bff 100644 Binary files a/plugins/official/checkstyle/dist/plugin.wasm and b/plugins/official/checkstyle/dist/plugin.wasm differ diff --git a/plugins/official/checkstyle/dist/plugin.wasm.sources b/plugins/official/checkstyle/dist/plugin.wasm.sources index 031a54034..acc705fa2 100644 --- a/plugins/official/checkstyle/dist/plugin.wasm.sources +++ b/plugins/official/checkstyle/dist/plugin.wasm.sources @@ -1 +1 @@ -6e1a6b0a87403dda7d9e780a43c7da97ab6673b80bc2ed7365d0b6e7d8191e47 +ceace9d394ce329f644ea4dec6e6b2c6bd64e2b9177a67744c84166768812c81 diff --git a/plugins/official/container-runner/dist/plugin.wasm b/plugins/official/container-runner/dist/plugin.wasm index e5d70fce0..8c006dfd9 100644 Binary files a/plugins/official/container-runner/dist/plugin.wasm and b/plugins/official/container-runner/dist/plugin.wasm differ diff --git a/plugins/official/container-runner/dist/plugin.wasm.sources b/plugins/official/container-runner/dist/plugin.wasm.sources index 54ab40fbd..0937bd658 100644 --- a/plugins/official/container-runner/dist/plugin.wasm.sources +++ b/plugins/official/container-runner/dist/plugin.wasm.sources @@ -1 +1 @@ -c0c583007f253e9466feb0cf49ddb0981470e3a41ededdeb08b468a86a69454e +ee01772f5bc9a0ea75c7a7078875414ec8e2d1506c58ca07cefb8534ca9d20e6 diff --git a/plugins/official/csv-editor/dist/plugin.wasm b/plugins/official/csv-editor/dist/plugin.wasm index 0385e2969..8c1636cd3 100644 Binary files a/plugins/official/csv-editor/dist/plugin.wasm and b/plugins/official/csv-editor/dist/plugin.wasm differ diff --git a/plugins/official/csv-editor/dist/plugin.wasm.sources b/plugins/official/csv-editor/dist/plugin.wasm.sources index 0aa8a6223..3bc557820 100644 --- a/plugins/official/csv-editor/dist/plugin.wasm.sources +++ b/plugins/official/csv-editor/dist/plugin.wasm.sources @@ -1 +1 @@ -7b7d7927f454ab760d1c01ec5f09e5be8dc1f3f8d5d293dd02c8a1373109784b +9a887b53a9bc0113fe12c839cdafd7dbe7bb8ca436c38c5d02eaf3fbe74efb11 diff --git a/plugins/official/git-toolbox/dist/plugin.wasm b/plugins/official/git-toolbox/dist/plugin.wasm index 7be7e458d..04b0f46cd 100644 Binary files a/plugins/official/git-toolbox/dist/plugin.wasm and b/plugins/official/git-toolbox/dist/plugin.wasm differ diff --git a/plugins/official/git-toolbox/dist/plugin.wasm.sources b/plugins/official/git-toolbox/dist/plugin.wasm.sources index c9d2004b9..0b553ce4f 100644 --- a/plugins/official/git-toolbox/dist/plugin.wasm.sources +++ b/plugins/official/git-toolbox/dist/plugin.wasm.sources @@ -1 +1 @@ -e3caa410ffa9be9be9ea5a734e0adf19aab2501b2ca4a5479edf55b71d0ad3ec +283fd9d8f97b62d3dad9681abb4faa5379bc17229b10dd36fb4d59ff6f4d780d diff --git a/plugins/official/graphviz/dist/plugin.wasm b/plugins/official/graphviz/dist/plugin.wasm index 833c96370..41c5b65e7 100644 Binary files a/plugins/official/graphviz/dist/plugin.wasm and b/plugins/official/graphviz/dist/plugin.wasm differ diff --git a/plugins/official/graphviz/dist/plugin.wasm.sources b/plugins/official/graphviz/dist/plugin.wasm.sources index 7a6cb0117..e3b014eaf 100644 --- a/plugins/official/graphviz/dist/plugin.wasm.sources +++ b/plugins/official/graphviz/dist/plugin.wasm.sources @@ -1 +1 @@ -e02e2caee7ba3ca06b295b727028a9e458077232c5d01bd374bace03f6d42b69 +88d75a8657cc4f1e1d07a161c5d0cd6b23ab9ba1ee59a07f35889dbd4f33042e diff --git a/plugins/official/key-promoter/dist/plugin.wasm b/plugins/official/key-promoter/dist/plugin.wasm index f4c72657d..363309663 100644 Binary files a/plugins/official/key-promoter/dist/plugin.wasm and b/plugins/official/key-promoter/dist/plugin.wasm differ diff --git a/plugins/official/key-promoter/dist/plugin.wasm.sources b/plugins/official/key-promoter/dist/plugin.wasm.sources index 6f548fc66..6495e7bdb 100644 --- a/plugins/official/key-promoter/dist/plugin.wasm.sources +++ b/plugins/official/key-promoter/dist/plugin.wasm.sources @@ -1 +1 @@ -22ccd44a9ee3146af69ab2ca849ebc2aa8f11150483df9ec816517f068f7735c +a04b9d53c06457146f2704c8e1a85c7ee56de91dee4309d54479587c06cdf214 diff --git a/plugins/official/license-header/dist/plugin.wasm b/plugins/official/license-header/dist/plugin.wasm index a4c7eeb91..a6ad4f613 100644 Binary files a/plugins/official/license-header/dist/plugin.wasm and b/plugins/official/license-header/dist/plugin.wasm differ diff --git a/plugins/official/license-header/dist/plugin.wasm.sources b/plugins/official/license-header/dist/plugin.wasm.sources index b9ee9ec89..6115866dd 100644 --- a/plugins/official/license-header/dist/plugin.wasm.sources +++ b/plugins/official/license-header/dist/plugin.wasm.sources @@ -1 +1 @@ -8b2db44e0b03392be363790a2c33d908c2a2dd201883b8e9ee7ec965bba88c60 +3a0640bf840f2072b716fd216f126df58aa8d0b85055e38d32abc0feb8ed3c2f diff --git a/plugins/official/mybatis/dist/plugin.wasm b/plugins/official/mybatis/dist/plugin.wasm index 040a9244f..5fa22f2da 100644 Binary files a/plugins/official/mybatis/dist/plugin.wasm and b/plugins/official/mybatis/dist/plugin.wasm differ diff --git a/plugins/official/mybatis/dist/plugin.wasm.sources b/plugins/official/mybatis/dist/plugin.wasm.sources index ca150fb2e..6877e9f91 100644 --- a/plugins/official/mybatis/dist/plugin.wasm.sources +++ b/plugins/official/mybatis/dist/plugin.wasm.sources @@ -1 +1 @@ -dd9021857cce89462f02ca368f67646f695f6cbb0ce9b337ebe081ebb7ef5e42 +b28e0a8603d5108d6d13e00e765b4368dc9dfe6a3eb8d574f692290c9601d188 diff --git a/plugins/official/regex-tester/dist/plugin.wasm b/plugins/official/regex-tester/dist/plugin.wasm index a3dc65418..1d66df963 100644 Binary files a/plugins/official/regex-tester/dist/plugin.wasm and b/plugins/official/regex-tester/dist/plugin.wasm differ diff --git a/plugins/official/regex-tester/dist/plugin.wasm.sources b/plugins/official/regex-tester/dist/plugin.wasm.sources index e6ba5300d..e53a1162f 100644 --- a/plugins/official/regex-tester/dist/plugin.wasm.sources +++ b/plugins/official/regex-tester/dist/plugin.wasm.sources @@ -1 +1 @@ -39b2238bf4ea17e18a504e33fd23b3a9b89fea64802922c724f69b21c6e6650b +0e03a7d68adca58bfab31b21ff3b237d2727a067a9bebe73177b32b2bd9d73c6 diff --git a/plugins/official/solidity/dist/plugin.wasm b/plugins/official/solidity/dist/plugin.wasm index 79cc3226e..4010302fe 100644 Binary files a/plugins/official/solidity/dist/plugin.wasm and b/plugins/official/solidity/dist/plugin.wasm differ diff --git a/plugins/official/solidity/dist/plugin.wasm.sources b/plugins/official/solidity/dist/plugin.wasm.sources index 3331a9d75..bc1925aba 100644 --- a/plugins/official/solidity/dist/plugin.wasm.sources +++ b/plugins/official/solidity/dist/plugin.wasm.sources @@ -1 +1 @@ -1cb9136c2c45c1730cdd83b03aac37eaa03fc9efc4ee924799c515ed7d5dd8a4 +f4edb16e6600f4823ab93c7ec1baea6b79f95323bcbf35998ced5239b5b68670 diff --git a/plugins/official/string-tools/dist/plugin.wasm b/plugins/official/string-tools/dist/plugin.wasm index 40f289f17..a31bb2366 100644 Binary files a/plugins/official/string-tools/dist/plugin.wasm and b/plugins/official/string-tools/dist/plugin.wasm differ diff --git a/plugins/official/string-tools/dist/plugin.wasm.sources b/plugins/official/string-tools/dist/plugin.wasm.sources index 79e1dc875..d3d274f4b 100644 --- a/plugins/official/string-tools/dist/plugin.wasm.sources +++ b/plugins/official/string-tools/dist/plugin.wasm.sources @@ -1 +1 @@ -c1917beaadec01fcb5b9c9e0f5a58ae5a27222fbfcf37679520e3db02c657cf3 +9c07f02ea83bf9d4a39b5861aed0c57c8bb20d5c6043f437e659f0c0960fdcb0 diff --git a/plugins/official/test-runner/dist/plugin.wasm b/plugins/official/test-runner/dist/plugin.wasm index 89c177e30..6cffae201 100644 Binary files a/plugins/official/test-runner/dist/plugin.wasm and b/plugins/official/test-runner/dist/plugin.wasm differ diff --git a/plugins/official/test-runner/dist/plugin.wasm.sources b/plugins/official/test-runner/dist/plugin.wasm.sources index a8acc2d9d..603cd955e 100644 --- a/plugins/official/test-runner/dist/plugin.wasm.sources +++ b/plugins/official/test-runner/dist/plugin.wasm.sources @@ -1 +1 @@ -cae35ef24ad347692d5adac598055a9b2bae7b6ae7593db1b20fcfa0a0054fa8 +0d5a8af3ebaaba02e3f0dd3fb2305b5a582db913232e0fc8a20f62cbd14b9bc4 diff --git a/plugins/official/todo-finder/dist/plugin.wasm b/plugins/official/todo-finder/dist/plugin.wasm index 582008de6..911afccc3 100644 Binary files a/plugins/official/todo-finder/dist/plugin.wasm and b/plugins/official/todo-finder/dist/plugin.wasm differ diff --git a/plugins/official/todo-finder/dist/plugin.wasm.sources b/plugins/official/todo-finder/dist/plugin.wasm.sources index a7e49b006..ce71a99c4 100644 --- a/plugins/official/todo-finder/dist/plugin.wasm.sources +++ b/plugins/official/todo-finder/dist/plugin.wasm.sources @@ -1 +1 @@ -7e8fb4f06edff8bfbedef110b8d4d2bc6219258e74ac61c5a1cb7bbf9a7838e0 +0863a485e05aebe10e66546cf5ee8c54784a0556464c845463a5841018c6599b diff --git a/sdk/rust/openidea-plugin/src/language_features.rs b/sdk/rust/openidea-plugin/src/language_features.rs index 683748f51..7b1c23962 100644 --- a/sdk/rust/openidea-plugin/src/language_features.rs +++ b/sdk/rust/openidea-plugin/src/language_features.rs @@ -88,6 +88,21 @@ pub struct GutterAction { pub command: String, pub argument: Option, } +/// An action rendered at the left edge of a line and revealed by hover. +#[derive(Clone, Debug, PartialEq)] +pub struct HoverAction { + /// The line the button is drawn on; normally the declaration line. + pub line: u32, + /// First line whose leftmost strip reveals this action, inclusive. + pub start_line: u32, + /// Last line whose leftmost strip reveals this action, inclusive. + pub end_line: u32, + pub icon: Option, + pub label: String, + pub tooltip: Option, + pub command: String, + pub argument: Option, +} /// Injection data. #[derive(Clone, Debug, PartialEq)] pub struct Injection { @@ -95,6 +110,15 @@ pub struct Injection { pub language: String, } /// Implement only the kinds declared under contributes.providers. +/// Optional API 1.12 export: actions rendered at the left edge of a line and +/// revealed while the pointer is in the leftmost editing-area strip of their +/// `range`. Export with `register_plugin!(Plugin, hover_actions)`. +pub trait HoverActions { + fn hover_actions(&mut self, _doc: &Document) -> Vec { + Vec::new() + } +} + pub trait LanguageFeatures { fn format( &mut self, diff --git a/sdk/rust/openidea-plugin/src/lib.rs b/sdk/rust/openidea-plugin/src/lib.rs index dec45fd67..9a816e1bf 100644 --- a/sdk/rust/openidea-plugin/src/lib.rs +++ b/sdk/rust/openidea-plugin/src/lib.rs @@ -59,6 +59,7 @@ mod types; pub mod views; pub use host::{Invocation, Project, Task, TextEditor}; +pub use language_features::{HoverAction, HoverActions}; pub use types::*; #[cfg(target_arch = "wasm32")] @@ -87,6 +88,20 @@ pub mod syntax_bindings { }); } +/// The optional `hover-actions` export: clickable actions shown at the +/// left edge of a line while the pointer is in its trigger strip. +#[cfg(target_arch = "wasm32")] +#[doc(hidden)] +pub mod hover_actions_bindings { + wit_bindgen::generate!({ + world: "hover-actions-provider", + path: "wit", + pub_export_macro: true, + export_macro_name: "__export_hover_actions_world", + default_bindings_module: "openidea_plugin::hover_actions_bindings", + }); +} + /// The `editor-providers` world: only the `providers` export, merged with /// `plugin` (world `plugin-providers`). #[cfg(target_arch = "wasm32")] @@ -99,7 +114,7 @@ pub mod providers_bindings { export_macro_name: "__export_editor_providers_world", default_bindings_module: "openidea_plugin::providers_bindings", with: { - "openidea:plugin/types@1.13.0": crate::bindings::openidea::plugin::types, + "openidea:plugin/types@1.14.0": crate::bindings::openidea::plugin::types, }, }); } @@ -116,10 +131,10 @@ pub mod views_bindings { export_macro_name: "__export_views_world", default_bindings_module: "openidea_plugin::views_bindings", with: { - "openidea:plugin/types@1.13.0": crate::bindings::openidea::plugin::types, - "openidea:plugin/workspace@1.13.0": crate::bindings::openidea::plugin::workspace, - "openidea:plugin/editor@1.13.0": crate::bindings::openidea::plugin::editor, - "openidea:plugin/invocation@1.13.0": crate::bindings::openidea::plugin::invocation, + "openidea:plugin/types@1.14.0": crate::bindings::openidea::plugin::types, + "openidea:plugin/workspace@1.14.0": crate::bindings::openidea::plugin::workspace, + "openidea:plugin/editor@1.14.0": crate::bindings::openidea::plugin::editor, + "openidea:plugin/invocation@1.14.0": crate::bindings::openidea::plugin::invocation, }, }); } @@ -131,7 +146,7 @@ pub mod indexing_bindings { world: "indexing", path: "wit", pub_export_macro: true, export_macro_name: "__export_indexing_world", default_bindings_module: "openidea_plugin::indexing_bindings", - with: { "openidea:plugin/types@1.13.0": crate::bindings::openidea::plugin::types }, + with: { "openidea:plugin/types@1.14.0": crate::bindings::openidea::plugin::types }, }); } @@ -143,10 +158,10 @@ pub mod details_bindings { export_macro_name: "__export_details_world", default_bindings_module: "openidea_plugin::details_bindings", with: { - "openidea:plugin/types@1.13.0": crate::bindings::openidea::plugin::types, - "openidea:plugin/workspace@1.13.0": crate::bindings::openidea::plugin::workspace, - "openidea:plugin/editor@1.13.0": crate::bindings::openidea::plugin::editor, - "openidea:plugin/invocation@1.13.0": crate::bindings::openidea::plugin::invocation, + "openidea:plugin/types@1.14.0": crate::bindings::openidea::plugin::types, + "openidea:plugin/workspace@1.14.0": crate::bindings::openidea::plugin::workspace, + "openidea:plugin/editor@1.14.0": crate::bindings::openidea::plugin::editor, + "openidea:plugin/invocation@1.14.0": crate::bindings::openidea::plugin::invocation, }, }); } @@ -158,7 +173,7 @@ pub mod semantic_bindings { world: "semantic-tokens", path: "wit", pub_export_macro: true, export_macro_name: "__export_semantic_tokens_world", default_bindings_module: "openidea_plugin::semantic_bindings", - with: { "openidea:plugin/types@1.13.0": crate::bindings::openidea::plugin::types }, + with: { "openidea:plugin/types@1.14.0": crate::bindings::openidea::plugin::types }, }); } @@ -170,8 +185,8 @@ pub mod diagnostics_bindings { export_macro_name: "__export_diagnostics_world", default_bindings_module: "openidea_plugin::diagnostics_bindings", with: { - "openidea:plugin/types@1.13.0": crate::bindings::openidea::plugin::types, - "openidea:plugin/diagnostics@1.13.0": crate::bindings::openidea::plugin::diagnostics, + "openidea:plugin/types@1.14.0": crate::bindings::openidea::plugin::types, + "openidea:plugin/diagnostics@1.14.0": crate::bindings::openidea::plugin::diagnostics, }, }); } @@ -183,7 +198,7 @@ pub mod hover_bindings { world: "hover", path: "wit", pub_export_macro: true, export_macro_name: "__export_hover_world", default_bindings_module: "openidea_plugin::hover_bindings", - with: { "openidea:plugin/types@1.13.0": crate::bindings::openidea::plugin::types }, + with: { "openidea:plugin/types@1.14.0": crate::bindings::openidea::plugin::types }, }); } @@ -195,11 +210,11 @@ pub mod commit_checks_bindings { export_macro_name: "__export_commit_checks_world", default_bindings_module: "openidea_plugin::commit_checks_bindings", with: { - "openidea:plugin/types@1.13.0": crate::bindings::openidea::plugin::types, - "openidea:plugin/workspace@1.13.0": crate::bindings::openidea::plugin::workspace, - "openidea:plugin/editor@1.13.0": crate::bindings::openidea::plugin::editor, - "openidea:plugin/invocation@1.13.0": crate::bindings::openidea::plugin::invocation, - "openidea:plugin/commit@1.13.0": crate::bindings::openidea::plugin::commit, + "openidea:plugin/types@1.14.0": crate::bindings::openidea::plugin::types, + "openidea:plugin/workspace@1.14.0": crate::bindings::openidea::plugin::workspace, + "openidea:plugin/editor@1.14.0": crate::bindings::openidea::plugin::editor, + "openidea:plugin/invocation@1.14.0": crate::bindings::openidea::plugin::invocation, + "openidea:plugin/commit@1.14.0": crate::bindings::openidea::plugin::commit, }, }); } @@ -211,7 +226,7 @@ pub mod inlay_bindings { world: "inlay-hints", path: "wit", pub_export_macro: true, export_macro_name: "__export_inlay_hints_world", default_bindings_module: "openidea_plugin::inlay_bindings", - with: { "openidea:plugin/types@1.13.0": crate::bindings::openidea::plugin::types }, + with: { "openidea:plugin/types@1.14.0": crate::bindings::openidea::plugin::types }, }); } @@ -222,7 +237,7 @@ pub mod file_actions_bindings { world: "file-actions-provider", path: "wit", pub_export_macro: true, export_macro_name: "__export_file_actions_world", default_bindings_module: "openidea_plugin::file_actions_bindings", - with: { "openidea:plugin/types@1.13.0": crate::bindings::openidea::plugin::types }, + with: { "openidea:plugin/types@1.14.0": crate::bindings::openidea::plugin::types }, }); } @@ -234,10 +249,10 @@ pub mod endpoints_bindings { export_macro_name: "__export_endpoints_world", default_bindings_module: "openidea_plugin::endpoints_bindings", with: { - "openidea:plugin/types@1.13.0": crate::bindings::openidea::plugin::types, - "openidea:plugin/workspace@1.13.0": crate::bindings::openidea::plugin::workspace, - "openidea:plugin/editor@1.13.0": crate::bindings::openidea::plugin::editor, - "openidea:plugin/invocation@1.13.0": crate::bindings::openidea::plugin::invocation, + "openidea:plugin/types@1.14.0": crate::bindings::openidea::plugin::types, + "openidea:plugin/workspace@1.14.0": crate::bindings::openidea::plugin::workspace, + "openidea:plugin/editor@1.14.0": crate::bindings::openidea::plugin::editor, + "openidea:plugin/invocation@1.14.0": crate::bindings::openidea::plugin::invocation, }, }); } @@ -250,16 +265,16 @@ pub mod search_bindings { export_macro_name: "__export_search_world", default_bindings_module: "openidea_plugin::search_bindings", with: { - "openidea:plugin/types@1.13.0": crate::bindings::openidea::plugin::types, - "openidea:plugin/workspace@1.13.0": crate::bindings::openidea::plugin::workspace, - "openidea:plugin/editor@1.13.0": crate::bindings::openidea::plugin::editor, - "openidea:plugin/invocation@1.13.0": crate::bindings::openidea::plugin::invocation, + "openidea:plugin/types@1.14.0": crate::bindings::openidea::plugin::types, + "openidea:plugin/workspace@1.14.0": crate::bindings::openidea::plugin::workspace, + "openidea:plugin/editor@1.14.0": crate::bindings::openidea::plugin::editor, + "openidea:plugin/invocation@1.14.0": crate::bindings::openidea::plugin::invocation, }, }); } /// The plugin API version this SDK targets. -pub const API_VERSION: &str = "1.13"; +pub const API_VERSION: &str = "1.14"; /// A plugin. One instance lives as long as the plugin's Wasm instance (until /// it is disabled, crashes or is reclaimed when idle). @@ -326,6 +341,9 @@ macro_rules! __optional_exports { (file_actions, $plugin:ty, $component:ident) => { $crate::__file_actions_exports!($plugin, $component); }; + (hover_actions, $plugin:ty, $component:ident) => { + $crate::__hover_actions_exports!($plugin, $component); + }; (search, $plugin:ty, $component:ident) => { $crate::__search_exports!($plugin, $component); }; (endpoints, $plugin:ty, $component:ident) => { $crate::__endpoints_exports!($plugin, $component); @@ -376,6 +394,51 @@ macro_rules! __optional_exports { }; } +/// `register_plugin!(T, hover_actions)`: `T` also exports +/// [`HoverActions`](crate::HoverActions). +#[cfg(target_arch = "wasm32")] +#[doc(hidden)] +#[macro_export] +macro_rules! __hover_actions_exports { + ($plugin:ty, $component:ident) => { + impl $crate::hover_actions_bindings::exports::openidea::plugin::hover_actions::Guest + for $component + { + fn hover_actions( + doc: $crate::hover_actions_bindings::exports::openidea::plugin::hover_actions::Document, + ) -> ::std::vec::Vec< + $crate::hover_actions_bindings::exports::openidea::plugin::hover_actions::HoverAction, + > { + let d = $crate::providers::Document { + path: doc.path.clone(), + language: doc.language.clone(), + version: doc.version, + text: doc.text.clone(), + }; + let result = $crate::__rt::with::<$plugin, _>(|p| p.hover_actions(&d)); + result + .into_iter() + .map(|v| { + $crate::hover_actions_bindings::exports::openidea::plugin::hover_actions::HoverAction { + line: v.line, + start_line: v.start_line, + end_line: v.end_line, + icon: v.icon, + label: v.label, + tooltip: v.tooltip, + command: v.command, + argument: v.argument, + } + }) + .collect() + } + } + $crate::hover_actions_bindings::__export_hover_actions_world!( + $component with_types_in $crate::hover_actions_bindings + ); + }; +} + /// `register_plugin!(T, providers)`: `T` is also a [`providers::Providers`]. #[doc(hidden)] #[macro_export] @@ -693,7 +756,7 @@ pub mod __rt { static INSTANCE: RefCell>> = const { RefCell::new(None) }; } - pub(crate) fn with(f: impl FnOnce(&mut T) -> R) -> R { + pub fn with(f: impl FnOnce(&mut T) -> R) -> R { INSTANCE.with(|cell| { let mut slot = cell.borrow_mut(); let plugin = slot.get_or_insert_with(|| Box::new(T::default())); @@ -1409,7 +1472,7 @@ pub mod run_configurations_bindings { pub mod launch_configurations_bindings { wit_bindgen::generate!({ world: "launch-configurations-provider", path: "wit", pub_export_macro: true, export_macro_name: "__export_launch_configurations_world", default_bindings_module: "openidea_plugin::launch_configurations_bindings", - with: { "openidea:plugin/types@1.13.0": crate::bindings::openidea::plugin::types }, + with: { "openidea:plugin/types@1.14.0": crate::bindings::openidea::plugin::types }, }); } #[cfg(target_arch = "wasm32")] @@ -1417,7 +1480,7 @@ pub mod launch_configurations_bindings { pub mod test_results_bindings { wit_bindgen::generate!({ world: "test-results-provider", path: "wit", pub_export_macro: true, export_macro_name: "__export_tests_world", default_bindings_module: "openidea_plugin::test_results_bindings", - with: { "openidea:plugin/types@1.13.0": crate::bindings::openidea::plugin::types }, + with: { "openidea:plugin/types@1.14.0": crate::bindings::openidea::plugin::types }, }); } #[doc(hidden)] @@ -1467,7 +1530,7 @@ pub mod language_features; pub mod language_features_bindings { wit_bindgen::generate!({world: "editor-language-features", path: "wit", pub_export_macro: true, export_macro_name: "__export_language_features_world", default_bindings_module: "openidea_plugin::language_features_bindings", - with: { "openidea:plugin/types@1.13.0": crate::bindings::openidea::plugin::types }, + with: { "openidea:plugin/types@1.14.0": crate::bindings::openidea::plugin::types }, }); } @@ -1499,7 +1562,7 @@ fn gutter_actions(doc: $crate::language_features_bindings::exports::openidea::pl pub mod injections_bindings { wit_bindgen::generate!({world: "language-injections", path: "wit", pub_export_macro: true, export_macro_name: "__export_injections_world", default_bindings_module: "openidea_plugin::injections_bindings", - with: { "openidea:plugin/types@1.13.0": crate::bindings::openidea::plugin::types }, + with: { "openidea:plugin/types@1.14.0": crate::bindings::openidea::plugin::types }, }); } @@ -1529,8 +1592,8 @@ pub mod mcp_bindings { wit_bindgen::generate!({ world: "mcp-tools", path: "wit", pub_export_macro: true, export_macro_name: "__export_mcp_world", default_bindings_module: "openidea_plugin::mcp_bindings", with: { - "openidea:plugin/types@1.13.0": crate::bindings::openidea::plugin::types, - "openidea:plugin/invocation@1.13.0": crate::bindings::openidea::plugin::invocation, + "openidea:plugin/types@1.14.0": crate::bindings::openidea::plugin::types, + "openidea:plugin/invocation@1.14.0": crate::bindings::openidea::plugin::invocation, }, }); } diff --git a/sdk/rust/openidea-plugin/wit/commit.wit b/sdk/rust/openidea-plugin/wit/commit.wit index 763911ad5..0b3b8fc24 100644 --- a/sdk/rust/openidea-plugin/wit/commit.wit +++ b/sdk/rust/openidea-plugin/wit/commit.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// The commit being prepared in the window the current command or event came /// from (the Commit tool window, or the Commit dialog while it is open): the diff --git a/sdk/rust/openidea-plugin/wit/database.wit b/sdk/rust/openidea-plugin/wit/database.wit index 379266834..ea5b543a2 100644 --- a/sdk/rust/openidea-plugin/wit/database.wit +++ b/sdk/rust/openidea-plugin/wit/database.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Plugin-owned project data sources. Requires database.sources and project trust. /// Runs on the Database subsystem's host, including on remote project servers. diff --git a/sdk/rust/openidea-plugin/wit/decorations.wit b/sdk/rust/openidea-plugin/wit/decorations.wit index a291643cb..96c543ae3 100644 --- a/sdk/rust/openidea-plugin/wit/decorations.wit +++ b/sdk/rust/openidea-plugin/wit/decorations.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Editor and project-tree decorations (API 1.4). Requires project.read. An editor set /// follows its file: the file's own project, or the nearest one when it is outside them all. diff --git a/sdk/rust/openidea-plugin/wit/details.wit b/sdk/rust/openidea-plugin/wit/details.wit index 3ebf0eea0..3363dc99c 100644 --- a/sdk/rust/openidea-plugin/wit/details.wit +++ b/sdk/rust/openidea-plugin/wit/details.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// What the pane beside the Services tree shows for a plugin's node. interface detail-types { diff --git a/sdk/rust/openidea-plugin/wit/diagnostics.wit b/sdk/rust/openidea-plugin/wit/diagnostics.wit index 72a5b5ceb..32f1a9188 100644 --- a/sdk/rust/openidea-plugin/wit/diagnostics.wit +++ b/sdk/rust/openidea-plugin/wit/diagnostics.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Optional export (world `plugin-diagnostics`): problems in the current, /// possibly unsaved document, for the languages declared with the diff --git a/sdk/rust/openidea-plugin/wit/endpoints.wit b/sdk/rust/openidea-plugin/wit/endpoints.wit index 0aca4c9ac..44b7c6d79 100644 --- a/sdk/rust/openidea-plugin/wit/endpoints.wit +++ b/sdk/rust/openidea-plugin/wit/endpoints.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// HTTP endpoints found in a project (`[[contributes.endpoints]]`). interface endpoints-provider { diff --git a/sdk/rust/openidea-plugin/wit/events.wit b/sdk/rust/openidea-plugin/wit/events.wit index 27b0639f8..ca11daa53 100644 --- a/sdk/rust/openidea-plugin/wit/events.wit +++ b/sdk/rust/openidea-plugin/wit/events.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Workbench events, delivered in batches to `event-handler.handle`. interface events { diff --git a/sdk/rust/openidea-plugin/wit/exports.wit b/sdk/rust/openidea-plugin/wit/exports.wit index 173fe19cd..15858b5be 100644 --- a/sdk/rust/openidea-plugin/wit/exports.wit +++ b/sdk/rust/openidea-plugin/wit/exports.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; interface lifecycle { use types.{context, error}; diff --git a/sdk/rust/openidea-plugin/wit/extensions.wit b/sdk/rust/openidea-plugin/wit/extensions.wit index d2b73648a..aa2cc9d09 100644 --- a/sdk/rust/openidea-plugin/wit/extensions.wit +++ b/sdk/rust/openidea-plugin/wit/extensions.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// What other plugins contributed to the extension points this plugin declares /// (`[[extension-points]]` in `plugin.toml`; the contributors list this plugin diff --git a/sdk/rust/openidea-plugin/wit/file-actions.wit b/sdk/rust/openidea-plugin/wit/file-actions.wit index 9de9084f9..175d54247 100644 --- a/sdk/rust/openidea-plugin/wit/file-actions.wit +++ b/sdk/rust/openidea-plugin/wit/file-actions.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Optional export (world `plugin-file-actions`): quick fixes and /// refactorings that create, rename or delete files, next to the text edits diff --git a/sdk/rust/openidea-plugin/wit/fs.wit b/sdk/rust/openidea-plugin/wit/fs.wit index fc70f83d1..80f29f67a 100644 --- a/sdk/rust/openidea-plugin/wit/fs.wit +++ b/sdk/rust/openidea-plugin/wit/fs.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Files outside the open projects: the configuration of the program a /// plugin integrates with, a tool installed elsewhere, a licence file. diff --git a/sdk/rust/openidea-plugin/wit/host.wit b/sdk/rust/openidea-plugin/wit/host.wit index 022f611f4..c47ec8243 100644 --- a/sdk/rust/openidea-plugin/wit/host.wit +++ b/sdk/rust/openidea-plugin/wit/host.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Writes to the IDE log, tagged with the plugin id. interface log { diff --git a/sdk/rust/openidea-plugin/wit/hover-actions.wit b/sdk/rust/openidea-plugin/wit/hover-actions.wit new file mode 100644 index 000000000..b58630b60 --- /dev/null +++ b/sdk/rust/openidea-plugin/wit/hover-actions.wit @@ -0,0 +1,40 @@ +package openidea:plugin@1.14.0; + +/// Optional export (world `plugin-hover-actions`): clickable actions rendered +/// at the left edge of a line and revealed while the pointer is in the leftmost +/// editing-area strip of the action's line range. +interface hover-actions { + use language-features.{document}; + + /// An action drawn at the left edge of `line`. + record hover-action { + /// The line the button is drawn on; normally the declaration line. + line: u32, + /// First line whose left strip reveals this action, inclusive. + start-line: u32, + /// Last line whose left strip reveals this action, inclusive. + end-line: u32, + /// Optional icon: a registered icon name or a declared manifest SVG path. + icon: option, + /// Text shown when no icon is present, or beside the icon. + label: string, + tooltip: option, + /// This plugin's declared command. + command: string, + argument: option, + } + + /// Actions for the visible document, under the editor-provider budget. + hover-actions: func(doc: document) -> list; +} + +/// The optional export-only world the SDK merges with `plugin`. +world hover-actions-provider { + export hover-actions; +} + +/// The host-side world used to instantiate a component that exports it. +world plugin-hover-actions { + include plugin; + export hover-actions; +} diff --git a/sdk/rust/openidea-plugin/wit/hover.wit b/sdk/rust/openidea-plugin/wit/hover.wit index c483d3df9..4a5bdad66 100644 --- a/sdk/rust/openidea-plugin/wit/hover.wit +++ b/sdk/rust/openidea-plugin/wit/hover.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Optional export (world `plugin-hover`): Markdown added to the hover of /// documents of the languages declared with the `hover` provider kind, diff --git a/sdk/rust/openidea-plugin/wit/indexing.wit b/sdk/rust/openidea-plugin/wit/indexing.wit index 727edfb77..9b2e9d5aa 100644 --- a/sdk/rust/openidea-plugin/wit/indexing.wit +++ b/sdk/rust/openidea-plugin/wit/indexing.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Cross-file associations a plugin publishes for the files it declares under /// `[[contributes.documentIndexers]]`. The host calls `index` in cancellable diff --git a/sdk/rust/openidea-plugin/wit/injections.wit b/sdk/rust/openidea-plugin/wit/injections.wit index 7570a6fb3..f9d56dbe1 100644 --- a/sdk/rust/openidea-plugin/wit/injections.wit +++ b/sdk/rust/openidea-plugin/wit/injections.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Embedded languages. The host routes plugin providers and configured language /// servers inside these ranges, preserving host-document UTF-16 coordinates. diff --git a/sdk/rust/openidea-plugin/wit/inlay.wit b/sdk/rust/openidea-plugin/wit/inlay.wit index aa58c6207..cfbb93b94 100644 --- a/sdk/rust/openidea-plugin/wit/inlay.wit +++ b/sdk/rust/openidea-plugin/wit/inlay.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Optional export (world `plugin-inlay-hints`): inline hints in documents of /// the languages declared with the `inlay-hints` provider kind, including diff --git a/sdk/rust/openidea-plugin/wit/io.wit b/sdk/rust/openidea-plugin/wit/io.wit index 1ebe516ce..829adfff0 100644 --- a/sdk/rust/openidea-plugin/wit/io.wit +++ b/sdk/rust/openidea-plugin/wit/io.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Problems in files, shown in the editor and the Problems view. interface diagnostics { diff --git a/sdk/rust/openidea-plugin/wit/language-features.wit b/sdk/rust/openidea-plugin/wit/language-features.wit index ea49b0cdc..47aa04b22 100644 --- a/sdk/rust/openidea-plugin/wit/language-features.wit +++ b/sdk/rust/openidea-plugin/wit/language-features.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Additional language features, called only for declared API 1.4 provider kinds. /// Editor calls have a 50 ms soft / 500 ms hard budget; formatting has 5 seconds. diff --git a/sdk/rust/openidea-plugin/wit/mcp.wit b/sdk/rust/openidea-plugin/wit/mcp.wit index b65527ab5..c07d71583 100644 --- a/sdk/rust/openidea-plugin/wit/mcp.wit +++ b/sdk/rust/openidea-plugin/wit/mcp.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Discovery of the IDE's built-in MCP server; never exposes its URL or token. interface mcp { diff --git a/sdk/rust/openidea-plugin/wit/plugin.wit b/sdk/rust/openidea-plugin/wit/plugin.wit index 9248969e9..c777abda8 100644 --- a/sdk/rust/openidea-plugin/wit/plugin.wit +++ b/sdk/rust/openidea-plugin/wit/plugin.wit @@ -8,7 +8,7 @@ /// `fs` and `workspace`, and everything else goes through the imports below, /// gated by the capabilities granted in `plugin.toml` (a missing one returns /// `error::denied`). -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; world plugin { import log; diff --git a/sdk/rust/openidea-plugin/wit/providers.wit b/sdk/rust/openidea-plugin/wit/providers.wit index 287bf5fa7..b8f4d25fb 100644 --- a/sdk/rust/openidea-plugin/wit/providers.wit +++ b/sdk/rust/openidea-plugin/wit/providers.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Editor features a plugin provides for the languages it declares under /// `[[contributes.providers]]` (the host calls only declared kinds). They run diff --git a/sdk/rust/openidea-plugin/wit/run-targets.wit b/sdk/rust/openidea-plugin/wit/run-targets.wit index 43af1f11b..eaf7caa4b 100644 --- a/sdk/rust/openidea-plugin/wit/run-targets.wit +++ b/sdk/rust/openidea-plugin/wit/run-targets.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Project-scoped targets owned by the registering plugin (API 1.4). interface run-targets { diff --git a/sdk/rust/openidea-plugin/wit/run.wit b/sdk/rust/openidea-plugin/wit/run.wit index 040c0a7d4..2d9984066 100644 --- a/sdk/rust/openidea-plugin/wit/run.wit +++ b/sdk/rust/openidea-plugin/wit/run.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Launches this plugin's configurations in the invoking window's Run tool window. interface run { diff --git a/sdk/rust/openidea-plugin/wit/search.wit b/sdk/rust/openidea-plugin/wit/search.wit index 020c9404d..ca2ef675b 100644 --- a/sdk/rust/openidea-plugin/wit/search.wit +++ b/sdk/rust/openidea-plugin/wit/search.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// On-demand results for `[[contributes.searchCategories]]`. Optional, API 1.13. interface search-provider { diff --git a/sdk/rust/openidea-plugin/wit/semantic.wit b/sdk/rust/openidea-plugin/wit/semantic.wit index 521f12b70..9fd28437d 100644 --- a/sdk/rust/openidea-plugin/wit/semantic.wit +++ b/sdk/rust/openidea-plugin/wit/semantic.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Optional export (world `plugin-semantic-tokens`): semantic colouring of /// documents of the languages declared with the `semantic-tokens` provider diff --git a/sdk/rust/openidea-plugin/wit/types.wit b/sdk/rust/openidea-plugin/wit/types.wit index a6c7ae278..0300c273b 100644 --- a/sdk/rust/openidea-plugin/wit/types.wit +++ b/sdk/rust/openidea-plugin/wit/types.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Shared types. Positions are 0-based lines and UTF-16 code unit columns, /// as in the editor and LSP. diff --git a/sdk/rust/openidea-plugin/wit/views.wit b/sdk/rust/openidea-plugin/wit/views.wit index 81d06ad18..02745a11e 100644 --- a/sdk/rust/openidea-plugin/wit/views.wit +++ b/sdk/rust/openidea-plugin/wit/views.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Declarative views: tool windows declared /// under `[[contributes.views]]` and custom editors under diff --git a/sdk/rust/openidea-plugin/wit/workspace.wit b/sdk/rust/openidea-plugin/wit/workspace.wit index 7e12d4c54..ff5b00105 100644 --- a/sdk/rust/openidea-plugin/wit/workspace.wit +++ b/sdk/rust/openidea-plugin/wit/workspace.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; interface workspace { use types.{error, location}; diff --git a/src/bindings.ts b/src/bindings.ts index 01900b953..1eedfdc19 100644 --- a/src/bindings.ts +++ b/src/bindings.ts @@ -6878,6 +6878,21 @@ export type Hover = { range: Range | null, }; +/** An action rendered at the left edge of a line and revealed by hover. */ +export type HoverAction = { + /** The line the button is drawn on; normally the declaration line. */ + line: number, + /** First line whose leftmost strip reveals this action, inclusive. */ + startLine: number, + /** Last line whose leftmost strip reveals this action, inclusive. */ + endLine: number, + icon: string | null, + label: string, + tooltip: string | null, + command: string, + argument: string | null, +}; + /** One request with its outcome. */ export type HttpExchange = { entry: HttpHistoryEntry, @@ -9392,6 +9407,7 @@ export type PluginLanguageVisuals = { injections: Injection[], colors: ([string, ColorInfo])[], gutterActions: ([string, GutterAction])[], + hoverActions: ([string, HoverAction])[], }; export type PluginLocation = { diff --git a/src/editor/core/controller.ts b/src/editor/core/controller.ts index 2c533097b..e0c12c95c 100644 --- a/src/editor/core/controller.ts +++ b/src/editor/core/controller.ts @@ -50,6 +50,7 @@ import { t, tx } from "@/platform/i18n"; import { call, commands, isTauri } from "@/platform/ipc"; import { openLightweightEditor } from "./openLightweightEditor"; import { windowBackgroundHex } from "@/workbench/theme"; +import { hoverActionsAt } from "@/platform/hoverActions"; import { save as saveFileDialog, type DialogFilter as SaveDialogFilter } from "@/platform/dialog"; import { isUntitledUri, untitledTitle } from "@/platform/virtualDocs"; import { isRemoteWindow } from "@/platform/remote"; @@ -864,8 +865,23 @@ export class EditorController implements SlotHost { if (pos !== null && !view.state.selection.ranges.some((r) => r.from <= pos && pos <= r.to)) view.dispatch({ selection: EditorSelection.cursor(pos) }); const hasSel = !view.state.selection.main.empty; + const caretLine = view.state.doc.lineAt(view.state.selection.main.head).number - 1; + const hoverItems: MenuItem[] = hoverActionsAt(slot.model.doc, caretLine).map(({ plugin, action }) => ({ + label: action.label, + verbatim: true, + icon: "run", + run: () => + void call( + commands.lspExecuteCommand(slot.model.doc, { + title: action.tooltip ?? action.label, + command: `openidea.plugin-language:${plugin}:${action.command}`, + arguments: [JSON.stringify(action.argument)], + }), + ).catch(console.warn), + })); const items: MenuItem[] = [ { kind: "action", action: "code.showIntentions", label: "Show Context Actions", icon: "bulb" }, + ...(hoverItems.length ? ([{ kind: "separator" }, ...hoverItems] as MenuItem[]) : []), { kind: "separator" }, // Like IDEA, Cut / Copy only with a selection. ...((hasSel diff --git a/src/editor/lsp/intentions.ts b/src/editor/lsp/intentions.ts index 4ff303bc3..12233191b 100644 --- a/src/editor/lsp/intentions.ts +++ b/src/editor/lsp/intentions.ts @@ -757,10 +757,14 @@ const bulbPlugin = ViewPlugin.fromClass( */ const BULB_COLUMNS = 3; -export function bulbLine(state: EditorView["state"], line: number): { line: number; gutter: boolean } { +export function bulbLine( + state: EditorView["state"], + line: number, + avoidLine?: number, +): { line: number; gutter: boolean } { const doc = state.doc; const free = (n: number) => { - if (n < 1 || n > doc.lines) return false; + if (n < 1 || n > doc.lines || n === avoidLine) return false; const text = doc.line(n).text; return text.length - text.trimStart().length >= BULB_COLUMNS || !text.trim(); }; @@ -786,9 +790,13 @@ class FloatingBulb { void showIntentions(this.view); }); view.scrollDOM.appendChild(this.dom); + view.scrollDOM.addEventListener("openidea-hover-actions", this.onInlineAction); this.place(); } + /** An hover action group asked for the anchor line; use the bulb's fallback. */ + private readonly onInlineAction = () => this.place(); + update(u: ViewUpdate) { const bulb = u.state.field(bulbField, false) ?? null; if (bulb !== this.shown || u.geometryChanged || u.viewportChanged) this.place(); @@ -807,7 +815,8 @@ class FloatingBulb { this.view.requestMeasure({ key: this, read: (view) => { - const at = bulbLine(view.state, bulb.line); + const reserved = Number(view.scrollDOM.dataset.hoverActionLine); + const at = bulbLine(view.state, bulb.line, Number.isFinite(reserved) ? reserved : undefined); const line = view.state.doc.line(at.line); const content = view.contentDOM.getBoundingClientRect(); const scroller = view.scrollDOM.getBoundingClientRect(); @@ -833,6 +842,7 @@ class FloatingBulb { } destroy() { + this.view.scrollDOM.removeEventListener("openidea-hover-actions", this.onInlineAction); this.dom.remove(); } } diff --git a/src/features/plugins/HoverActions.module.css b/src/features/plugins/HoverActions.module.css new file mode 100644 index 000000000..d3a124b05 --- /dev/null +++ b/src/features/plugins/HoverActions.module.css @@ -0,0 +1,70 @@ +.layer { + position: absolute; + z-index: 24; + display: flex; + align-items: center; + gap: 1px; + pointer-events: none; + opacity: 0; + transition: opacity 90ms ease-out; +} + +.layer[data-visible="true"] { + pointer-events: auto; + opacity: 1; +} + +.button, +.overflow { + height: 16px; + padding: 0; + display: flex; + align-items: center; + justify-content: center; + border: 0; + border-radius: var(--radius-small); + background: transparent; + color: var(--fg-muted); + font-family: var(--font-ui); + font-size: var(--fs-small); + cursor: pointer; +} + +.button { + width: 16px; +} + +.overflow { + width: 18px; +} + +.button:has(.label) { + width: auto; + padding: 0 4px; +} + +.button:hover, +.button:focus-visible, +.overflow:hover, +.overflow:focus-visible { + background: var(--bg-hover); + color: var(--fg); +} + +.button svg { + width: 14px; + height: 14px; + opacity: 0.8; +} + +.button:hover svg, +.button:focus-visible svg { + opacity: 1; +} + +.label { + max-width: 180px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} diff --git a/src/features/plugins/hoverActions.test.ts b/src/features/plugins/hoverActions.test.ts new file mode 100644 index 000000000..e3e775d49 --- /dev/null +++ b/src/features/plugins/hoverActions.test.ts @@ -0,0 +1,37 @@ +import { describe, expect, it } from "vitest"; +import { matchesLine, matchingActions, type PlacedHoverAction } from "./hoverActions"; + +function action(line: number, endLine: number, label: string): PlacedHoverAction { + return { + plugin: "test", + action: { + line, + startLine: line, + endLine, + icon: "run", + label, + tooltip: label, + command: "run", + argument: null, + }, + }; +} + +describe("inline editor actions", () => { + it("matches lines inside a method range including the declaration line", () => { + const outer = action(5, 12, "outer"); + expect(matchesLine(outer.action, 5)).toBe(true); + expect(matchesLine(outer.action, 9)).toBe(true); + expect(matchesLine(outer.action, 12)).toBe(true); + expect(matchesLine(outer.action, 4)).toBe(false); + expect(matchesLine(outer.action, 13)).toBe(false); + }); + + it("prefers the innermost overlapping range", () => { + const outer = action(5, 20, "outer"); + const inner = action(8, 10, "inner"); + expect(matchingActions([outer, inner], 9).map((a) => a.action.label)).toEqual(["inner"]); + expect(matchingActions([outer, inner], 15).map((a) => a.action.label)).toEqual(["outer"]); + expect(matchingActions([outer, inner], 30)).toEqual([]); + }); +}); diff --git a/src/features/plugins/hoverActions.ts b/src/features/plugins/hoverActions.ts new file mode 100644 index 000000000..ee539a067 --- /dev/null +++ b/src/features/plugins/hoverActions.ts @@ -0,0 +1,348 @@ +/** + * Hover-revealed inline editor actions (API 1.14). + * + * The host decides which action matches a line. This layer implements the + * editor-local parts of the interaction: + * - only the leftmost editing-area strip of a line is a trigger; + * - leaving the editing area to the left keeps the action visible; + * - entering the editing area to the right of the strip hides it; + * - the action is anchored to the action's `line`, not the hovered + * line, so hovering a method body shows the button at its declaration. + */ +import type { EditorView } from "@codemirror/view"; + +import { call, commands, type HoverAction } from "@/platform/ipc"; +import type { EditorDocContext } from "@/editor/api"; +import { markerIcon } from "./lineMarkerGutter"; +import { gutterIconMarkup } from "@/ui/icons"; +import { setHoverActions } from "@/platform/hoverActions"; +import { tx } from "@/platform/i18n"; +import { showContextMenu } from "@/ui"; +import styles from "./HoverActions.module.css"; + +export type PlacedHoverAction = { plugin: string; action: HoverAction }; + +/** Host-owned approximate width of the narrow left trigger strip, in character + * widths. The exact width belongs to the host; the reference is about four + * characters and adapts to the editor's font and zoom. */ +export const HOST_TRIGGER_STRIP_CHARS = 4; + +/** Whether a line belongs to an action's trigger range. */ +export function matchesLine(action: HoverAction, line: number): boolean { + return action.startLine <= line && line <= action.endLine; +} + +/** The innermost matching action wins, as when finding the innermost method. */ +export function matchingActions(actions: readonly PlacedHoverAction[], line: number): PlacedHoverAction[] { + const matches = actions.filter(({ action }) => matchesLine(action, line)); + if (!matches.length) return []; + const span = ({ action }: PlacedHoverAction) => action.endLine - action.startLine; + const smallest = Math.min(...matches.map(span)); + return matches.filter((match) => span(match) === smallest); +} + +class HoverActionLayer { + private readonly root: HTMLDivElement; + private placed: PlacedHoverAction[] = []; + private shown: PlacedHoverAction[] = []; + private visible = false; + private readonly onMove = (event: MouseEvent) => this.handleMove(event); + private readonly onScroll = () => this.reposition(); + private readonly onResize = () => this.reposition(); + private readonly onFocusIn = (event: FocusEvent) => { + if (event.target instanceof Node && this.root.contains(event.target)) this.setVisible(true); + }; + private readonly onWindowBlur = () => this.forceHide(); + private readonly onVisibilityChange = () => { + if (document.visibilityState === "hidden") this.forceHide(); + }; + private readonly onFocusOut = (event: FocusEvent) => { + const next = event.relatedTarget; + if (next instanceof Node && (this.root.contains(next) || this.view.dom.contains(next))) return; + this.forceHide(); + }; + + constructor( + private readonly view: EditorView, + private readonly ctx: EditorDocContext, + ) { + this.root = document.createElement("div"); + this.root.className = `${styles.layer} cm-plugin-hover-actions`; + this.root.dataset.visible = "false"; + this.root.setAttribute("role", "group"); + this.root.setAttribute("aria-label", tx`Hover actions`); + view.dom.appendChild(this.root); + view.contentDOM.addEventListener("mousemove", this.onMove); + view.scrollDOM.addEventListener("scroll", this.onScroll, { passive: true }); + window.addEventListener("resize", this.onResize); + this.root.addEventListener("focusin", this.onFocusIn); + this.view.dom.addEventListener("focusout", this.onFocusOut); + window.addEventListener("blur", this.onWindowBlur); + document.addEventListener("visibilitychange", this.onVisibilityChange); + } + + set(actions: readonly PlacedHoverAction[]) { + const next = [...actions]; + const signature = next + .map(({ plugin, action }) => `${plugin}:${action.command}:${action.line}:${action.label}`) + .join("|"); + if ( + signature === + this.placed.map(({ plugin, action }) => `${plugin}:${action.command}:${action.line}:${action.label}`).join("|") + ) { + this.placed = next; + setHoverActions(this.ctx.doc, next); + return; + } + // A provider refresh must not yank the action out from under keyboard focus. + if (this.root.contains(document.activeElement)) { + this.placed = next; + setHoverActions(this.ctx.doc, next); + return; + } + this.placed = next; + setHoverActions(this.ctx.doc, next); + this.clear(); + } + + private stripWidth(): number { + const width = (this.view as EditorView & { defaultCharacterWidth?: number }).defaultCharacterWidth ?? 8; + return width * HOST_TRIGGER_STRIP_CHARS; + } + + /** Keep the host intention bulb out of this anchor line's rail. */ + private reserveLine(line: number | null) { + const scroll = this.view.scrollDOM; + const next = line == null ? "" : String(line + 1); + if ((scroll.dataset.hoverActionLine ?? "") === next) return; + if (line == null) delete scroll.dataset.hoverActionLine; + else scroll.dataset.hoverActionLine = String(line + 1); + scroll.dispatchEvent(new Event("openidea-hover-actions")); + } + + /** Space before the first non-space character on the anchor line. The + * action must stay left of the text; a line with no room gets no overlay. */ + private availableWidth(line: number): number { + const docLine = this.view.state.doc.line(line + 1); + const indent = docLine.text.length - docLine.text.trimStart().length; + const characterWidth = (this.view as EditorView & { defaultCharacterWidth?: number }).defaultCharacterWidth ?? 8; + const coords = this.view.coordsAtPos(docLine.from + indent); + const content = this.view.contentDOM.getBoundingClientRect(); + const width = coords ? coords.left - content.left : indent * characterWidth; + return Math.max(0, width - 4); + } + + private handleMove(event: MouseEvent) { + const content = this.view.contentDOM; + if (!(event.target instanceof Node) || !content.contains(event.target)) { + // Left the editing area (for example into the gutter): keep the hint. + return; + } + const rect = content.getBoundingClientRect(); + if (event.clientX - rect.left > this.stripWidth()) { + this.hide(); + return; + } + const pos = this.view.posAtCoords({ x: event.clientX, y: event.clientY }); + const line = pos == null ? null : this.view.state.doc.lineAt(pos).number - 1; + const matches = line == null ? [] : matchingActions(this.placed, line); + if (!matches.length) { + this.hide(); + return; + } + this.show(matches); + } + + private show(matches: readonly PlacedHoverAction[]) { + this.reserveLine(matches[0]!.action.line); + const signature = matches + .map(({ plugin, action }) => `${plugin}:${action.command}:${action.line}:${action.label}`) + .join("|"); + if (signature !== this.currentSignature()) this.render(matches); + if (!this.root.childElementCount) { + this.shown = []; + this.setVisible(false); + return; + } + this.shown = [...matches]; + this.setVisible(true); + this.reposition(); + } + + private currentSignature(): string { + return this.shown + .map(({ plugin, action }) => `${plugin}:${action.command}:${action.line}:${action.label}`) + .join("|"); + } + + private render(matches: readonly PlacedHoverAction[]) { + this.root.replaceChildren(); + const anchorLine = matches[0]!.action.line; + const available = this.availableWidth(anchorLine); + const gap = 3; + const width = 16; + const overflowWidth = 18; + let visible = matches.length; + let overflow = false; + const group = (count: number, withOverflow: boolean) => + count * width + Math.max(0, count - 1) * gap + (withOverflow ? (count ? gap : 0) + overflowWidth : 0); + if (group(matches.length, false) > available) { + if (matches.length > 1 && group(1, true) <= available) { + visible = 1; + overflow = true; + } else if (overflowWidth <= available) { + visible = 0; + overflow = true; + } else { + visible = 0; + } + } + for (const match of matches.slice(0, visible)) this.appendAction(match); + if (overflow) this.appendOverflow(matches); + } + + private runAction(plugin: string, action: HoverAction) { + void call( + commands.lspExecuteCommand(this.ctx.doc, { + title: action.tooltip ?? action.label, + command: `openidea.plugin-language:${plugin}:${action.command}`, + arguments: [JSON.stringify(action.argument)], + }), + ).catch(console.warn); + } + + private appendAction({ plugin, action }: PlacedHoverAction) { + const button = document.createElement("button"); + button.type = "button"; + button.className = `${styles.button} cm-plugin-hover-action`; + button.title = action.tooltip ?? action.label; + button.setAttribute("aria-label", action.label || action.tooltip || tx`Hover action`); + const icon = action.icon ? gutterIconMarkup(markerIcon(action.icon)) : null; + if (icon) button.innerHTML = icon; + else { + const label = document.createElement("span"); + label.className = styles.label ?? "cm-plugin-hover-action-label"; + label.textContent = action.label; + button.appendChild(label); + } + button.addEventListener("mousedown", (event) => event.preventDefault()); + button.addEventListener("click", (event) => { + event.preventDefault(); + event.stopPropagation(); + this.runAction(plugin, action); + }); + this.root.appendChild(button); + } + + private appendOverflow(matches: readonly PlacedHoverAction[]) { + const button = document.createElement("button"); + button.type = "button"; + button.className = `${styles.overflow} cm-plugin-hover-action-overflow`; + button.textContent = "…"; + const label = tx`${matches.length} hover actions`; + button.title = label; + button.setAttribute("aria-label", label); + button.addEventListener("mousedown", (event) => event.preventDefault()); + button.addEventListener("click", (event) => { + event.preventDefault(); + event.stopPropagation(); + const rect = button.getBoundingClientRect(); + showContextMenu( + { x: rect.left, y: rect.bottom + 4 }, + matches.map(({ plugin, action }) => ({ + label: action.tooltip ?? action.label, + verbatim: true, + run: () => this.runAction(plugin, action), + })), + { owner: this.view.dom }, + ); + }); + this.root.appendChild(button); + } + + private reposition() { + if (!this.visible || !this.shown.length) return; + const anchorLine = this.shown[0]!.action.line; + if (anchorLine >= this.view.state.doc.lines) return this.hide(); + const line = this.view.state.doc.line(anchorLine + 1); + const coords = this.view.coordsAtPos(line.from); + if (!coords) return this.hide(); + const content = this.view.contentDOM.getBoundingClientRect(); + const editor = this.view.dom.getBoundingClientRect(); + const height = this.root.offsetHeight || 16; + // Align the visible icon centers. The bulb is 18px wide with a 1px-padded + // 16px icon; the action is a 16px button with a 14px SVG. Aligning only the + // container left would leave the action 1px left of the bulb. + const bulb = this.view.dom.querySelector(".cm-lsp-bulb"); + let left = content.left - editor.left + 4; + const bulbIcon = + bulb && getComputedStyle(bulb).display !== "none" && !bulb.classList.contains("cm-lsp-bulb-gutter") + ? [...bulb.querySelectorAll(".cm-openidea-icon")].find( + (icon) => getComputedStyle(icon).display !== "none", + ) + : undefined; + const actionIcon = this.root.querySelector(".cm-plugin-hover-action svg"); + if (bulbIcon && actionIcon) { + const bulbRect = bulbIcon.getBoundingClientRect(); + const actionRect = actionIcon.getBoundingClientRect(); + const rootRect = this.root.getBoundingClientRect(); + const actionCenter = actionRect.left + actionRect.width / 2 - rootRect.left; + left = bulbRect.left + bulbRect.width / 2 - actionCenter - editor.left; + } else if (bulb && getComputedStyle(bulb).display !== "none" && !bulb.classList.contains("cm-lsp-bulb-gutter")) { + left = bulb.getBoundingClientRect().left - editor.left + 1; + } + this.root.style.left = `${Math.max(0, left)}px`; + // Center on the line's visual row; the button's height changes independently + // of the editor line height, so do not position from the row top alone. + this.root.style.top = `${Math.round((coords.top + coords.bottom) / 2 - editor.top - height / 2)}px`; + } + + private setVisible(visible: boolean) { + this.visible = visible; + this.root.dataset.visible = visible ? "true" : "false"; + } + + /** + * Pointer leaves the editing area to the left: keep the hint (sticky). + * Editor/window focus loss and tab hiding override that stickiness. + */ + private hide() { + if (!this.shown.length) return; + if (document.activeElement instanceof Node && this.root.contains(document.activeElement)) { + this.setVisible(true); + return; + } + this.forceHide(); + } + + private forceHide() { + if (!this.shown.length) return; + this.shown = []; + this.reserveLine(null); + this.root.replaceChildren(); + this.setVisible(false); + } + + private clear() { + this.forceHide(); + } + + destroy() { + this.view.contentDOM.removeEventListener("mousemove", this.onMove); + this.view.scrollDOM.removeEventListener("scroll", this.onScroll); + window.removeEventListener("resize", this.onResize); + this.root.removeEventListener("focusin", this.onFocusIn); + this.view.dom.removeEventListener("focusout", this.onFocusOut); + window.removeEventListener("blur", this.onWindowBlur); + document.removeEventListener("visibilitychange", this.onVisibilityChange); + this.reserveLine(null); + setHoverActions(this.ctx.doc, []); + this.root.remove(); + } +} + +/** Extension owned by the plugin-language-visuals ViewPlugin. */ +export function hoverActionLayer(view: EditorView, ctx: EditorDocContext): HoverActionLayer { + return new HoverActionLayer(view, ctx); +} +export type { HoverActionLayer }; diff --git a/src/features/plugins/languageVisuals.ts b/src/features/plugins/languageVisuals.ts index b93dc1663..2e07ca7bf 100644 --- a/src/features/plugins/languageVisuals.ts +++ b/src/features/plugins/languageVisuals.ts @@ -19,6 +19,7 @@ import { call, commands, type GutterAction, type Injection } from "@/platform/ip import { gutterIconMarkup } from "@/ui/icons"; import { resolveMarkerIcon, onMarkerIconsChanged } from "./markerIcons"; import { markerIcon } from "./lineMarkerGutter"; +import { hoverActionLayer, type HoverActionLayer, type PlacedHoverAction } from "./hoverActions"; import styles from "@/editor/navigation/LineMarkers.module.css"; export async function injectedHighlights(state: EditorState, injections: readonly Injection[]): Promise { @@ -119,7 +120,9 @@ export function pluginLanguageVisuals(ctx: EditorDocContext): Extension { generation = 0; skipped = false; off: () => void; + hover: HoverActionLayer; constructor() { + this.hover = hoverActionLayer(view, ctx); const a = onNavigationProvidersChanged(() => this.schedule()); const b = onMarkerIconsChanged(() => this.schedule()); this.off = () => { @@ -142,6 +145,12 @@ export function pluginLanguageVisuals(ctx: EditorDocContext): Extension { try { const result = await pluginVisuals(view, ctx); const deco = await injectedHighlights(view.state, result.injections); + const hover = await Promise.all( + (result.hoverActions ?? []).map(async ([plugin, a]) => ({ + plugin, + action: { ...a, icon: await resolveMarkerIcon(plugin, a.icon) }, + })), + ); const placed = await Promise.all( result.gutterActions .filter(([, a]) => a.line < text.lines) @@ -154,6 +163,7 @@ export function pluginLanguageVisuals(ctx: EditorDocContext): Extension { this.skipped = !view.dom.isConnected; if (this.skipped) return; view.dispatch({ effects: [setHighlight.of(deco), setActions.of(placed)] }); + this.hover.set(hover as PlacedHoverAction[]); } catch (error) { console.debug("[plugin language visuals]", error); } @@ -162,6 +172,7 @@ export function pluginLanguageVisuals(ctx: EditorDocContext): Extension { this.generation++; clearTimeout(this.timer); this.off(); + this.hover.destroy(); } })(), ), diff --git a/src/platform/hoverActions.test.ts b/src/platform/hoverActions.test.ts new file mode 100644 index 000000000..9f8cf5df7 --- /dev/null +++ b/src/platform/hoverActions.test.ts @@ -0,0 +1,28 @@ +import { describe, expect, it } from "vitest"; +import { hoverActionsAt, setHoverActions } from "./hoverActions"; +import type { HoverAction } from "./ipc"; + +const action = (line: number, startLine: number, endLine: number, label: string): HoverAction => ({ + line, + startLine, + endLine, + icon: "run", + label, + tooltip: label, + command: "run", + argument: null, +}); + +describe("hover action context-menu store", () => { + it("lists the actions whose inclusive line range holds the caret", () => { + setHoverActions(7, [ + { plugin: "p", action: action(0, 0, 2, "outer") }, + { plugin: "q", action: action(5, 4, 8, "inner") }, + ]); + expect(hoverActionsAt(7, 1).map((e) => e.action.label)).toEqual(["outer"]); + expect(hoverActionsAt(7, 6).map((e) => e.action.label)).toEqual(["inner"]); + expect(hoverActionsAt(7, 9)).toEqual([]); + setHoverActions(7, []); + expect(hoverActionsAt(7, 1)).toEqual([]); + }); +}); diff --git a/src/platform/hoverActions.ts b/src/platform/hoverActions.ts new file mode 100644 index 000000000..fdef048bb --- /dev/null +++ b/src/platform/hoverActions.ts @@ -0,0 +1,16 @@ +/** Hover actions of the open editors, for the editor context menu. */ +import type { HoverAction } from "@/platform/ipc"; + +export type HoverActionEntry = { plugin: string; action: HoverAction }; + +const byDoc = new Map(); + +export function setHoverActions(doc: number, entries: readonly HoverActionEntry[]) { + if (entries.length) byDoc.set(doc, entries); + else byDoc.delete(doc); +} + +/** Actions whose line range holds `line` (0-based), in provider order. */ +export function hoverActionsAt(doc: number, line: number): readonly HoverActionEntry[] { + return (byDoc.get(doc) ?? []).filter(({ action }) => action.startLine <= line && line <= action.endLine); +} diff --git a/src/platform/locales/text/en.json b/src/platform/locales/text/en.json index 5c534fb47..d4df5f64d 100644 --- a/src/platform/locales/text/en.json +++ b/src/platform/locales/text/en.json @@ -2679,5 +2679,8 @@ "Focus Build tool window": "Focus Build tool window", "Only on errors": "Only on errors", "Automatic and explicit builds. Run/Debug before-launch builds stay hidden until they fail.": "Automatic and explicit builds. Run/Debug before-launch builds stay hidden until they fail.", - "When Build opens, whether it takes keyboard focus from the editor.": "When Build opens, whether it takes keyboard focus from the editor." + "When Build opens, whether it takes keyboard focus from the editor.": "When Build opens, whether it takes keyboard focus from the editor.", + "Hover actions": "Hover actions", + "Hover action": "Hover action", + "{count} hover actions": "{count} hover actions" } diff --git a/src/platform/locales/text/zh.json b/src/platform/locales/text/zh.json index 4be7d5a83..2f70bdef4 100644 --- a/src/platform/locales/text/zh.json +++ b/src/platform/locales/text/zh.json @@ -9054,5 +9054,8 @@ "Focus Build tool window": "聚焦构建工具窗口", "Only on errors": "仅在出错时", "Automatic and explicit builds. Run/Debug before-launch builds stay hidden until they fail.": "自动构建与手动构建均适用。运行/调试的启动前构建在失败前保持隐藏。", - "When Build opens, whether it takes keyboard focus from the editor.": "构建窗口打开时,是否从编辑器夺取键盘焦点。" + "When Build opens, whether it takes keyboard focus from the editor.": "构建窗口打开时,是否从编辑器夺取键盘焦点。", + "Hover actions": "悬停操作", + "Hover action": "悬停操作", + "{count} hover actions": "{count} 个悬停操作" } diff --git a/wit/commit.wit b/wit/commit.wit index 763911ad5..0b3b8fc24 100644 --- a/wit/commit.wit +++ b/wit/commit.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// The commit being prepared in the window the current command or event came /// from (the Commit tool window, or the Commit dialog while it is open): the diff --git a/wit/database.wit b/wit/database.wit index 379266834..ea5b543a2 100644 --- a/wit/database.wit +++ b/wit/database.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Plugin-owned project data sources. Requires database.sources and project trust. /// Runs on the Database subsystem's host, including on remote project servers. diff --git a/wit/decorations.wit b/wit/decorations.wit index a291643cb..96c543ae3 100644 --- a/wit/decorations.wit +++ b/wit/decorations.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Editor and project-tree decorations (API 1.4). Requires project.read. An editor set /// follows its file: the file's own project, or the nearest one when it is outside them all. diff --git a/wit/details.wit b/wit/details.wit index 3ebf0eea0..3363dc99c 100644 --- a/wit/details.wit +++ b/wit/details.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// What the pane beside the Services tree shows for a plugin's node. interface detail-types { diff --git a/wit/diagnostics.wit b/wit/diagnostics.wit index 72a5b5ceb..32f1a9188 100644 --- a/wit/diagnostics.wit +++ b/wit/diagnostics.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Optional export (world `plugin-diagnostics`): problems in the current, /// possibly unsaved document, for the languages declared with the diff --git a/wit/endpoints.wit b/wit/endpoints.wit index 0aca4c9ac..44b7c6d79 100644 --- a/wit/endpoints.wit +++ b/wit/endpoints.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// HTTP endpoints found in a project (`[[contributes.endpoints]]`). interface endpoints-provider { diff --git a/wit/events.wit b/wit/events.wit index 27b0639f8..ca11daa53 100644 --- a/wit/events.wit +++ b/wit/events.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Workbench events, delivered in batches to `event-handler.handle`. interface events { diff --git a/wit/exports.wit b/wit/exports.wit index 173fe19cd..15858b5be 100644 --- a/wit/exports.wit +++ b/wit/exports.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; interface lifecycle { use types.{context, error}; diff --git a/wit/extensions.wit b/wit/extensions.wit index d2b73648a..aa2cc9d09 100644 --- a/wit/extensions.wit +++ b/wit/extensions.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// What other plugins contributed to the extension points this plugin declares /// (`[[extension-points]]` in `plugin.toml`; the contributors list this plugin diff --git a/wit/file-actions.wit b/wit/file-actions.wit index 9de9084f9..175d54247 100644 --- a/wit/file-actions.wit +++ b/wit/file-actions.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Optional export (world `plugin-file-actions`): quick fixes and /// refactorings that create, rename or delete files, next to the text edits diff --git a/wit/fs.wit b/wit/fs.wit index fc70f83d1..80f29f67a 100644 --- a/wit/fs.wit +++ b/wit/fs.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Files outside the open projects: the configuration of the program a /// plugin integrates with, a tool installed elsewhere, a licence file. diff --git a/wit/host.wit b/wit/host.wit index 022f611f4..c47ec8243 100644 --- a/wit/host.wit +++ b/wit/host.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Writes to the IDE log, tagged with the plugin id. interface log { diff --git a/wit/hover-actions.wit b/wit/hover-actions.wit new file mode 100644 index 000000000..b58630b60 --- /dev/null +++ b/wit/hover-actions.wit @@ -0,0 +1,40 @@ +package openidea:plugin@1.14.0; + +/// Optional export (world `plugin-hover-actions`): clickable actions rendered +/// at the left edge of a line and revealed while the pointer is in the leftmost +/// editing-area strip of the action's line range. +interface hover-actions { + use language-features.{document}; + + /// An action drawn at the left edge of `line`. + record hover-action { + /// The line the button is drawn on; normally the declaration line. + line: u32, + /// First line whose left strip reveals this action, inclusive. + start-line: u32, + /// Last line whose left strip reveals this action, inclusive. + end-line: u32, + /// Optional icon: a registered icon name or a declared manifest SVG path. + icon: option, + /// Text shown when no icon is present, or beside the icon. + label: string, + tooltip: option, + /// This plugin's declared command. + command: string, + argument: option, + } + + /// Actions for the visible document, under the editor-provider budget. + hover-actions: func(doc: document) -> list; +} + +/// The optional export-only world the SDK merges with `plugin`. +world hover-actions-provider { + export hover-actions; +} + +/// The host-side world used to instantiate a component that exports it. +world plugin-hover-actions { + include plugin; + export hover-actions; +} diff --git a/wit/hover.wit b/wit/hover.wit index c483d3df9..4a5bdad66 100644 --- a/wit/hover.wit +++ b/wit/hover.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Optional export (world `plugin-hover`): Markdown added to the hover of /// documents of the languages declared with the `hover` provider kind, diff --git a/wit/indexing.wit b/wit/indexing.wit index 727edfb77..9b2e9d5aa 100644 --- a/wit/indexing.wit +++ b/wit/indexing.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Cross-file associations a plugin publishes for the files it declares under /// `[[contributes.documentIndexers]]`. The host calls `index` in cancellable diff --git a/wit/injections.wit b/wit/injections.wit index 7570a6fb3..f9d56dbe1 100644 --- a/wit/injections.wit +++ b/wit/injections.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Embedded languages. The host routes plugin providers and configured language /// servers inside these ranges, preserving host-document UTF-16 coordinates. diff --git a/wit/inlay.wit b/wit/inlay.wit index aa58c6207..cfbb93b94 100644 --- a/wit/inlay.wit +++ b/wit/inlay.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Optional export (world `plugin-inlay-hints`): inline hints in documents of /// the languages declared with the `inlay-hints` provider kind, including diff --git a/wit/io.wit b/wit/io.wit index 1ebe516ce..829adfff0 100644 --- a/wit/io.wit +++ b/wit/io.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Problems in files, shown in the editor and the Problems view. interface diagnostics { diff --git a/wit/language-features.wit b/wit/language-features.wit index ea49b0cdc..47aa04b22 100644 --- a/wit/language-features.wit +++ b/wit/language-features.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Additional language features, called only for declared API 1.4 provider kinds. /// Editor calls have a 50 ms soft / 500 ms hard budget; formatting has 5 seconds. diff --git a/wit/mcp.wit b/wit/mcp.wit index b65527ab5..c07d71583 100644 --- a/wit/mcp.wit +++ b/wit/mcp.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Discovery of the IDE's built-in MCP server; never exposes its URL or token. interface mcp { diff --git a/wit/plugin.wit b/wit/plugin.wit index 9248969e9..c777abda8 100644 --- a/wit/plugin.wit +++ b/wit/plugin.wit @@ -8,7 +8,7 @@ /// `fs` and `workspace`, and everything else goes through the imports below, /// gated by the capabilities granted in `plugin.toml` (a missing one returns /// `error::denied`). -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; world plugin { import log; diff --git a/wit/providers.wit b/wit/providers.wit index 287bf5fa7..b8f4d25fb 100644 --- a/wit/providers.wit +++ b/wit/providers.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Editor features a plugin provides for the languages it declares under /// `[[contributes.providers]]` (the host calls only declared kinds). They run diff --git a/wit/run-targets.wit b/wit/run-targets.wit index 43af1f11b..eaf7caa4b 100644 --- a/wit/run-targets.wit +++ b/wit/run-targets.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Project-scoped targets owned by the registering plugin (API 1.4). interface run-targets { diff --git a/wit/run.wit b/wit/run.wit index 040c0a7d4..2d9984066 100644 --- a/wit/run.wit +++ b/wit/run.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Launches this plugin's configurations in the invoking window's Run tool window. interface run { diff --git a/wit/search.wit b/wit/search.wit index 020c9404d..ca2ef675b 100644 --- a/wit/search.wit +++ b/wit/search.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// On-demand results for `[[contributes.searchCategories]]`. Optional, API 1.13. interface search-provider { diff --git a/wit/semantic.wit b/wit/semantic.wit index 521f12b70..9fd28437d 100644 --- a/wit/semantic.wit +++ b/wit/semantic.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Optional export (world `plugin-semantic-tokens`): semantic colouring of /// documents of the languages declared with the `semantic-tokens` provider diff --git a/wit/types.wit b/wit/types.wit index a6c7ae278..0300c273b 100644 --- a/wit/types.wit +++ b/wit/types.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Shared types. Positions are 0-based lines and UTF-16 code unit columns, /// as in the editor and LSP. diff --git a/wit/views.wit b/wit/views.wit index 81d06ad18..02745a11e 100644 --- a/wit/views.wit +++ b/wit/views.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; /// Declarative views: tool windows declared /// under `[[contributes.views]]` and custom editors under diff --git a/wit/workspace.wit b/wit/workspace.wit index 7e12d4c54..ff5b00105 100644 --- a/wit/workspace.wit +++ b/wit/workspace.wit @@ -1,4 +1,4 @@ -package openidea:plugin@1.13.0; +package openidea:plugin@1.14.0; interface workspace { use types.{error, location};