1
|
"use strict";
|
2
|
|
3
|
exports.__esModule = true;
|
4
|
exports.File = File;
|
5
|
exports.Program = Program;
|
6
|
exports.BlockStatement = BlockStatement;
|
7
|
exports.Noop = Noop;
|
8
|
exports.Directive = Directive;
|
9
|
|
10
|
var _types = require("./types");
|
11
|
|
12
|
Object.defineProperty(exports, "DirectiveLiteral", {
|
13
|
enumerable: true,
|
14
|
get: function get() {
|
15
|
return _types.StringLiteral;
|
16
|
}
|
17
|
});
|
18
|
function File(node) {
|
19
|
this.print(node.program, node);
|
20
|
}
|
21
|
|
22
|
function Program(node) {
|
23
|
this.printInnerComments(node, false);
|
24
|
|
25
|
this.printSequence(node.directives, node);
|
26
|
if (node.directives && node.directives.length) this.newline();
|
27
|
|
28
|
this.printSequence(node.body, node);
|
29
|
}
|
30
|
|
31
|
function BlockStatement(node) {
|
32
|
this.token("{");
|
33
|
this.printInnerComments(node);
|
34
|
|
35
|
var hasDirectives = node.directives && node.directives.length;
|
36
|
|
37
|
if (node.body.length || hasDirectives) {
|
38
|
this.newline();
|
39
|
|
40
|
this.printSequence(node.directives, node, { indent: true });
|
41
|
if (hasDirectives) this.newline();
|
42
|
|
43
|
this.printSequence(node.body, node, { indent: true });
|
44
|
this.removeTrailingNewline();
|
45
|
|
46
|
this.source("end", node.loc);
|
47
|
|
48
|
if (!this.endsWith("\n")) this.newline();
|
49
|
|
50
|
this.rightBrace();
|
51
|
} else {
|
52
|
this.source("end", node.loc);
|
53
|
this.token("}");
|
54
|
}
|
55
|
}
|
56
|
|
57
|
function Noop() {}
|
58
|
|
59
|
function Directive(node) {
|
60
|
this.print(node.value, node);
|
61
|
this.semicolon();
|
62
|
}
|