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;gBAClC,MAAM;aACP;SACF;QAED,OAAO,IAAI,+BAAc,CAAC;YACxB,gBAAgB,EAAE,gBAAgB;YAClC,WAAW,EAAE,WAAW;SACzB,CAAC,CAAC;IACL,CAAC;CACF;AA7ID,0CA6IC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { DeclarationReference } from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference';\nimport {\n ApiDocumentedItem,\n type IApiDocumentedItemJson,\n type IApiDocumentedItemOptions\n} from './ApiDocumentedItem';\nimport type { ApiItem } from './ApiItem';\nimport { Excerpt, ExcerptToken, type IExcerptTokenRange, type IExcerptToken } from '../mixins/Excerpt';\nimport type { DeserializerContext } from '../model/DeserializerContext';\nimport { SourceLocation } from '../model/SourceLocation';\n\n/**\n * Constructor options for {@link ApiDeclaredItem}.\n * @public\n */\nexport interface IApiDeclaredItemOptions extends IApiDocumentedItemOptions {\n excerptTokens: IExcerptToken[];\n fileUrlPath?: string;\n}\n\nexport interface IApiDeclaredItemJson extends IApiDocumentedItemJson {\n excerptTokens: IExcerptToken[];\n fileUrlPath?: string;\n}\n\n/**\n * The base class for API items that have an associated source code excerpt containing a TypeScript declaration.\n *\n * @remarks\n *\n * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of\n * API declarations.\n *\n * Most `ApiItem` subclasses have declarations and thus extend `ApiDeclaredItem`. Counterexamples include\n * `ApiModel` and `ApiPackage`, which do not have any corresponding TypeScript source code.\n *\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport class ApiDeclaredItem extends ApiDocumentedItem {\n private _excerptTokens: ExcerptToken[];\n private _excerpt: Excerpt;\n private _fileUrlPath?: string;\n private _sourceLocation?: SourceLocation;\n\n public constructor(options: IApiDeclaredItemOptions) {\n super(options);\n\n this._excerptTokens = options.excerptTokens.map((token) => {\n const canonicalReference: DeclarationReference | undefined =\n token.canonicalReference === undefined\n ? undefined\n : DeclarationReference.parse(token.canonicalReference);\n return new ExcerptToken(token.kind, token.text, canonicalReference);\n });\n this._excerpt = new Excerpt(this.excerptTokens, { startIndex: 0, endIndex: this.excerptTokens.length });\n this._fileUrlPath = options.fileUrlPath;\n }\n\n /** @override */\n public static onDeserializeInto(\n options: Partial<IApiDeclaredItemOptions>,\n context: DeserializerContext,\n jsonObject: IApiDeclaredItemJson\n ): void {\n super.onDeserializeInto(options, context, jsonObject);\n\n options.excerptTokens = jsonObject.excerptTokens;\n options.fileUrlPath = jsonObject.fileUrlPath;\n }\n\n /**\n * The source code excerpt where the API item is declared.\n */\n public get excerpt(): Excerpt {\n return this._excerpt;\n }\n\n /**\n * The individual source code tokens that comprise the main excerpt.\n */\n public get excerptTokens(): ReadonlyArray<ExcerptToken> {\n return this._excerptTokens;\n }\n\n /**\n * The file URL path relative to the `projectFolder` and `projectFolderURL` fields\n * as defined in the `api-extractor.json` config. Is `undefined` if the path is\n * the same as the parent API item's.\n */\n public get fileUrlPath(): string | undefined {\n return this._fileUrlPath;\n }\n\n /**\n * Returns the source location where the API item is declared.\n */\n public get sourceLocation(): SourceLocation {\n if (!this._sourceLocation) {\n this._sourceLocation = this._buildSourceLocation();\n }\n return this._sourceLocation;\n }\n\n /**\n * If the API item has certain important modifier tags such as `@sealed`, `@virtual`, or `@override`,\n * this prepends them as a doc comment above the excerpt.\n */\n public getExcerptWithModifiers(): string {\n const excerpt: string = this.excerpt.text;\n const modifierTags: string[] = [];\n\n if (excerpt.length > 0) {\n if (this instanceof ApiDocumentedItem) {\n if (this.tsdocComment) {\n if (this.tsdocComment.modifierTagSet.isSealed()) {\n modifierTags.push('@sealed');\n }\n if (this.tsdocComment.modifierTagSet.isVirtual()) {\n modifierTags.push('@virtual');\n }\n if (this.tsdocComment.modifierTagSet.isOverride()) {\n modifierTags.push('@override');\n }\n }\n if (modifierTags.length > 0) {\n return '/** ' + modifierTags.join(' ') + ' */\\n' + excerpt;\n }\n }\n }\n\n return excerpt;\n }\n\n /** @override */\n public serializeInto(jsonObject: Partial<IApiDeclaredItemJson>): void {\n super.serializeInto(jsonObject);\n jsonObject.excerptTokens = this.excerptTokens.map((x) => {\n const excerptToken: IExcerptToken = { kind: x.kind, text: x.text };\n if (x.canonicalReference !== undefined) {\n excerptToken.canonicalReference = x.canonicalReference.toString();\n }\n return excerptToken;\n });\n\n // Only serialize this API item's file URL path if it exists and it's different from its parent's\n // (a little optimization to keep the doc model succinct).\n if (this.fileUrlPath) {\n if (!(this.parent instanceof ApiDeclaredItem) || this.fileUrlPath !== this.parent.fileUrlPath) {\n jsonObject.fileUrlPath = this.fileUrlPath;\n }\n }\n }\n\n /**\n * Constructs a new {@link Excerpt} corresponding to the provided token range.\n */\n public buildExcerpt(tokenRange: IExcerptTokenRange): Excerpt {\n return new Excerpt(this.excerptTokens, tokenRange);\n }\n\n /**\n * Builds the cached object used by the `sourceLocation` property.\n */\n private _buildSourceLocation(): SourceLocation {\n const projectFolderUrl: string | undefined = this.getAssociatedPackage()?.projectFolderUrl;\n\n let fileUrlPath: string | undefined;\n for (let current: ApiItem | undefined = this; current !== undefined; current = current.parent) {\n if (current instanceof ApiDeclaredItem && current.fileUrlPath) {\n fileUrlPath = current.fileUrlPath;\n break;\n }\n }\n\n return new SourceLocation({\n projectFolderUrl: projectFolderUrl,\n fileUrlPath: fileUrlPath\n });\n }\n}\n"]} |