1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
3
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
4
// software and associated documentation files (the "Software"), to deal in the Software
5
// without restriction, including without limitation the rights to use, copy, modify, merge,
6
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7
// to whom the Software is furnished to do so, subject to the following conditions:
9
// The above copyright notice and this permission notice shall be included in all copies or
10
// substantial portions of the Software.
12
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17
// DEALINGS IN THE SOFTWARE.
20
using ICSharpCode.NRefactory.TypeSystem;
22
namespace ICSharpCode.NRefactory.CSharp.TypeSystem
24
public sealed class CSharpTypeResolveContext : ITypeResolveContext
26
readonly IAssembly assembly;
27
readonly ResolvedUsingScope currentUsingScope;
28
readonly ITypeDefinition currentTypeDefinition;
29
readonly IMember currentMember;
30
readonly string[] methodTypeParameterNames;
32
public CSharpTypeResolveContext(IAssembly assembly, ResolvedUsingScope usingScope = null, ITypeDefinition typeDefinition = null, IMember member = null)
35
throw new ArgumentNullException("assembly");
36
this.assembly = assembly;
37
this.currentUsingScope = usingScope;
38
this.currentTypeDefinition = typeDefinition;
39
this.currentMember = member;
42
private CSharpTypeResolveContext(IAssembly assembly, ResolvedUsingScope usingScope, ITypeDefinition typeDefinition, IMember member, string[] methodTypeParameterNames)
44
this.assembly = assembly;
45
this.currentUsingScope = usingScope;
46
this.currentTypeDefinition = typeDefinition;
47
this.currentMember = member;
48
this.methodTypeParameterNames = methodTypeParameterNames;
51
public ResolvedUsingScope CurrentUsingScope {
52
get { return currentUsingScope; }
55
public ICompilation Compilation {
56
get { return assembly.Compilation; }
59
public IAssembly CurrentAssembly {
60
get { return assembly; }
63
public ITypeDefinition CurrentTypeDefinition {
64
get { return currentTypeDefinition; }
67
public IMember CurrentMember {
68
get { return currentMember; }
71
public CSharpTypeResolveContext WithCurrentTypeDefinition(ITypeDefinition typeDefinition)
73
return new CSharpTypeResolveContext(assembly, currentUsingScope, typeDefinition, currentMember, methodTypeParameterNames);
76
ITypeResolveContext ITypeResolveContext.WithCurrentTypeDefinition(ITypeDefinition typeDefinition)
78
return WithCurrentTypeDefinition(typeDefinition);
81
public CSharpTypeResolveContext WithCurrentMember(IMember member)
83
return new CSharpTypeResolveContext(assembly, currentUsingScope, currentTypeDefinition, member, methodTypeParameterNames);
86
ITypeResolveContext ITypeResolveContext.WithCurrentMember(IMember member)
88
return WithCurrentMember(member);
91
public CSharpTypeResolveContext WithUsingScope(ResolvedUsingScope usingScope)
93
return new CSharpTypeResolveContext(assembly, usingScope, currentTypeDefinition, currentMember, methodTypeParameterNames);