Skip to content

Commit

Permalink
remove typechecks from cache on file close (ionide#1187)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAngryByrd authored and nojaf committed Nov 3, 2023
1 parent 378ece1 commit 0bf7ad9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/FsAutoComplete.Core/CompilerServiceInterface.fs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ type FSharpCompilerServiceChecker(hasAnalyzers, typecheckCacheSize, parallelRefe

let mutable lastCheckResults: IMemoryCache = memoryCache ()


let checkerLogger = LogProvider.getLoggerByName "Checker"
let optsLogger = LogProvider.getLoggerByName "Opts"

Expand Down Expand Up @@ -244,6 +243,8 @@ type FSharpCompilerServiceChecker(hasAnalyzers, typecheckCacheSize, parallelRefe
member __.ScriptTypecheckRequirementsChanged =
scriptTypecheckRequirementsChanged.Publish

member _.RemoveFileFromCache(file: string<LocalPath>) = lastCheckResults.Remove(file)

/// This function is called when the entire environment is known to have changed for reasons not encoded in the ProjectOptions of any project/compilation.
member _.ClearCaches() =
lastCheckResults.Dispose()
Expand Down
3 changes: 3 additions & 0 deletions src/FsAutoComplete.Core/CompilerServiceInterface.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ type FSharpCompilerServiceChecker =
file: string<LocalPath> * source: ISourceText * tfm: FSIRefs.TFM -> Async<FSharpProjectOptions>

member ScriptTypecheckRequirementsChanged: IEvent<unit>

member RemoveFileFromCache: file: string<LocalPath> -> unit

/// This function is called when the entire environment is known to have changed for reasons not encoded in the ProjectOptions of any project/compilation.
member ClearCaches: unit -> unit

Expand Down
2 changes: 2 additions & 0 deletions src/FsAutoComplete/LspServers/AdaptiveServerState.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1814,6 +1814,8 @@ type AdaptiveState(lspClient: FSharpLspClient, sourceTextFactory: ISourceTextFac

|> AsyncAVal.forceAsync

(AVal.force checker).RemoveFileFromCache(filePath)

transact (fun () ->
openFiles.Remove filePath |> ignore<bool>

Expand Down

0 comments on commit 0bf7ad9

Please sign in to comment.