Skip to content

Commit 5be09fb

Browse files
committed
update loc attrs
1 parent da94a3c commit 5be09fb

File tree

10 files changed

+32
-34
lines changed

10 files changed

+32
-34
lines changed

jscomp/syntax/src/res_core.ml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2005,7 +2005,6 @@ and parseBracketAccess p expr startPos =
20052005
Parser.eatBreadcrumb p;
20062006
let rbracket = p.prevEndPos in
20072007
let arrayLoc = mkLoc lbracket rbracket in
2008-
let attr = (Location.mkloc "res.syntaxSugar" arrayLoc, Parsetree.PStr []) in
20092008
match p.token with
20102009
| Equal ->
20112010
Parser.leaveBreadcrumb p ExprArrayMutation;
@@ -2015,15 +2014,23 @@ and parseBracketAccess p expr startPos =
20152014
Location.mkloc (Longident.Ldot (Lident "Array", "set")) arrayLoc
20162015
in
20172016
let endPos = p.prevEndPos in
2017+
let attr =
2018+
( Location.mkloc "res.syntaxSugar" (mkLoc startPos endPos),
2019+
Parsetree.PStr [] )
2020+
in
20182021
let arraySet =
2019-
Ast_helper.Exp.apply ~loc:(mkLoc startPos endPos) ~attrs:[attr]
2020-
(Ast_helper.Exp.ident ~loc:arrayLoc arraySet)
2022+
Ast_helper.Exp.apply ~loc:(mkLoc startPos endPos)
2023+
(Ast_helper.Exp.ident ~loc:arrayLoc arraySet ~attrs:[attr])
20212024
[(Nolabel, expr); (Nolabel, accessExpr); (Nolabel, rhsExpr)]
20222025
in
20232026
Parser.eatBreadcrumb p;
20242027
arraySet
20252028
| _ ->
20262029
let endPos = p.prevEndPos in
2030+
let attr =
2031+
( Location.mkloc "res.syntaxSugar" (mkLoc startPos endPos),
2032+
Parsetree.PStr [] )
2033+
in
20272034
let e =
20282035
Ast_helper.Exp.apply ~loc:(mkLoc startPos endPos)
20292036
(Ast_helper.Exp.ident ~loc:arrayLoc ~attrs:[attr]

jscomp/syntax/tests/parsing/grammar/expressions/expected/binaryNoEs6Arrow.res.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
| _ -> ())
3232
[@res.braces ]))[@res.namedArgLoc ][@res.braces ])
3333
~children:[] ())[@JSX ])
34-
;;if ((inclusions.(index) <- (uid, url))[@res.syntaxSugar ])
34+
;;if ((Array.set)[@res.syntaxSugar ]) inclusions index (uid, url)
3535
then onChange inclusions

jscomp/syntax/tests/parsing/grammar/expressions/expected/bracedOrRecord.res.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ let e = ((if a |> computation then true else false)
1515
let e = ((((Array.get)[@res.syntaxSugar ]) a 0)[@res.braces ])
1616
let e = ((f b)[@res.braces ])
1717
let e = (((a.b).c)[@res.braces ])
18-
let e = ((arr.(x) <- 20)[@res.braces ][@res.syntaxSugar ])
18+
let e = ((((Array.set)[@res.syntaxSugar ]) arr x 20)[@res.braces ])
1919
let e = ((fun x -> (x + 1) |> (doStuff config))[@res.braces ])
2020
let e = (((fun x -> x + 1) |> (doStuff config))[@res.braces ])
2121
let e = ((if fun x -> x + 1 then true else false)

jscomp/syntax/tests/parsing/grammar/expressions/expected/primary.res.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ let x =
1212
let x =
1313
((Array.get)[@res.syntaxSugar ])
1414
(((Array.get)[@res.syntaxSugar ]) arr (x : int)) (y : int)
15-
;;((arr.(0) <- (a + b))[@res.syntaxSugar ])
15+
;;((Array.set)[@res.syntaxSugar ]) arr 0 (a + b)
1616
;;f ()
1717
;;(f ()) ()
1818
;;f a

jscomp/syntax/tests/printer/comments/expected/array.res.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(@res.syntaxSugar a[/* zz */ 0] = 7)
1+
a[/* zz */ 0] = 7
22

33
let _ = /* zz */ a[0]
44

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
(@res.syntaxSugar numbers[20] = 10)
1+
numbers[20] = 10
22

3-
(
4-
@res.syntaxSugar
5-
streetsAddressBookThisIsALongName[
6-
streets->Belt.Array.length - 1
7-
] = streetWithAVeryVeryVerrrrrrryVeeeeeeeeeryLongName
8-
)
3+
streetsAddressBookThisIsALongName[
4+
streets->Belt.Array.length - 1
5+
] = streetWithAVeryVeryVerrrrrrryVeeeeeeeeeryLongName

jscomp/syntax/tests/printer/expr/expected/braced.res.txt

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -220,24 +220,18 @@ let _ = {module(ME: MyMod)}
220220
}[{
221221
0
222222
}]
223-
(@res.syntaxSugar {myArray}[{0}] = {20})
224-
(
225-
@res.syntaxSugar
226-
{
227-
myArray
228-
}[{
229-
0
230-
}] = {
231-
20
232-
}
233-
)
223+
{myArray}[{0}] = {20}
224+
{
225+
myArray
226+
}[{
227+
0
228+
}] = {
229+
20
230+
}
234231

235-
(
236-
@res.syntaxSugar
237-
myArray[20] = {
238-
a + b
239-
}
240-
)
232+
myArray[20] = {
233+
a + b
234+
}
241235

242236
{jsObject}["foo"]
243237
{jsObject}["foo"] = {"bar"}

jscomp/syntax/tests/printer/expr/expected/if.res.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ let x =
3636
sideEffect()
3737
}
3838

39-
if @res.syntaxSugar inclusions[index] = (uid, url) {
39+
if inclusions[index] = (uid, url) {
4040
onChange(inclusions)
4141
}
4242

jscomp/syntax/tests/printer/expr/expected/unary.res.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,4 @@ let () = {
8484
}
8585

8686
let x = (!truths)[0]
87-
(@res.syntaxSugar (!streets)[0] = "foo-street")
87+
(!streets)[0] = "foo-street"

jscomp/syntax/tests/printer/expr/expected/underscoreApply.res.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ f(a, b, _) ? g(x, y, _) : h(alpha, beta, _)
4949
<div> {f(a, b, _)} </div>
5050

5151
f(a, b, _)[ix]
52-
(@res.syntaxSugar f(a, b, _)[ix] = 2)
52+
f(a, b, _)[ix] = 2
5353

5454
getDirector(a, b, _).name = "Steve"
5555

0 commit comments

Comments
 (0)