mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-08 08:52:12 +00:00
Plugin API 1.2 gains an optional document-indexer export (plugin-indexing world). A plugin returns per document the keys it defines and refers to, aliases between key prefixes and gutter markers; the host indexes a trusted project in cancellable background batches, keeps the project-wide graph, and answers Go to Declaration / Ctrl-click and multi-target gutter markers from memory without calling the plugin again. Edits and file changes invalidate the affected entries; reload, disable or a failing runtime drops the plugin's graph. The interface is limited to cross-file associations: icons chosen by file content and embedded-language regions are separate concerns for later interfaces. The plugin navigation choosers' titles are translated. Co-authored-by: qjlqyf <[email protected]>
47 lines
1.2 KiB
Rust
47 lines
1.2 KiB
Rust
//! Background document indexing (`[[contributes.documentIndexers]]`): return
|
|
//! the keys a document defines and refers to; the host keeps the project-wide
|
|
//! graph and resolves Go to Declaration and gutter markers from it. Register
|
|
//! with `register_plugin!(Plugin, indexing)`.
|
|
use crate::Range;
|
|
|
|
/// A symbol the host's syntax support found in the document.
|
|
#[derive(Clone, Debug)]
|
|
pub struct Symbol {
|
|
pub name: String,
|
|
pub kind: String,
|
|
pub container: Option<String>,
|
|
pub range: Range,
|
|
}
|
|
|
|
pub struct Document {
|
|
pub path: String,
|
|
pub text: String,
|
|
pub symbols: Vec<Symbol>,
|
|
}
|
|
|
|
/// A range tied to a key the plugin chooses.
|
|
#[derive(Clone, Debug)]
|
|
pub struct Anchor {
|
|
pub key: String,
|
|
pub range: Range,
|
|
}
|
|
|
|
/// Keys starting with `prefix` also resolve under `target` (both end with `#`).
|
|
pub struct Alias {
|
|
pub prefix: String,
|
|
pub target: String,
|
|
}
|
|
|
|
#[derive(Default)]
|
|
pub struct Edges {
|
|
pub definitions: Vec<Anchor>,
|
|
pub references: Vec<Anchor>,
|
|
pub aliases: Vec<Alias>,
|
|
/// Gutter icons that go to the definitions of their key.
|
|
pub markers: Vec<Anchor>,
|
|
}
|
|
|
|
pub trait DocumentIndexer {
|
|
fn index(&mut self, doc: &Document) -> Edges;
|
|
}
|