Skip to content

Commit d9dde12

Browse files
committed
Fix issue where type paths longer than 1 were not emitted.
1 parent 7592147 commit d9dde12

File tree

3 files changed

+34
-27
lines changed

3 files changed

+34
-27
lines changed

analysis/src/SemanticTokens.ml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,11 @@ let emitJsxTag ~debug ~name ~pos emitter =
163163
if debug then Printf.printf "JsxTag %s: %s\n" name (posToString pos);
164164
emitter |> emitFromPos pos (fst pos, snd pos + 1) ~type_:Token.JsxTag
165165

166-
let emitType ~id ~debug ~loc emitter =
167-
if debug then Printf.printf "Type: %s %s\n" id (locToString loc);
168-
emitter |> emitFromLoc ~loc ~type_:Token.Type
166+
let emitType ~lid ~debug ~loc emitter =
167+
emitter
168+
|> emitLongident ~lowerCaseToken:Token.Type
169+
~pos:(Utils.tupleOfLexing loc.Location.loc_start)
170+
~lid ~debug
169171

170172
let emitRecordLabel ~(label : Longident.t Location.loc) ~debug emitter =
171173
emitter
@@ -185,18 +187,17 @@ let parser ~debug ~emitter ~path =
185187
in
186188
let typ (mapper : Ast_mapper.mapper) (coreType : Parsetree.core_type) =
187189
match coreType.ptyp_desc with
188-
| Ptyp_constr ({txt; loc}, args) ->
189-
(match txt with
190-
| Lident id -> emitter |> emitType ~id ~debug ~loc
191-
| _ -> ());
190+
| Ptyp_constr ({txt = lid; loc}, args) ->
191+
emitter |> emitType ~lid ~debug ~loc;
192192
args |> List.iter processTypeArg;
193193
Ast_mapper.default_mapper.typ mapper coreType
194194
| _ -> Ast_mapper.default_mapper.typ mapper coreType
195195
in
196196
let type_declaration (mapper : Ast_mapper.mapper)
197197
(tydecl : Parsetree.type_declaration) =
198198
emitter
199-
|> emitType ~id:tydecl.ptype_name.txt ~debug ~loc:tydecl.ptype_name.loc;
199+
|> emitType ~lid:(Lident tydecl.ptype_name.txt) ~debug
200+
~loc:tydecl.ptype_name.loc;
200201
Ast_mapper.default_mapper.type_declaration mapper tydecl
201202
in
202203
let pat (mapper : Ast_mapper.mapper) (p : Parsetree.pattern) =

analysis/tests/src/Parser.res

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,5 @@ let \"true" = 4
109109
let _ = \"true"
110110

111111
let enumInModule = T.A
112+
113+
type typeInModule = XX.YY.t

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

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Parse tests/src/Parser.res
2-
structure items:32 diagnostics:0
2+
structure items:33 diagnostics:0
33
Lident: M (0,7) Namespace
44
Lident: C (1,9) Namespace
55
Lident: Component (1,13) Namespace
@@ -32,19 +32,19 @@ Lident: string (14,11) Variable
3232
Ldot: React (15,5) Namespace
3333
Lident: string (15,11) Variable
3434
Variable: _d2 (10,4)->(10,7)
35-
Type: pair (18,5)->(18,9)
36-
Type: looooooooooooooooooooooooooooooooooooooong_int (20,5)->(20,51)
37-
Type: int (20,54)->(20,57)
38-
Type: looooooooooooooooooooooooooooooooooooooong_string (22,5)->(22,54)
39-
Type: string (22,57)->(22,63)
40-
Type: pairIntString (24,5)->(24,18)
41-
Type: list (24,21)->(24,25)
35+
Lident: pair (18,5) Type
36+
Lident: looooooooooooooooooooooooooooooooooooooong_int (20,5) Type
37+
Lident: int (20,54) Type
38+
Lident: looooooooooooooooooooooooooooooooooooooong_string (22,5) Type
39+
Lident: string (22,57) Type
40+
Lident: pairIntString (24,5) Type
41+
Lident: list (24,21) Type
4242
TypeArg: (25,2)->(28,3)
43-
Type: pair (25,2)->(25,6)
43+
Lident: pair (25,2) Type
4444
TypeArg: (26,4)->(26,50)
4545
TypeArg: (27,4)->(27,53)
46-
Type: looooooooooooooooooooooooooooooooooooooong_int (26,4)->(26,50)
47-
Type: looooooooooooooooooooooooooooooooooooooong_string (27,4)->(27,53)
46+
Lident: looooooooooooooooooooooooooooooooooooooong_int (26,4) Type
47+
Lident: looooooooooooooooooooooooooooooooooooooong_string (27,4) Type
4848
Binary operator < (31,10)->(31,11)
4949
Binary operator > (31,19)->(31,20)
5050
Lident: MT (33,12) Type
@@ -54,20 +54,20 @@ Lident: MT (39,12) Type
5454
Lident: DDF (40,9) Namespace
5555
Lident: XX (45,7) Namespace
5656
Lident: YY (46,9) Namespace
57-
Type: t (47,9)->(47,10)
58-
Type: int (47,13)->(47,16)
57+
Lident: t (47,9) Type
58+
Lident: int (47,13) Type
5959
Ldot: XX (51,5) Namespace
6060
Lident: YY (51,8) Namespace
61-
Type: tt (53,5)->(53,7)
62-
Type: t (53,10)->(53,11)
61+
Lident: tt (53,5) Type
62+
Lident: t (53,10) Type
6363
Lident: T (57,7) Namespace
64-
Type: someRecord (58,7)->(58,17)
64+
Lident: someRecord (58,7) Type
6565
Lident: someField (59,4) Property
66-
Type: int (59,15)->(59,18)
66+
Lident: int (59,15) Type
6767
Lident: someOtherField (60,4) Property
68-
Type: string (60,20)->(60,26)
68+
Lident: string (60,20) Type
6969
Lident: theParam (61,4) Property
70-
Type: someEnum (64,7)->(64,15)
70+
Lident: someEnum (64,7) Type
7171
Lident: A (64,18) EnumMember
7272
Lident: B (64,22) EnumMember
7373
Lident: C (64,26) EnumMember
@@ -126,4 +126,8 @@ QuotedIdent: true (108,8) Variable
126126
Ldot: T (110,19) Namespace
127127
Lident: A (110,21) EnumMember
128128
Variable: enumInModule (110,4)->(110,16)
129+
Lident: typeInModule (112,5) Type
130+
Ldot: XX (112,20) Namespace
131+
Ldot: YY (112,23) Namespace
132+
Lident: t (112,26) Type
129133

0 commit comments

Comments
 (0)