Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

Commit d757a76

Browse files
authored
Better handling of external symbols. Formatting module or namespace entities. (dotnet#11350)
1 parent 6b45dc5 commit d757a76

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

Common/CodeAnalysisExtensions.fs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ type Project with
3030

3131
type Solution with
3232

33+
/// Checks if the file path is associated with a document in the solution.
34+
member self.ContainsDocumentWithFilePath filePath =
35+
self.GetDocumentIdsWithFilePath(filePath).IsEmpty
36+
|> not
37+
3338
/// Try to get a document inside the solution using the document's name
3439
member self.TryGetDocumentNamed docName =
3540
self.Projects |> Seq.tryPick (fun proj ->

Navigation/GoToDefinition.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,8 @@ type internal GoToDefinition(checker: FSharpChecker, projectInfoManager: FSharpP
276276
return (FSharpGoToDefinitionResult.ExternalAssembly(targetSymbolUse, metadataReferences), idRange)
277277

278278
| FindDeclResult.DeclFound targetRange ->
279-
// If the file does not actually exist, it's external considered external.
280-
if not (File.Exists targetRange.FileName) then
279+
// If the file is not associated with a document, it's considered external.
280+
if not (originDocument.Project.Solution.ContainsDocumentWithFilePath(targetRange.FileName)) then
281281
let metadataReferences = originDocument.Project.MetadataReferences
282282
return (FSharpGoToDefinitionResult.ExternalAssembly(targetSymbolUse, metadataReferences), idRange)
283283
else

0 commit comments

Comments
 (0)