11using System ;
22using System . Collections . Generic ;
3+ using System . Linq ;
34
45namespace CppSharp . AST
56{
@@ -109,7 +110,7 @@ public interface ICommentVisitor<out T>
109110 T VisitTParamCommand ( TParamCommandComment comment ) ;
110111 T VisitVerbatimBlock ( VerbatimBlockComment comment ) ;
111112 T VisitVerbatimLine ( VerbatimLineComment comment ) ;
112- T VisitParagraphCommand ( ParagraphComment comment ) ;
113+ T VisitParagraph ( ParagraphComment comment ) ;
113114 T VisitFull ( FullComment comment ) ;
114115 T VisitHTMLStartTag ( HTMLStartTagComment comment ) ;
115116 T VisitHTMLEndTag ( HTMLEndTagComment comment ) ;
@@ -129,20 +130,13 @@ public abstract class Comment
129130
130131 public static string GetMultiLineCommentPrologue ( CommentKind kind )
131132 {
132- switch ( kind )
133+ return kind switch
133134 {
134- case CommentKind . BCPL :
135- case CommentKind . BCPLExcl :
136- return "//" ;
137- case CommentKind . C :
138- case CommentKind . JavaDoc :
139- case CommentKind . Qt :
140- return " *" ;
141- case CommentKind . BCPLSlash :
142- return "///" ;
143- default :
144- throw new ArgumentOutOfRangeException ( ) ;
145- }
135+ CommentKind . BCPL or CommentKind . BCPLExcl => "//" ,
136+ CommentKind . C or CommentKind . JavaDoc or CommentKind . Qt => " *" ,
137+ CommentKind . BCPLSlash => "///" ,
138+ _ => throw new ArgumentOutOfRangeException ( )
139+ } ;
146140 }
147141
148142 public static string GetLineCommentPrologue ( CommentKind kind )
@@ -375,7 +369,7 @@ public ParagraphComment()
375369
376370 public override void Visit < T > ( ICommentVisitor < T > visitor )
377371 {
378- visitor . VisitParagraphCommand ( this ) ;
372+ visitor . VisitParagraph ( this ) ;
379373 }
380374 }
381375
@@ -416,10 +410,17 @@ public struct Attribute
416410 {
417411 public string Name ;
418412 public string Value ;
413+
414+ public override string ToString ( )
415+ {
416+ return $ "{ Name } =\" { Value } \" ";
417+ }
419418 }
420419
421420 public List < Attribute > Attributes ;
422421
422+ public bool SelfClosing { get ; set ; }
423+
423424 public HTMLStartTagComment ( )
424425 {
425426 Kind = DocumentationCommentKind . HTMLStartTagComment ;
@@ -430,6 +431,15 @@ public override void Visit<T>(ICommentVisitor<T> visitor)
430431 {
431432 visitor . VisitHTMLStartTag ( this ) ;
432433 }
434+
435+ public override string ToString ( )
436+ {
437+ var attrStr = string . Empty ;
438+ if ( Attributes . Count != 0 )
439+ attrStr = " " + string . Join ( ' ' , Attributes . Select ( x => x . ToString ( ) ) ) ;
440+
441+ return $ "<{ TagName } { attrStr } { ( SelfClosing ? "/" : "" ) } >";
442+ }
433443 }
434444
435445 /// <summary>
@@ -446,6 +456,11 @@ public override void Visit<T>(ICommentVisitor<T> visitor)
446456 {
447457 visitor . VisitHTMLEndTag ( this ) ;
448458 }
459+
460+ public override string ToString ( )
461+ {
462+ return $ "</{ TagName } >";
463+ }
449464 }
450465
451466 /// <summary>
@@ -464,6 +479,13 @@ public override void Visit<T>(ICommentVisitor<T> visitor)
464479 {
465480 visitor . VisitText ( this ) ;
466481 }
482+
483+ public override string ToString ( )
484+ {
485+ return Text ;
486+ }
487+
488+ public bool IsEmpty => string . IsNullOrEmpty ( Text ) && ! HasTrailingNewline ;
467489 }
468490
469491 /// <summary>
0 commit comments