class

Krikri::YamlSourceMap

Inherits Reference < Object

Structural source positions for every node of a YAML document, keyed by a "/"-joined path of mapping keys and sequence indices ("0/tasks/2" = the third task of the first play's tasks: section; "4" = the fifth entry of a bare task-file list). The parser's own YAML::Any tree carries no position information (Crystal's YAML::Node has no marks), so the positions come from a second, cheap pass over the raw libyaml event stream - the same parser Crystal's YAML.parse uses, so the structure (and therefore the path correspondence) is identical by construction, and the marks are byte-identical to Ansible's own libyaml-derived Origin positions (0-based mark -> 1-based line/col).

Used only to label task-failure error blocks with their playbook origin; a scan failure or a missing path simply yields no position and the block is omitted (never fatal).

Constructors

scan(content : String) : YamlSourceMap
Source

Instance methods

all_suffix_at?(suffix : String) : Array(Pos)

Every position whose path ends with suffix, in document order - the counting form of #suffix_at?, for callers that must refuse an ambiguous origin (two matches = two candidate defining sites; the caller's exactly-one-match rule then hides the origin instead of mislabeling it).

Source
at?(path : String) : Pos | Nil
Source
collection_key_pos

The start mark of the mapping holding a collection used AS a mapping key (first occurrence in document order), 1-based line/column - ansible-core 2.19 refuses such a file at load time (rc=4, "This may be an issue with missing quotes around a template block."), because an unquoted key: {{ x }} parses as a flow mapping whose key is itself a mapping, and Ansible's loader rejects collection keys. krikri's own YAML layer happily builds that structure, so this is the only signal that the file needs the quoting refusal.

Source
duplicate_keys
Source
path_at?(line : Int32, column : Int32) : String | Nil

The first (document-order) source-map path whose recorded position equals (line, column) - for recovering the PATH of a node whose position is already known (a VarOrigin's value token), so a chain of container accesses can descend from it to the nested node's own position. nil when no node starts exactly there.

Source
plays

The top-level sequence entries as (index, start line) pairs sorted by position - for a playbook these are its plays, letting callers locate which play a given source line belongs to.

Source
suffix_at?(suffix : String) : Pos | Nil

The first (document-order) position whose path ends with suffix - for locating a nested var's value inside a file whose top-level wrapping differs by source kind ("0/vars/n/a" in a playbook vs "n/a" in a vars file).

Source

Nested types