printer.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _buffer = require("./buffer");
  7. var n = require("./node");
  8. var _t = require("@babel/types");
  9. var generatorFunctions = require("./generators");
  10. const {
  11. isFunction,
  12. isStatement,
  13. isClassBody,
  14. isTSInterfaceBody,
  15. isTSEnumDeclaration
  16. } = _t;
  17. const SCIENTIFIC_NOTATION = /e/i;
  18. const ZERO_DECIMAL_INTEGER = /\.0+$/;
  19. const NON_DECIMAL_LITERAL = /^0[box]/;
  20. const PURE_ANNOTATION_RE = /^\s*[@#]__PURE__\s*$/;
  21. const HAS_NEWLINE = /[\n\r\u2028\u2029]/;
  22. const HAS_BlOCK_COMMENT_END = /\*\//;
  23. const {
  24. needsParens
  25. } = n;
  26. class Printer {
  27. constructor(format, map) {
  28. this.inForStatementInitCounter = 0;
  29. this._printStack = [];
  30. this._indent = 0;
  31. this._indentChar = 0;
  32. this._indentRepeat = 0;
  33. this._insideAux = false;
  34. this._parenPushNewlineState = null;
  35. this._noLineTerminator = false;
  36. this._printAuxAfterOnNextUserNode = false;
  37. this._printedComments = new Set();
  38. this._endsWithInteger = false;
  39. this._endsWithWord = false;
  40. this._lastCommentLine = 0;
  41. this._endsWithInnerRaw = false;
  42. this._indentInnerComments = true;
  43. this.format = format;
  44. this._buf = new _buffer.default(map);
  45. this._indentChar = format.indent.style.charCodeAt(0);
  46. this._indentRepeat = format.indent.style.length;
  47. }
  48. generate(ast) {
  49. this.print(ast);
  50. this._maybeAddAuxComment();
  51. return this._buf.get();
  52. }
  53. indent() {
  54. if (this.format.compact || this.format.concise) return;
  55. this._indent++;
  56. }
  57. dedent() {
  58. if (this.format.compact || this.format.concise) return;
  59. this._indent--;
  60. }
  61. semicolon(force = false) {
  62. this._maybeAddAuxComment();
  63. if (force) {
  64. this._appendChar(59);
  65. } else {
  66. this._queue(59);
  67. }
  68. this._noLineTerminator = false;
  69. }
  70. rightBrace() {
  71. if (this.format.minified) {
  72. this._buf.removeLastSemicolon();
  73. }
  74. this.tokenChar(125);
  75. }
  76. space(force = false) {
  77. if (this.format.compact) return;
  78. if (force) {
  79. this._space();
  80. } else if (this._buf.hasContent()) {
  81. const lastCp = this.getLastChar();
  82. if (lastCp !== 32 && lastCp !== 10) {
  83. this._space();
  84. }
  85. }
  86. }
  87. word(str, noLineTerminatorAfter = false) {
  88. this._maybePrintInnerComments();
  89. if (this._endsWithWord || str.charCodeAt(0) === 47 && this.endsWith(47)) {
  90. this._space();
  91. }
  92. this._maybeAddAuxComment();
  93. this._append(str, false);
  94. this._endsWithWord = true;
  95. this._noLineTerminator = noLineTerminatorAfter;
  96. }
  97. number(str) {
  98. this.word(str);
  99. this._endsWithInteger = Number.isInteger(+str) && !NON_DECIMAL_LITERAL.test(str) && !SCIENTIFIC_NOTATION.test(str) && !ZERO_DECIMAL_INTEGER.test(str) && str.charCodeAt(str.length - 1) !== 46;
  100. }
  101. token(str, maybeNewline = false) {
  102. this._maybePrintInnerComments();
  103. const lastChar = this.getLastChar();
  104. const strFirst = str.charCodeAt(0);
  105. if (lastChar === 33 && str === "--" ||
  106. strFirst === 43 && lastChar === 43 || strFirst === 45 && lastChar === 45 ||
  107. strFirst === 46 && this._endsWithInteger) {
  108. this._space();
  109. }
  110. this._maybeAddAuxComment();
  111. this._append(str, maybeNewline);
  112. this._noLineTerminator = false;
  113. }
  114. tokenChar(char) {
  115. this._maybePrintInnerComments();
  116. const lastChar = this.getLastChar();
  117. if (
  118. char === 43 && lastChar === 43 || char === 45 && lastChar === 45 ||
  119. char === 46 && this._endsWithInteger) {
  120. this._space();
  121. }
  122. this._maybeAddAuxComment();
  123. this._appendChar(char);
  124. this._noLineTerminator = false;
  125. }
  126. newline(i = 1, force) {
  127. if (i <= 0) return;
  128. if (!force) {
  129. if (this.format.retainLines || this.format.compact) return;
  130. if (this.format.concise) {
  131. this.space();
  132. return;
  133. }
  134. }
  135. if (i > 2) i = 2;
  136. i -= this._buf.getNewlineCount();
  137. for (let j = 0; j < i; j++) {
  138. this._newline();
  139. }
  140. return;
  141. }
  142. endsWith(char) {
  143. return this.getLastChar() === char;
  144. }
  145. getLastChar() {
  146. return this._buf.getLastChar();
  147. }
  148. endsWithCharAndNewline() {
  149. return this._buf.endsWithCharAndNewline();
  150. }
  151. removeTrailingNewline() {
  152. this._buf.removeTrailingNewline();
  153. }
  154. exactSource(loc, cb) {
  155. if (!loc) return cb();
  156. this._catchUp("start", loc);
  157. this._buf.exactSource(loc, cb);
  158. }
  159. source(prop, loc) {
  160. if (!loc) return;
  161. this._catchUp(prop, loc);
  162. this._buf.source(prop, loc);
  163. }
  164. sourceWithOffset(prop, loc, lineOffset, columnOffset) {
  165. if (!loc) return;
  166. this._catchUp(prop, loc);
  167. this._buf.sourceWithOffset(prop, loc, lineOffset, columnOffset);
  168. }
  169. withSource(prop, loc, cb) {
  170. if (!loc) return cb();
  171. this._catchUp(prop, loc);
  172. this._buf.withSource(prop, loc, cb);
  173. }
  174. _space() {
  175. this._queue(32);
  176. }
  177. _newline() {
  178. this._queue(10);
  179. }
  180. _append(str, maybeNewline) {
  181. this._maybeAddParen(str);
  182. this._maybeIndent(str.charCodeAt(0));
  183. this._buf.append(str, maybeNewline);
  184. this._endsWithWord = false;
  185. this._endsWithInteger = false;
  186. }
  187. _appendChar(char) {
  188. this._maybeAddParenChar(char);
  189. this._maybeIndent(char);
  190. this._buf.appendChar(char);
  191. this._endsWithWord = false;
  192. this._endsWithInteger = false;
  193. }
  194. _queue(char) {
  195. this._maybeAddParenChar(char);
  196. this._maybeIndent(char);
  197. this._buf.queue(char);
  198. this._endsWithWord = false;
  199. this._endsWithInteger = false;
  200. }
  201. _maybeIndent(firstChar) {
  202. if (this._indent && firstChar !== 10 && this.endsWith(10)) {
  203. this._buf.queueIndentation(this._indentChar, this._getIndent());
  204. }
  205. }
  206. _shouldIndent(firstChar) {
  207. if (this._indent && firstChar !== 10 && this.endsWith(10)) {
  208. return true;
  209. }
  210. }
  211. _maybeAddParenChar(char) {
  212. const parenPushNewlineState = this._parenPushNewlineState;
  213. if (!parenPushNewlineState) return;
  214. if (char === 32) {
  215. return;
  216. }
  217. if (char !== 10) {
  218. this._parenPushNewlineState = null;
  219. return;
  220. }
  221. this.tokenChar(40);
  222. this.indent();
  223. parenPushNewlineState.printed = true;
  224. }
  225. _maybeAddParen(str) {
  226. const parenPushNewlineState = this._parenPushNewlineState;
  227. if (!parenPushNewlineState) return;
  228. const len = str.length;
  229. let i;
  230. for (i = 0; i < len && str.charCodeAt(i) === 32; i++) continue;
  231. if (i === len) {
  232. return;
  233. }
  234. const cha = str.charCodeAt(i);
  235. if (cha !== 10) {
  236. if (
  237. cha !== 47 ||
  238. i + 1 === len) {
  239. this._parenPushNewlineState = null;
  240. return;
  241. }
  242. const chaPost = str.charCodeAt(i + 1);
  243. if (chaPost === 42) {
  244. if (PURE_ANNOTATION_RE.test(str.slice(i + 2, len - 2))) {
  245. return;
  246. }
  247. } else if (chaPost !== 47) {
  248. this._parenPushNewlineState = null;
  249. return;
  250. }
  251. }
  252. this.tokenChar(40);
  253. this.indent();
  254. parenPushNewlineState.printed = true;
  255. }
  256. catchUp(line) {
  257. if (!this.format.retainLines) return;
  258. const count = line - this._buf.getCurrentLine();
  259. for (let i = 0; i < count; i++) {
  260. this._newline();
  261. }
  262. }
  263. _catchUp(prop, loc) {
  264. if (!this.format.retainLines) return;
  265. const pos = loc ? loc[prop] : null;
  266. if ((pos == null ? void 0 : pos.line) != null) {
  267. const count = pos.line - this._buf.getCurrentLine();
  268. for (let i = 0; i < count; i++) {
  269. this._newline();
  270. }
  271. }
  272. }
  273. _getIndent() {
  274. return this._indentRepeat * this._indent;
  275. }
  276. printTerminatorless(node, parent, isLabel) {
  277. if (isLabel) {
  278. this._noLineTerminator = true;
  279. this.print(node, parent);
  280. } else {
  281. const terminatorState = {
  282. printed: false
  283. };
  284. this._parenPushNewlineState = terminatorState;
  285. this.print(node, parent);
  286. if (terminatorState.printed) {
  287. this.dedent();
  288. this.newline();
  289. this.tokenChar(41);
  290. }
  291. }
  292. }
  293. print(node, parent, noLineTerminatorAfter,
  294. trailingCommentsLineOffset, forceParens) {
  295. if (!node) return;
  296. this._endsWithInnerRaw = false;
  297. const nodeType = node.type;
  298. const format = this.format;
  299. const oldConcise = format.concise;
  300. if (
  301. node._compact) {
  302. format.concise = true;
  303. }
  304. const printMethod = this[nodeType];
  305. if (printMethod === undefined) {
  306. throw new ReferenceError(`unknown node of type ${JSON.stringify(nodeType)} with constructor ${JSON.stringify(node.constructor.name)}`);
  307. }
  308. this._printStack.push(node);
  309. const oldInAux = this._insideAux;
  310. this._insideAux = node.loc == undefined;
  311. this._maybeAddAuxComment(this._insideAux && !oldInAux);
  312. let shouldPrintParens = false;
  313. if (forceParens) {
  314. shouldPrintParens = true;
  315. } else if (format.retainFunctionParens && nodeType === "FunctionExpression" && node.extra && node.extra.parenthesized) {
  316. shouldPrintParens = true;
  317. } else {
  318. shouldPrintParens = needsParens(node, parent, this._printStack);
  319. }
  320. if (shouldPrintParens) {
  321. this.tokenChar(40);
  322. this._endsWithInnerRaw = false;
  323. }
  324. this._lastCommentLine = 0;
  325. this._printLeadingComments(node, parent);
  326. const loc = nodeType === "Program" || nodeType === "File" ? null : node.loc;
  327. this.exactSource(loc, printMethod.bind(this, node, parent));
  328. if (shouldPrintParens) {
  329. this._printTrailingComments(node, parent);
  330. this.tokenChar(41);
  331. this._noLineTerminator = noLineTerminatorAfter;
  332. } else if (noLineTerminatorAfter && !this._noLineTerminator) {
  333. this._noLineTerminator = true;
  334. this._printTrailingComments(node, parent);
  335. } else {
  336. this._printTrailingComments(node, parent, trailingCommentsLineOffset);
  337. }
  338. this._printStack.pop();
  339. format.concise = oldConcise;
  340. this._insideAux = oldInAux;
  341. this._endsWithInnerRaw = false;
  342. }
  343. _maybeAddAuxComment(enteredPositionlessNode) {
  344. if (enteredPositionlessNode) this._printAuxBeforeComment();
  345. if (!this._insideAux) this._printAuxAfterComment();
  346. }
  347. _printAuxBeforeComment() {
  348. if (this._printAuxAfterOnNextUserNode) return;
  349. this._printAuxAfterOnNextUserNode = true;
  350. const comment = this.format.auxiliaryCommentBefore;
  351. if (comment) {
  352. this._printComment({
  353. type: "CommentBlock",
  354. value: comment
  355. }, 0);
  356. }
  357. }
  358. _printAuxAfterComment() {
  359. if (!this._printAuxAfterOnNextUserNode) return;
  360. this._printAuxAfterOnNextUserNode = false;
  361. const comment = this.format.auxiliaryCommentAfter;
  362. if (comment) {
  363. this._printComment({
  364. type: "CommentBlock",
  365. value: comment
  366. }, 0);
  367. }
  368. }
  369. getPossibleRaw(node) {
  370. const extra = node.extra;
  371. if (extra && extra.raw != null && extra.rawValue != null && node.value === extra.rawValue) {
  372. return extra.raw;
  373. }
  374. }
  375. printJoin(nodes, parent, opts = {}) {
  376. if (!(nodes != null && nodes.length)) return;
  377. if (opts.indent) this.indent();
  378. const newlineOpts = {
  379. addNewlines: opts.addNewlines,
  380. nextNodeStartLine: 0
  381. };
  382. const separator = opts.separator ? opts.separator.bind(this) : null;
  383. const len = nodes.length;
  384. for (let i = 0; i < len; i++) {
  385. const node = nodes[i];
  386. if (!node) continue;
  387. if (opts.statement) this._printNewline(i === 0, newlineOpts);
  388. this.print(node, parent, undefined, opts.trailingCommentsLineOffset || 0);
  389. opts.iterator == null ? void 0 : opts.iterator(node, i);
  390. if (i < len - 1) separator == null ? void 0 : separator();
  391. if (opts.statement) {
  392. if (i + 1 === len) {
  393. this.newline(1);
  394. } else {
  395. var _nextNode$loc;
  396. const nextNode = nodes[i + 1];
  397. newlineOpts.nextNodeStartLine = ((_nextNode$loc = nextNode.loc) == null ? void 0 : _nextNode$loc.start.line) || 0;
  398. this._printNewline(true, newlineOpts);
  399. }
  400. }
  401. }
  402. if (opts.indent) this.dedent();
  403. }
  404. printAndIndentOnComments(node, parent) {
  405. const indent = node.leadingComments && node.leadingComments.length > 0;
  406. if (indent) this.indent();
  407. this.print(node, parent);
  408. if (indent) this.dedent();
  409. }
  410. printBlock(parent) {
  411. const node = parent.body;
  412. if (node.type !== "EmptyStatement") {
  413. this.space();
  414. }
  415. this.print(node, parent);
  416. }
  417. _printTrailingComments(node, parent, lineOffset) {
  418. const {
  419. innerComments,
  420. trailingComments
  421. } = node;
  422. if (innerComments != null && innerComments.length) {
  423. this._printComments(2, innerComments, node, parent, lineOffset);
  424. }
  425. if (trailingComments != null && trailingComments.length) {
  426. this._printComments(2, trailingComments, node, parent, lineOffset);
  427. }
  428. }
  429. _printLeadingComments(node, parent) {
  430. const comments = node.leadingComments;
  431. if (!(comments != null && comments.length)) return;
  432. this._printComments(0, comments, node, parent);
  433. }
  434. _maybePrintInnerComments() {
  435. if (this._endsWithInnerRaw) this.printInnerComments();
  436. this._endsWithInnerRaw = true;
  437. this._indentInnerComments = true;
  438. }
  439. printInnerComments() {
  440. const node = this._printStack[this._printStack.length - 1];
  441. const comments = node.innerComments;
  442. if (!(comments != null && comments.length)) return;
  443. const hasSpace = this.endsWith(32);
  444. const indent = this._indentInnerComments;
  445. const printedCommentsCount = this._printedComments.size;
  446. if (indent) this.indent();
  447. this._printComments(1, comments, node);
  448. if (hasSpace && printedCommentsCount !== this._printedComments.size) {
  449. this.space();
  450. }
  451. if (indent) this.dedent();
  452. }
  453. noIndentInnerCommentsHere() {
  454. this._indentInnerComments = false;
  455. }
  456. printSequence(nodes, parent, opts = {}) {
  457. opts.statement = true;
  458. return this.printJoin(nodes, parent, opts);
  459. }
  460. printList(items, parent, opts = {}) {
  461. if (opts.separator == null) {
  462. opts.separator = commaSeparator;
  463. }
  464. return this.printJoin(items, parent, opts);
  465. }
  466. _printNewline(newLine, opts) {
  467. if (this.format.retainLines || this.format.compact) return;
  468. if (this.format.concise) {
  469. this.space();
  470. return;
  471. }
  472. if (!newLine) {
  473. return;
  474. }
  475. const startLine = opts.nextNodeStartLine;
  476. const lastCommentLine = this._lastCommentLine;
  477. if (startLine > 0 && lastCommentLine > 0) {
  478. const offset = startLine - lastCommentLine;
  479. if (offset >= 0) {
  480. this.newline(offset || 1);
  481. return;
  482. }
  483. }
  484. if (this._buf.hasContent()) {
  485. this.newline(1);
  486. }
  487. }
  488. _shouldPrintComment(comment) {
  489. if (comment.ignore) return 0;
  490. if (this._printedComments.has(comment)) return 0;
  491. if (this._noLineTerminator && (HAS_NEWLINE.test(comment.value) || HAS_BlOCK_COMMENT_END.test(comment.value))) {
  492. return 2;
  493. }
  494. this._printedComments.add(comment);
  495. if (!this.format.shouldPrintComment(comment.value)) {
  496. return 0;
  497. }
  498. return 1;
  499. }
  500. _printComment(comment, skipNewLines) {
  501. const noLineTerminator = this._noLineTerminator;
  502. const isBlockComment = comment.type === "CommentBlock";
  503. const printNewLines = isBlockComment && skipNewLines !== 1 && !this._noLineTerminator;
  504. if (printNewLines && this._buf.hasContent() && skipNewLines !== 2) {
  505. this.newline(1);
  506. }
  507. const lastCharCode = this.getLastChar();
  508. if (lastCharCode !== 91 && lastCharCode !== 123) {
  509. this.space();
  510. }
  511. let val;
  512. if (isBlockComment) {
  513. val = `/*${comment.value}*/`;
  514. if (this.format.indent.adjustMultilineComment) {
  515. var _comment$loc;
  516. const offset = (_comment$loc = comment.loc) == null ? void 0 : _comment$loc.start.column;
  517. if (offset) {
  518. const newlineRegex = new RegExp("\\n\\s{1," + offset + "}", "g");
  519. val = val.replace(newlineRegex, "\n");
  520. }
  521. let indentSize = this.format.retainLines ? 0 : this._buf.getCurrentColumn();
  522. if (this._shouldIndent(47) || this.format.retainLines) {
  523. indentSize += this._getIndent();
  524. }
  525. val = val.replace(/\n(?!$)/g, `\n${" ".repeat(indentSize)}`);
  526. }
  527. } else if (!noLineTerminator) {
  528. val = `//${comment.value}`;
  529. } else {
  530. val = `/*${comment.value}*/`;
  531. }
  532. if (this.endsWith(47)) this._space();
  533. this.source("start", comment.loc);
  534. this._append(val, isBlockComment);
  535. if (!isBlockComment && !noLineTerminator) {
  536. this.newline(1, true);
  537. }
  538. if (printNewLines && skipNewLines !== 3) {
  539. this.newline(1);
  540. }
  541. }
  542. _printComments(type, comments, node, parent, lineOffset = 0) {
  543. const nodeLoc = node.loc;
  544. const len = comments.length;
  545. let hasLoc = !!nodeLoc;
  546. const nodeStartLine = hasLoc ? nodeLoc.start.line : 0;
  547. const nodeEndLine = hasLoc ? nodeLoc.end.line : 0;
  548. let lastLine = 0;
  549. let leadingCommentNewline = 0;
  550. const maybeNewline = this._noLineTerminator ? function () {} : this.newline.bind(this);
  551. for (let i = 0; i < len; i++) {
  552. const comment = comments[i];
  553. const shouldPrint = this._shouldPrintComment(comment);
  554. if (shouldPrint === 2) {
  555. hasLoc = false;
  556. break;
  557. }
  558. if (hasLoc && comment.loc && shouldPrint === 1) {
  559. const commentStartLine = comment.loc.start.line;
  560. const commentEndLine = comment.loc.end.line;
  561. if (type === 0) {
  562. let offset = 0;
  563. if (i === 0) {
  564. if (this._buf.hasContent() && (comment.type === "CommentLine" || commentStartLine != commentEndLine)) {
  565. offset = leadingCommentNewline = 1;
  566. }
  567. } else {
  568. offset = commentStartLine - lastLine;
  569. }
  570. lastLine = commentEndLine;
  571. maybeNewline(offset);
  572. this._printComment(comment, 1);
  573. if (i + 1 === len) {
  574. maybeNewline(Math.max(nodeStartLine - lastLine, leadingCommentNewline));
  575. lastLine = nodeStartLine;
  576. }
  577. } else if (type === 1) {
  578. const offset = commentStartLine - (i === 0 ? nodeStartLine : lastLine);
  579. lastLine = commentEndLine;
  580. maybeNewline(offset);
  581. this._printComment(comment, 1);
  582. if (i + 1 === len) {
  583. maybeNewline(Math.min(1, nodeEndLine - lastLine));
  584. lastLine = nodeEndLine;
  585. }
  586. } else {
  587. const offset = commentStartLine - (i === 0 ? nodeEndLine - lineOffset : lastLine);
  588. lastLine = commentEndLine;
  589. maybeNewline(offset);
  590. this._printComment(comment, 1);
  591. }
  592. } else {
  593. hasLoc = false;
  594. if (shouldPrint !== 1) {
  595. continue;
  596. }
  597. if (len === 1) {
  598. const singleLine = comment.loc ? comment.loc.start.line === comment.loc.end.line : !HAS_NEWLINE.test(comment.value);
  599. const shouldSkipNewline = singleLine && !isStatement(node) && !isClassBody(parent) && !isTSInterfaceBody(parent) && !isTSEnumDeclaration(parent);
  600. if (type === 0) {
  601. this._printComment(comment, shouldSkipNewline && node.type !== "ObjectExpression" || singleLine && isFunction(parent, {
  602. body: node
  603. }) ? 1 : 0);
  604. } else if (shouldSkipNewline && type === 2) {
  605. this._printComment(comment, 1);
  606. } else {
  607. this._printComment(comment, 0);
  608. }
  609. } else if (type === 1 && !(node.type === "ObjectExpression" && node.properties.length > 1) && node.type !== "ClassBody" && node.type !== "TSInterfaceBody") {
  610. this._printComment(comment, i === 0 ? 2 : i === len - 1 ? 3 : 0);
  611. } else {
  612. this._printComment(comment, 0);
  613. }
  614. }
  615. }
  616. if (type === 2 && hasLoc && lastLine) {
  617. this._lastCommentLine = lastLine;
  618. }
  619. }
  620. }
  621. Object.assign(Printer.prototype, generatorFunctions);
  622. {
  623. Printer.prototype.Noop = function Noop() {};
  624. }
  625. var _default = Printer;
  626. exports.default = _default;
  627. function commaSeparator() {
  628. this.tokenChar(44);
  629. this.space();
  630. }
  631. //# sourceMappingURL=printer.js.map