Skip to content

Commit ede6f86

Browse files
committed
For module types, use Token.Type.
1 parent 73879ae commit ede6f86

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

analysis/src/SemanticTokens.ml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ let emitFromLoc ~loc ~type_ emitter =
7878
let posStart, posEnd = locToPositions loc in
7979
emitter |> emitFromPos posStart posEnd ~type_
8080

81-
let emitLongident ?(backwards = false) ?(jsx = false) ~pos ~lid ~debug emitter =
81+
let emitLongident ?(backwards = false) ?(jsx = false)
82+
?(moduleToken = Token.Module) ~pos ~lid ~debug emitter =
8283
let rec flatten acc lid =
8384
match lid with
8485
| Longident.Lident txt -> txt :: acc
@@ -94,14 +95,14 @@ let emitLongident ?(backwards = false) ?(jsx = false) ~pos ~lid ~debug emitter =
9495
emitter
9596
|> emitFromPos pos
9697
(fst pos, snd pos + String.length id)
97-
~type_:(if isUppercaseId id then Module else Token.Variable)
98+
~type_:(if isUppercaseId id then moduleToken else Variable)
9899
| id :: segments when isUppercaseId id || isLowercaseId id ->
99100
if debug then Printf.printf "Ldot: %s %s\n" id (posToString pos);
100101
let length = String.length id in
101102
emitter
102103
|> emitFromPos pos
103104
(fst pos, snd pos + length)
104-
~type_:(if isUppercaseId id then Module else Token.Variable);
105+
~type_:(if isUppercaseId id then moduleToken else Variable);
105106
loop (fst pos, snd pos + length + 1) segments
106107
| _ -> ()
107108
in
@@ -232,14 +233,16 @@ let parser ~debug ~emitter ~path =
232233
match mt.pmty_desc with
233234
| Pmty_ident {txt = lid; loc} ->
234235
emitter
235-
|> emitLongident ~pos:(Utils.tupleOfLexing loc.loc_start) ~lid ~debug;
236+
|> emitLongident ~moduleToken:Token.Type
237+
~pos:(Utils.tupleOfLexing loc.loc_start)
238+
~lid ~debug;
236239
Ast_mapper.default_mapper.module_type mapper mt
237240
| _ -> Ast_mapper.default_mapper.module_type mapper mt
238241
in
239242
let module_type_declaration (mapper : Ast_mapper.mapper)
240243
(mtd : Parsetree.module_type_declaration) =
241244
emitter
242-
|> emitLongident
245+
|> emitLongident ~moduleToken:Token.Type
243246
~pos:(Utils.tupleOfLexing mtd.pmtd_name.loc.loc_start)
244247
~lid:(Longident.Lident mtd.pmtd_name.txt) ~debug;
245248
Ast_mapper.default_mapper.module_type_declaration mapper mtd

0 commit comments

Comments
 (0)