Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit43dc891

Browse files
vasily-kirichenkoKevinRansom
authored andcommitted
Add glyph to Quick Info tooltip (dotnet#2157)
* add glyph to Quick Info tooltip* fix tests compilation
1 parented948ab commit43dc891

File tree

3 files changed

+87
-47
lines changed

3 files changed

+87
-47
lines changed

‎vsintegration/src/FSharp.Editor/Common/CommonRoslynHelpers.fs‎

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,80 @@ module internal CommonRoslynHelpers =
127127
| GlyphMajor.Error-> Glyph.Error
128128
|_-> Glyph.ClassPublic
129129

130+
let inline(|Public|Internal|Protected|Private|)(a:FSharpAccessibility)=
131+
if a.IsPublicthen Public
132+
elif a.IsInternalthen Internal
133+
elif a.IsPrivatethen Private
134+
else Protected
135+
136+
letGetGlyphForSymbol(symbol:FSharpSymbol)=
137+
match symbolwith
138+
|:? FSharpUnionCaseas x->
139+
match x.Accessibilitywith
140+
| Public-> Glyph.EnumPublic
141+
| Internal-> Glyph.EnumInternal
142+
| Protected-> Glyph.EnumProtected
143+
| Private-> Glyph.EnumPrivate
144+
|:? FSharpActivePatternCase-> Glyph.EnumPublic
145+
|:? FSharpFieldas x->
146+
match x.Accessibilitywith
147+
| Public-> Glyph.FieldPublic
148+
| Internal-> Glyph.FieldInternal
149+
| Protected-> Glyph.FieldProtected
150+
| Private-> Glyph.FieldPrivate
151+
|:? FSharpParameter-> Glyph.Parameter
152+
|:? FSharpMemberOrFunctionOrValueas x->
153+
if x.IsExtensionMemberthen
154+
match x.Accessibilitywith
155+
| Public-> Glyph.ExtensionMethodPublic
156+
| Internal-> Glyph.ExtensionMethodInternal
157+
| Protected-> Glyph.ExtensionMethodProtected
158+
| Private-> Glyph.ExtensionMethodPrivate
159+
elif x.IsProperty|| x.IsPropertyGetterMethod|| x.IsPropertySetterMethodthen
160+
match x.Accessibilitywith
161+
| Public-> Glyph.PropertyPublic
162+
| Internal-> Glyph.PropertyInternal
163+
| Protected-> Glyph.PropertyProtected
164+
| Private-> Glyph.PropertyPrivate
165+
elif x.IsEventthen
166+
match x.Accessibilitywith
167+
| Public-> Glyph.EventPublic
168+
| Internal-> Glyph.EventInternal
169+
| Protected-> Glyph.EventProtected
170+
| Private-> Glyph.EventPrivate
171+
else
172+
match x.Accessibilitywith
173+
| Public-> Glyph.MethodPublic
174+
| Internal-> Glyph.MethodInternal
175+
| Protected-> Glyph.MethodProtected
176+
| Private-> Glyph.MethodPrivate
177+
|:? FSharpEntityas x->
178+
if x.IsFSharpModulethen
179+
match x.Accessibilitywith
180+
| Public-> Glyph.ModulePublic
181+
| Internal-> Glyph.ModuleInternal
182+
| Protected-> Glyph.ModuleProtected
183+
| Private-> Glyph.ModulePrivate
184+
elif x.IsEnum|| x.IsFSharpUnionthen
185+
match x.Accessibilitywith
186+
| Public-> Glyph.EnumPublic
187+
| Internal-> Glyph.EnumInternal
188+
| Protected-> Glyph.EnumProtected
189+
| Private-> Glyph.EnumPrivate
190+
elif x.IsInterfacethen
191+
match x.Accessibilitywith
192+
| Public-> Glyph.InterfacePublic
193+
| Internal-> Glyph.InterfaceInternal
194+
| Protected-> Glyph.InterfaceProtected
195+
| Private-> Glyph.InterfacePrivate
196+
else
197+
match x.Accessibilitywith
198+
| Public-> Glyph.ClassPublic
199+
| Internal-> Glyph.ClassInternal
200+
| Protected-> Glyph.ClassProtected
201+
| Private-> Glyph.ClassPrivate
202+
|_-> Glyph.None
203+
130204
[<AutoOpen>]
131205
moduleinternalRoslynExtensions=
132206
typeProjectwith

‎vsintegration/src/FSharp.Editor/QuickInfo/QuickInfoProvider.fs‎

Lines changed: 12 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4,68 +4,33 @@ namespace Microsoft.VisualStudio.FSharp.Editor
44

55
openSystem
66
openSystem.Composition
7-
openSystem.Collections.Concurrent
8-
openSystem.Collections.Generic
9-
openSystem.Collections.Immutable
107
openSystem.Threading
118
openSystem.Threading.Tasks
12-
openSystem.Linq
13-
openSystem.Runtime.CompilerServices
14-
openSystem.Windows
15-
openSystem.Windows.Controls
16-
openSystem.Windows.Media
179

1810
openMicrosoft.CodeAnalysis
19-
openMicrosoft.CodeAnalysis.Completion
2011
openMicrosoft.CodeAnalysis.Classification
2112
openMicrosoft.CodeAnalysis.Editor
2213
openMicrosoft.CodeAnalysis.Editor.Implementation.IntelliSense.QuickInfo
23-
openMicrosoft.CodeAnalysis.Editor.Shared.Utilities
24-
openMicrosoft.CodeAnalysis.Formatting
2514
openMicrosoft.CodeAnalysis.Host.Mef
26-
openMicrosoft.CodeAnalysis.Options
2715
openMicrosoft.CodeAnalysis.Text
2816

2917
openMicrosoft.VisualStudio.FSharp.LanguageService
30-
openMicrosoft.VisualStudio.Text
31-
openMicrosoft.VisualStudio.Text.Classification
32-
openMicrosoft.VisualStudio.Text.Tagging
33-
openMicrosoft.VisualStudio.Text.Formatting
3418
openMicrosoft.VisualStudio.Shell
3519
openMicrosoft.VisualStudio.Shell.Interop
20+
openMicrosoft.VisualStudio.Language.Intellisense
3621

37-
openMicrosoft.FSharp.Compiler
38-
openMicrosoft.FSharp.Compiler.Parser
39-
openMicrosoft.FSharp.Compiler.Range
4022
openMicrosoft.FSharp.Compiler.SourceCodeServices
41-
openSystem.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-
typeinternalFSharpDeferredQuickInfoContent(content: string,textProperties: TextFormattingRunProperties)=
48-
interface IDeferredQuickInfoContentwith
49-
overridethis.Create():FrameworkElement=
50-
lettextBlock= 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)>]
6126
typeinternalFSharpQuickInfoProvider
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

