@@ -1487,7 +1487,12 @@ type extractedType =
1487
1487
| Tuple of QueryEnv .t * Types .type_expr list
1488
1488
| Toption of QueryEnv .t * Types .type_expr
1489
1489
| Tbool of QueryEnv .t
1490
- | Tvariant of {env : QueryEnv .t ; constructors : Constructor .t list }
1490
+ | Tvariant of {
1491
+ env : QueryEnv .t ;
1492
+ constructors : Constructor .t list ;
1493
+ variantDecl : Types .type_declaration ;
1494
+ variantName : string ;
1495
+ }
1491
1496
1492
1497
(* This is a more general extraction function for pulling out the type of a type_expr. We already have other similar functions, but they are all specialized on something (variants, records, etc). *)
1493
1498
let rec extractType ~env ~package (t : Types.type_expr ) =
@@ -1503,8 +1508,10 @@ let rec extractType ~env ~package (t : Types.type_expr) =
1503
1508
match References. digConstructor ~env ~package path with
1504
1509
| Some (env , {item = {decl = {type_manifest = Some t1 } } } ) ->
1505
1510
extractType ~env ~package t1
1506
- | Some (env , {item = {kind = Type. Variant constructors } } ) ->
1507
- Some (Tvariant {env; constructors})
1511
+ | Some (env , {name; item = {decl; kind = Type. Variant constructors } } ) ->
1512
+ Some
1513
+ (Tvariant
1514
+ {env; constructors; variantName = name.txt; variantDecl = decl})
1508
1515
| _ -> None )
1509
1516
| Ttuple expressions -> Some (Tuple (env, expressions))
1510
1517
| _ -> None
@@ -1532,7 +1539,7 @@ let completeTypedValue ~env ~full ~prefix ~expandOption =
1532
1539
items
1533
1540
|> List. filter (fun (item : Completion.t ) ->
1534
1541
Utils. startsWith item.name prefix)
1535
- | Some (Tvariant {env; constructors} ) ->
1542
+ | Some (Tvariant {env; constructors; variantDecl; variantName } ) ->
1536
1543
let items =
1537
1544
constructors
1538
1545
|> List. filter_map (fun (constructor : Constructor.t ) ->
@@ -1553,7 +1560,10 @@ let completeTypedValue ~env ~full ~prefix ~expandOption =
1553
1560
|> String. concat " , " )
1554
1561
^ " )"
1555
1562
else " " )
1556
- ~kind: (Constructor (constructor, " " (* TODO *) ))
1563
+ ~kind:
1564
+ (Constructor
1565
+ ( constructor,
1566
+ variantDecl |> Shared. declToString variantName ))
1557
1567
~env ))
1558
1568
in
1559
1569
items
0 commit comments