Skip to main content

SourceMapBuilder

Struct SourceMapBuilder 

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

Builder for constructing a SourceMap during parsing.

Implementations§

Source§

impl SourceMapBuilder

Source

pub fn new(source: &str) -> Self

Create a new builder for the given source text.

Source

pub fn add_entry(&mut self, span: Span, kind: EntryKind, name: Option<String>)

Add an arbitrary entry to the source map.

Source

pub fn add_entry_with_type( &mut self, span: Span, kind: EntryKind, name: Option<String>, ty_info: String, )

Add an entry with type information.

Source

pub fn add_definition(&mut self, span: Span, name: &str)

Add a definition entry.

Source

pub fn add_definition_with_type( &mut self, span: Span, name: &str, ty_info: &str, )

Add a definition entry with type info.

Source

pub fn add_reference(&mut self, span: Span, name: &str)

Add a reference entry.

Source

pub fn add_binder(&mut self, span: Span, name: &str)

Add a binder entry.

Source

pub fn add_constructor(&mut self, span: Span, name: &str)

Add a constructor entry.

Source

pub fn add_keyword(&mut self, span: Span)

Add a keyword entry.

Source

pub fn add_literal(&mut self, span: Span)

Add a literal entry.

Source

pub fn add_operator(&mut self, span: Span, symbol: &str)

Add an operator entry.

Source

pub fn add_comment(&mut self, span: Span)

Add a comment entry.

Source

pub fn add_doc_comment(&mut self, span: Span, text: &str)

Add a doc comment entry.

Source

pub fn add_tactic(&mut self, span: Span, name: &str)

Add a tactic entry.

Source

pub fn add_pattern(&mut self, span: Span, name: Option<&str>)

Add a pattern entry.

Source

pub fn add_type_annotation(&mut self, span: Span)

Add a type annotation entry.

Source

pub fn add_semantic_token(&mut self, token: SemanticToken)

Add a pre-computed semantic token.

Source

pub fn entry_count(&self) -> usize

Get the current number of entries.

Source

pub fn build(self) -> SourceMap

Build the final SourceMap.

Entries are sorted by span start offset for efficient lookup.

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> 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 = 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.