Sha256: 518cbdc94dc2b2ffe65071a88609c53ef07f2f5ad1d60a72a426075496f1e426

Contents?: true

Size: 890 Bytes

Versions: 9

Compression:

Stored size: 890 Bytes

Contents

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

function printSuper(path, opts, print) {
  const args = path.getValue().body[0];

  if (args.type === "arg_paren") {
    // In case there are explicitly no arguments but they are using parens,
    // we assume they are attempting to override the initializer and pass no
    // arguments up.
    if (args.body[0] === null) {
      return "super()";
    }

    return concat(["super", path.call(print, "body", 0)]);
  }

  const keyword = "super ";
  const argsDocs = path.call(print, "body", 0);

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

// Version of super without any parens or args.
const printZSuper = literal("super");

module.exports = {
  super: printSuper,
  zsuper: printZSuper
};

Version data entries

9 entries across 9 versions & 1 rubygems

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