Skip to content

Commit

Permalink
Just force caller to provide volatilefile
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAngryByrd committed Sep 2, 2024
1 parent d204b8e commit 176e7cc
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions src/FsAutoComplete/LspServers/AdaptiveServerState.fs
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,6 @@ type AdaptiveWorkspaceChosen =



type FilePathOrFile =
| Path of string<LocalPath>
| File of VolatileFile

member x.FileName =
match x with
| Path p -> p
| File f -> f.FileName


[<CustomEquality; NoComparison>]
Expand Down Expand Up @@ -1290,29 +1282,26 @@ type AdaptiveState

/// <summary>Parses a source code for a file and caches the results. Returns an AST that can be traversed for various features.</summary>
/// <param name="checker">The FSharpCompilerServiceChecker.</param>
/// <param name="sourceFilePath">The source to be parsed.</param>
/// <param name="file">The source to be parsed.</param>
/// <param name="compilerOptions"></param>
/// <returns></returns>

let parseFile
(checker: FSharpCompilerServiceChecker)
(sourceFilePath: FilePathOrFile)
(file: VolatileFile)
(compilerOptions: CompilerProjectOption)
=
task {
let! result =
match compilerOptions with
| CompilerProjectOption.TransparentCompiler snap ->
taskResult { return! checker.ParseFile(sourceFilePath.FileName, snap) }
taskResult { return! checker.ParseFile(file.FileName, snap) }
| CompilerProjectOption.BackgroundCompiler opts ->
taskResult {
let! file =
match sourceFilePath with
| Path file -> forceFindOpenFileOrRead file
| File file -> AsyncResult.ok file

return! checker.ParseFile(sourceFilePath.FileName, file.Source, opts)

return! checker.ParseFile(file.FileName, file.Source, opts)
}

let! ct = Async.CancellationToken
Expand Down Expand Up @@ -1343,8 +1332,12 @@ type AdaptiveState
|> HashSet.toArray
|> Array.collect (fun (snap) -> snap.SourceFilesTagged |> List.toArray |> Array.map (fun s -> snap, s))
|> Array.map (fun (snap, filePath) ->
taskResult {
let! vFile = forceFindOpenFileOrRead filePath
return! parseFile checker vFile snap

})

parseFile checker (FilePathOrFile.Path filePath) snap)
|> Task.WhenAll
}

Expand Down Expand Up @@ -1497,7 +1490,7 @@ type AdaptiveState
match loadedProject with
| Ok x ->
let! snap = x.FSharpProjectCompilerOptions
let! r = parseFile checker (FilePathOrFile.File file) snap
let! r = parseFile checker file snap
return r
| Error e -> return Error e
})
Expand Down

0 comments on commit 176e7cc

Please sign in to comment.