Skip to main content

SignatureDb

Struct SignatureDb 

Source
pub struct SignatureDb { /* private fields */ }
Expand description

The built-in command and environment signatures, keyed by name (without the leading \ for commands, the bare name for environments). Case-sensitive, as LaTeX names are (Verbatimverbatim).

Implementations§

Source§

impl SignatureDb

Source

pub fn command(&self, name: &str) -> Option<&CommandSig>

The signature of command name (without the leading \), if known.

Source

pub fn environment(&self, name: &str) -> Option<&EnvironmentSig>

The signature of environment name, if known.

Source

pub fn command_names(&self) -> impl Iterator<Item = &str>

All known command names (without the leading \), in arbitrary order. Backs name completion, which unions these with the per-document scanned definitions; the lookup methods stay the only refinement path.

Source

pub fn environment_names(&self) -> impl Iterator<Item = &str>

All known environment names, in arbitrary order. See command_names.

Source

pub fn env_begin_alias(&self, name: &str) -> Option<&str>

The environment name opens, if the per-file scan recorded it as an environment alias (env_begin_aliases). The name carries no leading \.

Source

pub fn env_end_alias(&self, name: &str) -> Option<&str>

The closer mirror of env_begin_alias.

Source

pub fn env_begin_aliases(&self) -> impl Iterator<Item = (&str, &str)>

Every recorded opener alias, as (alias, target) pairs in arbitrary order. Backs the parser’s projection of the map into its parse context.

Source

pub fn env_end_aliases(&self) -> impl Iterator<Item = (&str, &str)>

The closer mirror of env_begin_aliases.

Source

pub fn insert_env_begin_alias( &mut self, name: impl Into<SmolStr>, target: impl Into<SmolStr>, )

Record an opener alias, replacing any existing entry for name.

Source

pub fn insert_env_end_alias( &mut self, name: impl Into<SmolStr>, target: impl Into<SmolStr>, )

Record a closer alias, replacing any existing entry for name.

Source

pub fn command_origin(&self, name: &str) -> Option<&str>

The package (file stem) whose merge supplied the current signature of command name, if it came from a package (merge_from_package) rather than the document or a static tier.

Source

pub fn environment_origin(&self, name: &str) -> Option<&str>

The environment mirror of command_origin.

Source

pub fn insert_command(&mut self, name: impl Into<SmolStr>, sig: CommandSig)

Record a command signature, replacing any existing entry for name. Used by the per-file definition scan (super::define) to populate a fresh DB; the built-in DB is built from JSON and never mutated. A redefinition wins, mirroring TeX’s last-\newcommand-wins behavior; any recorded package origin is cleared, since it described the entry being replaced.

Source

pub fn insert_environment( &mut self, name: impl Into<SmolStr>, sig: EnvironmentSig, )

Record an environment signature, replacing any existing entry for name.

Source

pub fn insert_declared_environment( &mut self, name: impl Into<SmolStr>, sig: EnvironmentSig, )

Record an environment signature that came from a project declaration, replacing any existing entry for name and marking its provenance. See declared_environments for why the mark exists.

Source

pub fn is_declared_environment(&self, name: &str) -> bool

Whether name’s signature came from a project declaration.

Source

pub fn merge_from(&mut self, other: &SignatureDb)

Merge every command and environment of other into self, with other winning on a name clash (last-definition-wins, like an individual insert_*). Used to fold a loaded package’s scanned definitions into a document’s merged signature scope; the caller orders the merges so the document’s own definitions are applied last and override any package.

Origins always describe the current entry: each merged name takes other’s origin when it has one, and clears any stale one of self’s otherwise — so the document overlay (scanned defs carry no origins) automatically strips package provenance from a shadowed name.

Source

pub fn merge_declarations(&mut self, declared: &ResolvedDeclarations)

Overlay a project’s resolved declarations as the top tier of this scope: a declaration is the user explicitly correcting an inference, so it wins over scanned definitions and loaded packages alike.

A named entry rather than merge_from(declared.as_db()) at each call site, so the precedence rule is stated once and the two scope builders (the CLI’s collect_package_signatures and the salsa scope_signatures) cannot disagree about where in the order it goes.

Source

pub fn merge_from_package(&mut self, other: &SignatureDb, origin: &str)

Like merge_from, additionally recording origin (a package file stem, e.g. mypkg) as the provenance of every merged name. Used when folding a loaded package’s scanned definitions into a document scope, so hover can name the defining package. Package-over-package: the last merge wins, consistent with the signature overwrite itself.

Trait Implementations§

Source§

impl Clone for SignatureDb

Source§

fn clone(&self) -> SignatureDb

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SignatureDb

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SignatureDb

Source§

fn default() -> SignatureDb

Returns the “default value” for a type. Read more
Source§

impl Eq for SignatureDb

Source§

impl PartialEq for SignatureDb

Source§

fn eq(&self, other: &SignatureDb) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SignatureDb

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.