Instantiate Whitespace in the printer.

This commit is contained in:
Logan Smyth 2016-07-14 23:26:13 -07:00
parent ca1d601037
commit 5e730b18bb
2 changed files with 8 additions and 11 deletions

View File

@ -1,5 +1,4 @@
import detectIndent from "detect-indent";
import Whitespace from "./whitespace";
import SourceMap from "./source-map";
import * as messages from "babel-messages";
import Printer from "./printer";
@ -14,15 +13,11 @@ class Generator extends Printer {
opts = opts || {};
const tokens = ast.tokens || [];
let format = Generator.normalizeOptions(code, opts, tokens);
let format = Generator.normalizeOptions(code, opts, tokens);
let map = opts.sourceMaps ? new SourceMap(opts, code) : null;
super(format, map, tokens);
let map = opts.sourceMaps ? new SourceMap(opts, code) : null;
super(format, map);
this.ast = ast;
this._whitespace = tokens.length > 0 ? new Whitespace(tokens) : null;
this.ast = ast;
}
format: {
@ -42,7 +37,6 @@ class Generator extends Printer {
}
};
_whitespace: Whitespace;
ast: Object;
/**

View File

@ -3,18 +3,21 @@
import repeat from "lodash/repeat";
import Buffer from "./buffer";
import * as n from "./node";
import Whitespace from "./whitespace";
import * as t from "babel-types";
export default class Printer {
constructor(format, map) {
constructor(format, map, tokens) {
this.format = format || {};
this._buf = new Buffer(map);
this._whitespace = tokens.length > 0 ? new Whitespace(tokens) : null;
}
insideAux: boolean = false;
inForStatementInitCounter: number = 0;
_buf: Buffer;
_whitespace: Whitespace;
_printStack: Array<Node> = [];
_indent: number = 0;
_printedCommentStarts: Object = {};