Skip to main content

OriginMap

Struct OriginMap 

Source
pub struct OriginMap {
    pub definition: HashMap<NodeId, CstNodeId>,
    pub value: HashMap<NodeId, CstNodeId>,
    pub key: HashMap<(NodeId, ObjectKey), CstNodeId>,
    pub key_span: HashMap<(NodeId, ObjectKey), InputSpan>,
    pub key_span_by_cst: HashMap<(CstNodeId, ObjectKey), InputSpan>,
}
Expand description

Origin tracking for document nodes and map keys.

This structure provides span resolution for error reporting:

  • definition: Where the node’s key/name is defined (for MissingRequiredField)
  • value: The full value expression (for TypeMismatch, etc.)
  • key: Maps (MapNodeId, ObjectKey) to the key’s CstNodeId (for precise key spans)

Fields§

§definition: HashMap<NodeId, CstNodeId>

Definition span (where the node’s key/name is defined). Only the first definition is kept (via entry().or_insert()).

§value: HashMap<NodeId, CstNodeId>

Value span (the full value expression). Later values overwrite earlier ones.

§key: HashMap<(NodeId, ObjectKey), CstNodeId>

(MapNodeId, ObjectKey) -> key’s CstNodeId. Used for precise error spans on map keys.

§key_span: HashMap<(NodeId, ObjectKey), InputSpan>

Direct span storage for special cases (e.g., split float keys). Used when we need precise sub-spans that don’t correspond to a single CST node.

§key_span_by_cst: HashMap<(CstNodeId, ObjectKey), InputSpan>

CST-based key span storage: (CstNodeId, ObjectKey) -> InputSpan. Used for error reporting when we only have the CST node ID, not the document NodeId.

Implementations§

Source§

impl OriginMap

Source

pub fn new() -> Self

Create a new empty OriginMap.

Source

pub fn record_definition(&mut self, node_id: NodeId, cst_node_id: CstNodeId)

Record a definition span for a node (typically the key). Only the first definition is kept.

Source

pub fn record_value(&mut self, node_id: NodeId, cst_node_id: CstNodeId)

Record a value span for a node (the full expression). Later values overwrite earlier ones.

Source

pub fn record_key( &mut self, map_node_id: NodeId, key: ObjectKey, cst_node_id: CstNodeId, )

Record a map key origin.

Source

pub fn record_key_span( &mut self, map_node_id: NodeId, key: ObjectKey, span: InputSpan, )

Record a map key origin with direct InputSpan. Used for special cases where the key span doesn’t correspond to a CST node.

Source

pub fn record_key_span_by_cst( &mut self, cst_node_id: CstNodeId, key: ObjectKey, span: InputSpan, )

Record a map key origin with direct InputSpan, indexed by CST node ID. Used for error reporting when we only have the CST node ID.

Source

pub fn get_value_span(&self, node_id: NodeId, cst: &Cst) -> Option<InputSpan>

Get the value span for a node (the full value expression). Used for TypeMismatch and other value-related errors.

Source

pub fn get_definition_span( &self, node_id: NodeId, cst: &Cst, ) -> Option<InputSpan>

Get the definition span for a node (where the key is defined). Used for MissingRequiredField errors to point to where the record is defined.

Source

pub fn get_key_span( &self, map_node_id: NodeId, key: &ObjectKey, cst: &Cst, ) -> Option<InputSpan>

Get the span for a specific map key.

Trait Implementations§

Source§

impl Clone for OriginMap

Source§

fn clone(&self) -> OriginMap

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for OriginMap

Source§

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

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

impl Default for OriginMap

Source§

fn default() -> OriginMap

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

impl PartialEq for OriginMap

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for OriginMap

Source§

impl StructuralPartialEq for OriginMap

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

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

Compare self to key and return true if they are equal.
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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> QueryOutput for T
where T: PartialEq + Send + Sync + 'static,