base.js 1.2 KB

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