Explicitly label standalone tokens and words.

This commit is contained in:
Logan Smyth
2016-04-30 13:45:29 -07:00
parent e702e67233
commit 4286cb4f2a
12 changed files with 245 additions and 220 deletions

View File

@@ -98,7 +98,7 @@ export default class Buffer {
*/
semicolon() {
this.push(";");
this.token(";");
}
/**
@@ -110,7 +110,7 @@ export default class Buffer {
if (this.format.minified && !this._lastPrintedIsEmptyStatement) {
this._removeLast(";");
}
this.push("}");
this.token("}");
}
/**
@@ -118,7 +118,7 @@ export default class Buffer {
*/
keyword(name: string) {
this.push(name);
this.word(name);
this.space();
}
@@ -134,6 +134,23 @@ export default class Buffer {
}
}
/**
* Writes a token that can't be safely parsed without taking whitespace into account.
*/
word(str: string) {
this.push(str);
}
/**
* Writes a simple token.
*/
token(str: string) {
this.push(str);
}
/**
* Remove the last character.
*/
@@ -180,7 +197,7 @@ export default class Buffer {
if (state.printed) {
this.dedent();
this.newline();
this.push(")");
this.token(")");
}
}