@@ -5,7 +5,7 @@ open System.Reflection
5
5
6
6
open Ionide.LanguageServerProtocol .Server
7
7
open Ionide.LanguageServerProtocol .Types
8
- open Ionide.LanguageServerProtocol .Types . LspResult
8
+ open Ionide.LanguageServerProtocol .JsonRpc
9
9
10
10
open CSharpLanguageServer
11
11
open CSharpLanguageServer.State
@@ -16,7 +16,7 @@ open CSharpLanguageServer.Logging
16
16
17
17
[<RequireQualifiedAccess>]
18
18
module Completion =
19
- let private logger = LogProvider.getLoggerByName " Completion"
19
+ let private _logger = LogProvider.getLoggerByName " Completion"
20
20
21
21
let emptyRoslynOptionSet : Microsoft.CodeAnalysis.Options.OptionSet =
22
22
let osType = typeof< Microsoft.CodeAnalysis.Options.OptionSet>
@@ -134,9 +134,10 @@ module Completion =
134
134
135
135
let private cache = new LruCache<( Microsoft.CodeAnalysis.Document * Microsoft.CodeAnalysis.Completion.CompletionList)>( 5 )
136
136
137
- let handle ( context : ServerRequestContext ) ( p : CompletionParams ) : AsyncLspResult < Ionide.LanguageServerProtocol.Types. CompletionList option > = async {
137
+ let handle ( context : ServerRequestContext ) ( p : CompletionParams ) : Async < LspResult < U2 < CompletionItem array , CompletionList> option > > = async {
138
138
match context.GetDocument p.TextDocument.Uri with
139
- | None -> return None |> success
139
+ | None ->
140
+ return None |> LspResult.success
140
141
| Some doc ->
141
142
let! ct = Async.CancellationToken
142
143
let! sourceText = doc.GetTextAsync( ct) |> Async.AwaitTask
@@ -162,7 +163,7 @@ module Completion =
162
163
completionService.GetCompletionsAsync( doc, position, completionOptions, completionTrigger, ct)
163
164
|> Async.map Option.ofObj
164
165
else
165
- async.Return Option. None
166
+ async.Return None
166
167
167
168
return
168
169
completions
@@ -175,7 +176,8 @@ module Completion =
175
176
{ IsIncomplete = true
176
177
Items = items
177
178
ItemDefaults = None })
178
- |> success
179
+ |> Option.map U2.C2
180
+ |> LspResult.success
179
181
}
180
182
181
183
let resolve ( _context : ServerRequestContext ) ( item : CompletionItem ) : AsyncLspResult < CompletionItem > = async {
@@ -188,7 +190,6 @@ module Completion =
188
190
|> Seq.tryFind ( fun x -> x.DisplayText = item.Label && ( item.SortText.IsNone || x.SortText = item.SortText.Value))
189
191
|> Option.map ( fun x -> ( doc, x)))
190
192
with
191
- | None -> return item |> success
192
193
| Some ( doc, cachedItem) ->
193
194
let completionService = Microsoft.CodeAnalysis.Completion.CompletionService.GetService( doc)
194
195
let! ct = Async.CancellationToken
@@ -198,5 +199,8 @@ module Completion =
198
199
|> Async.map Option.ofObj
199
200
// TODO: make the doc as a markdown string instead of a plain text
200
201
let itemDocumentation = description |> Option.map Documentation.fromCompletionDescription
201
- return { item with Documentation = itemDocumentation |> Option.map U2.C2 } |> success
202
+ return { item with Documentation = itemDocumentation |> Option.map U2.C2 }
203
+ |> LspResult.success
204
+ | None ->
205
+ return item |> LspResult.success
202
206
}
0 commit comments