Sha256: 1c9b1049bc206e33c6d58ed6b80072cc406ea3e71fa1b906fd03463525e1d887

Contents?: true

Size: 902 Bytes

Versions: 9

Compression:

Stored size: 902 Bytes

Contents

const {
  addTrailingComment,
  align,
  concat,
  group,
  join,
  line
} = require("../prettier");

function printUndefSymbol(path, opts, print) {
  const node = path.getValue();

  // Since we're going to descend into the symbol literal to grab out the ident
  // node, then we need to make sure we copy over any comments as well,
  // otherwise we could accidentally skip printing them.
  if (node.comments) {
    node.comments.forEach((comment) => {
      addTrailingComment(node.body[0], comment);
    });
  }

  return path.call(print, "body", 0);
}

function printUndef(path, opts, print) {
  const keyword = "undef ";
  const argNodes = path.map(
    (symbolPath) => printUndefSymbol(symbolPath, opts, print),
    "body"
  );

  return group(
    concat([
      keyword,
      align(keyword.length, join(concat([",", line]), argNodes))
    ])
  );
}

module.exports = {
  undef: printUndef
};

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
prettier-1.2.2 src/nodes/undef.js
prettier-1.2.1 src/nodes/undef.js
prettier-1.2.0 src/nodes/undef.js
prettier-1.1.0 src/nodes/undef.js
prettier-1.0.1 src/nodes/undef.js
prettier-1.0.0 src/nodes/undef.js
prettier-1.0.0.pre.rc2 src/nodes/undef.js
prettier-1.0.0.pre.rc1 src/nodes/undef.js
prettier-0.22.0 src/nodes/undef.js