Skip to content

Commit f1e2638

Browse files
committed
Cleanup pipe: remove |.u which is effectively treated the same as |..
1 parent c2ad39e commit f1e2638

27 files changed

+116
-134
lines changed

analysis/src/CompletionFrontEnd.ml

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ let rec exprToContextPathInner (e : Parsetree.expression) =
218218
(match exprs with
219219
| [] -> None
220220
| exp :: _ -> exprToContextPath exp))
221-
| Pexp_ident {txt = Lident ("|." | "|.u")} -> None
221+
| Pexp_ident {txt = Lident "|."} -> None
222222
| Pexp_ident {txt; loc} ->
223223
Some
224224
(CPId {path = Utils.flattenLongIdent txt; completionContext = Value; loc})
@@ -258,7 +258,7 @@ let rec exprToContextPathInner (e : Parsetree.expression) =
258258
{
259259
funct =
260260
{
261-
pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u")};
261+
pexp_desc = Pexp_ident {txt = Lident "|."};
262262
pexp_loc;
263263
pexp_attributes;
264264
};
@@ -275,7 +275,7 @@ let rec exprToContextPathInner (e : Parsetree.expression) =
275275
}
276276
| Pexp_apply
277277
{
278-
funct = {pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u")}};
278+
funct = {pexp_desc = Pexp_ident {txt = Lident "|."}};
279279
args =
280280
[
281281
(_, lhs); (_, {pexp_desc = Pexp_ident id; pexp_loc; pexp_attributes});
@@ -328,15 +328,15 @@ let completePipeChain (exp : Parsetree.expression) =
328328
Example: someArray->Js.Array2.map(v => v + 2)-> *)
329329
| Pexp_apply
330330
{
331-
funct = {pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u")}};
331+
funct = {pexp_desc = Pexp_ident {txt = Lident "|."}};
332332
args = [_; (_, {pexp_desc = Pexp_apply {funct = d}})];
333333
} ->
334334
exprToContextPath exp |> Option.map (fun ctxPath -> (ctxPath, d.pexp_loc))
335335
(* When the left side of the pipe we're completing is an identifier application.
336336
Example: someArray->filterAllTheGoodStuff-> *)
337337
| Pexp_apply
338338
{
339-
funct = {pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u")}};
339+
funct = {pexp_desc = Pexp_ident {txt = Lident "|."}};
340340
args = [_; (_, {pexp_desc = Pexp_ident _; pexp_loc})];
341341
} ->
342342
exprToContextPath exp |> Option.map (fun ctxPath -> (ctxPath, pexp_loc))
@@ -1113,8 +1113,7 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor
11131113
resetCurrentCtxPath oldCtxPath
11141114
| Pexp_apply
11151115
{
1116-
funct =
1117-
{pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u"); loc = opLoc}};
1116+
funct = {pexp_desc = Pexp_ident {txt = Lident "|."; loc = opLoc}};
11181117
args =
11191118
[
11201119
(_, lhs);
@@ -1292,7 +1291,7 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor
12921291
else iterateJsxProps ~iterator jsxProps
12931292
| Pexp_apply
12941293
{
1295-
funct = {pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u")}};
1294+
funct = {pexp_desc = Pexp_ident {txt = Lident "|."}};
12961295
args =
12971296
[
12981297
(_, lhs);
@@ -1304,19 +1303,15 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor
13041303
setPipeResult ~lhs ~id |> ignore
13051304
| Pexp_apply
13061305
{
1307-
funct =
1308-
{
1309-
pexp_desc =
1310-
Pexp_ident {txt = Lident ("|." | "|.u"); loc = opLoc};
1311-
};
1306+
funct = {pexp_desc = Pexp_ident {txt = Lident "|."; loc = opLoc}};
13121307
args = [(_, lhs); _];
13131308
}
13141309
when Loc.end_ opLoc = posCursor ->
13151310
if Debug.verbose () then print_endline "[expr_iter] Case foo->";
13161311
setPipeResult ~lhs ~id:"" |> ignore
13171312
| Pexp_apply
13181313
{
1319-
funct = {pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u")}};
1314+
funct = {pexp_desc = Pexp_ident {txt = Lident "|."}};
13201315
args = [_; (_, {pexp_desc = Pexp_apply {funct = funExpr; args}})];
13211316
}
13221317
when (* Normally named arg completion fires when the cursor is right after the expression.
@@ -1352,7 +1347,7 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor
13521347
| Some argCompletable -> setResult argCompletable)
13531348
| Pexp_apply
13541349
{
1355-
funct = {pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u")}};
1350+
funct = {pexp_desc = Pexp_ident {txt = Lident "|."}};
13561351
args = [_; _];
13571352
} ->
13581353
(* Ignore any other pipe. *)

analysis/src/SignatureHelp.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ let signatureHelp ~path ~pos ~currentFile ~debug ~allowForConstructorPayloads =
365365
pexp_desc =
366366
Pexp_apply
367367
{
368-
funct = {pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u")}};
368+
funct = {pexp_desc = Pexp_ident {txt = Lident "|."}};
369369
args =
370370
[
371371
_;

compiler/frontend/ast_exp_apply.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ let view_as_app (fn : exp) (s : string list) : app_pattern option =
6969
Some {op; loc = fn.pexp_loc; args = check_and_discard args}
7070
| _ -> None
7171

72-
let infix_ops = ["|."; "|.u"; "#="; "##"]
72+
let infix_ops = ["|."; "#="; "##"]
7373

7474
let app_exp_mapper (e : exp) (self : Bs_ast_mapper.mapper) : exp =
7575
match view_as_app e infix_ops with
76-
| Some {op = "|." | "|.u"; args = [a_; f_]; loc} -> (
76+
| Some {op = "|."; args = [a_; f_]; loc} -> (
7777
(*
7878
a |. f
7979
a |. f b c [@bs] --> f a b c [@bs]

compiler/syntax/src/res_comments_table.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1343,7 +1343,7 @@ and walk_expression expr t comments =
13431343
( ":=" | "||" | "&&" | "=" | "==" | "<" | ">" | "!="
13441344
| "!==" | "<=" | ">=" | "|>" | "+" | "+." | "-" | "-."
13451345
| "++" | "^" | "*" | "*." | "/" | "/." | "**" | "|."
1346-
| "|.u" | "<>" );
1346+
| "<>" );
13471347
};
13481348
};
13491349
args = [(Nolabel, operand1); (Nolabel, operand2)];

compiler/syntax/src/res_core.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ let build_longident words =
391391

392392
let make_infix_operator (p : Parser.t) token start_pos end_pos =
393393
let stringified_token =
394-
if token = Token.MinusGreater then "|.u"
394+
if token = Token.MinusGreater then "|."
395395
else if token = Token.PlusPlus then "^"
396396
else if token = Token.BangEqual then "<>"
397397
else if token = Token.BangEqualEqual then "!="

compiler/syntax/src/res_parsetree_viewer.ml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ let operator_precedence operator =
274274
| "+" | "+." | "-" | "-." | "^" -> 5
275275
| "*" | "*." | "/" | "/." | "%" -> 6
276276
| "**" -> 7
277-
| "#" | "##" | "|." | "|.u" -> 8
277+
| "#" | "##" | "|." -> 8
278278
| _ -> 0
279279

280280
let is_unary_operator operator =
@@ -298,7 +298,7 @@ let is_binary_operator operator =
298298
match operator with
299299
| ":=" | "||" | "&&" | "=" | "==" | "<" | ">" | "!=" | "!==" | "<=" | ">="
300300
| "|>" | "+" | "+." | "-" | "-." | "^" | "*" | "*." | "/" | "/." | "**" | "|."
301-
| "|.u" | "<>" | "%" ->
301+
| "<>" | "%" ->
302302
true
303303
| _ -> false
304304

@@ -714,11 +714,7 @@ let is_single_pipe_expr expr =
714714
match expr.pexp_desc with
715715
| Pexp_apply
716716
{
717-
funct =
718-
{
719-
pexp_desc =
720-
Pexp_ident {txt = Longident.Lident ("|." | "|.u" | "|>")};
721-
};
717+
funct = {pexp_desc = Pexp_ident {txt = Longident.Lident ("|." | "|>")}};
722718
args = [(Nolabel, _operand1); (Nolabel, _operand2)];
723719
} ->
724720
true
@@ -727,10 +723,7 @@ let is_single_pipe_expr expr =
727723
match expr.pexp_desc with
728724
| Pexp_apply
729725
{
730-
funct =
731-
{
732-
pexp_desc = Pexp_ident {txt = Longident.Lident ("|." | "|.u" | "|>")};
733-
};
726+
funct = {pexp_desc = Pexp_ident {txt = Longident.Lident ("|." | "|>")}};
734727
args = [(Nolabel, operand1); (Nolabel, _operand2)];
735728
}
736729
when not (is_pipe_expr operand1) ->

compiler/syntax/src/res_printer.ml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3666,7 +3666,7 @@ and print_binary_expression ~state (expr : Parsetree.expression) cmt_tbl =
36663666
let print_binary_operator ~inline_rhs operator =
36673667
let operator_txt =
36683668
match operator with
3669-
| "|." | "|.u" -> "->"
3669+
| "|." -> "->"
36703670
| "^" -> "++"
36713671
| "=" -> "=="
36723672
| "==" -> "==="
@@ -3675,12 +3675,12 @@ and print_binary_expression ~state (expr : Parsetree.expression) cmt_tbl =
36753675
| txt -> txt
36763676
in
36773677
let spacing_before_operator =
3678-
if operator = "|." || operator = "|.u" then Doc.soft_line
3678+
if operator = "|." then Doc.soft_line
36793679
else if operator = "|>" then Doc.line
36803680
else Doc.space
36813681
in
36823682
let spacing_after_operator =
3683-
if operator = "|." || operator = "|.u" then Doc.nil
3683+
if operator = "|." then Doc.nil
36843684
else if operator = "|>" then Doc.space
36853685
else if inline_rhs then Doc.space
36863686
else Doc.line
@@ -3751,7 +3751,7 @@ and print_binary_expression ~state (expr : Parsetree.expression) cmt_tbl =
37513751
]
37523752
else
37533753
match operator with
3754-
| ("|." | "|.u") when is_multiline ->
3754+
| "|." when is_multiline ->
37553755
(* If the pipe-chain is written over multiple lines, break automatically
37563756
* `let x = a->b->c -> same line, break when line-width exceeded
37573757
* `let x = a->
@@ -3857,8 +3857,7 @@ and print_binary_expression ~state (expr : Parsetree.expression) cmt_tbl =
38573857
{
38583858
funct =
38593859
{
3860-
pexp_desc =
3861-
Pexp_ident {txt = Longident.Lident (("|." | "|.u" | "|>") as op)};
3860+
pexp_desc = Pexp_ident {txt = Longident.Lident (("|." | "|>") as op)};
38623861
};
38633862
args = [(Nolabel, lhs); (Nolabel, rhs)];
38643863
}
@@ -3876,8 +3875,8 @@ and print_binary_expression ~state (expr : Parsetree.expression) cmt_tbl =
38763875
print_attributes ~state expr.pexp_attributes cmt_tbl;
38773876
lhs_doc;
38783877
(match (lhs_has_comment_below, op) with
3879-
| true, ("|." | "|.u") -> Doc.concat [Doc.soft_line; Doc.text "->"]
3880-
| false, ("|." | "|.u") -> Doc.text "->"
3878+
| true, "|." -> Doc.concat [Doc.soft_line; Doc.text "->"]
3879+
| false, "|." -> Doc.text "->"
38813880
| true, "|>" -> Doc.concat [Doc.line; Doc.text "|> "]
38823881
| false, "|>" -> Doc.text " |> "
38833882
| _ -> Doc.nil);

tests/syntax_tests/data/parsing/errors/expressions/expected/block.res.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,14 @@ let findThreadByIdLinearScan [arity:2]~threads:((threads)[@res.namedArgLoc ])
7474
otherPersonIDWhichIsAlsoThreadID
7575
| Group { id } -> id
7676
| Unknown { id } ->
77-
(unknown.id |.u Js.String.make) |.u FBID.ofStringUnsafe in
77+
(unknown.id |. Js.String.make) |. FBID.ofStringUnsafe in
7878
thisId == id)
7979
[@res.braces ])))
8080
[@res.braces ])
81-
let x = ((loop 0 (Nil |.u (push doc)))[@res.braces ])
81+
let x = ((loop 0 (Nil |. (push doc)))[@res.braces ])
8282
;;match stack with
8383
| Empty -> [%rescript.exprhole ]
8484
| Cons (doc, rest) -> ()
85-
| Join (doc1, doc2) ->
86-
(buffer |.u (Buffer.add_string indentation); loop ())
85+
| Join (doc1, doc2) -> (buffer |. (Buffer.add_string indentation); loop ())
8786
let pipeline =
8887
match scheduler with | Some -> [%rescript.exprhole ] | None -> ()

tests/syntax_tests/data/parsing/errors/structure/expected/gh16B.res.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313

1414
open Ws
1515
let wss = Server.make { port = 82 }
16-
let address = wss |.u Server.address
16+
let address = wss |. Server.address
1717
let log [arity:1]msg =
1818
Js.log
1919
(((((({js|> Server: |js})[@res.template ]) ^ msg)[@res.template ]) ^
2020
(({js||js})[@res.template ]))[@res.template ])
2121
;;log
2222
(((((((((((((({js|Running on: |js})[@res.template ]) ^ address.address)
2323
[@res.template ]) ^ (({js|:|js})[@res.template ]))
24-
[@res.template ]) ^ (address.port |.u string_of_int))
24+
[@res.template ]) ^ (address.port |. string_of_int))
2525
[@res.template ]) ^ (({js| (|js})[@res.template ]))
2626
[@res.template ]) ^ address.family)
2727
[@res.template ]) ^ (({js|)|js})[@res.template ]))[@res.template ])
@@ -31,8 +31,8 @@ module ClientSet =
3131
(Belt.Id.MakeComparable)(struct
3232
type nonrec t = Client.t
3333
let cmp [arity:2]a b =
34-
((compare (a |.u Client.getUniqueId)
35-
(b |.u Client.getUniqueId))
34+
((compare (a |. Client.getUniqueId)
35+
(b |. Client.getUniqueId))
3636
[@res.braces ])
3737
end)
3838
let empty = Belt.Set.make ~id:(((module T))[@res.namedArgLoc ])

tests/syntax_tests/data/parsing/errors/structure/expected/letBinding.res.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@
100100
let rightResource =
101101
(ur.resources).find
102102
(fun [arity:1]r -> r.account_id == ((connection.left).account).id)
103-
let x = ((let field = p |.u parseFieldDeclaration in field)[@res.braces ])
104-
let t = ((let (_, _, token) = scanner |.u scan in token)[@res.braces ])
103+
let x = ((let field = p |. parseFieldDeclaration in field)[@res.braces ])
104+
let t = ((let (_, _, token) = scanner |. scan in token)[@res.braces ])
105105
let (keyTable : int Belt.Map.String.t) = [%rescript.exprhole ]
106106
let foo = [%rescript.exprhole ]
107107
let (x : int) = string = y

tests/syntax_tests/data/parsing/grammar/expressions/expected/UncurriedAlways.res.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ let foo [arity:2]x y = x + y
33
let z = foo 3 4
44
let bar [arity:2]x y = x + y
55
let b = bar 3 4
6-
let w = 3 |.u (foo 4)
7-
let a = 3 |.u (foo 4)
6+
let w = 3 |. (foo 4)
7+
let a = 3 |. (foo 4)

tests/syntax_tests/data/parsing/grammar/expressions/expected/UncurriedByDefault.res.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ type nonrec uu2 = unit -> unit -> unit (a:2)
9191
type nonrec up2 = unit -> unit -> unit (a:2)
9292
type nonrec cnested = (string -> unit (a:1)) -> unit (a:1)
9393
type nonrec unested = (string -> unit (a:1)) -> unit (a:1)
94-
let pipe1 = 3 |.u f
94+
let pipe1 = 3 |. f
9595
let (uannpoly : 'a -> string (a:1)) = xx
9696
let (uannint : int -> string (a:1)) = xx
9797
let _ = ((fun [arity:1]x -> 34)[@att ])

tests/syntax_tests/data/parsing/grammar/expressions/expected/arrow.res.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ let f [arity:2](a, b) (c, d) = ((a + b) + c) + d
1818
let f [arity:1]exception Terminate = ()
1919
let f [arity:2]exception Terminate exception Exit = ()
2020
let f [arity:1][] = ()
21-
let f [arity:1](x::xs) = x + (xs |.u Belt.List.length)
21+
let f [arity:1](x::xs) = x + (xs |. Belt.List.length)
2222
let f [arity:2](x : int) (y : int) = x + y
2323
let f [arity:2]~a:((a)[@res.namedArgLoc ]) ~b:((b)[@res.namedArgLoc ]) =
2424
a + b

tests/syntax_tests/data/parsing/grammar/expressions/expected/async.res.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ let fetch2 =
1010
[@res.braces ])
1111
let async =
1212
((let f = async () in
13-
() |.u async;
13+
() |. async;
1414
async ();
1515
async.async;
1616
{ async = (async.(async)) };
17-
(result |.u async) |.u (mapAsync (fun [arity:1]a -> doStuff a)))
17+
(result |. async) |. (mapAsync (fun [arity:1]a -> doStuff a)))
1818
[@res.braces ])
1919
let f =
2020
((if isPositive
@@ -25,7 +25,7 @@ let foo = async ~a:((34)[@res.namedArgLoc ])
2525
let bar async [arity:1]~a:((a)[@res.namedArgLoc ]) = a + 1
2626
let ex1 = ((3)[@res.await ]) + ((4)[@res.await ])
2727
let ex2 = ((3)[@res.await ]) ** ((4)[@res.await ])
28-
let ex3 = ((foo |.u (bar ~arg:((arg)[@res.namedArgLoc ])))[@res.await ])
28+
let ex3 = ((foo |. (bar ~arg:((arg)[@res.namedArgLoc ])))[@res.await ])
2929
let ex4 = (((foo.bar).baz)[@res.await ])
3030
let attr1 = ((async fun [arity:1]x -> x + 1)[@a ])
3131
let attr2 = ((fun (type a) ->

tests/syntax_tests/data/parsing/grammar/expressions/expected/binary.res.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
;;node := (if newBalance == 2 then avl |.u (rotateRight node) else node)
2-
;;node := ((if newBalance == 2 then avl |.u (rotateRight node) else node)
1+
;;node := (if newBalance == 2 then avl |. (rotateRight node) else node)
2+
;;node := ((if newBalance == 2 then avl |. (rotateRight node) else node)
33
[@attr ])
44
let x = (match z with | _ -> false) z
55
let x = ((match z with | _ -> false)[@attr ]) z
@@ -19,6 +19,6 @@ let x = a -. b
1919
;;Constructor (a, b)
2020
;;`Constructor (a, b)
2121
let _ = ((Constructor (a, b); `Constructor (a, b))[@res.braces ])
22-
;;(library.getBalance account) |.u
22+
;;(library.getBalance account) |.
2323
(Promise.Js.catch
2424
(fun [arity:1]_ -> ((Promise.resolved None)[@res.braces ])))

tests/syntax_tests/data/parsing/grammar/expressions/expected/binaryNoEs6Arrow.res.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
| Some videoContainerRect ->
2828
let newChapter =
2929
({ startTime = (percent *. duration) } : Video.chapter) in
30-
{ a; b } |.u onChange
30+
{ a; b } |. onChange
3131
| _ -> ())
3232
[@res.braces ]))[@res.namedArgLoc ][@res.braces ])
3333
~children:[] ())[@JSX ])

tests/syntax_tests/data/parsing/grammar/expressions/expected/block.res.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
let b =
22
((let module Array = Belt.Array in
3-
([|1;2|] |.u (Array.map (fun [arity:1]x -> x + 1))) |.u Js.log)
3+
([|1;2|] |. (Array.map (fun [arity:1]x -> x + 1))) |. Js.log)
44
[@res.braces ])
55
let b =
66
((let open Belt.Array in
7-
([|1;2|] |.u (map (fun [arity:1]x -> x + 1))) |.u Js.log)
7+
([|1;2|] |. (map (fun [arity:1]x -> x + 1))) |. Js.log)
88
[@res.braces ])
99
let b = ((let exception QuitEarly in raise QuitEarly)[@res.braces ])
1010
let b = ((let a = 1 in let b = 2 in a + b)[@res.braces ])
@@ -20,7 +20,7 @@ let b =
2020
let a = 1 in
2121
let b = 2 in
2222
sideEffect ();
23-
(let x = (1 + 2) |.u (fun [arity:1]x -> x + 1) in
23+
(let x = (1 + 2) |. (fun [arity:1]x -> x + 1) in
2424
raise (Terminate x)))
2525
[@res.braces ])
2626
let b = ((f (); g (); h (); (let arr = [|1;2;3|] in ()))[@res.braces ])

tests/syntax_tests/data/parsing/grammar/expressions/expected/bracedOrRecord.res.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ let f = ((fun [arity:1]event -> (event.target).value)[@res.braces ])
2626
let f = ((fun [arity:1]event -> ((event.target).value : string))
2727
[@res.braces ])
2828
let x = ((let a = 1 in let b = 2 in a + b)[@res.braces ])
29-
;;(([(({js|\n|js} |.u React.string)[@res.braces ])])[@JSX ])
29+
;;(([(({js|\n|js} |. React.string)[@res.braces ])])[@JSX ])

0 commit comments

Comments
 (0)