Skip to content

Commit

Permalink
Make background/transparent compiler switchable
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAngryByrd committed Apr 21, 2024
1 parent 77aca9a commit ae52948
Show file tree
Hide file tree
Showing 18 changed files with 751 additions and 253 deletions.
25 changes: 12 additions & 13 deletions src/FsAutoComplete.Core/Commands.fs
Original file line number Diff line number Diff line change
Expand Up @@ -731,10 +731,10 @@ module Commands =

let symbolUseWorkspaceAux
(getDeclarationLocation: FSharpSymbolUse * IFSACSourceText -> Async<SymbolDeclarationLocation option>)
(findReferencesForSymbolInFile: (string<LocalPath> * FSharpProjectSnapshot * FSharpSymbol) -> Async<Range seq>)
(findReferencesForSymbolInFile: (string<LocalPath> * CompilerProjectOption * FSharpSymbol) -> Async<Range seq>)
(tryGetFileSource: string<LocalPath> -> Async<ResultOrString<IFSACSourceText>>)
(tryGetProjectOptionsForFsproj: string<LocalPath> -> Async<FSharpProjectSnapshot option>)
(getAllProjectOptions: unit -> Async<FSharpProjectSnapshot seq>)
(tryGetProjectOptionsForFsproj: string<LocalPath> -> Async<CompilerProjectOption option>)
(getAllProjectOptions: unit -> Async<CompilerProjectOption seq>)
(includeDeclarations: bool)
(includeBackticks: bool)
(errorOnFailureToFixRange: bool)
Expand Down Expand Up @@ -787,7 +787,7 @@ module Commands =

return (symbol, ranges)
| scope ->
let projectsToCheck: Async<FSharpProjectSnapshot list> =
let projectsToCheck: Async<CompilerProjectOption list> =
async {
match scope with
| Some(SymbolDeclarationLocation.Projects(projects (*isLocalForProject=*) , true)) -> return projects
Expand All @@ -798,8 +798,8 @@ module Commands =
yield Async.singleton (Some project)

yield!
project.ReferencedProjects
|> List.map (fun p -> Utils.normalizePath p.OutputFile |> tryGetProjectOptionsForFsproj) ]
project.ReferencedProjectsPath
|> List.map (fun p -> Utils.normalizePath p |> tryGetProjectOptionsForFsproj) ]
|> Async.parallel75


Expand Down Expand Up @@ -839,7 +839,7 @@ module Commands =
/// Adds References of `symbol` in `file` to `dict`
///
/// `Error` iff adjusting ranges failed (including cannot get source) and `errorOnFailureToFixRange`. Otherwise always `Ok`
let tryFindReferencesInFile (file: string<LocalPath>, project: FSharpProjectSnapshot) =
let tryFindReferencesInFile (file: string<LocalPath>, project: CompilerProjectOption) =
async {
if dict.ContainsKey file then
return Ok()
Expand Down Expand Up @@ -882,15 +882,14 @@ module Commands =

if errorOnFailureToFixRange then Error e else Ok())

let iterProjects (projects: FSharpProjectSnapshot seq) =
let iterProjects (projects: CompilerProjectOption seq) =
// should:
// * check files in parallel
// * stop when error occurs
// -> `Async.Choice`: executes in parallel, returns first `Some`
// -> map `Error` to `Some` for `Async.Choice`, afterwards map `Some` back to `Error`
[ for project in projects do
for file in project.SourceFiles do
let file = Utils.normalizePath file.FileName
for file in project.SourceFilesTagged do

async {
match! tryFindReferencesInFile (file, project) with
Expand Down Expand Up @@ -930,10 +929,10 @@ module Commands =
/// -> for "Rename"
let symbolUseWorkspace
(getDeclarationLocation: FSharpSymbolUse * IFSACSourceText -> Async<SymbolDeclarationLocation option>)
(findReferencesForSymbolInFile: (string<LocalPath> * FSharpProjectSnapshot * FSharpSymbol) -> Async<Range seq>)
(findReferencesForSymbolInFile: (string<LocalPath> * CompilerProjectOption * FSharpSymbol) -> Async<Range seq>)
(tryGetFileSource: string<LocalPath> -> Async<ResultOrString<IFSACSourceText>>)
(tryGetProjectOptionsForFsproj: string<LocalPath> -> Async<FSharpProjectSnapshot option>)
(getAllProjectOptions: unit -> Async<FSharpProjectSnapshot seq>)
(tryGetProjectOptionsForFsproj: string<LocalPath> -> Async<CompilerProjectOption option>)
(getAllProjectOptions: unit -> Async<CompilerProjectOption seq>)
(includeDeclarations: bool)
(includeBackticks: bool)
(errorOnFailureToFixRange: bool)
Expand Down
Loading

0 comments on commit ae52948

Please sign in to comment.