pub trait AsyncContextSource:
Send
+ Sync
+ Debug {
// Required methods
fn source_id(&self) -> u64;
fn produce(
&self,
buffer_id: u64,
path: Option<PathBuf>,
line_count: u32,
syntax: Option<Arc<dyn Any + Send + Sync>>,
) -> ContextFuture<'_>;
}Expand description
An async, off-render-path producer of a buffer’s structural context scopes.
The renderer NEVER calls this, and neither does anything on the keystroke path. The host drives it when a reparse completes, stamps the result with the parse version, and publishes it; resolution against a pane’s anchor and viewport is native and happens per publish.
Required Methods§
Sourcefn source_id(&self) -> u64
fn source_id(&self) -> u64
Stable id of the producing plugin — the teardown key. Two producers with
the same id are the same plugin (a reload replaces rather than
duplicates), mirroring
AsyncGutterDecorationSource::source_id.
Sourcefn produce(
&self,
buffer_id: u64,
path: Option<PathBuf>,
line_count: u32,
syntax: Option<Arc<dyn Any + Send + Sync>>,
) -> ContextFuture<'_>
fn produce( &self, buffer_id: u64, path: Option<PathBuf>, line_count: u32, syntax: Option<Arc<dyn Any + Send + Sync>>, ) -> ContextFuture<'_>
Produce this buffer’s context scopes off the render path.
path is the buffer’s on-disk path when it has one; line_count bounds
the addressable lines.
syntax is the buffer’s parse snapshot, type-erased — the same
Option<Arc<dyn Any + Send + Sync>> shape ActionContext::syntax uses
(lattice-grammar), and for the same reason: lattice-mode must not
depend on lattice-syntax, so the implementor downcasts. None means
the buffer has no parse (plain text, or one still pending), and a
producer with nothing to work from returns an empty list rather than an
error — “no tree yet” is a normal state, not a failure.
The caller acquires syntax at the same instant as line_count so the
tree and the text agree on version (the tree-sitter seam’s §7 rule).
See ContextFuture for the Ok/Err contract.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".