/// Prepares a generated function that matches `call`.
/// The function is generated in `target_module` or next to `call`
Prepares a generated function that matches `call`.
The function is generated in `target_module` or next to `call`
Prepares a generated function that matches ` call ` . The function is generated in ` target_module ` or next to ` call `
fn from_call(
        ctx: &AssistContext,
        call: &ast::CallExpr,
        path: &ast::Path,
        target_module: Option<hir::Module>,
    ) -> Option<Self> {
        let mut file = ctx.frange.file_id;
        let target = match &target_module {
            Some(target_module) => {
                let module_source = target_module.definition_source(ctx.db);
                let (in_file, target) = next_space_for_fn_in_module(ctx.sema.db, &module_source)?;
                file = in_file;
                target
            }
            None => next_space_for_fn_after_call_site(&call)?,
        };
        let needs_pub = target_module.is_some();
        let target_module = target_module.or_else(|| ctx.sema.scope(target.syntax()).module())?;
        let fn_name = fn_name(&path)?;
        let (type_params, params) = fn_args(ctx, target_module, &call)?;
        Some(Self { target, fn_name, type_params, params, file, needs_pub })
    }
fn from_call ( ctx : & AssistContext , call : & ast :: CallExpr , path : & ast :: Path , target_module : Option < hir :: Module > , ) -> Option < Self > { let mut file = ctx . frange . file_id ; let target = match & target_module { Some ( target_module ) => { let module_source = target_module . definition_source ( ctx . db ) ; let ( in_file , target ) = next_space_for_fn_in_module ( ctx . sema . db , & module_source ) ? ; file = in_file ; target } None => next_space_for_fn_after_call_site ( & call ) ? , } ; let needs_pub = target_module . is_some ( ) ; let target_module = target_module . or_else ( | | ctx . sema . scope ( target . syntax ( ) ) . module ( ) ) ? ; let fn_name = fn_name ( & path ) ? ; let ( type_params , params ) = fn_args ( ctx , target_module , & call ) ? ; Some ( Self { target , fn_name , type_params , params , file , needs_pub } ) }
Prepares a generated function that matches `call`.
Prepares a generated function that matches ` call ` .
ctx
&AssistContext
call
&ast::CallExpr
path
&ast::Path
target_module
Option<hir::Module>