1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const tag_1 = require("./tag");
|
4 | class Comment {
|
5 | constructor(shortText, text) {
|
6 | this.shortText = shortText || '';
|
7 | this.text = text || '';
|
8 | }
|
9 | hasVisibleComponent() {
|
10 | return !!this.shortText || !!this.text || !!this.tags;
|
11 | }
|
12 | hasTag(tagName) {
|
13 | if (!this.tags) {
|
14 | return false;
|
15 | }
|
16 | for (let i = 0, c = this.tags.length; i < c; i++) {
|
17 | if (this.tags[i].tagName === tagName) {
|
18 | return true;
|
19 | }
|
20 | }
|
21 | return false;
|
22 | }
|
23 | getTag(tagName, paramName) {
|
24 | return (this.tags || []).find(tag => {
|
25 | return tag.tagName === tagName && (paramName === void 0 || tag.paramName === paramName);
|
26 | });
|
27 | }
|
28 | copyFrom(comment) {
|
29 | this.shortText = comment.shortText;
|
30 | this.text = comment.text;
|
31 | this.returns = comment.returns;
|
32 | this.tags = comment.tags ? comment.tags.map((tag) => new tag_1.CommentTag(tag.tagName, tag.paramName, tag.text)) : undefined;
|
33 | }
|
34 | toObject() {
|
35 | const result = {};
|
36 | if (this.shortText) {
|
37 | result.shortText = this.shortText;
|
38 | }
|
39 | if (this.text) {
|
40 | result.text = this.text;
|
41 | }
|
42 | if (this.returns) {
|
43 | result.returns = this.returns;
|
44 | }
|
45 | if (this.tags && this.tags.length) {
|
46 | result.tags = [];
|
47 | this.tags.forEach((tag) => result.tags.push(tag.toObject()));
|
48 | }
|
49 | return result;
|
50 | }
|
51 | }
|
52 | exports.Comment = Comment;
|
53 |
|
\ | No newline at end of file |