дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-03 16:51:16 +02:00
The optional run-configuration-completion export receives the project, the configuration's id, the field (arguments), its text and a UTF-16 caret, and answers items that each replace one UTF-16 range, so other options, quoted values and the arguments after -- stay as typed. The host completes only configurations the plugin currently provides for the window's project (also a user's override of one), keeps 200 items and gives the plugin 300 ms. In Run | Edit Configurations the field asks while typing and on Ctrl+Space, applies an item with Enter or Tab, closes the popup on Escape without closing the dialog, drops answers for text that has changed, and stays usable when the plugin fails. Fixes #4753
146 рядки
6.6 KiB
Plaintext
146 рядки
6.6 KiB
Plaintext
package openidea:[email protected];
|
|
|
|
interface lifecycle {
|
|
use types.{context, error};
|
|
|
|
/// Called once after the instance is created: subscribe to events and
|
|
/// restore state from `storage`. Contributions (commands, languages,
|
|
/// themes, …) are declared in plugin.toml, not registered here.
|
|
/// An error fails the activation (shown on the plugin's page).
|
|
activate: func(ctx: context) -> result<_, error>;
|
|
/// Called before the instance is dropped (disable, uninstall, idle reclaim).
|
|
deactivate: func();
|
|
}
|
|
|
|
interface commands {
|
|
use types.{error};
|
|
use invocation.{invocation};
|
|
|
|
/// Runs one of the plugin's commands. Returns an optional message.
|
|
/// `cancelled` (the user gave up) and `denied` (a capability is missing)
|
|
/// are not counted as the plugin failing.
|
|
run: func(id: string, ctx: borrow<invocation>, arg: option<string>) -> result<option<string>, error>;
|
|
}
|
|
|
|
interface event-handler {
|
|
use events.{event};
|
|
use invocation.{invocation};
|
|
|
|
/// A batch of subscribed events, oldest first, from one window (`ctx`).
|
|
handle: func(events: list<event>, ctx: borrow<invocation>);
|
|
}
|
|
|
|
/// Optional export (world `plugin-syntax`): syntax of the plugin's own
|
|
/// languages, for languages the IDE has no grammar for. The IDE calls it
|
|
/// with the whole document; results are flat. Offsets are UTF-8 byte offsets
|
|
/// into `text` (the IDE converts them); lines are 0-based.
|
|
interface syntax-provider {
|
|
/// One highlighted range. `kind` is a highlight category: keyword, string,
|
|
/// string-special, escape, regexp, atom, number, constant, comment,
|
|
/// doc-comment, function, function-call, builtin, type, namespace,
|
|
/// variable, self-variable, property, attribute, macro, label, tag,
|
|
/// operator, punctuation. Unknown kinds are ignored; ranges must be
|
|
/// sorted and not overlap.
|
|
record token {
|
|
start: u32,
|
|
end: u32,
|
|
kind: string,
|
|
}
|
|
|
|
/// A symbol of the structure view. `parent` is the index of the enclosing
|
|
/// symbol in the same list (which must come first).
|
|
record symbol {
|
|
name: string,
|
|
detail: option<string>,
|
|
/// class, interface, struct, enum, function, method, constructor,
|
|
/// field, property, variable, constant, module, namespace, event, …
|
|
kind: string,
|
|
start: u32,
|
|
end: u32,
|
|
name-start: u32,
|
|
name-end: u32,
|
|
parent: option<u32>,
|
|
}
|
|
|
|
/// A foldable line range. `kind`: region, comment or imports.
|
|
record fold {
|
|
start-line: u32,
|
|
end-line: u32,
|
|
kind: string,
|
|
}
|
|
|
|
highlights: func(language: string, text: string) -> list<token>;
|
|
outline: func(language: string, text: string) -> list<symbol>;
|
|
folding: func(language: string, text: string) -> list<fold>;
|
|
}
|
|
|
|
/// Optional Run Anything (Ctrl Ctrl) entries and command lines for the prefixes
|
|
/// the plugin declares under `[[contributes.runAnything]]` (API 1.18).
|
|
interface run-anything-provider {
|
|
record run-anything-item {
|
|
/// What the list shows, such as `task build`.
|
|
label: string,
|
|
/// Grey text after the label.
|
|
detail: option<string>,
|
|
/// The line Tab completes in the field and Enter runs (default: `label`).
|
|
line: option<string>,
|
|
}
|
|
/// Entries for `text`, the field's text, which starts with the declared `prefix`
|
|
/// (or is the start of it). Answer from what the plugin already knows: the IDE
|
|
/// asks while the user types, keeps the first 100 entries, and drops an answer
|
|
/// that comes after the text changed or takes longer than 300 ms.
|
|
suggest: func(project: string, prefix: string, text: string) -> list<run-anything-item>;
|
|
/// Runs `line`, whose first word is `prefix`, from the invoking window: the
|
|
/// plugin starts it through its own host calls (`run.start`, terminals), with
|
|
/// their trust and grant checks. True claims the line; false leaves it to the
|
|
/// IDE's other entries and finally the shell. A failed call claims the line
|
|
/// too, so it never runs in the shell instead.
|
|
run: func(project: string, prefix: string, line: string) -> bool;
|
|
}
|
|
|
|
/// Optional completion in the fields of this plugin's own run configurations, in
|
|
/// the Run/Debug Configurations dialog (API 1.18).
|
|
interface run-configuration-completion {
|
|
record completion-item {
|
|
/// What the list shows, such as `build`.
|
|
label: string,
|
|
/// Grey text after the label, such as the file the entry comes from.
|
|
detail: option<string>,
|
|
/// The text that replaces `[replace-start, replace-end)` (default: `label`).
|
|
insert: option<string>,
|
|
/// UTF-16 offsets into `text`; the caret ends after the inserted text.
|
|
replace-start: u32,
|
|
replace-end: u32,
|
|
}
|
|
/// Completions for `field` of the configuration `config` (its id as this plugin
|
|
/// reported it) in `project`. `field` is `arguments` today: the field splits like a
|
|
/// shell command line (whitespace separates arguments, `'` and `"` quote). Later
|
|
/// IDEs may ask for other fields, so answer none for a field you don't know.
|
|
/// `text` is the field as typed and `caret` a UTF-16 offset into it. Replace only
|
|
/// the token being completed, so the other options, quoted values and arguments
|
|
/// after `--` stay as they are. Answer from what the plugin already knows (no
|
|
/// process per keystroke): the IDE asks while the user types, keeps the first 200
|
|
/// items, drops an item whose range is outside `text`, and drops an answer that
|
|
/// comes after the text changed or takes longer than 300 ms.
|
|
complete: func(project: string, config: string, field: string, text: string, caret: u32) -> list<completion-item>;
|
|
}
|
|
|
|
/// Optional pre-launch gate for targets owned by this plugin (API 1.5).
|
|
interface run-target-validation {
|
|
enum operation { run, test }
|
|
record launch-info {
|
|
operation: operation,
|
|
/// Bare program name before wrapping; no arguments or environment.
|
|
program: string,
|
|
/// Absolute working directory on the machine hosting the plugin.
|
|
cwd: string,
|
|
}
|
|
/// Called after trust, ownership, process grants and executable pin checks.
|
|
/// An error refuses the launch without changing the selected target. The
|
|
/// host prefixes and bounds the message. Missing exports allow the launch.
|
|
/// Calls wake reclaimed instances, use the host call timeout (5s by default),
|
|
/// and are cancelled with the launch. Traps/timeouts refuse the launch.
|
|
/// For remote projects this runs on the server, where the plugin lives.
|
|
validate: func(project: string, target-id: string, launch: launch-info) -> result<_, string>;
|
|
}
|