Skip to main content

SemanticModel

Struct SemanticModel 

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

A file’s label definitions and reference uses.

Eq is load-bearing: the semantic_model salsa query is not no_eq (unlike parsed_document), so an edit leaving this model unchanged backdates and downstream queries are not re-run.

Implementations§

Source§

impl SemanticModel

Source

pub fn build(root: &SyntaxNode) -> Self

Build the model from a parse tree root.

Source

pub fn build_with_declarations( root: &SyntaxNode, declared: &ResolvedDeclarations, ) -> Self

Build the model under a project’s declared ref/cite command aliases.

Source

pub fn labels(&self) -> &[LabelDef]

Source

pub fn label(&self, id: LabelId) -> &LabelDef

Source

pub fn refs(&self) -> &[LabelRef]

Source

pub fn citations(&self) -> &[CitationRef]

The citation uses (\cite/\parencite/… keys) in this file.

Source

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

Whether name is a command whose arguments hold opaque keys rather than typeset text — a curated one (builder::key_argument_command) or a project-declared alias of one.

Answered by name, not by the ranges collected into refs and citations: a command whose key cannot be extracted (\myref{\textbf{a}} yields no LabelRef) still has a key argument, and a declared alias must not be gated more weakly than the built-in it copies.

Source

pub fn glossary_defs(&self) -> &[GlossaryDef]

The glossary/acronym key definitions (\newglossaryentry/\newacronym/…) in this file.

Source

pub fn color_defs(&self) -> &[ColorDef]

The color-name definitions (\definecolor/\providecolor/\colorlet) in this file, offered by color-name completion.

Source

pub fn has_wildcard_nocite(&self) -> bool

Whether the file contains a \nocite{*} wildcard.

Source

pub fn provides(&self) -> Option<&ProvidesDecl>

The file’s \ProvidesPackage/\ProvidesClass/\ProvidesFile self-identification.

Source

pub fn needs_format(&self) -> Option<&NeedsFormatDecl>

The file’s \NeedsTeXFormat declaration.

Source

pub fn options(&self) -> &[OptionDecl]

The file’s \DeclareOption declarations.

Source

pub fn reference(&self, id: RefId) -> &LabelRef

Source

pub fn unreferenced_labels(&self) -> impl Iterator<Item = LabelId> + '_

Label definitions never referenced within this file.

A per-file fact, not a lint signal: a label referenced only from another file looks unreferenced here. The cross-file unreferenced-label lint instead builds on the project-level project::resolved_labels (as undefined-ref does for refs), firing only in a closed, rooted namespace so it never false-positives on labels referenced from outside the analyzed set.

Source

pub fn unresolved_refs(&self) -> impl Iterator<Item = RefId> + '_

References whose key matches no \label in this file.

A per-file fact, not a lint signal: the key may be defined in an included file. The undefined-ref lint instead consults the cross-file project::resolved_labels, firing only in a closed, rooted document namespace.

Trait Implementations§

Source§

impl Debug for SemanticModel

Source§

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

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

impl Default for SemanticModel

Source§

fn default() -> SemanticModel

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

impl Eq for SemanticModel

Source§

impl PartialEq for SemanticModel

Source§

fn eq(&self, other: &SemanticModel) -> 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 SemanticModel

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<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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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.