@@ -1028,6 +1028,38 @@ and walk_value_binding vb t comments =
10281028
10291029and walk_expression expr t comments =
10301030 let open Location in
1031+ let walk_apply_expr call_expr arguments t comments =
1032+ let before, inside, after =
1033+ partition_by_loc comments call_expr.Parsetree. pexp_loc
1034+ in
1035+ let after =
1036+ if is_block_expr call_expr then (
1037+ let after_expr, rest =
1038+ partition_adjacent_trailing call_expr.Parsetree. pexp_loc after
1039+ in
1040+ walk_expression call_expr t (List. concat [before; inside; after_expr]);
1041+ rest)
1042+ else (
1043+ attach t.leading call_expr.Parsetree. pexp_loc before;
1044+ walk_expression call_expr t inside;
1045+ after)
1046+ in
1047+ let after_expr, rest =
1048+ partition_adjacent_trailing call_expr.Parsetree. pexp_loc after
1049+ in
1050+ attach t.trailing call_expr.Parsetree. pexp_loc after_expr;
1051+ walk_list
1052+ (arguments
1053+ |> List. map (fun (lbl , expr ) ->
1054+ let loc =
1055+ match lbl with
1056+ | Asttypes. Labelled {loc} | Optional {loc} ->
1057+ {loc with loc_end = expr.Parsetree. pexp_loc.loc_end}
1058+ | _ -> expr.pexp_loc
1059+ in
1060+ ExprArgument {expr; loc}))
1061+ t rest
1062+ in
10311063 match expr.Parsetree. pexp_desc with
10321064 | _ when comments = [] -> ()
10331065 | Pexp_constant _ ->
@@ -1563,69 +1595,10 @@ and walk_expression expr t comments =
15631595 walk_list (all_exprs |> List. map (fun e -> Expression e)) t comments
15641596 | _ ->
15651597 (* Fallback to regular apply handling *)
1566- let before, inside, after =
1567- partition_by_loc comments call_expr.pexp_loc
1568- in
1569- let after =
1570- if is_block_expr call_expr then (
1571- let after_expr, rest =
1572- partition_adjacent_trailing call_expr.pexp_loc after
1573- in
1574- walk_expression call_expr t
1575- (List. concat [before; inside; after_expr]);
1576- rest)
1577- else (
1578- attach t.leading call_expr.pexp_loc before;
1579- walk_expression call_expr t inside;
1580- after)
1581- in
1582- let after_expr, rest =
1583- partition_adjacent_trailing call_expr.pexp_loc after
1584- in
1585- attach t.trailing call_expr.pexp_loc after_expr;
1586- walk_list
1587- (arguments
1588- |> List. map (fun (lbl , expr ) ->
1589- let loc =
1590- match lbl with
1591- | Asttypes. Labelled {loc} | Optional {loc} ->
1592- {loc with loc_end = expr.Parsetree. pexp_loc.loc_end}
1593- | _ -> expr.pexp_loc
1594- in
1595- ExprArgument {expr; loc}))
1596- t rest)
1598+ walk_apply_expr call_expr arguments t comments)
15971599 | _ ->
15981600 (* Regular apply handling *)
1599- let before, inside, after =
1600- partition_by_loc comments call_expr.pexp_loc
1601- in
1602- let after =
1603- if is_block_expr call_expr then (
1604- let after_expr, rest =
1605- partition_adjacent_trailing call_expr.pexp_loc after
1606- in
1607- walk_expression call_expr t (List. concat [before; inside; after_expr]);
1608- rest)
1609- else (
1610- attach t.leading call_expr.pexp_loc before;
1611- walk_expression call_expr t inside;
1612- after)
1613- in
1614- let after_expr, rest =
1615- partition_adjacent_trailing call_expr.pexp_loc after
1616- in
1617- attach t.trailing call_expr.pexp_loc after_expr;
1618- walk_list
1619- (arguments
1620- |> List. map (fun (lbl , expr ) ->
1621- let loc =
1622- match lbl with
1623- | Asttypes. Labelled {loc} | Optional {loc} ->
1624- {loc with loc_end = expr.Parsetree. pexp_loc.loc_end}
1625- | _ -> expr.pexp_loc
1626- in
1627- ExprArgument {expr; loc}))
1628- t rest)
1601+ walk_apply_expr call_expr arguments t comments)
16291602 | Pexp_fun _ | Pexp_newtype _ -> (
16301603 let _, parameters, return_expr = fun_expr expr in
16311604 let comments =
0 commit comments