Struct 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>
impl<'a> PathTransform<'a>
pub fn trait_impl( target_scope: &'a SemanticsScope<'a>, source_scope: &'a SemanticsScope<'a>, trait_: Trait, impl_: Impl, ) -> PathTransform<'a>
pub fn function_call( target_scope: &'a SemanticsScope<'a>, source_scope: &'a SemanticsScope<'a>, function: Function, generic_arg_list: GenericArgList, ) -> PathTransform<'a>
pub fn impl_transformation( target_scope: &'a SemanticsScope<'a>, source_scope: &'a SemanticsScope<'a>, impl_: Impl, generic_arg_list: GenericArgList, ) -> PathTransform<'a>
pub fn adt_transformation( target_scope: &'a SemanticsScope<'a>, source_scope: &'a SemanticsScope<'a>, adt: Adt, generic_arg_list: GenericArgList, ) -> PathTransform<'a>
pub fn generic_transformation( target_scope: &'a SemanticsScope<'a>, source_scope: &'a SemanticsScope<'a>, ) -> PathTransform<'a>
pub fn apply(&self, syntax: &SyntaxNode)
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> 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
§impl<T> Cast for T
impl<T> Cast for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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