Skip to main content

SheetDiagnostics

Struct SheetDiagnostics 

Source
pub struct SheetDiagnostics {
Show 13 fields pub cell_names: IndexMap<String, (CellId, TypeShape)>, pub output_names: IndexMap<String, CellId>, pub requirement_names: HashMap<RequirementId, String>, pub requirement_labels: HashMap<RequirementId, SourceLabel>, pub method_spans: HashMap<(RelationshipId, usize), SourceSpan>, pub relationship_spans: HashMap<RelationshipId, SourceSpan>, pub cell_spans: HashMap<CellId, SourceSpan>, pub sources: Vec<SourceId>, pub anonymous_source: Option<SourceId>, pub instance_origins: Vec<InstanceOrigin>, pub method_origins: HashMap<(RelationshipId, usize), MethodOrigin>, pub cell_origins: HashMap<CellId, Vec<CellOrigin>>, pub cell_shapes: HashMap<CellId, TypeShape>,
}
Expand description

Retains source and native provenance without owning or borrowing a Sheet.

The snapshot owns names, spans, source identities, requirement labels, and expansion provenance. Its immutable source owners and authored records may share backing storage with the parsed model.

§Examples

let diagnostics = adam_lang::ParsedSheet::new().diagnostics();
assert!(diagnostics.sources().is_empty());

Fields§

§cell_names: IndexMap<String, (CellId, TypeShape)>

Public root cell names and their IDs and complete shapes, in declaration order.

§output_names: IndexMap<String, CellId>

Public output names and their IDs, in declaration order.

§requirement_names: HashMap<RequirementId, String>

Explicit requirement names keyed by runtime requirement ID.

§requirement_labels: HashMap<RequirementId, SourceLabel>

Requirement IDs mapped to authored source labels, including unnamed checks.

§method_spans: HashMap<(RelationshipId, usize), SourceSpan>

Root-local method spans keyed by relationship ID and method index.

§relationship_spans: HashMap<RelationshipId, SourceSpan>

Root-local relationship spans keyed by relationship ID.

§cell_spans: HashMap<CellId, SourceSpan>

Root-local declaration spans keyed by cell ID.

§sources: Vec<SourceId>

Retained source owners in insertion order.

§anonymous_source: Option<SourceId>

Anonymous convenience source used for caller-selected display names.

§instance_origins: Vec<InstanceOrigin>

Parent-linked native occurrence provenance.

§method_origins: HashMap<(RelationshipId, usize), MethodOrigin>

Authored method origins keyed by runtime relationship and method index.

§cell_origins: HashMap<CellId, Vec<CellOrigin>>

Authored cell origins keyed by runtime cell ID.

§cell_shapes: HashMap<CellId, TypeShape>

Complete shapes for root and private cells.

Implementations§

Source§

impl SheetDiagnostics

Source

pub fn locate_error(&self, error: &Error) -> Vec<SourceLabel>

Resolves an error to owning definition and invocation labels.

  • Complexity: O(o + m + c + k + p × a + q × a + l²) time and O(o + m + c + k + l) space for occurrences o, methods m, public cells c, conditionals k, candidate cell origins p, visited occurrence/ancestor records q, local authored items a, and returned labels l.
§Examples
use adam_lang::{AdamParser, TypeRegistry};
let mut parsed = AdamParser::new(TypeRegistry::new(), cel_parser::OpLookup::new())
    .parse_str("sheet s { cell x: i32 = 0; cell y: i32; relationship { y := 10i32 / x; } }")?;
let diagnostics = parsed.diagnostics();
let error = parsed.propagate().unwrap_err();
assert!(!diagnostics.locate_error(&error).is_empty());
Source

pub fn sources(&self) -> &[SourceId]

Borrows retained source owners in their original insertion order.

§Examples
use adam_lang::{AdamParser, TypeRegistry};
let parsed = AdamParser::new(TypeRegistry::new(), cel_parser::OpLookup::new())
    .parse_str("sheet s { cell x: i32 = 1; }")?;
assert_eq!(parsed.diagnostics().sources().len(), 1);
Source

pub fn anonymous_source(&self) -> Option<&SourceId>

Borrows the anonymous convenience source used for caller-selected display names.

§Examples
use adam_lang::{AdamParser, TypeRegistry};
let parsed = AdamParser::new(TypeRegistry::new(), cel_parser::OpLookup::new())
    .parse_str("sheet s { cell x: i32 = 1; }")?;
assert_eq!(parsed.diagnostics().anonymous_source().unwrap().file_name(), "<input>");

Trait Implementations§

Source§

impl Clone for SheetDiagnostics

Source§

fn clone(&self) -> Self

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 SheetDiagnostics

Source§

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

Formats the value using the given formatter. Read more

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

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

fn try_from(value: U) -> Result<T, !>

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.