@@ -2,6 +2,7 @@ namespace CSharpLanguageServer.Common
2
2
3
3
open System
4
4
open Microsoft.CodeAnalysis
5
+ open Microsoft.CodeAnalysis .Completion
5
6
open Microsoft.CodeAnalysis .Text
6
7
open Ionide.LanguageServerProtocol .Types
7
8
open FSharpPlus
@@ -205,3 +206,25 @@ module CompletionContext =
205
206
| CompletionTriggerKind.TriggerCharacter -> Option.map Completion.CompletionTrigger.CreateInsertionTrigger ctx.TriggerCharacter
206
207
| _ -> None)
207
208
|> Option.defaultValue ( Completion.CompletionTrigger.Invoke)
209
+
210
+
211
+ module CompletionDescription =
212
+ let toMarkdownString ( description : CompletionDescription ) : string =
213
+ description.TaggedParts
214
+ |> Seq.map ( fun taggedText ->
215
+ // WTF, if the developers of Roslyn don't want users to use TaggedText, why they set TaggedText to public?
216
+ // If they indeed want users to use it, why they set lots of imported fields to internal?
217
+ match taggedText.Tag with
218
+ // TODO: Support code block?
219
+ | " CodeBlockStart" -> " `` " + taggedText.Text
220
+ | " CodeBlockEnd" -> " ``" + taggedText.Text
221
+ | TextTags.LineBreak -> " \n\n "
222
+ | _ -> taggedText.Text)
223
+ |> String.concat " "
224
+
225
+ let toDocumentation ( description : CompletionDescription ) : Documentation =
226
+ Documentation.Markup { Kind = MarkupKind.Markdown; Value = toMarkdownString description }
227
+
228
+
229
+ module Documentation =
230
+ let fromCompletionDescription = CompletionDescription.toDocumentation
0 commit comments