File tree Expand file tree Collapse file tree 5 files changed +31
-3
lines changed
tests/build_tests/actions Expand file tree Collapse file tree 5 files changed +31
-3
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 @@ -4655,13 +4655,18 @@ let report_error env loc ppf error =
46554655
46564656 if not is_fallback then fprintf ppf " @," ;
46574657
4658- if List. length missing_required_args > 0 then
4658+ if List. length missing_required_args > 0 then (
46594659 (* TODO(actions) Add missing arguments *)
4660- (* TODO(actions) Partially apply *)
4660+ Cmt_utils. add_possible_action
4661+ {
4662+ loc;
4663+ action = PartiallyApplyFunction ;
4664+ description = " Partially apply function" ;
4665+ };
46614666 fprintf ppf " @,- Missing arguments that must be provided: %s"
46624667 (missing_required_args
46634668 |> List. map (fun v -> " ~" ^ v)
4664- |> String. concat " , " );
4669+ |> String. concat " , " )) ;
46654670
46664671 if List. length superfluous_args > 0 then
46674672 (* TODO(actions) Remove arguments *)
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