(text, lineMap, writer, commentPos, commentEnd, newLine)
| 18787 | } |
| 18788 | ts.emitDetachedComments = emitDetachedComments; |
| 18789 | function writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine) { |
| 18790 | if (text.charCodeAt(commentPos + 1) === 42 /* CharacterCodes.asterisk */) { |
| 18791 | var firstCommentLineAndCharacter = ts.computeLineAndCharacterOfPosition(lineMap, commentPos); |
| 18792 | var lineCount = lineMap.length; |
| 18793 | var firstCommentLineIndent = void 0; |
| 18794 | for (var pos = commentPos, currentLine = firstCommentLineAndCharacter.line; pos < commentEnd; currentLine++) { |
| 18795 | var nextLineStart = (currentLine + 1) === lineCount |
| 18796 | ? text.length + 1 |
| 18797 | : lineMap[currentLine + 1]; |
| 18798 | if (pos !== commentPos) { |
| 18799 | // If we are not emitting first line, we need to write the spaces to adjust the alignment |
| 18800 | if (firstCommentLineIndent === undefined) { |
| 18801 | firstCommentLineIndent = calculateIndent(text, lineMap[firstCommentLineAndCharacter.line], commentPos); |
| 18802 | } |
| 18803 | // These are number of spaces writer is going to write at current indent |
| 18804 | var currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); |
| 18805 | // Number of spaces we want to be writing |
| 18806 | // eg: Assume writer indent |
| 18807 | // module m { |
| 18808 | // /* starts at character 9 this is line 1 |
| 18809 | // * starts at character pos 4 line --1 = 8 - 8 + 3 |
| 18810 | // More left indented comment */ --2 = 8 - 8 + 2 |
| 18811 | // class c { } |
| 18812 | // } |
| 18813 | // module m { |
| 18814 | // /* this is line 1 -- Assume current writer indent 8 |
| 18815 | // * line --3 = 8 - 4 + 5 |
| 18816 | // More right indented comment */ --4 = 8 - 4 + 11 |
| 18817 | // class c { } |
| 18818 | // } |
| 18819 | var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(text, pos, nextLineStart); |
| 18820 | if (spacesToEmit > 0) { |
| 18821 | var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); |
| 18822 | var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); |
| 18823 | // Write indent size string ( in eg 1: = "", 2: "" , 3: string with 8 spaces 4: string with 12 spaces |
| 18824 | writer.rawWrite(indentSizeSpaceString); |
| 18825 | // Emit the single spaces (in eg: 1: 3 spaces, 2: 2 spaces, 3: 1 space, 4: 3 spaces) |
| 18826 | while (numberOfSingleSpacesToEmit) { |
| 18827 | writer.rawWrite(" "); |
| 18828 | numberOfSingleSpacesToEmit--; |
| 18829 | } |
| 18830 | } |
| 18831 | else { |
| 18832 | // No spaces to emit write empty string |
| 18833 | writer.rawWrite(""); |
| 18834 | } |
| 18835 | } |
| 18836 | // Write the comment line text |
| 18837 | writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart); |
| 18838 | pos = nextLineStart; |
| 18839 | } |
| 18840 | } |
| 18841 | else { |
| 18842 | // Single line comment of style //.... |
| 18843 | writer.writeComment(text.substring(commentPos, commentEnd)); |
| 18844 | } |
| 18845 | } |
| 18846 | ts.writeCommentRange = writeCommentRange; |
nothing calls this directly
no test coverage detected
searching dependent graphs…