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

« back to all changes in this revision

Viewing changes to external/nrefactory/ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/EventDeclaration.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
// EventDeclaration.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 System;
 
28
using System.Collections.Generic;
 
29
using System.ComponentModel;
 
30
 
 
31
using ICSharpCode.NRefactory.TypeSystem;
 
32
 
 
33
namespace ICSharpCode.NRefactory.CSharp
 
34
{
 
35
        public class EventDeclaration : EntityDeclaration
 
36
        {
 
37
                public static readonly TokenRole EventKeywordRole = new TokenRole ("event");
 
38
                
 
39
                public override EntityType EntityType {
 
40
                        get { return EntityType.Event; }
 
41
                }
 
42
                
 
43
                public AstNodeCollection<VariableInitializer> Variables {
 
44
                        get { return GetChildrenByRole (Roles.Variable); }
 
45
                }
 
46
                
 
47
                // Hide .Name and .NameToken from users; the actual field names
 
48
                // are stored in the VariableInitializer.
 
49
                [EditorBrowsable(EditorBrowsableState.Never)]
 
50
                public override string Name {
 
51
                        get { return string.Empty; }
 
52
                        set { throw new NotSupportedException(); }
 
53
                }
 
54
                
 
55
                [EditorBrowsable(EditorBrowsableState.Never)]
 
56
                public override Identifier NameToken {
 
57
                        get { return Identifier.Null; }
 
58
                        set { throw new NotSupportedException(); }
 
59
                }
 
60
                
 
61
                public override void AcceptVisitor (IAstVisitor visitor)
 
62
                {
 
63
                        visitor.VisitEventDeclaration (this);
 
64
                }
 
65
                        
 
66
                public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
 
67
                {
 
68
                        return visitor.VisitEventDeclaration (this);
 
69
                }
 
70
 
 
71
                public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
 
72
                {
 
73
                        return visitor.VisitEventDeclaration (this, data);
 
74
                }
 
75
                
 
76
                protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
 
77
                {
 
78
                        EventDeclaration o = other as EventDeclaration;
 
79
                        return o != null && this.MatchAttributesAndModifiers(o, match)
 
80
                                && this.ReturnType.DoMatch(o.ReturnType, match) && this.Variables.DoMatch(o.Variables, match);
 
81
                }
 
82
        }
 
83
        
 
84
        public class CustomEventDeclaration : EntityDeclaration
 
85
        {
 
86
                public static readonly TokenRole EventKeywordRole = new TokenRole ("event");
 
87
                public static readonly TokenRole AddKeywordRole = new TokenRole ("add");
 
88
                public static readonly TokenRole RemoveKeywordRole = new TokenRole ("remove");
 
89
                
 
90
                public static readonly Role<Accessor> AddAccessorRole = new Role<Accessor>("AddAccessor", Accessor.Null);
 
91
                public static readonly Role<Accessor> RemoveAccessorRole = new Role<Accessor>("RemoveAccessor", Accessor.Null);
 
92
                
 
93
                public override EntityType EntityType {
 
94
                        get { return EntityType.Event; }
 
95
                }
 
96
                
 
97
                /// <summary>
 
98
                /// Gets/Sets the type reference of the interface that is explicitly implemented.
 
99
                /// Null node if this member is not an explicit interface implementation.
 
100
                /// </summary>
 
101
                public AstType PrivateImplementationType {
 
102
                        get { return GetChildByRole (PrivateImplementationTypeRole); }
 
103
                        set { SetChildByRole (PrivateImplementationTypeRole, value); }
 
104
                }
 
105
                
 
106
                public CSharpTokenNode LBraceToken {
 
107
                        get { return GetChildByRole (Roles.LBrace); }
 
108
                }
 
109
                
 
110
                public Accessor AddAccessor {
 
111
                        get { return GetChildByRole (AddAccessorRole); }
 
112
                        set { SetChildByRole (AddAccessorRole, value); }
 
113
                }
 
114
                
 
115
                public Accessor RemoveAccessor {
 
116
                        get { return GetChildByRole (RemoveAccessorRole); }
 
117
                        set { SetChildByRole (RemoveAccessorRole, value); }
 
118
                }
 
119
                
 
120
                public CSharpTokenNode RBraceToken {
 
121
                        get { return GetChildByRole (Roles.RBrace); }
 
122
                }
 
123
                
 
124
                public override void AcceptVisitor (IAstVisitor visitor)
 
125
                {
 
126
                        visitor.VisitCustomEventDeclaration (this);
 
127
                }
 
128
                        
 
129
                public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
 
130
                {
 
131
                        return visitor.VisitCustomEventDeclaration (this);
 
132
                }
 
133
 
 
134
                public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
 
135
                {
 
136
                        return visitor.VisitCustomEventDeclaration (this, data);
 
137
                }
 
138
                
 
139
                protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
 
140
                {
 
141
                        CustomEventDeclaration o = other as CustomEventDeclaration;
 
142
                        return o != null && MatchString(this.Name, o.Name)
 
143
                                && this.MatchAttributesAndModifiers(o, match) && this.ReturnType.DoMatch(o.ReturnType, match)
 
144
                                && this.PrivateImplementationType.DoMatch(o.PrivateImplementationType, match)
 
145
                                && this.AddAccessor.DoMatch(o.AddAccessor, match) && this.RemoveAccessor.DoMatch(o.RemoveAccessor, match);
 
146
                }
 
147
        }
 
148
}