Use getJsDocFromText to get trailing comments

Also update a couple of missed spots in the previous undo commits
This commit is contained in:
Nathan Shively-Sanders 2016-09-01 21:39:24 -07:00
parent ff9ccc9b05
commit 643cf302c6
3 changed files with 3 additions and 7 deletions

View File

@ -8288,11 +8288,7 @@ const _super = (function (geti, seti) {
emitNewLineBeforeLeadingComments(currentLineMap, writer, node, leadingComments);
// Leading comments are emitted at /*leading comment1 */space/*leading comment*/space
// However, a leading mid-line comment of the end of file token is emitted with spaces before,
// as if it were a trailing comment of the previous token
const commentStartsInMidLine = leadingComments && leadingComments.length && leadingComments[0].pos - 1 > 0 && currentText.charCodeAt(leadingComments[0].pos - 1) !== 10;
const isEndOfFile = node.kind === SyntaxKind.EndOfFileToken && commentStartsInMidLine;
emitComments(currentText, currentLineMap, writer, leadingComments, /*trailingSeparator*/ !isEndOfFile, newLine, writeComment);
emitComments(currentText, currentLineMap, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment);
}
function emitTrailingComments(node: Node) {

View File

@ -652,7 +652,7 @@ namespace ts {
function addJSDocComment<T extends Node>(node: T): T {
const comments = getLeadingCommentRangesOfNode(node, sourceFile);
const comments = getJsDocCommentsFromText(node, sourceFile.text);
if (comments) {
for (const comment of comments) {
const jsDoc = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos);

View File

@ -18,4 +18,4 @@ var Foo = (function () {
var baz = Foo.b;
// Foo.b won't bind.
baz.concat("y");
// So we don't want an error on 'concat'.
// So we don't want an error on 'concat'.