📄
core/src/ImmutableDictionaryExtensions.cs
using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; using Microsoft.CodeAnalysis; namespace Cfa; internal static class ImmutableDictionaryExtensions { public static IEnumerable<KeyValuePair<ISymbol, IImmutableList<Call>>> Invert( this ImmutableDictionary<ISymbol, IImmutableList<Call>>.Builder builder ) => builder .SelectMany(kvp => kvp.Value.Select(call => (from: kvp.Key, to: call.Target, kind: call.LinkKind))) .GroupBy(x => x.to, SymbolEqualityComparer.Default) .Select(g => KeyValuePair.Create(g.Key, (IImmutableList<Call>)[.. g.Select(x => new Call(x.from, x.kind))]) ); }