1
// Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
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:
9
// The above copyright notice and this permission notice shall be included in all copies or
10
// substantial portions of the Software.
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.
20
using ICSharpCode.NRefactory.TypeSystem;
22
namespace ICSharpCode.NRefactory.CSharp
25
/// Represents a 'cref' reference in XML documentation.
27
public class DocumentationReference : AstNode
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);
32
EntityType entityType;
33
OperatorType operatorType;
34
bool hasParameterList;
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.
44
public EntityType EntityType {
45
get { return entityType; }
53
/// Gets/Sets the operator type.
54
/// This property is only used when EntityType==Operator.
56
public OperatorType OperatorType {
57
get { return operatorType; }
65
/// Gets/Sets whether a parameter list was provided.
67
public bool HasParameterList {
68
get { return hasParameterList; }
71
hasParameterList = value;
75
public override NodeType NodeType {
76
get { return NodeType.Unknown; }
80
/// Gets/Sets the declaring type.
82
public AstType DeclaringType {
83
get { return GetChildByRole(DeclaringTypeRole); }
84
set { SetChildByRole(DeclaringTypeRole, value); }
88
/// Gets/sets the member name.
89
/// This property is only used when EntityType==None.
91
public string MemberName {
92
get { return GetChildByRole(Roles.Identifier).Name; }
93
set { SetChildByRole(Roles.Identifier, Identifier.Create(value)); }
97
/// Gets/Sets the return type of conversion operators.
98
/// This property is only used when EntityType==Operator and OperatorType is explicit or implicit.
100
public AstType ConversionOperatorReturnType {
101
get { return GetChildByRole(ConversionOperatorReturnTypeRole); }
102
set { SetChildByRole(ConversionOperatorReturnTypeRole, value); }
105
public AstNodeCollection<AstType> TypeArguments {
106
get { return GetChildrenByRole (Roles.TypeArgument); }
109
public AstNodeCollection<ParameterDeclaration> Parameters {
110
get { return GetChildrenByRole (Roles.Parameter); }
113
protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match)
115
DocumentationReference o = other as DocumentationReference;
116
if (!(o != null && this.EntityType == o.EntityType && this.HasParameterList == o.HasParameterList))
118
if (this.EntityType == EntityType.Operator) {
119
if (this.OperatorType != o.OperatorType)
121
if (this.OperatorType == OperatorType.Implicit || this.OperatorType == OperatorType.Explicit) {
122
if (!this.ConversionOperatorReturnType.DoMatch(o.ConversionOperatorReturnType, match))
125
} else if (this.EntityType == EntityType.None) {
126
if (!MatchString(this.MemberName, o.MemberName))
128
if (!this.TypeArguments.DoMatch(o.TypeArguments, match))
131
return this.Parameters.DoMatch(o.Parameters, match);
134
public override void AcceptVisitor (IAstVisitor visitor)
136
visitor.VisitDocumentationReference (this);
139
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
141
return visitor.VisitDocumentationReference (this);
144
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
146
return visitor.VisitDocumentationReference (this, data);