Struct ra_ap_ide_db::path_transform::PathTransform

source ·
pub struct PathTransform<'a> { /* private fields */ }
Expand description

PathTransform substitutes path in SyntaxNodes in bulk.

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<V>;
  pub trait T<U> { fn foo(&self, _: U) -> A<U>; }
}

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<()> {}
  }
}

Implementations§

source§

impl<'a> PathTransform<'a>

source

pub fn trait_impl( target_scope: &'a SemanticsScope<'a>, source_scope: &'a SemanticsScope<'a>, trait_: Trait, impl_: Impl ) -> PathTransform<'a>

source

pub fn function_call( target_scope: &'a SemanticsScope<'a>, source_scope: &'a SemanticsScope<'a>, function: Function, generic_arg_list: GenericArgList ) -> PathTransform<'a>

source

pub fn impl_transformation( target_scope: &'a SemanticsScope<'a>, source_scope: &'a SemanticsScope<'a>, impl_: Impl, generic_arg_list: GenericArgList ) -> PathTransform<'a>

source

pub fn adt_transformation( target_scope: &'a SemanticsScope<'a>, source_scope: &'a SemanticsScope<'a>, adt: Adt, generic_arg_list: GenericArgList ) -> PathTransform<'a>

source

pub fn generic_transformation( target_scope: &'a SemanticsScope<'a>, source_scope: &'a SemanticsScope<'a> ) -> PathTransform<'a>

source

pub fn apply(&self, syntax: &SyntaxNode)

source

pub fn apply_all<'b>(&self, nodes: impl IntoIterator<Item = &'b SyntaxNode>)

Auto Trait Implementations§

§

impl<'a> Freeze for PathTransform<'a>

§

impl<'a> !RefUnwindSafe for PathTransform<'a>

§

impl<'a> !Send for PathTransform<'a>

§

impl<'a> !Sync for PathTransform<'a>

§

impl<'a> Unpin for PathTransform<'a>

§

impl<'a> !UnwindSafe for PathTransform<'a>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> Cast for T

source§

fn cast<U>(self, interner: <U as HasInterner>::Interner) -> U
where Self: CastTo<U>, U: HasInterner,

Cast a value to type U using CastTo.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoBox<dyn Any> for T
where T: Any,

source§

fn into_box(self) -> Box<dyn Any>

Convert self into the appropriate boxed form.
source§

impl<T> IntoEither for T

source§

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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<'a, T> Captures<'a> for T
where T: ?Sized,