5
// Mike Krüger <mkrueger@novell.com>
7
// Copyright (c) 2010 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
namespace ICSharpCode.NRefactory.CSharp
29
public enum CommentType
44
/// Inactive code (code in non-taken "#if")
50
MultiLineDocumentation
53
public class Comment : AstNode
55
public override NodeType NodeType {
57
return NodeType.Whitespace;
61
CommentType commentType;
63
public CommentType CommentType {
64
get { return commentType; }
65
set { ThrowIfFrozen(); commentType = value; }
69
/// Returns true if the <see cref="CommentType"/> is Documentation or MultiLineDocumentation.
71
public bool IsDocumentation {
73
return commentType == CommentType.Documentation || commentType == CommentType.MultiLineDocumentation;
79
public bool StartsLine {
80
get { return startsLine; }
81
set { ThrowIfFrozen(); startsLine = value; }
86
public string Content {
87
get { return content; }
88
set { ThrowIfFrozen(); content = value; }
91
TextLocation startLocation;
92
public override TextLocation StartLocation {
98
TextLocation endLocation;
99
public override TextLocation EndLocation {
105
public Comment (string content, CommentType type = CommentType.SingleLine)
107
this.CommentType = type;
108
this.Content = content;
111
public Comment (CommentType commentType, TextLocation startLocation, TextLocation endLocation)
113
this.CommentType = commentType;
114
this.startLocation = startLocation;
115
this.endLocation = endLocation;
118
public override void AcceptVisitor (IAstVisitor visitor)
120
visitor.VisitComment (this);
123
public override T AcceptVisitor<T> (IAstVisitor<T> visitor)
125
return visitor.VisitComment (this);
128
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
130
return visitor.VisitComment (this, data);
133
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
135
Comment o = other as Comment;
136
return o != null && this.CommentType == o.CommentType && MatchString(this.Content, o.Content);