Trait ra_ap_assists::ast_transform::AstTransform[][src]

pub trait AstTransform<'a> {
    fn get_substitution(
        &self,
        node: &SyntaxNode,
        recur: &dyn AstTransform<'a>
    ) -> Option<SyntaxNode>; fn or<T: AstTransform<'a> + 'a>(
        self,
        other: T
    ) -> Box<dyn AstTransform<'a> + 'a>
    where
        Self: Sized + 'a
, { ... } }

AstTransform helps with applying bulk transformations to syntax nodes.

This is mostly useful for IDE code generation. If you paste some existing code into a new context (for example, to add method overrides to an impl block), you generally want to appropriately qualify the names, and sometimes you might want to substitute generic parameters as well:

mod x {
  pub struct A;
  pub trait T<U> { fn foo(&self, _: U) -> A; }
}

mod y {
  use x::T;

  impl T<()> for () {
     // If we invoke **Add Missing Members** here, we want to copy-paste `foo`.
     // But we want a slightly-modified version of it:
     fn foo(&self, _: ()) -> x::A {}
  }
}

So, a single AstTransform describes such function from SyntaxNode to SyntaxNode. Note that the API here is a bit too high-order and high-brow. We'd want to somehow express this concept simpler, but so far nobody got to simplifying this!

Required methods

fn get_substitution(
    &self,
    node: &SyntaxNode,
    recur: &dyn AstTransform<'a>
) -> Option<SyntaxNode>
[src]

Loading content...

Provided methods

fn or<T: AstTransform<'a> + 'a>(
    self,
    other: T
) -> Box<dyn AstTransform<'a> + 'a> where
    Self: Sized + 'a, 
[src]

Loading content...

Implementors

impl<'a> AstTransform<'a> for QualifyPaths<'a>[src]

impl<'a> AstTransform<'a> for SubstituteTypeParams<'a>[src]

Loading content...