UNPKG

7.78 kBJavaScriptView Raw
1var __extends = (this && this.__extends) || (function () {
2 var extendStatics = function (d, b) {
3 extendStatics = Object.setPrototypeOf ||
4 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6 return extendStatics(d, b);
7 };
8 return function (d, b) {
9 extendStatics(d, b);
10 function __() { this.constructor = d; }
11 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12 };
13})();
14import { DocNode, DocNodeKind } from './DocNode';
15import { DocExcerpt, ExcerptKind } from './DocExcerpt';
16/**
17 * A {@link DocDeclarationReference | declaration reference} includes a chain of
18 * member references represented using `DocMemberReference` nodes.
19 *
20 * @remarks
21 * For example, `example-library#ui.controls.Button.(render:static)` is a
22 * declaration reference that contains three member references:
23 * `ui`, `.controls`, and `.Button`, and `.(render:static)`.
24 */
25var DocMemberReference = /** @class */ (function (_super) {
26 __extends(DocMemberReference, _super);
27 /**
28 * Don't call this directly. Instead use {@link TSDocParser}
29 * @internal
30 */
31 function DocMemberReference(parameters) {
32 var _this = _super.call(this, parameters) || this;
33 if (DocNode.isParsedParameters(parameters)) {
34 _this._hasDot = !!parameters.dotExcerpt;
35 if (parameters.dotExcerpt) {
36 _this._dotExcerpt = new DocExcerpt({
37 configuration: _this.configuration,
38 excerptKind: ExcerptKind.MemberReference_Dot,
39 content: parameters.dotExcerpt
40 });
41 }
42 if (parameters.spacingAfterDotExcerpt) {
43 _this._spacingAfterDotExcerpt = new DocExcerpt({
44 configuration: _this.configuration,
45 excerptKind: ExcerptKind.Spacing,
46 content: parameters.spacingAfterDotExcerpt
47 });
48 }
49 if (parameters.leftParenthesisExcerpt) {
50 _this._leftParenthesisExcerpt = new DocExcerpt({
51 configuration: _this.configuration,
52 excerptKind: ExcerptKind.MemberReference_LeftParenthesis,
53 content: parameters.leftParenthesisExcerpt
54 });
55 }
56 if (parameters.spacingAfterLeftParenthesisExcerpt) {
57 _this._spacingAfterLeftParenthesisExcerpt = new DocExcerpt({
58 configuration: _this.configuration,
59 excerptKind: ExcerptKind.Spacing,
60 content: parameters.spacingAfterLeftParenthesisExcerpt
61 });
62 }
63 if (parameters.spacingAfterMemberExcerpt) {
64 _this._spacingAfterMemberExcerpt = new DocExcerpt({
65 configuration: _this.configuration,
66 excerptKind: ExcerptKind.Spacing,
67 content: parameters.spacingAfterMemberExcerpt
68 });
69 }
70 if (parameters.colonExcerpt) {
71 _this._colonExcerpt = new DocExcerpt({
72 excerptKind: ExcerptKind.MemberReference_Colon,
73 configuration: _this.configuration,
74 content: parameters.colonExcerpt
75 });
76 }
77 if (parameters.spacingAfterColonExcerpt) {
78 _this._spacingAfterColonExcerpt = new DocExcerpt({
79 configuration: _this.configuration,
80 excerptKind: ExcerptKind.Spacing,
81 content: parameters.spacingAfterColonExcerpt
82 });
83 }
84 if (parameters.spacingAfterSelectorExcerpt) {
85 _this._spacingAfterSelectorExcerpt = new DocExcerpt({
86 configuration: _this.configuration,
87 excerptKind: ExcerptKind.Spacing,
88 content: parameters.spacingAfterSelectorExcerpt
89 });
90 }
91 if (parameters.rightParenthesisExcerpt) {
92 _this._rightParenthesisExcerpt = new DocExcerpt({
93 configuration: _this.configuration,
94 excerptKind: ExcerptKind.MemberReference_RightParenthesis,
95 content: parameters.rightParenthesisExcerpt
96 });
97 }
98 if (parameters.spacingAfterRightParenthesisExcerpt) {
99 _this._spacingAfterRightParenthesisExcerpt = new DocExcerpt({
100 configuration: _this.configuration,
101 excerptKind: ExcerptKind.Spacing,
102 content: parameters.spacingAfterRightParenthesisExcerpt
103 });
104 }
105 }
106 else {
107 _this._hasDot = parameters.hasDot;
108 }
109 _this._memberIdentifier = parameters.memberIdentifier;
110 _this._memberSymbol = parameters.memberSymbol;
111 _this._selector = parameters.selector;
112 return _this;
113 }
114 Object.defineProperty(DocMemberReference.prototype, "kind", {
115 /** @override */
116 get: function () {
117 return DocNodeKind.MemberReference;
118 },
119 enumerable: false,
120 configurable: true
121 });
122 Object.defineProperty(DocMemberReference.prototype, "hasDot", {
123 /**
124 * True if this member reference is preceded by a dot (".") token.
125 * It should be false only for the first member in the chain.
126 */
127 get: function () {
128 return this._hasDot;
129 },
130 enumerable: false,
131 configurable: true
132 });
133 Object.defineProperty(DocMemberReference.prototype, "memberIdentifier", {
134 /**
135 * The identifier for the referenced member.
136 * @remarks
137 * Either `memberIdentifier` or `memberSymbol` may be specified, but not both.
138 */
139 get: function () {
140 return this._memberIdentifier;
141 },
142 enumerable: false,
143 configurable: true
144 });
145 Object.defineProperty(DocMemberReference.prototype, "memberSymbol", {
146 /**
147 * The ECMAScript 6 symbol expression, which may be used instead of an identifier
148 * to indicate the referenced member.
149 * @remarks
150 * Either `memberIdentifier` or `memberSymbol` may be specified, but not both.
151 */
152 get: function () {
153 return this._memberSymbol;
154 },
155 enumerable: false,
156 configurable: true
157 });
158 Object.defineProperty(DocMemberReference.prototype, "selector", {
159 /**
160 * A TSDoc selector, which may be optionally when the identifier or symbol is insufficient
161 * to unambiguously determine the referenced declaration.
162 */
163 get: function () {
164 return this._selector;
165 },
166 enumerable: false,
167 configurable: true
168 });
169 /** @override */
170 DocMemberReference.prototype.onGetChildNodes = function () {
171 return [
172 this._dotExcerpt,
173 this._spacingAfterDotExcerpt,
174 this._leftParenthesisExcerpt,
175 this._spacingAfterLeftParenthesisExcerpt,
176 this._memberIdentifier,
177 this._memberSymbol,
178 this._spacingAfterMemberExcerpt,
179 this._colonExcerpt,
180 this._spacingAfterColonExcerpt,
181 this._selector,
182 this._spacingAfterSelectorExcerpt,
183 this._rightParenthesisExcerpt,
184 this._spacingAfterRightParenthesisExcerpt
185 ];
186 };
187 return DocMemberReference;
188}(DocNode));
189export { DocMemberReference };
190//# sourceMappingURL=DocMemberReference.js.map
\No newline at end of file