@@ -21,97 +21,6 @@ private CommentLine(Context cx, Microsoft.CodeAnalysis.Location loc, CommentLine
2121 public string Text { get { return symbol . Item2 ; } }
2222 public string RawText { get ; private set ; }
2323
24- public static void Extract ( Context cx , SyntaxTrivia trivia )
25- {
26- switch ( trivia . Kind ( ) )
27- {
28- case SyntaxKind . SingleLineDocumentationCommentTrivia :
29- /*
30- This is actually a multi-line comment consisting of /// lines.
31- So split it up.
32- */
33-
34- var text = trivia . ToFullString ( ) ;
35-
36- var split = text . Split ( '\n ' ) ;
37- var currentLocation = trivia . GetLocation ( ) . SourceSpan . Start - 3 ;
38-
39- for ( var line = 0 ; line < split . Length - 1 ; ++ line )
40- {
41- var fullLine = split [ line ] ;
42- var nextLineLocation = currentLocation + fullLine . Length + 1 ;
43- fullLine = fullLine . TrimEnd ( '\r ' ) ;
44- var trimmedLine = fullLine ;
45-
46- var leadingSpaces = trimmedLine . IndexOf ( '/' ) ;
47- if ( leadingSpaces != - 1 )
48- {
49- fullLine = fullLine . Substring ( leadingSpaces ) ;
50- currentLocation += leadingSpaces ;
51- trimmedLine = trimmedLine . Substring ( leadingSpaces + 3 ) ; // Remove leading spaces and the "///"
52- trimmedLine = trimmedLine . Trim ( ) ;
53-
54- var span = Microsoft . CodeAnalysis . Text . TextSpan . FromBounds ( currentLocation , currentLocation + fullLine . Length ) ;
55- var location = Microsoft . CodeAnalysis . Location . Create ( trivia . SyntaxTree , span ) ;
56- var commentType = CommentLineType . XmlDoc ;
57- cx . CommentGenerator . AddComment ( Create ( cx , location , commentType , trimmedLine , fullLine ) ) ;
58- }
59- else
60- {
61- cx . ModelError ( "Unexpected comment format" ) ;
62- }
63- currentLocation = nextLineLocation ;
64- }
65- break ;
66-
67- case SyntaxKind . SingleLineCommentTrivia :
68- {
69- var contents = trivia . ToString ( ) . Substring ( 2 ) ;
70- var commentType = CommentLineType . Singleline ;
71- if ( contents . Length > 0 && contents [ 0 ] == '/' )
72- {
73- commentType = CommentLineType . XmlDoc ;
74- contents = contents . Substring ( 1 ) ; // An XML comment.
75- }
76- cx . CommentGenerator . AddComment ( Create ( cx , trivia . GetLocation ( ) , commentType , contents . Trim ( ) , trivia . ToFullString ( ) ) ) ;
77- }
78- break ;
79- case SyntaxKind . MultiLineDocumentationCommentTrivia :
80- case SyntaxKind . MultiLineCommentTrivia :
81- /* We receive a single SyntaxTrivia for a multiline block spanning several lines.
82- So we split it into separate lines
83- */
84- text = trivia . ToFullString ( ) ;
85-
86- split = text . Split ( '\n ' ) ;
87- currentLocation = trivia . GetLocation ( ) . SourceSpan . Start ;
88-
89- for ( var line = 0 ; line < split . Length ; ++ line )
90- {
91- var fullLine = split [ line ] ;
92- var nextLineLocation = currentLocation + fullLine . Length + 1 ;
93- fullLine = fullLine . TrimEnd ( '\r ' ) ;
94- var trimmedLine = fullLine ;
95- if ( line == 0 )
96- trimmedLine = trimmedLine . Substring ( 2 ) ;
97- if ( line == split . Length - 1 )
98- trimmedLine = trimmedLine . Substring ( 0 , trimmedLine . Length - 2 ) ;
99- trimmedLine = trimmedLine . Trim ( ) ;
100-
101- var span = Microsoft . CodeAnalysis . Text . TextSpan . FromBounds ( currentLocation , currentLocation + fullLine . Length ) ;
102- var location = Microsoft . CodeAnalysis . Location . Create ( trivia . SyntaxTree , span ) ;
103- var commentType = line == 0 ? CommentLineType . Multiline : CommentLineType . MultilineContinuation ;
104- cx . CommentGenerator . AddComment ( Create ( cx , location , commentType , trimmedLine , fullLine ) ) ;
105- currentLocation = nextLineLocation ;
106- }
107- break ;
108- // Strangely, these are reported as SingleLineCommentTrivia.
109- case SyntaxKind . DocumentationCommentExteriorTrivia :
110- cx . ModelError ( $ "Unhandled comment type { trivia . Kind ( ) } for { trivia } ") ;
111- break ;
112- }
113- }
114-
11524 private Extraction . Entities . Location location ;
11625
11726 public override void Populate ( TextWriter trapFile )
@@ -131,7 +40,7 @@ public override void WriteId(TextWriter trapFile)
13140 trapFile . Write ( ";commentline" ) ;
13241 }
13342
134- private static CommentLine Create ( Context cx , Microsoft . CodeAnalysis . Location loc , CommentLineType type , string text , string raw )
43+ internal static CommentLine Create ( Context cx , Microsoft . CodeAnalysis . Location loc , CommentLineType type , string text , string raw )
13544 {
13645 var init = ( loc , type , text , raw ) ;
13746 return CommentLineFactory . Instance . CreateEntity ( cx , init , init ) ;
0 commit comments