enum FunctionBody {
Expr(Expr),
Span {
parent: StmtList,
elements: RangeInclusive<SyntaxElement>,
text_range: TextRange,
},
}Expand description
Semantically same as ast::Expr, but preserves identity when using only part of the Block
This is the future function body, the part that is being extracted.
Variants§
Implementations§
Source§impl FunctionBody
impl FunctionBody
fn parent(&self) -> Option<SyntaxNode>
fn node(&self) -> &SyntaxNode
fn extracted_from_trait_impl(&self) -> bool
fn descendants(&self) -> impl Iterator<Item = SyntaxNode>
fn descendant_paths(&self) -> impl Iterator<Item = Path>
fn from_expr(expr: Expr) -> Option<Self>
fn from_range(parent: StmtList, selected: TextRange) -> Option<FunctionBody>
fn indent_level(&self) -> IndentLevel
fn tail_expr(&self) -> Option<Expr>
fn preorder_expr(&self, cb: &mut dyn FnMut(WalkEvent<Expr>) -> bool)
fn walk_pat(&self, cb: &mut dyn FnMut(Pat))
fn text_range(&self) -> TextRange
fn contains_range(&self, range: TextRange) -> bool
fn precedes_range(&self, range: TextRange) -> bool
fn contains_node(&self, node: &SyntaxNode) -> bool
fn suggest_name(&self) -> Option<String>
Source§impl FunctionBody
impl FunctionBody
Sourcefn analyze(
&self,
sema: &Semantics<'_, RootDatabase>,
) -> (FxIndexSet<Local>, Option<SelfParam>)
fn analyze( &self, sema: &Semantics<'_, RootDatabase>, ) -> (FxIndexSet<Local>, Option<SelfParam>)
Analyzes a function body, returning the used local variables that are referenced in it as well as whether it contains an await expression.
fn analyze_container<'db>( &self, make: &SyntaxFactory, sema: &Semantics<'db, RootDatabase>, edition: Edition, trait_name: Option<Name>, ) -> Option<(ContainerInfo<'db>, bool)>
fn return_ty<'db>(&self, ctx: &AssistContext<'_, 'db>) -> Option<RetType<'db>>
Sourcefn ret_values<'a>(
&self,
ctx: &'a AssistContext<'_, '_>,
) -> impl Iterator<Item = OutlivedLocal> + 'a
fn ret_values<'a>( &self, ctx: &'a AssistContext<'_, '_>, ) -> impl Iterator<Item = OutlivedLocal> + 'a
Local variables defined inside body that are accessed outside of it
Sourcefn external_control_flow<'db>(
&self,
ctx: &AssistContext<'_, 'db>,
container_info: &ContainerInfo<'db>,
) -> Option<ControlFlow<'db>>
fn external_control_flow<'db>( &self, ctx: &AssistContext<'_, 'db>, container_info: &ContainerInfo<'db>, ) -> Option<ControlFlow<'db>>
Analyses the function body for external control flow.
Sourcefn extracted_function_params<'db>(
&self,
ctx: &AssistContext<'_, 'db>,
container_info: &ContainerInfo<'db>,
locals: FxIndexSet<Local>,
) -> Vec<Param<'db>>
fn extracted_function_params<'db>( &self, ctx: &AssistContext<'_, 'db>, container_info: &ContainerInfo<'db>, locals: FxIndexSet<Local>, ) -> Vec<Param<'db>>
find variables that should be extracted as params
Computes additional info that affects param type and mutability
fn has_usages_after_body(&self, usages: &LocalUsages) -> bool
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FunctionBody
impl !RefUnwindSafe for FunctionBody
impl !Send for FunctionBody
impl !Sync for FunctionBody
impl Unpin for FunctionBody
impl UnsafeUnpin for FunctionBody
impl !UnwindSafe for FunctionBody
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, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> 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