-
Notifications
You must be signed in to change notification settings - Fork 1
/
ClassDescriptor.ts
38 lines (32 loc) · 1.09 KB
/
ClassDescriptor.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
// tslint:disable-next-line: max-line-length
import { ClassLikeDeclarationBase, ConstructorDeclaration, HeritageClause, MethodSignature, Modifier, Node, PropertySignature, TypeElement, TypeParameterDeclaration } from 'typescript';
export class ClassDescriptor {
methods: MethodSignature[];
properties: PropertySignature[];
modifiers: Modifier[];
readonly className: string;
typeParameters: TypeParameterDeclaration[];
heritageClauses: HeritageClause[];
classDeclarationString: string;
jsDoc: Node[];
classDeclaration: ClassLikeDeclarationBase;
ctors: ConstructorDeclaration[];
get interfaceName(): string {
return `I${this.className}`;
}
constructor(className: string) {
this.className = className;
}
getMembersAsNode(): Node[] {
return (<Node[]>this.properties).concat(this.methods);
}
getPropertiesAsNode(): Node[] {
return (<Node[]>this.properties);
}
getMethodsAsNode(): Node[] {
return (<Node[]>this.methods);
}
getMembersAsTypeElement(): ReadonlyArray<TypeElement> {
return (<TypeElement[]>this.properties).concat(this.methods);
}
}