дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 17:21:13 +02:00
A command is now declared once, on the fn that implements it. A project-host command is an ide-host fn with #[command(trust = …)] listed in its module's domain!; its Tauri adapter, bindings entry, JSON-RPC handler, trust class and remote routing are derived from that declaration. Desktop-only commands keep their Tauri fn and add #[desktop_command(trust = …)]. This removes the hand-written pass-through adapters, collect_commands!, the per-domain register fns and the trust tables in trust.rs. The invoke handler looks up each command's declared trust class; a name nothing declares is denied. A remote window routes the project-host commands of the desktop's own build. Duplicate names are a compile error. CI runs ide-command's compile_fail doctests. Part of #3344. Co-authored-by: Mr0Bread <[email protected]>
34 рядки
1.3 KiB
Rust
34 рядки
1.3 KiB
Rust
//! The Commit view's side of the `commit` API, as the window commands
|
|
//! `plugin_answer_commit` / `plugin_commit_checks` serve it — the desktop for
|
|
//! local projects, `openidea-server` for remote ones.
|
|
|
|
use super::{CommitSelection, PluginCommitCheckRef, PluginCommitCheckResult, PluginHost};
|
|
use ide_command::command;
|
|
use ide_core::{IdeError, IdeResult, RequestId};
|
|
use std::sync::Arc;
|
|
|
|
/// Runs plugins' before-commit checks on what `selection` commits, until
|
|
/// `request` is cancelled.
|
|
#[command(trust = trusted)]
|
|
pub async fn plugin_commit_checks(
|
|
host: &crate::Host,
|
|
plugins: &Arc<PluginHost>,
|
|
window: &str,
|
|
selection: CommitSelection,
|
|
checks: Vec<PluginCommitCheckRef>,
|
|
request: RequestId,
|
|
) -> IdeResult<Vec<PluginCommitCheckResult>> {
|
|
host.require_trust(window)?;
|
|
let plugins = plugins.clone();
|
|
let invocation = super::views::view_invocation(host, window, None, None)?;
|
|
let cancel = host.begin_project_read_request(window, request);
|
|
let result = tokio::task::spawn_blocking(move || plugins.commit_checks(invocation, selection, checks, &cancel))
|
|
.await
|
|
.map_err(|e| IdeError::internal(e.to_string()))
|
|
.and_then(|r| r);
|
|
host.end_request(request);
|
|
result
|
|
}
|
|
|
|
ide_command::domain!(plugins_commit: plugin_commit_checks);
|