1 // =================================
 2 // Copyright (c) 2024 Seppo Laakko
 3 // Distributed under the MIT license
 4 // =================================
 5 
 6 using System;
 7 
 8 namespace System.Xml
 9 {
10     public class Comment : CharacterData
11     {
12         public Comment(const System.Lex.Span& span_int fileIndex_) : base(NodeKind.commentNodespan_fileIndex_"comment")
13         {
14         }
15         public Comment(const System.Lex.Span& span_int fileIndex_const string& comment_) : base(NodeKind.commentNodespan_fileIndex_"comment"comment_)
16         {
17         }
18         public override void Accept(Visitor& visitor)
19         {
20             visitor.Visit(*this);
21         }
22         [nodiscard]
23         public override Result<bool> Write(System.Text.CodeFormatter& formatter)
24         {
25             if (formatter.Error())
26             {
27                 return Result<bool>(ErrorId(formatter.GetErrorId()));
28             }
29             auto result = formatter.Write("<!-- ");
30             if (result.Error()) return result;
31             result = formatter.Write(Data());
32             if (result.Error()) return result;
33             result = formatter.Write(" -->");
34             if (result.Error()) return result;
35             return Result<bool>(true);
36         }
37         public override Node* Clone(bool deep) const
38         {
39             return new Comment(Span()FileIndex()Data());
40         }
41     }
42 
43     public Comment* MakeComment(const string& comment)
44     {
45         return new Comment(System.Lex.Span()-1comment);
46     }
47 }