Skip to content

Commit 0fb3112

Browse files
authored
Merge branch 'feature/lsp' into merge/main-to-feature/lsp
2 parents 9b4a7ce + 965606d commit 0fb3112

File tree

41 files changed

+2092
-124
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2092
-124
lines changed

VSFSharpExtension.sln

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31903.59
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{B4A1E626-4A48-4977-B291-219882DB3413}"
7+
EndProject
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FSharp.VisualStudio.Extension", "src\FSharp.VisualStudio.Extension\FSharp.VisualStudio.Extension.csproj", "{14B9AB0E-2FC0-43F1-9775-20C262202D12}"
9+
EndProject
10+
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Compiler.LanguageServer", "src\FSharp.Compiler.LanguageServer\FSharp.Compiler.LanguageServer.fsproj", "{7EDDFB35-2428-4433-8ABF-47233480B746}"
11+
EndProject
12+
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Compiler.Service", "src\Compiler\FSharp.Compiler.Service.fsproj", "{0B24DCA6-902F-409E-A18C-7B1BFDDC8849}"
13+
EndProject
14+
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Core", "src\FSharp.Core\FSharp.Core.fsproj", "{5A4B66D5-A6C3-402C-A010-7A3635098DA7}"
15+
EndProject
16+
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.DependencyManager.Nuget", "src\FSharp.DependencyManager.Nuget\FSharp.DependencyManager.Nuget.fsproj", "{860808CF-D092-4511-B011-6205B654031D}"
17+
EndProject
18+
Global
19+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
20+
Debug|Any CPU = Debug|Any CPU
21+
Proto|Any CPU = Proto|Any CPU
22+
Release|Any CPU = Release|Any CPU
23+
EndGlobalSection
24+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
25+
{14B9AB0E-2FC0-43F1-9775-20C262202D12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
26+
{14B9AB0E-2FC0-43F1-9775-20C262202D12}.Debug|Any CPU.Build.0 = Debug|Any CPU
27+
{14B9AB0E-2FC0-43F1-9775-20C262202D12}.Proto|Any CPU.ActiveCfg = Release|Any CPU
28+
{14B9AB0E-2FC0-43F1-9775-20C262202D12}.Proto|Any CPU.Build.0 = Release|Any CPU
29+
{14B9AB0E-2FC0-43F1-9775-20C262202D12}.Proto|Any CPU.Deploy.0 = Release|Any CPU
30+
{14B9AB0E-2FC0-43F1-9775-20C262202D12}.Release|Any CPU.ActiveCfg = Release|Any CPU
31+
{14B9AB0E-2FC0-43F1-9775-20C262202D12}.Release|Any CPU.Build.0 = Release|Any CPU
32+
{7EDDFB35-2428-4433-8ABF-47233480B746}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33+
{7EDDFB35-2428-4433-8ABF-47233480B746}.Debug|Any CPU.Build.0 = Debug|Any CPU
34+
{7EDDFB35-2428-4433-8ABF-47233480B746}.Proto|Any CPU.ActiveCfg = Release|Any CPU
35+
{7EDDFB35-2428-4433-8ABF-47233480B746}.Proto|Any CPU.Build.0 = Release|Any CPU
36+
{7EDDFB35-2428-4433-8ABF-47233480B746}.Release|Any CPU.ActiveCfg = Release|Any CPU
37+
{7EDDFB35-2428-4433-8ABF-47233480B746}.Release|Any CPU.Build.0 = Release|Any CPU
38+
{0B24DCA6-902F-409E-A18C-7B1BFDDC8849}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
39+
{0B24DCA6-902F-409E-A18C-7B1BFDDC8849}.Debug|Any CPU.Build.0 = Debug|Any CPU
40+
{0B24DCA6-902F-409E-A18C-7B1BFDDC8849}.Proto|Any CPU.ActiveCfg = Debug|Any CPU
41+
{0B24DCA6-902F-409E-A18C-7B1BFDDC8849}.Proto|Any CPU.Build.0 = Debug|Any CPU
42+
{0B24DCA6-902F-409E-A18C-7B1BFDDC8849}.Release|Any CPU.ActiveCfg = Release|Any CPU
43+
{0B24DCA6-902F-409E-A18C-7B1BFDDC8849}.Release|Any CPU.Build.0 = Release|Any CPU
44+
{5A4B66D5-A6C3-402C-A010-7A3635098DA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
45+
{5A4B66D5-A6C3-402C-A010-7A3635098DA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
46+
{5A4B66D5-A6C3-402C-A010-7A3635098DA7}.Proto|Any CPU.ActiveCfg = Proto|Any CPU
47+
{5A4B66D5-A6C3-402C-A010-7A3635098DA7}.Proto|Any CPU.Build.0 = Proto|Any CPU
48+
{5A4B66D5-A6C3-402C-A010-7A3635098DA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
49+
{5A4B66D5-A6C3-402C-A010-7A3635098DA7}.Release|Any CPU.Build.0 = Release|Any CPU
50+
{860808CF-D092-4511-B011-6205B654031D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
51+
{860808CF-D092-4511-B011-6205B654031D}.Debug|Any CPU.Build.0 = Debug|Any CPU
52+
{860808CF-D092-4511-B011-6205B654031D}.Proto|Any CPU.ActiveCfg = Debug|Any CPU
53+
{860808CF-D092-4511-B011-6205B654031D}.Proto|Any CPU.Build.0 = Debug|Any CPU
54+
{860808CF-D092-4511-B011-6205B654031D}.Release|Any CPU.ActiveCfg = Release|Any CPU
55+
{860808CF-D092-4511-B011-6205B654031D}.Release|Any CPU.Build.0 = Release|Any CPU
56+
EndGlobalSection
57+
GlobalSection(SolutionProperties) = preSolution
58+
HideSolutionNode = FALSE
59+
EndGlobalSection
60+
GlobalSection(NestedProjects) = preSolution
61+
{14B9AB0E-2FC0-43F1-9775-20C262202D12} = {B4A1E626-4A48-4977-B291-219882DB3413}
62+
EndGlobalSection
63+
GlobalSection(ExtensibilityGlobals) = postSolution
64+
SolutionGuid = {BCE01FEF-1B00-471B-81E0-A06994EC90ED}
65+
EndGlobalSection
66+
EndGlobal

VisualFSharp.sln

+57
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,14 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "MicroPerf", "tests\benchmar
193193
EndProject
194194
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MicroPerfCSharp", "tests\benchmarks\CompiledCodeBenchmarks\MicroPerf\CS\MicroPerfCSharp.csproj", "{9F9DD315-37DA-4413-928E-1CFC6924B64F}"
195195
EndProject
196+
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Compiler.LanguageServer", "src\FSharp.Compiler.LanguageServer\FSharp.Compiler.LanguageServer.fsproj", "{D72F6593-DB2D-47AC-8E15-8DCE8527972E}"
197+
EndProject
198+
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Compiler.LanguageServer.Tests", "tests\FSharp.Compiler.LanguageServer.Tests\FSharp.Compiler.LanguageServer.Tests.fsproj", "{1E83A6C8-FA4D-42BD-B4A5-B7F9AAD1B388}"
199+
EndProject
200+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FSharp.VisualStudio.Extension", "src\FSharp.VisualStudio.Extension\FSharp.VisualStudio.Extension.csproj", "{E1013576-6257-47BA-AAFB-F95B68DAB1FF}"
201+
EndProject
202+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.CommonLanguageServerProtocol.Framework.Proxy", "src\Microsoft.CommonLanguageServerProtocol.Framework.Proxy\Microsoft.CommonLanguageServerProtocol.Framework.Proxy.csproj", "{FAFF15B5-F7C4-1CE5-9A18-2F6DC93E03ED}"
203+
EndProject
196204
Global
197205
GlobalSection(SolutionConfigurationPlatforms) = preSolution
198206
Debug|Any CPU = Debug|Any CPU
@@ -1019,6 +1027,54 @@ Global
10191027
{9F9DD315-37DA-4413-928E-1CFC6924B64F}.Release|Any CPU.Build.0 = Release|Any CPU
10201028
{9F9DD315-37DA-4413-928E-1CFC6924B64F}.Release|x86.ActiveCfg = Release|Any CPU
10211029
{9F9DD315-37DA-4413-928E-1CFC6924B64F}.Release|x86.Build.0 = Release|Any CPU
1030+
{D72F6593-DB2D-47AC-8E15-8DCE8527972E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1031+
{D72F6593-DB2D-47AC-8E15-8DCE8527972E}.Debug|Any CPU.Build.0 = Debug|Any CPU
1032+
{D72F6593-DB2D-47AC-8E15-8DCE8527972E}.Debug|x86.ActiveCfg = Debug|Any CPU
1033+
{D72F6593-DB2D-47AC-8E15-8DCE8527972E}.Debug|x86.Build.0 = Debug|Any CPU
1034+
{D72F6593-DB2D-47AC-8E15-8DCE8527972E}.Proto|Any CPU.ActiveCfg = Debug|Any CPU
1035+
{D72F6593-DB2D-47AC-8E15-8DCE8527972E}.Proto|Any CPU.Build.0 = Debug|Any CPU
1036+
{D72F6593-DB2D-47AC-8E15-8DCE8527972E}.Proto|x86.ActiveCfg = Debug|Any CPU
1037+
{D72F6593-DB2D-47AC-8E15-8DCE8527972E}.Proto|x86.Build.0 = Debug|Any CPU
1038+
{D72F6593-DB2D-47AC-8E15-8DCE8527972E}.Release|Any CPU.ActiveCfg = Release|Any CPU
1039+
{D72F6593-DB2D-47AC-8E15-8DCE8527972E}.Release|Any CPU.Build.0 = Release|Any CPU
1040+
{D72F6593-DB2D-47AC-8E15-8DCE8527972E}.Release|x86.ActiveCfg = Release|Any CPU
1041+
{D72F6593-DB2D-47AC-8E15-8DCE8527972E}.Release|x86.Build.0 = Release|Any CPU
1042+
{1E83A6C8-FA4D-42BD-B4A5-B7F9AAD1B388}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1043+
{1E83A6C8-FA4D-42BD-B4A5-B7F9AAD1B388}.Debug|Any CPU.Build.0 = Debug|Any CPU
1044+
{1E83A6C8-FA4D-42BD-B4A5-B7F9AAD1B388}.Debug|x86.ActiveCfg = Debug|Any CPU
1045+
{1E83A6C8-FA4D-42BD-B4A5-B7F9AAD1B388}.Debug|x86.Build.0 = Debug|Any CPU
1046+
{1E83A6C8-FA4D-42BD-B4A5-B7F9AAD1B388}.Proto|Any CPU.ActiveCfg = Debug|Any CPU
1047+
{1E83A6C8-FA4D-42BD-B4A5-B7F9AAD1B388}.Proto|Any CPU.Build.0 = Debug|Any CPU
1048+
{1E83A6C8-FA4D-42BD-B4A5-B7F9AAD1B388}.Proto|x86.ActiveCfg = Debug|Any CPU
1049+
{1E83A6C8-FA4D-42BD-B4A5-B7F9AAD1B388}.Proto|x86.Build.0 = Debug|Any CPU
1050+
{1E83A6C8-FA4D-42BD-B4A5-B7F9AAD1B388}.Release|Any CPU.ActiveCfg = Release|Any CPU
1051+
{1E83A6C8-FA4D-42BD-B4A5-B7F9AAD1B388}.Release|Any CPU.Build.0 = Release|Any CPU
1052+
{1E83A6C8-FA4D-42BD-B4A5-B7F9AAD1B388}.Release|x86.ActiveCfg = Release|Any CPU
1053+
{1E83A6C8-FA4D-42BD-B4A5-B7F9AAD1B388}.Release|x86.Build.0 = Release|Any CPU
1054+
{E1013576-6257-47BA-AAFB-F95B68DAB1FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1055+
{E1013576-6257-47BA-AAFB-F95B68DAB1FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
1056+
{E1013576-6257-47BA-AAFB-F95B68DAB1FF}.Debug|x86.ActiveCfg = Debug|Any CPU
1057+
{E1013576-6257-47BA-AAFB-F95B68DAB1FF}.Debug|x86.Build.0 = Debug|Any CPU
1058+
{E1013576-6257-47BA-AAFB-F95B68DAB1FF}.Proto|Any CPU.ActiveCfg = Debug|Any CPU
1059+
{E1013576-6257-47BA-AAFB-F95B68DAB1FF}.Proto|Any CPU.Build.0 = Debug|Any CPU
1060+
{E1013576-6257-47BA-AAFB-F95B68DAB1FF}.Proto|x86.ActiveCfg = Debug|Any CPU
1061+
{E1013576-6257-47BA-AAFB-F95B68DAB1FF}.Proto|x86.Build.0 = Debug|Any CPU
1062+
{E1013576-6257-47BA-AAFB-F95B68DAB1FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
1063+
{E1013576-6257-47BA-AAFB-F95B68DAB1FF}.Release|Any CPU.Build.0 = Release|Any CPU
1064+
{E1013576-6257-47BA-AAFB-F95B68DAB1FF}.Release|x86.ActiveCfg = Release|Any CPU
1065+
{E1013576-6257-47BA-AAFB-F95B68DAB1FF}.Release|x86.Build.0 = Release|Any CPU
1066+
{FAFF15B5-F7C4-1CE5-9A18-2F6DC93E03ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1067+
{FAFF15B5-F7C4-1CE5-9A18-2F6DC93E03ED}.Debug|Any CPU.Build.0 = Debug|Any CPU
1068+
{FAFF15B5-F7C4-1CE5-9A18-2F6DC93E03ED}.Debug|x86.ActiveCfg = Debug|Any CPU
1069+
{FAFF15B5-F7C4-1CE5-9A18-2F6DC93E03ED}.Debug|x86.Build.0 = Debug|Any CPU
1070+
{FAFF15B5-F7C4-1CE5-9A18-2F6DC93E03ED}.Proto|Any CPU.ActiveCfg = Debug|Any CPU
1071+
{FAFF15B5-F7C4-1CE5-9A18-2F6DC93E03ED}.Proto|Any CPU.Build.0 = Debug|Any CPU
1072+
{FAFF15B5-F7C4-1CE5-9A18-2F6DC93E03ED}.Proto|x86.ActiveCfg = Debug|Any CPU
1073+
{FAFF15B5-F7C4-1CE5-9A18-2F6DC93E03ED}.Proto|x86.Build.0 = Debug|Any CPU
1074+
{FAFF15B5-F7C4-1CE5-9A18-2F6DC93E03ED}.Release|Any CPU.ActiveCfg = Release|Any CPU
1075+
{FAFF15B5-F7C4-1CE5-9A18-2F6DC93E03ED}.Release|Any CPU.Build.0 = Release|Any CPU
1076+
{FAFF15B5-F7C4-1CE5-9A18-2F6DC93E03ED}.Release|x86.ActiveCfg = Release|Any CPU
1077+
{FAFF15B5-F7C4-1CE5-9A18-2F6DC93E03ED}.Release|x86.Build.0 = Release|Any CPU
10221078
EndGlobalSection
10231079
GlobalSection(SolutionProperties) = preSolution
10241080
HideSolutionNode = FALSE
@@ -1099,6 +1155,7 @@ Global
10991155
{6734FC6F-B5F3-45E1-9A72-720378BB49C9} = {DFB6ADD7-3149-43D9-AFA0-FC4A818B472B}
11001156
{601CD5C1-EAFA-4AE3-8FB9-F667B5728213} = {DFB6ADD7-3149-43D9-AFA0-FC4A818B472B}
11011157
{9F9DD315-37DA-4413-928E-1CFC6924B64F} = {DFB6ADD7-3149-43D9-AFA0-FC4A818B472B}
1158+
{1E83A6C8-FA4D-42BD-B4A5-B7F9AAD1B388} = {CFE3259A-2D30-4EB0-80D5-E8B5F3D01449}
11021159
EndGlobalSection
11031160
GlobalSection(ExtensibilityGlobals) = postSolution
11041161
SolutionGuid = {48EDBBBE-C8EE-4E3C-8B19-97184A487B37}

buildtools/AssemblyCheck/SkipVerifyEmbeddedPdb.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ FSharp.Benchmarks.Common.dll
33
FSharp.Compiler.Benchmarks.dll
44
FSharp.Compiler.ComponentTests.dll
55
FSharp.Test.Utilities.dll
6+
FSharp.Compiler.LanguageServer.Tests.dll
67
FSharp.Compiler.Private.Scripting.UnitTests.dll
78
FSharp.Compiler.Service.Tests.dll
89
FSharp.Core.UnitTests.dll
9-
FSharpSuite.Tests.dll
10+
FSharpSuite.Tests.dll

src/Compiler/FSharp.Compiler.Service.fsproj

+2
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@
9797
<InternalsVisibleTo Include="HistoricalBenchmark" />
9898
<InternalsVisibleTo Include="FSharp.Test.Utilities" />
9999
<InternalsVisibleTo Include="FSharp.Editor" />
100+
<InternalsVisibleTo Include="FSharp.Compiler.LanguageServer" />
101+
<InternalsVisibleTo Include="FSharp.VisualStudio.Extension" />
100102
</ItemGroup>
101103

102104
<ItemGroup>

src/Compiler/Facilities/AsyncMemoize.fs

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ module internal Utils =
114114

115115
/// Return file name with one directory above it
116116
let shortPath (path: string) =
117-
let dirPath = !!Path.GetDirectoryName(path)
117+
let dirPath = Path.GetDirectoryName(path) |> Option.ofObj |> Option.defaultValue ""
118118

119119
let dir =
120120
dirPath.Split Path.DirectorySeparatorChar

src/Compiler/Facilities/Hashing.fs

+5-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ module internal Md5Hasher =
4646
let private md5 =
4747
new ThreadLocal<_>(fun () -> System.Security.Cryptography.MD5.Create())
4848

49-
let computeHash (bytes: byte array) = md5.Value.ComputeHash(bytes)
49+
let computeHash (bytes: byte array) =
50+
// md5.Value.ComputeHash(bytes) TODO: the threadlocal is not working in new VS extension
51+
ignore md5
52+
let md5 = System.Security.Cryptography.MD5.Create()
53+
md5.ComputeHash(bytes)
5054

5155
let empty = Array.empty
5256

src/Compiler/Service/FSharpProjectSnapshot.fs

+64
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,7 @@ and [<Experimental("This FCS API is experimental and subject to change.")>] FSha
619619
member _.OriginalLoadReferences = projectSnapshot.OriginalLoadReferences
620620
member _.Stamp = projectSnapshot.Stamp
621621
member _.OutputFileName = projectSnapshot.OutputFileName
622+
member _.ProjectConfig = projectSnapshot.ProjectConfig
622623

623624
static member Create
624625
(
@@ -745,6 +746,69 @@ and [<Experimental("This FCS API is experimental and subject to change.")>] FSha
745746

746747
FSharpProjectSnapshot.FromOptions(options, getFileSnapshot)
747748

749+
static member FromResponseFile(responseFile: FileInfo, projectFileName) =
750+
if not responseFile.Exists then
751+
failwith $"%s{responseFile.FullName} does not exist"
752+
753+
let compilerArgs = File.ReadAllLines responseFile.FullName
754+
755+
let directoryName: string =
756+
match responseFile.DirectoryName with
757+
| null -> failwith "Directory name of the response file is null"
758+
| str -> str
759+
760+
FSharpProjectSnapshot.FromCommandLineArgs(compilerArgs, directoryName, projectFileName)
761+
762+
static member FromCommandLineArgs(compilerArgs: string array, directoryPath: string, projectFileName) =
763+
let fsharpFileExtensions = set [| ".fs"; ".fsi"; ".fsx" |]
764+
765+
let isFSharpFile (file: string) =
766+
Set.exists (fun (ext: string) -> file.EndsWith(ext, StringComparison.Ordinal)) fsharpFileExtensions
767+
768+
let isReference: string -> bool = _.StartsWith("-r:")
769+
770+
let fsharpFiles =
771+
compilerArgs
772+
|> Array.choose (fun (line: string) ->
773+
if not (isFSharpFile line) then
774+
None
775+
else
776+
777+
let fullPath = Path.Combine(directoryPath, line)
778+
if not (File.Exists fullPath) then None else Some fullPath)
779+
|> Array.toList
780+
781+
let referencesOnDisk =
782+
compilerArgs |> Seq.filter isReference |> Seq.map _.Substring(3) |> Seq.toList
783+
784+
let otherOptions =
785+
compilerArgs
786+
|> Seq.filter (not << isReference)
787+
|> Seq.filter (not << isFSharpFile)
788+
|> Seq.toList
789+
790+
FSharpProjectSnapshot.Create(
791+
projectFileName = projectFileName,
792+
outputFileName = None,
793+
projectId = None,
794+
sourceFiles = (fsharpFiles |> List.map FSharpFileSnapshot.CreateFromFileSystem),
795+
referencesOnDisk =
796+
(referencesOnDisk
797+
|> List.map (fun x ->
798+
{
799+
Path = x
800+
LastModified = FileSystem.GetLastWriteTimeShim(x)
801+
})),
802+
otherOptions = otherOptions,
803+
referencedProjects = [],
804+
isIncompleteTypeCheckEnvironment = false,
805+
useScriptResolutionRules = false,
806+
loadTime = DateTime.Now,
807+
unresolvedReferences = None,
808+
originalLoadReferences = [],
809+
stamp = None
810+
)
811+
748812
let internal snapshotTable =
749813
ConditionalWeakTable<ProjectSnapshot, FSharpProjectOptions>()
750814

src/Compiler/Service/FSharpWorkspace.fs

+1-8
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,7 @@ type FSharpWorkspace(checker: FSharpChecker) =
4646
)
4747
)
4848

49-
member internal this.Debug_DumpMermaid(path) =
50-
let content =
51-
depGraph.Debug_RenderMermaid (function
52-
// Collapse all reference on disk nodes into one. Otherwise the graph is too big to render.
53-
| WorkspaceGraphTypes.WorkspaceNodeKey.ReferenceOnDisk _ -> WorkspaceGraphTypes.WorkspaceNodeKey.ReferenceOnDisk "..."
54-
| x -> x)
55-
56-
File.WriteAllText(__SOURCE_DIRECTORY__ + path, content)
49+
member internal _.DepGraph = depGraph
5750

5851
/// The `FSharpChecker` instance used by this workspace.
5952
member _.Checker = checker

src/Compiler/Service/FSharpWorkspaceQuery.fs

+40-10
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ module FSharp.Compiler.CodeAnalysis.Workspace.FSharpWorkspaceQuery
55

66
open System
77
open System.Collections.Generic
8+
open FSharp.Compiler.Diagnostics
89
open System.Threading
910

1011
open FSharp.Compiler.CodeAnalysis
1112

1213
open Internal.Utilities.DependencyGraph
14+
open Internal.Utilities.Library.Extras
1315
open FSharpWorkspaceState
16+
open Internal.Utilities.Library
1417

1518
#nowarn "57"
1619

@@ -32,13 +35,20 @@ type FSharpWorkspaceQuery internal (depGraph: IThreadSafeDependencyGraph<_, _>,
3235
// in order to be able to clear previous diagnostics
3336
let getDiagnosticResultId () = Interlocked.Increment(&resultIdCounter)
3437

38+
member internal _.Checker = checker
39+
3540
member _.GetProjectSnapshot projectIdentifier =
41+
use _ =
42+
Activity.start "GetProjectSnapshot" [ Activity.Tags.project, projectIdentifier.ToString() |> (!!) ]
43+
3644
try
3745
depGraph.GetProjectSnapshot projectIdentifier |> Some
3846
with :? KeyNotFoundException ->
3947
None
4048

4149
member _.GetProjectSnapshotForFile(file: Uri) =
50+
use _ =
51+
Activity.start "GetProjectSnapshotForFile" [ Activity.Tags.fileName, file.LocalPath ]
4252

4353
depGraph.GetProjectsContaining file.LocalPath
4454

@@ -47,28 +57,48 @@ type FSharpWorkspaceQuery internal (depGraph: IThreadSafeDependencyGraph<_, _>,
4757
// Otherwise we have to keep track of which project/configuration is active
4858
|> Seq.tryHead // For now just get the first one
4959

50-
// TODO: split to parse and check diagnostics
51-
member this.GetDiagnosticsForFile(file: Uri) =
60+
member this.GetParseAndCheckResultsForFile(file: Uri) =
5261
async {
5362

54-
let! diagnostics =
63+
use _ =
64+
Activity.start "GetParseAndCheckResultsForFile" [ Activity.Tags.fileName, file.LocalPath ]
65+
66+
return!
5567
this.GetProjectSnapshotForFile file
5668
|> Option.map (fun snapshot ->
5769
async {
58-
let! parseResult, checkFileAnswer =
59-
checker.ParseAndCheckFileInProject(file.LocalPath, snapshot, "LSP Get diagnostics")
70+
let! parseResult, checkFileAnswer = checker.ParseAndCheckFileInProject(file.LocalPath, snapshot)
6071

6172
return
6273
match checkFileAnswer with
63-
| FSharpCheckFileAnswer.Succeeded result -> result.Diagnostics
64-
| FSharpCheckFileAnswer.Aborted -> parseResult.Diagnostics
74+
| FSharpCheckFileAnswer.Succeeded result -> Some parseResult, Some result
75+
| FSharpCheckFileAnswer.Aborted -> Some parseResult, None
6576
})
66-
|> Option.defaultValue (async.Return [||])
77+
|> Option.defaultValue (async.Return(None, None))
6778

68-
return FSharpDiagnosticReport(diagnostics, getDiagnosticResultId ())
6979
}
7080

71-
member this.GetSemanticClassification(file) =
81+
member this.GetCheckResultsForFile(file) =
82+
this.GetParseAndCheckResultsForFile file |> Async.map snd
83+
84+
// TODO: split to parse and check diagnostics
85+
member this.GetDiagnosticsForFile(file: Uri) =
86+
use _ =
87+
Activity.start "GetDiagnosticsForFile" [ Activity.Tags.fileName, file.LocalPath ]
88+
89+
this.GetParseAndCheckResultsForFile file
90+
|> Async.map (fun results ->
91+
let diagnostics =
92+
match results with
93+
| _, Some checkResult -> checkResult.Diagnostics
94+
| Some parseResult, _ -> parseResult.Diagnostics
95+
| _ -> [||]
96+
97+
FSharpDiagnosticReport(diagnostics, getDiagnosticResultId ()))
98+
99+
member this.GetSemanticClassification(file: Uri) =
100+
use _ =
101+
Activity.start "GetSemanticClassification" [ Activity.Tags.fileName, file.LocalPath ]
72102

73103
this.GetProjectSnapshotForFile file
74104
|> Option.map (fun snapshot ->

0 commit comments

Comments
 (0)