@@ -100,27 +100,27 @@ let findRelevantTypesFromType ~file ~package typ =
100
100
let constructors = Shared. findTypeConstructors typesToSearch in
101
101
constructors |> List. filter_map (fromConstructorPath ~env: envToSearch)
102
102
103
+ let expandTypes ~file ~package ~supportsMarkdownLinks typ =
104
+ findRelevantTypesFromType typ ~file ~package
105
+ |> List. map (fun {decl; env; loc; path} ->
106
+ let linkToTypeDefinitionStr =
107
+ if supportsMarkdownLinks then
108
+ Markdown. goToDefinitionText ~env ~pos: loc.Warnings. loc_start
109
+ else " "
110
+ in
111
+ Markdown. divider
112
+ ^ (if supportsMarkdownLinks then Markdown. spacing else " " )
113
+ ^ Markdown. codeBlock
114
+ (decl
115
+ |> Shared. declToString ~print NameAsIs:true
116
+ (SharedTypes. pathIdentToString path))
117
+ ^ linkToTypeDefinitionStr ^ " \n " )
118
+
103
119
(* Produces a hover with relevant types expanded in the main type being hovered. *)
104
120
let hoverWithExpandedTypes ~file ~package ~supportsMarkdownLinks typ =
105
121
let typeString = Markdown. codeBlock (typ |> Shared. typeToString) in
106
- let types = findRelevantTypesFromType typ ~file ~package in
107
- let typeDefinitions =
108
- types
109
- |> List. map (fun {decl; env; loc; path} ->
110
- let linkToTypeDefinitionStr =
111
- if supportsMarkdownLinks then
112
- Markdown. goToDefinitionText ~env ~pos: loc.Warnings. loc_start
113
- else " "
114
- in
115
- Markdown. divider
116
- ^ (if supportsMarkdownLinks then Markdown. spacing else " " )
117
- ^ Markdown. codeBlock
118
- (decl
119
- |> Shared. declToString ~print NameAsIs:true
120
- (SharedTypes. pathIdentToString path))
121
- ^ linkToTypeDefinitionStr ^ " \n " )
122
- in
123
- typeString :: typeDefinitions |> String. concat " \n "
122
+ typeString :: expandTypes ~file ~package ~supports MarkdownLinks typ
123
+ |> String. concat " \n "
124
124
125
125
(* Leverages autocomplete functionality to produce a hover for a position. This
126
126
makes it (most often) work with unsaved content. *)
@@ -166,9 +166,14 @@ let getHoverViaCompletions ~debug ~path ~pos ~currentFile ~forHover
166
166
167
167
let newHover ~full :{file; package} ~supportsMarkdownLinks locItem =
168
168
match locItem.locType with
169
- | TypeDefinition (name , decl , _stamp ) ->
170
- let typeDef = Shared. declToString name decl in
171
- Some (Markdown. codeBlock typeDef)
169
+ | TypeDefinition (name , decl , _stamp ) -> (
170
+ let typeDef = Markdown. codeBlock (Shared. declToString name decl) in
171
+ match decl.type_manifest with
172
+ | None -> Some typeDef
173
+ | Some typ ->
174
+ Some
175
+ (typeDef :: expandTypes ~file ~package ~supports MarkdownLinks typ
176
+ |> String. concat " \n " ))
172
177
| LModule (Definition (stamp, _tip)) | LModule (LocalReference (stamp, _tip))
173
178
-> (
174
179
match Stamps. findModule file.stamps stamp with
0 commit comments