@@ -255,33 +255,43 @@ let rec exprToContextPathInner (e : Parsetree.expression) =
255255 | None -> None
256256 | Some contexPath -> Some (CPObj (contexPath, txt)))
257257 | Pexp_apply
258- ( {pexp_desc = Pexp_ident {txt = Lident (" |." | " |.u" )}},
259- [
260- (_, lhs);
261- (_, {pexp_desc = Pexp_apply (d, args); pexp_loc; pexp_attributes});
262- ] ) ->
258+ {
259+ funct =
260+ {
261+ pexp_desc = Pexp_ident {txt = Lident (" |." | " |.u" )};
262+ pexp_loc;
263+ pexp_attributes;
264+ };
265+ args = [(_, lhs); (_, {pexp_desc = Pexp_apply {funct = d; args}})];
266+ } ->
263267 (* Transform away pipe with apply call *)
264268 exprToContextPath
265269 {
266- pexp_desc = Pexp_apply (d, (Nolabel , lhs) :: args) ;
270+ pexp_desc = Pexp_apply {funct = d; args = (Nolabel , lhs) :: args} ;
267271 pexp_loc;
268272 pexp_attributes;
269273 }
270274 | Pexp_apply
271- ( {pexp_desc = Pexp_ident {txt = Lident (" |." | " |.u" )}},
272- [(_, lhs); (_, {pexp_desc = Pexp_ident id; pexp_loc; pexp_attributes})]
273- ) ->
275+ {
276+ funct = {pexp_desc = Pexp_ident {txt = Lident (" |." | " |.u" )}};
277+ args =
278+ [
279+ (_, lhs); (_, {pexp_desc = Pexp_ident id; pexp_loc; pexp_attributes});
280+ ];
281+ } ->
274282 (* Transform away pipe with identifier *)
275283 exprToContextPath
276284 {
277285 pexp_desc =
278286 Pexp_apply
279- ( {pexp_desc = Pexp_ident id; pexp_loc; pexp_attributes},
280- [(Nolabel , lhs)] );
287+ {
288+ funct = {pexp_desc = Pexp_ident id; pexp_loc; pexp_attributes};
289+ args = [(Nolabel , lhs)];
290+ };
281291 pexp_loc;
282292 pexp_attributes;
283293 }
284- | Pexp_apply ( e1 , args ) -> (
294+ | Pexp_apply { funct = e1 ; args} -> (
285295 match exprToContextPath e1 with
286296 | None -> None
287297 | Some contexPath -> Some (CPApply (contexPath, args |> List. map fst)))
@@ -313,14 +323,18 @@ let completePipeChain (exp : Parsetree.expression) =
313323 (* When the left side of the pipe we're completing is a function application.
314324 Example: someArray->Js.Array2.map(v => v + 2)-> *)
315325 | Pexp_apply
316- ( {pexp_desc = Pexp_ident {txt = Lident (" |." | " |.u" )}},
317- [_; (_, {pexp_desc = Pexp_apply (d, _)})] ) ->
326+ {
327+ funct = {pexp_desc = Pexp_ident {txt = Lident (" |." | " |.u" )}};
328+ args = [_; (_, {pexp_desc = Pexp_apply {funct = d}})];
329+ } ->
318330 exprToContextPath exp |> Option. map (fun ctxPath -> (ctxPath, d.pexp_loc))
319331 (* When the left side of the pipe we're completing is an identifier application.
320332 Example: someArray->filterAllTheGoodStuff-> *)
321333 | Pexp_apply
322- ( {pexp_desc = Pexp_ident {txt = Lident (" |." | " |.u" )}},
323- [_; (_, {pexp_desc = Pexp_ident _; pexp_loc})] ) ->
334+ {
335+ funct = {pexp_desc = Pexp_ident {txt = Lident (" |." | " |.u" )}};
336+ args = [_; (_, {pexp_desc = Pexp_ident _; pexp_loc})];
337+ } ->
324338 exprToContextPath exp |> Option. map (fun ctxPath -> (ctxPath, pexp_loc))
325339 | _ -> None
326340
@@ -1094,11 +1108,15 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor
10941108 scope := oldScope);
10951109 resetCurrentCtxPath oldCtxPath
10961110 | Pexp_apply
1097- ( {pexp_desc = Pexp_ident {txt = Lident (" |." | " |.u" ); loc = opLoc}},
1098- [
1099- (_, lhs);
1100- (_, {pexp_desc = Pexp_extension _; pexp_loc = {loc_ghost = true }});
1101- ] )
1111+ {
1112+ funct =
1113+ {pexp_desc = Pexp_ident {txt = Lident (" |." | " |.u" ); loc = opLoc}};
1114+ args =
1115+ [
1116+ (_, lhs);
1117+ (_, {pexp_desc = Pexp_extension _; pexp_loc = {loc_ghost = true }});
1118+ ];
1119+ }
11021120 when opLoc |> Loc. hasPos ~pos: posBeforeCursor ->
11031121 (* Case foo-> when the parser adds a ghost expression to the rhs
11041122 so the apply expression does not include the cursor *)
@@ -1228,7 +1246,7 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor
12281246 exprLoc = e.pexp_loc;
12291247 }))
12301248 | None -> () )
1231- | Pexp_apply ({ pexp_desc = Pexp_ident compName}, args)
1249+ | Pexp_apply {funct = { pexp_desc = Pexp_ident compName}; args}
12321250 when Res_parsetree_viewer. is_jsx_expression expr ->
12331251 inJsxContext := true ;
12341252 let jsxProps = CompletionJsx. extractJsxProps ~comp Name ~args in
@@ -1269,23 +1287,34 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor
12691287 }))
12701288 else iterateJsxProps ~iterator jsxProps
12711289 | Pexp_apply
1272- ( {pexp_desc = Pexp_ident {txt = Lident (" |." | " |.u" )}},
1273- [
1274- (_, lhs);
1275- (_, {pexp_desc = Pexp_ident {txt = Longident. Lident id; loc}});
1276- ] )
1290+ {
1291+ funct = {pexp_desc = Pexp_ident {txt = Lident (" |." | " |.u" )}};
1292+ args =
1293+ [
1294+ (_, lhs);
1295+ (_, {pexp_desc = Pexp_ident {txt = Longident. Lident id; loc}});
1296+ ];
1297+ }
12771298 when loc |> Loc. hasPos ~pos: posBeforeCursor ->
12781299 if Debug. verbose () then print_endline " [expr_iter] Case foo->id" ;
12791300 setPipeResult ~lhs ~id |> ignore
12801301 | Pexp_apply
1281- ( {pexp_desc = Pexp_ident {txt = Lident (" |." | " |.u" ); loc = opLoc}},
1282- [(_, lhs); _] )
1302+ {
1303+ funct =
1304+ {
1305+ pexp_desc =
1306+ Pexp_ident {txt = Lident (" |." | " |.u" ); loc = opLoc};
1307+ };
1308+ args = [(_, lhs); _];
1309+ }
12831310 when Loc. end_ opLoc = posCursor ->
12841311 if Debug. verbose () then print_endline " [expr_iter] Case foo->" ;
12851312 setPipeResult ~lhs ~id: " " |> ignore
12861313 | Pexp_apply
1287- ( {pexp_desc = Pexp_ident {txt = Lident (" |." | " |.u" )}},
1288- [_; (_, {pexp_desc = Pexp_apply (funExpr, args)})] )
1314+ {
1315+ funct = {pexp_desc = Pexp_ident {txt = Lident (" |." | " |.u" )}};
1316+ args = [_; (_, {pexp_desc = Pexp_apply {funct = funExpr; args}})];
1317+ }
12891318 when (* Normally named arg completion fires when the cursor is right after the expression.
12901319 E.g in foo(~<---there
12911320 But it should not fire in foo(~a)<---there *)
@@ -1318,10 +1347,13 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor
13181347 resetCurrentCtxPath oldCtxPath)
13191348 | Some argCompletable -> setResult argCompletable)
13201349 | Pexp_apply
1321- ({pexp_desc = Pexp_ident {txt = Lident (" |." | "|.u" )}}, [_; _]) ->
1350+ {
1351+ funct = {pexp_desc = Pexp_ident {txt = Lident (" |." | " |.u" )}};
1352+ args = [_; _];
1353+ } ->
13221354 (* Ignore any other pipe. *)
13231355 ()
1324- | Pexp_apply ( funExpr, args)
1356+ | Pexp_apply {funct = funExpr; args}
13251357 when not
13261358 (Loc. end_ expr.pexp_loc = posCursor
13271359 && charBeforeCursor = Some ')' ) -> (
0 commit comments