Skip to content

Commit 82919f0

Browse files
committed
reduce diff
1 parent 8d16f48 commit 82919f0

File tree

8 files changed

+223
-234
lines changed

8 files changed

+223
-234
lines changed

tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.release.bsl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3970,7 +3970,7 @@ FSharp.Compiler.EditorServices.ToolTipElement: Boolean get_IsNone()
39703970
FSharp.Compiler.EditorServices.ToolTipElement: FSharp.Compiler.EditorServices.ToolTipElement NewCompositionError(System.String)
39713971
FSharp.Compiler.EditorServices.ToolTipElement: FSharp.Compiler.EditorServices.ToolTipElement NewGroup(Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.EditorServices.ToolTipElementData])
39723972
FSharp.Compiler.EditorServices.ToolTipElement: FSharp.Compiler.EditorServices.ToolTipElement None
3973-
FSharp.Compiler.EditorServices.ToolTipElement: FSharp.Compiler.EditorServices.ToolTipElement Single(FSharp.Compiler.Text.TaggedText[], FSharp.Compiler.Symbols.FSharpXmlDoc, Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.TaggedText[]]], Microsoft.FSharp.Core.FSharpOption`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.TaggedText[]])
3973+
FSharp.Compiler.EditorServices.ToolTipElement: FSharp.Compiler.EditorServices.ToolTipElement Single(FSharp.Compiler.Text.TaggedText[], FSharp.Compiler.Symbols.FSharpXmlDoc, Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.TaggedText[]]], Microsoft.FSharp.Core.FSharpOption`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.TaggedText[]], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Symbols.FSharpSymbol])
39743974
FSharp.Compiler.EditorServices.ToolTipElement: FSharp.Compiler.EditorServices.ToolTipElement get_None()
39753975
FSharp.Compiler.EditorServices.ToolTipElement: FSharp.Compiler.EditorServices.ToolTipElement+CompositionError
39763976
FSharp.Compiler.EditorServices.ToolTipElement: FSharp.Compiler.EditorServices.ToolTipElement+Group
@@ -3991,12 +3991,14 @@ FSharp.Compiler.EditorServices.ToolTipElementData: Int32 GetHashCode()
39913991
FSharp.Compiler.EditorServices.ToolTipElementData: Int32 GetHashCode(System.Collections.IEqualityComparer)
39923992
FSharp.Compiler.EditorServices.ToolTipElementData: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.TaggedText[]] TypeMapping
39933993
FSharp.Compiler.EditorServices.ToolTipElementData: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.TaggedText[]] get_TypeMapping()
3994+
FSharp.Compiler.EditorServices.ToolTipElementData: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Symbols.FSharpSymbol] Symbol
3995+
FSharp.Compiler.EditorServices.ToolTipElementData: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Symbols.FSharpSymbol] get_Symbol()
39943996
FSharp.Compiler.EditorServices.ToolTipElementData: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.TaggedText[]] Remarks
39953997
FSharp.Compiler.EditorServices.ToolTipElementData: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.TaggedText[]] get_Remarks()
39963998
FSharp.Compiler.EditorServices.ToolTipElementData: Microsoft.FSharp.Core.FSharpOption`1[System.String] ParamName
39973999
FSharp.Compiler.EditorServices.ToolTipElementData: Microsoft.FSharp.Core.FSharpOption`1[System.String] get_ParamName()
39984000
FSharp.Compiler.EditorServices.ToolTipElementData: System.String ToString()
3999-
FSharp.Compiler.EditorServices.ToolTipElementData: Void .ctor(FSharp.Compiler.Text.TaggedText[], FSharp.Compiler.Symbols.FSharpXmlDoc, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.TaggedText[]], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.TaggedText[]], Microsoft.FSharp.Core.FSharpOption`1[System.String])
4001+
FSharp.Compiler.EditorServices.ToolTipElementData: Void .ctor(Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Symbols.FSharpSymbol], FSharp.Compiler.Text.TaggedText[], FSharp.Compiler.Symbols.FSharpXmlDoc, Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.TaggedText[]], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.TaggedText[]], Microsoft.FSharp.Core.FSharpOption`1[System.String])
40004002
FSharp.Compiler.EditorServices.ToolTipText: Boolean Equals(FSharp.Compiler.EditorServices.ToolTipText)
40014003
FSharp.Compiler.EditorServices.ToolTipText: Boolean Equals(System.Object)
40024004
FSharp.Compiler.EditorServices.ToolTipText: Boolean Equals(System.Object, System.Collections.IEqualityComparer)

vsintegration/src/FSharp.Editor/Navigation/FindDefinitionService.fs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,15 @@ open FSharp.Compiler.Text.Range
1010
open Microsoft.CodeAnalysis
1111
open Microsoft.CodeAnalysis.ExternalAccess.FSharp.GoToDefinition
1212

13-
open Microsoft.VisualStudio.Shell
14-
open Microsoft.VisualStudio.Shell.Interop
1513
open System.Collections.Immutable
1614
open System.Threading.Tasks
1715

1816
[<Export(typeof<IFSharpFindDefinitionService>)>]
1917
[<Export(typeof<FSharpFindDefinitionService>)>]
2018
type internal FSharpFindDefinitionService [<ImportingConstructor>] (metadataAsSource: FSharpMetadataAsSourceService) =
21-
22-
let statusBar =
23-
StatusBar(ServiceProvider.GlobalProvider.GetService<SVsStatusbar, IVsStatusbar>())
24-
2519
interface IFSharpFindDefinitionService with
2620
member _.FindDefinitionsAsync(document: Document, position: int, cancellationToken: CancellationToken) =
27-
let navigation =
28-
FSharpNavigation(statusBar, metadataAsSource, document, rangeStartup)
21+
let navigation = FSharpNavigation(metadataAsSource, document, rangeStartup)
2922

3023
let definitions = navigation.FindDefinitions(position, cancellationToken)
3124
ImmutableArray.CreateRange(definitions) |> Task.FromResult

vsintegration/src/FSharp.Editor/Navigation/GoToDefinition.fs

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ module private ExternalSymbol =
109109
| _ -> []
110110

111111
// TODO: Uncomment code when VS has a fix for updating the status bar.
112-
type StatusBar(statusBar: IVsStatusbar) =
112+
type StatusBar() =
113+
let statusBar =
114+
ServiceProvider.GlobalProvider.GetService<SVsStatusbar, IVsStatusbar>()
115+
113116
let mutable _searchIcon =
114117
int16 Microsoft.VisualStudio.Shell.Interop.Constants.SBAI_Find :> obj
115118

@@ -394,7 +397,6 @@ type internal GoToDefinition(metadataAsSource: FSharpMetadataAsSourceService) =
394397
(
395398
document: Document,
396399
textSpan: Microsoft.CodeAnalysis.Text.TextSpan,
397-
statusBar: StatusBar,
398400
cancellationToken: CancellationToken
399401
) =
400402
let navigableItem = FSharpGoToDefinitionNavigableItem(document, textSpan)
@@ -407,9 +409,10 @@ type internal GoToDefinition(metadataAsSource: FSharpMetadataAsSourceService) =
407409
navigationService.TryNavigateToSpan(workspace, navigableItem.Document.Id, navigableItem.SourceSpan, cancellationToken)
408410

409411
if not navigationSucceeded then
410-
statusBar.TempMessage(SR.CannotNavigateUnknown())
412+
StatusBar().TempMessage(SR.CannotNavigateUnknown())
411413

412-
member _.NavigateToItem(navigableItem: FSharpNavigableItem, statusBar: StatusBar, cancellationToken: CancellationToken) =
414+
member _.NavigateToItem(navigableItem: FSharpNavigableItem, cancellationToken: CancellationToken) =
415+
let statusBar = StatusBar()
413416
use __ = statusBar.Animate()
414417

415418
statusBar.Message(SR.NavigatingTo())
@@ -434,12 +437,11 @@ type internal GoToDefinition(metadataAsSource: FSharpMetadataAsSourceService) =
434437
targetDocument: Document,
435438
targetSourceText: SourceText,
436439
symbolRange: range,
437-
statusBar: StatusBar,
438440
cancellationToken: CancellationToken
439441
) =
440442
asyncMaybe {
441443
let! item = this.FindDeclarationOfSymbolAtRange(targetDocument, symbolRange, targetSourceText)
442-
return this.NavigateToItem(item, statusBar, cancellationToken)
444+
return this.NavigateToItem(item, cancellationToken)
443445
}
444446

445447
/// Find the definition location (implementation file/.fs) of the target symbol
@@ -448,12 +450,11 @@ type internal GoToDefinition(metadataAsSource: FSharpMetadataAsSourceService) =
448450
targetDocument: Document,
449451
targetSourceText: SourceText,
450452
symbolRange: range,
451-
statusBar: StatusBar,
452453
cancellationToken: CancellationToken
453454
) =
454455
asyncMaybe {
455456
let! item = this.FindDefinitionOfSymbolAtRange(targetDocument, symbolRange, targetSourceText)
456-
return this.NavigateToItem(item, statusBar, cancellationToken)
457+
return this.NavigateToItem(item, cancellationToken)
457458
}
458459

459460
member this.NavigateToExternalDeclaration
@@ -546,7 +547,7 @@ type internal GoToDefinition(metadataAsSource: FSharpMetadataAsSourceService) =
546547
| _ -> TextSpan()
547548

548549
let navItem = FSharpGoToDefinitionNavigableItem(tmpShownDoc, span)
549-
this.NavigateToItem(navItem, statusBar, cancellationToken)
550+
this.NavigateToItem(navItem, cancellationToken)
550551
true
551552
| _ -> false
552553
| _ -> false
@@ -556,13 +557,7 @@ type internal GoToDefinition(metadataAsSource: FSharpMetadataAsSourceService) =
556557
else
557558
statusBar.TempMessage(SR.CannotNavigateUnknown())
558559

559-
type internal FSharpNavigation
560-
(
561-
statusBar: StatusBar,
562-
metadataAsSource: FSharpMetadataAsSourceService,
563-
initialDoc: Document,
564-
thisSymbolUseRange: range
565-
) =
560+
type internal FSharpNavigation(metadataAsSource: FSharpMetadataAsSourceService, initialDoc: Document, thisSymbolUseRange: range) =
566561

567562
let workspace = initialDoc.Project.Solution.Workspace
568563
let solution = workspace.CurrentSolution
@@ -603,15 +598,13 @@ type internal FSharpNavigation
603598

604599
match initialDoc.FilePath, targetPath with
605600
| Signature, Signature
606-
| Implementation, Implementation -> return gtd.TryNavigateToTextSpan(targetDoc, targetTextSpan, statusBar, cancellationToken)
601+
| Implementation, Implementation -> return gtd.TryNavigateToTextSpan(targetDoc, targetTextSpan, cancellationToken)
607602

608603
// Adjust the target from signature to implementation.
609-
| Implementation, Signature ->
610-
return! gtd.NavigateToSymbolDefinitionAsync(targetDoc, targetSource, range, statusBar, cancellationToken)
604+
| Implementation, Signature -> return! gtd.NavigateToSymbolDefinitionAsync(targetDoc, targetSource, range, cancellationToken)
611605

612606
// Adjust the target from implmentation to signature.
613-
| Signature, Implementation ->
614-
return! gtd.NavigateToSymbolDeclarationAsync(targetDoc, targetSource, range, statusBar, cancellationToken)
607+
| Signature, Implementation -> return! gtd.NavigateToSymbolDeclarationAsync(targetDoc, targetSource, range, cancellationToken)
615608
}
616609
|> Async.Ignore
617610
|> Async.StartImmediate
@@ -630,6 +623,7 @@ type internal FSharpNavigation
630623

631624
member _.TryGoToDefinition(position, cancellationToken) =
632625
let gtd = GoToDefinition(metadataAsSource)
626+
let statusBar = StatusBar()
633627
let gtdTask = gtd.FindDefinitionTask(initialDoc, position, cancellationToken)
634628

635629
// Wrap this in a try/with as if the user clicks "Cancel" on the thread dialog, we'll be cancelled.
@@ -641,7 +635,7 @@ type internal FSharpNavigation
641635
if gtdTask.Status = TaskStatus.RanToCompletion && gtdTask.Result.IsSome then
642636
match gtdTask.Result.Value with
643637
| FSharpGoToDefinitionResult.NavigableItem (navItem), _ ->
644-
gtd.NavigateToItem(navItem, statusBar, cancellationToken)
638+
gtd.NavigateToItem(navItem, cancellationToken)
645639
// 'true' means do it, like Sheev Palpatine would want us to.
646640
true
647641
| FSharpGoToDefinitionResult.ExternalAssembly (targetSymbolUse, metadataReferences), _ ->
@@ -688,7 +682,7 @@ type internal DocCommentId =
688682
| Type of EntityPath: string list
689683
| None
690684

