const { concat, group, indent, join, line, softline } = require("../prettier"); const { makeList } = require("../utils"); module.exports = { massign: (path, opts, print) => { let right = path.call(print, "body", 1); if ( ["mrhs_add_star", "mrhs_new_from_args"].includes( path.getValue().body[1].type ) ) { right = group(join(concat([",", line]), right)); } return group( concat([ group(join(concat([",", line]), path.call(print, "body", 0))), " =", indent(concat([line, right])) ]) ); }, mlhs: makeList, mlhs_add_post: (path, opts, print) => path.call(print, "body", 0).concat(path.call(print, "body", 1)), mlhs_add_star: (path, opts, print) => path .call(print, "body", 0) .concat([ path.getValue().body[1] ? concat(["*", path.call(print, "body", 1)]) : "*" ]), mlhs_paren: (path, opts, print) => { if (["massign", "mlhs_paren"].includes(path.getParentNode().type)) { // If we're nested in brackets as part of the left hand side of an // assignment, i.e., (a, b, c) = 1, 2, 3 // ignore the current node and just go straight to the content return path.call(print, "body", 0); } return group( concat([ "(", indent( concat([ softline, join(concat([",", line]), path.call(print, "body", 0)) ]) ), concat([softline, ")"]) ]) ); }, mrhs: makeList, mrhs_add_star: (path, opts, print) => path .call(print, "body", 0) .concat([concat(["*", path.call(print, "body", 1)])]), mrhs_new_from_args: (path, opts, print) => { const parts = path.call(print, "body", 0); if (path.getValue().body.length > 1) { parts.push(path.call(print, "body", 1)); } return parts; } };