Sha256: eb89a53d5d7a52e08d6180c559adb8b554f6229ccab0be91379589af510c1fcc

Contents?: true

Size: 1.95 KB

Versions: 31

Compression:

Stored size: 1.95 KB

Contents

/* */ 
"format cjs";
/**
 * Print ClassDeclaration, prints decorators, typeParameters, extends, implements, and body.
 */

"use strict";

exports.__esModule = true;
exports.ClassDeclaration = ClassDeclaration;
exports.ClassBody = ClassBody;
exports.ClassProperty = ClassProperty;
exports.MethodDefinition = MethodDefinition;

function ClassDeclaration(node, print) {
  print.list(node.decorators, { separator: "" });
  this.push("class");

  if (node.id) {
    this.push(" ");
    print.plain(node.id);
  }

  print.plain(node.typeParameters);

  if (node.superClass) {
    this.push(" extends ");
    print.plain(node.superClass);
    print.plain(node.superTypeParameters);
  }

  if (node["implements"]) {
    this.push(" implements ");
    print.join(node["implements"], { separator: ", " });
  }

  this.space();
  print.plain(node.body);
}

/**
 * Alias ClassDeclaration printer as ClassExpression.
 */

exports.ClassExpression = ClassDeclaration;

/**
 * Print ClassBody, collapses empty blocks, prints body.
 */

function ClassBody(node, print) {
  this.push("{");
  if (node.body.length === 0) {
    print.printInnerComments();
    this.push("}");
  } else {
    this.newline();

    this.indent();
    print.sequence(node.body);
    this.dedent();

    this.rightBrace();
  }
}

/**
 * Print ClassProperty, prints decorators, static, key, typeAnnotation, and value.
 * Also: semicolons, deal with it.
 */

function ClassProperty(node, print) {
  print.list(node.decorators, { separator: "" });

  if (node["static"]) this.push("static ");
  print.plain(node.key);
  print.plain(node.typeAnnotation);
  if (node.value) {
    this.space();
    this.push("=");
    this.space();
    print.plain(node.value);
  }
  this.semicolon();
}

/**
 * Print MethodDefinition, prints decorations, static, and method.
 */

function MethodDefinition(node, print) {
  print.list(node.decorators, { separator: "" });

  if (node["static"]) {
    this.push("static ");
  }

  this._method(node, print);
}

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
sequenceserver-3.1.3 public/vendor/npm/babel-core@5.8.23/lib/generation/generators/classes.js
sequenceserver-3.1.2 public/vendor/npm/babel-core@5.8.23/lib/generation/generators/classes.js
sequenceserver-3.1.1 public/vendor/npm/babel-core@5.8.23/lib/generation/generators/classes.js
sequenceserver-3.1.0 public/vendor/npm/babel-core@5.8.23/lib/generation/generators/classes.js
sequenceserver-3.0.1 public/vendor/npm/babel-core@5.8.23/lib/generation/generators/classes.js
sequenceserver-3.0 public/vendor/npm/babel-core@5.8.23/lib/generation/generators/classes.js
sequenceserver-2.2.0 public/vendor/npm/babel-core@5.8.23/lib/generation/generators/classes.js
sequenceserver-2.1.0 public/vendor/npm/babel-core@5.8.23/lib/generation/generators/classes.js
sequenceserver-2.0.0 public/vendor/npm/babel-core@5.8.23/lib/generation/generators/classes.js
sequenceserver-2.0.0.rc8 public/vendor/npm/babel-core@5.8.23/lib/generation/generators/classes.js
sequenceserver-2.0.0.rc7 public/vendor/npm/babel-core@5.8.23/lib/generation/generators/classes.js
sequenceserver-2.0.0.rc6 public/vendor/npm/babel-core@5.8.23/lib/generation/generators/classes.js
sequenceserver-2.0.0.rc5 public/vendor/npm/babel-core@5.8.23/lib/generation/generators/classes.js
sequenceserver-2.0.0.rc4 public/vendor/npm/babel-core@5.8.23/lib/generation/generators/classes.js
sequenceserver-2.0.0.rc3 public/vendor/npm/babel-core@5.8.23/lib/generation/generators/classes.js
sequenceserver-2.0.0.rc2 public/vendor/npm/babel-core@5.8.23/lib/generation/generators/classes.js
sequenceserver-2.0.0.rc1 public/vendor/npm/babel-core@5.8.23/lib/generation/generators/classes.js
sequenceserver-2.0.0.beta4 public/vendor/npm/babel-core@5.8.23/lib/generation/generators/classes.js
sequenceserver-2.0.0.beta3 public/vendor/npm/babel-core@5.8.23/lib/generation/generators/classes.js
sequenceserver-2.0.0.beta1 public/vendor/npm/babel-core@5.8.23/lib/generation/generators/classes.js