From 0e7ec6238f1a0cc9511cd576176a5b1c92547c89 Mon Sep 17 00:00:00 2001 From: Jimmy Byrd Date: Sun, 8 Dec 2024 14:18:01 -0500 Subject: [PATCH] Transparent compiler fixes --- .vscode/settings.json | 2 -- .../CompilerServiceInterface.fs | 17 +++++++++-------- .../LspServers/ProjectWorkspace.fs | 13 +++++++++++++ 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 68066a306..2f9d3073a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -168,6 +168,4 @@ "FSharp.lineLens.enabled": "replaceCodeLens", "FSharp.codeLenses.signature.enabled": false, "FSharp.verboseLogging": true, - "FSharp.fcs.transparentCompiler.enabled": true, - "FSharp.fsac.netCoreDllPath": "C:\\Users\\jimmy\\Repositories\\public\\TheAngryByrd\\FsAutoComplete\\src\\FsAutoComplete\\bin\\Release\\" } diff --git a/src/FsAutoComplete.Core/CompilerServiceInterface.fs b/src/FsAutoComplete.Core/CompilerServiceInterface.fs index a91a2ce66..4e23a9f38 100644 --- a/src/FsAutoComplete.Core/CompilerServiceInterface.fs +++ b/src/FsAutoComplete.Core/CompilerServiceInterface.fs @@ -81,8 +81,12 @@ type CompilerProjectOption = type FSharpCompilerServiceChecker(hasAnalyzers, typecheckCacheSize, parallelReferenceResolution, useTransparentCompiler) = let checker = - let c = - FSharpChecker.Create( + let cacheSize = + if useTransparentCompiler then + TransparentCompiler.CacheSizes.Create(10) |> Some + else + None + FSharp.Compiler.CodeAnalysis.FSharpChecker.Create( projectCacheSize = 200, keepAssemblyContents = hasAnalyzers, keepAllBackgroundResolutions = true, @@ -92,14 +96,10 @@ type FSharpCompilerServiceChecker(hasAnalyzers, typecheckCacheSize, parallelRefe enablePartialTypeChecking = not hasAnalyzers, parallelReferenceResolution = parallelReferenceResolution, captureIdentifiersWhenParsing = true, - useTransparentCompiler = useTransparentCompiler + useTransparentCompiler = useTransparentCompiler, + ?transparentCompilerCacheSizes = cacheSize ) - if useTransparentCompiler then - c.TransparentCompiler.SetCacheSizeFactor(10) - - c - let entityCache = EntityCache() // FCS can't seem to handle parallel project restores for script files @@ -145,6 +145,7 @@ type FSharpCompilerServiceChecker(hasAnalyzers, typecheckCacheSize, parallelRefe FSharpProjectSnapshot.Create( snapshot.ProjectFileName, + snapshot.OutputFileName, snapshot.ProjectId, snapshot.SourceFiles, snapshot.ReferencesOnDisk, diff --git a/src/FsAutoComplete/LspServers/ProjectWorkspace.fs b/src/FsAutoComplete/LspServers/ProjectWorkspace.fs index a8e942e7b..87acea47c 100644 --- a/src/FsAutoComplete/LspServers/ProjectWorkspace.fs +++ b/src/FsAutoComplete/LspServers/ProjectWorkspace.fs @@ -44,6 +44,7 @@ module Snapshots = let makeAdaptiveFCSSnapshot projectFileName + outputFileName projectId sourceFiles referencePaths @@ -59,6 +60,7 @@ module Snapshots = // If any of these change, it will create a new snapshot. // And if any of the snapshots in the referencedProjects change, it will create a new snapshot for them as well. let! projectFileName = projectFileName + and! outputFileName = outputFileName and! projectId = projectId and! sourceFiles = sourceFiles and! referencePaths = referencePaths @@ -81,6 +83,7 @@ module Snapshots = return FSharpProjectSnapshot.Create( projectFileName, + outputFileName, projectId, sourceFiles, referencePaths, @@ -97,6 +100,7 @@ module Snapshots = let makeAdaptiveFCSSnapshot2 projectFileName + outputFileName projectId (sourceFiles: alist>) (referencePaths: aset>) @@ -113,6 +117,7 @@ module Snapshots = makeAdaptiveFCSSnapshot projectFileName + outputFileName projectId (flattenAList sourceFiles) (flattenASet referencePaths) @@ -245,6 +250,13 @@ module Snapshots = ) let projectName = AVal.constant project.ProjectFileName + + let outputFileName = + project.OtherOptions + |> Seq.tryFind (fun (x: string) -> x.StartsWith("-o:")) + |> Option.map (fun x -> x.Substring(3)) + |> AVal.constant + let projectId = AVal.constant project.ProjectId @@ -283,6 +295,7 @@ module Snapshots = makeAdaptiveFCSSnapshot2 projectName projectId + outputFileName sourceFiles referencePaths otherOptions