7136
letxmlMemberIndexService= serviceProvider.GetService(typeof<SVsXMLMemberIndexService>):?> IVsXMLMemberIndexService
@@ -76,15 +41,15 @@ type internal FSharpQuickInfoProvider
7641
let!_,checkFileResults= checker.ParseAndCheckDocument(filePath, textVersionHash, sourceText.ToString(), options)
7742
lettextLine= sourceText.Lines.GetLineFromPosition(position)
7843
lettextLineNumber= textLine.LineNumber+1// Roslyn line numbers are zero-based
79-
//let qualifyingNames, partialName = QuickParse.GetPartialLongNameEx(textLine.ToString(), textLineColumn - 1)
8044
letdefines= CompilerEnvironment.GetCompilationDefinesForEditing(filePath, options.OtherOptions|> Seq.toList)
8145
let!symbol= CommonHelpers.getSymbolAtPosition(documentId, sourceText, position, filePath, defines, SymbolLookupKind.Fuzzy)
8246
let!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

9055
interface IQuickInfoProviderwith
@@ -95,7 +60,8 @@ type internal FSharpQuickInfoProvider
9560
let!_= CommonHelpers.getSymbolAtPosition(document.Id, sourceText, position, document.FilePath, defines, SymbolLookupKind.Fuzzy)
9661
let!options= projectInfoManager.TryGetOptionsForEditingDocumentOrProject(document)
9762
let!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())
9965
letmainDescription= Collections.Generic.List()
10066
letdocumentation= Collections.Generic.List()
10167
XmlDocumentation.BuildDataTipText(
@@ -107,7 +73,7 @@ type internal FSharpQuickInfoProvider
10773
letcontent=
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),

‎vsintegration/tests/unittests/QuickInfoProviderTests.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,5 @@ Full name: System.Console"
101101
FSharpQuickInfoProvider.ProvideQuickInfo(FSharpChecker.Instance, documentId, SourceText.From(fileContents), filePath, caretPosition, options,0)
102102
|> Async.RunSynchronously
103103

104-
letactual= quickInfo|> Option.map(fun(text,_)-> getQuickInfoText text)
104+
letactual= quickInfo|> Option.map(fun(text,_,_)-> getQuickInfoText text)
105105
Assert.AreEqual(expected, actual)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp