@@ -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 }
0 commit comments