Sha256: 8ebdc8fd6cfbbd5abf9036ab79cc8fa5f65f5797255b54c40853be92f4bbf133

Contents?: true

Size: 896 Bytes

Versions: 13

Compression:

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

13 entries across 13 versions & 1 rubygems

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