move keyword method and restyle variable declarations

This commit is contained in:
Sebastian McKenzie 2014-11-01 19:29:02 +11:00
parent 9475dc681f
commit 629cea497f

View File

@ -15,13 +15,13 @@ function CodeGenerator(code, ast, opts) {
opts = opts || {}
this.tabWidth = 2;
this._indent = 0;
this.opts = opts;
this.ast = ast;
this.buf = "";
this.line = 1;
this.column = 0;
this.line = 1;
this.column = 0;
this._indent = 0;
if (opts.sourceMap) {
this.map = new sourceMap.SourceMapGenerator({
@ -61,6 +61,11 @@ CodeGenerator.prototype.semicolon = function () {
this.column++;
};
CodeGenerator.prototype.keyword = function (name) {
this.push(name);
this.push(" ");
};
CodeGenerator.prototype.push = function (str) {
if (this._indent) {
// we have an indent level and we aren't pushing a newline
@ -151,11 +156,6 @@ CodeGenerator.prototype.print = function (node, parent) {
}
};
CodeGenerator.prototype.keyword = function (name) {
this.push(name);
this.push(" ");
};
CodeGenerator.prototype.generateComment = function (comment) {
var val = comment.value;
if (comment.type === "Line") {