@@ -477,11 +477,11 @@ fn resolve_rhs_instantiation(
477477 && !ctor. template_bindings . is_empty ( )
478478 && let Some ( ref arg_list) = inst. argument_list
479479 {
480- let text_args =
481- super :: raw_type_inference:: extract_argument_text ( arg_list, ctx. content ) ;
482- if !text_args . is_empty ( ) {
480+ let arg_texts =
481+ super :: raw_type_inference:: extract_arg_texts_from_ast ( arg_list, ctx. content ) ;
482+ if !arg_texts . is_empty ( ) {
483483 let rctx = ctx. as_resolution_ctx ( ) ;
484- let subs = build_constructor_template_subs ( cls, ctor, & text_args , & rctx, ctx) ;
484+ let subs = build_constructor_template_subs ( cls, ctor, & arg_texts , & rctx, ctx) ;
485485 if !subs. is_empty ( ) {
486486 let type_args: Vec < PhpType > = cls
487487 . template_params
@@ -569,11 +569,10 @@ fn resolve_rhs_instantiation(
569569fn build_constructor_template_subs (
570570 _class : & ClassInfo ,
571571 ctor : & crate :: types:: MethodInfo ,
572- text_args : & str ,
572+ arg_texts : & [ String ] ,
573573 rctx : & crate :: completion:: resolver:: ResolutionCtx < ' _ > ,
574574 ctx : & VarResolutionCtx < ' _ > ,
575575) -> HashMap < String , PhpType > {
576- let args = crate :: completion:: conditional_resolution:: split_text_args ( text_args) ;
577576 let mut subs = HashMap :: new ( ) ;
578577
579578 for ( tpl_name, param_name) in & ctor. template_bindings {
@@ -584,7 +583,7 @@ fn build_constructor_template_subs(
584583 } ;
585584
586585 // Get the corresponding argument text.
587- let arg_text = match args . get ( param_idx) {
586+ let arg_text = match arg_texts . get ( param_idx) {
588587 Some ( text) => text. trim ( ) ,
589588 None => continue ,
590589 } ;
@@ -828,8 +827,12 @@ fn resolve_generic_wrapper_template(
828827 let paren_end = arg_text. rfind ( ')' ) ?;
829828 let inner_args = arg_text[ paren_start + 1 ..paren_end] . trim ( ) ;
830829
830+ let wrapper_arg_texts = crate :: completion:: conditional_resolution:: split_text_args ( inner_args)
831+ . into_iter ( )
832+ . map ( |s| s. to_string ( ) )
833+ . collect :: < Vec < _ > > ( ) ;
831834 let wrapper_subs =
832- build_constructor_template_subs ( & wrapper_cls, wrapper_ctor, inner_args , rctx, ctx) ;
835+ build_constructor_template_subs ( & wrapper_cls, wrapper_ctor, & wrapper_arg_texts , rctx, ctx) ;
833836
834837 // Find the wrapper's template param at the given position and
835838 // look it up in the substitution map.
@@ -1012,10 +1015,9 @@ fn classify_array_index(index: &Expression<'_>) -> ArrayBracketSegment {
10121015/// positional resolution through the wrapper's generic arguments.
10131016pub ( crate ) fn build_function_template_subs (
10141017 func_info : & crate :: types:: FunctionInfo ,
1015- text_args : & str ,
1018+ arg_texts : & [ String ] ,
10161019 rctx : & crate :: completion:: resolver:: ResolutionCtx < ' _ > ,
10171020) -> HashMap < String , PhpType > {
1018- let args = crate :: completion:: conditional_resolution:: split_text_args ( text_args) ;
10191021 let mut subs = HashMap :: new ( ) ;
10201022
10211023 for ( tpl_name, param_name) in & func_info. template_bindings {
@@ -1028,7 +1030,7 @@ pub(crate) fn build_function_template_subs(
10281030 None => continue ,
10291031 } ;
10301032
1031- let arg_text = match args . get ( param_idx) {
1033+ let arg_text = match arg_texts . get ( param_idx) {
10321034 Some ( text) => text. trim ( ) ,
10331035 None => continue ,
10341036 } ;
@@ -1353,11 +1355,13 @@ fn resolve_rhs_function_call<'b>(
13531355 && !func_info. template_bindings . is_empty ( )
13541356 && func_info. return_type . is_some ( )
13551357 {
1356- let text_args =
1357- super :: raw_type_inference:: extract_argument_text ( & func_call. argument_list , content) ;
1358- if !text_args. is_empty ( ) {
1358+ let arg_texts = super :: raw_type_inference:: extract_arg_texts_from_ast (
1359+ & func_call. argument_list ,
1360+ content,
1361+ ) ;
1362+ if !arg_texts. is_empty ( ) {
13591363 let rctx = ctx. as_resolution_ctx ( ) ;
1360- let subs = build_function_template_subs ( & func_info, & text_args , & rctx) ;
1364+ let subs = build_function_template_subs ( & func_info, & arg_texts , & rctx) ;
13611365 if !subs. is_empty ( )
13621366 && let Some ( ref ret) = func_info. return_type
13631367 {
@@ -1673,13 +1677,16 @@ fn resolve_rhs_method_call_inner<'b>(
16731677 ( classes, resolved)
16741678 } ;
16751679
1676- let text_args = super :: raw_type_inference:: extract_argument_text ( argument_list, ctx. content ) ;
1680+ let arg_texts =
1681+ super :: raw_type_inference:: extract_arg_texts_from_ast ( argument_list, ctx. content ) ;
1682+ let arg_refs: Vec < & str > = arg_texts. iter ( ) . map ( |s| s. as_str ( ) ) . collect ( ) ;
1683+ let text_args = arg_texts. join ( ", " ) ;
16771684 let rctx = ctx. as_resolution_ctx ( ) ;
16781685 let var_resolver = build_var_resolver_from_ctx ( ctx) ;
16791686
16801687 for owner in & owner_classes {
16811688 let template_subs =
1682- Backend :: build_method_template_subs ( owner, & method_name, & text_args , & rctx) ;
1689+ Backend :: build_method_template_subs ( owner, & method_name, & arg_refs , & rctx) ;
16831690 let mr_ctx = MethodReturnCtx {
16841691 all_classes : ctx. all_classes ,
16851692 class_loader : ctx. class_loader ,
@@ -1894,13 +1901,15 @@ fn resolve_rhs_static_call(
18941901 . map ( |c| ClassInfo :: clone ( c) )
18951902 . or_else ( || ( ctx. class_loader ) ( & cls_name) . map ( Arc :: unwrap_or_clone) ) ;
18961903 if let Some ( ref owner) = owner {
1897- let text_args = super :: raw_type_inference:: extract_argument_text (
1904+ let arg_texts = super :: raw_type_inference:: extract_arg_texts_from_ast (
18981905 & static_call. argument_list ,
18991906 ctx. content ,
19001907 ) ;
1908+ let arg_refs: Vec < & str > = arg_texts. iter ( ) . map ( |s| s. as_str ( ) ) . collect ( ) ;
1909+ let text_args = arg_texts. join ( ", " ) ;
19011910 let rctx = ctx. as_resolution_ctx ( ) ;
19021911 let template_subs =
1903- Backend :: build_method_template_subs ( owner, & method_name, & text_args , & rctx) ;
1912+ Backend :: build_method_template_subs ( owner, & method_name, & arg_refs , & rctx) ;
19041913 let var_resolver = build_var_resolver_from_ctx ( ctx) ;
19051914 let mr_ctx = MethodReturnCtx {
19061915 all_classes : ctx. all_classes ,
0 commit comments