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BAAgB,iEAEtC,eAAe,SAAS,6CAA6C,kBAAkB,EAAE,EACzF,cAAc,CACf,CAAC;qBACH;iBACF;aACF;SACF;IACH,CAAC;IAED,+EAA+E;IAC/E,EAAE;IACF,sDAAsD;IAC9C,MAAM,CAAC,mBAAmB,CAAC,SAAoB;QACrD,IAAI,SAAS,CAAC,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE;YAC1C,OAAO,KAAK,CAAC;SACd;QAED,oCAAoC;QACpC,EAAE;QACF,yBAAyB;QACzB,kCAAkC;QAClC,mCAAmC;QACnC,oBAAoB;QACpB,6CAA6C;QAC7C,qCAAqC;QACrC,MAAM,cAAc,GAAmB,SAAS,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;QACpE,IAAI,EAAE,CAAC,qBAAqB,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE;YACxD,MAAM,gBAAgB,GAA4B,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC;YAClF,IAAI,gBAAgB,EAAE;gBACpB,KAAK,MAAM,KAAK,IAAI,gBAAgB,CAAC,WAAW,EAAE,EAAE;oBAClD,IAAI,KAAK,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,aAAa,EAAE;wBAC9C,OAAO,IAAI,CAAC;qBACb;iBACF;aACF;SACF;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA3RD,gDA2RC","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 * as path from 'path';\nimport * as ts from 'typescript';\n\nimport type { Collector } from '../collector/Collector';\nimport { AstSymbol } from '../analyzer/AstSymbol';\nimport type { AstDeclaration } from '../analyzer/AstDeclaration';\nimport type { ApiItemMetadata } from '../collector/ApiItemMetadata';\nimport type { SymbolMetadata } from '../collector/SymbolMetadata';\nimport type { CollectorEntity } from '../collector/CollectorEntity';\nimport { ExtractorMessageId } from '../api/ExtractorMessageId';\nimport { ReleaseTag } from '@microsoft/api-extractor-model';\nimport { AstNamespaceImport } from '../analyzer/AstNamespaceImport';\nimport type { AstModuleExportInfo } from '../analyzer/AstModule';\nimport type { AstEntity } from '../analyzer/AstEntity';\n\nexport class ValidationEnhancer {\n public static analyze(collector: Collector): void {\n const alreadyWarnedEntities: Set<AstEntity> = new Set<AstEntity>();\n\n for (const entity of collector.entities) {\n if (\n !(\n entity.consumable ||\n collector.extractorConfig.apiReportIncludeForgottenExports ||\n collector.extractorConfig.docModelIncludeForgottenExports\n )\n ) {\n continue;\n }\n\n if (entity.astEntity instanceof AstSymbol) {\n // A regular exported AstSymbol\n\n const astSymbol: AstSymbol = entity.astEntity;\n\n astSymbol.forEachDeclarationRecursive((astDeclaration: AstDeclaration) => {\n ValidationEnhancer._checkReferences(collector, astDeclaration, alreadyWarnedEntities);\n });\n\n const symbolMetadata: SymbolMetadata = collector.fetchSymbolMetadata(astSymbol);\n ValidationEnhancer._checkForInternalUnderscore(collector, entity, astSymbol, symbolMetadata);\n ValidationEnhancer._checkForInconsistentReleaseTags(collector, astSymbol, symbolMetadata);\n } else if (entity.astEntity instanceof AstNamespaceImport) {\n // A namespace created using \"import * as ___ from ___\"\n const astNamespaceImport: AstNamespaceImport = entity.astEntity;\n\n const astModuleExportInfo: AstModuleExportInfo =\n astNamespaceImport.fetchAstModuleExportInfo(collector);\n\n for (const namespaceMemberAstEntity of astModuleExportInfo.exportedLocalEntities.values()) {\n if (namespaceMemberAstEntity instanceof AstSymbol) {\n const astSymbol: AstSymbol = namespaceMemberAstEntity;\n\n astSymbol.forEachDeclarationRecursive((astDeclaration: AstDeclaration) => {\n ValidationEnhancer._checkReferences(collector, astDeclaration, alreadyWarnedEntities);\n });\n\n const symbolMetadata: SymbolMetadata = collector.fetchSymbolMetadata(astSymbol);\n\n // (Don't apply ValidationEnhancer._checkForInternalUnderscore() for AstNamespaceImport members)\n\n ValidationEnhancer._checkForInconsistentReleaseTags(collector, astSymbol, symbolMetadata);\n }\n }\n }\n }\n }\n\n private static _checkForInternalUnderscore(\n collector: Collector,\n collectorEntity: CollectorEntity,\n astSymbol: AstSymbol,\n symbolMetadata: SymbolMetadata\n ): void {\n let needsUnderscore: boolean = false;\n\n if (symbolMetadata.maxEffectiveReleaseTag === ReleaseTag.Internal) {\n if (!astSymbol.parentAstSymbol) {\n // If it's marked as @internal and has no parent, then it needs an underscore.\n // We use maxEffectiveReleaseTag because a merged declaration would NOT need an underscore in a case like this:\n //\n // /** @public */\n // export enum X { }\n //\n // /** @internal */\n // export namespace X { }\n //\n // (The above normally reports an error \"ae-different-release-tags\", but that may be suppressed.)\n needsUnderscore = true;\n } else {\n // If it's marked as @internal and the parent isn't obviously already @internal, then it needs an underscore.\n //\n // For example, we WOULD need an underscore for a merged declaration like this:\n //\n // /** @internal */\n // export namespace X {\n // export interface _Y { }\n // }\n //\n // /** @public */\n // export class X {\n // /** @internal */\n // public static _Y(): void { } // <==== different from parent\n // }\n const parentSymbolMetadata: SymbolMetadata = collector.fetchSymbolMetadata(astSymbol);\n if (parentSymbolMetadata.maxEffectiveReleaseTag > ReleaseTag.Internal) {\n needsUnderscore = true;\n }\n }\n }\n\n if (needsUnderscore) {\n for (const exportName of collectorEntity.exportNames) {\n if (exportName[0] !== '_') {\n collector.messageRouter.addAnalyzerIssue(\n ExtractorMessageId.InternalMissingUnderscore,\n `The name \"${exportName}\" should be prefixed with an underscore` +\n ` because the declaration is marked as @internal`,\n astSymbol,\n { exportName }\n );\n }\n }\n }\n }\n\n private static _checkForInconsistentReleaseTags(\n collector: Collector,\n astSymbol: AstSymbol,\n symbolMetadata: SymbolMetadata\n ): void {\n if (astSymbol.isExternal) {\n // For now, don't report errors for external code. If the developer cares about it, they should run\n // API Extractor separately on the external project\n return;\n }\n\n // Normally we will expect all release tags to be the same. Arbitrarily we choose the maxEffectiveReleaseTag\n // as the thing they should all match.\n const expectedEffectiveReleaseTag: ReleaseTag = symbolMetadata.maxEffectiveReleaseTag;\n\n // This is set to true if we find a declaration whose release tag is different from expectedEffectiveReleaseTag\n let mixedReleaseTags: boolean = false;\n\n // This is set to false if we find a declaration that is not a function/method overload\n let onlyFunctionOverloads: boolean = true;\n\n // This is set to true if we find a declaration that is @internal\n let anyInternalReleaseTags: boolean = false;\n\n for (const astDeclaration of astSymbol.astDeclarations) {\n const apiItemMetadata: ApiItemMetadata = collector.fetchApiItemMetadata(astDeclaration);\n const effectiveReleaseTag: ReleaseTag = apiItemMetadata.effectiveReleaseTag;\n\n switch (astDeclaration.declaration.kind) {\n case ts.SyntaxKind.FunctionDeclaration:\n case ts.SyntaxKind.MethodDeclaration:\n break;\n default:\n onlyFunctionOverloads = false;\n }\n\n if (effectiveReleaseTag !== expectedEffectiveReleaseTag) {\n mixedReleaseTags = true;\n }\n\n if (effectiveReleaseTag === ReleaseTag.Internal) {\n anyInternalReleaseTags = true;\n }\n }\n\n if (mixedReleaseTags) {\n if (!onlyFunctionOverloads) {\n collector.messageRouter.addAnalyzerIssue(\n ExtractorMessageId.DifferentReleaseTags,\n 'This symbol has another declaration with a different release tag',\n astSymbol\n );\n }\n\n if (anyInternalReleaseTags) {\n collector.messageRouter.addAnalyzerIssue(\n ExtractorMessageId.InternalMixedReleaseTag,\n `Mixed release tags are not allowed for \"${astSymbol.localName}\" because one of its declarations` +\n ` is marked as @internal`,\n astSymbol\n );\n }\n }\n }\n\n private static _checkReferences(\n collector: Collector,\n astDeclaration: AstDeclaration,\n alreadyWarnedEntities: Set<AstEntity>\n ): void {\n const apiItemMetadata: ApiItemMetadata = collector.fetchApiItemMetadata(astDeclaration);\n const declarationReleaseTag: ReleaseTag = apiItemMetadata.effectiveReleaseTag;\n\n for (const referencedEntity of astDeclaration.referencedAstEntities) {\n let collectorEntity: CollectorEntity | undefined;\n let referencedReleaseTag: ReleaseTag;\n let localName: string;\n\n if (referencedEntity instanceof AstSymbol) {\n // If this is e.g. a member of a namespace, then we need to be checking the top-level scope to see\n // whether it's exported.\n //\n // TODO: Technically we should also check each of the nested scopes along the way.\n const rootSymbol: AstSymbol = referencedEntity.rootAstSymbol;\n\n if (rootSymbol.isExternal) {\n continue;\n }\n\n collectorEntity = collector.tryGetCollectorEntity(rootSymbol);\n localName = collectorEntity?.nameForEmit || rootSymbol.localName;\n\n const referencedMetadata: SymbolMetadata = collector.fetchSymbolMetadata(referencedEntity);\n referencedReleaseTag = referencedMetadata.maxEffectiveReleaseTag;\n } else if (referencedEntity instanceof AstNamespaceImport) {\n collectorEntity = collector.tryGetCollectorEntity(referencedEntity);\n\n // TODO: Currently the \"import * as ___ from ___\" syntax does not yet support doc comments\n referencedReleaseTag = ReleaseTag.Public;\n\n localName = collectorEntity?.nameForEmit || referencedEntity.localName;\n } else {\n continue;\n }\n\n if (collectorEntity && collectorEntity.consumable) {\n if (ReleaseTag.compare(declarationReleaseTag, referencedReleaseTag) > 0) {\n collector.messageRouter.addAnalyzerIssue(\n ExtractorMessageId.IncompatibleReleaseTags,\n `The symbol \"${astDeclaration.astSymbol.localName}\"` +\n ` is marked as ${ReleaseTag.getTagName(declarationReleaseTag)},` +\n ` but its signature references \"${localName}\"` +\n ` which is marked as ${ReleaseTag.getTagName(referencedReleaseTag)}`,\n astDeclaration\n );\n }\n } else {\n const entryPointFilename: string = path.basename(\n collector.workingPackage.entryPointSourceFile.fileName\n );\n\n if (!alreadyWarnedEntities.has(referencedEntity)) {\n alreadyWarnedEntities.add(referencedEntity);\n\n if (\n referencedEntity instanceof AstSymbol &&\n ValidationEnhancer._isEcmaScriptSymbol(referencedEntity)\n ) {\n // The main usage scenario for ECMAScript symbols is to attach private data to a JavaScript object,\n // so as a special case, we do NOT report them as forgotten exports.\n } else {\n collector.messageRouter.addAnalyzerIssue(\n ExtractorMessageId.ForgottenExport,\n `The symbol \"${localName}\" needs to be exported by the entry point ${entryPointFilename}`,\n astDeclaration\n );\n }\n }\n }\n }\n }\n\n // Detect an AstSymbol that refers to an ECMAScript symbol declaration such as:\n //\n // const mySymbol: unique symbol = Symbol('mySymbol');\n private static _isEcmaScriptSymbol(astSymbol: AstSymbol): boolean {\n if (astSymbol.astDeclarations.length !== 1) {\n return false;\n }\n\n // We are matching a form like this:\n //\n // - VariableDeclaration:\n // - Identifier: pre=[mySymbol]\n // - ColonToken: pre=[:] sep=[ ]\n // - TypeOperator:\n // - UniqueKeyword: pre=[unique] sep=[ ]\n // - SymbolKeyword: pre=[symbol]\n const astDeclaration: AstDeclaration = astSymbol.astDeclarations[0];\n if (ts.isVariableDeclaration(astDeclaration.declaration)) {\n const variableTypeNode: ts.TypeNode | undefined = astDeclaration.declaration.type;\n if (variableTypeNode) {\n for (const token of variableTypeNode.getChildren()) {\n if (token.kind === ts.SyntaxKind.SymbolKeyword) {\n return true;\n }\n }\n }\n }\n\n return false;\n }\n}\n"]} |