pub struct AstRoot<D>where
D: Doc,{ /* private fields */ }Expand description
Root of an AST tree that owns the source code and parsed tree structure.
Root acts as the entry point for all AST operations. It manages the document (source code + parsed tree) and provides methods to get the root node and perform tree-wide operations like replacements.
§Generic Parameters
D: Doc- The document type that holds source code and language information
§Example
let mut ast = Language::Tsx.ast_grep("let x = 42;");
let root_node = ast.root();
// Perform tree-wide replacements
ast.replace("let $VAR = $VALUE", "const $VAR = $VALUE");
println!("{}", ast.generate());Implementations§
Source§impl<D> Root<D>where
D: Doc,
impl<D> Root<D>where
D: Doc,
Source§impl<L> Root<StrDoc<L>>where
L: LanguageExt,
impl<L> Root<StrDoc<L>>where
L: LanguageExt,
Source§impl<L> Root<StrDoc<L>>where
L: LanguageExt,
impl<L> Root<StrDoc<L>>where
L: LanguageExt,
Trait Implementations§
Auto Trait Implementations§
impl<D> Freeze for Root<D>where
D: Freeze,
impl<D> RefUnwindSafe for Root<D>where
D: RefUnwindSafe,
impl<D> Send for Root<D>
impl<D> Sync for Root<D>
impl<D> Unpin for Root<D>where
D: Unpin,
impl<D> UnsafeUnpin for Root<D>where
D: UnsafeUnpin,
impl<D> UnwindSafe for Root<D>where
D: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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