1
1
using System ;
2
2
using System . Collections . Generic ;
3
+ using System . Linq ;
3
4
4
5
namespace CppSharp . AST
5
6
{
@@ -109,7 +110,7 @@ public interface ICommentVisitor<out T>
109
110
T VisitTParamCommand ( TParamCommandComment comment ) ;
110
111
T VisitVerbatimBlock ( VerbatimBlockComment comment ) ;
111
112
T VisitVerbatimLine ( VerbatimLineComment comment ) ;
112
- T VisitParagraphCommand ( ParagraphComment comment ) ;
113
+ T VisitParagraph ( ParagraphComment comment ) ;
113
114
T VisitFull ( FullComment comment ) ;
114
115
T VisitHTMLStartTag ( HTMLStartTagComment comment ) ;
115
116
T VisitHTMLEndTag ( HTMLEndTagComment comment ) ;
@@ -129,20 +130,13 @@ public abstract class Comment
129
130
130
131
public static string GetMultiLineCommentPrologue ( CommentKind kind )
131
132
{
132
- switch ( kind )
133
+ return kind switch
133
134
{
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
+ } ;
146
140
}
147
141
148
142
public static string GetLineCommentPrologue ( CommentKind kind )
@@ -375,7 +369,7 @@ public ParagraphComment()
375
369
376
370
public override void Visit < T > ( ICommentVisitor < T > visitor )
377
371
{
378
- visitor . VisitParagraphCommand ( this ) ;
372
+ visitor . VisitParagraph ( this ) ;
379
373
}
380
374
}
381
375
@@ -416,10 +410,17 @@ public struct Attribute
416
410
{
417
411
public string Name ;
418
412
public string Value ;
413
+
414
+ public override string ToString ( )
415
+ {
416
+ return $ "{ Name } =\" { Value } \" ";
417
+ }
419
418
}
420
419
421
420
public List < Attribute > Attributes ;
422
421
422
+ public bool SelfClosing { get ; set ; }
423
+
423
424
public HTMLStartTagComment ( )
424
425
{
425
426
Kind = DocumentationCommentKind . HTMLStartTagComment ;
@@ -430,6 +431,15 @@ public override void Visit<T>(ICommentVisitor<T> visitor)
430
431
{
431
432
visitor . VisitHTMLStartTag ( this ) ;
432
433
}
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
+ }
433
443
}
434
444
435
445
/// <summary>
@@ -446,6 +456,11 @@ public override void Visit<T>(ICommentVisitor<T> visitor)
446
456
{
447
457
visitor . VisitHTMLEndTag ( this ) ;
448
458
}
459
+
460
+ public override string ToString ( )
461
+ {
462
+ return $ "</{ TagName } >";
463
+ }
449
464
}
450
465
451
466
/// <summary>
@@ -464,6 +479,13 @@ public override void Visit<T>(ICommentVisitor<T> visitor)
464
479
{
465
480
visitor . VisitText ( this ) ;
466
481
}
482
+
483
+ public override string ToString ( )
484
+ {
485
+ return Text ;
486
+ }
487
+
488
+ public bool IsEmpty => string . IsNullOrEmpty ( Text ) && ! HasTrailingNewline ;
467
489
}
468
490
469
491
/// <summary>
0 commit comments