|
3 | 3 | namespace Microsoft.VisualStudio.FSharp.Editor |
4 | 4 |
|
5 | 5 | open System |
| 6 | +open System.Text.RegularExpressions |
6 | 7 | open System.Composition |
7 | 8 | open System.Collections.Concurrent |
8 | 9 | open System.Collections.Generic |
@@ -181,20 +182,49 @@ type internal FSharpSignatureHelpProvider |
181 | 182 | let paramDoc = XmlDocumentation.BuildMethodParamText(documentationBuilder, method.XmlDoc, p.ParameterName) |
182 | 183 | let doc = if String.IsNullOrWhiteSpace(paramDoc) then [||] |
183 | 184 | else [| TaggedText(TextTags.Text, paramDoc) |] |
184 | | - yield (p.ParameterName,p.IsOptional,doc,[| TaggedText(TextTags.Text,p.Display) |]) |] |
| 185 | + let parameterParts = |
| 186 | + if isStaticArgTip then |
| 187 | + [| TaggedText(TextTags.Class, p.Display) |] |
| 188 | + else |
| 189 | + let str = p.Display |
| 190 | + match str.IndexOf(':') with |
| 191 | + | -1 -> [| TaggedText(TextTags.Parameter, str) |] |
| 192 | + | 0 -> |
| 193 | + [| TaggedText(TextTags.Punctuation, ":"); |
| 194 | + TaggedText(TextTags.Class, str.[1..]) |] |
| 195 | + | i -> |
| 196 | + [| TaggedText(TextTags.Parameter, str.[..i-1]); |
| 197 | + TaggedText(TextTags.Punctuation, ":"); |
| 198 | + TaggedText(TextTags.Class, str.[i+1..]) |] |
| 199 | + yield (p.ParameterName, p.IsOptional, doc, parameterParts) |
| 200 | + |] |
185 | 201 |
|
186 | 202 | let hasParamComments (pcs: (string*bool*TaggedText[]*TaggedText[])[]) = |
187 | 203 | pcs |> Array.exists (fun (_, _, doc, _) -> doc.Length > 0) |
188 | 204 |
|
189 | | - let summaryText = if String.IsNullOrWhiteSpace(summaryDoc) then [| TaggedText() |] |
190 | | - elif (hasParamComments parameters) then [| TaggedText(TextTags.Text, summaryDoc + "\n") |] |
191 | | - else [| TaggedText(TextTags.Text, summaryDoc) |] |
192 | | - |
| 205 | + let summaryText = |
| 206 | + let doc = |
| 207 | + if String.IsNullOrWhiteSpace summaryDoc then |
| 208 | + String.Empty |
| 209 | + elif hasParamComments parameters then |
| 210 | + summaryDoc + "\n" |
| 211 | + else |
| 212 | + summaryDoc |
| 213 | + [| TaggedText(TextTags.Text, doc) |] |
| 214 | + |
193 | 215 | // Prepare the text to display |
194 | | - let descriptionParts = [| TaggedText(TextTags.Text, method.TypeText) |] |
195 | | - let prefixParts = [| TaggedText(TextTags.Text, methodGroup.MethodName); TaggedText(TextTags.Punctuation, (if isStaticArgTip then "<" else "(")) |] |
| 216 | + let descriptionParts = |
| 217 | + let str = method.TypeText |
| 218 | + if str.StartsWith(":", StringComparison.OrdinalIgnoreCase) then |
| 219 | + [| TaggedText(TextTags.Punctuation, ":"); |
| 220 | + TaggedText(TextTags.Class, str.[1..]) |] |
| 221 | + else |
| 222 | + [| TaggedText(TextTags.Text, str) |] |
| 223 | + let prefixParts = |
| 224 | + [| TaggedText(TextTags.Method, methodGroup.MethodName); |
| 225 | + TaggedText(TextTags.Punctuation, (if isStaticArgTip then "<" else "(")) |] |
196 | 226 | let separatorParts = [| TaggedText(TextTags.Punctuation, ", ") |] |
197 | | - let suffixParts = [| TaggedText(TextTags.Text, (if isStaticArgTip then ">" else ")")) |] |
| 227 | + let suffixParts = [| TaggedText(TextTags.Punctuation, (if isStaticArgTip then ">" else ")")) |] |
198 | 228 |
|
199 | 229 | let completionItem = (method.HasParamArrayArg, summaryText, prefixParts, separatorParts, suffixParts, parameters, descriptionParts) |
200 | 230 | // FSROSLYNTODO: Do we need a cache like for completion? |
@@ -244,3 +274,17 @@ type internal FSharpSignatureHelpProvider |
244 | 274 | return null |
245 | 275 | } |> CommonRoslynHelpers.StartAsyncAsTask cancellationToken |
246 | 276 |
|
| 277 | +open System.ComponentModel.Composition |
| 278 | +open Microsoft.VisualStudio.Utilities |
| 279 | +open Microsoft.VisualStudio.Text |
| 280 | +open Microsoft.VisualStudio.Text.Classification |
| 281 | +open Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.SignatureHelp.Presentation |
| 282 | + |
| 283 | +// Enable colorized signature help for F# buffers |
| 284 | + |
| 285 | +[<Export(typeof<IClassifierProvider>)>] |
| 286 | +[<ContentType(FSharpCommonConstants.FSharpSignatureHelpContentTypeName)>] |
| 287 | +type FSharpSignatureHelpClassifierProvider [<ImportingConstructor>] (typeMap) = |
| 288 | + interface IClassifierProvider with |
| 289 | + override __.GetClassifier (buffer: ITextBuffer) = |
| 290 | + buffer.Properties.GetOrCreateSingletonProperty(fun _ -> SignatureHelpClassifier(buffer, typeMap) :> _) |
0 commit comments