@@ -4,68 +4,33 @@ namespace Microsoft.VisualStudio.FSharp.Editor
44
55open System
66open System.Composition
7- open System.Collections .Concurrent
8- open System.Collections .Generic
9- open System.Collections .Immutable
107open System.Threading
118open System.Threading .Tasks
12- open System.Linq
13- open System.Runtime .CompilerServices
14- open System.Windows
15- open System.Windows .Controls
16- open System.Windows .Media
179
1810open Microsoft.CodeAnalysis
19- open Microsoft.CodeAnalysis .Completion
2011open Microsoft.CodeAnalysis .Classification
2112open Microsoft.CodeAnalysis .Editor
2213open Microsoft.CodeAnalysis .Editor .Implementation .IntelliSense .QuickInfo
23- open Microsoft.CodeAnalysis .Editor .Shared .Utilities
24- open Microsoft.CodeAnalysis .Formatting
2514open Microsoft.CodeAnalysis .Host .Mef
26- open Microsoft.CodeAnalysis .Options
2715open Microsoft.CodeAnalysis .Text
2816
2917open Microsoft.VisualStudio .FSharp .LanguageService
30- open Microsoft.VisualStudio .Text
31- open Microsoft.VisualStudio .Text .Classification
32- open Microsoft.VisualStudio .Text .Tagging
33- open Microsoft.VisualStudio .Text .Formatting
3418open Microsoft.VisualStudio .Shell
3519open Microsoft.VisualStudio .Shell .Interop
20+ open Microsoft.VisualStudio .Language .Intellisense
3621
37- open Microsoft.FSharp .Compiler
38- open Microsoft.FSharp .Compiler .Parser
39- open Microsoft.FSharp .Compiler .Range
4022open Microsoft.FSharp .Compiler .SourceCodeServices
41- open System.Windows .Documents
42-
43- // FSROSLYNTODO: with the merge of the below PR, the QuickInfo API should be changed
44- // to allow for a more flexible syntax for defining the content of the tooltip.
45- // The below interface should be discarded then or updated accourdingly.
46- // https://github.com/dotnet/roslyn/pull/13623
47- type internal FSharpDeferredQuickInfoContent ( content : string , textProperties : TextFormattingRunProperties ) =
48- interface IDeferredQuickInfoContentwith
49- override this.Create () : FrameworkElement =
50- let textBlock = TextBlock( Run( content), TextWrapping= TextWrapping.Wrap, TextTrimming= TextTrimming.None)
51- textBlock.SetValue( TextElement.BackgroundProperty, textProperties.BackgroundBrush)
52- textBlock.SetValue( TextElement.ForegroundProperty, textProperties.ForegroundBrush)
53- textBlock.SetValue( TextElement.FontFamilyProperty, textProperties.Typeface.FontFamily)
54- textBlock.SetValue( TextElement.FontSizeProperty, textProperties.FontRenderingEmSize)
55- textBlock.SetValue( TextElement.FontStyleProperty, if textProperties.Italicthen FontStyles.Italicelse FontStyles.Normal)
56- textBlock.SetValue( TextElement.FontWeightProperty, if textProperties.Boldthen FontWeights.Boldelse FontWeights.Normal)
57- upcast textBlock
5823
5924[<Shared>]
6025[<ExportQuickInfoProvider( PredefinedQuickInfoProviderNames.Semantic, FSharpCommonConstants.FSharpLanguageName) >]
6126type internal FSharpQuickInfoProvider
6227[<System.ComponentModel.Composition.ImportingConstructor>]
6328(
6429[< System.ComponentModel.Composition.Import( typeof< SVsServiceProvider>)>] serviceProvider: IServiceProvider,
65- _ classificationFormatMapService: IClassificationFormatMapService,
6630 checkerProvider: FSharpCheckerProvider,
6731 projectInfoManager: ProjectInfoManager,
68- typeMap: Shared.Utilities.ClassificationTypeMap
32+ typeMap: Shared.Utilities.ClassificationTypeMap,
33+ glyphService: IGlyphService
6934) =
7035
7136let xmlMemberIndexService = serviceProvider.GetService( typeof< SVsXMLMemberIndexService>) :?> IVsXMLMemberIndexService
@@ -76,15 +41,15 @@ type internal FSharpQuickInfoProvider
7641let! _ , checkFileResults = checker.ParseAndCheckDocument( filePath, textVersionHash, sourceText.ToString(), options)
7742let textLine = sourceText.Lines.GetLineFromPosition( position)
7843let textLineNumber = textLine.LineNumber+ 1 // Roslyn line numbers are zero-based
79- //let qualifyingNames, partialName = QuickParse.GetPartialLongNameEx(textLine.ToString(), textLineColumn - 1)
8044let defines = CompilerEnvironment.GetCompilationDefinesForEditing( filePath, options.OtherOptions|> Seq.toList)
8145let! symbol = CommonHelpers.getSymbolAtPosition( documentId, sourceText, position, filePath, defines, SymbolLookupKind.Fuzzy)
8246let! res = checkFileResults.GetStructuredToolTipTextAlternate( textLineNumber, symbol.RightColumn, textLine.ToString(), [ symbol.Text], FSharpTokenTag.IDENT) |> liftAsync
83- return !
84- match reswith
85- | FSharpToolTipText[]
86- | FSharpToolTipText[ FSharpStructuredToolTipElement.None] -> None
87- | _ -> Some( res, CommonRoslynHelpers.FSharpRangeToTextSpan( sourceText, symbol.Range))
47+ match reswith
48+ | FSharpToolTipText[]
49+ | FSharpToolTipText[ FSharpStructuredToolTipElement.None] -> return ! None
50+ | _ ->
51+ let! symbolUse = checkFileResults.GetSymbolUseAtLocation( textLineNumber, symbol.RightColumn, textLine.ToString(), [ symbol.Text])
52+ return ! Some( res, CommonRoslynHelpers.FSharpRangeToTextSpan( sourceText, symbol.Range), symbolUse.Symbol)
8853}
8954
9055interface IQuickInfoProviderwith
@@ -95,7 +60,8 @@ type internal FSharpQuickInfoProvider
9560let! _ = CommonHelpers.getSymbolAtPosition( document.Id, sourceText, position, document.FilePath, defines, SymbolLookupKind.Fuzzy)
9661let! options = projectInfoManager.TryGetOptionsForEditingDocumentOrProject( document)
9762let! textVersion = document.GetTextVersionAsync( cancellationToken)
98- let! toolTipElement , textSpan = FSharpQuickInfoProvider.ProvideQuickInfo( checkerProvider.Checker, document.Id, sourceText, document.FilePath, position, options, textVersion.GetHashCode())
63+ let! toolTipElement , textSpan , symbol =
64+ FSharpQuickInfoProvider.ProvideQuickInfo( checkerProvider.Checker, document.Id, sourceText, document.FilePath, position, options, textVersion.GetHashCode())
9965let mainDescription = Collections.Generic.List()
10066let documentation = Collections.Generic.List()
10167 XmlDocumentation.BuildDataTipText(
@@ -107,7 +73,7 @@ type internal FSharpQuickInfoProvider
10773let content =
10874 QuickInfoDisplayDeferredContent
10975(
110- symbolGlyph= null ,// SymbolGlyphDeferredContent(),
76+ symbolGlyph= SymbolGlyphDeferredContent( CommonRoslynHelpers.GetGlyphForSymbol ( symbol ), glyphService ),
11177 warningGlyph= null ,
11278 mainDescription= ClassifiableDeferredContent( mainDescription, typeMap),
11379 documentation= ClassifiableDeferredContent( documentation, typeMap),