Skip to content

Commit

Permalink
Enhancement: Find Usages in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
Booksbaum committed Mar 3, 2023
1 parent dfcc3ea commit de6beb9
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/FsAutoComplete.Core/Commands.fs
Original file line number Diff line number Diff line change
Expand Up @@ -867,21 +867,25 @@ module Commands =

if errorOnFailureToFixRange then Error e else Ok())

let iterProject (project: FSharpProjectOptions) =
asyncResult {
//Enhancement: do in parallel?
for file in project.SourceFiles do
let file = UMX.tag file
// early return iff `Error`
// (which can only happen iff `errorOnFailureToFixRange`. otherwise errors are ignored and the loop continues)
do! tryFindReferencesInFile (file, project)
}

let iterProjects (projects: FSharpProjectOptions seq) =
asyncResult {
// 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
do! iterProject project
}
for file in project.SourceFiles do
let file = UMX.tag file
async {
match! tryFindReferencesInFile (file, project) with
| Ok _ -> return None
| Error err -> return Some err

}
]
|> Async.Choice
|> Async.map (function | None -> Ok () | Some err -> Error err)

do! iterProjects projectsToCheck

Expand Down

0 comments on commit de6beb9

Please sign in to comment.