Skip to content
This repository was archived by the owner on Jul 19, 2019. It is now read-only.

Commit 9b59d39

Browse files
alfonsogarciacaroncave
authored andcommitted
Keep source hashes through watch compilations
1 parent 3da62cd commit 9b59d39

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

fcs/FSharp.Compiler.Service/service_slim.fs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ type InteractiveChecker internal (tcConfig, tcGlobals, tcImports, tcInitialState
7878
let tcInitialEnv = GetInitialTcEnv (assemblyName, rangeStartup, tcConfig, tcImports, tcGlobals)
7979
let tcInitialState = GetInitialTcState (rangeStartup, assemblyName, tcConfig, tcGlobals, tcImports, niceNameGen, tcInitialEnv)
8080

81-
let reactorOps =
81+
let reactorOps =
8282
{ new IReactorOperations with
8383
member __.EnqueueAndAwaitOpAsync (userOpName, opName, opArg, op) =
8484
async.Return (Cancellable.runWithoutCancellation (op ctok))
@@ -116,11 +116,11 @@ type InteractiveChecker internal (tcConfig, tcGlobals, tcImports, tcInitialState
116116
// restore all cached typecheck entries above file
117117
cachedAbove |> Array.iter (fun (key, value) -> checkCache.TryAdd(key, value) |> ignore)
118118

119-
member private x.ParseFile (fileName: string, source: string, parsingOptions: FSharpParsingOptions) =
120-
let parseCacheKey = fileName, hash source
119+
member private x.ParseFile (fileName: string, sourceHash: int, source: Lazy<string>, parsingOptions: FSharpParsingOptions) =
120+
let parseCacheKey = fileName, sourceHash
121121
parseCache.GetOrAdd(parseCacheKey, fun _ ->
122122
x.ClearStaleCache(fileName, parsingOptions)
123-
let parseErrors, parseTreeOpt, anyErrors = Parser.parseFile (source, fileName, parsingOptions, userOpName)
123+
let parseErrors, parseTreeOpt, anyErrors = Parser.parseFile (source.Value, fileName, parsingOptions, userOpName)
124124
let dependencyFiles = [||] // interactions have no dependencies
125125
FSharpParseFileResults (parseErrors, parseTreeOpt, anyErrors, dependencyFiles) )
126126

@@ -197,11 +197,12 @@ type InteractiveChecker internal (tcConfig, tcGlobals, tcImports, tcInitialState
197197
/// Parses and checks the whole project, good for compilers (Fable etc.)
198198
/// Does not retain name resolutions and symbol uses which are quite memory hungry (so no intellisense etc.).
199199
/// Already parsed files will be cached so subsequent compilations will be faster.
200-
member x.ParseAndCheckProject (projectFileName: string, fileNames: string[], sources: string[]) =
200+
member x.ParseAndCheckProject (projectFileName: string, fileNames: string[], sourceReader: string->int*Lazy<string>) =
201201
// parse files
202202
let parsingOptions = FSharpParsingOptions.FromTcConfig(tcConfig, fileNames, false)
203-
let parseFile (fileName, source) = x.ParseFile (fileName, source, parsingOptions)
204-
let parseResults = Array.zip fileNames sources |> Array.map parseFile
203+
let parseResults = fileNames |> Array.map (fun fileName ->
204+
let sourceHash, source = sourceReader fileName
205+
x.ParseFile(fileName, sourceHash, source, parsingOptions))
205206

206207
// type check files
207208
let tcState, topAttrs, tcImplFiles, _tcEnvAtEnd, _moduleNamesDict, tcErrors =
@@ -228,7 +229,7 @@ type InteractiveChecker internal (tcConfig, tcGlobals, tcImports, tcInitialState
228229

229230
// parse files before file
230231
let parsingOptions = FSharpParsingOptions.FromTcConfig(tcConfig, fileNames, false)
231-
let parseFile (fileName, source) = x.ParseFile (fileName, source, parsingOptions)
232+
let parseFile (fileName, source) = x.ParseFile (fileName, hash source, lazy source, parsingOptions)
232233
let parseResults = Array.zip fileNamesBeforeFile sourcesBeforeFile |> Array.map parseFile
233234

234235
// type check files before file

0 commit comments

Comments
 (0)