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

« back to all changes in this revision

Viewing changes to contrib/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/ConstructorDeclaration.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
 
// 
2
 
// ConstructorDeclaration.cs
3
 
//
4
 
// Author:
5
 
//       Mike Krüger <mkrueger@novell.com>
6
 
// 
7
 
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
8
 
// 
9
 
// Permission is hereby granted, free of charge, to any person obtaining a copy
10
 
// of this software and associated documentation files (the "Software"), to deal
11
 
// in the Software without restriction, including without limitation the rights
12
 
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
 
// copies of the Software, and to permit persons to whom the Software is
14
 
// furnished to do so, subject to the following conditions:
15
 
// 
16
 
// The above copyright notice and this permission notice shall be included in
17
 
// all copies or substantial portions of the Software.
18
 
// 
19
 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
 
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
 
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
 
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
 
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
 
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25
 
// THE SOFTWARE.
26
 
 
27
 
using ICSharpCode.NRefactory.TypeSystem;
28
 
 
29
 
namespace ICSharpCode.NRefactory.CSharp
30
 
{
31
 
        public class ConstructorDeclaration : EntityDeclaration
32
 
        {
33
 
                public static readonly Role<ConstructorInitializer> InitializerRole = new Role<ConstructorInitializer>("Initializer", ConstructorInitializer.Null);
34
 
                
35
 
                public override EntityType EntityType {
36
 
                        get { return EntityType.Constructor; }
37
 
                }
38
 
                
39
 
                public CSharpTokenNode LParToken {
40
 
                        get { return GetChildByRole (Roles.LPar); }
41
 
                }
42
 
                
43
 
                public AstNodeCollection<ParameterDeclaration> Parameters {
44
 
                        get { return GetChildrenByRole (Roles.Parameter); }
45
 
                }
46
 
                
47
 
                public CSharpTokenNode RParToken {
48
 
                        get { return GetChildByRole (Roles.RPar); }
49
 
                }
50
 
                
51
 
                public CSharpTokenNode ColonToken {
52
 
                        get { return GetChildByRole (Roles.Colon); }
53
 
                }
54
 
                
55
 
                public ConstructorInitializer Initializer {
56
 
                        get { return GetChildByRole (InitializerRole); }
57
 
                        set { SetChildByRole( InitializerRole, value); }
58
 
                }
59
 
                
60
 
                public BlockStatement Body {
61
 
                        get { return GetChildByRole (Roles.Body); }
62
 
                        set { SetChildByRole (Roles.Body, value); }
63
 
                }
64
 
                
65
 
                public override void AcceptVisitor (IAstVisitor visitor)
66
 
                {
67
 
                        visitor.VisitConstructorDeclaration (this);
68
 
                }
69
 
                        
70
 
                public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
71
 
                {
72
 
                        return visitor.VisitConstructorDeclaration (this);
73
 
                }
74
 
                
75
 
                public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
76
 
                {
77
 
                        return visitor.VisitConstructorDeclaration (this, data);
78
 
                }
79
 
                
80
 
                protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
81
 
                {
82
 
                        ConstructorDeclaration o = other as ConstructorDeclaration;
83
 
                        return o != null && this.MatchAttributesAndModifiers(o, match) && this.Parameters.DoMatch(o.Parameters, match)
84
 
                                && this.Initializer.DoMatch(o.Initializer, match) && this.Body.DoMatch(o.Body, match);
85
 
                }
86
 
        }
87
 
        
88
 
        public enum ConstructorInitializerType {
89
 
                Base,
90
 
                This
91
 
        }
92
 
        
93
 
        public class ConstructorInitializer : AstNode
94
 
        {
95
 
                public static readonly TokenRole BaseKeywordRole = new TokenRole ("base");
96
 
                public static readonly TokenRole ThisKeywordRole = new TokenRole ("this");
97
 
                
98
 
                public static readonly new ConstructorInitializer Null = new NullConstructorInitializer ();
99
 
                class NullConstructorInitializer : ConstructorInitializer
100
 
                {
101
 
                        public override NodeType NodeType {
102
 
                                get {
103
 
                                        return NodeType.Unknown;
104
 
                                }
105
 
                        }
106
 
                        
107
 
                        public override bool IsNull {
108
 
                                get {
109
 
                                        return true;
110
 
                                }
111
 
                        }
112
 
                        
113
 
                        public override void AcceptVisitor (IAstVisitor visitor)
114
 
                        {
115
 
                        }
116
 
                                
117
 
                        public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
118
 
                        {
119
 
                                return default (T);
120
 
                        }
121
 
                        
122
 
                        public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
123
 
                        {
124
 
                                return default (S);
125
 
                        }
126
 
                        
127
 
                        protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
128
 
                        {
129
 
                                return other == null || other.IsNull;
130
 
                        }
131
 
                }
132
 
                
133
 
                public override NodeType NodeType {
134
 
                        get {
135
 
                                return NodeType.Unknown;
136
 
                        }
137
 
                }
138
 
                
139
 
                public ConstructorInitializerType ConstructorInitializerType {
140
 
                        get;
141
 
                        set;
142
 
                }
143
 
                
144
 
                public CSharpTokenNode LParToken {
145
 
                        get { return GetChildByRole (Roles.LPar); }
146
 
                }
147
 
                
148
 
                public AstNodeCollection<Expression> Arguments {
149
 
                        get { return GetChildrenByRole (Roles.Argument); }
150
 
                }
151
 
                
152
 
                public CSharpTokenNode RParToken {
153
 
                        get { return GetChildByRole (Roles.RPar); }
154
 
                }
155
 
                
156
 
                public override void AcceptVisitor (IAstVisitor visitor)
157
 
                {
158
 
                        visitor.VisitConstructorInitializer (this);
159
 
                }
160
 
                        
161
 
                public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
162
 
                {
163
 
                        return visitor.VisitConstructorInitializer (this);
164
 
                }
165
 
                
166
 
                public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
167
 
                {
168
 
                        return visitor.VisitConstructorInitializer (this, data);
169
 
                }
170
 
                
171
 
                protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
172
 
                {
173
 
                        ConstructorInitializer o = other as ConstructorInitializer;
174
 
                        return o != null && !o.IsNull && this.ConstructorInitializerType == o.ConstructorInitializerType && this.Arguments.DoMatch(o.Arguments, match);
175
 
                }
176
 
        }
177
 
}