pub struct CommentPreservingComposer {
parser: BasicParser,
scanner: BasicScanner,
limits: Limits,
resource_tracker: ResourceTracker,
anchors: HashMap<String, CommentedValue>,
current_depth: usize,
alias_expansion_stack: Vec<String>,
comment_map: HashMap<Position, String>,
pending_comments: Vec<String>,
yaml_version: YamlVersion,
}Expand description
A composer that preserves comments during parsing
Fields§
§parser: BasicParser§scanner: BasicScanner§limits: Limits§resource_tracker: ResourceTracker§anchors: HashMap<String, CommentedValue>§current_depth: usize§alias_expansion_stack: Vec<String>§comment_map: HashMap<Position, String>Map of positions to comments (position -> comment text)
pending_comments: Vec<String>Stack of pending comments that might belong to the next value
yaml_version: YamlVersionActive YAML spec version for the current document.
Implementations§
Source§impl CommentPreservingComposer
impl CommentPreservingComposer
Sourcepub fn with_limits(input: String, limits: Limits) -> Self
pub fn with_limits(input: String, limits: Limits) -> Self
Create a new comment-preserving composer with limits
Sourcefn extract_comments(&mut self) -> Result<()>
fn extract_comments(&mut self) -> Result<()>
Extract comments from the scanner and build a position map
Sourcefn get_comments_for_position(&self, position: Position) -> Comments
fn get_comments_for_position(&self, position: Position) -> Comments
Get comments that should be associated with a value at the given position
Sourcepub fn compose_document(&mut self) -> Result<Option<CommentedValue>>
pub fn compose_document(&mut self) -> Result<Option<CommentedValue>>
Compose a single document with comment preservation
Sourcefn compose_node(&mut self) -> Result<Option<CommentedValue>>
fn compose_node(&mut self) -> Result<Option<CommentedValue>>
Compose a single node (value) with comments
Sourcefn compose_scalar(
&mut self,
value: String,
anchor: Option<String>,
position: Position,
) -> Result<Option<CommentedValue>>
fn compose_scalar( &mut self, value: String, anchor: Option<String>, position: Position, ) -> Result<Option<CommentedValue>>
Compose a scalar value
Sourcefn resolve_scalar_type(
&self,
value: String,
position: Position,
) -> Result<Value>
fn resolve_scalar_type( &self, value: String, position: Position, ) -> Result<Value>
Resolve scalar type from string value (version-aware).
Returns Err when the YAML 1.1 = value tag is detected — the
CommentedValue tree has no tagged-scalar representation, so we
surface the same error as the other composers (matches
ruamel.yaml typ="safe").
Sourcefn compose_sequence(
&mut self,
anchor: Option<String>,
position: Position,
) -> Result<Option<CommentedValue>>
fn compose_sequence( &mut self, anchor: Option<String>, position: Position, ) -> Result<Option<CommentedValue>>
Compose a sequence
Sourcefn compose_mapping(
&mut self,
anchor: Option<String>,
position: Position,
) -> Result<Option<CommentedValue>>
fn compose_mapping( &mut self, anchor: Option<String>, position: Position, ) -> Result<Option<CommentedValue>>
Compose a mapping
Sourcefn compose_alias(
&mut self,
anchor: String,
position: Position,
) -> Result<Option<CommentedValue>>
fn compose_alias( &mut self, anchor: String, position: Position, ) -> Result<Option<CommentedValue>>
Compose an alias reference
Sourcefn collect_item_comments(
&self,
item: &CommentedValue,
inner_comments: &mut Vec<String>,
)
fn collect_item_comments( &self, item: &CommentedValue, inner_comments: &mut Vec<String>, )
Collect comments from a commented value’s comments into inner comments
Sourcefn collect_comments(
&self,
comments: &Comments,
inner_comments: &mut Vec<String>,
)
fn collect_comments( &self, comments: &Comments, inner_comments: &mut Vec<String>, )
Collect comments from a Comments struct into inner comments