128 lines
3.4 KiB
C#
128 lines
3.4 KiB
C#
using System.Collections.Immutable;
|
|
using System.Threading;
|
|
using Microsoft.CodeAnalysis.CSharp.Symbols.PublicModel;
|
|
using Microsoft.CodeAnalysis.Text;
|
|
using Roslyn.Utilities;
|
|
|
|
namespace Microsoft.CodeAnalysis.CSharp.Symbols;
|
|
|
|
internal class RangeVariableSymbol : Symbol
|
|
{
|
|
private readonly string _name;
|
|
|
|
private readonly Location? _location;
|
|
|
|
private readonly Symbol _containingSymbol;
|
|
|
|
internal bool IsTransparent { get; }
|
|
|
|
public override string Name => _name;
|
|
|
|
public override SymbolKind Kind => (SymbolKind)16;
|
|
|
|
public override ImmutableArray<Location> Locations
|
|
{
|
|
get
|
|
{
|
|
if (_location != null)
|
|
{
|
|
return ImmutableArray.Create<Location>(_location);
|
|
}
|
|
return ImmutableArray<Location>.Empty;
|
|
}
|
|
}
|
|
|
|
public override ImmutableArray<SyntaxReference> DeclaringSyntaxReferences
|
|
{
|
|
get
|
|
{
|
|
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
|
|
if (_location == null)
|
|
{
|
|
return ImmutableArray<SyntaxReference>.Empty;
|
|
}
|
|
SyntaxNode root = _location.SourceTree.GetRoot(default(CancellationToken));
|
|
TextSpan sourceSpan = _location.SourceSpan;
|
|
SyntaxToken val = root.FindToken(((TextSpan)(ref sourceSpan)).Start, false);
|
|
return ImmutableArray.Create<SyntaxReference>(((SyntaxToken)(ref val)).Parent.GetReference());
|
|
}
|
|
}
|
|
|
|
public override bool IsExtern => false;
|
|
|
|
public override bool IsSealed => false;
|
|
|
|
public override bool IsAbstract => false;
|
|
|
|
public override bool IsOverride => false;
|
|
|
|
public override bool IsVirtual => false;
|
|
|
|
public override bool IsStatic => false;
|
|
|
|
internal sealed override ObsoleteAttributeData? ObsoleteAttributeData => null;
|
|
|
|
public override Accessibility DeclaredAccessibility => (Accessibility)0;
|
|
|
|
public override Symbol ContainingSymbol => _containingSymbol;
|
|
|
|
internal RangeVariableSymbol(string Name, Symbol containingSymbol, Location? location, bool isTransparent = false)
|
|
{
|
|
_name = Name;
|
|
_containingSymbol = containingSymbol;
|
|
_location = location;
|
|
IsTransparent = isTransparent;
|
|
}
|
|
|
|
public override Location? TryGetFirstLocation()
|
|
{
|
|
return _location;
|
|
}
|
|
|
|
internal override TResult Accept<TArg, TResult>(CSharpSymbolVisitor<TArg, TResult> visitor, TArg a)
|
|
{
|
|
return visitor.VisitRangeVariable(this, a);
|
|
}
|
|
|
|
public override void Accept(CSharpSymbolVisitor visitor)
|
|
{
|
|
visitor.VisitRangeVariable(this);
|
|
}
|
|
|
|
public override TResult Accept<TResult>(CSharpSymbolVisitor<TResult> visitor)
|
|
{
|
|
return visitor.VisitRangeVariable(this);
|
|
}
|
|
|
|
public override bool Equals(Symbol obj, TypeCompareKind compareKind)
|
|
{
|
|
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
|
|
if ((object)obj == this)
|
|
{
|
|
return true;
|
|
}
|
|
if (_location == null)
|
|
{
|
|
return false;
|
|
}
|
|
if (obj is RangeVariableSymbol rangeVariableSymbol && ((object)_location).Equals((object?)rangeVariableSymbol._location))
|
|
{
|
|
return _containingSymbol.Equals(rangeVariableSymbol.ContainingSymbol, compareKind);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return Hash.Combine(((object)_location)?.GetHashCode() ?? 0, _containingSymbol.GetHashCode());
|
|
}
|
|
|
|
protected override ISymbol CreateISymbol()
|
|
{
|
|
return (ISymbol)(object)new Microsoft.CodeAnalysis.CSharp.Symbols.PublicModel.RangeVariableSymbol(this);
|
|
}
|
|
}
|