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
} }
} }
ResolvedUsingScope usingScope = new ResolvedUsingScope( UsingScope usingScope = new UsingScope(
new CSharpTypeResolveContext(typeSystem.MainModule), new CSharpTypeResolveContext(typeSystem.MainModule),
typeSystem.RootNamespace, typeSystem.RootNamespace,
resolvedNamespaces.ToImmutableArray() resolvedNamespaces.ToImmutableArray()

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

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

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

@ -495,7 +495,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
// Look if there's an alias to the target type // Look if there's an alias to the target type
if (UseAliases) 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) foreach (var pair in usingScope.UsingAliases)
{ {
@ -643,7 +643,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
// Look if there's an alias to the target namespace // Look if there's an alias to the target namespace
if (UseAliases) 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) foreach (var pair in usingScope.UsingAliases)
{ {

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

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

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

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

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

@ -25,12 +25,12 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem
public sealed class CSharpTypeResolveContext : ITypeResolveContext public sealed class CSharpTypeResolveContext : ITypeResolveContext
{ {
readonly IModule module; readonly IModule module;
readonly ResolvedUsingScope currentUsingScope; readonly UsingScope currentUsingScope;
readonly ITypeDefinition currentTypeDefinition; readonly ITypeDefinition currentTypeDefinition;
readonly IMember currentMember; readonly IMember currentMember;
readonly string[] methodTypeParameterNames; 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) if (module == null)
throw new ArgumentNullException(nameof(module)); throw new ArgumentNullException(nameof(module));
@ -40,7 +40,7 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem
this.currentMember = member; 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.module = module;
this.currentUsingScope = usingScope; this.currentUsingScope = usingScope;
@ -49,7 +49,7 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem
this.methodTypeParameterNames = methodTypeParameterNames; this.methodTypeParameterNames = methodTypeParameterNames;
} }
public ResolvedUsingScope CurrentUsingScope { public UsingScope CurrentUsingScope {
get { return currentUsingScope; } get { return currentUsingScope; }
} }
@ -89,7 +89,7 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem
return WithCurrentMember(member); return WithCurrentMember(member);
} }
public CSharpTypeResolveContext WithUsingScope(ResolvedUsingScope usingScope) public CSharpTypeResolveContext WithUsingScope(UsingScope usingScope)
{ {
return new CSharpTypeResolveContext(module, usingScope, currentTypeDefinition, currentMember, methodTypeParameterNames); 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
/// Represents a scope that contains "using" statements. /// Represents a scope that contains "using" statements.
/// This is either the mo itself, or a namespace declaration. /// This is either the mo itself, or a namespace declaration.
/// </summary> /// </summary>
public class ResolvedUsingScope public class UsingScope
{ {
readonly CSharpTypeResolveContext parentContext; readonly CSharpTypeResolveContext parentContext;
internal readonly ConcurrentDictionary<string, ResolveResult> ResolveCache = new ConcurrentDictionary<string, ResolveResult>(); internal readonly ConcurrentDictionary<string, ResolveResult> ResolveCache = new ConcurrentDictionary<string, ResolveResult>();
internal List<List<IMethod>>? AllExtensionMethods; 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.parentContext = context ?? throw new ArgumentNullException(nameof(context));
this.Usings = usings; this.Usings = usings;
@ -50,7 +50,7 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem
public INamespace Namespace { get; } public INamespace Namespace { get; }
public ResolvedUsingScope Parent { public UsingScope Parent {
get { return parentContext.CurrentUsingScope; } get { return parentContext.CurrentUsingScope; }
} }
@ -66,10 +66,10 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem
/// </summary> /// </summary>
public bool HasAlias(string identifier) => false; 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); var ns = Namespace.GetChildNamespace(simpleName) ?? new DummyNamespace(Namespace, simpleName);
return new ResolvedUsingScope( return new UsingScope(
parentContext.WithUsingScope(this), parentContext.WithUsingScope(this),
ns, ns,
[]); []);

4
ICSharpCode.Decompiler/DecompileRun.cs

@ -37,9 +37,9 @@ namespace ICSharpCode.Decompiler
public Dictionary<ITypeDefinition, bool> TypeHierarchyIsKnown { get; } = new(); 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.Settings = settings ?? throw new ArgumentNullException(nameof(settings));
this.UsingScope = usingScope ?? throw new ArgumentNullException(nameof(usingScope)); this.UsingScope = usingScope ?? throw new ArgumentNullException(nameof(usingScope));

2
ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj

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

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

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

Loading…
Cancel
Save