691-
type FSharpNavigableLocation(statusBar: StatusBar, metadataAsSource: FSharpMetadataAsSourceService, symbolRange: range, project: Project) =
685+
type FSharpNavigableLocation(metadataAsSource: FSharpMetadataAsSourceService, symbolRange: range, project: Project) =
692686
interface IFSharpNavigableLocation with
693687
member _.NavigateToAsync(_options: FSharpNavigationOptions2, cancellationToken: CancellationToken) : Task<bool> =
694688
asyncMaybe {
@@ -704,10 +698,8 @@ type FSharpNavigableLocation(statusBar: StatusBar, metadataAsSource: FSharpMetad
704698
Implementation
705699

706700
match targetPath with
707-
| Signature ->
708-
return! gtd.NavigateToSymbolDefinitionAsync(targetDoc, targetSource, symbolRange, statusBar, cancellationToken)
709-
| Implementation ->
710-
return! gtd.NavigateToSymbolDeclarationAsync(targetDoc, targetSource, symbolRange, statusBar, cancellationToken)
701+
| Signature -> return! gtd.NavigateToSymbolDefinitionAsync(targetDoc, targetSource, symbolRange, cancellationToken)
702+
| Implementation -> return! gtd.NavigateToSymbolDeclarationAsync(targetDoc, targetSource, symbolRange, cancellationToken)
711703
}
712704
|> Async.map (fun a -> a.IsSome)
713705
|> RoslynHelpers.StartAsyncAsTask cancellationToken
@@ -720,9 +712,6 @@ type FSharpCrossLanguageSymbolNavigationService() =
720712

721713
let workspace = componentModel.GetService<VisualStudioWorkspace>()
722714

723-
let statusBar =
724-
StatusBar(ServiceProvider.GlobalProvider.GetService<SVsStatusbar, IVsStatusbar>())
725-
726715
let metadataAsSource =
727716
componentModel
728717
.DefaultExportProvider
@@ -953,7 +942,7 @@ type FSharpCrossLanguageSymbolNavigationService() =
953942
// More results can theoretically be returned in case of method overloads, or when we have both signature and implementation files.
954943
if locations.Count() >= 1 then
955944
let (location, project) = locations.First()
956-
return FSharpNavigableLocation(statusBar, metadataAsSource, location, project) :> IFSharpNavigableLocation
945+
return FSharpNavigableLocation(metadataAsSource, location, project) :> IFSharpNavigableLocation
957946
else
958947
return Unchecked.defaultof<_> // returning null here, so Roslyn can fallback to default source-as-metadata implementation.
959948
}

vsintegration/src/FSharp.Editor/Navigation/GoToDefinitionService.fs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Microsoft.VisualStudio.FSharp.Editor
44

5-
open System
65
open System.Composition
76
open System.Threading
87
open System.Threading.Tasks
@@ -12,31 +11,24 @@ open FSharp.Compiler.Text.Range
1211
open Microsoft.CodeAnalysis
1312
open Microsoft.CodeAnalysis.ExternalAccess.FSharp.Editor
1413

15-
open Microsoft.VisualStudio.Shell
16-
open Microsoft.VisualStudio.Shell.Interop
17-
1814
[<Export(typeof<IFSharpGoToDefinitionService>)>]
1915
[<Export(typeof<FSharpGoToDefinitionService>)>]
2016
type internal FSharpGoToDefinitionService [<ImportingConstructor>] (metadataAsSource: FSharpMetadataAsSourceService) =
2117

22-
let statusBar =
23-
StatusBar(ServiceProvider.GlobalProvider.GetService<SVsStatusbar, IVsStatusbar>())
24-
2518
interface IFSharpGoToDefinitionService with
2619
/// Invoked with Peek Definition.
2720
member _.FindDefinitionsAsync(document: Document, position: int, cancellationToken: CancellationToken) =
28-
let navigation =
29-
FSharpNavigation(statusBar, metadataAsSource, document, rangeStartup)
21+
let navigation = FSharpNavigation(metadataAsSource, document, rangeStartup)
3022

3123
navigation.FindDefinitions(position, cancellationToken) |> Task.FromResult
3224

