Skip to content

Commit cc9f10e

Browse files
committed
Backwards-compatible check for braces attribute.
1 parent d7cab95 commit cc9f10e

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

analysis/tests/src/expected/Xform.res.txt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,15 @@ Hit: Add braces to function
4141
{"start": {"line": 26, "character": 0}, "end": {"line": 32, "character": 3}}
4242
newText:
4343
<--here
44-
let foo = x =>
44+
let foo = x => {
4545
// ^xfm
4646
@ns.braces
4747
switch x {
4848
| None => 33
4949
| Some(q) => q.T.a + 1
5050
// ^xfm
5151
}
52+
}
5253

5354
Xform src/Xform.res 34:21
5455
Hit: Add type annotation
@@ -71,15 +72,19 @@ Hit: Add braces to function
7172
{"start": {"line": 48, "character": 0}, "end": {"line": 48, "character": 25}}
7273
newText:
7374
<--here
74-
let noBraces = () => @ns.braces name
75+
let noBraces = () => {
76+
@ns.braces name
77+
}
7578

7679
Xform src/Xform.res 52:34
7780
Hit: Add braces to function
7881
{"start": {"line": 51, "character": 0}, "end": {"line": 54, "character": 1}}
7982
newText:
8083
<--here
8184
let nested = () => {
82-
let _noBraces = (_x, _y, _z) => @ns.braces "someNewFunc"
85+
let _noBraces = (_x, _y, _z) => {
86+
@ns.braces "someNewFunc"
87+
}
8388
// ^xfm
8489
}
8590

@@ -88,10 +93,11 @@ Hit: Add braces to function
8893
{"start": {"line": 58, "character": 4}, "end": {"line": 62, "character": 7}}
8994
newText:
9095
<--here
91-
let foo = (_x, y, _z) =>
96+
let foo = (_x, y, _z) => {
9297
@ns.braces
9398
switch y {
9499
| #some => 3
95100
| #stuff => 4
96101
}
102+
}
97103

analysis/vendor/res_outcome_printer/res_parsetree_viewer.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ let funExpr expr =
193193

194194
let processBracesAttr expr =
195195
match expr.pexp_attributes with
196-
| (({txt = "res.braces"}, _) as attr) :: attrs ->
196+
| (({txt = "res.braces" | "ns.braces"}, _) as attr) :: attrs ->
197197
(Some attr, {expr with pexp_attributes = attrs})
198198
| _ -> (None, expr)
199199

0 commit comments

Comments
 (0)