Sha256: 642d997f85de67926bf516de73da491ad926832d87b2aa11b34b43f0447fb7b2

Contents?: true

Size: 905 Bytes

Versions: 13

Compression:

Stored size: 905 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

13 entries across 13 versions & 1 rubygems

Version Path
prettier-1.6.1 src/ruby/nodes/undef.js
prettier-1.6.0 src/ruby/nodes/undef.js
prettier-1.5.5 src/ruby/nodes/undef.js
prettier-1.5.4 src/ruby/nodes/undef.js
prettier-1.5.3 src/ruby/nodes/undef.js
prettier-1.5.2 src/ruby/nodes/undef.js
prettier-1.5.1 src/ruby/nodes/undef.js
prettier-1.5.0 src/ruby/nodes/undef.js
prettier-1.4.0 src/ruby/nodes/undef.js
prettier-1.3.0 src/ruby/nodes/undef.js
prettier-1.2.5 src/ruby/nodes/undef.js
prettier-1.2.4 src/ruby/nodes/undef.js
prettier-1.2.3 src/ruby/nodes/undef.js