Skip to content

Commit

Permalink
Transparent compiler fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAngryByrd committed Dec 8, 2024
1 parent e3a113e commit dfd967e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
2 changes: 0 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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\\"
}
17 changes: 9 additions & 8 deletions src/FsAutoComplete.Core/CompilerServiceInterface.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -145,6 +145,7 @@ type FSharpCompilerServiceChecker(hasAnalyzers, typecheckCacheSize, parallelRefe

FSharpProjectSnapshot.Create(
snapshot.ProjectFileName,
snapshot.OutputFileName,
snapshot.ProjectId,
snapshot.SourceFiles,
snapshot.ReferencesOnDisk,
Expand Down
13 changes: 13 additions & 0 deletions src/FsAutoComplete/LspServers/ProjectWorkspace.fs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module Snapshots =

let makeAdaptiveFCSSnapshot
projectFileName
outputFileName
projectId
sourceFiles
referencePaths
Expand All @@ -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
Expand All @@ -81,6 +83,7 @@ module Snapshots =
return
FSharpProjectSnapshot.Create(
projectFileName,
outputFileName,
projectId,
sourceFiles,
referencePaths,
Expand All @@ -97,6 +100,7 @@ module Snapshots =

let makeAdaptiveFCSSnapshot2
projectFileName
outputFileName
projectId
(sourceFiles: alist<aval<FSharpFileSnapshot>>)
(referencePaths: aset<aval<ReferenceOnDisk>>)
Expand All @@ -113,6 +117,7 @@ module Snapshots =

makeAdaptiveFCSSnapshot
projectFileName
outputFileName
projectId
(flattenAList sourceFiles)
(flattenASet referencePaths)
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -283,6 +295,7 @@ module Snapshots =
makeAdaptiveFCSSnapshot2
projectName
projectId
outputFileName
sourceFiles
referencePaths
otherOptions
Expand Down

0 comments on commit dfd967e

Please sign in to comment.