MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / walk_closures_in_call

Function walk_closures_in_call

src/completion/variable/forward_walk.rs:630–736  ·  view source on GitHub ↗

Handle a call expression: infer callable parameter types from the function/method signature and pass them when walking closure arguments.

(
    call: &'b Call<'b>,
    outer_scope: &ScopeState,
    ctx: &ForwardWalkCtx<'_>,
)

Source from the content-addressed store, hash-verified

628/// Handle a call expression: infer callable parameter types from the
629/// function/method signature and pass them when walking closure arguments.
630fn walk_closures_in_call<'b>(
631 call: &'b Call<'b>,
632 outer_scope: &ScopeState,
633 ctx: &ForwardWalkCtx<'_>,
634) {
635 match call {
636 Call::Function(fc) => {
637 // Recurse into the function expression (for closures in
638 // chained calls like `$fn()($anotherClosure)`).
639 walk_closures_in_expr(fc.function, outer_scope, ctx, None);
640
641 let func_name = match fc.function {
642 Expression::Identifier(ident) => Some(ident.value().to_string()),
643 _ => None,
644 };
645 walk_closures_in_call_args(&fc.argument_list.arguments, outer_scope, ctx, |arg_idx| {
646 if let Some(ref name) = func_name {
647 infer_callable_params_from_function_fw(
648 name,
649 arg_idx,
650 &fc.argument_list.arguments,
651 outer_scope,
652 ctx,
653 )
654 } else {
655 vec![]
656 }
657 });
658 }
659 Call::Method(mc) => {
660 walk_closures_in_expr(mc.object, outer_scope, ctx, None);
661
662 let method_name = if let ClassLikeMemberSelector::Identifier(ident) = &mc.method {
663 Some(ident.value.to_string())
664 } else {
665 None
666 };
667 let obj_span = mc.object.span();
668 let first_arg = extract_first_arg_string_fw(&mc.argument_list.arguments, ctx.content);
669 walk_closures_in_call_args(&mc.argument_list.arguments, outer_scope, ctx, |arg_idx| {
670 if let Some(ref name) = method_name {
671 infer_callable_params_from_receiver_fw(
672 obj_span.start.offset,
673 obj_span.end.offset,
674 name,
675 arg_idx,
676 first_arg.as_deref(),
677 outer_scope,
678 ctx,
679 )
680 } else {
681 vec![]
682 }
683 });
684 }
685 Call::NullSafeMethod(mc) => {
686 walk_closures_in_expr(mc.object, outer_scope, ctx, None);
687

Callers 1

walk_closures_in_exprFunction · 0.85

Tested by

no test coverage detected