~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to contrib/ICSharpCode.NRefactory.CSharp/TypeSystem/CSharpTypeResolveContext.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
Import upstream version 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
2
 
// 
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:
8
 
// 
9
 
// The above copyright notice and this permission notice shall be included in all copies or
10
 
// substantial portions of the Software.
11
 
// 
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.
18
 
 
19
 
using System;
20
 
using ICSharpCode.NRefactory.TypeSystem;
21
 
 
22
 
namespace ICSharpCode.NRefactory.CSharp.TypeSystem
23
 
{
24
 
        public sealed class CSharpTypeResolveContext : ITypeResolveContext
25
 
        {
26
 
                readonly IAssembly assembly;
27
 
                readonly ResolvedUsingScope currentUsingScope;
28
 
                readonly ITypeDefinition currentTypeDefinition;
29
 
                readonly IMember currentMember;
30
 
                readonly string[] methodTypeParameterNames;
31
 
                
32
 
                public CSharpTypeResolveContext(IAssembly assembly, ResolvedUsingScope usingScope = null, ITypeDefinition typeDefinition = null, IMember member = null)
33
 
                {
34
 
                        if (assembly == null)
35
 
                                throw new ArgumentNullException("assembly");
36
 
                        this.assembly = assembly;
37
 
                        this.currentUsingScope = usingScope;
38
 
                        this.currentTypeDefinition = typeDefinition;
39
 
                        this.currentMember = member;
40
 
                }
41
 
                
42
 
                private CSharpTypeResolveContext(IAssembly assembly, ResolvedUsingScope usingScope, ITypeDefinition typeDefinition, IMember member, string[] methodTypeParameterNames)
43
 
                {
44
 
                        this.assembly = assembly;
45
 
                        this.currentUsingScope = usingScope;
46
 
                        this.currentTypeDefinition = typeDefinition;
47
 
                        this.currentMember = member;
48
 
                        this.methodTypeParameterNames = methodTypeParameterNames;
49
 
                }
50
 
                
51
 
                public ResolvedUsingScope CurrentUsingScope {
52
 
                        get { return currentUsingScope; }
53
 
                }
54
 
                
55
 
                public ICompilation Compilation {
56
 
                        get { return assembly.Compilation; }
57
 
                }
58
 
                
59
 
                public IAssembly CurrentAssembly {
60
 
                        get { return assembly; }
61
 
                }
62
 
                
63
 
                public ITypeDefinition CurrentTypeDefinition {
64
 
                        get { return currentTypeDefinition; }
65
 
                }
66
 
                
67
 
                public IMember CurrentMember {
68
 
                        get { return currentMember; }
69
 
                }
70
 
                
71
 
                public CSharpTypeResolveContext WithCurrentTypeDefinition(ITypeDefinition typeDefinition)
72
 
                {
73
 
                        return new CSharpTypeResolveContext(assembly, currentUsingScope, typeDefinition, currentMember, methodTypeParameterNames);
74
 
                }
75
 
                
76
 
                ITypeResolveContext ITypeResolveContext.WithCurrentTypeDefinition(ITypeDefinition typeDefinition)
77
 
                {
78
 
                        return WithCurrentTypeDefinition(typeDefinition);
79
 
                }
80
 
                
81
 
                public CSharpTypeResolveContext WithCurrentMember(IMember member)
82
 
                {
83
 
                        return new CSharpTypeResolveContext(assembly, currentUsingScope, currentTypeDefinition, member, methodTypeParameterNames);
84
 
                }
85
 
                
86
 
                ITypeResolveContext ITypeResolveContext.WithCurrentMember(IMember member)
87
 
                {
88
 
                        return WithCurrentMember(member);
89
 
                }
90
 
                
91
 
                public CSharpTypeResolveContext WithUsingScope(ResolvedUsingScope usingScope)
92
 
                {
93
 
                        return new CSharpTypeResolveContext(assembly, usingScope, currentTypeDefinition, currentMember, methodTypeParameterNames);
94
 
                }
95
 
        }
96
 
}