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>,
}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
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) -> Value
fn resolve_scalar_type(&self, value: String) -> Value
Resolve scalar type from string value
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
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CommentPreservingComposer
impl !RefUnwindSafe for CommentPreservingComposer
impl Send for CommentPreservingComposer
impl Sync for CommentPreservingComposer
impl Unpin for CommentPreservingComposer
impl !UnwindSafe for CommentPreservingComposer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more