File tree Expand file tree Collapse file tree 10 files changed +23
-46
lines changed Expand file tree Collapse file tree 10 files changed +23
-46
lines changed Original file line number Diff line number Diff line change @@ -146,21 +146,13 @@ module Exp = struct
146
146
false
147
147
| _ -> List. exists pexp_attributes ~f: (Fn. non Attr. is_doc)
148
148
149
- let is_string_const_trivial str =
150
- let is_char_trivial = function
151
- | ' ' | '\t' | '\n' | '\x00' .. '\x1f' | '\x7f' .. '\xff' -> false
152
- | _ -> true
153
- in
154
- let len = String. length str in
155
- len < 5 || (len < 20 && String. for_all ~f: is_char_trivial str)
156
-
157
149
let rec is_trivial exp =
158
150
match exp.pexp_desc with
159
151
(* String literals using the heavy syntax are not trivial. *)
160
152
| Pexp_constant {pconst_desc = Pconst_string (_ , _ , Some _ ); _} -> false
161
- (* Some short strings are trivial. *)
153
+ (* Short strings are trivial. *)
162
154
| Pexp_constant {pconst_desc = Pconst_string (str , _ , None); _} ->
163
- is_string_const_trivial str
155
+ String. length str < 30
164
156
| Pexp_constant _ | Pexp_field _ | Pexp_ident _ | Pexp_send _ -> true
165
157
| Pexp_construct (_ , exp ) -> Option. for_all exp ~f: is_trivial
166
158
| Pexp_prefix (_ , e ) -> is_trivial e
Original file line number Diff line number Diff line change @@ -303,8 +303,8 @@ let rec place t loc_tree ?prev_loc ?deep_loc locs cmts =
303
303
(* * Relocate comments, for Ast transformations such as sugaring. *)
304
304
let relocate (t : t ) ~src ~before ~after =
305
305
if t.debug then
306
- Format. eprintf " relocate %a to %a and %a@\n %!"
307
- Location. fmt src Location. fmt before Location. fmt after ;
306
+ Format. eprintf " relocate %a to %a and %a@\n %!" Location. fmt src
307
+ Location. fmt before Location. fmt after ;
308
308
let merge_and_sort x y =
309
309
List. rev_append x y
310
310
|> List. sort ~compare: (Comparable. lift Location. compare_start ~f: Cmt. loc)
Original file line number Diff line number Diff line change @@ -187,8 +187,8 @@ let rec pp_from fs = function
187
187
| `Profile (s , p ) -> Format. fprintf fs " (profile %s%a)" s pp_from_src p
188
188
| `Updated (x , None) -> pp_from_src fs x
189
189
| `Updated (x , Some r ) ->
190
- Format. fprintf fs " %a -- Warning (redundant): %a"
191
- pp_from_src x pp_from r
190
+ Format. fprintf fs " %a -- Warning (redundant): %a" pp_from_src x pp_from
191
+ r
192
192
193
193
let loc_udapted_from = function
194
194
| `Commandline -> Location. in_file " <command-line>"
Original file line number Diff line number Diff line change @@ -3657,9 +3657,7 @@ and fmt_module_type c ?(rec_ = false) ({ast= mty; _} as xmty) =
3657
3657
pro=
3658
3658
Some
3659
3659
( Cmts. fmt_before c pmty_loc
3660
- $ fmt_if parens " ("
3661
- $ str " module type of "
3662
- $ pro )
3660
+ $ fmt_if parens " (" $ str " module type of " $ pro )
3663
3661
; epi= Some epi }
3664
3662
| _ ->
3665
3663
{ blk with
@@ -4014,17 +4012,14 @@ and fmt_with_constraint c ctx ~pre = function
4014
4012
| Pwith_type (lid , td ) ->
4015
4013
fmt_type_declaration ~pre: (pre ^ " type" ) c ~name: lid (sub_td ~ctx td)
4016
4014
| Pwith_module (m1 , m2 ) ->
4017
- str pre
4018
- $ str " module "
4019
- $ fmt_longident_loc c m1 $ str " = " $ fmt_longident_loc c m2
4015
+ str pre $ str " module " $ fmt_longident_loc c m1 $ str " = "
4016
+ $ fmt_longident_loc c m2
4020
4017
| Pwith_typesubst (lid , td ) ->
4021
- fmt_type_declaration
4022
- ~pre: (pre ^ " type" )
4023
- c ~eq: " :=" ~name: lid (sub_td ~ctx td)
4018
+ fmt_type_declaration ~pre: (pre ^ " type" ) c ~eq: " :=" ~name: lid
4019
+ (sub_td ~ctx td)
4024
4020
| Pwith_modsubst (m1 , m2 ) ->
4025
- str pre
4026
- $ str " module "
4027
- $ fmt_longident_loc c m1 $ str " := " $ fmt_longident_loc c m2
4021
+ str pre $ str " module " $ fmt_longident_loc c m1 $ str " := "
4022
+ $ fmt_longident_loc c m2
4028
4023
| Pwith_modtype (m1 , m2 ) ->
4029
4024
let m1 = {m1 with txt= Some (str_longident m1.txt)} in
4030
4025
let m2 = Some (sub_mty ~ctx m2) in
Original file line number Diff line number Diff line change @@ -409,8 +409,7 @@ let collection_expr (c : Conf.t) ~space_around opn cls =
409
409
else box_collec c 0 (wrap_collec c ~space_around opn cls k) )
410
410
; sep_before= noop
411
411
; sep_after_non_final=
412
- fmt_or_k dock
413
- (fmt " ;@;<1 0>" )
412
+ fmt_or_k dock (fmt " ;@;<1 0>" )
414
413
(char ';' $ break 1 (String. length opn + 1 ))
415
414
; sep_after_final= fmt_if_k dock (fits_breaks ~level: 1 " " " ;" ) }
416
415
Original file line number Diff line number Diff line change @@ -57,11 +57,10 @@ hvbox 0
57
57
$ wrap " (" " )"
58
58
( str txt
59
59
$ opt mt (fun _ ->
60
- fmt " @ : " $ Option. call ~f: pro_t $ psp_t
61
- $ fmt " @;<1 2>"
62
- $ bdy_t $ esp_t $ Option. call ~f: epi_t ) )
63
- $ fmt " ->@ "
64
- $ Option. call ~f: pro_e $ psp_e $ bdy_e $ esp_e $ Option. call ~f: epi_e )
60
+ fmt " @ : " $ Option. call ~f: pro_t $ psp_t $ fmt " @;<1 2>" $ bdy_t
61
+ $ esp_t $ Option. call ~f: epi_t ) )
62
+ $ fmt " ->@ " $ Option. call ~f: pro_e $ psp_e $ bdy_e $ esp_e
63
+ $ Option. call ~f: epi_e )
65
64
66
65
let to_json {integers; floats; strings} =
67
66
`Assoc
Original file line number Diff line number Diff line change @@ -2,8 +2,7 @@ let div =
2
2
[ div
3
3
~a:
4
4
[ Reactive. a_style
5
- (React.S. map
6
- (sprintf " height: %dpx" )
5
+ (React.S. map (sprintf " height: %dpx" )
7
6
(State. player_height_signal app_state) )
8
7
(* ksprintf a_style "%s" (if_smth "min-height: 300px;" ""); *) ]
9
8
content ]
Original file line number Diff line number Diff line change @@ -100,10 +100,7 @@ let close_client () =
100
100
| Errored -> ()
101
101
102
102
let config c =
103
- get_client ()
104
- >> = fun cl ->
105
- log " [ocf] Config\n %!" ;
106
- Ocf. config c cl
103
+ get_client () >> = fun cl -> log " [ocf] Config\n %!" ; Ocf. config c cl
107
104
108
105
let format ?(format_args = empty_args) ?versions x =
109
106
get_client ?versions ()
Original file line number Diff line number Diff line change @@ -98,10 +98,7 @@ let close_client () =
98
98
| Errored -> ()
99
99
100
100
let config c =
101
- get_client ()
102
- >> = fun cl ->
103
- log " [ocf] Config\n %!" ;
104
- Ocf. config c cl
101
+ get_client () >> = fun cl -> log " [ocf] Config\n %!" ; Ocf. config c cl
105
102
106
103
let format x =
107
104
get_client ()
Original file line number Diff line number Diff line change @@ -25,9 +25,8 @@ let tests_string =
25
25
in
26
26
let test name s ~expected_preserve ~expected_normalize =
27
27
[ test_one (name ^ " (preserve)" ) s `Preserve ~expected: expected_preserve
28
- ; test_one
29
- (name ^ " (normalize)" )
30
- s `Normalize ~expected: expected_normalize ]
28
+ ; test_one (name ^ " (normalize)" ) s `Normalize
29
+ ~expected: expected_normalize ]
31
30
in
32
31
List. concat
33
32
[ [test_opt " string: not a string" {| hello| } `Preserve ~expected: None ]
You can’t perform that action at this time.
0 commit comments