pub struct Field(/* private fields */);Implementations§
Source§impl Field
impl Field
Sourcepub fn name(&self) -> SmolStr
pub fn name(&self) -> SmolStr
The field’s name, excluding any whitespace before the colon. Empty when
the source had no name at all (: value), which the parser also
diagnoses.
Sourcepub fn name_token(&self) -> Option<SyntaxToken>
pub fn name_token(&self) -> Option<SyntaxToken>
The FIELD_NAME token, absent for a nameless : value.
Sourcepub fn name_range(&self) -> TextRange
pub fn name_range(&self) -> TextRange
The name’s source range, collapsed to the colon’s start when there is no name token — so a diagnostic always has somewhere to point.
Sourcepub fn value_range(&self) -> TextRange
pub fn value_range(&self) -> TextRange
The range spanning every value line, or an empty range at the field’s
end when the field has no value at all (Package: at EOF).
Sourcepub fn value_lines(&self) -> impl Iterator<Item = ValueLine> + use<>
pub fn value_lines(&self) -> impl Iterator<Item = ValueLine> + use<>
The field’s value lines, starting with the field’s own line (everything after the colon) and continuing through its continuation lines.
Sourcepub fn comment_lines(&self) -> impl Iterator<Item = CommentLine> + use<>
pub fn comment_lines(&self) -> impl Iterator<Item = CommentLine> + use<>
Comment lines interleaved into this field’s continuation block. R’s
read.dcf skips them and resumes the field.
Sourcepub fn folded_value(&self) -> String
pub fn folded_value(&self) -> String
The field’s logical value: each nonempty value line trimmed, joined
with \n. This is what a caller wanting Depends or Roxygen reads.
Empty value lines contribute no segment, matching R’s read.dcf.
Sourcepub fn raw_value_text(&self) -> String
pub fn raw_value_text(&self) -> String
The exact source bytes of everything after the colon, newlines and interleaved comments included. For the formatter, which rewrites rather than reads.