Skip to content

Commit a45e936

Browse files
committed
Handle quoted Pexp_ident.
1 parent 8c8653f commit a45e936

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

analysis/src/SemanticTokens.ml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,17 @@ let parser ~debug ~emitter ~path =
211211
in
212212
let expr (mapper : Ast_mapper.mapper) (e : Parsetree.expression) =
213213
match e.pexp_desc with
214+
| Pexp_ident {txt = Lident id}
215+
when snd (Utils.tupleOfLexing e.pexp_loc.loc_end)
216+
- snd (Utils.tupleOfLexing e.pexp_loc.loc_start)
217+
> String.length id (* /"stuff" *) ->
218+
let type_ = Token.Variable in
219+
if debug then
220+
Printf.printf "QuotedIdent: %s %s %s\n" id
221+
(posToString (Utils.tupleOfLexing e.pexp_loc.loc_start))
222+
(Token.tokenTypeDebug type_);
223+
emitter |> emitFromLoc ~loc:e.pexp_loc ~type_;
224+
Ast_mapper.default_mapper.expr mapper e
214225
| Pexp_ident {txt = lid; loc} ->
215226
emitter
216227
|> emitLongident ~pos:(Utils.tupleOfLexing loc.loc_start) ~lid ~debug;

analysis/tests/src/Parser.res

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,7 @@ module ToAsProp = {
103103
}
104104
}
105105
let _ = <ToAsProp to=3 />
106+
107+
// quoted identifiers
108+
let \"true" = 4
109+
let _ = \"true"

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Parse tests/src/Parser.res
2-
structure items:29 diagnostics:0
2+
structure items:31 diagnostics:0
33
Lident: M (0,7) Namespace
44
Lident: C (1,9) Namespace
55
Lident: Component (1,13) Namespace
@@ -121,4 +121,6 @@ Variable: to (100,14)->(100,17)
121121
Variable: make (100,6)->(100,10)
122122
JsxTag <: (104,8)
123123
Lident: ToAsProp (104,9) Namespace
124+
Variable: true (107,4)->(107,11)
125+
QuotedIdent: true (108,8) Variable
124126

0 commit comments

Comments
 (0)