pub struct Root<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: Doc> Root<D>
impl<D: Doc> Root<D>
Source§impl<L: LanguageExt> Root<StrDoc<L>>
impl<L: LanguageExt> Root<StrDoc<L>>
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