3325
/// Invoked with Go to Definition.
3426
/// Try to navigate to the definiton of the symbol at the symbolRange in the originDocument
3527
member _.TryGoToDefinition(document: Document, position: int, cancellationToken: CancellationToken) =
28+
let statusBar = StatusBar()
3629
statusBar.Message(SR.LocatingSymbol())
3730
use __ = statusBar.Animate()
3831

39-
let navigation =
40-
FSharpNavigation(statusBar, metadataAsSource, document, rangeStartup)
32+
let navigation = FSharpNavigation(metadataAsSource, document, rangeStartup)
4133

4234
navigation.TryGoToDefinition(position, cancellationToken)

vsintegration/src/FSharp.Editor/Navigation/NavigableSymbolsService.fs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,28 @@ open System.Threading.Tasks
88
open System.ComponentModel.Composition
99

1010
open Microsoft.CodeAnalysis.Text
11-
open Microsoft.CodeAnalysis.Navigation
1211
open Microsoft.CodeAnalysis.ExternalAccess.FSharp.Navigation
1312

1413
open Microsoft.VisualStudio.Language.Intellisense
1514
open Microsoft.VisualStudio.Text
1615
open Microsoft.VisualStudio.Text.Editor
17-
open Microsoft.VisualStudio.Shell.Interop
1816
open Microsoft.VisualStudio.Utilities
19-
open Microsoft.VisualStudio.Shell
2017

2118
[<AllowNullLiteral>]
22-
type internal FSharpNavigableSymbol(item: FSharpNavigableItem, span: SnapshotSpan, gtd: GoToDefinition, statusBar: StatusBar) =
19+
type internal FSharpNavigableSymbol(item: FSharpNavigableItem, span: SnapshotSpan, gtd: GoToDefinition) =
2320
interface INavigableSymbol with
2421
member _.Navigate(_: INavigableRelationship) =
25-
gtd.NavigateToItem(item, statusBar, CancellationToken.None)
22+
gtd.NavigateToItem(item, CancellationToken.None)
2623

2724
member _.Relationships = seq { yield PredefinedNavigableRelationships.Definition }
2825

2926
member _.SymbolSpan = span
3027

31-
type internal FSharpNavigableSymbolSource(metadataAsSource, serviceProvider: IServiceProvider) =
28+
type internal FSharpNavigableSymbolSource(metadataAsSource) =
3229

3330
let mutable disposed = false
3431
let gtd = GoToDefinition(metadataAsSource)
35-
let statusBar = StatusBar(serviceProvider.GetService<SVsStatusbar, IVsStatusbar>())
32+
let statusBar = StatusBar()
3633

3734
interface INavigableSymbolSource with
3835
member _.GetNavigableSymbolAsync(triggerSpan: SnapshotSpan, cancellationToken: CancellationToken) =
@@ -67,7 +64,7 @@ type internal FSharpNavigableSymbolSource(metadataAsSource, serviceProvider: ISe
6764

6865
match result with
6966
| FSharpGoToDefinitionResult.NavigableItem (navItem) ->
70-
return FSharpNavigableSymbol(navItem, symbolSpan, gtd, statusBar) :> INavigableSymbol
67+
return FSharpNavigableSymbol(navItem, symbolSpan, gtd) :> INavigableSymbol
7168

7269
| FSharpGoToDefinitionResult.ExternalAssembly (targetSymbolUse, metadataReferences) ->
7370
let nav =
@@ -105,12 +102,8 @@ type internal FSharpNavigableSymbolSource(metadataAsSource, serviceProvider: ISe
105102
[<Name("F# Navigable Symbol Service")>]
106103
[<ContentType(Constants.FSharpContentType)>]
107104
[<Order>]
108-
type internal FSharpNavigableSymbolService [<ImportingConstructor>]
109-
(
110-
[<Import(typeof<SVsServiceProvider>)>] serviceProvider: IServiceProvider,
111-
metadataAsSource: FSharpMetadataAsSourceService
112-
) =
105+
type internal FSharpNavigableSymbolService [<ImportingConstructor>] (metadataAsSource: FSharpMetadataAsSourceService) =
113106

114107
interface INavigableSymbolSourceProvider with
115108
member _.TryCreateNavigableSymbolSource(_: ITextView, _: ITextBuffer) =
116-
new FSharpNavigableSymbolSource(metadataAsSource, serviceProvider) :> INavigableSymbolSource
109+
new FSharpNavigableSymbolSource(metadataAsSource)

0 commit comments

Comments
 (0)