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MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAE3B,OAAO,IAAI,CAAC;IACd,CAAC;IACH,qBAAC;AAAD,CAAC,AA5DD,IA4DC","sourcesContent":["import { DocBlockTag } from '../nodes/DocBlockTag';\r\nimport { TSDocTagDefinition, TSDocTagSyntaxKind } from '../configuration/TSDocTagDefinition';\r\n\r\n/**\r\n * Represents a set of modifier tags that were extracted from a doc comment.\r\n *\r\n * @remarks\r\n * TSDoc modifier tags are block tags that do not have any associated rich text content.\r\n * Instead, their presence or absence acts as an on/off switch, indicating some aspect\r\n * of the underlying API item. For example, the `@internal` modifier indicates that a\r\n * signature is internal (i.e. not part of the public API contract).\r\n */\r\nexport class ModifierTagSet {\r\n private readonly _nodes: DocBlockTag[] = [];\r\n\r\n // NOTE: To implement case insensitivity, the keys in this set are always upper-case.\r\n // This convention makes the normalization more obvious (and as a general practice handles\r\n // the Turkish \"i\" character correctly).\r\n private readonly _nodesByName: Map<string, DocBlockTag> = new Map<string, DocBlockTag>();\r\n\r\n /**\r\n * The original block tag nodes that defined the modifiers in this set, excluding duplicates.\r\n */\r\n public get nodes(): ReadonlyArray<DocBlockTag> {\r\n return this._nodes;\r\n }\r\n\r\n /**\r\n * Returns true if the set contains a DocBlockTag with the specified tag name.\r\n * Note that synonyms are not considered. The comparison is case-insensitive.\r\n * @param modifierTagName - The name of the tag, including the `@` prefix For example, `@internal`\r\n */\r\n public hasTagName(modifierTagName: string): boolean {\r\n return this._nodesByName.has(modifierTagName.toUpperCase());\r\n }\r\n\r\n /**\r\n * Returns true if the set contains a DocBlockTag matching the specified tag definition.\r\n * Note that synonyms are not considered. The comparison is case-insensitive.\r\n * The TSDocTagDefinition must be a modifier tag.\r\n * @param tagName - The name of the tag, including the `@` prefix For example, `@internal`\r\n */\r\n public hasTag(modifierTagDefinition: TSDocTagDefinition): boolean {\r\n return !!this.tryGetTag(modifierTagDefinition);\r\n }\r\n\r\n /**\r\n * Returns a DocBlockTag matching the specified tag definition, or undefined if no such\r\n * tag was added to the set. If there were multiple instances, returned object will be\r\n * the first one to be added.\r\n */\r\n public tryGetTag(modifierTagDefinition: TSDocTagDefinition): DocBlockTag | undefined {\r\n if (modifierTagDefinition.syntaxKind !== TSDocTagSyntaxKind.ModifierTag) {\r\n throw new Error('The tag definition is not a modifier tag');\r\n }\r\n return this._nodesByName.get(modifierTagDefinition.tagNameWithUpperCase);\r\n }\r\n\r\n /**\r\n * Adds a new modifier tag to the set. If a tag already exists with the same name,\r\n * then no change is made, and the return value is false.\r\n */\r\n public addTag(blockTag: DocBlockTag): boolean {\r\n if (this._nodesByName.has(blockTag.tagNameWithUpperCase)) {\r\n return false;\r\n }\r\n\r\n this._nodesByName.set(blockTag.tagNameWithUpperCase, blockTag);\r\n this._nodes.push(blockTag);\r\n\r\n return true;\r\n }\r\n}\r\n"]}
\No newline at end of file