prepend Comment to comment node types
This commit is contained in:
parent
255c819727
commit
51b0ffa7bf
@ -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";
|
||||
}
|
||||
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -330,7 +330,7 @@ export default class File {
|
||||
if (comment) {
|
||||
node.leadingComments = node.leadingComments || [];
|
||||
node.leadingComments.push({
|
||||
type: "Line",
|
||||
type: "CommentLine",
|
||||
value: " " + comment
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user