Skip to main content

PreciseBackend

Trait PreciseBackend 

Source
pub trait PreciseBackend: Send + Sync {
    // Required methods
    fn find_definitions(
        &self,
        symbol: &str,
        file_path: &str,
        line: usize,
    ) -> Result<Vec<SearchCandidate>>;
    fn find_references(
        &self,
        symbol: &str,
        file_path: &str,
        line: usize,
    ) -> Result<Vec<SearchCandidate>>;
    fn hover(
        &self,
        file_path: &str,
        line: usize,
        column: usize,
    ) -> Result<Option<String>>;
    fn diagnostics(&self, file_path: &str) -> Result<Vec<CodeDiagnostic>>;
    fn source(&self) -> IntelligenceSource;
    fn has_index_for(&self, file_path: &str) -> bool;
}
Expand description

Trait for optional precise code intelligence backends (LSP, SCIP).

The engine’s default fast path uses tree-sitter for all operations. When a precise backend is available, it supplements or replaces tree-sitter results with type-aware, cross-file intelligence.

Implementors: ScipIndex (planned), LspClient (planned).

§Usage

if let Some(precise) = engine.precise_backend() {
    let defs = precise.find_definitions("MyStruct", "src/lib.rs", 42)?;
    // defs carry IntelligenceSource::Scip or ::Lsp
} else {
    // fall back to tree-sitter search
}

Required Methods§

Source

fn find_definitions( &self, symbol: &str, file_path: &str, line: usize, ) -> Result<Vec<SearchCandidate>>

Find definitions of a symbol at the given location.

Source

fn find_references( &self, symbol: &str, file_path: &str, line: usize, ) -> Result<Vec<SearchCandidate>>

Find all references to a symbol at the given location.

Source

fn hover( &self, file_path: &str, line: usize, column: usize, ) -> Result<Option<String>>

Get hover documentation for a symbol.

Source

fn diagnostics(&self, file_path: &str) -> Result<Vec<CodeDiagnostic>>

Get diagnostics for a file.

Source

fn source(&self) -> IntelligenceSource

Which intelligence source this backend provides.

Source

fn has_index_for(&self, file_path: &str) -> bool

Whether this backend has an index for the given file.

Implementors§