@@ -4907,7 +4907,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
4907
4907
4908
4908
increaseIndent ( ) ;
4909
4909
let outPos = writer . getTextPos ( ) ;
4910
- emitDetachedComments ( node . body ) ;
4910
+ detachedCommentsInfo = emitDetachedComments ( currentSourceFile , writer , writeComment , node . body , newLine , compilerOptions . removeComments , detachedCommentsInfo ) ;
4911
4911
emitFunctionBodyPreamble ( node ) ;
4912
4912
let preambleEmitted = writer . getTextPos ( ) !== outPos ;
4913
4913
decreaseIndent ( ) ;
@@ -4952,7 +4952,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
4952
4952
let initialTextPos = writer . getTextPos ( ) ;
4953
4953
4954
4954
increaseIndent ( ) ;
4955
- emitDetachedComments ( body . statements ) ;
4955
+ detachedCommentsInfo = emitDetachedComments ( currentSourceFile , writer , writeComment , body . statements , newLine , compilerOptions . removeComments , detachedCommentsInfo ) ;
4956
+
4956
4957
4957
4958
// Emit all the directive prologues (like "use strict"). These have to come before
4958
4959
// any other preamble code we write (like parameter initializers).
@@ -5274,7 +5275,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
5274
5275
// Emit all the directive prologues (like "use strict"). These have to come before
5275
5276
// any other preamble code we write (like parameter initializers).
5276
5277
startIndex = emitDirectivePrologues ( ctor . body . statements , /*startWithNewLine*/ true ) ;
5277
- emitDetachedComments ( ctor . body . statements ) ;
5278
+ detachedCommentsInfo = emitDetachedComments ( currentSourceFile , writer , writeComment , ctor . body . statements , newLine , compilerOptions . removeComments , detachedCommentsInfo ) ;
5278
5279
}
5279
5280
emitCaptureThisForNodeIfNecessary ( node ) ;
5280
5281
let superCall : ExpressionStatement ;
@@ -7652,7 +7653,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
7652
7653
// Start new file on new line
7653
7654
writeLine ( ) ;
7654
7655
emitShebang ( ) ;
7655
- emitDetachedComments ( node ) ;
7656
+ detachedCommentsInfo = emitDetachedComments ( currentSourceFile , writer , writeComment , node , newLine , compilerOptions . removeComments , detachedCommentsInfo ) ;
7656
7657
7657
7658
if ( isExternalModule ( node ) || compilerOptions . isolatedModules ) {
7658
7659
let emitModule = moduleEmitDelegates [ modulekind ] || moduleEmitDelegates [ ModuleKind . CommonJS ] ;
@@ -7948,11 +7949,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
7948
7949
return leadingComments ;
7949
7950
}
7950
7951
7951
- function isPinnedComments ( comment : CommentRange ) {
7952
- return currentSourceFile . text . charCodeAt ( comment . pos + 1 ) === CharacterCodes . asterisk &&
7953
- currentSourceFile . text . charCodeAt ( comment . pos + 2 ) === CharacterCodes . exclamation ;
7954
- }
7955
-
7956
7952
/**
7957
7953
* Determine if the given comment is a triple-slash
7958
7954
*
@@ -8086,66 +8082,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
8086
8082
emitComments ( currentSourceFile , writer , leadingComments , /*trailingSeparator*/ true , newLine , writeComment ) ;
8087
8083
}
8088
8084
8089
- function emitDetachedComments ( node : TextRange ) {
8090
- let leadingComments : CommentRange [ ] ;
8091
- if ( compilerOptions . removeComments ) {
8092
- // removeComments is true, only reserve pinned comment at the top of file
8093
- // For example:
8094
- // /*! Pinned Comment */
8095
- //
8096
- // var x = 10;
8097
- if ( node . pos === 0 ) {
8098
- leadingComments = filter ( getLeadingCommentRanges ( currentSourceFile . text , node . pos ) , isPinnedComments ) ;
8099
- }
8100
- }
8101
- else {
8102
- // removeComments is false, just get detached as normal and bypass the process to filter comment
8103
- leadingComments = getLeadingCommentRanges ( currentSourceFile . text , node . pos ) ;
8104
- }
8105
-
8106
- if ( leadingComments ) {
8107
- let detachedComments : CommentRange [ ] = [ ] ;
8108
- let lastComment : CommentRange ;
8109
-
8110
- forEach ( leadingComments , comment => {
8111
- if ( lastComment ) {
8112
- let lastCommentLine = getLineOfLocalPosition ( currentSourceFile , lastComment . end ) ;
8113
- let commentLine = getLineOfLocalPosition ( currentSourceFile , comment . pos ) ;
8114
-
8115
- if ( commentLine >= lastCommentLine + 2 ) {
8116
- // There was a blank line between the last comment and this comment. This
8117
- // comment is not part of the copyright comments. Return what we have so
8118
- // far.
8119
- return detachedComments ;
8120
- }
8121
- }
8122
-
8123
- detachedComments . push ( comment ) ;
8124
- lastComment = comment ;
8125
- } ) ;
8126
-
8127
- if ( detachedComments . length ) {
8128
- // All comments look like they could have been part of the copyright header. Make
8129
- // sure there is at least one blank line between it and the node. If not, it's not
8130
- // a copyright header.
8131
- let lastCommentLine = getLineOfLocalPosition ( currentSourceFile , lastOrUndefined ( detachedComments ) . end ) ;
8132
- let nodeLine = getLineOfLocalPosition ( currentSourceFile , skipTrivia ( currentSourceFile . text , node . pos ) ) ;
8133
- if ( nodeLine >= lastCommentLine + 2 ) {
8134
- // Valid detachedComments
8135
- emitNewLineBeforeLeadingComments ( currentSourceFile , writer , node , leadingComments ) ;
8136
- emitComments ( currentSourceFile , writer , detachedComments , /*trailingSeparator*/ true , newLine , writeComment ) ;
8137
- let currentDetachedCommentInfo = { nodePos : node . pos , detachedCommentEndPos : lastOrUndefined ( detachedComments ) . end } ;
8138
- if ( detachedCommentsInfo ) {
8139
- detachedCommentsInfo . push ( currentDetachedCommentInfo ) ;
8140
- }
8141
- else {
8142
- detachedCommentsInfo = [ currentDetachedCommentInfo ] ;
8143
- }
8144
- }
8145
- }
8146
- }
8147
- }
8148
-
8149
8085
function emitShebang ( ) {
8150
8086
let shebang = getShebang ( currentSourceFile . text ) ;
8151
8087
if ( shebang ) {
0 commit comments