Projekt

Obecné

Profil

Stáhnout (1.83 KB) Statistiky
| Větev: | Revize:
1
"use strict";
2

    
3
exports.__esModule = true;
4
exports.ClassDeclaration = ClassDeclaration;
5
exports.ClassBody = ClassBody;
6
exports.ClassProperty = ClassProperty;
7
exports.ClassMethod = ClassMethod;
8
function ClassDeclaration(node) {
9
  this.printJoin(node.decorators, node);
10
  this.word("class");
11

    
12
  if (node.id) {
13
    this.space();
14
    this.print(node.id, node);
15
  }
16

    
17
  this.print(node.typeParameters, node);
18

    
19
  if (node.superClass) {
20
    this.space();
21
    this.word("extends");
22
    this.space();
23
    this.print(node.superClass, node);
24
    this.print(node.superTypeParameters, node);
25
  }
26

    
27
  if (node.implements) {
28
    this.space();
29
    this.word("implements");
30
    this.space();
31
    this.printList(node.implements, node);
32
  }
33

    
34
  this.space();
35
  this.print(node.body, node);
36
}
37

    
38
exports.ClassExpression = ClassDeclaration;
39
function ClassBody(node) {
40
  this.token("{");
41
  this.printInnerComments(node);
42
  if (node.body.length === 0) {
43
    this.token("}");
44
  } else {
45
    this.newline();
46

    
47
    this.indent();
48
    this.printSequence(node.body, node);
49
    this.dedent();
50

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

    
53
    this.rightBrace();
54
  }
55
}
56

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

    
60
  if (node.static) {
61
    this.word("static");
62
    this.space();
63
  }
64
  if (node.computed) {
65
    this.token("[");
66
    this.print(node.key, node);
67
    this.token("]");
68
  } else {
69
    this._variance(node);
70
    this.print(node.key, node);
71
  }
72
  this.print(node.typeAnnotation, node);
73
  if (node.value) {
74
    this.space();
75
    this.token("=");
76
    this.space();
77
    this.print(node.value, node);
78
  }
79
  this.semicolon();
80
}
81

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

    
85
  if (node.static) {
86
    this.word("static");
87
    this.space();
88
  }
89

    
90
  if (node.kind === "constructorCall") {
91
    this.word("call");
92
    this.space();
93
  }
94

    
95
  this._method(node);
96
}
(2-2/10)