-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathclass.js
56 lines (45 loc) · 1.04 KB
/
class.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*jslint node: true, indent: 2 */
'use strict';
var doBody = require('./helper/body');
module.exports = function (node, indent) {
var codegen, str, that;
codegen = this.process.bind(this);
str = '';
that = this;
// Start
if (node.isAbstract) {
str += 'abstract ';
} else if (node.isFinal) {
str += 'final ';
}
str += 'class';
if (node.name) {
str += ' ' + node.name;
}
if (node.extends) {
str += ' extends ' + codegen(node.extends, indent);
}
if (node.implements) {
str += ' implements ' + node.implements.map(function (x) {
return codegen(x, indent);
}).join(',' + that.ws);
}
// begin curly brace
if (node.name) {
if (this.options.bracketsNewLine) {
str += this.nl + indent + '{' + this.nl;
} else {
str += this.ws + '{' + this.nl;
}
} else {
str += this.ws + '{' + this.nl;
}
// class body
str += doBody.call(this, codegen, indent, node.body);
// end curly brace
str += indent + '}';
if (node.name) {
str += this.nl;
}
return str;
};