Skip to content

Commit b95fd3d

Browse files
committed
Sync parser and outcome printer from syntax master
Fixes #454 This commit: rescript-lang/syntax@3aec2c8
1 parent a3d86d8 commit b95fd3d

22 files changed

+532
-250
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,8 @@ Completable: Cpath Value[ForAuto, a]
937937

938938
Complete src/Completion.res 234:34
939939
posCursor:[234:34] posNoWhite:[234:33] Found expr:[234:18->234:36]
940+
Pexp_apply ...__ghost__[0:-1->0:-1] (...[234:18->234:34], ...[234:34->234:36])
941+
posCursor:[234:34] posNoWhite:[234:33] Found expr:[234:18->234:34]
940942
Pexp_apply ...__ghost__[0:-1->0:-1] (...[234:18->234:32], ...[234:32->234:34])
941943
posCursor:[234:34] posNoWhite:[234:33] Found expr:[234:32->234:34]
942944
Pexp_ident na:[234:32->234:34]
@@ -1432,6 +1434,8 @@ Completable: Cpath Value[AndThatOther, T]
14321434

14331435
Complete src/Completion.res 378:24
14341436
posCursor:[378:24] posNoWhite:[378:23] Found expr:[378:12->378:26]
1437+
Pexp_apply ...__ghost__[0:-1->0:-1] (...[378:12->378:24], ...[378:24->378:26])
1438+
posCursor:[378:24] posNoWhite:[378:23] Found expr:[378:12->378:24]
14351439
Pexp_apply ...__ghost__[0:-1->0:-1] (...[378:12->378:16], ...[378:16->378:24])
14361440
posCursor:[378:24] posNoWhite:[378:23] Found expr:[378:16->378:24]
14371441
Pexp_ident ForAuto.:[378:16->378:24]
@@ -1452,6 +1456,8 @@ Completable: Cpath Value[ForAuto, ""]
14521456

14531457
Complete src/Completion.res 381:38
14541458
posCursor:[381:38] posNoWhite:[381:37] Found expr:[381:12->381:41]
1459+
Pexp_apply ...__ghost__[0:-1->0:-1] (...[381:12->381:39], ...[381:39->381:41])
1460+
posCursor:[381:38] posNoWhite:[381:37] Found expr:[381:12->381:39]
14551461
Pexp_apply ...__ghost__[0:-1->0:-1] (...[381:12->381:19], ...[381:19->381:39])
14561462
posCursor:[381:38] posNoWhite:[381:37] Found expr:[381:19->381:39]
14571463
Pexp_send [381:38->381:38] e:[381:19->381:36]
@@ -1472,6 +1478,10 @@ Completable: Cpath Value[FAO, forAutoObject][""]
14721478

14731479
Complete src/Completion.res 384:24
14741480
posCursor:[384:24] posNoWhite:[384:23] Found expr:[384:11->384:26]
1481+
Pexp_apply ...__ghost__[0:-1->0:-1] (...[384:11->384:24], ...[384:24->384:26])
1482+
posCursor:[384:24] posNoWhite:[384:23] Found expr:[384:11->384:24]
1483+
Pexp_apply ...__ghost__[0:-1->0:-1] (...[384:11->384:14], ...[384:14->384:24])
1484+
posCursor:[384:24] posNoWhite:[384:23] Found expr:[384:14->384:24]
14751485
Pexp_field [384:14->384:23] _:[384:24->384:24]
14761486
Completable: Cpath Value[funRecord].""
14771487
[{

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@ Completable: Cdecorator(live)
8787
{"contents": "The `@live` decorator is for reanalyze, a static analysis tool for ReScript that can do dead code analysis.\n\n`@live` tells the dead code analysis that the value should be considered live, even though it might appear to be dead. This is typically used in case of FFI where there are indirect ways to access values. It can be added to everything that could otherwise be considered unused by the dead code analysis - values, functions, arguments, records, individual record fields, and so on.\n\n[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#live-decorator).\n\nHint: Did you know you can run an interactive code analysis in your project by running the command `> ReScript: Start Code Analyzer`? Try it!"}
8888

8989
Hover src/Hover.res 115:4
90-
{"contents": "```rescript\n(.) => unit => int\n```"}
90+
{"contents": "```rescript\n(. ()) => unit => int\n```"}
9191

9292
Hover src/Hover.res 121:4
93-
{"contents": "```rescript\n(.) => (.) => int\n```"}
93+
{"contents": "```rescript\n(. ()) => (. ()) => int\n```"}
9494

9595
Hover src/Hover.res 124:4
9696
{"contents": "```rescript\n(. unit, unit) => int\n```"}
9797

9898
Hover src/Hover.res 127:5
99-
{"contents": "```rescript\n(.) => unit => int\n```"}
99+
{"contents": "```rescript\n(. ()) => unit => int\n```"}
100100

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ Completable: Cpath Value[t2].n2.n->m
3333
}]
3434

