Порівняти коміти

..
Автор SHA1 Повідомлення Дата
l0ng-ai 07e9ccb4dd fix(plugins): keep each stored value in its own file
A set rewrote the whole storage.json, up to 64 MiB, for one small key, and
a get parsed all of it. Each key now has its own file (named by its hash,
written atomically); an older storage.json moves into them on first use.
2026-11-07 18:58:25 +08:00
68 змінених файлів з 93 додано та 1047 видалено

No files matched your search

+5 -33
Переглянути файл
@@ -299,11 +299,9 @@ fn appimage_fixes() -> Vec<(OsString, Option<OsString>)> {
const APPIMAGE_LAUNCH_VARS: [&str; 4] = ["APPDIR", "APPIMAGE", "ARGV0", "OWD"];
/// What to change in `vars` (an environment) so a child sees the host's environment rather
/// than the AppImage's: every `:`-separated entry inside `$APPDIR` — or inside *any*
/// AppImage mount, since an in-app update restart inherits the previous mount's entries
/// alongside the new one — is dropped (a saved `<NAME>_ORIG` wins when present),
/// variables left empty are removed, and so are the runtime's own launch variables.
/// Nothing changes when `APPDIR` is not set.
/// than the AppImage's: every `:`-separated entry inside `$APPDIR` is dropped (a saved
/// `<NAME>_ORIG` wins when present), variables left empty are removed, and so are the
/// runtime's own launch variables. Nothing changes when `APPDIR` is not set.
fn appimage_env_fixes(vars: &[(OsString, OsString)]) -> Vec<(OsString, Option<OsString>)> {
let get = |name: &str| vars.iter().find(|(k, _)| k == name).map(|(_, v)| v);
let Some(appdir) =
@@ -311,12 +309,7 @@ fn appimage_env_fixes(vars: &[(OsString, OsString)]) -> Vec<(OsString, Option<Os
else {
return Vec::new();
};
let inside = |entry: &str| {
let own = entry.strip_prefix(appdir).is_some_and(|rest| rest.is_empty() || rest.starts_with('/'));
// AppImages extract to `/tmp/.mount_<name>`; an entry under another mount is
// another image's (e.g. the pre-update one a restart inherited), never the host's.
own || entry.starts_with("/tmp/.mount_")
};
let inside = |entry: &str| entry.strip_prefix(appdir).is_some_and(|rest| rest.is_empty() || rest.starts_with('/'));
let mut fixes = Vec::new();
for (key, value) in vars {
let (Some(name), Some(value)) = (key.to_str(), value.to_str()) else { continue };
@@ -722,7 +715,7 @@ mod tests {
("PATH", "/tmp/.mount_OpenIDabc/usr/bin/:/tmp/.mount_OpenIDabc/usr/sbin/:/usr/local/bin:/usr/bin"),
("XDG_DATA_DIRS", "/tmp/.mount_OpenIDabc/usr/share:/usr/share:/usr/local/share:/usr/share"),
("HOME", "/home/me"),
("JAVA_HOME", "/opt/jdk"),
("JAVA_HOME", "/tmp/.mount_OpenIDabcdef/jdk"),
]);
assert_eq!(
got,
@@ -735,27 +728,6 @@ mod tests {
);
}
#[test]
fn entries_of_a_previous_updates_mount_are_dropped() {
// An in-app update restart inherits the old mount's entries: a child's curl
// must not load the old image's libraries (they can still be mounted).
let got = fixes(&[
("APPDIR", "/tmp/.mount_OpenIDjIlFFA"),
("LD_LIBRARY_PATH", "/tmp/.mount_OpenIDjIlFFA/usr/lib/:/tmp/.mount_OpenIDdaNGfM/usr/lib/:/usr/local/lib"),
("PATH", "/tmp/.mount_OpenIDjIlFFA/usr/bin/:/tmp/.mount_OpenIDdaNGfM/usr/bin/:/usr/bin"),
("GIO_MODULE_DIR", "/tmp/.mount_OpenIDdaNGfM/usr/lib/gio/modules"),
]);
assert_eq!(
got,
[
fix("APPDIR", None),
fix("LD_LIBRARY_PATH", Some("/usr/local/lib")),
fix("PATH", Some("/usr/bin")),
fix("GIO_MODULE_DIR", None),
]
);
}
#[test]
fn variables_left_empty_are_removed() {
// AppRun prepends to an unset variable, leaving a trailing `:`; hooks set single paths.
+1 -16
Переглянути файл
@@ -677,22 +677,7 @@ pub async fn lsp_format(
}
pub async fn lsp_inlay_hints(host: &Host, window: &str, doc: DocId, range: Range) -> IdeResult<Vec<InlayHint>> {
let lsp = host.project(window)?.lsp.clone();
let Some((plugins, d)) = plugin_providers(host, window, doc, ProviderKind::InlayHints) else {
return lsp.inlay_hints(doc, range).await;
};
let (result, hints) =
tokio::join!(lsp.inlay_hints(doc, range), plugin_call(move || plugins.provide_inlay_hints(&d, range)));
let hints = hints.unwrap_or_default();
if hints.is_empty() {
return result;
}
let server = match result {
Ok(server) => server,
Err(e) if matches!(e.kind, ErrorKind::NotFound | ErrorKind::Unavailable) => Vec::new(),
Err(e) => return Err(e),
};
Ok(crate::plugins::merge_inlay_hints(server, hints, range))
host.project(window)?.lsp.inlay_hints(doc, range).await
}
pub async fn lsp_semantic_tokens(host: &Host, window: &str, doc: DocId) -> IdeResult<Option<SemanticTokens>> {
-94
Переглянути файл
@@ -1,94 +0,0 @@
use ide_core::Range;
use ide_lsp::types::{InlayHint, InlayKind};
use ide_plugin::PluginInlayHint;
pub(crate) fn merge(server: Vec<InlayHint>, plugin: Vec<PluginInlayHint>, range: Range) -> Vec<InlayHint> {
let inside = |h: &PluginInlayHint| {
let at = (h.position.line, h.position.col);
(range.start.line, range.start.col) <= at && at <= (range.end.line, range.end.col)
};
let mut out = server;
out.extend(plugin.into_iter().filter(inside).map(|h| InlayHint {
position: h.position,
label: h.label,
kind: match h.kind.as_str() {
"type" => InlayKind::Type,
"parameter" => InlayKind::Parameter,
_ => InlayKind::Other,
},
padding_left: h.padding_left,
padding_right: h.padding_right,
tooltip: h.tooltip,
parts: Vec::new(),
}));
out.sort_by_key(|h| (h.position.line, h.position.col));
out
}
#[cfg(test)]
mod tests {
use super::*;
use ide_core::Pos;
fn plugin(line: u32, col: u32, label: &str, kind: &str) -> PluginInlayHint {
PluginInlayHint {
position: Pos::new(line, col),
label: label.into(),
kind: kind.into(),
tooltip: Some("from the plugin".into()),
padding_left: true,
padding_right: false,
}
}
fn server(line: u32, col: u32, label: &str) -> InlayHint {
InlayHint {
position: Pos::new(line, col),
label: label.into(),
kind: InlayKind::Parameter,
padding_left: false,
padding_right: true,
tooltip: None,
parts: Vec::new(),
}
}
fn summary(hints: &[InlayHint]) -> Vec<(u32, u32, String)> {
hints.iter().map(|h| (h.position.line, h.position.col, h.label.clone())).collect()
}
#[test]
fn plugin_hints_join_the_servers_in_position_order() {
let range = Range::new(Pos::new(0, 0), Pos::new(10, 0));
let merged = merge(
vec![server(2, 4, "name:"), server(5, 1, "id:")],
vec![plugin(3, 9, ": string", "type"), plugin(2, 1, "GET /orders", "other")],
range,
);
assert_eq!(
summary(&merged),
[
(2, 1, "GET /orders".to_owned()),
(2, 4, "name:".to_owned()),
(3, 9, ": string".to_owned()),
(5, 1, "id:".to_owned())
]
);
let typed = merged.iter().find(|h| h.label == ": string").unwrap();
assert!(matches!(typed.kind, InlayKind::Type));
assert!(typed.padding_left && !typed.padding_right);
assert_eq!(typed.tooltip.as_deref(), Some("from the plugin"));
}
#[test]
fn unknown_kinds_are_other_and_hints_outside_the_range_are_dropped() {
let range = Range::new(Pos::new(2, 5), Pos::new(4, 3));
let merged = merge(
Vec::new(),
vec![plugin(2, 4, "before", "type"), plugin(3, 0, "in", "route"), plugin(4, 4, "after", "type")],
range,
);
assert_eq!(summary(&merged), [(3, 0, "in".to_owned())]);
assert!(matches!(merged[0].kind, InlayKind::Other));
}
}
-2
Переглянути файл
@@ -23,7 +23,6 @@ mod icon_patterns;
mod icon_settings;
mod icons;
pub mod index_ops;
mod inlay_hints;
mod install;
pub mod intellij;
mod market;
@@ -45,7 +44,6 @@ pub(crate) use hover::merge as merge_hover;
pub use icons::{
MAX_PLUGIN_ICON, map_asset as icon_theme_map_asset, plugin_icon, sanitize_svg, svg_prefix as icon_theme_svg_prefix,
};
pub(crate) use inlay_hints::merge as merge_inlay_hints;
pub use market::{
INDEX_FILE as MARKET_INDEX_FILE, MarketPlugin, OFFICIAL_INDEX as OFFICIAL_MARKET_INDEX, OFFICIAL_PUBLISHER,
read_url as read_market_url, resolve as resolve_market_href,
+1 -15
Переглянути файл
@@ -39,7 +39,6 @@ pub enum ProviderKind {
LineMarkers,
SemanticTokens,
Hover,
InlayHints,
}
#[derive(Clone, Debug, Deserialize)]
@@ -121,9 +120,6 @@ impl ExtensionPoint for ProvidersPoint {
if d.kinds.contains(&ProviderKind::Hover) {
pkg.manifest.needs_api("contributes.providers: hover", 3)?;
}
if d.kinds.contains(&ProviderKind::InlayHints) {
pkg.manifest.needs_api("contributes.providers: inlay-hints", 3)?;
}
for l in &d.languages {
if l != "*"
&& (l.is_empty()
@@ -173,7 +169,7 @@ use super::{LoadedPlugin, PluginHost, PluginStatus};
use ide_core::CancellationToken;
use ide_plugin::{
ActorError, CallError, CodeAction, CompletionItem, InlineSuggestion, LineMarker, Location, Pending, PluginHover,
PluginInlayHint, ProviderDocument, Runtime, SemanticToken,
ProviderDocument, Runtime, SemanticToken,
};
use std::sync::Weak;
use std::time::{Duration, Instant};
@@ -361,16 +357,6 @@ impl PluginHost {
.collect()
}
pub fn provide_inlay_hints(&self, doc: &ProviderDocument, range: ide_core::Range) -> Vec<PluginInlayHint> {
let d = Arc::new(doc.clone());
self.edit_calls(ProviderKind::InlayHints, &doc.language, move |rt, timeout| {
rt.provide_inlay_hints(&d, range, timeout)
})
.into_iter()
.flat_map(|(_, hints)| hints)
.collect()
}
/// Ghost text from the first plugin that has some. Not bound by the
/// edit-path soft deadline (it may need the network) but by `cancel`:
/// the editor cancels a request as soon as the user types on.
+1 -1
Переглянути файл
@@ -60,7 +60,7 @@ use std::collections::BTreeSet;
use std::path::PathBuf;
/// A view whose tree shows in the Services tool window; the plugin's
/// `detail-provider` renders the selected node's pane.
/// `service-provider` renders the selected node's pane.
pub const SERVICES_LOCATION: &str = "services";
pub const MENUS: &str = "menus";
pub const KEYMAPS: &str = "keymaps";
-59
Переглянути файл
@@ -1,59 +0,0 @@
use ide_core::{Pos, Range};
use ide_host::plugins::{Consent, PluginHost};
use ide_plugin::{Limits, ProviderDocument};
use std::path::{Path, PathBuf};
use std::sync::Arc;
use std::time::Duration;
fn fixture_dir() -> PathBuf {
Path::new(env!("CARGO_MANIFEST_DIR")).join("../ide-plugin/tests/fixtures/inlay-hints")
}
fn host(dir: &Path) -> PluginHost {
let limits = Limits { edit_soft: Duration::from_secs(5), edit_hard: Duration::from_secs(10), ..Limits::default() };
PluginHost::new(dir.join("plugins"), Arc::new(|_: Option<&str>, _| {}), limits).unwrap()
}
fn doc(dir: &Path, language: &str, text: &str) -> ProviderDocument {
ProviderDocument { path: dir.join("Order.php"), language: language.into(), version: 1, text: text.into() }
}
const ORDER: &str = "<?php\nclass Order\n{\n public function user(): ?User {}\n}\n$order->user();\n$order->total();\n$order->user;\n";
fn all() -> Range {
Range::new(Pos::new(0, 0), Pos::new(100, 0))
}
#[test]
fn calls_of_declared_methods_get_a_type_hint() {
let tmp = tempfile::tempdir().unwrap();
let host = host(tmp.path());
host.install_from_dir(&fixture_dir(), &Consent::all()).unwrap();
let hints = host.provide_inlay_hints(&doc(tmp.path(), "php", ORDER), all());
let found: Vec<_> =
hints.iter().map(|h| (h.position.line, h.position.col, h.label.as_str(), h.kind.as_str())).collect();
assert_eq!(found, [(5, 14, ": ?User", "type")]);
assert_eq!(hints[0].tooltip.as_deref(), Some("user() returns ?User"));
assert!(!hints[0].padding_left && !hints[0].padding_right);
}
#[test]
fn only_declared_languages_are_asked() {
let tmp = tempfile::tempdir().unwrap();
let host = host(tmp.path());
host.install_from_dir(&fixture_dir(), &Consent::all()).unwrap();
assert!(host.provide_inlay_hints(&doc(tmp.path(), "javascript", ORDER), all()).is_empty());
}
#[test]
fn the_kind_needs_plugin_api_1_3() {
let tmp = tempfile::tempdir().unwrap();
let host = host(tmp.path());
let pkg = tmp.path().join("old");
std::fs::create_dir_all(pkg.join("dist")).unwrap();
std::fs::copy(fixture_dir().join("dist/plugin.wasm"), pkg.join("dist/plugin.wasm")).unwrap();
let manifest = std::fs::read_to_string(fixture_dir().join("plugin.toml")).unwrap();
std::fs::write(pkg.join("plugin.toml"), manifest.replace("\"^1.3\"", "\"^1.0\"")).unwrap();
let err = host.install_from_dir(&pkg, &Consent::all()).unwrap_err();
assert!(err.message.contains("new in plugin API 1.3"), "{}", err.message);
}
+17 -69
Переглянути файл
@@ -5,7 +5,7 @@
use crate::types::{
CodeAction, CommitDraft, CommitProblem, CompletionItem, InlineSuggestion, LineMarker, Location, PluginHover,
PluginInlayHint, ProviderDocument, SemanticToken,
ProviderDocument, SemanticToken,
};
use crate::types::{
EventKind, HostError, HttpRequest, HttpResponse, Invocation, Limits, NotificationLevel, ProcessOutput, Prompt,
@@ -16,8 +16,8 @@ use crate::types::{
ViewField, ViewListItem, ViewTable, ViewTreeItem, Viewport,
};
use crate::wit_host::{
bindings, commit_checks_bindings, details_bindings, hover_bindings, indexing_bindings, inlay_bindings,
providers_bindings, semantic_bindings, syntax_bindings, views_bindings,
bindings, commit_checks_bindings, hover_bindings, indexing_bindings, providers_bindings, semantic_bindings,
services_bindings, syntax_bindings, views_bindings,
};
use ide_core::CancellationToken;
use ide_core::ipc_path::to_ipc;
@@ -35,13 +35,12 @@ use wasmtime_wasi::{WasiCtx, WasiCtxView, WasiView};
use bindings::openidea::plugin::events as wit_events;
use bindings::openidea::plugin::types as wit_types;
use commit_checks_bindings::exports::openidea::plugin::commit_checker as wit_cc;
use details_bindings::exports::openidea::plugin::detail_provider as wit_detail;
use details_bindings::openidea::plugin::detail_types as wit_dt;
use hover_bindings::exports::openidea::plugin::hover_provider as wit_hover;
use indexing_bindings::exports::openidea::plugin::document_indexer as wit_index;
use inlay_bindings::exports::openidea::plugin::inlay_hints_provider as wit_inlay;
use providers_bindings::exports::openidea::plugin::providers as wit_prov;
use semantic_bindings::exports::openidea::plugin::semantic_tokens_provider as wit_sem;
use services_bindings::exports::openidea::plugin::service_provider as wit_svc;
use services_bindings::openidea::plugin::service_types as wit_st;
use syntax_bindings::exports::openidea::plugin::syntax_provider as wit_syntax;
use views_bindings::exports::openidea::plugin::view_provider as wit_view;
use views_bindings::openidea::plugin::view_types as wit_vt;
@@ -543,10 +542,9 @@ struct Exports {
indexer: Option<wit_index::Guest>,
views: Option<wit_view::Guest>,
semantic: Option<wit_sem::Guest>,
details: Option<wit_detail::Guest>,
services: Option<wit_svc::Guest>,
hover: Option<wit_hover::Guest>,
commit_checks: Option<wit_cc::Guest>,
inlay: Option<wit_inlay::Guest>,
}
/// Most results one syntax call may return (more are dropped).
@@ -627,10 +625,9 @@ impl Runtime {
let provider_indices = wit_prov::GuestIndices::new(&pre).ok();
let view_indices = wit_view::GuestIndices::new(&pre).ok();
let semantic_indices = wit_sem::GuestIndices::new(&pre).ok();
let detail_indices = wit_detail::GuestIndices::new(&pre).ok();
let service_indices = wit_svc::GuestIndices::new(&pre).ok();
let hover_indices = wit_hover::GuestIndices::new(&pre).ok();
let commit_check_indices = wit_cc::GuestIndices::new(&pre).ok();
let inlay_indices = wit_inlay::GuestIndices::new(&pre).ok();
let instance = pre.instantiate(&mut store).map_err(api_hint)?;
let plugin = plugin_indices.load(&mut store, &instance).map_err(api_hint)?;
let syntax = match syntax_indices {
@@ -653,7 +650,7 @@ impl Runtime {
Some(indices) => Some(indices.load(&mut store, &instance).map_err(api_hint)?),
None => None,
};
let details = match detail_indices {
let services = match service_indices {
Some(indices) => Some(indices.load(&mut store, &instance).map_err(api_hint)?),
None => None,
};
@@ -665,24 +662,9 @@ impl Runtime {
Some(indices) => Some(indices.load(&mut store, &instance).map_err(api_hint)?),
None => None,
};
let inlay = match inlay_indices {
Some(indices) => Some(indices.load(&mut store, &instance).map_err(api_hint)?),
None => None,
};
Ok(Self {
store,
exports: Exports {
plugin,
syntax,
providers,
views,
indexer,
semantic,
details,
hover,
commit_checks,
inlay,
},
exports: Exports { plugin, syntax, providers, views, indexer, semantic, services, hover, commit_checks },
limits: setup.limits,
version: setup.version,
})
@@ -963,40 +945,6 @@ impl Runtime {
.map(|h| PluginHover { markdown: clip(h.markdown, MAX_HOVER_BYTES), range: h.range.map(range_from_wit) }))
}
pub fn provide_inlay_hints(
&mut self,
doc: &ProviderDocument,
range: ide_core::Range,
timeout: Duration,
) -> Result<Vec<PluginInlayHint>, CallError> {
if self.exports.inlay.is_none() {
return Err(CallError::missing_export("inlay-hints-provider"));
}
let d = wit_inlay::Document {
path: to_ipc(&doc.path),
language: doc.language.clone(),
version: doc.version,
text: doc.text.clone(),
};
let r = wit_types::Range { start: pos_to_wit(range.start), end: pos_to_wit(range.end) };
let hints = self.call(Invocation::default(), timeout, |e, store| {
e.inlay.as_ref().expect("checked").call_inlay_hints(store, &d, r)
})?;
Ok(hints
.into_iter()
.filter(|h| !h.label.trim().is_empty())
.take(MAX_PROVIDER_ITEMS)
.map(|h| PluginInlayHint {
position: ide_core::Pos::new(h.position.line, h.position.character),
label: clip(h.label, 256),
kind: clip(h.kind, 32),
tooltip: h.tooltip.map(|t| clip(t, 1024)),
padding_left: h.padding_left,
padding_right: h.padding_right,
})
.collect())
}
pub fn activate(&mut self) -> Result<(), CallError> {
let data = self.store.data();
let ctx = wit_types::Context {
@@ -1069,13 +1017,13 @@ impl Runtime {
key: &str,
invocation: Invocation,
) -> Result<Vec<ServiceTab>, CallError> {
if self.exports.details.is_none() {
return Err(CallError::missing_export("detail-provider"));
if self.exports.services.is_none() {
return Err(CallError::missing_export("service-provider"));
}
let result = self.call(invocation, self.limits.timeout, |e, store| {
let ctx = store.data_mut().new_invocation()?;
let details = e.details.as_ref().expect("checked");
let r = details.call_detail(&mut *store, view, key, wasmtime::component::Resource::new_borrow(ctx.rep()));
let services = e.services.as_ref().expect("checked");
let r = services.call_detail(&mut *store, view, key, wasmtime::component::Resource::new_borrow(ctx.rep()));
store.data_mut().drop_invocation(ctx);
r
})?;
@@ -1322,11 +1270,11 @@ const MAX_LOG_TOGGLES: usize = 8;
const MAX_LOG_ARGS: usize = 256;
const MAX_LOG_ARG: usize = 4096;
fn service_tab_from_wit(t: wit_dt::Tab) -> ServiceTab {
fn service_tab_from_wit(t: wit_st::Tab) -> ServiceTab {
let body = match t.body {
wit_dt::Pane::Message(m) => ServicePane::Message(clip(m, 16 << 10)),
wit_dt::Pane::Text(text) => ServicePane::Text(clip(text, MAX_TEXT)),
wit_dt::Pane::Log(log) => {
wit_st::Pane::Message(m) => ServicePane::Message(clip(m, 16 << 10)),
wit_st::Pane::Text(text) => ServicePane::Text(clip(text, MAX_TEXT)),
wit_st::Pane::Log(log) => {
let args_fit = |args: &[String]| args.len() <= MAX_LOG_ARGS && args.iter().all(|a| a.len() <= MAX_LOG_ARG);
if args_fit(&log.args)
&& log.toggles.len() <= MAX_LOG_TOGGLES
+1 -11
Переглянути файл
@@ -466,16 +466,6 @@ pub struct PluginHover {
pub range: Option<ide_core::Range>,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct PluginInlayHint {
pub position: ide_core::Pos,
pub label: String,
pub kind: String,
pub tooltip: Option<String>,
pub padding_left: bool,
pub padding_right: bool,
}
// ---- declarative views (wit/views.wit) ---------------------------------------
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)]
@@ -555,7 +545,7 @@ pub struct View {
pub status: Option<String>,
}
/// A tab of the Services pane of a plugin's node (`detail-provider.detail`).
/// A tab of the Services pane of a plugin's node (`service-provider.detail`).
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)]
#[serde(rename_all = "camelCase")]
pub struct ServiceTab {
+3 -10
Переглянути файл
@@ -928,10 +928,10 @@ pub(crate) mod indexing_bindings {
});
}
/// The optional `detail-provider` export.
pub(crate) mod details_bindings {
/// The optional `service-provider` export.
pub(crate) mod services_bindings {
wasmtime::component::bindgen!({
world: "details", path: "../../wit",
world: "services", path: "../../wit",
with: {
"openidea:plugin/types": super::bindings::openidea::plugin::types,
"openidea:plugin/workspace": super::bindings::openidea::plugin::workspace,
@@ -968,10 +968,3 @@ pub(crate) mod hover_bindings {
with: { "openidea:plugin/types": super::bindings::openidea::plugin::types },
});
}
pub(crate) mod inlay_bindings {
wasmtime::component::bindgen!({
world: "inlay-hints", path: "../../wit",
with: { "openidea:plugin/types": super::bindings::openidea::plugin::types },
});
}
-1
Переглянути файл
@@ -30,7 +30,6 @@ fn components() -> Vec<PathBuf> {
repo().join("crates/ide-plugin/tests/fixtures/indexer/dist/plugin.wasm"),
repo().join("crates/ide-plugin/tests/fixtures/semantic-tokens/dist/plugin.wasm"),
repo().join("crates/ide-plugin/tests/fixtures/hover/dist/plugin.wasm"),
repo().join("crates/ide-plugin/tests/fixtures/inlay-hints/dist/plugin.wasm"),
];
let official = repo().join("plugins/official");
let mut dirs: Vec<_> = std::fs::read_dir(&official).unwrap().map(|e| e.unwrap().path()).collect();
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
9cdb9b328e2b72c2f8849548b1d5bc119044acb4136dac614319138db2e4890d
83a1e3f362740752ed69c53da29ff950cf9c9de18125af6c98995ea490b31690
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
32634dd8c1172c6980cd1c4f9345fb2ed7b2e5cbacfd061bcefaa7fa9aad162e
a9f1e2ec87de32ef241fcb559d157cd05800dcf106ab27e906ba36468c0b39e5
+3 -3
Переглянути файл
@@ -1,7 +1,7 @@
//! Sample OpenIDEA plugin, written with the `openidea-plugin` SDK.
//! Build with `openidea-plugin build crates/ide-plugin/tests/fixtures/hello` (see plugins/README.md).
use openidea_plugin::details::{Details, Pane, ProcessLog, Tab};
use openidea_plugin::services::{Pane, ProcessLog, Services, Tab};
use openidea_plugin::views::{Body, Button, TreeItem, View, ViewEvent, Viewport, Views};
use openidea_plugin::{Context, Error, Invocation, LogLevel, NotificationLevel, Plugin, host, register_plugin};
use std::collections::BTreeSet;
@@ -98,14 +98,14 @@ impl Views for Hello {
}
/// As a services view (tests): a node's key is the `sh -c` script its Log tab runs.
impl Details for Hello {
impl Services for Hello {
fn detail(&mut self, view: &str, key: &str, _ctx: &Invocation) -> Result<Vec<Tab>, Error> {
let log = ProcessLog::new("sh", &["-c", key]).toggle("named", "Named", &["named"]);
Ok(vec![Tab::new("log", "Log", log), Tab::new("info", "Info", Pane::Text(format!("{view}: {key}")))])
}
}
register_plugin!(Hello, views, details);
register_plugin!(Hello, views, services);
/// Today's UTC date as `YYYY-MM-DD` (WASI wall clock).
fn today() -> String {
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
b7b63faf536d558cafc375a17765823015863e47d897e2128d453fbc8975e19c
d065af9f54b5bd1ec2fbc31250c87153a55501a4e8bf4002fcc04c67c2d1e03e
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
809180a1c4ba29988af7b1ead1c31c1a3018fe3a1c266930ba588f34de1d3319
dd57b09293deb0fdc3201978e350c118f428429df4beccc4f23665be0335a795
-333
Переглянути файл
@@ -1,333 +0,0 @@
# 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.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
[[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 = [
"wit-bindgen",
]
[[package]]
name = "openidea-test-inlay-hints"
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",
]
[[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.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b"
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"
-20
Переглянути файл
@@ -1,20 +0,0 @@
[package]
name = "openidea-test-inlay-hints"
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"
-7
Переглянути файл
@@ -1,7 +0,0 @@
# Inlay hints test fixture
After every `->name()` call in a PHP document that declares
`function name(): Type`, shows `: Type` as a type hint.
Used by `cargo test -p ide-host --test plugin_inlay_hints` to exercise the
optional `inlay-hints-provider` export. It is not a marketplace plugin.
Бінарний файл не відображається.
-1
Переглянути файл
@@ -1 +0,0 @@
6fd9e638afa22170ef2e7a6bd7351bd5e0200d6726cf5d5835be7c5c7cfa19dc
-9
Переглянути файл
@@ -1,9 +0,0 @@
id = "test.inlay-hints"
name = "Inlay hints fixture"
version = "0.1.0"
engines.openidea = "^1.3"
wasm = "dist/plugin.wasm"
[[contributes.providers]]
kinds = ["inlay-hints"]
languages = ["php"]
-47
Переглянути файл
@@ -1,47 +0,0 @@
use openidea_plugin::inlay_hints::{Document, InlayHint, InlayHints, InlayKind};
use openidea_plugin::{Error, Invocation, Plugin, Range, register_plugin, text};
#[derive(Default)]
struct Fixture;
impl Plugin for Fixture {
fn run_command(&mut self, id: &str, _: &Invocation, _: Option<&str>) -> Result<Option<String>, Error> {
Err(Error::NotFound(id.into()))
}
}
impl InlayHints for Fixture {
fn inlay_hints(&mut self, doc: &Document, _range: Range) -> Vec<InlayHint> {
let text = doc.text.as_str();
let mut out = Vec::new();
let mut rest = 0;
while let Some(i) = text[rest..].find("->") {
let start = rest + i + 2;
let end = text[start..]
.find(|c: char| !(c.is_ascii_alphanumeric() || c == '_'))
.map_or(text.len(), |n| start + n);
rest = end;
if end == start || !text[end..].starts_with("()") {
continue;
}
let name = &text[start..end];
let declared = format!("function {name}(): ");
let Some(at) = text.find(&declared) else { continue };
let ty: String = text[at + declared.len()..]
.chars()
.take_while(|c| c.is_ascii_alphanumeric() || matches!(c, '_' | '\\' | '?'))
.collect();
if ty.is_empty() {
continue;
}
out.push(
InlayHint::new(text::position(text, end + 2), format!(": {ty}"))
.kind(InlayKind::Type)
.tooltip(format!("{name}() returns {ty}")),
);
}
out
}
}
register_plugin!(Fixture, inlay_hints);
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
81a1c6a7d78cf6ca6e463ffff6a4e243d668230a8d802028262ed5fc752f2f27
436516e5f17a11f5a1225b854ab9fef703172a47d33bf3d840c721ad6d373e62
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
c3b3e3c96d62106398299a6704e6a39fb18cfa734be877d1137f005d16553b4b
4e8118c9f4974385421d1e2ca0106fd658ad85124e1453c4114f60a164f72f68
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
fac2994442eb96b09dea926546d2bacde333615392bc59fd70df73999ae84f62
b77e7e3d163995f0a9a3f3cb49dc6c4ea04b2eaa0a8b74b46c64e83908bae504
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
2a97235992302d0dfda55a1774883c046fe8aed6353b0f047aafa8bfe0155fa3
9f2195fb83f16221e98313c095d57c293e79041ed8ae439fe2fb4f008a3a0921
+6 -27
Переглянути файл
@@ -34,7 +34,7 @@ plugins/
├─ regex-tester/ # html view talking to its code, settings, the editor's selection
└─ license-header/ # file-opened events, quick fix, project scan in a task
sdk/rust/openidea-plugin/ # the Rust SDK (host API, Plugin trait, mock host)
crates/ide-plugin/tests/fixtures/ # test plugins: hello, jobs, language-toy, misbehave, semantic-tokens, hover, commit, inlay-hints
crates/ide-plugin/tests/fixtures/ # test plugins: hello, jobs, language-toy, misbehave, semantic-tokens, hover, commit
```
The plugin API is defined in [`wit/`](../wit/) (`openidea:[email protected]`, world
@@ -448,7 +448,7 @@ declaration matches the file's language are called (and loaded):
```toml
[[contributes.providers]]
kinds = ["definition", "line-markers", "completion"] # also "inline-completion", "code-actions", "semantic-tokens", "hover", "inlay-hints"
kinds = ["definition", "line-markers", "completion"] # also "inline-completion", "code-actions", "semantic-tokens", "hover"
languages = ["java", "xml"] # editor language ids; "*" for any
```
@@ -523,27 +523,6 @@ edit-path budget, and shows the server's hover first, then each plugin's
below a rule. `range`, when given, is the text the hover describes (used when
the server names none). At most 64 KiB of Markdown per plugin.
#### Inlay hints
The `inlay-hints` kind (API 1.3) shows short labels inside the code of
documents of the declared languages, such as a type after a call. Register
with `register_plugin!(MyPlugin, inlay_hints)` and implement
`openidea_plugin::inlay_hints::InlayHints`:
```rust
impl InlayHints for MyPlugin {
fn inlay_hints(&mut self, doc: &Document, range: Range) -> Vec<InlayHint> {
vec![InlayHint::new(range.start, ": string").kind(InlayKind::Type).tooltip("returns string")]
}
}
```
`range` is the visible part of the document; hints outside it are dropped. A
hint's kind (`type`, `parameter` or `other`) decides which Inlay Hints setting
shows it. The host asks the language server and the plugins together, under
the edit-path budget, and shows both; the editor asks again after edits and
scrolling. Labels are cut at 256 bytes and tooltips at 1 KiB.
### Network and secrets
`host::fetch` makes an HTTPS request (plain HTTP only to `localhost`) to a host
@@ -650,13 +629,13 @@ optional = ["process:kubectl"]
The items of the view's `tree` are Services nodes: `render`, `handle` and the
toolbar work as in a tool window, the toolbar's buttons acting on the one
selected node, and `viewItem.context` menus give the nodes a right-click menu.
The pane beside the tree comes from the `detail-provider` export: register
`register_plugin!(MyPlugin, views, details)` and implement
`openidea_plugin::details::Details`, which returns the selected node's tabs
The pane beside the tree comes from the `service-provider` export: register
`register_plugin!(MyPlugin, views, services)` and implement
`openidea_plugin::services::Services`, which returns the selected node's tabs
(at most 8; asked again after `host::refresh_view("kube")`):
```rust
impl Details for MyPlugin {
impl Services for MyPlugin {
fn detail(&mut self, view: &str, key: &str, _ctx: &Invocation) -> Result<Vec<Tab>, Error> {
let pod = key.trim_start_matches("pod:");
let log = ProcessLog::new("kubectl", &["logs", "-f", "--tail=1000", pod])
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
5de6d0c1cb0ee1a92d36b57ec18590f03829b2c29cc1c306be453931c528c692
a5cba00850ccde12896ed7a69ae336a1968e024e8f5fefb6a49f2adea10569e4
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
9a89ec93d158e460998cf472837d7e0e8aa76d5441cb1dd24c3184bd814a29c1
27d61fcc109561aeea56f3a37da0aba7b6c56fdf01ff918f2e62d5732832ba3d
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
652557045106ab5bd1126cb8e05965d030c4aa28c01ede31be3fe285aab98a67
c86fae61f88b6903354b1fb706b0718f9036f82085653481d77ddc3f622b3a73
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
7c8c97e02f754676ff512d10f454a7451468e2a98c2e992e790096215dd28658
b4d059850083339f826223700eda7df0c8b655a40e4832d3acda36dc0f76db9a
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
1b6e3f30cc49d9d67d95f7655cbe337c5f8465c6ef7b8709cfab4734c3c40fdf
b2977b3b82ad26126125c614281cbbf888bb8151ece9a43fbaa5459c7a8b97cc
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
3225880631e679780c3c7eb09683b598bb3803fcf7be7b6940369eada633c48f
9f59f59b999475a8c4c626f1cfc3c77ef1b3c0684f0cbf9af148556c8f9d30c0
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
a59623542b4df024f5a85bc2cd0e046189044a0c292c793384fdb5465e8eec48
0f175352e4fcfe3b07359afb7f4a20348a488a21012e89775c628d19277d8c8c
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
f230ae32c2d5ab469f23c6851fc7830a6ecce7538c7d435be39b5bbebe38a64f
d7e9b2801ca70df9a84ec458f0fc5c6b01b7d03c056807c53268e40ecbbb9d1a
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
63f52f8cf8a90affc751ac7e19352a89f0726fc7c8dbbb303172ebd42e23af8c
50524b5be85f6bc040521f97adba6030263045dcacfeae8dbcf73ce7234e2616
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
178862630cf39bca56f5d54cd135dcac4a1ab74a3e10356163d00e5a718ae728
0c44311a5f9ddb1893be7c82d818297a05b15576d996a33ddc2389f9432c416c
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
a6c188aed4fc57cd9955d6b47ef715c52dc3f8c7b69f7d18ea71b3932888710f
3e4e23976ce0ddb1e83813269eefc24008521cdf22757e6b5249f6f219f344d2
-84
Переглянути файл
@@ -1,84 +0,0 @@
use crate::types::{Position, Range};
pub use crate::providers::Document;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum InlayKind {
Type,
Parameter,
Other,
}
impl InlayKind {
pub fn as_str(self) -> &'static str {
match self {
Self::Type => "type",
Self::Parameter => "parameter",
Self::Other => "other",
}
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct InlayHint {
pub position: Position,
pub label: String,
pub kind: InlayKind,
pub tooltip: Option<String>,
pub padding_left: bool,
pub padding_right: bool,
}
impl InlayHint {
pub fn new(position: Position, label: impl Into<String>) -> Self {
Self {
position,
label: label.into(),
kind: InlayKind::Other,
tooltip: None,
padding_left: false,
padding_right: false,
}
}
pub fn kind(mut self, kind: InlayKind) -> Self {
self.kind = kind;
self
}
pub fn tooltip(mut self, tooltip: impl Into<String>) -> Self {
self.tooltip = Some(tooltip.into());
self
}
pub fn padding_left(mut self) -> Self {
self.padding_left = true;
self
}
pub fn padding_right(mut self) -> Self {
self.padding_right = true;
self
}
}
pub trait InlayHints {
fn inlay_hints(&mut self, doc: &Document, range: Range) -> Vec<InlayHint>;
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn a_hint_is_built_step_by_step() {
let at = Position { line: 3, character: 14 };
let hint = InlayHint::new(at, "GET /orders").kind(InlayKind::Type).tooltip("orders.index").padding_left();
assert_eq!(hint.position, at);
assert_eq!(hint.kind.as_str(), "type");
assert_eq!(hint.tooltip.as_deref(), Some("orders.index"));
assert!(hint.padding_left && !hint.padding_right);
assert_eq!(InlayHint::new(at, "x").kind, InlayKind::Other);
}
}
+16 -66
Переглянути файл
@@ -40,15 +40,14 @@
//! wasm32-wasip2`); see `plugins/README.md`.
pub mod commit;
pub mod details;
pub mod host;
pub mod hover;
pub mod indexing;
pub mod inlay_hints;
#[cfg(not(target_arch = "wasm32"))]
pub mod mock;
pub mod providers;
pub mod semantic_tokens;
pub mod services;
pub mod syntax;
pub mod text;
mod types;
@@ -133,11 +132,11 @@ pub mod indexing_bindings {
#[cfg(target_arch = "wasm32")]
#[doc(hidden)]
pub mod details_bindings {
pub mod services_bindings {
wit_bindgen::generate!({
world: "details", path: "wit", pub_export_macro: true,
export_macro_name: "__export_details_world",
default_bindings_module: "openidea_plugin::details_bindings",
world: "services", path: "wit", pub_export_macro: true,
export_macro_name: "__export_services_world",
default_bindings_module: "openidea_plugin::services_bindings",
with: {
"openidea:plugin/[email protected]": crate::bindings::openidea::plugin::types,
"openidea:plugin/[email protected]": crate::bindings::openidea::plugin::workspace,
@@ -186,17 +185,6 @@ pub mod commit_checks_bindings {
});
}
#[cfg(target_arch = "wasm32")]
#[doc(hidden)]
pub mod inlay_bindings {
wit_bindgen::generate!({
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/[email protected]": crate::bindings::openidea::plugin::types },
});
}
/// The plugin API version this SDK targets.
pub const API_VERSION: &str = "1.3";
@@ -254,8 +242,8 @@ macro_rules! __optional_exports {
(semantic_tokens, $plugin:ty, $component:ident) => {
$crate::__semantic_tokens_exports!($plugin, $component);
};
(details, $plugin:ty, $component:ident) => {
$crate::__details_exports!($plugin, $component);
(services, $plugin:ty, $component:ident) => {
$crate::__services_exports!($plugin, $component);
};
(hover, $plugin:ty, $component:ident) => {
$crate::__hover_exports!($plugin, $component);
@@ -263,9 +251,6 @@ macro_rules! __optional_exports {
(commit_checks, $plugin:ty, $component:ident) => {
$crate::__commit_checks_exports!($plugin, $component);
};
(inlay_hints, $plugin:ty, $component:ident) => {
$crate::__inlay_hints_exports!($plugin, $component);
};
(syntax, $plugin:ty, $component:ident) => {
impl $crate::syntax_bindings::exports::openidea::plugin::syntax_provider::Guest for $component {
fn highlights(
@@ -397,24 +382,24 @@ macro_rules! __indexing_exports {
};
}
/// `register_plugin!(T, details)`: `T` is also a [`details::Details`].
/// `register_plugin!(T, services)`: `T` is also a [`services::Services`].
#[doc(hidden)]
#[macro_export]
macro_rules! __details_exports {
macro_rules! __services_exports {
($plugin:ty, $component:ident) => {
impl $crate::details_bindings::exports::openidea::plugin::detail_provider::Guest for $component {
impl $crate::services_bindings::exports::openidea::plugin::service_provider::Guest for $component {
fn detail(
view: ::std::string::String,
key: ::std::string::String,
ctx: &$crate::bindings::openidea::plugin::invocation::Invocation,
) -> ::core::result::Result<
::std::vec::Vec<$crate::details_bindings::openidea::plugin::detail_types::Tab>,
::std::vec::Vec<$crate::services_bindings::openidea::plugin::service_types::Tab>,
$crate::bindings::openidea::plugin::types::Error,
> {
$crate::__rt::service_detail::<$plugin>(view, key, ctx)
}
}
$crate::details_bindings::__export_details_world!($component with_types_in $crate::details_bindings);
$crate::services_bindings::__export_services_world!($component with_types_in $crate::services_bindings);
};
}
@@ -472,22 +457,6 @@ macro_rules! __hover_exports {
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __inlay_hints_exports {
($plugin:ty, $component:ident) => {
impl $crate::inlay_bindings::exports::openidea::plugin::inlay_hints_provider::Guest for $component {
fn inlay_hints(
doc: $crate::inlay_bindings::exports::openidea::plugin::inlay_hints_provider::Document,
range: $crate::bindings::openidea::plugin::types::Range,
) -> ::std::vec::Vec<$crate::inlay_bindings::exports::openidea::plugin::inlay_hints_provider::InlayHint> {
$crate::__rt::inlay_hints::<$plugin>(doc, range)
}
}
$crate::inlay_bindings::__export_inlay_hints_world!($component with_types_in $crate::inlay_bindings);
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __plugin_exports {
@@ -753,25 +722,6 @@ pub mod __rt {
.map(|h| w::HoverContent { markdown: h.markdown, range: h.range.map(crate::host::__range_to) })
}
pub fn inlay_hints<T: Plugin + crate::inlay_hints::InlayHints + Default>(
d: crate::inlay_bindings::exports::openidea::plugin::inlay_hints_provider::Document,
range: b::types::Range,
) -> Vec<crate::inlay_bindings::exports::openidea::plugin::inlay_hints_provider::InlayHint> {
use crate::inlay_bindings::exports::openidea::plugin::inlay_hints_provider as w;
let doc = crate::providers::Document { path: d.path, language: d.language, version: d.version, text: d.text };
with::<T, _>(|p| p.inlay_hints(&doc, crate::host::__range_from(range)))
.into_iter()
.map(|h| w::InlayHint {
position: b::types::Position { line: h.position.line, character: h.position.character },
label: h.label,
kind: h.kind.as_str().into(),
tooltip: h.tooltip,
padding_left: h.padding_left,
padding_right: h.padding_right,
})
.collect()
}
// ---- views ----
use crate::views as v;
@@ -861,13 +811,13 @@ pub mod __rt {
with::<T, _>(|p| p.render(&view, viewport, &ctx)).map(view_out).map_err(error_out)
}
pub fn service_detail<T: Plugin + crate::details::Details + Default>(
pub fn service_detail<T: Plugin + crate::services::Services + Default>(
view: String,
key: String,
ctx: &b::invocation::Invocation,
) -> Result<Vec<crate::details_bindings::openidea::plugin::detail_types::Tab>, b::types::Error> {
use crate::details as s;
use crate::details_bindings::openidea::plugin::detail_types as w;
) -> Result<Vec<crate::services_bindings::openidea::plugin::service_types::Tab>, b::types::Error> {
use crate::services as s;
use crate::services_bindings::openidea::plugin::service_types as w;
let ctx = Invocation::__new(ctx);
let tab = |t: s::Tab| w::Tab {
id: t.id,
+3 -3
Переглянути файл
@@ -1,7 +1,7 @@
//! The pane beside the Services tree for the nodes of the plugin's
//! `location = "services"` views (world `plugin-details`). The nodes, the
//! `location = "services"` views (world `plugin-services`). The nodes, the
//! toolbar and their events come from [`crate::views::Views`] as in any view;
//! register both: `register_plugin!(MyPlugin, views, details)`.
//! register both: `register_plugin!(MyPlugin, views, services)`.
use crate::{Error, Invocation};
@@ -65,7 +65,7 @@ impl Tab {
}
/// The detail pane of the nodes of the plugin's services views.
pub trait Details {
pub trait Services {
/// The tabs of node `key` of view `view` (at most 8), asked when the node is
/// selected and again after [`crate::host::refresh_view`] of the view.
fn detail(&mut self, view: &str, key: &str, ctx: &Invocation) -> Result<Vec<Tab>, Error>;
-39
Переглянути файл
@@ -1,39 +0,0 @@
package openidea:[email protected];
/// Optional export (world `plugin-inlay-hints`): inline hints in documents of
/// the languages declared with the `inlay-hints` provider kind, including
/// languages the plugin doesn't contribute. They are shown next to the
/// language server's hints.
interface inlay-hints-provider {
use types.{position, range};
/// The document the hints are for (the editor's text while it is open).
record document {
path: string,
language: string,
version: u64,
text: string,
}
/// A hint shown at `position`, before the character there.
record inlay-hint {
/// UTF-16 position (0-based line and column).
position: position,
/// The text shown, e.g. `GET /orders` or `: string`.
label: string,
/// `type` or `parameter` follow the Inlay Hints settings of that kind;
/// anything else counts as `other`.
kind: string,
/// Shown when the pointer rests on the hint.
tooltip: option<string>,
/// A space before the label.
padding-left: bool,
/// A space after the label.
padding-right: bool,
}
/// The hints within `range` (the visible part of the document), under the
/// edit-path budget. Hints outside `range` are dropped; at most 10,000 per
/// call.
inlay-hints: func(doc: document, range: range) -> list<inlay-hint>;
}
+5 -16
Переглянути файл
@@ -67,17 +67,11 @@ world plugin-hover {
export hover-provider;
}
/// A plugin with inlay hints (`inlay-hints` under `[[contributes.providers]]`).
world plugin-inlay-hints {
include plugin;
export inlay-hints-provider;
}
/// A plugin whose views show in the Services tool window
/// (`location = "services"`): their nodes' detail pane.
world plugin-details {
world plugin-services {
include plugin;
export detail-provider;
export service-provider;
}
/// A plugin with before-commit checks (`[[contributes.commitChecks]]`).
@@ -115,14 +109,9 @@ world hover {
export hover-provider;
}
/// Only the `inlay-hints-provider` export, generated next to `plugin` like `syntax`.
world inlay-hints {
export inlay-hints-provider;
}
/// Only the `detail-provider` export, generated next to `plugin` like `syntax`.
world details {
export detail-provider;
/// Only the `service-provider` export, generated next to `plugin` like `syntax`.
world services {
export service-provider;
}
/// Only the `commit-checker` export, generated next to `plugin` like `syntax`.
+3 -3
Переглянути файл
@@ -1,7 +1,7 @@
package openidea:[email protected];
/// What the pane beside the Services tree shows for a plugin's node.
interface detail-types {
interface service-types {
/// A switch above a log; when on, `args` are appended and the program
/// starts again.
record log-toggle {
@@ -39,10 +39,10 @@ interface detail-types {
/// The detail pane of the nodes of a plugin's `location = "services"` views.
/// The nodes themselves, the toolbar and their events come from
/// `view-provider` (`render` / `handle` of the view).
interface detail-provider {
interface service-provider {
use types.{error};
use invocation.{invocation};
use detail-types.{tab};
use service-types.{tab};
/// The tabs of node `key` of view `view` (at most 8), rendered when the
/// node is selected and again after `views.refresh(view)`.
+1 -1
Переглянути файл
@@ -7067,7 +7067,7 @@ export type ServicePane = { kind: "message"; value: string } |
/** A program the IDE runs (with the plugin's `process:` grant), followed in a log. */
{ kind: "log"; value: ServiceLog };
/** A tab of the Services pane of a plugin's node (`detail-provider.detail`). */
/** A tab of the Services pane of a plugin's node (`service-provider.detail`). */
export type ServiceTab = {
id: string,
label: string,
-39
Переглянути файл
@@ -1,39 +0,0 @@
package openidea:[email protected];
/// Optional export (world `plugin-inlay-hints`): inline hints in documents of
/// the languages declared with the `inlay-hints` provider kind, including
/// languages the plugin doesn't contribute. They are shown next to the
/// language server's hints.
interface inlay-hints-provider {
use types.{position, range};
/// The document the hints are for (the editor's text while it is open).
record document {
path: string,
language: string,
version: u64,
text: string,
}
/// A hint shown at `position`, before the character there.
record inlay-hint {
/// UTF-16 position (0-based line and column).
position: position,
/// The text shown, e.g. `GET /orders` or `: string`.
label: string,
/// `type` or `parameter` follow the Inlay Hints settings of that kind;
/// anything else counts as `other`.
kind: string,
/// Shown when the pointer rests on the hint.
tooltip: option<string>,
/// A space before the label.
padding-left: bool,
/// A space after the label.
padding-right: bool,
}
/// The hints within `range` (the visible part of the document), under the
/// edit-path budget. Hints outside `range` are dropped; at most 10,000 per
/// call.
inlay-hints: func(doc: document, range: range) -> list<inlay-hint>;
}
+5 -16
Переглянути файл
@@ -67,17 +67,11 @@ world plugin-hover {
export hover-provider;
}
/// A plugin with inlay hints (`inlay-hints` under `[[contributes.providers]]`).
world plugin-inlay-hints {
include plugin;
export inlay-hints-provider;
}
/// A plugin whose views show in the Services tool window
/// (`location = "services"`): their nodes' detail pane.
world plugin-details {
world plugin-services {
include plugin;
export detail-provider;
export service-provider;
}
/// A plugin with before-commit checks (`[[contributes.commitChecks]]`).
@@ -115,14 +109,9 @@ world hover {
export hover-provider;
}
/// Only the `inlay-hints-provider` export, generated next to `plugin` like `syntax`.
world inlay-hints {
export inlay-hints-provider;
}
/// Only the `detail-provider` export, generated next to `plugin` like `syntax`.
world details {
export detail-provider;
/// Only the `service-provider` export, generated next to `plugin` like `syntax`.
world services {
export service-provider;
}
/// Only the `commit-checker` export, generated next to `plugin` like `syntax`.
+3 -3
Переглянути файл
@@ -1,7 +1,7 @@
package openidea:[email protected];
/// What the pane beside the Services tree shows for a plugin's node.
interface detail-types {
interface service-types {
/// A switch above a log; when on, `args` are appended and the program
/// starts again.
record log-toggle {
@@ -39,10 +39,10 @@ interface detail-types {
/// The detail pane of the nodes of a plugin's `location = "services"` views.
/// The nodes themselves, the toolbar and their events come from
/// `view-provider` (`render` / `handle` of the view).
interface detail-provider {
interface service-provider {
use types.{error};
use invocation.{invocation};
use detail-types.{tab};
use service-types.{tab};
/// The tabs of node `key` of view `view` (at most 8), rendered when the
/// node is selected and again after `views.refresh(view)`.