5
// Mike Krüger <mkrueger@novell.com>
7
// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
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:
16
// The above copyright notice and this permission notice shall be included in
17
// all copies or substantial portions of the Software.
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
27
using System.Collections.Generic;
28
using ICSharpCode.NRefactory.TypeSystem;
30
namespace ICSharpCode.NRefactory.CSharp
32
public class EventDeclaration : EntityDeclaration
34
public static readonly TokenRole EventKeywordRole = new TokenRole ("event");
36
public override EntityType EntityType {
37
get { return EntityType.Event; }
40
public AstNodeCollection<VariableInitializer> Variables {
41
get { return GetChildrenByRole (Roles.Variable); }
44
public override void AcceptVisitor (IAstVisitor visitor)
46
visitor.VisitEventDeclaration (this);
49
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
51
return visitor.VisitEventDeclaration (this);
54
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
56
return visitor.VisitEventDeclaration (this, data);
59
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
61
EventDeclaration o = other as EventDeclaration;
62
return o != null && this.MatchAttributesAndModifiers(o, match)
63
&& this.ReturnType.DoMatch(o.ReturnType, match) && this.Variables.DoMatch(o.Variables, match);
67
public class CustomEventDeclaration : EntityDeclaration
69
public static readonly TokenRole EventKeywordRole = new TokenRole ("event");
70
public static readonly TokenRole AddKeywordRole = new TokenRole ("add");
71
public static readonly TokenRole RemoveKeywordRole = new TokenRole ("remove");
73
public static readonly Role<Accessor> AddAccessorRole = new Role<Accessor>("AddAccessor", Accessor.Null);
74
public static readonly Role<Accessor> RemoveAccessorRole = new Role<Accessor>("RemoveAccessor", Accessor.Null);
76
public override EntityType EntityType {
77
get { return EntityType.Event; }
81
/// Gets/Sets the type reference of the interface that is explicitly implemented.
82
/// Null node if this member is not an explicit interface implementation.
84
public AstType PrivateImplementationType {
85
get { return GetChildByRole (PrivateImplementationTypeRole); }
86
set { SetChildByRole (PrivateImplementationTypeRole, value); }
89
public CSharpTokenNode LBraceToken {
90
get { return GetChildByRole (Roles.LBrace); }
93
public Accessor AddAccessor {
94
get { return GetChildByRole (AddAccessorRole); }
95
set { SetChildByRole (AddAccessorRole, value); }
98
public Accessor RemoveAccessor {
99
get { return GetChildByRole (RemoveAccessorRole); }
100
set { SetChildByRole (RemoveAccessorRole, value); }
103
public CSharpTokenNode RBraceToken {
104
get { return GetChildByRole (Roles.RBrace); }
107
public override void AcceptVisitor (IAstVisitor visitor)
109
visitor.VisitCustomEventDeclaration (this);
112
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
114
return visitor.VisitCustomEventDeclaration (this);
117
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
119
return visitor.VisitCustomEventDeclaration (this, data);
122
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
124
CustomEventDeclaration o = other as CustomEventDeclaration;
125
return o != null && MatchString(this.Name, o.Name)
126
&& this.MatchAttributesAndModifiers(o, match) && this.ReturnType.DoMatch(o.ReturnType, match)
127
&& this.PrivateImplementationType.DoMatch(o.PrivateImplementationType, match)
128
&& this.AddAccessor.DoMatch(o.AddAccessor, match) && this.RemoveAccessor.DoMatch(o.RemoveAccessor, match);