1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const abstract_1 = require("./abstract");
|
4 | const index_1 = require("../types/index");
|
5 | const container_1 = require("./container");
|
6 | const lodash_1 = require("lodash");
|
7 | class DeclarationReflection extends container_1.ContainerReflection {
|
8 | hasGetterOrSetter() {
|
9 | return !!this.getSignature || !!this.setSignature;
|
10 | }
|
11 | getAllSignatures() {
|
12 | let result = [];
|
13 | if (this.signatures) {
|
14 | result = result.concat(this.signatures);
|
15 | }
|
16 | if (this.indexSignature) {
|
17 | result.push(this.indexSignature);
|
18 | }
|
19 | if (this.getSignature) {
|
20 | result.push(this.getSignature);
|
21 | }
|
22 | if (this.setSignature) {
|
23 | result.push(this.setSignature);
|
24 | }
|
25 | return result;
|
26 | }
|
27 | traverse(callback) {
|
28 | for (const parameter of lodash_1.toArray(this.typeParameters)) {
|
29 | if (callback(parameter, abstract_1.TraverseProperty.TypeParameter) === false) {
|
30 | return;
|
31 | }
|
32 | }
|
33 | if (this.type instanceof index_1.ReflectionType) {
|
34 | if (callback(this.type.declaration, abstract_1.TraverseProperty.TypeLiteral) === false) {
|
35 | return;
|
36 | }
|
37 | }
|
38 | for (const signature of lodash_1.toArray(this.signatures)) {
|
39 | if (callback(signature, abstract_1.TraverseProperty.Signatures) === false) {
|
40 | return;
|
41 | }
|
42 | }
|
43 | if (this.indexSignature) {
|
44 | if (callback(this.indexSignature, abstract_1.TraverseProperty.IndexSignature) === false) {
|
45 | return;
|
46 | }
|
47 | }
|
48 | if (this.getSignature) {
|
49 | if (callback(this.getSignature, abstract_1.TraverseProperty.GetSignature) === false) {
|
50 | return;
|
51 | }
|
52 | }
|
53 | if (this.setSignature) {
|
54 | if (callback(this.setSignature, abstract_1.TraverseProperty.SetSignature) === false) {
|
55 | return;
|
56 | }
|
57 | }
|
58 | super.traverse(callback);
|
59 | }
|
60 | toObject() {
|
61 | let result = super.toObject();
|
62 | if (this.type) {
|
63 | result.type = this.type.toObject();
|
64 | }
|
65 | if (this.defaultValue) {
|
66 | result.defaultValue = this.defaultValue;
|
67 | }
|
68 | if (this.overwrites) {
|
69 | result.overwrites = this.overwrites.toObject();
|
70 | }
|
71 | if (this.inheritedFrom) {
|
72 | result.inheritedFrom = this.inheritedFrom.toObject();
|
73 | }
|
74 | if (this.extendedTypes) {
|
75 | result.extendedTypes = this.extendedTypes.map((t) => t.toObject());
|
76 | }
|
77 | if (this.extendedBy) {
|
78 | result.extendedBy = this.extendedBy.map((t) => t.toObject());
|
79 | }
|
80 | if (this.implementedTypes) {
|
81 | result.implementedTypes = this.implementedTypes.map((t) => t.toObject());
|
82 | }
|
83 | if (this.implementedBy) {
|
84 | result.implementedBy = this.implementedBy.map((t) => t.toObject());
|
85 | }
|
86 | if (this.implementationOf) {
|
87 | result.implementationOf = this.implementationOf.toObject();
|
88 | }
|
89 | return result;
|
90 | }
|
91 | toString() {
|
92 | let result = super.toString();
|
93 | if (this.typeParameters) {
|
94 | const parameters = [];
|
95 | this.typeParameters.forEach((parameter) => {
|
96 | parameters.push(parameter.name);
|
97 | });
|
98 | result += '<' + parameters.join(', ') + '>';
|
99 | }
|
100 | if (this.type) {
|
101 | result += ':' + this.type.toString();
|
102 | }
|
103 | return result;
|
104 | }
|
105 | }
|
106 | exports.DeclarationReflection = DeclarationReflection;
|
107 |
|
\ | No newline at end of file |