Files
sbox-public/engine/Sandbox.Compiling/Compiler/Compiler.Blacklist.cs
Sol Williams 6668270f7b Incremental compiles: smarter processing, syntax tree reuse (#4011)
Avoids unnecessary reparsing and allocations by reusing identical trees, and running generators only on what's been modified, significantly reducing incremental compile times for small changes in large codebases.
2026-02-19 14:29:56 +00:00

31 lines
720 B
C#

using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using System.Collections.Concurrent;
namespace Sandbox;
partial class Compiler
{
private void RunBlacklistWalker( CSharpCompilation compiler, IEnumerable<SyntaxTree> syntaxTrees, CompilerOutput output )
{
if ( !syntaxTrees.Any() )
{
return;
}
ConcurrentBag<Diagnostic> diagnostics = new();
var result = System.Threading.Tasks.Parallel.ForEach( syntaxTrees, tree =>
{
var semanticModel = compiler.GetSemanticModel( tree );
var walker = new BlacklistCodeWalker( semanticModel );
walker.Visit( tree.GetRoot() );
walker.Diagnostics.ForEach( diagnostics.Add );
} );
output.Diagnostics.AddRange( diagnostics );
}
}