Sha256: bae7836af91bc31291c9b0c1a0d4209df9631e53359cc9e1e988cd591d3481a4

Contents?: true

Size: 1.83 KB

Versions: 37

Compression:

Stored size: 1.83 KB

Contents

"use strict";

exports.__esModule = true;
exports.ClassDeclaration = ClassDeclaration;
exports.ClassBody = ClassBody;
exports.ClassProperty = ClassProperty;
exports.ClassMethod = ClassMethod;
function ClassDeclaration(node) {
  this.printJoin(node.decorators, node);
  this.word("class");

  if (node.id) {
    this.space();
    this.print(node.id, node);
  }

  this.print(node.typeParameters, node);

  if (node.superClass) {
    this.space();
    this.word("extends");
    this.space();
    this.print(node.superClass, node);
    this.print(node.superTypeParameters, node);
  }

  if (node.implements) {
    this.space();
    this.word("implements");
    this.space();
    this.printList(node.implements, node);
  }

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

exports.ClassExpression = ClassDeclaration;
function ClassBody(node) {
  this.token("{");
  this.printInnerComments(node);
  if (node.body.length === 0) {
    this.token("}");
  } else {
    this.newline();

    this.indent();
    this.printSequence(node.body, node);
    this.dedent();

    if (!this.endsWith("\n")) this.newline();

    this.rightBrace();
  }
}

function ClassProperty(node) {
  this.printJoin(node.decorators, node);

  if (node.static) {
    this.word("static");
    this.space();
  }
  if (node.computed) {
    this.token("[");
    this.print(node.key, node);
    this.token("]");
  } else {
    this._variance(node);
    this.print(node.key, node);
  }
  this.print(node.typeAnnotation, node);
  if (node.value) {
    this.space();
    this.token("=");
    this.space();
    this.print(node.value, node);
  }
  this.semicolon();
}

function ClassMethod(node) {
  this.printJoin(node.decorators, node);

  if (node.static) {
    this.word("static");
    this.space();
  }

  if (node.kind === "constructorCall") {
    this.word("call");
    this.space();
  }

  this._method(node);
}

Version data entries

37 entries across 37 versions & 9 rubygems

Version Path
immosquare-cleaner-0.1.60 node_modules/babel-generator/lib/generators/classes.js
immosquare-cleaner-0.1.59 node_modules/babel-generator/lib/generators/classes.js
immosquare-cleaner-0.1.58 node_modules/babel-generator/lib/generators/classes.js
immosquare-cleaner-0.1.57 node_modules/babel-generator/lib/generators/classes.js
immosquare-cleaner-0.1.56 node_modules/babel-generator/lib/generators/classes.js
immosquare-cleaner-0.1.55 node_modules/babel-generator/lib/generators/classes.js
immosquare-cleaner-0.1.54 node_modules/babel-generator/lib/generators/classes.js
immosquare-cleaner-0.1.53 node_modules/babel-generator/lib/generators/classes.js
immosquare-cleaner-0.1.52 node_modules/babel-generator/lib/generators/classes.js
immosquare-cleaner-0.1.51 node_modules/babel-generator/lib/generators/classes.js
immosquare-cleaner-0.1.50 node_modules/babel-generator/lib/generators/classes.js
immosquare-cleaner-0.1.49 node_modules/babel-generator/lib/generators/classes.js
immosquare-cleaner-0.1.48 node_modules/babel-generator/lib/generators/classes.js
immosquare-cleaner-0.1.47 node_modules/babel-generator/lib/generators/classes.js
immosquare-cleaner-0.1.46 node_modules/babel-generator/lib/generators/classes.js
immosquare-cleaner-0.1.45 node_modules/babel-generator/lib/generators/classes.js
immosquare-cleaner-0.1.44 node_modules/babel-generator/lib/generators/classes.js
immosquare-cleaner-0.1.43 node_modules/babel-generator/lib/generators/classes.js
immosquare-cleaner-0.1.42 node_modules/babel-generator/lib/generators/classes.js
immosquare-cleaner-0.1.41 node_modules/babel-generator/lib/generators/classes.js