@@ -149,6 +149,7 @@ type FcsCheckerService(lifetime: Lifetime, logger: ILogger, onSolutionCloseNotif
149
149
let setting = SettingsUtil.getEntry< FSharpOptions> settingsStore name
150
150
settingsStoreLive.GetValueProperty( lifetime, setting, null )
151
151
152
+ // TODO: double check setting
152
153
let useTransparentCompiler = true //(getSettingProperty "UseTransparentCompiler").Value
153
154
154
155
let checker =
@@ -177,6 +178,7 @@ type FcsCheckerService(lifetime: Lifetime, logger: ILogger, onSolutionCloseNotif
177
178
member val AssemblyReaderShim = Unchecked.defaultof< IFcsAssemblyReaderShim> with get, set
178
179
179
180
member x.Checker = checker.Value
181
+ member val UseTransparentCompiler = useTransparentCompiler
180
182
181
183
member this.AssertFcsAccessThread () =
182
184
()
@@ -267,20 +269,34 @@ type FcsCheckerService(lifetime: Lifetime, logger: ILogger, onSolutionCloseNotif
267
269
let path = file.GetLocation() .FullPath
268
270
logger.Trace( " TryGetStaleCheckResults: start {0}, {1}" , path, opName)
269
271
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 ->
272
289
logger.Trace( " TryGetStaleCheckResults: finish {0}, {1}" , path, opName)
273
290
Some checkResults
274
-
275
291
| _ ->
276
292
logger.Trace( " TryGetStaleCheckResults: fail {0}, {1}" , path, opName)
277
293
None
278
294
279
295
member x.GetCachedScriptOptions ( path ) =
280
296
if checker.IsValueCreated then
297
+ checker.Value.GetCachedScriptOptions( path)
298
+ else
281
299
None
282
- // TODO: checker.Value.GetCachedScriptOptions(path)
283
- else None
284
300
285
301
member x.InvalidateFcsProject ( projectOptions : FSharpProjectOptions , invalidationType : FcsProjectInvalidationType ) =
286
302
if checker.IsValueCreated then
@@ -290,7 +306,13 @@ type FcsCheckerService(lifetime: Lifetime, logger: ILogger, onSolutionCloseNotif
290
306
checker.Value.ClearCache( Seq.singleton projectOptions)
291
307
| FcsProjectInvalidationType.Remove ->
292
308
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)
294
316
295
317
/// Use with care: returns wrong symbol inside its non-recursive declaration, see dotnet/fsharp#7694.
296
318
member x.ResolveNameAtLocation ( sourceFile : IPsiSourceFile , names , coords , resolveExpr : bool , opName ) =
0 commit comments