Skip to main content

Crate gritpack_searchlib

Crate gritpack_searchlib 

Source
Expand description

Compiler-facing resolver and grammar integration surface for Gritpack.

This crate is the handoff boundary for compiler, language-server, and other language-tooling integrations. It intentionally exposes the narrow read-side resolver API, the build-side grammar publication helpers, and the shared grammar model types.

§Who This Is For

gritpack-searchlib is for compiler and toolchain authors who need to work against a compiled Gritpack project snapshot.

The primary workflow is:

  1. define grammar metadata in grammar
  2. publish that metadata into an existing project snapshot with build
  3. reopen the snapshot through resolver
  4. start from authoritative participating files
  5. use grammar-aware narrowing only as an optimization layer

§Public Modules

  • build publishes grammar specifications and external-driver payloads into a project snapshot
  • grammar defines the build-side grammar model and query-time capability contract
  • resolver exposes the read-only resolver API over compiled snapshot state

§Correctness Model

The key rule for consumers is:

  • participating files are the correctness baseline
  • grammar-aware queries are narrowing optimizations over that baseline

If a narrowing answer is non-authoritative, callers should fall back to the broader participating-file set before making semantic decisions.

§Quick Start

use gritpack_searchlib::grammar::GrammarId;
use gritpack_searchlib::resolver::{
    LoadedProjectResolver, ModuleQuery, PackageScope, ParticipatingFileQuery,
    QuerySelection, ReferenceQuery,
};

let resolver = LoadedProjectResolver::open(std::path::Path::new("/workspace/project")).await?;

let participating = resolver.participating_files(&ParticipatingFileQuery {
    package_scope: PackageScope::AnyDependency,
});
assert!(participating.authoritative);

let grammar = GrammarId {
    dialect: "lumen/1.0.0".to_string(),
    name: "modules".to_string(),
    version: 1,
};

match resolver.files_for_query(
    &grammar,
    &ReferenceQuery::Modules(vec![ModuleQuery {
        package_scope: PackageScope::AnyDependency,
        name: "demo::thing".to_string(),
    }]),
)? {
    Some(QuerySelection::Files(selection)) if selection.authoritative => {
        for path in selection.file_paths {
            println!("candidate={path}");
        }
    }
    _ => {}
}

Modules§

build
Build-side helpers for publishing grammar data into a Gritpack resolver snapshot.
grammar
Build-side grammar model for Gritpack resolver indexes.
resolver
Read-only resolver API over a compiled Gritpack project snapshot.

Enums§

CliError