Browse Source

Rename ResolvedUsingScope to UsingScope

pull/3532/head
Siegfried Pammer 11 months ago
parent
commit
9dde97414a
  1. 2
      ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs
  2. 14
      ICSharpCode.Decompiler/CSharp/Resolver/CSharpResolver.cs
  3. 4
      ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs
  4. 4
      ICSharpCode.Decompiler/CSharp/Transforms/IntroduceExtensionMethods.cs
  5. 4
      ICSharpCode.Decompiler/CSharp/Transforms/IntroduceUsingDeclarations.cs
  6. 10
      ICSharpCode.Decompiler/CSharp/TypeSystem/CSharpTypeResolveContext.cs
  7. 10
      ICSharpCode.Decompiler/CSharp/TypeSystem/UsingScope.cs
  8. 4
      ICSharpCode.Decompiler/DecompileRun.cs
  9. 2
      ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj
  10. 2
      ICSharpCode.Decompiler/IL/Transforms/IILTransform.cs

2
ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs

@ -532,7 +532,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -532,7 +532,7 @@ namespace ICSharpCode.Decompiler.CSharp
}
}
ResolvedUsingScope usingScope = new ResolvedUsingScope(
UsingScope usingScope = new UsingScope(
new CSharpTypeResolveContext(typeSystem.MainModule),
typeSystem.RootNamespace,
resolvedNamespaces.ToImmutableArray()

14
ICSharpCode.Decompiler/CSharp/Resolver/CSharpResolver.cs

@ -162,14 +162,14 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -162,14 +162,14 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
/// <summary>
/// Gets the current using scope that is used to look up identifiers as class names.
/// </summary>
public ResolvedUsingScope CurrentUsingScope {
public UsingScope CurrentUsingScope {
get { return context.CurrentUsingScope; }
}
/// <summary>
/// Sets the current using scope that is used to look up identifiers as class names.
/// </summary>
public CSharpResolver WithCurrentUsingScope(ResolvedUsingScope usingScope)
public CSharpResolver WithCurrentUsingScope(UsingScope usingScope)
{
return WithContext(context.WithUsingScope(usingScope));
}
@ -1656,8 +1656,8 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -1656,8 +1656,8 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
ResolveResult LookInCurrentUsingScope(string identifier, IReadOnlyList<IType> typeArguments, bool isInUsingDeclaration, bool parameterizeResultType)
{
// look in current namespace definitions
ResolvedUsingScope currentUsingScope = this.CurrentUsingScope;
for (ResolvedUsingScope u = currentUsingScope; u != null; u = u.Parent)
UsingScope currentUsingScope = this.CurrentUsingScope;
for (UsingScope u = currentUsingScope; u != null; u = u.Parent)
{
var resultInNamespace = LookInUsingScopeNamespace(u, u.Namespace, identifier, typeArguments, parameterizeResultType);
if (resultInNamespace != null)
@ -1714,7 +1714,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -1714,7 +1714,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
return null;
}
ResolveResult LookInUsingScopeNamespace(ResolvedUsingScope usingScope, INamespace n, string identifier, IReadOnlyList<IType> typeArguments, bool parameterizeResultType)
ResolveResult LookInUsingScopeNamespace(UsingScope usingScope, INamespace n, string identifier, IReadOnlyList<IType> typeArguments, bool parameterizeResultType)
{
if (n == null)
return null;
@ -1764,7 +1764,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -1764,7 +1764,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
if (identifier == "global")
return new NamespaceResolveResult(compilation.RootNamespace);
for (ResolvedUsingScope n = this.CurrentUsingScope; n != null; n = n.Parent)
for (UsingScope n = this.CurrentUsingScope; n != null; n = n.Parent)
{
if (n.ExternAliases.Contains(identifier))
{
@ -2190,7 +2190,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -2190,7 +2190,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
}
extensionMethodGroups = new List<List<IMethod>>();
List<IMethod> m;
for (ResolvedUsingScope scope = currentUsingScope; scope != null; scope = scope.Parent)
for (UsingScope scope = currentUsingScope; scope != null; scope = scope.Parent)
{
INamespace ns = scope.Namespace;
if (ns != null)

4
ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs

@ -495,7 +495,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -495,7 +495,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
// Look if there's an alias to the target type
if (UseAliases)
{
for (ResolvedUsingScope usingScope = resolver.CurrentUsingScope; usingScope != null; usingScope = usingScope.Parent)
for (UsingScope usingScope = resolver.CurrentUsingScope; usingScope != null; usingScope = usingScope.Parent)
{
foreach (var pair in usingScope.UsingAliases)
{
@ -643,7 +643,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -643,7 +643,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
// Look if there's an alias to the target namespace
if (UseAliases)
{
for (ResolvedUsingScope usingScope = resolver.CurrentUsingScope; usingScope != null; usingScope = usingScope.Parent)
for (UsingScope usingScope = resolver.CurrentUsingScope; usingScope != null; usingScope = usingScope.Parent)
{
foreach (var pair in usingScope.UsingAliases)
{

4
ICSharpCode.Decompiler/CSharp/Transforms/IntroduceExtensionMethods.cs

@ -42,11 +42,11 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -42,11 +42,11 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
{
this.context = context;
this.conversions = CSharpConversions.Get(context.TypeSystem);
InitializeContext(rootNode.Annotation<ResolvedUsingScope>());
InitializeContext(rootNode.Annotation<UsingScope>());
rootNode.AcceptVisitor(this);
}
void InitializeContext(ResolvedUsingScope usingScope)
void InitializeContext(UsingScope usingScope)
{
if (!string.IsNullOrEmpty(context.CurrentTypeDefinition?.Namespace))
{

4
ICSharpCode.Decompiler/CSharp/Transforms/IntroduceUsingDeclarations.cs

@ -73,7 +73,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -73,7 +73,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
}
}
var usingScope = new ResolvedUsingScope(
var usingScope = new UsingScope(
new CSharpTypeResolveContext(context.TypeSystem.MainModule),
context.TypeSystem.RootNamespace,
resolvedNamespaces.ToImmutableArray()
@ -189,7 +189,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -189,7 +189,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
CSharpResolver resolver;
TypeSystemAstBuilder astBuilder;
public FullyQualifyAmbiguousTypeNamesVisitor(TransformContext context, ResolvedUsingScope usingScope)
public FullyQualifyAmbiguousTypeNamesVisitor(TransformContext context, UsingScope usingScope)
{
this.ignoreUsingScope = !context.Settings.UsingDeclarations;
this.settings = context.Settings;

10
ICSharpCode.Decompiler/CSharp/TypeSystem/CSharpTypeResolveContext.cs

@ -25,12 +25,12 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem @@ -25,12 +25,12 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem
public sealed class CSharpTypeResolveContext : ITypeResolveContext
{
readonly IModule module;
readonly ResolvedUsingScope currentUsingScope;
readonly UsingScope currentUsingScope;
readonly ITypeDefinition currentTypeDefinition;
readonly IMember currentMember;
readonly string[] methodTypeParameterNames;
public CSharpTypeResolveContext(IModule module, ResolvedUsingScope usingScope = null, ITypeDefinition typeDefinition = null, IMember member = null)
public CSharpTypeResolveContext(IModule module, UsingScope usingScope = null, ITypeDefinition typeDefinition = null, IMember member = null)
{
if (module == null)
throw new ArgumentNullException(nameof(module));
@ -40,7 +40,7 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem @@ -40,7 +40,7 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem
this.currentMember = member;
}
private CSharpTypeResolveContext(IModule module, ResolvedUsingScope usingScope, ITypeDefinition typeDefinition, IMember member, string[] methodTypeParameterNames)
private CSharpTypeResolveContext(IModule module, UsingScope usingScope, ITypeDefinition typeDefinition, IMember member, string[] methodTypeParameterNames)
{
this.module = module;
this.currentUsingScope = usingScope;
@ -49,7 +49,7 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem @@ -49,7 +49,7 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem
this.methodTypeParameterNames = methodTypeParameterNames;
}
public ResolvedUsingScope CurrentUsingScope {
public UsingScope CurrentUsingScope {
get { return currentUsingScope; }
}
@ -89,7 +89,7 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem @@ -89,7 +89,7 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem
return WithCurrentMember(member);
}
public CSharpTypeResolveContext WithUsingScope(ResolvedUsingScope usingScope)
public CSharpTypeResolveContext WithUsingScope(UsingScope usingScope)
{
return new CSharpTypeResolveContext(module, usingScope, currentTypeDefinition, currentMember, methodTypeParameterNames);
}

10
ICSharpCode.Decompiler/CSharp/TypeSystem/ResolvedUsingScope.cs → ICSharpCode.Decompiler/CSharp/TypeSystem/UsingScope.cs

@ -34,14 +34,14 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem @@ -34,14 +34,14 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem
/// Represents a scope that contains "using" statements.
/// This is either the mo itself, or a namespace declaration.
/// </summary>
public class ResolvedUsingScope
public class UsingScope
{
readonly CSharpTypeResolveContext parentContext;
internal readonly ConcurrentDictionary<string, ResolveResult> ResolveCache = new ConcurrentDictionary<string, ResolveResult>();
internal List<List<IMethod>>? AllExtensionMethods;
public ResolvedUsingScope(CSharpTypeResolveContext context, INamespace @namespace, ImmutableArray<INamespace> usings)
public UsingScope(CSharpTypeResolveContext context, INamespace @namespace, ImmutableArray<INamespace> usings)
{
this.parentContext = context ?? throw new ArgumentNullException(nameof(context));
this.Usings = usings;
@ -50,7 +50,7 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem @@ -50,7 +50,7 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem
public INamespace Namespace { get; }
public ResolvedUsingScope Parent {
public UsingScope Parent {
get { return parentContext.CurrentUsingScope; }
}
@ -66,10 +66,10 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem @@ -66,10 +66,10 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem
/// </summary>
public bool HasAlias(string identifier) => false;
internal ResolvedUsingScope WithNestedNamespace(string simpleName)
internal UsingScope WithNestedNamespace(string simpleName)
{
var ns = Namespace.GetChildNamespace(simpleName) ?? new DummyNamespace(Namespace, simpleName);
return new ResolvedUsingScope(
return new UsingScope(
parentContext.WithUsingScope(this),
ns,
[]);

4
ICSharpCode.Decompiler/DecompileRun.cs

@ -37,9 +37,9 @@ namespace ICSharpCode.Decompiler @@ -37,9 +37,9 @@ namespace ICSharpCode.Decompiler
public Dictionary<ITypeDefinition, bool> TypeHierarchyIsKnown { get; } = new();
public CSharp.TypeSystem.ResolvedUsingScope UsingScope { get; }
public CSharp.TypeSystem.UsingScope UsingScope { get; }
public DecompileRun(DecompilerSettings settings, CSharp.TypeSystem.ResolvedUsingScope usingScope)
public DecompileRun(DecompilerSettings settings, CSharp.TypeSystem.UsingScope usingScope)
{
this.Settings = settings ?? throw new ArgumentNullException(nameof(settings));
this.UsingScope = usingScope ?? throw new ArgumentNullException(nameof(usingScope));

2
ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj

@ -338,7 +338,7 @@ @@ -338,7 +338,7 @@
<Compile Include="CSharp\TypeSystem\AliasNamespaceReference.cs" />
<Compile Include="CSharp\TypeSystem\CSharpTypeResolveContext.cs" />
<Compile Include="CSharp\TypeSystem\MemberTypeOrNamespaceReference.cs" />
<Compile Include="CSharp\TypeSystem\ResolvedUsingScope.cs" />
<Compile Include="CSharp\TypeSystem\UsingScope.cs" />
<Compile Include="CSharp\TypeSystem\SimpleTypeOrNamespaceReference.cs" />
<Compile Include="CSharp\TypeSystem\TypeOrNamespaceReference.cs" />
<Compile Include="DebugInfo\AsyncDebugInfo.cs" />

2
ICSharpCode.Decompiler/IL/Transforms/IILTransform.cs

@ -52,7 +52,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -52,7 +52,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
public Metadata.MetadataFile PEFile => TypeSystem.MainModule.MetadataFile;
internal DecompileRun? DecompileRun { get; set; }
internal ResolvedUsingScope? UsingScope => DecompileRun?.UsingScope;
internal UsingScope? UsingScope => DecompileRun?.UsingScope;
CSharpResolver? csharpResolver;

Loading…
Cancel
Save