1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const abstract_1 = require("./abstract");
|
4 | class ReferenceType extends abstract_1.Type {
|
5 | constructor(name, symbolID, reflection) {
|
6 | super();
|
7 | this.type = 'reference';
|
8 | this.name = name;
|
9 | this.symbolID = symbolID;
|
10 | this.reflection = reflection;
|
11 | }
|
12 | clone() {
|
13 | const clone = new ReferenceType(this.name, this.symbolID, this.reflection);
|
14 | clone.typeArguments = this.typeArguments;
|
15 | return clone;
|
16 | }
|
17 | equals(type) {
|
18 | return type instanceof ReferenceType &&
|
19 | (type.symbolID === this.symbolID || type.reflection === this.reflection);
|
20 | }
|
21 | toObject() {
|
22 | const result = super.toObject();
|
23 | result.name = this.name;
|
24 | if (this.reflection) {
|
25 | result.id = this.reflection.id;
|
26 | }
|
27 | if (this.typeArguments && this.typeArguments.length) {
|
28 | result.typeArguments = this.typeArguments.map((t) => t.toObject());
|
29 | }
|
30 | return result;
|
31 | }
|
32 | toString() {
|
33 | const name = this.reflection ? this.reflection.name : this.name;
|
34 | let typeArgs = '';
|
35 | if (this.typeArguments) {
|
36 | typeArgs += '<';
|
37 | typeArgs += this.typeArguments.map(arg => arg.toString()).join(', ');
|
38 | typeArgs += '>';
|
39 | }
|
40 | return name + typeArgs;
|
41 | }
|
42 | }
|
43 | ReferenceType.SYMBOL_ID_RESOLVED = -1;
|
44 | ReferenceType.SYMBOL_ID_RESOLVE_BY_NAME = -2;
|
45 | exports.ReferenceType = ReferenceType;
|
46 |
|
\ | No newline at end of file |