Struct ast_grep_core::meta_var::MetaVarEnv
source · pub struct MetaVarEnv<'tree, D: Doc> { /* private fields */ }
Expand description
a dictionary that stores metavariable instantiation const a = 123 matched with const a = $A will produce env: $A => 123
Implementations§
source§impl<'tree, D: Doc> MetaVarEnv<'tree, D>
impl<'tree, D: Doc> MetaVarEnv<'tree, D>
pub fn new() -> Self
pub fn insert( &mut self, id: MetaVariableID, ret: Node<'tree, D> ) -> Option<&mut Self>
pub fn insert_multi( &mut self, id: MetaVariableID, ret: Vec<Node<'tree, D>> ) -> Option<&mut Self>
pub fn insert_transformation( &mut self, name: MetaVariableID, src: Vec<<<D as Doc>::Source as Content>::Underlying> )
pub fn get_match(&self, var: &str) -> Option<&Node<'tree, D>>
pub fn get_multiple_matches(&self, var: &str) -> Vec<Node<'tree, D>>
pub fn get_transformed( &self, var: &str ) -> Option<&Vec<<<D as Doc>::Source as Content>::Underlying>>
pub fn get_var_bytes<'s>( &'s self, var: &MetaVariable ) -> Option<&'s [<D::Source as Content>::Underlying]>
pub fn add_label(&mut self, label: &str, node: Node<'tree, D>)
pub fn get_labels(&self, label: &str) -> Option<&Vec<Node<'tree, D>>>
pub fn get_matched_variables(&self) -> impl Iterator<Item = MetaVariable> + '_
pub fn match_constraints( &self, var_matchers: &MetaVarMatchers<impl Doc<Lang = D::Lang>> ) -> bool
Trait Implementations§
source§impl<'tree, D: Clone + Doc> Clone for MetaVarEnv<'tree, D>
impl<'tree, D: Clone + Doc> Clone for MetaVarEnv<'tree, D>
source§fn clone(&self) -> MetaVarEnv<'tree, D>
fn clone(&self) -> MetaVarEnv<'tree, D>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<'tree, D: Doc> Default for MetaVarEnv<'tree, D>
impl<'tree, D: Doc> Default for MetaVarEnv<'tree, D>
Auto Trait Implementations§
impl<'tree, D> RefUnwindSafe for MetaVarEnv<'tree, D>where D: RefUnwindSafe, <<D as Doc>::Source as Content>::Underlying: RefUnwindSafe,
impl<'tree, D> !Send for MetaVarEnv<'tree, D>
impl<'tree, D> !Sync for MetaVarEnv<'tree, D>
impl<'tree, D> Unpin for MetaVarEnv<'tree, D>where <<D as Doc>::Source as Content>::Underlying: Unpin,
impl<'tree, D> UnwindSafe for MetaVarEnv<'tree, D>where D: RefUnwindSafe, <<D as Doc>::Source as Content>::Underlying: 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