From 51b0ffa7bf2de4f79b65075b9b654692a43c9b3e Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Sun, 31 May 2015 20:25:26 +0100 Subject: [PATCH] prepend Comment to comment node types --- src/babel/generation/index.js | 6 +++--- src/babel/generation/whitespace.js | 2 +- src/babel/helpers/parse.js | 2 +- src/babel/transformation/file/index.js | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/babel/generation/index.js b/src/babel/generation/index.js index 4870efe5b0..925d640247 100644 --- a/src/babel/generation/index.js +++ b/src/babel/generation/index.js @@ -267,7 +267,7 @@ class CodeGenerator { generateComment(comment) { var val = comment.value; - if (comment.type === "Line") { + if (comment.type === "CommentLine") { val = `//${val}`; } else { val = `/*${val}*/`; @@ -343,7 +343,7 @@ class CodeGenerator { } // - if (comment.type === "Block" && this.format.indent.adjustMultilineComment) { + if (comment.type === "CommentBlock" && this.format.indent.adjustMultilineComment) { var offset = comment.loc.start.column; if (offset) { var newlineRegex = new RegExp("\\n\\s{1," + offset + "}", "g"); @@ -360,7 +360,7 @@ class CodeGenerator { // force a newline for line comments when retainLines is set in case the next printed node // doesn't catch up - if (this.format.retainLines && comment.type === "Line") { + if (this.format.retainLines && comment.type === "CommentLine") { val += "\n"; } diff --git a/src/babel/generation/whitespace.js b/src/babel/generation/whitespace.js index c1351f01e8..255fcf69a8 100644 --- a/src/babel/generation/whitespace.js +++ b/src/babel/generation/whitespace.js @@ -82,7 +82,7 @@ export default class Whitespace { return 1; } else { var lines = this.getNewlinesBetween(startToken, endToken); - if (node.type === "Line" && !lines) { + if (node.type === "CommentLine" && !lines) { // line comment return 1; } else { diff --git a/src/babel/helpers/parse.js b/src/babel/helpers/parse.js index 28b8b7af74..925c5bf331 100644 --- a/src/babel/helpers/parse.js +++ b/src/babel/helpers/parse.js @@ -22,7 +22,7 @@ export default function (code, opts = {}) { parseOpts.onComment = function (block, text, start, end, startLoc, endLoc) { var comment = { - type: block ? "Block" : "Line", + type: block ? "CommentBlock" : "CommentLine", value: text, start: start, end: end, diff --git a/src/babel/transformation/file/index.js b/src/babel/transformation/file/index.js index 04ffbe3afa..3ea2b246c8 100644 --- a/src/babel/transformation/file/index.js +++ b/src/babel/transformation/file/index.js @@ -330,7 +330,7 @@ export default class File { if (comment) { node.leadingComments = node.leadingComments || []; node.leadingComments.push({ - type: "Line", + type: "CommentLine", value: " " + comment }); }