59 lines
2.5 KiB
C#
59 lines
2.5 KiB
C#
using System.Collections.Immutable;
|
|
using Microsoft.CodeAnalysis.CSharp.Symbols;
|
|
using Microsoft.CodeAnalysis.PooledObjects;
|
|
using Roslyn.Utilities;
|
|
|
|
namespace Microsoft.CodeAnalysis.CSharp;
|
|
|
|
internal static class SymbolInfoFactory
|
|
{
|
|
internal static SymbolInfo Create(ImmutableArray<Symbol> symbols, LookupResultKind resultKind, bool isDynamic)
|
|
{
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
|
|
return Create(OneOrMany.Create<Symbol>(ImmutableArrayExtensions.NullToEmpty<Symbol>(symbols)), resultKind, isDynamic);
|
|
}
|
|
|
|
internal static SymbolInfo Create(OneOrMany<Symbol> symbols, LookupResultKind resultKind, bool isDynamic)
|
|
{
|
|
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
|
|
if (isDynamic)
|
|
{
|
|
if (symbols.Count == 1)
|
|
{
|
|
return new SymbolInfo(symbols[0].GetPublicSymbol(), (CandidateReason)14);
|
|
}
|
|
return new SymbolInfo(getPublicSymbols(symbols), (CandidateReason)14);
|
|
}
|
|
if (resultKind == LookupResultKind.Viable)
|
|
{
|
|
if (symbols.Count > 0)
|
|
{
|
|
return new SymbolInfo(symbols[0].GetPublicSymbol());
|
|
}
|
|
return SymbolInfo.None;
|
|
}
|
|
return new SymbolInfo(getPublicSymbols(symbols), (CandidateReason)((symbols.Count > 0) ? ((int)resultKind.ToCandidateReason()) : 0));
|
|
static ImmutableArray<ISymbol> getPublicSymbols(OneOrMany<Symbol> val)
|
|
{
|
|
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
|
|
ArrayBuilder<ISymbol> instance = ArrayBuilder<ISymbol>.GetInstance(val.Count);
|
|
Enumerator<Symbol> enumerator = val.GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
Symbol current = enumerator.Current;
|
|
instance.Add(current.GetPublicSymbol());
|
|
}
|
|
return instance.ToImmutableAndFree();
|
|
}
|
|
}
|
|
}
|