@@ -123,54 +123,33 @@ let hoverWithExpandedTypes ~file ~package ~supportsMarkdownLinks typ =
123
123
makes it (most often) work with unsaved content. *)
124
124
let getHoverViaCompletions ~debug ~path ~pos ~currentFile ~forHover
125
125
~supportsMarkdownLinks =
126
- let textOpt = Files. readFile currentFile in
127
- match textOpt with
128
- | None | Some "" -> None
129
- | Some text -> (
130
- match
131
- CompletionFrontEnd. completionWithParser ~debug ~path ~pos Cursor:pos
132
- ~current File ~text
133
- with
134
- | None -> None
135
- | Some (completable , scope ) -> (
136
- if debug then
137
- Printf. printf " Completable: %s\n "
138
- (SharedTypes.Completable. toString completable);
139
- (* Only perform expensive ast operations if there are completables *)
140
- match Cmt. loadFullCmtFromPath ~path with
141
- | None -> None
142
- | Some full -> (
143
- let {file; package} = full in
144
- let env = SharedTypes.QueryEnv. fromFile file in
145
- let completions =
146
- completable
147
- |> CompletionBackEnd. processCompletable ~debug ~full ~pos ~scope ~env
148
- ~for Hover
126
+ match Completions. getCompletions ~debug ~path ~pos ~current File ~for Hover with
127
+ | None -> None
128
+ | Some (completions , {file; package} ) -> (
129
+ match completions with
130
+ | {kind = Label typString ; docstring} :: _ ->
131
+ let parts =
132
+ (if typString = " " then [] else [Markdown. codeBlock typString])
133
+ @ docstring
134
+ in
135
+ Some (Protocol. stringifyHover (String. concat " \n\n " parts))
136
+ | {kind = Field _ ; docstring} :: _ -> (
137
+ match CompletionBackEnd. completionsGetTypeEnv completions with
138
+ | Some (typ , _env ) ->
139
+ let typeString =
140
+ hoverWithExpandedTypes ~file ~package ~supports MarkdownLinks typ
149
141
in
150
- match completions with
151
- | {kind = Label typString ; docstring} :: _ ->
152
- let parts =
153
- (if typString = " " then [] else [Markdown. codeBlock typString])
154
- @ docstring
155
- in
156
- Some (Protocol. stringifyHover (String. concat " \n\n " parts))
157
- | {kind = Field _ ; docstring} :: _ -> (
158
- match CompletionBackEnd. completionsGetTypeEnv completions with
159
- | Some (typ , _env ) ->
160
- let typeString =
161
- hoverWithExpandedTypes ~file ~package ~supports MarkdownLinks typ
162
- in
163
- let parts = typeString :: docstring in
164
- Some (Protocol. stringifyHover (String. concat " \n\n " parts))
165
- | None -> None )
166
- | _ -> (
167
- match CompletionBackEnd. completionsGetTypeEnv completions with
168
- | Some (typ , _env ) ->
169
- let typeString =
170
- hoverWithExpandedTypes ~file ~package ~supports MarkdownLinks typ
171
- in
172
- Some (Protocol. stringifyHover typeString)
173
- | None -> None ))))
142
+ let parts = typeString :: docstring in
143
+ Some (Protocol. stringifyHover (String. concat " \n\n " parts))
144
+ | None -> None )
145
+ | _ -> (
146
+ match CompletionBackEnd. completionsGetTypeEnv completions with
147
+ | Some (typ , _env ) ->
148
+ let typeString =
149
+ hoverWithExpandedTypes ~file ~package ~supports MarkdownLinks typ
150
+ in
151
+ Some (Protocol. stringifyHover typeString)
152
+ | None -> None ))
174
153
175
154
let newHover ~full :{file; package} ~supportsMarkdownLinks locItem =
176
155
match locItem.locType with
0 commit comments