Skip to content

Commit 6a4a663

Browse files
committed
CSharpLanguageServer.Handlers.Hover: rewrite in a more functional approach
1 parent 0c731b1 commit 6a4a663

File tree

1 file changed

+13
-15
lines changed
  • src/CSharpLanguageServer/Handlers

1 file changed

+13
-15
lines changed

src/CSharpLanguageServer/Handlers/Hover.fs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,22 @@ open Ionide.LanguageServerProtocol.JsonRpc
55

66
open CSharpLanguageServer
77
open CSharpLanguageServer.State
8+
open CSharpLanguageServer.Util
89

910
[<RequireQualifiedAccess>]
1011
module Hover =
11-
let provider (_: ClientCapabilities) : U2<bool, HoverOptions> option = Some(U2.C1 true)
12+
let provider (_cc: ClientCapabilities) : U2<bool, HoverOptions> option = Some(U2.C1 true)
1213

13-
let handle (context: ServerRequestContext) (p: HoverParams) : AsyncLspResult<Hover option> = async {
14-
match! context.FindSymbol' p.TextDocument.Uri p.Position with
15-
| None -> return None |> LspResult.success
16-
| Some(symbol, _, _) ->
17-
let content = DocumentationUtil.markdownDocForSymbolWithSignature symbol
14+
let makeHoverForSymbol symbol =
15+
let content = DocumentationUtil.markdownDocForSymbolWithSignature symbol
1816

19-
let hover =
20-
{ Contents =
21-
{ Kind = MarkupKind.Markdown
22-
Value = content }
23-
|> U3.C1
24-
// TODO: Support range
25-
Range = None }
17+
{ Contents =
18+
{ Kind = MarkupKind.Markdown
19+
Value = content }
20+
|> U3.C1
21+
Range = None } // TODO: Support range
2622

27-
return hover |> Some |> LspResult.success
28-
}
23+
let handle (context: ServerRequestContext) (p: HoverParams) : AsyncLspResult<Hover option> =
24+
context.FindSymbol p.TextDocument.Uri p.Position
25+
|> Async.map (Option.map makeHoverForSymbol)
26+
|> Async.map LspResult.success

0 commit comments

Comments
 (0)