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 =
21
21
| ForceOpen
22
22
| AssignToUnderscore
23
23
| PipeToIgnore
24
+ | PartiallyApplyFunction
24
25
25
26
(* TODO:
26
27
- Unused var in patterns (and aliases )*)
@@ -65,6 +66,7 @@ let action_to_string = function
65
66
| `Labelled -> " RewriteArgType(Labelled)"
66
67
| `Optional -> " RewriteArgType(Optional)"
67
68
| `Unlabelled -> " RewriteArgType(Unlabelled)" )
69
+ | PartiallyApplyFunction -> " PartiallyApplyFunction"
68
70
69
71
let _add_possible_action : (cmt_action -> unit) ref = ref (fun _ -> () )
70
72
let add_possible_action action = ! _add_possible_action action
Original file line number Diff line number Diff line change @@ -4656,13 +4656,18 @@ let report_error env loc ppf error =
4656
4656
4657
4657
if not is_fallback then fprintf ppf " @," ;
4658
4658
4659
- if List. length missing_required_args > 0 then
4659
+ if List. length missing_required_args > 0 then (
4660
4660
(* TODO(actions) Add missing arguments *)
4661
- (* TODO(actions) Partially apply *)
4661
+ Cmt_utils. add_possible_action
4662
+ {
4663
+ loc;
4664
+ action = PartiallyApplyFunction ;
4665
+ description = " Partially apply function" ;
4666
+ };
4662
4667
fprintf ppf " @,- Missing arguments that must be provided: %s"
4663
4668
(missing_required_args
4664
4669
|> List. map (fun v -> " ~" ^ v)
4665
- |> String. concat " , " );
4670
+ |> String. concat " , " )) ;
4666
4671
4667
4672
if List. length superfluous_args > 0 then
4668
4673
(* 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
1606
1606
else
1607
1607
(* Other cases when the loc is on something else in the expr *)
1608
1608
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
+ }
1609
1618
| Pexp_apply ({args} as apply), RewriteArgType {to_type}
1610
1619
->
1611
1620
let arg_locs =
@@ -1772,6 +1781,8 @@ module Actions = struct
1772
1781
| RemoveRecordSpread -> List. mem " RemoveRecordSpread" filter
1773
1782
| AssignToUnderscore -> List. mem " AssignToUnderscore" filter
1774
1783
| PipeToIgnore -> List. mem " PipeToIgnore" filter
1784
+ | PartiallyApplyFunction ->
1785
+ List. mem " PartiallyApplyFunction" filter
1775
1786
| RewriteArgType _ -> List. mem " RewriteArgType" filter)
1776
1787
in
1777
1788
match applyActionsToFile path possible_actions with
You can’t perform that action at this time.
0 commit comments