pub struct Signatures<'a> { /* private fields */ }Expand description
A two-tier signature lookup: a per-document SignatureDb of scanned
\newcommand/\newenvironment/xparse definitions consulted first, falling back
to the process-wide builtin DB. Cheap to copy (it borrows the scanned DB),
so it threads through the formatter’s lowering like a context handle.
Scanned-first matches TeX scoping intuition: a locally (re)defined command shadows a built-in of the same name. (We do not yet model where a definition becomes visible — a whole-file union — which is sound for the formatter’s arity needs; lexical/conditional visibility is out of scope, per AGENTS.md #1.)
Implementations§
Source§impl<'a> Signatures<'a>
impl<'a> Signatures<'a>
Sourcepub fn new(user: &'a SignatureDb) -> Self
pub fn new(user: &'a SignatureDb) -> Self
Resolve against user first, then the built-in DB.
Sourcepub fn command(&self, name: &str) -> Option<&'a CommandSig>
pub fn command(&self, name: &str) -> Option<&'a CommandSig>
The signature of command name: scanned definition first, then the curated
built-in, then the bulk CWL tier. CWL is consulted last and contributes only
argument arity (its behavior flags are all default), so a CWL-only command is
laid out like any unknown command, just with its argument count known.
Sourcepub fn environment(&self, name: &str) -> Option<&'a EnvironmentSig>
pub fn environment(&self, name: &str) -> Option<&'a EnvironmentSig>
The signature of environment name: scanned, then built-in, then CWL. See
command for why the CWL tier is safe to consult here.
Environment aliases are deliberately not consulted: an alias names a
command, and a name alone cannot tell a \bea-opened delimiter from a
literal \begin{bea} that happens to spell the same word. Resolve those
through environment_at, which has the node.
Sourcepub fn environment_at(&self, node: &SyntaxNode) -> Option<&'a EnvironmentSig>
pub fn environment_at(&self, node: &SyntaxNode) -> Option<&'a EnvironmentSig>
The signature governing node — an ENVIRONMENT or its BEGIN — which is
environment except that an environment-alias
delimiter resolves through the alias map instead.
This is the node-keyed lookup every layout decision wants, because an alias
BEGIN (a bare control word, Begin::is_alias) and a literal \begin{X}
are indistinguishable once reduced to a name. Only the former inherits the
target’s behavior; a literal \begin{bea} in a file that also defines \bea
as an alias is an unrelated environment of that name and stays unknown.
The alias arm resolves against curated data only, for the same reason
the parser’s ParseCtx::is_math_environment does: an alias declares a
spelling, never a semantic, so every behavior flag still comes from
curated data. That means builtin plus the scope’s declared entries
— a declaration is curated (like copies a built-in entry and resolves
against nothing else), which is what lets \startmyenv … \endmyenv reach
the behavior of a myenv that has no built-in counterpart. A scanned
\newenvironment of the same name still lends an alias nothing.
Trait Implementations§
Source§impl<'a> Clone for Signatures<'a>
impl<'a> Clone for Signatures<'a>
Source§fn clone(&self) -> Signatures<'a>
fn clone(&self) -> Signatures<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more