pub struct ParsedReplacementBody {
pub source: String,
pub tree: Tree,
pub body_offset: usize,
pub parameters: Vec<String>,
/* private fields */
}Expand description
A function-like macro replacement parsed inside a sentinel function body.
Tree-sitter keeps a #define NAME(a) ... replacement as one opaque
preproc_arg. Wrapping that exact byte slice in a function body recovers
its statements, declarations, and member calls as ordinary C++ structure.
The slice is copied verbatim at Self::body_offset, so a node range in
Self::tree maps back onto the defining preproc_arg by subtracting
that offset.
Fields§
§source: String§tree: Tree§body_offset: usize§parameters: Vec<String>Implementations§
Source§impl ParsedReplacementBody
impl ParsedReplacementBody
Sourcepub fn statements(&self) -> Option<Node<'_>>
pub fn statements(&self) -> Option<Node<'_>>
The sentinel function body holding the replacement’s statements.
Sourcepub fn file_range(
&self,
node: Node<'_>,
replacement_start: usize,
) -> Range<usize> ⓘ
pub fn file_range( &self, node: Node<'_>, replacement_start: usize, ) -> Range<usize> ⓘ
The byte range node occupies in the file that defines the macro.
replacement_start is the logical replacement span’s start byte.
The origin map accounts for continuation whitespace and any synthetic
statement separators inserted while parsing the replacement.
Auto Trait Implementations§
impl Freeze for ParsedReplacementBody
impl RefUnwindSafe for ParsedReplacementBody
impl Send for ParsedReplacementBody
impl Sync for ParsedReplacementBody
impl Unpin for ParsedReplacementBody
impl UnsafeUnpin for ParsedReplacementBody
impl UnwindSafe for ParsedReplacementBody
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more