@@ -149,6 +149,7 @@ type FcsCheckerService(lifetime: Lifetime, logger: ILogger, onSolutionCloseNotif
149149 let setting = SettingsUtil.getEntry< FSharpOptions> settingsStore name
150150 settingsStoreLive.GetValueProperty( lifetime, setting, null )
151151
152+ // TODO: double check setting
152153 let useTransparentCompiler = true //(getSettingProperty "UseTransparentCompiler").Value
153154
154155 let checker =
@@ -177,6 +178,7 @@ type FcsCheckerService(lifetime: Lifetime, logger: ILogger, onSolutionCloseNotif
177178 member val AssemblyReaderShim = Unchecked.defaultof< IFcsAssemblyReaderShim> with get, set
178179
179180 member x.Checker = checker.Value
181+ member val UseTransparentCompiler = useTransparentCompiler
180182
181183 member this.AssertFcsAccessThread () =
182184 ()
@@ -267,20 +269,34 @@ type FcsCheckerService(lifetime: Lifetime, logger: ILogger, onSolutionCloseNotif
267269 let path = file.GetLocation() .FullPath
268270 logger.Trace( " TryGetStaleCheckResults: start {0}, {1}" , path, opName)
269271
270- match x.Checker.TryGetRecentCheckResultsForFile( path, options) with
271- | Some (_, checkResults, _) ->
272+ let recentCheckResults =
273+ if not useTransparentCompiler then
274+ x.Checker.TryGetRecentCheckResultsForFile( path, options)
275+ |> Option.map ( fun ( _ , checkResults , _ ) -> checkResults)
276+ else
277+ match x.FcsProjectProvider.GetFcsProject( file.PsiModule) with
278+ | None -> None
279+ | Some fcsProject ->
280+
281+ let projectKey = FcsProjectKey.Create( file.PsiModule)
282+ let fcsSnapshotCache = file.GetSolution() .GetComponent< FcsSnapshotCache>()
283+ let snapshot = fcsSnapshotCache.GetProjectSnapshot( projectKey, fcsProject.ProjectOptions)
284+ x.Checker.TryGetRecentCheckResultsForFile( path, snapshot)
285+ |> Option.map snd
286+
287+ match recentCheckResults with
288+ | Some checkResults ->
272289 logger.Trace( " TryGetStaleCheckResults: finish {0}, {1}" , path, opName)
273290 Some checkResults
274-
275291 | _ ->
276292 logger.Trace( " TryGetStaleCheckResults: fail {0}, {1}" , path, opName)
277293 None
278294
279295 member x.GetCachedScriptOptions ( path ) =
280296 if checker.IsValueCreated then
297+ checker.Value.GetCachedScriptOptions( path)
298+ else
281299 None
282- // TODO: checker.Value.GetCachedScriptOptions(path)
283- else None
284300
285301 member x.InvalidateFcsProject ( projectOptions : FSharpProjectOptions , invalidationType : FcsProjectInvalidationType ) =
286302 if checker.IsValueCreated then
@@ -290,7 +306,13 @@ type FcsCheckerService(lifetime: Lifetime, logger: ILogger, onSolutionCloseNotif
290306 checker.Value.ClearCache( Seq.singleton projectOptions)
291307 | FcsProjectInvalidationType.Remove ->
292308 logger.Trace( " Invalidate FcsProject in FCS: {0}" , projectOptions.ProjectFileName)
293- checker.Value.InvalidateConfiguration( projectOptions)
309+ if useTransparentCompiler then
310+ // InvalidateConfiguration isn't required for the transparent compiler as it works differently.
311+ // InvalidateConfiguration in the BackgroundCompiler will recreate the createBuilderNode.
312+ // This is not required in the TransparentCompiler and so Clearing the cache would be the proper equivalent.
313+ checker.Value.ClearCache( Seq.singleton projectOptions)
314+ else
315+ checker.Value.InvalidateConfiguration( projectOptions)
294316
295317 /// Use with care: returns wrong symbol inside its non-recursive declaration, see dotnet/fsharp#7694.
296318 member x.ResolveNameAtLocation ( sourceFile : IPsiSourceFile , names , coords , resolveExpr : bool , opName ) =
0 commit comments