Skip to content

Commit

Permalink
Inline method
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrusNajmabadi committed Feb 24, 2024
1 parent 96fe6a3 commit 29a58dc
Showing 1 changed file with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,14 @@ internal sealed class AddDocumentsAction(
public readonly ImmutableArray<DocumentState> Documents = documents;

public override async Task<Compilation> TransformCompilationAsync(Compilation oldCompilation, CancellationToken cancellationToken)
{
var trees = await GetAllSyntaxTreesAsync(cancellationToken).ConfigureAwait(false);
return oldCompilation.AddSyntaxTrees(trees);
}

private async Task<SyntaxTree[]> GetAllSyntaxTreesAsync(CancellationToken cancellationToken)
{
// Parse all the documents in parallel.
using var _ = ArrayBuilder<Task<SyntaxTree>>.GetInstance(this.Documents.Length, out var tasks);
foreach (var document in this.Documents)
tasks.Add(Task.Run(async () => await document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false), cancellationToken));

return await Task.WhenAll(tasks).ConfigureAwait(false);
var trees = await Task.WhenAll(tasks).ConfigureAwait(false);
return oldCompilation.AddSyntaxTrees(trees);
}

// This action adds the specified trees, but leaves the generated trees untouched.
Expand Down

0 comments on commit 29a58dc

Please sign in to comment.