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IAAI,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,gBAAU,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,SAAS,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC3H,CAAC;IAMD,QAAQ;QACJ,MAAM,MAAM,GAAQ,EAAE,CAAC;QACvB,IAAI,IAAI,CAAC,SAAS,EAAE;YAChB,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;SACrC;QACD,IAAI,IAAI,CAAC,IAAI,EAAE;YACX,MAAM,CAAC,IAAI,GAAQ,IAAI,CAAC,IAAI,CAAC;SAChC;QACD,IAAI,IAAI,CAAC,OAAO,EAAE;YACd,MAAM,CAAC,OAAO,GAAK,IAAI,CAAC,OAAO,CAAC;SACnC;QAED,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAC/B,MAAM,CAAC,IAAI,GAAG,EAAE,CAAC;YACjB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;SAChE;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AA3GD,0BA2GC","sourcesContent":["import { CommentTag } from './tag';\n\n/**\n * A model that represents a javadoc comment.\n *\n * Instances of this model are created by the [[CommentHandler]]. You can retrieve comments\n * through the [[BaseReflection.comment]] property.\n */\nexport class Comment {\n /**\n * The abstract of the comment. TypeDoc interprets the first paragraph of a comment\n * as the abstract.\n */\n shortText: string;\n\n /**\n * The full body text of the comment. Excludes the [[shortText]].\n */\n text: string;\n\n /**\n * The text of the ```@returns``` tag if present.\n */\n returns?: string;\n\n /**\n * All associated javadoc tags.\n */\n tags?: CommentTag[];\n\n /**\n * Creates a new Comment instance.\n */\n constructor(shortText?: string, text?: string) {\n this.shortText = shortText || '';\n this.text = text || '';\n }\n\n /**\n * Has this comment a visible component?\n *\n * @returns TRUE when this comment has a visible component.\n */\n hasVisibleComponent(): boolean {\n return !!this.shortText || !!this.text || !!this.tags;\n }\n\n /**\n * Test whether this comment contains a tag with the given name.\n *\n * @param tagName The name of the tag to look for.\n * @returns TRUE when this comment contains a tag with the given name, otherwise FALSE.\n */\n hasTag(tagName: string): boolean {\n if (!this.tags) {\n return false;\n }\n for (let i = 0, c = this.tags.length; i < c; i++) {\n if (this.tags[i].tagName === tagName) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Return the first tag with the given name.\n *\n * You can optionally pass a parameter name that should be searched to.\n *\n * @param tagName The name of the tag to look for.\n * @param paramName An optional parameter name to look for.\n * @returns The found tag or undefined.\n */\n getTag(tagName: string, paramName?: string): CommentTag | undefined {\n return (this.tags || []).find(tag => {\n return tag.tagName === tagName && (paramName === void 0 || tag.paramName === paramName);\n });\n }\n\n /**\n * Copy the data of the given comment into this comment.\n *\n * @param comment\n */\n copyFrom(comment: Comment) {\n this.shortText = comment.shortText;\n this.text = comment.text;\n this.returns = comment.returns;\n this.tags = comment.tags ? comment.tags.map((tag) => new CommentTag(tag.tagName, tag.paramName, tag.text)) : undefined;\n }\n\n /**\n * Return a raw object representation of this comment.\n * @deprecated Use serializers instead\n */\n toObject(): any {\n const result: any = {};\n if (this.shortText) {\n result.shortText = this.shortText;\n }\n if (this.text) {\n result.text = this.text;\n }\n if (this.returns) {\n result.returns = this.returns;\n }\n\n if (this.tags && this.tags.length) {\n result.tags = [];\n this.tags.forEach((tag) => result.tags.push(tag.toObject()));\n }\n\n return result;\n }\n}\n"]}
\No newline at end of file