Skip to content

Commit a42d74f

Browse files
committed
Fix true/false.
Don't emit semantic tokens for true/false. Remove redundant parts of grammar that were overriding booleans.
1 parent 2ebe7a6 commit a42d74f

File tree

4 files changed

+7
-9
lines changed

4 files changed

+7
-9
lines changed

analysis/src/SemanticTokens.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,9 @@ let parser ~debug ~emitter ~path =
277277
| Pexp_field (_, label) | Pexp_setfield (_, label, _) ->
278278
emitter |> emitRecordLabel ~label ~debug;
279279
Ast_mapper.default_mapper.expr mapper e
280+
| Pexp_construct ({txt = Lident ("true" | "false")}, _) ->
281+
(* Don't emit true or false *)
282+
Ast_mapper.default_mapper.expr mapper e
280283
| Pexp_construct (name, _) ->
281284
emitter |> emitVariant ~name ~debug;
282285
Ast_mapper.default_mapper.expr mapper e

analysis/tests/src/Parser.res

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,5 @@ module SomeComponent = {
8383
}
8484

8585
let _ = <SomeComponent.Nested> <div /> </SomeComponent.Nested>
86+
87+
let _ = true

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Parse tests/src/Parser.res
2-
structure items:22 diagnostics:0
2+
structure items:23 diagnostics:0
33
Lident: M (0,7) Namespace
44
Lident: C (1,9) Namespace
55
Lident: Component (1,13) Namespace

grammars/rescript.tmLanguage.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
},
1616
"RE_KEYWORDS": {
1717
"name": "keyword.control",
18-
"match": "\\b(and|as|assert|constraint|downto|else|exception|external|false|for|if|in|include|lazy|module|mutable|of|open|rec|switch|to|true|try|type|when|while|with)\\b"
18+
"match": "\\b(and|as|assert|constraint|downto|else|exception|external|for|if|in|include|lazy|module|mutable|of|open|rec|switch|to|try|type|when|while|with)\\b"
1919
},
2020
"RE_CONSTANTS_BOOL": {
2121
"name": "constant.language.boolean",
@@ -25,10 +25,6 @@
2525
"name": "keyword",
2626
"match": "\\b(let)\\b"
2727
},
28-
"RE_LITERAL": {
29-
"name": "constant.language",
30-
"match": "\\b(true|false)\\b"
31-
},
3228
"commentLine": {
3329
"match": "//.*",
3430
"name": "comment.line"
@@ -107,9 +103,6 @@
107103
},
108104
"constant": {
109105
"patterns": [
110-
{
111-
"include": "#RE_LITERAL"
112-
},
113106
{
114107
"include": "#RE_CONSTANTS_BOOL"
115108
}

0 commit comments

Comments
 (0)