File tree Expand file tree Collapse file tree 5 files changed +30
-2
lines changed
tests/build_tests/actions Expand file tree Collapse file tree 5 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ type action_type =
2121 | ForceOpen
2222 | AssignToUnderscore
2323 | PipeToIgnore
24+ | PartiallyApplyFunction
2425
2526(* TODO:
2627- Unused var in patterns (and aliases )*)
@@ -65,6 +66,7 @@ let action_to_string = function
6566 | `Labelled -> " RewriteArgType(Labelled)"
6667 | `Optional -> " RewriteArgType(Optional)"
6768 | `Unlabelled -> " RewriteArgType(Unlabelled)" )
69+ | PartiallyApplyFunction -> " PartiallyApplyFunction"
6870
6971let _add_possible_action : (cmt_action -> unit) ref = ref (fun _ -> () )
7072let add_possible_action action = ! _add_possible_action action
Original file line number Diff line number Diff line change @@ -4716,11 +4716,16 @@ let report_error env loc ppf error =
47164716
47174717 if List. length missing_required_args > 0 then (
47184718 (* TODO(actions) Add missing arguments *)
4719- (* TODO(actions) Partially apply *)
4719+ Cmt_utils. add_possible_action
4720+ {
4721+ loc;
4722+ action = PartiallyApplyFunction ;
4723+ description = " Partially apply function" ;
4724+ };
47204725 fprintf ppf " @,- Missing arguments that must be provided: %s"
47214726 (missing_required_args
47224727 |> List. map (fun v -> " ~" ^ v)
4723- |> String. concat " , " );
4728+ |> String. concat " , " )) ;
47244729
47254730 fprintf ppf
47264731 " @,\
Original file line number Diff line number Diff line change 1+ // actionFilter=PartiallyApplyFunction
2+ let x = (~a , ~b ) => a + b
3+ let y = x (~a = 2 , ... ) + 2
4+
5+ /* === AVAILABLE ACTIONS:
6+ - PartiallyApplyFunction - Partially apply function
7+ */
Original file line number Diff line number Diff line change 1+ // actionFilter=PartiallyApplyFunction
2+ let x = (~a , ~b ) => a + b
3+ let y = x (~a = 2 ) + 2
Original file line number Diff line number Diff line change @@ -1606,6 +1606,15 @@ module Actions = struct
16061606 else
16071607 (* Other cases when the loc is on something else in the expr *)
16081608 match (expr.pexp_desc, action.action) with
1609+ | ( Pexp_apply ({funct} as apply_args),
1610+ PartiallyApplyFunction )
1611+ when funct.pexp_loc = action.loc ->
1612+ Some
1613+ {
1614+ expr with
1615+ pexp_desc =
1616+ Pexp_apply {apply_args with partial = true };
1617+ }
16091618 | Pexp_apply ({args} as apply), RewriteArgType {to_type}
16101619 ->
16111620 let arg_locs =
@@ -1772,6 +1781,8 @@ module Actions = struct
17721781 | RemoveRecordSpread -> List. mem " RemoveRecordSpread" filter
17731782 | AssignToUnderscore -> List. mem " AssignToUnderscore" filter
17741783 | PipeToIgnore -> List. mem " PipeToIgnore" filter
1784+ | PartiallyApplyFunction ->
1785+ List. mem " PartiallyApplyFunction" filter
17751786 | RewriteArgType _ -> List. mem " RewriteArgType" filter)
17761787 in
17771788 match applyActionsToFile path possible_actions with
You can’t perform that action at this time.
0 commit comments