1 | // |
---|
2 | // PropertyDeclaration.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 | using ICSharpCode.NRefactory.TypeSystem; |
---|
27 | |
---|
28 | namespace ICSharpCode.NRefactory.CSharp |
---|
29 | { |
---|
30 | public class PropertyDeclaration : EntityDeclaration |
---|
31 | { |
---|
32 | public static readonly TokenRole GetKeywordRole = new TokenRole ("get"); |
---|
33 | public static readonly TokenRole SetKeywordRole = new TokenRole ("set"); |
---|
34 | public static readonly Role<Accessor> GetterRole = new Role<Accessor>("Getter", Accessor.Null); |
---|
35 | public static readonly Role<Accessor> SetterRole = new Role<Accessor>("Setter", Accessor.Null); |
---|
36 | |
---|
37 | public override SymbolKind SymbolKind { |
---|
38 | get { return SymbolKind.Property; } |
---|
39 | } |
---|
40 | |
---|
41 | /// <summary> |
---|
42 | /// Gets/Sets the type reference of the interface that is explicitly implemented. |
---|
43 | /// Null node if this member is not an explicit interface implementation. |
---|
44 | /// </summary> |
---|
45 | public AstType PrivateImplementationType { |
---|
46 | get { return GetChildByRole (PrivateImplementationTypeRole); } |
---|
47 | set { SetChildByRole (PrivateImplementationTypeRole, value); } |
---|
48 | } |
---|
49 | |
---|
50 | public CSharpTokenNode LBraceToken { |
---|
51 | get { return GetChildByRole (Roles.LBrace); } |
---|
52 | } |
---|
53 | |
---|
54 | public Accessor Getter { |
---|
55 | get { return GetChildByRole(GetterRole); } |
---|
56 | set { SetChildByRole(GetterRole, value); } |
---|
57 | } |
---|
58 | |
---|
59 | public Accessor Setter { |
---|
60 | get { return GetChildByRole(SetterRole); } |
---|
61 | set { SetChildByRole(SetterRole, value); } |
---|
62 | } |
---|
63 | |
---|
64 | public CSharpTokenNode RBraceToken { |
---|
65 | get { return GetChildByRole (Roles.RBrace); } |
---|
66 | } |
---|
67 | |
---|
68 | public override void AcceptVisitor (IAstVisitor visitor) |
---|
69 | { |
---|
70 | visitor.VisitPropertyDeclaration (this); |
---|
71 | } |
---|
72 | |
---|
73 | public override T AcceptVisitor<T> (IAstVisitor<T> visitor) |
---|
74 | { |
---|
75 | return visitor.VisitPropertyDeclaration (this); |
---|
76 | } |
---|
77 | |
---|
78 | public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data) |
---|
79 | { |
---|
80 | return visitor.VisitPropertyDeclaration (this, data); |
---|
81 | } |
---|
82 | |
---|
83 | protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) |
---|
84 | { |
---|
85 | PropertyDeclaration o = other as PropertyDeclaration; |
---|
86 | return o != null && MatchString(this.Name, o.Name) |
---|
87 | && this.MatchAttributesAndModifiers(o, match) && this.ReturnType.DoMatch(o.ReturnType, match) |
---|
88 | && this.PrivateImplementationType.DoMatch(o.PrivateImplementationType, match) |
---|
89 | && this.Getter.DoMatch(o.Getter, match) && this.Setter.DoMatch(o.Setter, match); |
---|
90 | } |
---|
91 | } |
---|
92 | } |
---|