-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathClassSpec.ts
72 lines (53 loc) · 1.67 KB
/
ClassSpec.ts
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// This file is part of readts, copyright (c) 2016 BusFaster Ltd.
// Released under the MIT license, see LICENSE.
import * as ts from 'typescript';
import * as readts from './index';
import { SymbolSpec } from './Parser';
/** Class or interface and its members. */
export class ClassSpec {
/** @ignore internal use. */
constructor(spec: SymbolSpec) {
this.name = spec.name;
this.pos = spec.pos;
this.symbol = spec.symbol;
this.exports = new readts.ModuleSpec();
if(spec.doc) this.doc = spec.doc;
}
/** Add constructor signature. @ignore internal use. */
addConstructor(spec: readts.SignatureSpec) {
if(!this.construct) this.construct = new readts.FunctionSpec(null);
this.construct.addSignature(spec);
}
/** Add method. @ignore internal use. */
addMethod(spec: readts.FunctionSpec) {
if(!this.methodList) this.methodList = [];
this.methodList.push(spec);
}
/** Add property. @ignore internal use. */
addProperty(spec: readts.IdentifierSpec) {
if(!this.propertyList) this.propertyList = [];
this.propertyList.push(spec);
}
/** Add extend. @ignore internal use. */
addExtend(spec: readts.ClassSpec) {
if(!this.extendList) this.extendList = [];
this.extendList.push(spec);
}
/** Class name. */
name: string;
pos: readts.SourcePos;
/** Symbol from TypeScript services. @ignore internal use. */
symbol: ts.Symbol;
/** Constructor function. */
construct: readts.FunctionSpec;
/** Public methods. */
methodList: readts.FunctionSpec[];
/** Public properties. */
propertyList: readts.IdentifierSpec[];
/** Class extends */
extendList: readts.ClassSpec[];
/** Class exports */
exports: readts.ModuleSpec;
/** JSDoc comment. */
doc: string;
}