Expand description
Single-file semantic analysis: the per-file label/reference def-use model.
LaTeX labels live in one document/project-global namespace — there is no
lexical scoping — so the model is a flat pair of vectors (defs + refs),
not a scope tree. It is built in one
CST walk by builder::build, then a resolve pass marks each def
referenced and each ref resolved by matching keys. No caching lives
here; the incremental salsa layer (in the badness crate) owns that, via
the semantic_model query.
Cross-file resolution is deferred. A label defined in an \input-ed file
and referenced here resolves only once a project-level query unions label
sets across the include graph. This slice is per-file only — “harness + model
only”, like incremental and the project graph landed.
Re-exports§
pub use define::DefSite;pub use define::DefSiteKind;pub use define::scan_definition_sites;pub use define::scan_definitions;pub use doc::DocAssociation;pub use doc::DocKind;pub use doc::doc_associations;pub use label::CitationRef;pub use label::ColorDef;pub use label::ColorDefKind;pub use label::GlossaryDef;pub use label::GlossaryDefKind;pub use label::LabelDef;pub use label::LabelId;pub use label::LabelRef;pub use label::RefCommand;pub use label::RefId;pub use outline::LabelContext;pub use outline::OutlineItem;pub use outline::OutlineSymbol;pub use outline::label_context;pub use outline::outline;pub use pkgmeta::NeedsFormatDecl;pub use pkgmeta::OptionDecl;pub use pkgmeta::ProvidesDecl;pub use pkgmeta::ProvidesKind;pub use signature::ArgKind;pub use signature::ArgSpec;pub use signature::CommandSig;pub use signature::ContentKind;pub use signature::EnvironmentSig;pub use signature::SignatureDb;pub use signature::Signatures;
Modules§
- builder
- Build the per-file label/reference model from the CST.
- define
- Scan a document for user definitions —
\newcommand/\newenvironmentand the xparse\NewDocument…family — and extract their argument signatures into a per-documentSignatureDb. Signatures only: we read the declared argument shape, never the replacement text, and never execute anything (AGENTS.md non-goals and decision #1). - doc
- Associate
.dtxdocumentation prose with the macro/environment it documents. - expl3
- The expl3 call-site model: argspec arity for expl3 function names, and the statement segmentation built on it.
- label
- Label definitions and reference uses — the data of the per-file
label/reference model:
Vec-stored records addressed by newtype ids. - outline
- Build a document-symbol outline from the CST: the sectioning hierarchy
(
\part…\subparagraph), with float/theorem environments,\labels, and a.dtx’s documented macros/environments (viadoc_associations) as leaves. LSP-agnostic by design (byte ranges, nolsp_types) so it is unit-testable without the language server; thelspmodule converts theOutlineItemtree intolsp_types::DocumentSymbol. - pkgmeta
- Static recognition of the package/class authoring commands — the metadata a
.sty/.clsdeclares about itself. We read the declared facts only; nothing is ever executed (AGENTS.md non-goals). - signature
- The built-in signature database: command/environment argument shapes plus the semantic metadata a formatter/linter needs (sectioning level, verbatim-ness, math-ness). This is the place where meaning is assigned to names, kept strictly out of the parser (AGENTS.md decision #2).
- xparse
- Parser for the xparse argument specification mini-language — the string in
the second group of
\NewDocumentCommand{\foo}{<spec>}{…}(and the environment variants). It is parsed, never executed (AGENTS.md decision #1): we read the shape of each argument, not its processing.
Structs§
- Semantic
Model - A file’s label definitions and reference uses.