@@ -182,7 +182,7 @@ module ts {
182
182
} ) ;
183
183
}
184
184
185
- function emitComments ( comments : Comment [ ] , trailingSeparator : boolean , writer : EmitTextWriter , writeComment : ( comment : Comment , writer : EmitTextWriter ) => void ) {
185
+ function emitComments ( comments : CommentRange [ ] , trailingSeparator : boolean , writer : EmitTextWriter , writeComment : ( comment : CommentRange , writer : EmitTextWriter ) => void ) {
186
186
var emitLeadingSpace = ! trailingSeparator ;
187
187
forEach ( comments , comment => {
188
188
if ( emitLeadingSpace ) {
@@ -203,15 +203,15 @@ module ts {
203
203
} ) ;
204
204
}
205
205
206
- function emitNewLineBeforeLeadingComments ( node : TextRange , leadingComments : Comment [ ] , writer : EmitTextWriter ) {
206
+ function emitNewLineBeforeLeadingComments ( node : TextRange , leadingComments : CommentRange [ ] , writer : EmitTextWriter ) {
207
207
// If the leading comments start on different line than the start of node, write new line
208
208
if ( leadingComments && leadingComments . length && node . pos !== leadingComments [ 0 ] . pos &&
209
209
getLineOfLocalPosition ( node . pos ) !== getLineOfLocalPosition ( leadingComments [ 0 ] . pos ) ) {
210
210
writer . writeLine ( ) ;
211
211
}
212
212
}
213
213
214
- function writeCommentRange ( comment : Comment , writer : EmitTextWriter ) {
214
+ function writeCommentRange ( comment : CommentRange , writer : EmitTextWriter ) {
215
215
if ( currentSourceFile . text . charCodeAt ( comment . pos + 1 ) === CharacterCodes . asterisk ) {
216
216
var firstCommentLineAndCharacter = currentSourceFile . getLineAndCharacterFromPosition ( comment . pos ) ;
217
217
var firstCommentLineIndent : number ;
@@ -585,7 +585,7 @@ module ts {
585
585
sourceMapNameIndices . pop ( ) ;
586
586
} ;
587
587
588
- function writeCommentRangeWithMap ( comment : Comment , writer : EmitTextWriter ) {
588
+ function writeCommentRangeWithMap ( comment : CommentRange , writer : EmitTextWriter ) {
589
589
recordSourceMapSpan ( comment . pos ) ;
590
590
writeCommentRange ( comment , writer ) ;
591
591
recordSourceMapSpan ( comment . end ) ;
@@ -2108,7 +2108,7 @@ module ts {
2108
2108
2109
2109
function getLeadingCommentsWithoutDetachedComments ( ) {
2110
2110
// get the leading comments from detachedPos
2111
- var leadingComments = getLeadingComments ( currentSourceFile . text , detachedCommentsInfo [ detachedCommentsInfo . length - 1 ] . detachedCommentEndPos ) ;
2111
+ var leadingComments = getLeadingCommentRanges ( currentSourceFile . text , detachedCommentsInfo [ detachedCommentsInfo . length - 1 ] . detachedCommentEndPos ) ;
2112
2112
if ( detachedCommentsInfo . length - 1 ) {
2113
2113
detachedCommentsInfo . pop ( ) ;
2114
2114
}
@@ -2122,14 +2122,14 @@ module ts {
2122
2122
function getLeadingCommentsToEmit ( node : Node ) {
2123
2123
// Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments
2124
2124
if ( node . parent . kind === SyntaxKind . SourceFile || node . pos !== node . parent . pos ) {
2125
- var leadingComments : Comment [ ] ;
2125
+ var leadingComments : CommentRange [ ] ;
2126
2126
if ( hasDetachedComments ( node . pos ) ) {
2127
2127
// get comments without detached comments
2128
2128
leadingComments = getLeadingCommentsWithoutDetachedComments ( ) ;
2129
2129
}
2130
2130
else {
2131
2131
// get the leading comments from the node
2132
- leadingComments = getLeadingCommentsOfNode ( node , currentSourceFile ) ;
2132
+ leadingComments = getLeadingCommentRangesOfNode ( node , currentSourceFile ) ;
2133
2133
}
2134
2134
return leadingComments ;
2135
2135
}
@@ -2145,32 +2145,32 @@ module ts {
2145
2145
function emitTrailingDeclarationComments ( node : Node ) {
2146
2146
// Emit the trailing comments only if the parent's end doesn't match
2147
2147
if ( node . parent . kind === SyntaxKind . SourceFile || node . end !== node . parent . end ) {
2148
- var trailingComments = getTrailingComments ( currentSourceFile . text , node . end ) ;
2148
+ var trailingComments = getTrailingCommentRanges ( currentSourceFile . text , node . end ) ;
2149
2149
// trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/
2150
2150
emitComments ( trailingComments , /*trailingSeparator*/ false , writer , writeComment ) ;
2151
2151
}
2152
2152
}
2153
2153
2154
2154
function emitLeadingCommentsOfLocalPosition ( pos : number ) {
2155
- var leadingComments : Comment [ ] ;
2155
+ var leadingComments : CommentRange [ ] ;
2156
2156
if ( hasDetachedComments ( pos ) ) {
2157
2157
// get comments without detached comments
2158
2158
leadingComments = getLeadingCommentsWithoutDetachedComments ( ) ;
2159
2159
}
2160
2160
else {
2161
2161
// get the leading comments from the node
2162
- leadingComments = getLeadingComments ( currentSourceFile . text , pos ) ;
2162
+ leadingComments = getLeadingCommentRanges ( currentSourceFile . text , pos ) ;
2163
2163
}
2164
2164
emitNewLineBeforeLeadingComments ( { pos : pos , end : pos } , leadingComments , writer ) ;
2165
2165
// Leading comments are emitted at /*leading comment1 */space/*leading comment*/space
2166
2166
emitComments ( leadingComments , /*trailingSeparator*/ true , writer , writeComment ) ;
2167
2167
}
2168
2168
2169
2169
function emitDetachedCommentsAtPosition ( node : TextRange ) {
2170
- var leadingComments = getLeadingComments ( currentSourceFile . text , node . pos ) ;
2170
+ var leadingComments = getLeadingCommentRanges ( currentSourceFile . text , node . pos ) ;
2171
2171
if ( leadingComments ) {
2172
- var detachedComments : Comment [ ] = [ ] ;
2173
- var lastComment : Comment ;
2172
+ var detachedComments : CommentRange [ ] = [ ] ;
2173
+ var lastComment : CommentRange ;
2174
2174
2175
2175
forEach ( leadingComments , comment => {
2176
2176
if ( lastComment ) {
@@ -2214,7 +2214,7 @@ module ts {
2214
2214
function emitPinnedOrTripleSlashCommentsOfNode ( node : Node ) {
2215
2215
var pinnedComments = ts . filter ( getLeadingCommentsToEmit ( node ) , isPinnedOrTripleSlashComment ) ;
2216
2216
2217
- function isPinnedOrTripleSlashComment ( comment : Comment ) {
2217
+ function isPinnedOrTripleSlashComment ( comment : CommentRange ) {
2218
2218
if ( currentSourceFile . text . charCodeAt ( comment . pos + 1 ) === CharacterCodes . asterisk ) {
2219
2219
return currentSourceFile . text . charCodeAt ( comment . pos + 2 ) === CharacterCodes . exclamation ;
2220
2220
}
0 commit comments