UNPKG

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