-
Notifications
You must be signed in to change notification settings - Fork 790
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Quickinfo Tooltip and GotoDefinition Navigation Improvements (#2683)
* full type name in tooltip, provisional tab preferred * more entities made navigable * use IGoToDefinition service * this is used only here * MEF import FSharpGotoDefinitionService into QuickInfoProvider * speed up gotoDefinition * additional GotoDefn navigation strategies * quickinfo navigation stays in its lane tooltip from .fsi links to .fsi tooltip from .fs links to .fs quick navigation if no redirect is necessary * fix unittests * restore recursive matchingDoc * asynchronous navigation from tooltips * fix cross project .fs -> .fs and .fsi -> .fsi Navigation * cleanup and extra documentation fixed bug in cross project .fs -> .fs navigation * missed this one * gotodefinition sig <-> impl at declaration location * fix async workflow * animate status bar search and timeout on msgs * Better links styling * integrate sig doccoms * fix error introduced by prior merge * fixed invalid type access in `getUnusedOpens` * fix invalid span bug in `symbolIsFullyQualified` * check if normalized doccom text matches * cleanup status bar usage * fix underline pen position, code cleanup and formatting * do not show links for symbol itself
- Loading branch information
1 parent
dd53a3d
commit 7360d04
Showing
16 changed files
with
899 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
vsintegration/src/FSharp.Editor/Common/CodeAnalysisExtensions.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
[<AutoOpen>] | ||
module internal Microsoft.VisualStudio.FSharp.Editor.CodeAnalysisExtensions | ||
|
||
open Microsoft.CodeAnalysis | ||
open Microsoft.FSharp.Compiler.Range | ||
|
||
type Project with | ||
|
||
/// Returns the projectIds of all projects within the same solution that directly reference this project | ||
member this.GetDependentProjectIds () = | ||
this.Solution.GetProjectDependencyGraph().GetProjectsThatDirectlyDependOnThisProject this.Id | ||
|
||
|
||
/// Returns all projects within the same solution that directly reference this project. | ||
member this.GetDependentProjects () = | ||
this.Solution.GetProjectDependencyGraph().GetProjectsThatDirectlyDependOnThisProject this.Id | ||
|> Seq.map this.Solution.GetProject | ||
|
||
|
||
/// Returns the ProjectIds of all of the projects that this project directly or transitively depneds on | ||
member this.GetProjectIdsOfAllProjectsThisProjectDependsOn () = | ||
let graph = this.Solution.GetProjectDependencyGraph() | ||
let transitiveDependencies = graph.GetProjectsThatThisProjectTransitivelyDependsOn this.Id | ||
let directDependencies = graph.GetProjectsThatThisProjectDirectlyDependsOn this.Id | ||
Seq.append directDependencies transitiveDependencies | ||
|
||
|
||
/// The list all of the projects that this project directly or transitively depneds on | ||
member this.GetAllProjectsThisProjectDependsOn () = | ||
this.GetProjectIdsOfAllProjectsThisProjectDependsOn () | ||
|> Seq.map this.Solution.GetProject | ||
|
||
|
||
type Solution with | ||
|
||
/// Try to get a document inside the solution using the document's name | ||
member self.TryGetDocumentNamed docName = | ||
self.Projects |> Seq.tryPick (fun proj -> | ||
proj.Documents |> Seq.tryFind (fun doc -> doc.Name = docName)) | ||
|
||
|
||
/// Try to find the documentId corresponding to the provided filepath within this solution | ||
member self.TryGetDocumentFromPath filePath = | ||
self.GetDocumentIdsWithFilePath filePath | ||
|> Seq.tryHead |> Option.map (fun docId -> self.GetDocument docId) | ||
|
||
|
||
/// Try to get a project inside the solution using the project's id | ||
member self.TryGetProject (projId:ProjectId) = | ||
if self.ContainsProject projId then Some (self.GetProject projId) else None | ||
|
||
|
||
/// Returns the projectIds of all projects within this solution that directly reference the provided project | ||
member self.GetDependentProjects (projectId:ProjectId) = | ||
self.GetProjectDependencyGraph().GetProjectsThatDirectlyDependOnThisProject projectId | ||
|> Seq.map self.GetProject | ||
|
||
|
||
/// Returns the projectIds of all projects within this solution that directly reference the provided project | ||
member self.GetDependentProjectIds (projectId:ProjectId) = | ||
self.GetProjectDependencyGraph().GetProjectsThatDirectlyDependOnThisProject projectId | ||
|
||
|
||
/// Returns the ProjectIds of all of the projects that directly or transitively depends on | ||
member self.GetProjectIdsOfAllProjectReferences (projectId:ProjectId) = | ||
let graph = self.GetProjectDependencyGraph() | ||
let transitiveDependencies = graph.GetProjectsThatThisProjectTransitivelyDependsOn projectId | ||
let directDependencies = graph.GetProjectsThatThisProjectDirectlyDependsOn projectId | ||
Seq.append directDependencies transitiveDependencies | ||
|
||
|
||
/// Returns all of the projects that this project that directly or transitively depends on | ||
member self.GetAllProjectsThisProjectDependsOn (projectId:ProjectId) = | ||
self.GetProjectIdsOfAllProjectReferences projectId | ||
|> Seq.map self.GetProject | ||
|
||
|
||
/// Try to retrieve the corresponding DocumentId for the range's file in the solution | ||
/// and if a projectId is provided, only try to find the document within that project | ||
/// or a project referenced by that project | ||
member self.TryGetDocumentIdFromFSharpRange (range:range,?projectId:ProjectId) = | ||
|
||
let filePath = System.IO.Path.GetFullPathSafe range.FileName | ||
let checkProjectId (docId:DocumentId) = | ||
if projectId.IsSome then docId.ProjectId = projectId.Value else false | ||
//The same file may be present in many projects. We choose one from current or referenced project. | ||
let rec matchingDoc = function | ||
| [] -> None | ||
| (docId:DocumentId)::_ when checkProjectId docId -> Some docId | ||
| docId::tail -> | ||
match projectId with | ||
| Some projectId -> | ||
if self.GetDependentProjectIds docId.ProjectId |> Seq.contains projectId | ||
then Some docId | ||
else matchingDoc tail | ||
| None -> Some docId | ||
|
||
self.GetDocumentIdsWithFilePath filePath |> List.ofSeq |> matchingDoc | ||
|
||
|
||
/// Try to retrieve the corresponding Document for the range's file in the solution | ||
/// and if a projectId is provided, only try to find the document within that project | ||
/// or a project referenced by that project | ||
member self.TryGetDocumentFromFSharpRange (range:range,?projectId:ProjectId) = | ||
match projectId with | ||
| Some projectId -> self.TryGetDocumentIdFromFSharpRange (range, projectId) | ||
| None -> self.TryGetDocumentIdFromFSharpRange range | ||
|> Option.map self.GetDocument |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.