3535
Complete src/RecordCompletion.res 19:7
36-
posCursor:[19:7] posNoWhite:[19:6] Found expr:[19:3->25:0]
37-
Pexp_field [19:3->19:4] R.:[19:5->25:0]
36+
posCursor:[19:7] posNoWhite:[19:6] Found expr:[19:3->19:7]
37+
Pexp_field [19:3->19:4] R.:[19:5->19:7]
3838
Completable: Cpath Module[R].""
3939
[{
4040
"label": "name",

analysis/vendor/res_outcome_printer/res_ast_conversion.ml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,8 @@ let hasUncurriedAttribute attrs = List.exists (fun attr -> match attr with
323323
| _ -> false
324324
) attrs
325325

326+
let templateLiteralAttr = (Location.mknoloc "res.template", Parsetree.PStr [])
327+
326328
let normalize =
327329
let open Ast_mapper in
328330
{ default_mapper with
@@ -368,7 +370,7 @@ let normalize =
368370
in
369371
let s = Parsetree.Pconst_string ((escapeTemplateLiteral txt), newTag) in
370372
{p with
371-
ppat_attributes = mapper.attributes mapper p.ppat_attributes;
373+
ppat_attributes = templateLiteralAttr::(mapper.attributes mapper p.ppat_attributes);
372374
ppat_desc = Ppat_constant s
373375
}
374376
| _ ->
@@ -396,7 +398,7 @@ let normalize =
396398
in
397399
let s = Parsetree.Pconst_string ((escapeTemplateLiteral txt), newTag) in
398400
{expr with
399-
pexp_attributes = mapper.attributes mapper expr.pexp_attributes;
401+
pexp_attributes= templateLiteralAttr::(mapper.attributes mapper expr.pexp_attributes);
400402
pexp_desc = Pexp_constant s
401403
}
402404
| Pexp_apply (

analysis/vendor/res_outcome_printer/res_ast_debugger.ml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,13 @@ module SexpAst = struct
143143
string txt;
144144
optChar tag;
145145
]
146-
| Pconst_char c ->
146+
| Pconst_char _ ->
147+
Sexp.list [
148+
Sexp.atom "Pconst_char";
149+
]
150+
| Pconst_string(_, Some "INTERNAL_RES_CHAR_CONTENTS") ->
147151
Sexp.list [
148152
Sexp.atom "Pconst_char";
149-
Sexp.atom (Char.escaped c);
150153
]
151154
| Pconst_string (txt, tag) ->
152155
Sexp.list [

analysis/vendor/res_outcome_printer/res_comments_table.ml

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,22 +1682,13 @@ and walkExprArgument (_argLabel, expr) t comments =
16821682
recordRows
16831683
t
16841684
comments
1685-
| Ppat_or (pattern1, pattern2) ->
1686-
let (beforePattern1, insidePattern1, afterPattern1) =
1687-
partitionByLoc comments pattern1.ppat_loc
1688-
in
1689-
attach t.leading pattern1.ppat_loc beforePattern1;
1690-
walkPattern pattern1 t insidePattern1;
1691-
let (afterPattern1, rest) =
1692-
partitionAdjacentTrailing pattern1.ppat_loc afterPattern1
1693-
in
1694-
attach t.trailing pattern1.ppat_loc afterPattern1;
1695-
let (beforePattern2, insidePattern2, afterPattern2) =
1696-
partitionByLoc rest pattern2.ppat_loc
1697-
in
1698-
attach t.leading pattern2.ppat_loc beforePattern2;
1699-
walkPattern pattern2 t insidePattern2;
1700-
attach t.trailing pattern2.ppat_loc afterPattern2
1685+
| Ppat_or _->
1686+
walkList
1687+
~getLoc: (fun pattern -> pattern.Parsetree.ppat_loc)
1688+
~walkNode: (fun pattern -> walkPattern pattern)
1689+
(Res_parsetree_viewer.collectOrPatternChain pat)
1690+
t
1691+
comments
17011692
| Ppat_constraint (pattern, typ) ->
17021693
let (beforePattern, insidePattern, afterPattern) =
17031694
partitionByLoc comments pattern.ppat_loc

0 commit comments

Comments
 (0)