prepend Comment to comment node types

This commit is contained in:
Sebastian McKenzie 2015-05-31 20:25:26 +01:00
parent 255c819727
commit 51b0ffa7bf
4 changed files with 6 additions and 6 deletions

View File

@ -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";
}

View File

@ -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 {

View File

@ -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,

View File

@ -330,7 +330,7 @@ export default class File {
if (comment) {
node.leadingComments = node.leadingComments || [];
node.leadingComments.push({
type: "Line",
type: "CommentLine",
value: " " + comment
});
}