UNPKG

4.01 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 { DocNodeKind, DocNode } from './DocNode';
15import { DocExcerpt, ExcerptKind } from './DocExcerpt';
16/**
17 * Represents a span of text that contained invalid markup.
18 * The characters should be rendered as plain text.
19 */
20var DocErrorText = /** @class */ (function (_super) {
21 __extends(DocErrorText, _super);
22 /**
23 * Don't call this directly. Instead use {@link TSDocParser}
24 * @internal
25 */
26 function DocErrorText(parameters) {
27 var _this = _super.call(this, parameters) || this;
28 _this._textExcerpt = new DocExcerpt({
29 configuration: _this.configuration,
30 excerptKind: ExcerptKind.ErrorText,
31 content: parameters.textExcerpt
32 });
33 _this._messageId = parameters.messageId;
34 _this._errorMessage = parameters.errorMessage;
35 _this._errorLocation = parameters.errorLocation;
36 return _this;
37 }
38 Object.defineProperty(DocErrorText.prototype, "kind", {
39 /** @override */
40 get: function () {
41 return DocNodeKind.ErrorText;
42 },
43 enumerable: false,
44 configurable: true
45 });
46 Object.defineProperty(DocErrorText.prototype, "text", {
47 /**
48 * The characters that should be rendered as plain text because they
49 * could not be parsed successfully.
50 */
51 get: function () {
52 if (this._text === undefined) {
53 this._text = this._textExcerpt.content.toString();
54 }
55 return this._text;
56 },
57 enumerable: false,
58 configurable: true
59 });
60 Object.defineProperty(DocErrorText.prototype, "textExcerpt", {
61 get: function () {
62 if (this._textExcerpt) {
63 return this._textExcerpt.content;
64 }
65 else {
66 return undefined;
67 }
68 },
69 enumerable: false,
70 configurable: true
71 });
72 Object.defineProperty(DocErrorText.prototype, "messageId", {
73 /**
74 * The TSDoc error message identifier.
75 */
76 get: function () {
77 return this._messageId;
78 },
79 enumerable: false,
80 configurable: true
81 });
82 Object.defineProperty(DocErrorText.prototype, "errorMessage", {
83 /**
84 * A description of why the character could not be parsed.
85 */
86 get: function () {
87 return this._errorMessage;
88 },
89 enumerable: false,
90 configurable: true
91 });
92 Object.defineProperty(DocErrorText.prototype, "errorLocation", {
93 /**
94 * The range of characters that caused the error. In general these may be
95 * somewhat farther ahead in the input stream from the DocErrorText node itself.
96 *
97 * @remarks
98 * For example, for the malformed HTML tag `<a href="123" @ /a>`, the DocErrorText node
99 * will correspond to the `<` character that looked like an HTML tag, whereas the
100 * error location might be the `@` character that caused the trouble.
101 */
102 get: function () {
103 return this._errorLocation;
104 },
105 enumerable: false,
106 configurable: true
107 });
108 /** @override */
109 DocErrorText.prototype.onGetChildNodes = function () {
110 return [this._textExcerpt];
111 };
112 return DocErrorText;
113}(DocNode));
114export { DocErrorText };
115//# sourceMappingURL=DocErrorText.js.map
\No newline at end of file