Файли
openidea/wit/project-view.wit
T
astesiaтаkirito1105 05a88394fb feat(plugins): Project view panes and Git branch menu commands (API 1.21) (#7980)
Plugins can add panes to the Project tool window and commands to the Git branch menus:

- `[[contributes.projectViewPanes]]` with the `project-view-provider` export regroups a directory's native children under virtual folders. Existing nodes keep their icons, Git status and actions. `project-view.refresh` / `select-in` and `projectViewContext` menu items work against these panes. Requires `project.read`.
- `git.branches.popup` and `git.branch.context` menus. `invocation.git-action-context` gives the command the repository roots and the full ref of the clicked branch. Requires `vcs.read`.
- `views.open-revision-comparison` opens the IDE's comparison of two full commit IDs as a Compare tool window tab, the same one Compare Versions opens. The repository must be a mapped Git root of the invoking trusted project. Requires `vcs.read`.

All of this is part of plugin API 1.21. A project-view test fixture and host tests cover the provider, the branch menu context and the comparison call. The plugin components and bindings are rebuilt.

Co-authored-by: kirito1105 <[email protected]>
2026-12-05 12:24:10 +08:00

56 рядки
2.2 KiB
Plaintext

package openidea:[email protected];
/// Nodes of the native Project tree (API 1.21).
interface project-view-types {
enum node-kind { file, directory }
record native-node {
id: string,
path: string,
label: string,
kind: node-kind,
}
record folder-details {
label: string,
/// An IDE icon name. The host uses its folder icon when absent or unknown.
icon: option<string>,
}
variant projection-kind {
existing-node,
virtual-folder(folder-details),
}
record projection-node {
/// Existing nodes use an id from the input. A virtual folder uses a
/// stable plugin-chosen id scoped to this native parent.
id: string,
/// The virtual folder id to group under, or none for a direct child.
parent: option<string>,
kind: projection-kind,
}
}
interface project-view {
use types.{error};
/// Recompute the plugin's pane, or one project-relative or absolute
/// directory. Without an invoking window, invalidate the pane in every window.
refresh: func(view-id: string, directory: option<string>) -> result<_, error>;
/// Select a real file or directory in an owned pane or the built-in `project`
/// pane of the invoking window. `focus` defaults to true.
select-in: func(view-id: string, path: string, focus: option<bool>) -> result<_, error>;
}
/// Optional export for `[[contributes.projectViewPanes]]`. It runs while the
/// plugin's pane is visible, on the project's native direct children. Return
/// none to leave those children unchanged. Order is preserved among siblings;
/// parent ids designate virtual folders in the same result. Omitted native
/// children stay in the pane in native order. Unknown ids, duplicate references
/// and invalid virtual trees discard the result.
interface project-view-provider {
use project-view-types.{native-node, projection-node};
use invocation.{invocation};
/// `settings` is the current view options as a JSON object.
modify-children: func(view-id: string, parent: native-node, children: list<native-node>, settings: string, ctx: borrow<invocation>) -> option<list<projection-node>>;
}