提交 14223229 编写于 作者: V Vasily Kirichenko 提交者: Kevin Ransom (msft)

Fix go to definition to symbols defined in referenced assemblies and have not...

Fix go to definition to symbols defined in referenced assemblies and have not normalized file paths (#3773)

* fix Solution.TryGetDocumentFromPath for relative paths

* temp logging

* debug

* normalize range.filename in TaskPickle

* remove debug

* Revert "normalize range.filename in TaskPickle"

This reverts commit 31967a5833b566ad3cfb6270d685c0eb012d38f5.

* normalize full paths in mkRange

* remove null check
上级 d2cb4149
......@@ -170,7 +170,11 @@ type range(code:int64) =
override r.Equals(obj) = match obj with :? range as r2 -> code = r2.Code | _ -> false
override r.GetHashCode() = hash code
let mkRange f b e = range (fileIndexOfFile f, b, e)
let mkRange f b e =
// remove relative parts from full path
let normalizedFilePath = if Path.IsPathRooted f then try Path.GetFullPath f with _ -> f else f
range (fileIndexOfFile normalizedFilePath, b, e)
let mkFileIndexRange fi b e = range (fi, b, e)
(* end representation, start derived ops *)
......
......@@ -3,6 +3,7 @@ module internal Microsoft.VisualStudio.FSharp.Editor.CodeAnalysisExtensions
open Microsoft.CodeAnalysis
open Microsoft.FSharp.Compiler.Range
open System.IO
type Project with
......@@ -41,7 +42,9 @@ type Solution with
/// Try to find the documentId corresponding to the provided filepath within this solution
member self.TryGetDocumentFromPath filePath =
self.GetDocumentIdsWithFilePath filePath
// It's crucial to normalize file path here (specificaly, remove relative parts),
// otherwise Roslyn does not find documents.
self.GetDocumentIdsWithFilePath (Path.GetFullPath filePath)
|> Seq.tryHead |> Option.map (fun docId -> self.GetDocument docId)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册