Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
vzarytovskii committed Apr 15, 2024
1 parent 8e5813c commit 9264c4a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
33 changes: 27 additions & 6 deletions vsintegration/src/FSharp.Editor/Navigation/GoToDefinition.fs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ open System.Text.RegularExpressions
open CancellableTasks
open Microsoft.VisualStudio.FSharp.Editor.Telemetry
open Microsoft.VisualStudio.Telemetry
open System.Collections.Generic
open Microsoft.VisualStudio.Threading

module private Symbol =
let fullName (root: ISymbol) : string =
Expand Down Expand Up @@ -565,6 +565,18 @@ type internal GoToDefinition(metadataAsSource: FSharpMetadataAsSourceService) =
return this.NavigateToItem(item, cancellationToken)
}

member this.NavigateToExternalDeclarationAsync
(
targetSymbolUse: FSharpSymbolUse,
metadataReferences: seq<MetadataReference>
) =
foregroundCancellableTask
{
let! cancellationToken = CancellableTask.getCancellationToken()
do! ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken)
return this.NavigateToExternalDeclaration(targetSymbolUse, metadataReferences, cancellationToken)
}

member this.NavigateToExternalDeclaration
(
targetSymbolUse: FSharpSymbolUse,
Expand Down Expand Up @@ -600,9 +612,9 @@ type internal GoToDefinition(metadataAsSource: FSharpMetadataAsSourceService) =
fileName,
metadataReferences
)

let tmpShownDocOpt =
metadataAsSource.ShowDocument(tmpProjInfo, tmpDocInfo.FilePath, SourceText.From(text.ToString()))


match tmpShownDocOpt with
| ValueSome tmpShownDoc ->
Expand Down Expand Up @@ -706,10 +718,19 @@ type internal FSharpNavigation(metadataAsSource: FSharpMetadataAsSourceService,
let gtd = GoToDefinition(metadataAsSource)
let! result = gtd.FindDefinitionAtPosition(initialDoc, position)

return
match result with
| ValueSome(FSharpGoToDefinitionResult.NavigableItem(navItem), _) -> ImmutableArray.create navItem
| _ -> ImmutableArray.empty

match result with
| ValueSome(FSharpGoToDefinitionResult.NavigableItem(navItem), _) ->
return ImmutableArray.create navItem
| ValueSome(FSharpGoToDefinitionResult.ExternalAssembly(targetSymbolUse, metadataReferences), _) ->
let! res = gtd.NavigateToExternalDeclarationAsync(targetSymbolUse, metadataReferences)
if not res then
return ImmutableArray.empty
else
// TODO: return something? Maybe cancelled task?
return ImmutableArray.empty
| _ ->
return ImmutableArray.empty
}

member _.TryGoToDefinition(position, cancellationToken) =
Expand Down
2 changes: 1 addition & 1 deletion vsintegration/src/FSharp.Editor/Options/EditorOptions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ type EditorOptions() =
member _.Formatting: FormattingOptions = store.Get()

[<Export(typeof<SettingsStore.ISettingsStore>)>]
member private _.SettingsStore = store
member _.SettingsStore = store

member _.With value = store.Register value

Expand Down

0 comments on commit 9264c4a

Please sign in to comment.