add concise format option

This commit is contained in:
Sebastian McKenzie 2015-02-04 08:39:17 +11:00
parent 23c6e7e168
commit 86fbba08d8
2 changed files with 6 additions and 5 deletions

View File

@ -19,7 +19,7 @@ Buffer.prototype.get = function () {
};
Buffer.prototype.getIndent = function () {
if (this.format.compact) {
if (this.format.compact || this.format.concise) {
return "";
} else {
return util.repeat(this._indent, this.format.indent.style);
@ -72,7 +72,7 @@ Buffer.prototype.removeLast = function (cha) {
};
Buffer.prototype.newline = function (i, removeLast) {
if (this.format.compact) {
if (this.format.compact || this.format.concise) {
this.space();
return;
}

View File

@ -50,6 +50,7 @@ CodeGenerator.normalizeOptions = function (code, opts) {
parentheses: true,
comments: opts.comments == null || opts.comments,
compact: false,
concise: false,
indent: {
adjustMultilineComment: true,
style: style,
@ -139,9 +140,9 @@ CodeGenerator.prototype.print = function (node, parent, opts) {
node._compact = true;
}
var oldCompact = this.format.compact;
var oldConcise = this.format.concise;
if (node._compact) {
this.format.compact = true;
this.format.concise = true;
}
var self = this;
@ -208,7 +209,7 @@ CodeGenerator.prototype.print = function (node, parent, opts) {
throw new ReferenceError("unknown node of type " + JSON.stringify(node.type) + " with constructor " + JSON.stringify(node && node.constructor.name));
}
this.format.compact = oldCompact;
this.format.concise = oldConcise;
};
CodeGenerator.prototype.printJoin = function (print, nodes, opts) {