Sha256: b2fc3608cad0f6e477b5bf6abfa9733e0f93efaa97f381f50a3e2a0815ecace2

Contents?: true

Size: 1020 Bytes

Versions: 9

Compression:

Stored size: 1020 Bytes

Contents

const { concat, group, indent, join, softline } = require("../prettier");
const { makeCall } = require("../utils");

function printConstPath(path, opts, print) {
  return join("::", path.map(print, "body"));
}

function printConstRef(path, opts, print) {
  return path.call(print, "body", 0);
}

function printDefined(path, opts, print) {
  return group(
    concat([
      "defined?(",
      indent(concat([softline, path.call(print, "body", 0)])),
      concat([softline, ")"])
    ])
  );
}

function printField(path, opts, print) {
  return group(
    concat([
      path.call(print, "body", 0),
      concat([makeCall(path, opts, print), path.call(print, "body", 2)])
    ])
  );
}

function printTopConst(path, opts, print) {
  return concat(["::", path.call(print, "body", 0)]);
}

module.exports = {
  const_path_field: printConstPath,
  const_path_ref: printConstPath,
  const_ref: printConstRef,
  defined: printDefined,
  field: printField,
  top_const_field: printTopConst,
  top_const_ref: printTopConst
};

Version data entries

9 entries across 9 versions & 1 rubygems

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