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

« back to all changes in this revision

Viewing changes to external/nrefactory/ICSharpCode.NRefactory.CSharp/Ast/DocumentationReference.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) 2010-2013 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
 
23
{
 
24
        /// <summary>
 
25
        /// Represents a 'cref' reference in XML documentation.
 
26
        /// </summary>
 
27
        public class DocumentationReference : AstNode
 
28
        {
 
29
                public static readonly Role<AstType> DeclaringTypeRole = new Role<AstType>("DeclaringType", AstType.Null);
 
30
                public static readonly Role<AstType> ConversionOperatorReturnTypeRole = new Role<AstType>("ConversionOperatorReturnType", AstType.Null);
 
31
                
 
32
                EntityType entityType;
 
33
                OperatorType operatorType;
 
34
                bool hasParameterList;
 
35
                
 
36
                /// <summary>
 
37
                /// Gets/Sets the entity type.
 
38
                /// Possible values are:
 
39
                ///   <c>EntityType.Operator</c> for operators,
 
40
                ///   <c>EntityType.Indexer</c> for indexers,
 
41
                ///   <c>EntityType.TypeDefinition</c> for references to primitive types,
 
42
                ///   and <c>EntityType.None</c> for everything else.
 
43
                /// </summary>
 
44
                public EntityType EntityType {
 
45
                        get { return entityType; }
 
46
                        set {
 
47
                                ThrowIfFrozen();
 
48
                                entityType = value;
 
49
                        }
 
50
                }
 
51
                
 
52
                /// <summary>
 
53
                /// Gets/Sets the operator type.
 
54
                /// This property is only used when EntityType==Operator.
 
55
                /// </summary>
 
56
                public OperatorType OperatorType {
 
57
                        get { return operatorType; }
 
58
                        set {
 
59
                                ThrowIfFrozen();
 
60
                                operatorType = value;
 
61
                        }
 
62
                }
 
63
                
 
64
                /// <summary>
 
65
                /// Gets/Sets whether a parameter list was provided.
 
66
                /// </summary>
 
67
                public bool HasParameterList {
 
68
                        get { return hasParameterList; }
 
69
                        set {
 
70
                                ThrowIfFrozen();
 
71
                                hasParameterList = value;
 
72
                        }
 
73
                }
 
74
                
 
75
                public override NodeType NodeType {
 
76
                        get { return NodeType.Unknown; }
 
77
                }
 
78
                
 
79
                /// <summary>
 
80
                /// Gets/Sets the declaring type.
 
81
                /// </summary>
 
82
                public AstType DeclaringType {
 
83
                        get { return GetChildByRole(DeclaringTypeRole); }
 
84
                        set { SetChildByRole(DeclaringTypeRole, value); }
 
85
                }
 
86
                
 
87
                /// <summary>
 
88
                /// Gets/sets the member name.
 
89
                /// This property is only used when EntityType==None.
 
90
                /// </summary>
 
91
                public string MemberName {
 
92
                        get { return GetChildByRole(Roles.Identifier).Name; }
 
93
                        set { SetChildByRole(Roles.Identifier, Identifier.Create(value)); }
 
94
                }
 
95
                
 
96
                /// <summary>
 
97
                /// Gets/Sets the return type of conversion operators.
 
98
                /// This property is only used when EntityType==Operator and OperatorType is explicit or implicit.
 
99
                /// </summary>
 
100
                public AstType ConversionOperatorReturnType {
 
101
                        get { return GetChildByRole(ConversionOperatorReturnTypeRole); }
 
102
                        set { SetChildByRole(ConversionOperatorReturnTypeRole, value); }
 
103
                }
 
104
                
 
105
                public AstNodeCollection<AstType> TypeArguments {
 
106
                        get { return GetChildrenByRole (Roles.TypeArgument); }
 
107
                }
 
108
                
 
109
                public AstNodeCollection<ParameterDeclaration> Parameters {
 
110
                        get { return GetChildrenByRole (Roles.Parameter); }
 
111
                }
 
112
                
 
113
                protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match)
 
114
                {
 
115
                        DocumentationReference o = other as DocumentationReference;
 
116
                        if (!(o != null && this.EntityType == o.EntityType && this.HasParameterList == o.HasParameterList))
 
117
                                return false;
 
118
                        if (this.EntityType == EntityType.Operator) {
 
119
                                if (this.OperatorType != o.OperatorType)
 
120
                                        return false;
 
121
                                if (this.OperatorType == OperatorType.Implicit || this.OperatorType == OperatorType.Explicit) {
 
122
                                        if (!this.ConversionOperatorReturnType.DoMatch(o.ConversionOperatorReturnType, match))
 
123
                                                return false;
 
124
                                }
 
125
                        } else if (this.EntityType == EntityType.None) {
 
126
                                if (!MatchString(this.MemberName, o.MemberName))
 
127
                                        return false;
 
128
                                if (!this.TypeArguments.DoMatch(o.TypeArguments, match))
 
129
                                        return false;
 
130
                        }
 
131
                        return this.Parameters.DoMatch(o.Parameters, match);
 
132
                }
 
133
                
 
134
                public override void AcceptVisitor (IAstVisitor visitor)
 
135
                {
 
136
                        visitor.VisitDocumentationReference (this);
 
137
                }
 
138
                
 
139
                public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
 
140
                {
 
141
                        return visitor.VisitDocumentationReference (this);
 
142
                }
 
143
                
 
144
                public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
 
145
                {
 
146
                        return visitor.VisitDocumentationReference (this, data);
 
147
                }
 
148
        }
 
149
}