Skip to content

Commit fb51c25

Browse files
authored
Fix IFSharpFindDefinitionService MEF export (#14647)
Fixes #14053
1 parent 5061f4d commit fb51c25

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
<Compile Include="Navigation\NavigationBarItemService.fs" />
8787
<Compile Include="Navigation\NavigateToSearchService.fs" />
8888
<Compile Include="Navigation\FindUsagesService.fs" />
89+
<Compile Include="Navigation\FindDefinitionService.fs" />
8990
<Compile Include="QuickInfo\NavigableTextRun.fs" />
9091
<Compile Include="QuickInfo\WpfNagivableTextRunViewElementFactory.fs" />
9192
<Compile Include="QuickInfo\Views.fs" />
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
2+
3+
namespace Microsoft.VisualStudio.FSharp.Editor
4+
5+
open System.Composition
6+
open System.Threading
7+
8+
open FSharp.Compiler.Text.Range
9+
10+
open Microsoft.CodeAnalysis
11+
open Microsoft.CodeAnalysis.ExternalAccess.FSharp.GoToDefinition
12+
13+
open Microsoft.VisualStudio.Shell
14+
open Microsoft.VisualStudio.Shell.Interop
15+
open System.Collections.Immutable
16+
open System.Threading.Tasks
17+
18+
[<Export(typeof<IFSharpFindDefinitionService>)>]
19+
[<Export(typeof<FSharpFindDefinitionService>)>]
20+
type internal FSharpFindDefinitionService
21+
[<ImportingConstructor>]
22+
(metadataAsSource: FSharpMetadataAsSourceService) =
23+
24+
let statusBar = StatusBar(ServiceProvider.GlobalProvider.GetService<SVsStatusbar,IVsStatusbar>())
25+
26+
interface IFSharpFindDefinitionService with
27+
member _.FindDefinitionsAsync (document: Document, position: int, cancellationToken: CancellationToken) =
28+
let navigation = FSharpNavigation(statusBar, metadataAsSource, document, rangeStartup)
29+
let definitions = navigation.FindDefinitions(position, cancellationToken)
30+
ImmutableArray.CreateRange(definitions) |> Task.FromResult

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,6 @@ type internal FSharpNavigation
699699
| FSharpGoToDefinitionResult.NavigableItem(navItem) -> Some navItem
700700
| _ -> None
701701
)
702-
|> Task.FromResult
703702

704703
member _.TryGoToDefinition(position, cancellationToken) =
705704
let gtd = GoToDefinition(metadataAsSource)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type internal FSharpGoToDefinitionService
2929
/// Invoked with Peek Definition.
3030
member _.FindDefinitionsAsync (document: Document, position: int, cancellationToken: CancellationToken) =
3131
let navigation = FSharpNavigation(statusBar, metadataAsSource, document, rangeStartup)
32-
navigation.FindDefinitions(position, cancellationToken)
32+
navigation.FindDefinitions(position, cancellationToken) |> Task.FromResult
3333

3434
/// Invoked with Go to Definition.
3535
/// Try to navigate to the definiton of the symbol at the symbolRange in the originDocument

0 commit comments

Comments
 (0)