@microsoft/api-extractor 7.51.1 → 7.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +12 -0
- package/CHANGELOG.md +8 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/aedoc/PackageDocComment.js +17 -7
- package/lib/aedoc/PackageDocComment.js.map +1 -1
- package/lib/analyzer/AstDeclaration.js +17 -7
- package/lib/analyzer/AstDeclaration.js.map +1 -1
- package/lib/analyzer/AstReferenceResolver.js +17 -7
- package/lib/analyzer/AstReferenceResolver.js.map +1 -1
- package/lib/analyzer/AstSymbolTable.js +17 -7
- package/lib/analyzer/AstSymbolTable.js.map +1 -1
- package/lib/analyzer/ExportAnalyzer.js +17 -7
- package/lib/analyzer/ExportAnalyzer.js.map +1 -1
- package/lib/analyzer/SourceFileLocationFormatter.js +17 -7
- package/lib/analyzer/SourceFileLocationFormatter.js.map +1 -1
- package/lib/analyzer/Span.js +17 -7
- package/lib/analyzer/Span.js.map +1 -1
- package/lib/analyzer/SyntaxHelpers.js +17 -7
- package/lib/analyzer/SyntaxHelpers.js.map +1 -1
- package/lib/analyzer/TypeScriptHelpers.js +17 -7
- package/lib/analyzer/TypeScriptHelpers.js.map +1 -1
- package/lib/analyzer/TypeScriptInternals.js +18 -8
- package/lib/analyzer/TypeScriptInternals.js.map +1 -1
- package/lib/api/CompilerState.js +17 -7
- package/lib/api/CompilerState.js.map +1 -1
- package/lib/api/Extractor.js +17 -7
- package/lib/api/Extractor.js.map +1 -1
- package/lib/api/ExtractorConfig.js +17 -7
- package/lib/api/ExtractorConfig.js.map +1 -1
- package/lib/cli/ApiExtractorCommandLine.js +17 -7
- package/lib/cli/ApiExtractorCommandLine.js.map +1 -1
- package/lib/cli/InitAction.js +17 -7
- package/lib/cli/InitAction.js.map +1 -1
- package/lib/cli/RunAction.js +17 -7
- package/lib/cli/RunAction.js.map +1 -1
- package/lib/collector/Collector.js +17 -7
- package/lib/collector/Collector.js.map +1 -1
- package/lib/collector/CollectorEntity.js +17 -7
- package/lib/collector/CollectorEntity.js.map +1 -1
- package/lib/collector/MessageRouter.js +17 -7
- package/lib/collector/MessageRouter.js.map +1 -1
- package/lib/collector/SourceMapper.js +17 -7
- package/lib/collector/SourceMapper.js.map +1 -1
- package/lib/enhancers/DocCommentEnhancer.js +17 -7
- package/lib/enhancers/DocCommentEnhancer.js.map +1 -1
- package/lib/enhancers/ValidationEnhancer.js +17 -7
- package/lib/enhancers/ValidationEnhancer.js.map +1 -1
- package/lib/generators/ApiModelGenerator.js +17 -7
- package/lib/generators/ApiModelGenerator.js.map +1 -1
- package/lib/generators/ApiReportGenerator.js +17 -7
- package/lib/generators/ApiReportGenerator.js.map +1 -1
- package/lib/generators/DeclarationReferenceGenerator.js +17 -7
- package/lib/generators/DeclarationReferenceGenerator.js.map +1 -1
- package/lib/generators/DtsEmitHelpers.js +17 -7
- package/lib/generators/DtsEmitHelpers.js.map +1 -1
- package/lib/generators/DtsRollupGenerator.js +17 -7
- package/lib/generators/DtsRollupGenerator.js.map +1 -1
- package/lib/generators/ExcerptBuilder.js +17 -7
- package/lib/generators/ExcerptBuilder.js.map +1 -1
- package/lib/start.js +17 -7
- package/lib/start.js.map +1 -1
- package/package.json +5 -5
|
@@ -17,13 +17,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
17
17
|
}) : function(o, v) {
|
|
18
18
|
o["default"] = v;
|
|
19
19
|
});
|
|
20
|
-
var __importStar = (this && this.__importStar) || function (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
20
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
21
|
+
var ownKeys = function(o) {
|
|
22
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
23
|
+
var ar = [];
|
|
24
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
25
|
+
return ar;
|
|
26
|
+
};
|
|
27
|
+
return ownKeys(o);
|
|
28
|
+
};
|
|
29
|
+
return function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
})();
|
|
27
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
38
|
exports.ExportAnalyzer = void 0;
|
|
29
39
|
const ts = __importStar(require("typescript"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExportAnalyzer.js","sourceRoot":"","sources":["../../src/analyzer/ExportAnalyzer.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,+CAAiC;AACjC,oEAA6D;AAE7D,2DAAwD;AACxD,2CAAwC;AACxC,2CAA+E;AAC/E,2CAAmE;AACnE,+DAA4D;AAC5D,+EAA4E;AAG5E,6DAA0D;AAC1D,mDAAgD;AAChD,6DAA0D;AAgC1D;;;;;;;;;GASG;AACH,MAAa,cAAc;IAczB,YACE,OAAmB,EACnB,WAA2B,EAC3B,mBAAwC,EACxC,cAA+B;QAZhB,8BAAyB,GAA8B,IAAI,GAAG,EAAwB,CAAC;QAExG,4CAA4C;QAC3B,kCAA6B,GAAuB,IAAI,GAAG,EAAiB,CAAC;QAE7E,qBAAgB,GAA2B,IAAI,GAAG,EAAqB,CAAC;QACxE,gCAA2B,GAAuC,IAAI,GAAG,EAAE,CAAC;QAQ3F,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,oBAAoB,GAAG,mBAAmB,CAAC;QAChD,IAAI,CAAC,eAAe,GAAG,cA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in the project root for license information.\n\nimport * as ts from 'typescript';\nimport { InternalError } from '@rushstack/node-core-library';\n\nimport { TypeScriptHelpers } from './TypeScriptHelpers';\nimport { AstSymbol } from './AstSymbol';\nimport { AstImport, type IAstImportOptions, AstImportKind } from './AstImport';\nimport { AstModule, type IAstModuleExportInfo } from './AstModule';\nimport { TypeScriptInternals } from './TypeScriptInternals';\nimport { SourceFileLocationFormatter } from './SourceFileLocationFormatter';\nimport type { IFetchAstSymbolOptions } from './AstSymbolTable';\nimport type { AstEntity } from './AstEntity';\nimport { AstNamespaceImport } from './AstNamespaceImport';\nimport { SyntaxHelpers } from './SyntaxHelpers';\nimport { AstNamespaceExport } from './AstNamespaceExport';\n\n/**\n * Exposes the minimal APIs from AstSymbolTable that are needed by ExportAnalyzer.\n *\n * In particular, we want ExportAnalyzer to be able to call AstSymbolTable._fetchAstSymbol() even though it\n * is a very private API that should not be exposed to any other components.\n */\nexport interface IAstSymbolTable {\n fetchAstSymbol(options: IFetchAstSymbolOptions): AstSymbol | undefined;\n\n analyze(astEntity: AstEntity): void;\n}\n\n/**\n * Used with ExportAnalyzer.fetchAstModuleBySourceFile() to provide contextual information about how the source file\n * was imported.\n */\ninterface IAstModuleReference {\n /**\n * For example, if we are following a statement like `import { X } from 'some-package'`, this will be the\n * string `\"some-package\"`.\n */\n moduleSpecifier: string;\n\n /**\n * For example, if we are following a statement like `import { X } from 'some-package'`, this will be the\n * symbol for `X`.\n */\n moduleSpecifierSymbol: ts.Symbol;\n}\n\n/**\n * The ExportAnalyzer is an internal part of AstSymbolTable that has been moved out into its own source file\n * because it is a complex and mostly self-contained algorithm.\n *\n * Its job is to build up AstModule objects by crawling import statements to discover where declarations come from.\n * This is conceptually the same as the compiler's own TypeChecker.getExportsOfModule(), except that when\n * ExportAnalyzer encounters a declaration that was imported from an external package, it remembers how it was imported\n * (i.e. the AstImport object). Today the compiler API does not expose this information, which is crucial for\n * generating .d.ts rollups.\n */\nexport class ExportAnalyzer {\n private readonly _program: ts.Program;\n private readonly _typeChecker: ts.TypeChecker;\n private readonly _bundledPackageNames: ReadonlySet<string>;\n private readonly _astSymbolTable: IAstSymbolTable;\n\n private readonly _astModulesByModuleSymbol: Map<ts.Symbol, AstModule> = new Map<ts.Symbol, AstModule>();\n\n // Used with isImportableAmbientSourceFile()\n private readonly _importableAmbientSourceFiles: Set<ts.SourceFile> = new Set<ts.SourceFile>();\n\n private readonly _astImportsByKey: Map<string, AstImport> = new Map<string, AstImport>();\n private readonly _astNamespaceImportByModule: Map<AstModule, AstNamespaceImport> = new Map();\n\n public constructor(\n program: ts.Program,\n typeChecker: ts.TypeChecker,\n bundledPackageNames: ReadonlySet<string>,\n astSymbolTable: IAstSymbolTable\n ) {\n this._program = program;\n this._typeChecker = typeChecker;\n this._bundledPackageNames = bundledPackageNames;\n this._astSymbolTable = astSymbolTable;\n }\n\n /**\n * For a given source file, this analyzes all of its exports and produces an AstModule object.\n *\n * @param moduleReference - contextual information about the import statement that took us to this source file.\n * or `undefined` if this source file is the initial entry point\n * @param isExternal - whether the given `moduleReference` is external.\n */\n public fetchAstModuleFromSourceFile(\n sourceFile: ts.SourceFile,\n moduleReference: IAstModuleReference | undefined,\n isExternal: boolean\n ): AstModule {\n const moduleSymbol: ts.Symbol = this._getModuleSymbolFromSourceFile(sourceFile, moduleReference);\n\n // Don't traverse into a module that we already processed before:\n // The compiler allows m1 to have \"export * from 'm2'\" and \"export * from 'm3'\",\n // even if m2 and m3 both have \"export * from 'm4'\".\n let astModule: AstModule | undefined = this._astModulesByModuleSymbol.get(moduleSymbol);\n if (!astModule) {\n // (If moduleReference === undefined, then this is the entry point of the local project being analyzed.)\n const externalModulePath: string | undefined =\n moduleReference !== undefined && isExternal ? moduleReference.moduleSpecifier : undefined;\n\n astModule = new AstModule({ sourceFile, moduleSymbol, externalModulePath });\n\n this._astModulesByModuleSymbol.set(moduleSymbol, astModule);\n\n if (astModule.isExternal) {\n // It's an external package, so do the special simplified analysis that doesn't crawl into referenced modules\n for (const exportedSymbol of this._typeChecker.getExportsOfModule(moduleSymbol)) {\n if (externalModulePath === undefined) {\n throw new InternalError(\n 'Failed assertion: externalModulePath=undefined but astModule.isExternal=true'\n );\n }\n\n const followedSymbol: ts.Symbol = TypeScriptHelpers.followAliases(\n exportedSymbol,\n this._typeChecker\n );\n\n // Ignore virtual symbols that don't have any declarations\n const arbitraryDeclaration: ts.Declaration | undefined =\n TypeScriptHelpers.tryGetADeclaration(followedSymbol);\n if (arbitraryDeclaration) {\n const astSymbol: AstSymbol | undefined = this._astSymbolTable.fetchAstSymbol({\n followedSymbol: followedSymbol,\n isExternal: astModule.isExternal,\n includeNominalAnalysis: true,\n addIfMissing: true\n });\n\n if (!astSymbol) {\n throw new Error(\n `Unsupported export ${JSON.stringify(exportedSymbol.name)}:\\n` +\n SourceFileLocationFormatter.formatDeclaration(arbitraryDeclaration)\n );\n }\n\n astModule.cachedExportedEntities.set(exportedSymbol.name, astSymbol);\n }\n }\n } else {\n // The module is part of the local project, so do the full analysis\n\n if (moduleSymbol.exports) {\n // The \"export * from 'module-name';\" declarations are all attached to a single virtual symbol\n // whose name is InternalSymbolName.ExportStar\n const exportStarSymbol: ts.Symbol | undefined = moduleSymbol.exports.get(\n ts.InternalSymbolName.ExportStar\n );\n if (exportStarSymbol) {\n for (const exportStarDeclaration of exportStarSymbol.getDeclarations() || []) {\n if (ts.isExportDeclaration(exportStarDeclaration)) {\n const starExportedModule: AstModule | undefined = this._fetchSpecifierAstModule(\n exportStarDeclaration,\n exportStarSymbol\n );\n\n if (starExportedModule !== undefined) {\n astModule.starExportedModules.add(starExportedModule);\n }\n } else {\n // Ignore ExportDeclaration nodes that don't match the expected pattern\n // TODO: Should we report a warning?\n }\n }\n }\n }\n }\n }\n\n return astModule;\n }\n\n /**\n * Retrieves the symbol for the module corresponding to the ts.SourceFile that is being imported/exported.\n *\n * @remarks\n * The `module` keyword can be used to declare multiple TypeScript modules inside a single source file.\n * (This is a deprecated construct and mainly used for typings such as `@types/node`.) In this situation,\n * `moduleReference` helps us to fish out the correct module symbol.\n */\n private _getModuleSymbolFromSourceFile(\n sourceFile: ts.SourceFile,\n moduleReference: IAstModuleReference | undefined\n ): ts.Symbol {\n const moduleSymbol: ts.Symbol | undefined = TypeScriptInternals.tryGetSymbolForDeclaration(\n sourceFile,\n this._typeChecker\n );\n if (moduleSymbol !== undefined) {\n // This is the normal case. The SourceFile acts is a module and has a symbol.\n return moduleSymbol;\n }\n\n if (moduleReference !== undefined) {\n // But there is also an elaborate case where the source file contains one or more \"module\" declarations,\n // and our moduleReference took us to one of those.\n\n // eslint-disable-next-line no-bitwise\n if ((moduleReference.moduleSpecifierSymbol.flags & ts.SymbolFlags.Alias) !== 0) {\n // Follow the import/export declaration to one hop the exported item inside the target module\n let followedSymbol: ts.Symbol | undefined = TypeScriptInternals.getImmediateAliasedSymbol(\n moduleReference.moduleSpecifierSymbol,\n this._typeChecker\n );\n\n if (followedSymbol === undefined) {\n // This is a workaround for a compiler bug where getImmediateAliasedSymbol() sometimes returns undefined\n followedSymbol = this._typeChecker.getAliasedSymbol(moduleReference.moduleSpecifierSymbol);\n }\n\n if (followedSymbol !== undefined && followedSymbol !== moduleReference.moduleSpecifierSymbol) {\n // The parent of the exported symbol will be the module that we're importing from\n const parent: ts.Symbol | undefined = TypeScriptInternals.getSymbolParent(followedSymbol);\n if (parent !== undefined) {\n // Make sure the thing we found is a module\n // eslint-disable-next-line no-bitwise\n if ((parent.flags & ts.SymbolFlags.ValueModule) !== 0) {\n // Record that that this is an ambient module that can also be imported from\n this._importableAmbientSourceFiles.add(sourceFile);\n return parent;\n }\n }\n }\n }\n }\n\n throw new InternalError('Unable to determine module for: ' + sourceFile.fileName);\n }\n\n /**\n * Implementation of {@link AstSymbolTable.fetchAstModuleExportInfo}.\n */\n public fetchAstModuleExportInfo(entryPointAstModule: AstModule): IAstModuleExportInfo {\n if (entryPointAstModule.isExternal) {\n throw new Error('fetchAstModuleExportInfo() is not supported for external modules');\n }\n\n if (entryPointAstModule.astModuleExportInfo === undefined) {\n const astModuleExportInfo: IAstModuleExportInfo = {\n visitedAstModules: new Set<AstModule>(),\n exportedLocalEntities: new Map<string, AstEntity>(),\n starExportedExternalModules: new Set<AstModule>()\n };\n\n this._collectAllExportsRecursive(astModuleExportInfo, entryPointAstModule);\n\n entryPointAstModule.astModuleExportInfo = astModuleExportInfo;\n }\n return entryPointAstModule.astModuleExportInfo;\n }\n\n /**\n * Returns true if the module specifier refers to an external package. Ignores packages listed in the\n * \"bundledPackages\" setting from the api-extractor.json config file.\n */\n private _isExternalModulePath(\n importOrExportDeclaration: ts.ImportDeclaration | ts.ExportDeclaration | ts.ImportTypeNode,\n moduleSpecifier: string\n ): boolean {\n const specifier: ts.TypeNode | ts.Expression | undefined = ts.isImportTypeNode(importOrExportDeclaration)\n ? importOrExportDeclaration.argument\n : importOrExportDeclaration.moduleSpecifier;\n const mode: ts.ModuleKind.CommonJS | ts.ModuleKind.ESNext | undefined =\n specifier && ts.isStringLiteralLike(specifier)\n ? TypeScriptInternals.getModeForUsageLocation(\n importOrExportDeclaration.getSourceFile(),\n specifier,\n this._program.getCompilerOptions()\n )\n : undefined;\n\n const resolvedModule: ts.ResolvedModuleFull | undefined = TypeScriptInternals.getResolvedModule(\n this._program,\n importOrExportDeclaration.getSourceFile(),\n moduleSpecifier,\n mode\n );\n\n if (resolvedModule === undefined) {\n // The TS compiler API `getResolvedModule` cannot resolve ambient modules. Thus, to match API Extractor's\n // previous behavior, simply treat all ambient modules as external. This bug is tracked by\n // https://github.com/microsoft/rushstack/issues/3335.\n return true;\n }\n\n // Either something like `jquery` or `@microsoft/api-extractor`.\n const packageName: string | undefined = resolvedModule.packageId?.name;\n if (packageName !== undefined && this._bundledPackageNames.has(packageName)) {\n return false;\n }\n\n if (resolvedModule.isExternalLibraryImport === undefined) {\n // This presumably means the compiler couldn't figure out whether the module was external, but we're not\n // sure how this can happen.\n throw new InternalError(\n `Cannot determine whether the module ${JSON.stringify(moduleSpecifier)} is external\\n` +\n SourceFileLocationFormatter.formatDeclaration(importOrExportDeclaration)\n );\n }\n\n return resolvedModule.isExternalLibraryImport;\n }\n\n /**\n * Returns true if when we analyzed sourceFile, we found that it contains an \"export=\" statement that allows\n * it to behave /either/ as an ambient module /or/ as a regular importable module. In this case,\n * `AstSymbolTable._fetchAstSymbol()` will analyze its symbols even though `TypeScriptHelpers.isAmbient()`\n * returns true.\n */\n public isImportableAmbientSourceFile(sourceFile: ts.SourceFile): boolean {\n return this._importableAmbientSourceFiles.has(sourceFile);\n }\n\n private _collectAllExportsRecursive(astModuleExportInfo: IAstModuleExportInfo, astModule: AstModule): void {\n const { visitedAstModules, starExportedExternalModules, exportedLocalEntities } = astModuleExportInfo;\n if (visitedAstModules.has(astModule)) {\n return;\n }\n visitedAstModules.add(astModule);\n\n if (astModule.isExternal) {\n starExportedExternalModules.add(astModule);\n } else {\n // Fetch each of the explicit exports for this module\n if (astModule.moduleSymbol.exports) {\n astModule.moduleSymbol.exports.forEach((exportSymbol, exportName) => {\n switch (exportName) {\n case ts.InternalSymbolName.ExportStar:\n case ts.InternalSymbolName.ExportEquals:\n break;\n default:\n // Don't collect the \"export default\" symbol unless this is the entry point module\n if (exportName !== ts.InternalSymbolName.Default || visitedAstModules.size === 1) {\n if (!exportedLocalEntities.has(exportSymbol.name)) {\n const astEntity: AstEntity = this._getExportOfAstModule(exportSymbol.name, astModule);\n\n if (astEntity instanceof AstSymbol && !astEntity.isExternal) {\n this._astSymbolTable.analyze(astEntity);\n }\n\n if (astEntity instanceof AstNamespaceImport && !astEntity.astModule.isExternal) {\n this._astSymbolTable.analyze(astEntity);\n }\n\n exportedLocalEntities.set(exportSymbol.name, astEntity);\n }\n }\n break;\n }\n });\n }\n\n for (const starExportedModule of astModule.starExportedModules) {\n this._collectAllExportsRecursive(astModuleExportInfo, starExportedModule);\n }\n }\n }\n\n /**\n * For a given symbol (which was encountered in the specified sourceFile), this fetches the AstEntity that it\n * refers to. For example, if a particular interface describes the return value of a function, this API can help\n * us determine a TSDoc declaration reference for that symbol (if the symbol is exported).\n */\n public fetchReferencedAstEntity(\n symbol: ts.Symbol,\n referringModuleIsExternal: boolean\n ): AstEntity | undefined {\n // eslint-disable-next-line no-bitwise\n if ((symbol.flags & ts.SymbolFlags.FunctionScopedVariable) !== 0) {\n // If a symbol refers back to part of its own definition, don't follow that rabbit hole\n // Example:\n //\n // function f(x: number): typeof x {\n // return 123;\n // }\n return undefined;\n }\n\n let current: ts.Symbol = symbol;\n\n if (referringModuleIsExternal) {\n current = TypeScriptHelpers.followAliases(symbol, this._typeChecker);\n } else {\n for (;;) {\n // Is this symbol an import/export that we need to follow to find the real declaration?\n for (const declaration of current.declarations || []) {\n let matchedAstEntity: AstEntity | undefined;\n matchedAstEntity = this._tryMatchExportDeclaration(declaration, current);\n if (matchedAstEntity !== undefined) {\n return matchedAstEntity;\n }\n matchedAstEntity = this._tryMatchImportDeclaration(declaration, current);\n if (matchedAstEntity !== undefined) {\n return matchedAstEntity;\n }\n }\n\n // eslint-disable-next-line no-bitwise\n if (!(current.flags & ts.SymbolFlags.Alias)) {\n break;\n }\n\n const currentAlias: ts.Symbol = TypeScriptInternals.getImmediateAliasedSymbol(\n current,\n this._typeChecker\n );\n // Stop if we reach the end of the chain\n if (!currentAlias || currentAlias === current) {\n break;\n }\n\n current = currentAlias;\n }\n }\n\n // Otherwise, assume it is a normal declaration\n const astSymbol: AstSymbol | undefined = this._astSymbolTable.fetchAstSymbol({\n followedSymbol: current,\n isExternal: referringModuleIsExternal,\n includeNominalAnalysis: false,\n addIfMissing: true\n });\n\n return astSymbol;\n }\n\n public fetchReferencedAstEntityFromImportTypeNode(\n node: ts.ImportTypeNode,\n referringModuleIsExternal: boolean\n ): AstEntity | undefined {\n const externalModulePath: string | undefined = this._tryGetExternalModulePath(node);\n\n if (externalModulePath) {\n let exportName: string;\n if (node.qualifier) {\n // Example input:\n // import('api-extractor-lib1-test').Lib1GenericType<number>\n //\n // Extracted qualifier:\n // Lib1GenericType\n exportName = node.qualifier.getText().trim();\n } else {\n // Example input:\n // import('api-extractor-lib1-test')\n //\n // Extracted qualifier:\n // apiExtractorLib1Test\n\n exportName = SyntaxHelpers.makeCamelCaseIdentifier(externalModulePath);\n }\n\n return this._fetchAstImport(undefined, {\n importKind: AstImportKind.ImportType,\n exportName: exportName,\n modulePath: externalModulePath,\n isTypeOnly: false\n });\n }\n\n // Internal reference: AstSymbol\n const rightMostToken: ts.Identifier | ts.ImportTypeNode = node.qualifier\n ? node.qualifier.kind === ts.SyntaxKind.QualifiedName\n ? node.qualifier.right\n : node.qualifier\n : node;\n\n // There is no symbol property in a ImportTypeNode, obtain the associated export symbol\n const exportSymbol: ts.Symbol | undefined = this._typeChecker.getSymbolAtLocation(rightMostToken);\n if (!exportSymbol) {\n throw new InternalError(\n `Symbol not found for identifier: ${node.getText()}\\n` +\n SourceFileLocationFormatter.formatDeclaration(node)\n );\n }\n\n let followedSymbol: ts.Symbol = exportSymbol;\n for (;;) {\n const referencedAstEntity: AstEntity | undefined = this.fetchReferencedAstEntity(\n followedSymbol,\n referringModuleIsExternal\n );\n\n if (referencedAstEntity) {\n return referencedAstEntity;\n }\n\n const followedSymbolNode: ts.Node | ts.ImportTypeNode | undefined =\n followedSymbol.declarations && (followedSymbol.declarations[0] as ts.Node | undefined);\n\n if (followedSymbolNode && followedSymbolNode.kind === ts.SyntaxKind.ImportType) {\n return this.fetchReferencedAstEntityFromImportTypeNode(\n followedSymbolNode as ts.ImportTypeNode,\n referringModuleIsExternal\n );\n }\n\n // eslint-disable-next-line no-bitwise\n if (!(followedSymbol.flags & ts.SymbolFlags.Alias)) {\n break;\n }\n\n const currentAlias: ts.Symbol = this._typeChecker.getAliasedSymbol(followedSymbol);\n if (!currentAlias || currentAlias === followedSymbol) {\n break;\n }\n\n followedSymbol = currentAlias;\n }\n\n const astSymbol: AstSymbol | undefined = this._astSymbolTable.fetchAstSymbol({\n followedSymbol: followedSymbol,\n isExternal: referringModuleIsExternal,\n includeNominalAnalysis: false,\n addIfMissing: true\n });\n\n return astSymbol;\n }\n\n private _tryMatchExportDeclaration(\n declaration: ts.Declaration,\n declarationSymbol: ts.Symbol\n ): AstEntity | undefined {\n const exportDeclaration: ts.ExportDeclaration | undefined =\n TypeScriptHelpers.findFirstParent<ts.ExportDeclaration>(declaration, ts.SyntaxKind.ExportDeclaration);\n\n if (exportDeclaration) {\n let exportName: string | undefined = undefined;\n\n if (declaration.kind === ts.SyntaxKind.ExportSpecifier) {\n // EXAMPLE:\n // \"export { A } from './file-a';\"\n //\n // ExportDeclaration:\n // ExportKeyword: pre=[export] sep=[ ]\n // NamedExports:\n // FirstPunctuation: pre=[{] sep=[ ]\n // SyntaxList:\n // ExportSpecifier: <------------- declaration\n // Identifier: pre=[A] sep=[ ]\n // CloseBraceToken: pre=[}] sep=[ ]\n // FromKeyword: pre=[from] sep=[ ]\n // StringLiteral: pre=['./file-a']\n // SemicolonToken: pre=[;]\n\n // Example: \" ExportName as RenamedName\"\n const exportSpecifier: ts.ExportSpecifier = declaration as ts.ExportSpecifier;\n exportName = (exportSpecifier.propertyName || exportSpecifier.name).getText().trim();\n } else if (declaration.kind === ts.SyntaxKind.NamespaceExport) {\n // EXAMPLE:\n // \"export * as theLib from 'the-lib';\"\n //\n // ExportDeclaration:\n // ExportKeyword: pre=[export] sep=[ ]\n // NamespaceExport:\n // AsteriskToken: pre=[*] sep=[ ]\n // AsKeyword: pre=[as] sep=[ ]\n // Identifier: pre=[theLib] sep=[ ]\n // FromKeyword: pre=[from] sep=[ ]\n // StringLiteral: pre=['the-lib']\n // SemicolonToken: pre=[;]\n\n // Issue tracking this feature: https://github.com/microsoft/rushstack/issues/2780\n\n const astModule: AstModule = this._fetchSpecifierAstModule(exportDeclaration, declarationSymbol);\n return this._getAstNamespaceExport(astModule, declarationSymbol, declaration);\n } else {\n throw new InternalError(\n `Unimplemented export declaration kind: ${declaration.getText()}\\n` +\n SourceFileLocationFormatter.formatDeclaration(declaration)\n );\n }\n\n // Ignore \"export { A }\" without a module specifier\n if (exportDeclaration.moduleSpecifier) {\n const externalModulePath: string | undefined = this._tryGetExternalModulePath(exportDeclaration);\n\n if (externalModulePath !== undefined) {\n return this._fetchAstImport(declarationSymbol, {\n importKind: AstImportKind.NamedImport,\n modulePath: externalModulePath,\n exportName: exportName,\n isTypeOnly: false\n });\n }\n\n return this._getExportOfSpecifierAstModule(exportName, exportDeclaration, declarationSymbol);\n }\n }\n\n return undefined;\n }\n\n private _getAstNamespaceExport(\n astModule: AstModule,\n declarationSymbol: ts.Symbol,\n declaration: ts.Declaration\n ): AstNamespaceExport {\n const imoprtNamespace: AstNamespaceImport = this._getAstNamespaceImport(\n astModule,\n declarationSymbol,\n declaration\n );\n\n return new AstNamespaceExport({\n namespaceName: imoprtNamespace.localName,\n astModule: astModule,\n declaration,\n symbol: declarationSymbol\n });\n }\n\n private _tryMatchImportDeclaration(\n declaration: ts.Declaration,\n declarationSymbol: ts.Symbol\n ): AstEntity | undefined {\n const importDeclaration: ts.ImportDeclaration | undefined =\n TypeScriptHelpers.findFirstParent<ts.ImportDeclaration>(declaration, ts.SyntaxKind.ImportDeclaration);\n\n if (importDeclaration) {\n const externalModulePath: string | undefined = this._tryGetExternalModulePath(importDeclaration);\n\n if (declaration.kind === ts.SyntaxKind.NamespaceImport) {\n // EXAMPLE:\n // \"import * as theLib from 'the-lib';\"\n //\n // ImportDeclaration:\n // ImportKeyword: pre=[import] sep=[ ]\n // ImportClause:\n // NamespaceImport: <------------- declaration\n // AsteriskToken: pre=[*] sep=[ ]\n // AsKeyword: pre=[as] sep=[ ]\n // Identifier: pre=[theLib] sep=[ ]\n // FromKeyword: pre=[from] sep=[ ]\n // StringLiteral: pre=['the-lib']\n // SemicolonToken: pre=[;]\n\n if (externalModulePath === undefined) {\n const astModule: AstModule = this._fetchSpecifierAstModule(importDeclaration, declarationSymbol);\n return this._getAstNamespaceImport(astModule, declarationSymbol, declaration);\n }\n\n // Here importSymbol=undefined because {@inheritDoc} and such are not going to work correctly for\n // a package or source file.\n return this._fetchAstImport(undefined, {\n importKind: AstImportKind.StarImport,\n exportName: declarationSymbol.name,\n modulePath: externalModulePath,\n isTypeOnly: ExportAnalyzer._getIsTypeOnly(importDeclaration)\n });\n }\n\n if (declaration.kind === ts.SyntaxKind.ImportSpecifier) {\n // EXAMPLE:\n // \"import { A, B } from 'the-lib';\"\n //\n // ImportDeclaration:\n // ImportKeyword: pre=[import] sep=[ ]\n // ImportClause:\n // NamedImports:\n // FirstPunctuation: pre=[{] sep=[ ]\n // SyntaxList:\n // ImportSpecifier: <------------- declaration\n // Identifier: pre=[A]\n // CommaToken: pre=[,] sep=[ ]\n // ImportSpecifier:\n // Identifier: pre=[B] sep=[ ]\n // CloseBraceToken: pre=[}] sep=[ ]\n // FromKeyword: pre=[from] sep=[ ]\n // StringLiteral: pre=['the-lib']\n // SemicolonToken: pre=[;]\n\n // Example: \" ExportName as RenamedName\"\n const importSpecifier: ts.ImportSpecifier = declaration as ts.ImportSpecifier;\n const exportName: string = (importSpecifier.propertyName || importSpecifier.name).getText().trim();\n\n if (externalModulePath !== undefined) {\n return this._fetchAstImport(declarationSymbol, {\n importKind: AstImportKind.NamedImport,\n modulePath: externalModulePath,\n exportName: exportName,\n isTypeOnly: ExportAnalyzer._getIsTypeOnly(importDeclaration)\n });\n }\n\n return this._getExportOfSpecifierAstModule(exportName, importDeclaration, declarationSymbol);\n } else if (declaration.kind === ts.SyntaxKind.ImportClause) {\n // EXAMPLE:\n // \"import A, { B } from './A';\"\n //\n // ImportDeclaration:\n // ImportKeyword: pre=[import] sep=[ ]\n // ImportClause: <------------- declaration (referring to A)\n // Identifier: pre=[A]\n // CommaToken: pre=[,] sep=[ ]\n // NamedImports:\n // FirstPunctuation: pre=[{] sep=[ ]\n // SyntaxList:\n // ImportSpecifier:\n // Identifier: pre=[B] sep=[ ]\n // CloseBraceToken: pre=[}] sep=[ ]\n // FromKeyword: pre=[from] sep=[ ]\n // StringLiteral: pre=['./A']\n // SemicolonToken: pre=[;]\n\n const importClause: ts.ImportClause = declaration as ts.ImportClause;\n const exportName: string = importClause.name\n ? importClause.name.getText().trim()\n : ts.InternalSymbolName.Default;\n\n if (externalModulePath !== undefined) {\n return this._fetchAstImport(declarationSymbol, {\n importKind: AstImportKind.DefaultImport,\n modulePath: externalModulePath,\n exportName,\n isTypeOnly: ExportAnalyzer._getIsTypeOnly(importDeclaration)\n });\n }\n\n return this._getExportOfSpecifierAstModule(\n ts.InternalSymbolName.Default,\n importDeclaration,\n declarationSymbol\n );\n } else {\n throw new InternalError(\n `Unimplemented import declaration kind: ${declaration.getText()}\\n` +\n SourceFileLocationFormatter.formatDeclaration(declaration)\n );\n }\n }\n\n if (ts.isImportEqualsDeclaration(declaration)) {\n // EXAMPLE:\n // import myLib = require('my-lib');\n //\n // ImportEqualsDeclaration:\n // ImportKeyword: pre=[import] sep=[ ]\n // Identifier: pre=[myLib] sep=[ ]\n // FirstAssignment: pre=[=] sep=[ ]\n // ExternalModuleReference:\n // RequireKeyword: pre=[require]\n // OpenParenToken: pre=[(]\n // StringLiteral: pre=['my-lib']\n // CloseParenToken: pre=[)]\n // SemicolonToken: pre=[;]\n if (ts.isExternalModuleReference(declaration.moduleReference)) {\n if (ts.isStringLiteralLike(declaration.moduleReference.expression)) {\n const variableName: string = TypeScriptInternals.getTextOfIdentifierOrLiteral(declaration.name);\n const externalModuleName: string = TypeScriptInternals.getTextOfIdentifierOrLiteral(\n declaration.moduleReference.expression\n );\n\n return this._fetchAstImport(declarationSymbol, {\n importKind: AstImportKind.EqualsImport,\n modulePath: externalModuleName,\n exportName: variableName,\n isTypeOnly: false\n });\n }\n }\n }\n\n return undefined;\n }\n\n private _getAstNamespaceImport(\n astModule: AstModule,\n declarationSymbol: ts.Symbol,\n declaration: ts.Declaration\n ): AstNamespaceImport {\n let namespaceImport: AstNamespaceImport | undefined = this._astNamespaceImportByModule.get(astModule);\n if (namespaceImport === undefined) {\n namespaceImport = new AstNamespaceImport({\n namespaceName: declarationSymbol.name,\n astModule: astModule,\n declaration: declaration,\n symbol: declarationSymbol\n });\n this._astNamespaceImportByModule.set(astModule, namespaceImport);\n }\n\n return namespaceImport;\n }\n\n private static _getIsTypeOnly(importDeclaration: ts.ImportDeclaration): boolean {\n if (importDeclaration.importClause) {\n return !!importDeclaration.importClause.isTypeOnly;\n }\n return false;\n }\n\n private _getExportOfSpecifierAstModule(\n exportName: string,\n importOrExportDeclaration: ts.ImportDeclaration | ts.ExportDeclaration,\n exportSymbol: ts.Symbol\n ): AstEntity {\n const specifierAstModule: AstModule = this._fetchSpecifierAstModule(\n importOrExportDeclaration,\n exportSymbol\n );\n const astEntity: AstEntity = this._getExportOfAstModule(exportName, specifierAstModule);\n return astEntity;\n }\n\n private _getExportOfAstModule(exportName: string, astModule: AstModule): AstEntity {\n const visitedAstModules: Set<AstModule> = new Set<AstModule>();\n const astEntity: AstEntity | undefined = this._tryGetExportOfAstModule(\n exportName,\n astModule,\n visitedAstModules\n );\n if (astEntity === undefined) {\n throw new InternalError(\n `Unable to analyze the export ${JSON.stringify(exportName)} in\\n` + astModule.sourceFile.fileName\n );\n }\n return astEntity;\n }\n\n /**\n * Implementation of {@link AstSymbolTable.tryGetExportOfAstModule}.\n */\n public tryGetExportOfAstModule(exportName: string, astModule: AstModule): AstEntity | undefined {\n const visitedAstModules: Set<AstModule> = new Set<AstModule>();\n return this._tryGetExportOfAstModule(exportName, astModule, visitedAstModules);\n }\n\n private _tryGetExportOfAstModule(\n exportName: string,\n astModule: AstModule,\n visitedAstModules: Set<AstModule>\n ): AstEntity | undefined {\n if (visitedAstModules.has(astModule)) {\n return undefined;\n }\n visitedAstModules.add(astModule);\n\n let astEntity: AstEntity | undefined = astModule.cachedExportedEntities.get(exportName);\n if (astEntity !== undefined) {\n return astEntity;\n }\n\n // Try the explicit exports\n const escapedExportName: ts.__String = ts.escapeLeadingUnderscores(exportName);\n if (astModule.moduleSymbol.exports) {\n const exportSymbol: ts.Symbol | undefined = astModule.moduleSymbol.exports.get(escapedExportName);\n if (exportSymbol) {\n astEntity = this.fetchReferencedAstEntity(exportSymbol, astModule.isExternal);\n\n if (astEntity !== undefined) {\n astModule.cachedExportedEntities.set(exportName, astEntity); // cache for next time\n return astEntity;\n }\n }\n }\n\n // Try each of the star imports\n for (const starExportedModule of astModule.starExportedModules) {\n astEntity = this._tryGetExportOfAstModule(exportName, starExportedModule, visitedAstModules);\n\n if (astEntity !== undefined) {\n if (starExportedModule.externalModulePath !== undefined) {\n // This entity was obtained from an external module, so return an AstImport instead\n const astSymbol: AstSymbol = astEntity as AstSymbol;\n return this._fetchAstImport(astSymbol.followedSymbol, {\n importKind: AstImportKind.NamedImport,\n modulePath: starExportedModule.externalModulePath,\n exportName: exportName,\n isTypeOnly: false\n });\n }\n\n return astEntity;\n }\n }\n\n return undefined;\n }\n\n private _tryGetExternalModulePath(\n importOrExportDeclaration: ts.ImportDeclaration | ts.ExportDeclaration | ts.ImportTypeNode\n ): string | undefined {\n const moduleSpecifier: string = this._getModuleSpecifier(importOrExportDeclaration);\n if (this._isExternalModulePath(importOrExportDeclaration, moduleSpecifier)) {\n return moduleSpecifier;\n }\n\n return undefined;\n }\n\n /**\n * Given an ImportDeclaration of the form `export { X } from \"___\";`, this interprets the module specifier (`\"___\"`)\n * and fetches the corresponding AstModule object.\n */\n private _fetchSpecifierAstModule(\n importOrExportDeclaration: ts.ImportDeclaration | ts.ExportDeclaration,\n exportSymbol: ts.Symbol\n ): AstModule {\n const moduleSpecifier: string = this._getModuleSpecifier(importOrExportDeclaration);\n const mode: ts.ModuleKind.CommonJS | ts.ModuleKind.ESNext | undefined =\n importOrExportDeclaration.moduleSpecifier &&\n ts.isStringLiteralLike(importOrExportDeclaration.moduleSpecifier)\n ? TypeScriptInternals.getModeForUsageLocation(\n importOrExportDeclaration.getSourceFile(),\n importOrExportDeclaration.moduleSpecifier,\n this._program.getCompilerOptions()\n )\n : undefined;\n const resolvedModule: ts.ResolvedModuleFull | undefined = TypeScriptInternals.getResolvedModule(\n this._program,\n importOrExportDeclaration.getSourceFile(),\n moduleSpecifier,\n mode\n );\n\n if (resolvedModule === undefined) {\n // Encountered in https://github.com/microsoft/rushstack/issues/1914.\n //\n // It's also possible for this to occur with ambient modules. However, in practice this doesn't happen\n // as API Extractor treats all ambient modules as external per the logic in `_isExternalModulePath`, and\n // thus this code path is never reached for ambient modules.\n throw new InternalError(\n `getResolvedModule() could not resolve module name ${JSON.stringify(moduleSpecifier)}\\n` +\n SourceFileLocationFormatter.formatDeclaration(importOrExportDeclaration)\n );\n }\n\n // Map the filename back to the corresponding SourceFile. This circuitous approach is needed because\n // we have no way to access the compiler's internal resolveExternalModuleName() function\n const moduleSourceFile: ts.SourceFile | undefined = this._program.getSourceFile(\n resolvedModule.resolvedFileName\n );\n if (!moduleSourceFile) {\n // This should not happen, since getResolvedModule() specifically looks up names that the compiler\n // found in export declarations for this source file\n throw new InternalError(\n `getSourceFile() failed to locate ${JSON.stringify(resolvedModule.resolvedFileName)}\\n` +\n SourceFileLocationFormatter.formatDeclaration(importOrExportDeclaration)\n );\n }\n\n const isExternal: boolean = this._isExternalModulePath(importOrExportDeclaration, moduleSpecifier);\n const moduleReference: IAstModuleReference = {\n moduleSpecifier: moduleSpecifier,\n moduleSpecifierSymbol: exportSymbol\n };\n const specifierAstModule: AstModule = this.fetchAstModuleFromSourceFile(\n moduleSourceFile,\n moduleReference,\n isExternal\n );\n\n return specifierAstModule;\n }\n\n private _fetchAstImport(importSymbol: ts.Symbol | undefined, options: IAstImportOptions): AstImport {\n const key: string = AstImport.getKey(options);\n\n let astImport: AstImport | undefined = this._astImportsByKey.get(key);\n\n if (!astImport) {\n astImport = new AstImport(options);\n this._astImportsByKey.set(key, astImport);\n\n if (importSymbol) {\n const followedSymbol: ts.Symbol = TypeScriptHelpers.followAliases(importSymbol, this._typeChecker);\n\n astImport.astSymbol = this._astSymbolTable.fetchAstSymbol({\n followedSymbol: followedSymbol,\n isExternal: true,\n includeNominalAnalysis: false,\n addIfMissing: true\n });\n }\n } else {\n // If we encounter at least one import that does not use the type-only form,\n // then the .d.ts rollup will NOT use \"import type\".\n if (!options.isTypeOnly) {\n astImport.isTypeOnlyEverywhere = false;\n }\n }\n\n return astImport;\n }\n\n private _getModuleSpecifier(\n importOrExportDeclaration: ts.ImportDeclaration | ts.ExportDeclaration | ts.ImportTypeNode\n ): string {\n // The name of the module, which could be like \"./SomeLocalFile' or like 'external-package/entry/point'\n const moduleSpecifier: string | undefined =\n TypeScriptHelpers.getModuleSpecifier(importOrExportDeclaration);\n\n if (!moduleSpecifier) {\n throw new InternalError(\n 'Unable to parse module specifier\\n' +\n SourceFileLocationFormatter.formatDeclaration(importOrExportDeclaration)\n );\n }\n\n return moduleSpecifier;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ExportAnalyzer.js","sourceRoot":"","sources":["../../src/analyzer/ExportAnalyzer.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,+CAAiC;AACjC,oEAA6D;AAE7D,2DAAwD;AACxD,2CAAwC;AACxC,2CAA+E;AAC/E,2CAAmE;AACnE,+DAA4D;AAC5D,+EAA4E;AAG5E,6DAA0D;AAC1D,mDAAgD;AAChD,6DAA0D;AAgC1D;;;;;;;;;GASG;AACH,MAAa,cAAc;IAczB,YACE,OAAmB,EACnB,WAA2B,EAC3B,mBAAwC,EACxC,cAA+B;QAZhB,8BAAyB,GAA8B,IAAI,GAAG,EAAwB,CAAC;QAExG,4CAA4C;QAC3B,kCAA6B,GAAuB,IAAI,GAAG,EAAiB,CAAC;QAE7E,qBAAgB,GAA2B,IAAI,GAAG,EAAqB,CAAC;QACxE,gCAA2B,GAAuC,IAAI,GAAG,EAAE,CAAC;QAQ3F,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,oBAAoB,GAAG,mBAAmB,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Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as ts from 'typescript';\nimport { InternalError } from '@rushstack/node-core-library';\n\nimport { TypeScriptHelpers } from './TypeScriptHelpers';\nimport { AstSymbol } from './AstSymbol';\nimport { AstImport, type IAstImportOptions, AstImportKind } from './AstImport';\nimport { AstModule, type IAstModuleExportInfo } from './AstModule';\nimport { TypeScriptInternals } from './TypeScriptInternals';\nimport { SourceFileLocationFormatter } from './SourceFileLocationFormatter';\nimport type { IFetchAstSymbolOptions } from './AstSymbolTable';\nimport type { AstEntity } from './AstEntity';\nimport { AstNamespaceImport } from './AstNamespaceImport';\nimport { SyntaxHelpers } from './SyntaxHelpers';\nimport { AstNamespaceExport } from './AstNamespaceExport';\n\n/**\n * Exposes the minimal APIs from AstSymbolTable that are needed by ExportAnalyzer.\n *\n * In particular, we want ExportAnalyzer to be able to call AstSymbolTable._fetchAstSymbol() even though it\n * is a very private API that should not be exposed to any other components.\n */\nexport interface IAstSymbolTable {\n fetchAstSymbol(options: IFetchAstSymbolOptions): AstSymbol | undefined;\n\n analyze(astEntity: AstEntity): void;\n}\n\n/**\n * Used with ExportAnalyzer.fetchAstModuleBySourceFile() to provide contextual information about how the source file\n * was imported.\n */\ninterface IAstModuleReference {\n /**\n * For example, if we are following a statement like `import { X } from 'some-package'`, this will be the\n * string `\"some-package\"`.\n */\n moduleSpecifier: string;\n\n /**\n * For example, if we are following a statement like `import { X } from 'some-package'`, this will be the\n * symbol for `X`.\n */\n moduleSpecifierSymbol: ts.Symbol;\n}\n\n/**\n * The ExportAnalyzer is an internal part of AstSymbolTable that has been moved out into its own source file\n * because it is a complex and mostly self-contained algorithm.\n *\n * Its job is to build up AstModule objects by crawling import statements to discover where declarations come from.\n * This is conceptually the same as the compiler's own TypeChecker.getExportsOfModule(), except that when\n * ExportAnalyzer encounters a declaration that was imported from an external package, it remembers how it was imported\n * (i.e. the AstImport object). Today the compiler API does not expose this information, which is crucial for\n * generating .d.ts rollups.\n */\nexport class ExportAnalyzer {\n private readonly _program: ts.Program;\n private readonly _typeChecker: ts.TypeChecker;\n private readonly _bundledPackageNames: ReadonlySet<string>;\n private readonly _astSymbolTable: IAstSymbolTable;\n\n private readonly _astModulesByModuleSymbol: Map<ts.Symbol, AstModule> = new Map<ts.Symbol, AstModule>();\n\n // Used with isImportableAmbientSourceFile()\n private readonly _importableAmbientSourceFiles: Set<ts.SourceFile> = new Set<ts.SourceFile>();\n\n private readonly _astImportsByKey: Map<string, AstImport> = new Map<string, AstImport>();\n private readonly _astNamespaceImportByModule: Map<AstModule, AstNamespaceImport> = new Map();\n\n public constructor(\n program: ts.Program,\n typeChecker: ts.TypeChecker,\n bundledPackageNames: ReadonlySet<string>,\n astSymbolTable: IAstSymbolTable\n ) {\n this._program = program;\n this._typeChecker = typeChecker;\n this._bundledPackageNames = bundledPackageNames;\n this._astSymbolTable = astSymbolTable;\n }\n\n /**\n * For a given source file, this analyzes all of its exports and produces an AstModule object.\n *\n * @param moduleReference - contextual information about the import statement that took us to this source file.\n * or `undefined` if this source file is the initial entry point\n * @param isExternal - whether the given `moduleReference` is external.\n */\n public fetchAstModuleFromSourceFile(\n sourceFile: ts.SourceFile,\n moduleReference: IAstModuleReference | undefined,\n isExternal: boolean\n ): AstModule {\n const moduleSymbol: ts.Symbol = this._getModuleSymbolFromSourceFile(sourceFile, moduleReference);\n\n // Don't traverse into a module that we already processed before:\n // The compiler allows m1 to have \"export * from 'm2'\" and \"export * from 'm3'\",\n // even if m2 and m3 both have \"export * from 'm4'\".\n let astModule: AstModule | undefined = this._astModulesByModuleSymbol.get(moduleSymbol);\n if (!astModule) {\n // (If moduleReference === undefined, then this is the entry point of the local project being analyzed.)\n const externalModulePath: string | undefined =\n moduleReference !== undefined && isExternal ? moduleReference.moduleSpecifier : undefined;\n\n astModule = new AstModule({ sourceFile, moduleSymbol, externalModulePath });\n\n this._astModulesByModuleSymbol.set(moduleSymbol, astModule);\n\n if (astModule.isExternal) {\n // It's an external package, so do the special simplified analysis that doesn't crawl into referenced modules\n for (const exportedSymbol of this._typeChecker.getExportsOfModule(moduleSymbol)) {\n if (externalModulePath === undefined) {\n throw new InternalError(\n 'Failed assertion: externalModulePath=undefined but astModule.isExternal=true'\n );\n }\n\n const followedSymbol: ts.Symbol = TypeScriptHelpers.followAliases(\n exportedSymbol,\n this._typeChecker\n );\n\n // Ignore virtual symbols that don't have any declarations\n const arbitraryDeclaration: ts.Declaration | undefined =\n TypeScriptHelpers.tryGetADeclaration(followedSymbol);\n if (arbitraryDeclaration) {\n const astSymbol: AstSymbol | undefined = this._astSymbolTable.fetchAstSymbol({\n followedSymbol: followedSymbol,\n isExternal: astModule.isExternal,\n includeNominalAnalysis: true,\n addIfMissing: true\n });\n\n if (!astSymbol) {\n throw new Error(\n `Unsupported export ${JSON.stringify(exportedSymbol.name)}:\\n` +\n SourceFileLocationFormatter.formatDeclaration(arbitraryDeclaration)\n );\n }\n\n astModule.cachedExportedEntities.set(exportedSymbol.name, astSymbol);\n }\n }\n } else {\n // The module is part of the local project, so do the full analysis\n\n if (moduleSymbol.exports) {\n // The \"export * from 'module-name';\" declarations are all attached to a single virtual symbol\n // whose name is InternalSymbolName.ExportStar\n const exportStarSymbol: ts.Symbol | undefined = moduleSymbol.exports.get(\n ts.InternalSymbolName.ExportStar\n );\n if (exportStarSymbol) {\n for (const exportStarDeclaration of exportStarSymbol.getDeclarations() || []) {\n if (ts.isExportDeclaration(exportStarDeclaration)) {\n const starExportedModule: AstModule | undefined = this._fetchSpecifierAstModule(\n exportStarDeclaration,\n exportStarSymbol\n );\n\n if (starExportedModule !== undefined) {\n astModule.starExportedModules.add(starExportedModule);\n }\n } else {\n // Ignore ExportDeclaration nodes that don't match the expected pattern\n // TODO: Should we report a warning?\n }\n }\n }\n }\n }\n }\n\n return astModule;\n }\n\n /**\n * Retrieves the symbol for the module corresponding to the ts.SourceFile that is being imported/exported.\n *\n * @remarks\n * The `module` keyword can be used to declare multiple TypeScript modules inside a single source file.\n * (This is a deprecated construct and mainly used for typings such as `@types/node`.) In this situation,\n * `moduleReference` helps us to fish out the correct module symbol.\n */\n private _getModuleSymbolFromSourceFile(\n sourceFile: ts.SourceFile,\n moduleReference: IAstModuleReference | undefined\n ): ts.Symbol {\n const moduleSymbol: ts.Symbol | undefined = TypeScriptInternals.tryGetSymbolForDeclaration(\n sourceFile,\n this._typeChecker\n );\n if (moduleSymbol !== undefined) {\n // This is the normal case. The SourceFile acts is a module and has a symbol.\n return moduleSymbol;\n }\n\n if (moduleReference !== undefined) {\n // But there is also an elaborate case where the source file contains one or more \"module\" declarations,\n // and our moduleReference took us to one of those.\n\n // eslint-disable-next-line no-bitwise\n if ((moduleReference.moduleSpecifierSymbol.flags & ts.SymbolFlags.Alias) !== 0) {\n // Follow the import/export declaration to one hop the exported item inside the target module\n let followedSymbol: ts.Symbol | undefined = TypeScriptInternals.getImmediateAliasedSymbol(\n moduleReference.moduleSpecifierSymbol,\n this._typeChecker\n );\n\n if (followedSymbol === undefined) {\n // This is a workaround for a compiler bug where getImmediateAliasedSymbol() sometimes returns undefined\n followedSymbol = this._typeChecker.getAliasedSymbol(moduleReference.moduleSpecifierSymbol);\n }\n\n if (followedSymbol !== undefined && followedSymbol !== moduleReference.moduleSpecifierSymbol) {\n // The parent of the exported symbol will be the module that we're importing from\n const parent: ts.Symbol | undefined = TypeScriptInternals.getSymbolParent(followedSymbol);\n if (parent !== undefined) {\n // Make sure the thing we found is a module\n // eslint-disable-next-line no-bitwise\n if ((parent.flags & ts.SymbolFlags.ValueModule) !== 0) {\n // Record that that this is an ambient module that can also be imported from\n this._importableAmbientSourceFiles.add(sourceFile);\n return parent;\n }\n }\n }\n }\n }\n\n throw new InternalError('Unable to determine module for: ' + sourceFile.fileName);\n }\n\n /**\n * Implementation of {@link AstSymbolTable.fetchAstModuleExportInfo}.\n */\n public fetchAstModuleExportInfo(entryPointAstModule: AstModule): IAstModuleExportInfo {\n if (entryPointAstModule.isExternal) {\n throw new Error('fetchAstModuleExportInfo() is not supported for external modules');\n }\n\n if (entryPointAstModule.astModuleExportInfo === undefined) {\n const astModuleExportInfo: IAstModuleExportInfo = {\n visitedAstModules: new Set<AstModule>(),\n exportedLocalEntities: new Map<string, AstEntity>(),\n starExportedExternalModules: new Set<AstModule>()\n };\n\n this._collectAllExportsRecursive(astModuleExportInfo, entryPointAstModule);\n\n entryPointAstModule.astModuleExportInfo = astModuleExportInfo;\n }\n return entryPointAstModule.astModuleExportInfo;\n }\n\n /**\n * Returns true if the module specifier refers to an external package. Ignores packages listed in the\n * \"bundledPackages\" setting from the api-extractor.json config file.\n */\n private _isExternalModulePath(\n importOrExportDeclaration: ts.ImportDeclaration | ts.ExportDeclaration | ts.ImportTypeNode,\n moduleSpecifier: string\n ): boolean {\n const specifier: ts.TypeNode | ts.Expression | undefined = ts.isImportTypeNode(importOrExportDeclaration)\n ? importOrExportDeclaration.argument\n : importOrExportDeclaration.moduleSpecifier;\n const mode: ts.ModuleKind.CommonJS | ts.ModuleKind.ESNext | undefined =\n specifier && ts.isStringLiteralLike(specifier)\n ? TypeScriptInternals.getModeForUsageLocation(\n importOrExportDeclaration.getSourceFile(),\n specifier,\n this._program.getCompilerOptions()\n )\n : undefined;\n\n const resolvedModule: ts.ResolvedModuleFull | undefined = TypeScriptInternals.getResolvedModule(\n this._program,\n importOrExportDeclaration.getSourceFile(),\n moduleSpecifier,\n mode\n );\n\n if (resolvedModule === undefined) {\n // The TS compiler API `getResolvedModule` cannot resolve ambient modules. Thus, to match API Extractor's\n // previous behavior, simply treat all ambient modules as external. This bug is tracked by\n // https://github.com/microsoft/rushstack/issues/3335.\n return true;\n }\n\n // Either something like `jquery` or `@microsoft/api-extractor`.\n const packageName: string | undefined = resolvedModule.packageId?.name;\n if (packageName !== undefined && this._bundledPackageNames.has(packageName)) {\n return false;\n }\n\n if (resolvedModule.isExternalLibraryImport === undefined) {\n // This presumably means the compiler couldn't figure out whether the module was external, but we're not\n // sure how this can happen.\n throw new InternalError(\n `Cannot determine whether the module ${JSON.stringify(moduleSpecifier)} is external\\n` +\n SourceFileLocationFormatter.formatDeclaration(importOrExportDeclaration)\n );\n }\n\n return resolvedModule.isExternalLibraryImport;\n }\n\n /**\n * Returns true if when we analyzed sourceFile, we found that it contains an \"export=\" statement that allows\n * it to behave /either/ as an ambient module /or/ as a regular importable module. In this case,\n * `AstSymbolTable._fetchAstSymbol()` will analyze its symbols even though `TypeScriptHelpers.isAmbient()`\n * returns true.\n */\n public isImportableAmbientSourceFile(sourceFile: ts.SourceFile): boolean {\n return this._importableAmbientSourceFiles.has(sourceFile);\n }\n\n private _collectAllExportsRecursive(astModuleExportInfo: IAstModuleExportInfo, astModule: AstModule): void {\n const { visitedAstModules, starExportedExternalModules, exportedLocalEntities } = astModuleExportInfo;\n if (visitedAstModules.has(astModule)) {\n return;\n }\n visitedAstModules.add(astModule);\n\n if (astModule.isExternal) {\n starExportedExternalModules.add(astModule);\n } else {\n // Fetch each of the explicit exports for this module\n if (astModule.moduleSymbol.exports) {\n astModule.moduleSymbol.exports.forEach((exportSymbol, exportName) => {\n switch (exportName) {\n case ts.InternalSymbolName.ExportStar:\n case ts.InternalSymbolName.ExportEquals:\n break;\n default:\n // Don't collect the \"export default\" symbol unless this is the entry point module\n if (exportName !== ts.InternalSymbolName.Default || visitedAstModules.size === 1) {\n if (!exportedLocalEntities.has(exportSymbol.name)) {\n const astEntity: AstEntity = this._getExportOfAstModule(exportSymbol.name, astModule);\n\n if (astEntity instanceof AstSymbol && !astEntity.isExternal) {\n this._astSymbolTable.analyze(astEntity);\n }\n\n if (astEntity instanceof AstNamespaceImport && !astEntity.astModule.isExternal) {\n this._astSymbolTable.analyze(astEntity);\n }\n\n exportedLocalEntities.set(exportSymbol.name, astEntity);\n }\n }\n break;\n }\n });\n }\n\n for (const starExportedModule of astModule.starExportedModules) {\n this._collectAllExportsRecursive(astModuleExportInfo, starExportedModule);\n }\n }\n }\n\n /**\n * For a given symbol (which was encountered in the specified sourceFile), this fetches the AstEntity that it\n * refers to. For example, if a particular interface describes the return value of a function, this API can help\n * us determine a TSDoc declaration reference for that symbol (if the symbol is exported).\n */\n public fetchReferencedAstEntity(\n symbol: ts.Symbol,\n referringModuleIsExternal: boolean\n ): AstEntity | undefined {\n // eslint-disable-next-line no-bitwise\n if ((symbol.flags & ts.SymbolFlags.FunctionScopedVariable) !== 0) {\n // If a symbol refers back to part of its own definition, don't follow that rabbit hole\n // Example:\n //\n // function f(x: number): typeof x {\n // return 123;\n // }\n return undefined;\n }\n\n let current: ts.Symbol = symbol;\n\n if (referringModuleIsExternal) {\n current = TypeScriptHelpers.followAliases(symbol, this._typeChecker);\n } else {\n for (;;) {\n // Is this symbol an import/export that we need to follow to find the real declaration?\n for (const declaration of current.declarations || []) {\n let matchedAstEntity: AstEntity | undefined;\n matchedAstEntity = this._tryMatchExportDeclaration(declaration, current);\n if (matchedAstEntity !== undefined) {\n return matchedAstEntity;\n }\n matchedAstEntity = this._tryMatchImportDeclaration(declaration, current);\n if (matchedAstEntity !== undefined) {\n return matchedAstEntity;\n }\n }\n\n // eslint-disable-next-line no-bitwise\n if (!(current.flags & ts.SymbolFlags.Alias)) {\n break;\n }\n\n const currentAlias: ts.Symbol = TypeScriptInternals.getImmediateAliasedSymbol(\n current,\n this._typeChecker\n );\n // Stop if we reach the end of the chain\n if (!currentAlias || currentAlias === current) {\n break;\n }\n\n current = currentAlias;\n }\n }\n\n // Otherwise, assume it is a normal declaration\n const astSymbol: AstSymbol | undefined = this._astSymbolTable.fetchAstSymbol({\n followedSymbol: current,\n isExternal: referringModuleIsExternal,\n includeNominalAnalysis: false,\n addIfMissing: true\n });\n\n return astSymbol;\n }\n\n public fetchReferencedAstEntityFromImportTypeNode(\n node: ts.ImportTypeNode,\n referringModuleIsExternal: boolean\n ): AstEntity | undefined {\n const externalModulePath: string | undefined = this._tryGetExternalModulePath(node);\n\n if (externalModulePath) {\n let exportName: string;\n if (node.qualifier) {\n // Example input:\n // import('api-extractor-lib1-test').Lib1GenericType<number>\n //\n // Extracted qualifier:\n // Lib1GenericType\n exportName = node.qualifier.getText().trim();\n } else {\n // Example input:\n // import('api-extractor-lib1-test')\n //\n // Extracted qualifier:\n // apiExtractorLib1Test\n\n exportName = SyntaxHelpers.makeCamelCaseIdentifier(externalModulePath);\n }\n\n return this._fetchAstImport(undefined, {\n importKind: AstImportKind.ImportType,\n exportName: exportName,\n modulePath: externalModulePath,\n isTypeOnly: false\n });\n }\n\n // Internal reference: AstSymbol\n const rightMostToken: ts.Identifier | ts.ImportTypeNode = node.qualifier\n ? node.qualifier.kind === ts.SyntaxKind.QualifiedName\n ? node.qualifier.right\n : node.qualifier\n : node;\n\n // There is no symbol property in a ImportTypeNode, obtain the associated export symbol\n const exportSymbol: ts.Symbol | undefined = this._typeChecker.getSymbolAtLocation(rightMostToken);\n if (!exportSymbol) {\n throw new InternalError(\n `Symbol not found for identifier: ${node.getText()}\\n` +\n SourceFileLocationFormatter.formatDeclaration(node)\n );\n }\n\n let followedSymbol: ts.Symbol = exportSymbol;\n for (;;) {\n const referencedAstEntity: AstEntity | undefined = this.fetchReferencedAstEntity(\n followedSymbol,\n referringModuleIsExternal\n );\n\n if (referencedAstEntity) {\n return referencedAstEntity;\n }\n\n const followedSymbolNode: ts.Node | ts.ImportTypeNode | undefined =\n followedSymbol.declarations && (followedSymbol.declarations[0] as ts.Node | undefined);\n\n if (followedSymbolNode && followedSymbolNode.kind === ts.SyntaxKind.ImportType) {\n return this.fetchReferencedAstEntityFromImportTypeNode(\n followedSymbolNode as ts.ImportTypeNode,\n referringModuleIsExternal\n );\n }\n\n // eslint-disable-next-line no-bitwise\n if (!(followedSymbol.flags & ts.SymbolFlags.Alias)) {\n break;\n }\n\n const currentAlias: ts.Symbol = this._typeChecker.getAliasedSymbol(followedSymbol);\n if (!currentAlias || currentAlias === followedSymbol) {\n break;\n }\n\n followedSymbol = currentAlias;\n }\n\n const astSymbol: AstSymbol | undefined = this._astSymbolTable.fetchAstSymbol({\n followedSymbol: followedSymbol,\n isExternal: referringModuleIsExternal,\n includeNominalAnalysis: false,\n addIfMissing: true\n });\n\n return astSymbol;\n }\n\n private _tryMatchExportDeclaration(\n declaration: ts.Declaration,\n declarationSymbol: ts.Symbol\n ): AstEntity | undefined {\n const exportDeclaration: ts.ExportDeclaration | undefined =\n TypeScriptHelpers.findFirstParent<ts.ExportDeclaration>(declaration, ts.SyntaxKind.ExportDeclaration);\n\n if (exportDeclaration) {\n let exportName: string | undefined = undefined;\n\n if (declaration.kind === ts.SyntaxKind.ExportSpecifier) {\n // EXAMPLE:\n // \"export { A } from './file-a';\"\n //\n // ExportDeclaration:\n // ExportKeyword: pre=[export] sep=[ ]\n // NamedExports:\n // FirstPunctuation: pre=[{] sep=[ ]\n // SyntaxList:\n // ExportSpecifier: <------------- declaration\n // Identifier: pre=[A] sep=[ ]\n // CloseBraceToken: pre=[}] sep=[ ]\n // FromKeyword: pre=[from] sep=[ ]\n // StringLiteral: pre=['./file-a']\n // SemicolonToken: pre=[;]\n\n // Example: \" ExportName as RenamedName\"\n const exportSpecifier: ts.ExportSpecifier = declaration as ts.ExportSpecifier;\n exportName = (exportSpecifier.propertyName || exportSpecifier.name).getText().trim();\n } else if (declaration.kind === ts.SyntaxKind.NamespaceExport) {\n // EXAMPLE:\n // \"export * as theLib from 'the-lib';\"\n //\n // ExportDeclaration:\n // ExportKeyword: pre=[export] sep=[ ]\n // NamespaceExport:\n // AsteriskToken: pre=[*] sep=[ ]\n // AsKeyword: pre=[as] sep=[ ]\n // Identifier: pre=[theLib] sep=[ ]\n // FromKeyword: pre=[from] sep=[ ]\n // StringLiteral: pre=['the-lib']\n // SemicolonToken: pre=[;]\n\n // Issue tracking this feature: https://github.com/microsoft/rushstack/issues/2780\n\n const astModule: AstModule = this._fetchSpecifierAstModule(exportDeclaration, declarationSymbol);\n return this._getAstNamespaceExport(astModule, declarationSymbol, declaration);\n } else {\n throw new InternalError(\n `Unimplemented export declaration kind: ${declaration.getText()}\\n` +\n SourceFileLocationFormatter.formatDeclaration(declaration)\n );\n }\n\n // Ignore \"export { A }\" without a module specifier\n if (exportDeclaration.moduleSpecifier) {\n const externalModulePath: string | undefined = this._tryGetExternalModulePath(exportDeclaration);\n\n if (externalModulePath !== undefined) {\n return this._fetchAstImport(declarationSymbol, {\n importKind: AstImportKind.NamedImport,\n modulePath: externalModulePath,\n exportName: exportName,\n isTypeOnly: false\n });\n }\n\n return this._getExportOfSpecifierAstModule(exportName, exportDeclaration, declarationSymbol);\n }\n }\n\n return undefined;\n }\n\n private _getAstNamespaceExport(\n astModule: AstModule,\n declarationSymbol: ts.Symbol,\n declaration: ts.Declaration\n ): AstNamespaceExport {\n const imoprtNamespace: AstNamespaceImport = this._getAstNamespaceImport(\n astModule,\n declarationSymbol,\n declaration\n );\n\n return new AstNamespaceExport({\n namespaceName: imoprtNamespace.localName,\n astModule: astModule,\n declaration,\n symbol: declarationSymbol\n });\n }\n\n private _tryMatchImportDeclaration(\n declaration: ts.Declaration,\n declarationSymbol: ts.Symbol\n ): AstEntity | undefined {\n const importDeclaration: ts.ImportDeclaration | undefined =\n TypeScriptHelpers.findFirstParent<ts.ImportDeclaration>(declaration, ts.SyntaxKind.ImportDeclaration);\n\n if (importDeclaration) {\n const externalModulePath: string | undefined = this._tryGetExternalModulePath(importDeclaration);\n\n if (declaration.kind === ts.SyntaxKind.NamespaceImport) {\n // EXAMPLE:\n // \"import * as theLib from 'the-lib';\"\n //\n // ImportDeclaration:\n // ImportKeyword: pre=[import] sep=[ ]\n // ImportClause:\n // NamespaceImport: <------------- declaration\n // AsteriskToken: pre=[*] sep=[ ]\n // AsKeyword: pre=[as] sep=[ ]\n // Identifier: pre=[theLib] sep=[ ]\n // FromKeyword: pre=[from] sep=[ ]\n // StringLiteral: pre=['the-lib']\n // SemicolonToken: pre=[;]\n\n if (externalModulePath === undefined) {\n const astModule: AstModule = this._fetchSpecifierAstModule(importDeclaration, declarationSymbol);\n return this._getAstNamespaceImport(astModule, declarationSymbol, declaration);\n }\n\n // Here importSymbol=undefined because {@inheritDoc} and such are not going to work correctly for\n // a package or source file.\n return this._fetchAstImport(undefined, {\n importKind: AstImportKind.StarImport,\n exportName: declarationSymbol.name,\n modulePath: externalModulePath,\n isTypeOnly: ExportAnalyzer._getIsTypeOnly(importDeclaration)\n });\n }\n\n if (declaration.kind === ts.SyntaxKind.ImportSpecifier) {\n // EXAMPLE:\n // \"import { A, B } from 'the-lib';\"\n //\n // ImportDeclaration:\n // ImportKeyword: pre=[import] sep=[ ]\n // ImportClause:\n // NamedImports:\n // FirstPunctuation: pre=[{] sep=[ ]\n // SyntaxList:\n // ImportSpecifier: <------------- declaration\n // Identifier: pre=[A]\n // CommaToken: pre=[,] sep=[ ]\n // ImportSpecifier:\n // Identifier: pre=[B] sep=[ ]\n // CloseBraceToken: pre=[}] sep=[ ]\n // FromKeyword: pre=[from] sep=[ ]\n // StringLiteral: pre=['the-lib']\n // SemicolonToken: pre=[;]\n\n // Example: \" ExportName as RenamedName\"\n const importSpecifier: ts.ImportSpecifier = declaration as ts.ImportSpecifier;\n const exportName: string = (importSpecifier.propertyName || importSpecifier.name).getText().trim();\n\n if (externalModulePath !== undefined) {\n return this._fetchAstImport(declarationSymbol, {\n importKind: AstImportKind.NamedImport,\n modulePath: externalModulePath,\n exportName: exportName,\n isTypeOnly: ExportAnalyzer._getIsTypeOnly(importDeclaration)\n });\n }\n\n return this._getExportOfSpecifierAstModule(exportName, importDeclaration, declarationSymbol);\n } else if (declaration.kind === ts.SyntaxKind.ImportClause) {\n // EXAMPLE:\n // \"import A, { B } from './A';\"\n //\n // ImportDeclaration:\n // ImportKeyword: pre=[import] sep=[ ]\n // ImportClause: <------------- declaration (referring to A)\n // Identifier: pre=[A]\n // CommaToken: pre=[,] sep=[ ]\n // NamedImports:\n // FirstPunctuation: pre=[{] sep=[ ]\n // SyntaxList:\n // ImportSpecifier:\n // Identifier: pre=[B] sep=[ ]\n // CloseBraceToken: pre=[}] sep=[ ]\n // FromKeyword: pre=[from] sep=[ ]\n // StringLiteral: pre=['./A']\n // SemicolonToken: pre=[;]\n\n const importClause: ts.ImportClause = declaration as ts.ImportClause;\n const exportName: string = importClause.name\n ? importClause.name.getText().trim()\n : ts.InternalSymbolName.Default;\n\n if (externalModulePath !== undefined) {\n return this._fetchAstImport(declarationSymbol, {\n importKind: AstImportKind.DefaultImport,\n modulePath: externalModulePath,\n exportName,\n isTypeOnly: ExportAnalyzer._getIsTypeOnly(importDeclaration)\n });\n }\n\n return this._getExportOfSpecifierAstModule(\n ts.InternalSymbolName.Default,\n importDeclaration,\n declarationSymbol\n );\n } else {\n throw new InternalError(\n `Unimplemented import declaration kind: ${declaration.getText()}\\n` +\n SourceFileLocationFormatter.formatDeclaration(declaration)\n );\n }\n }\n\n if (ts.isImportEqualsDeclaration(declaration)) {\n // EXAMPLE:\n // import myLib = require('my-lib');\n //\n // ImportEqualsDeclaration:\n // ImportKeyword: pre=[import] sep=[ ]\n // Identifier: pre=[myLib] sep=[ ]\n // FirstAssignment: pre=[=] sep=[ ]\n // ExternalModuleReference:\n // RequireKeyword: pre=[require]\n // OpenParenToken: pre=[(]\n // StringLiteral: pre=['my-lib']\n // CloseParenToken: pre=[)]\n // SemicolonToken: pre=[;]\n if (ts.isExternalModuleReference(declaration.moduleReference)) {\n if (ts.isStringLiteralLike(declaration.moduleReference.expression)) {\n const variableName: string = TypeScriptInternals.getTextOfIdentifierOrLiteral(declaration.name);\n const externalModuleName: string = TypeScriptInternals.getTextOfIdentifierOrLiteral(\n declaration.moduleReference.expression\n );\n\n return this._fetchAstImport(declarationSymbol, {\n importKind: AstImportKind.EqualsImport,\n modulePath: externalModuleName,\n exportName: variableName,\n isTypeOnly: false\n });\n }\n }\n }\n\n return undefined;\n }\n\n private _getAstNamespaceImport(\n astModule: AstModule,\n declarationSymbol: ts.Symbol,\n declaration: ts.Declaration\n ): AstNamespaceImport {\n let namespaceImport: AstNamespaceImport | undefined = this._astNamespaceImportByModule.get(astModule);\n if (namespaceImport === undefined) {\n namespaceImport = new AstNamespaceImport({\n namespaceName: declarationSymbol.name,\n astModule: astModule,\n declaration: declaration,\n symbol: declarationSymbol\n });\n this._astNamespaceImportByModule.set(astModule, namespaceImport);\n }\n\n return namespaceImport;\n }\n\n private static _getIsTypeOnly(importDeclaration: ts.ImportDeclaration): boolean {\n if (importDeclaration.importClause) {\n return !!importDeclaration.importClause.isTypeOnly;\n }\n return false;\n }\n\n private _getExportOfSpecifierAstModule(\n exportName: string,\n importOrExportDeclaration: ts.ImportDeclaration | ts.ExportDeclaration,\n exportSymbol: ts.Symbol\n ): AstEntity {\n const specifierAstModule: AstModule = this._fetchSpecifierAstModule(\n importOrExportDeclaration,\n exportSymbol\n );\n const astEntity: AstEntity = this._getExportOfAstModule(exportName, specifierAstModule);\n return astEntity;\n }\n\n private _getExportOfAstModule(exportName: string, astModule: AstModule): AstEntity {\n const visitedAstModules: Set<AstModule> = new Set<AstModule>();\n const astEntity: AstEntity | undefined = this._tryGetExportOfAstModule(\n exportName,\n astModule,\n visitedAstModules\n );\n if (astEntity === undefined) {\n throw new InternalError(\n `Unable to analyze the export ${JSON.stringify(exportName)} in\\n` + astModule.sourceFile.fileName\n );\n }\n return astEntity;\n }\n\n /**\n * Implementation of {@link AstSymbolTable.tryGetExportOfAstModule}.\n */\n public tryGetExportOfAstModule(exportName: string, astModule: AstModule): AstEntity | undefined {\n const visitedAstModules: Set<AstModule> = new Set<AstModule>();\n return this._tryGetExportOfAstModule(exportName, astModule, visitedAstModules);\n }\n\n private _tryGetExportOfAstModule(\n exportName: string,\n astModule: AstModule,\n visitedAstModules: Set<AstModule>\n ): AstEntity | undefined {\n if (visitedAstModules.has(astModule)) {\n return undefined;\n }\n visitedAstModules.add(astModule);\n\n let astEntity: AstEntity | undefined = astModule.cachedExportedEntities.get(exportName);\n if (astEntity !== undefined) {\n return astEntity;\n }\n\n // Try the explicit exports\n const escapedExportName: ts.__String = ts.escapeLeadingUnderscores(exportName);\n if (astModule.moduleSymbol.exports) {\n const exportSymbol: ts.Symbol | undefined = astModule.moduleSymbol.exports.get(escapedExportName);\n if (exportSymbol) {\n astEntity = this.fetchReferencedAstEntity(exportSymbol, astModule.isExternal);\n\n if (astEntity !== undefined) {\n astModule.cachedExportedEntities.set(exportName, astEntity); // cache for next time\n return astEntity;\n }\n }\n }\n\n // Try each of the star imports\n for (const starExportedModule of astModule.starExportedModules) {\n astEntity = this._tryGetExportOfAstModule(exportName, starExportedModule, visitedAstModules);\n\n if (astEntity !== undefined) {\n if (starExportedModule.externalModulePath !== undefined) {\n // This entity was obtained from an external module, so return an AstImport instead\n const astSymbol: AstSymbol = astEntity as AstSymbol;\n return this._fetchAstImport(astSymbol.followedSymbol, {\n importKind: AstImportKind.NamedImport,\n modulePath: starExportedModule.externalModulePath,\n exportName: exportName,\n isTypeOnly: false\n });\n }\n\n return astEntity;\n }\n }\n\n return undefined;\n }\n\n private _tryGetExternalModulePath(\n importOrExportDeclaration: ts.ImportDeclaration | ts.ExportDeclaration | ts.ImportTypeNode\n ): string | undefined {\n const moduleSpecifier: string = this._getModuleSpecifier(importOrExportDeclaration);\n if (this._isExternalModulePath(importOrExportDeclaration, moduleSpecifier)) {\n return moduleSpecifier;\n }\n\n return undefined;\n }\n\n /**\n * Given an ImportDeclaration of the form `export { X } from \"___\";`, this interprets the module specifier (`\"___\"`)\n * and fetches the corresponding AstModule object.\n */\n private _fetchSpecifierAstModule(\n importOrExportDeclaration: ts.ImportDeclaration | ts.ExportDeclaration,\n exportSymbol: ts.Symbol\n ): AstModule {\n const moduleSpecifier: string = this._getModuleSpecifier(importOrExportDeclaration);\n const mode: ts.ModuleKind.CommonJS | ts.ModuleKind.ESNext | undefined =\n importOrExportDeclaration.moduleSpecifier &&\n ts.isStringLiteralLike(importOrExportDeclaration.moduleSpecifier)\n ? TypeScriptInternals.getModeForUsageLocation(\n importOrExportDeclaration.getSourceFile(),\n importOrExportDeclaration.moduleSpecifier,\n this._program.getCompilerOptions()\n )\n : undefined;\n const resolvedModule: ts.ResolvedModuleFull | undefined = TypeScriptInternals.getResolvedModule(\n this._program,\n importOrExportDeclaration.getSourceFile(),\n moduleSpecifier,\n mode\n );\n\n if (resolvedModule === undefined) {\n // Encountered in https://github.com/microsoft/rushstack/issues/1914.\n //\n // It's also possible for this to occur with ambient modules. However, in practice this doesn't happen\n // as API Extractor treats all ambient modules as external per the logic in `_isExternalModulePath`, and\n // thus this code path is never reached for ambient modules.\n throw new InternalError(\n `getResolvedModule() could not resolve module name ${JSON.stringify(moduleSpecifier)}\\n` +\n SourceFileLocationFormatter.formatDeclaration(importOrExportDeclaration)\n );\n }\n\n // Map the filename back to the corresponding SourceFile. This circuitous approach is needed because\n // we have no way to access the compiler's internal resolveExternalModuleName() function\n const moduleSourceFile: ts.SourceFile | undefined = this._program.getSourceFile(\n resolvedModule.resolvedFileName\n );\n if (!moduleSourceFile) {\n // This should not happen, since getResolvedModule() specifically looks up names that the compiler\n // found in export declarations for this source file\n throw new InternalError(\n `getSourceFile() failed to locate ${JSON.stringify(resolvedModule.resolvedFileName)}\\n` +\n SourceFileLocationFormatter.formatDeclaration(importOrExportDeclaration)\n );\n }\n\n const isExternal: boolean = this._isExternalModulePath(importOrExportDeclaration, moduleSpecifier);\n const moduleReference: IAstModuleReference = {\n moduleSpecifier: moduleSpecifier,\n moduleSpecifierSymbol: exportSymbol\n };\n const specifierAstModule: AstModule = this.fetchAstModuleFromSourceFile(\n moduleSourceFile,\n moduleReference,\n isExternal\n );\n\n return specifierAstModule;\n }\n\n private _fetchAstImport(importSymbol: ts.Symbol | undefined, options: IAstImportOptions): AstImport {\n const key: string = AstImport.getKey(options);\n\n let astImport: AstImport | undefined = this._astImportsByKey.get(key);\n\n if (!astImport) {\n astImport = new AstImport(options);\n this._astImportsByKey.set(key, astImport);\n\n if (importSymbol) {\n const followedSymbol: ts.Symbol = TypeScriptHelpers.followAliases(importSymbol, this._typeChecker);\n\n astImport.astSymbol = this._astSymbolTable.fetchAstSymbol({\n followedSymbol: followedSymbol,\n isExternal: true,\n includeNominalAnalysis: false,\n addIfMissing: true\n });\n }\n } else {\n // If we encounter at least one import that does not use the type-only form,\n // then the .d.ts rollup will NOT use \"import type\".\n if (!options.isTypeOnly) {\n astImport.isTypeOnlyEverywhere = false;\n }\n }\n\n return astImport;\n }\n\n private _getModuleSpecifier(\n importOrExportDeclaration: ts.ImportDeclaration | ts.ExportDeclaration | ts.ImportTypeNode\n ): string {\n // The name of the module, which could be like \"./SomeLocalFile' or like 'external-package/entry/point'\n const moduleSpecifier: string | undefined =\n TypeScriptHelpers.getModuleSpecifier(importOrExportDeclaration);\n\n if (!moduleSpecifier) {\n throw new InternalError(\n 'Unable to parse module specifier\\n' +\n SourceFileLocationFormatter.formatDeclaration(importOrExportDeclaration)\n );\n }\n\n return moduleSpecifier;\n }\n}\n"]}
|
|
@@ -17,13 +17,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
17
17
|
}) : function(o, v) {
|
|
18
18
|
o["default"] = v;
|
|
19
19
|
});
|
|
20
|
-
var __importStar = (this && this.__importStar) || function (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
20
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
21
|
+
var ownKeys = function(o) {
|
|
22
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
23
|
+
var ar = [];
|
|
24
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
25
|
+
return ar;
|
|
26
|
+
};
|
|
27
|
+
return ownKeys(o);
|
|
28
|
+
};
|
|
29
|
+
return function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
})();
|
|
27
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
38
|
exports.SourceFileLocationFormatter = void 0;
|
|
29
39
|
const path = __importStar(require("path"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SourceFileLocationFormatter.js","sourceRoot":"","sources":["../../src/analyzer/SourceFileLocationFormatter.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D
|
|
1
|
+
{"version":3,"file":"SourceFileLocationFormatter.js","sourceRoot":"","sources":["../../src/analyzer/SourceFileLocationFormatter.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAG3D,2CAA6B;AAC7B,oEAA0D;AAQ1D,MAAa,2BAA2B;IACtC;;;OAGG;IACI,MAAM,CAAC,iBAAiB,CAAC,IAAa,EAAE,wBAAiC;QAC9E,MAAM,UAAU,GAAkB,IAAI,CAAC,aAAa,EAAE,CAAC;QACvD,MAAM,gBAAgB,GAAwB,UAAU,CAAC,6BAA6B,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QAExG,OAAO,2BAA2B,CAAC,UAAU,CAAC,UAAU,CAAC,QAAQ,EAAE;YACjE,cAAc,EAAE,gBAAgB,CAAC,IAAI,GAAG,CAAC;YACzC,gBAAgB,EAAE,gBAAgB,CAAC,SAAS,GAAG,CAAC;YAChD,wBAAwB;SACzB,CAAC,CAAC;IACL,CAAC;IAEM,MAAM,CAAC,UAAU,CAAC,cAAsB,EAAE,OAA0C;QACzF,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,GAAG,EAAE,CAAC;QACf,CAAC;QAED,IAAI,MAAM,GAAW,EAAE,CAAC;QAExB,yDAAyD;QACzD,IAAI,YAAY,GAAW,cAAc,CAAC;QAE1C,IAAI,OAAO,CAAC,wBAAwB,EAAE,CAAC;YACrC,4DAA4D;YAC5D,IAAI,wBAAI,CAAC,cAAc,CAAC,cAAc,EAAE,OAAO,CAAC,wBAAwB,CAAC,EAAE,CAAC;gBAC1E,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,wBAAwB,EAAE,cAAc,CAAC,CAAC;YACjF,CAAC;QACH,CAAC;QAED,kCAAkC;QAClC,YAAY,GAAG,wBAAI,CAAC,UAAU,CAAC,YAAY,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;QACxD,MAAM,IAAI,YAAY,CAAC;QAEvB,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;YAC3B,MAAM,IAAI,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;YAEvC,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;gBAC7B,MAAM,IAAI,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;YAC3C,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA/CD,kEA+CC","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 type * as ts from 'typescript';\nimport * as path from 'path';\nimport { Path, Text } from '@rushstack/node-core-library';\n\nexport interface ISourceFileLocationFormatOptions {\n sourceFileLine?: number;\n sourceFileColumn?: number;\n workingPackageFolderPath?: string;\n}\n\nexport class SourceFileLocationFormatter {\n /**\n * Returns a string such as this, based on the context information in the provided node:\n * \"[C:\\Folder\\File.ts#123]\"\n */\n public static formatDeclaration(node: ts.Node, workingPackageFolderPath?: string): string {\n const sourceFile: ts.SourceFile = node.getSourceFile();\n const lineAndCharacter: ts.LineAndCharacter = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n\n return SourceFileLocationFormatter.formatPath(sourceFile.fileName, {\n sourceFileLine: lineAndCharacter.line + 1,\n sourceFileColumn: lineAndCharacter.character + 1,\n workingPackageFolderPath\n });\n }\n\n public static formatPath(sourceFilePath: string, options?: ISourceFileLocationFormatOptions): string {\n if (!options) {\n options = {};\n }\n\n let result: string = '';\n\n // Make the path relative to the workingPackageFolderPath\n let scrubbedPath: string = sourceFilePath;\n\n if (options.workingPackageFolderPath) {\n // If it's under the working folder, make it a relative path\n if (Path.isUnderOrEqual(sourceFilePath, options.workingPackageFolderPath)) {\n scrubbedPath = path.relative(options.workingPackageFolderPath, sourceFilePath);\n }\n }\n\n // Convert it to a Unix-style path\n scrubbedPath = Text.replaceAll(scrubbedPath, '\\\\', '/');\n result += scrubbedPath;\n\n if (options.sourceFileLine) {\n result += `:${options.sourceFileLine}`;\n\n if (options.sourceFileColumn) {\n result += `:${options.sourceFileColumn}`;\n }\n }\n\n return result;\n }\n}\n"]}
|
package/lib/analyzer/Span.js
CHANGED
|
@@ -17,13 +17,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
17
17
|
}) : function(o, v) {
|
|
18
18
|
o["default"] = v;
|
|
19
19
|
});
|
|
20
|
-
var __importStar = (this && this.__importStar) || function (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
20
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
21
|
+
var ownKeys = function(o) {
|
|
22
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
23
|
+
var ar = [];
|
|
24
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
25
|
+
return ar;
|
|
26
|
+
};
|
|
27
|
+
return ownKeys(o);
|
|
28
|
+
};
|
|
29
|
+
return function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
})();
|
|
27
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
38
|
exports.Span = exports.SpanModification = exports.IndentDocCommentScope = void 0;
|
|
29
39
|
const ts = __importStar(require("typescript"));
|
package/lib/analyzer/Span.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Span.js","sourceRoot":"","sources":["../../src/analyzer/Span.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,+CAAiC;AACjC,oEAAyE;AAEzE,iEAA8D;AAQ9D,IAAK,qBAiBJ;AAjBD,WAAK,qBAAqB;IACxB;;OAEG;IACH,yEAAY,CAAA;IACZ;;OAEG;IACH,mGAAyB,CAAA;IACzB;;OAEG;IACH,qGAA0B,CAAA;IAC1B;;OAEG;IACH,iEAAQ,CAAA;AACV,CAAC,EAjBI,qBAAqB,KAArB,qBAAqB,QAiBzB;AAED;;GAEG;AACH,IAAY,qBAeX;AAfD,WAAY,qBAAqB;IAC/B;;OAEG;IACH,iEAAQ,CAAA;IAER;;OAEG;IACH,6EAAc,CAAA;IAEd;;OAEG;IACH,uFAAmB,CAAA;AACrB,CAAC,EAfW,qBAAqB,qCAArB,qBAAqB,QAehC;AAED;;GAEG;AACH,MAAa,gBAAgB;IA4C3B,YAAmB,IAAU;QA3C7B;;;;WAIG;QACI,iBAAY,GAAY,KAAK,CAAC;QAErC;;WAEG;QACI,uBAAkB,GAAY,KAAK,CAAC;QAE3C;;;;WAIG;QACI,iBAAY,GAAY,KAAK,CAAC;QAOrC;;;;;;;;;;;;WAYG;QACI,qBAAgB,GAA0B,qBAAqB,CAAC,IAAI,CAAC;QAO1E,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM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sBAAsB,EAAE,CAAC;YACnF,IAAI,KAAK,GAAW,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC7C,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;gBACf,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC;gBACrB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;gBACrD,UAAU,GAAG,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;gBACzC,OAAO,CAAC,qBAAqB,GAAG,qBAAqB,CAAC,IAAI,CAAC;gBAE3D,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;YAClC,CAAC;QACH,CAAC;QAED,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACnC,CAAC;IAEO,WAAW,CAAC,IAAY;QAC9B,OAAO,wBAAI,CAAC,oBAAoB,CAAC,wBAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;IAChE,CAAC;IAEO,aAAa,CAAC,UAAkB,EAAE,QAAgB;QACxD,IAAI,UAAU,KAAK,QAAQ,EAAE,CAAC;YAC5B,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IACxE,CAAC;CACF;AArdD,oBAqdC","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 ts from 'typescript';\nimport { InternalError, Sort, Text } from '@rushstack/node-core-library';\n\nimport { IndentedWriter } from '../generators/IndentedWriter';\n\ninterface IWriteModifiedTextOptions {\n writer: IndentedWriter;\n separatorOverride: string | undefined;\n indentDocCommentState: IndentDocCommentState;\n}\n\nenum IndentDocCommentState {\n /**\n * `indentDocComment` was not requested for this subtree.\n */\n Inactive = 0,\n /**\n * `indentDocComment` was requested and we are looking for the opening `/` `*`\n */\n AwaitingOpenDelimiter = 1,\n /**\n * `indentDocComment` was requested and we are looking for the closing `*` `/`\n */\n AwaitingCloseDelimiter = 2,\n /**\n * `indentDocComment` was requested and we have finished indenting the comment.\n */\n Done = 3\n}\n\n/**\n * Choices for SpanModification.indentDocComment.\n */\nexport enum IndentDocCommentScope {\n /**\n * Do not detect and indent comments.\n */\n None = 0,\n\n /**\n * Look for one doc comment in the {@link Span.prefix} text only.\n */\n PrefixOnly = 1,\n\n /**\n * Look for one doc comment potentially distributed across the Span and its children.\n */\n SpanAndChildren = 2\n}\n\n/**\n * Specifies various transformations that will be performed by Span.getModifiedText().\n */\nexport class SpanModification {\n /**\n * If true, all of the child spans will be omitted from the Span.getModifiedText() output.\n * @remarks\n * Also, the modify() operation will not recurse into these spans.\n */\n public omitChildren: boolean = false;\n\n /**\n * If true, then the Span.separator will be removed from the Span.getModifiedText() output.\n */\n public omitSeparatorAfter: boolean = false;\n\n /**\n * If true, then Span.getModifiedText() will sort the immediate children according to their Span.sortKey\n * property. The separators will also be fixed up to ensure correct indentation. If the Span.sortKey is undefined\n * for some items, those items will not be moved, i.e. their array indexes will be unchanged.\n */\n public sortChildren: boolean = false;\n\n /**\n * Used if the parent span has Span.sortChildren=true.\n */\n public sortKey: string | undefined;\n\n /**\n * Optionally configures getModifiedText() to search for a \"/*\" doc comment and indent it.\n * At most one comment is detected.\n *\n * @remarks\n * The indentation can be applied to the `Span.modifier.prefix` only, or it can be applied to the\n * full subtree of nodes (as needed for `ts.SyntaxKind.JSDocComment` trees). However the enabled\n * scopes must not overlap.\n *\n * This feature is enabled selectively because (1) we do not want to accidentally match `/*` appearing\n * in a string literal or other expression that is not a comment, and (2) parsing comments is relatively\n * expensive.\n */\n public indentDocComment: IndentDocCommentScope = IndentDocCommentScope.None;\n\n private readonly _span: Span;\n private _prefix: string | undefined;\n private _suffix: string | undefined;\n\n public constructor(span: Span) {\n this._span = span;\n this.reset();\n }\n\n /**\n * Allows the Span.prefix text to be changed.\n */\n public get prefix(): string {\n return this._prefix !== undefined ? this._prefix : this._span.prefix;\n }\n\n public set prefix(value: string) {\n this._prefix = value;\n }\n\n /**\n * Allows the Span.suffix text to be changed.\n */\n public get suffix(): string {\n return this._suffix !== undefined ? this._suffix : this._span.suffix;\n }\n\n public set suffix(value: string) {\n this._suffix = value;\n }\n\n /**\n * Reverts any modifications made to this object.\n */\n public reset(): void {\n this.omitChildren = false;\n this.omitSeparatorAfter = false;\n this.sortChildren = false;\n this.sortKey = undefined;\n this._prefix = undefined;\n this._suffix = undefined;\n if (this._span.kind === ts.SyntaxKind.JSDocComment) {\n this.indentDocComment = IndentDocCommentScope.SpanAndChildren;\n }\n }\n\n /**\n * Effectively deletes the Span from the tree, by skipping its children, skipping its separator,\n * and setting its prefix/suffix to the empty string.\n */\n public skipAll(): void {\n this.prefix = '';\n this.suffix = '';\n this.omitChildren = true;\n this.omitSeparatorAfter = true;\n }\n}\n\n/**\n * The Span class provides a simple way to rewrite TypeScript source files\n * based on simple syntax transformations, i.e. without having to process deeper aspects\n * of the underlying grammar. An example transformation might be deleting JSDoc comments\n * from a source file.\n *\n * @remarks\n * TypeScript's abstract syntax tree (AST) is represented using Node objects.\n * The Node text ignores its surrounding whitespace, and does not have an ordering guarantee.\n * For example, a JSDocComment node can be a child of a FunctionDeclaration node, even though\n * the actual comment precedes the function in the input stream.\n *\n * The Span class is a wrapper for a single Node, that provides access to every character\n * in the input stream, such that Span.getText() will exactly reproduce the corresponding\n * full Node.getText() output.\n *\n * A Span is comprised of these parts, which appear in sequential order:\n * - A prefix\n * - A collection of child spans\n * - A suffix\n * - A separator (e.g. whitespace between this span and the next item in the tree)\n *\n * These parts can be modified via Span.modification. The modification is applied by\n * calling Span.getModifiedText().\n */\nexport class Span {\n public readonly node: ts.Node;\n\n // To improve performance, substrings are not allocated until actually needed\n public readonly startIndex: number;\n public readonly endIndex: number;\n\n public readonly children: Span[];\n\n public readonly modification: SpanModification;\n\n private _parent: Span | undefined;\n private _previousSibling: Span | undefined;\n private _nextSibling: Span | undefined;\n\n private _separatorStartIndex: number;\n private _separatorEndIndex: number;\n\n public constructor(node: ts.Node) {\n this.node = node;\n this.startIndex = node.kind === ts.SyntaxKind.SourceFile ? node.getFullStart() : node.getStart();\n this.endIndex = node.end;\n this._separatorStartIndex = 0;\n this._separatorEndIndex = 0;\n this.children = [];\n this.modification = new SpanModification(this);\n\n let previousChildSpan: Span | undefined = undefined;\n\n for (const childNode of this.node.getChildren() || []) {\n const childSpan: Span = new Span(childNode);\n childSpan._parent = this;\n childSpan._previousSibling = previousChildSpan;\n\n if (previousChildSpan) {\n previousChildSpan._nextSibling = childSpan;\n }\n\n this.children.push(childSpan);\n\n // Normalize the bounds so that a child is never outside its parent\n if (childSpan.startIndex < this.startIndex) {\n this.startIndex = childSpan.startIndex;\n }\n\n if (childSpan.endIndex > this.endIndex) {\n // This has never been observed empirically, but here's how we would handle it\n this.endIndex = childSpan.endIndex;\n throw new InternalError('Unexpected AST case');\n }\n\n if (previousChildSpan) {\n if (previousChildSpan.endIndex < childSpan.startIndex) {\n // There is some leftover text after previous child -- assign it as the separator for\n // the preceding span. If the preceding span has no suffix, then assign it to the\n // deepest preceding span with no suffix. This heuristic simplifies the most\n // common transformations, and otherwise it can be fished out using getLastInnerSeparator().\n let separatorRecipient: Span = previousChildSpan;\n while (separatorRecipient.children.length > 0) {\n const lastChild: Span = separatorRecipient.children[separatorRecipient.children.length - 1];\n if (lastChild.endIndex !== separatorRecipient.endIndex) {\n // There is a suffix, so we cannot push the separator any further down, or else\n // it would get printed before this suffix.\n break;\n }\n separatorRecipient = lastChild;\n }\n separatorRecipient._separatorStartIndex = previousChildSpan.endIndex;\n separatorRecipient._separatorEndIndex = childSpan.startIndex;\n }\n }\n\n previousChildSpan = childSpan;\n }\n }\n\n public get kind(): ts.SyntaxKind {\n return this.node.kind;\n }\n\n /**\n * The parent Span, if any.\n * NOTE: This will be undefined for a root Span, even though the corresponding Node\n * may have a parent in the AST.\n */\n public get parent(): Span | undefined {\n return this._parent;\n }\n\n /**\n * If the current object is this.parent.children[i], then previousSibling corresponds\n * to this.parent.children[i-1] if it exists.\n * NOTE: This will be undefined for a root Span, even though the corresponding Node\n * may have a previous sibling in the AST.\n */\n public get previousSibling(): Span | undefined {\n return this._previousSibling;\n }\n\n /**\n * If the current object is this.parent.children[i], then previousSibling corresponds\n * to this.parent.children[i+1] if it exists.\n * NOTE: This will be undefined for a root Span, even though the corresponding Node\n * may have a previous sibling in the AST.\n */\n public get nextSibling(): Span | undefined {\n return this._nextSibling;\n }\n\n /**\n * The text associated with the underlying Node, up to its first child.\n */\n public get prefix(): string {\n if (this.children.length) {\n // Everything up to the first child\n return this._getSubstring(this.startIndex, this.children[0].startIndex);\n } else {\n return this._getSubstring(this.startIndex, this.endIndex);\n }\n }\n\n /**\n * The text associated with the underlying Node, after its last child.\n * If there are no children, this is always an empty string.\n */\n public get suffix(): string {\n if (this.children.length) {\n // Everything after the last child\n return this._getSubstring(this.children[this.children.length - 1].endIndex, this.endIndex);\n } else {\n return '';\n }\n }\n\n /**\n * Whitespace that appeared after this node, and before the \"next\" node in the tree.\n * Here we mean \"next\" according to an inorder traversal, not necessarily a sibling.\n */\n public get separator(): string {\n return this._getSubstring(this._separatorStartIndex, this._separatorEndIndex);\n }\n\n /**\n * Returns the separator of this Span, or else recursively calls getLastInnerSeparator()\n * on the last child.\n */\n public getLastInnerSeparator(): string {\n if (this.separator) {\n return this.separator;\n }\n if (this.children.length > 0) {\n return this.children[this.children.length - 1].getLastInnerSeparator();\n }\n return '';\n }\n\n /**\n * Returns the first parent node with the specified SyntaxKind, or undefined if there is no match.\n */\n public findFirstParent(kindToMatch: ts.SyntaxKind): Span | undefined {\n let current: Span | undefined = this;\n\n while (current) {\n if (current.kind === kindToMatch) {\n return current;\n }\n current = current.parent;\n }\n\n return undefined;\n }\n\n /**\n * Recursively invokes the callback on this Span and all its children. The callback\n * can make changes to Span.modification for each node.\n */\n public forEach(callback: (span: Span) => void): void {\n callback(this);\n for (const child of this.children) {\n child.forEach(callback);\n }\n }\n\n /**\n * Returns the original unmodified text represented by this Span.\n */\n public getText(): string {\n let result: string = '';\n result += this.prefix;\n\n for (const child of this.children) {\n result += child.getText();\n }\n\n result += this.suffix;\n result += this.separator;\n\n return result;\n }\n\n /**\n * Returns the text represented by this Span, after applying all requested modifications.\n */\n public getModifiedText(): string {\n const writer: IndentedWriter = new IndentedWriter();\n writer.trimLeadingSpaces = true;\n\n this._writeModifiedText({\n writer: writer,\n separatorOverride: undefined,\n indentDocCommentState: IndentDocCommentState.Inactive\n });\n\n return writer.getText();\n }\n\n public writeModifiedText(output: IndentedWriter): void {\n this._writeModifiedText({\n writer: output,\n separatorOverride: undefined,\n indentDocCommentState: IndentDocCommentState.Inactive\n });\n }\n\n /**\n * Returns a diagnostic dump of the tree, showing the prefix/suffix/separator for\n * each node.\n */\n public getDump(indent: string = ''): string {\n let result: string = indent + ts.SyntaxKind[this.node.kind] + ': ';\n\n if (this.prefix) {\n result += ' pre=[' + this._getTrimmed(this.prefix) + ']';\n }\n if (this.suffix) {\n result += ' suf=[' + this._getTrimmed(this.suffix) + ']';\n }\n if (this.separator) {\n result += ' sep=[' + this._getTrimmed(this.separator) + ']';\n }\n result += '\\n';\n\n for (const child of this.children) {\n result += child.getDump(indent + ' ');\n }\n\n return result;\n }\n\n /**\n * Returns a diagnostic dump of the tree, showing the SpanModification settings for each nodde.\n */\n public getModifiedDump(indent: string = ''): string {\n let result: string = indent + ts.SyntaxKind[this.node.kind] + ': ';\n\n if (this.prefix) {\n result += ' pre=[' + this._getTrimmed(this.modification.prefix) + ']';\n }\n if (this.suffix) {\n result += ' suf=[' + this._getTrimmed(this.modification.suffix) + ']';\n }\n if (this.separator) {\n result += ' sep=[' + this._getTrimmed(this.separator) + ']';\n }\n if (this.modification.indentDocComment !== IndentDocCommentScope.None) {\n result += ' indentDocComment=' + IndentDocCommentScope[this.modification.indentDocComment];\n }\n if (this.modification.omitChildren) {\n result += ' omitChildren';\n }\n if (this.modification.omitSeparatorAfter) {\n result += ' omitSeparatorAfter';\n }\n if (this.modification.sortChildren) {\n result += ' sortChildren';\n }\n if (this.modification.sortKey !== undefined) {\n result += ` sortKey=\"${this.modification.sortKey}\"`;\n }\n result += '\\n';\n\n if (!this.modification.omitChildren) {\n for (const child of this.children) {\n result += child.getModifiedDump(indent + ' ');\n }\n } else {\n result += `${indent} (${this.children.length} children)\\n`;\n }\n\n return result;\n }\n\n /**\n * Recursive implementation of `getModifiedText()` and `writeModifiedText()`.\n */\n private _writeModifiedText(options: IWriteModifiedTextOptions): void {\n // Apply indentation based on \"{\" and \"}\"\n if (this.prefix === '{') {\n options.writer.increaseIndent();\n } else if (this.prefix === '}') {\n options.writer.decreaseIndent();\n }\n\n if (this.modification.indentDocComment !== IndentDocCommentScope.None) {\n this._beginIndentDocComment(options);\n }\n\n this._write(this.modification.prefix, options);\n\n if (this.modification.indentDocComment === IndentDocCommentScope.PrefixOnly) {\n this._endIndentDocComment(options);\n }\n\n let sortedSubset: Span[] | undefined;\n\n if (!this.modification.omitChildren) {\n if (this.modification.sortChildren) {\n // We will only sort the items with a sortKey\n const filtered: Span[] = this.children.filter((x) => x.modification.sortKey !== undefined);\n\n // Is there at least one of them?\n if (filtered.length > 1) {\n sortedSubset = filtered;\n }\n }\n }\n\n if (sortedSubset) {\n // This is the complicated special case that sorts an arbitrary subset of the child nodes,\n // preserving the surrounding nodes.\n\n const sortedSubsetCount: number = sortedSubset.length;\n // Remember the separator for the first and last ones\n const firstSeparator: string = sortedSubset[0].getLastInnerSeparator();\n const lastSeparator: string = sortedSubset[sortedSubsetCount - 1].getLastInnerSeparator();\n\n Sort.sortBy(sortedSubset, (x) => x.modification.sortKey);\n\n const childOptions: IWriteModifiedTextOptions = { ...options };\n\n let sortedSubsetIndex: number = 0;\n for (let index: number = 0; index < this.children.length; ++index) {\n let current: Span;\n\n // Is this an item that we sorted?\n if (this.children[index].modification.sortKey === undefined) {\n // No, take the next item from the original array\n current = this.children[index];\n childOptions.separatorOverride = undefined;\n } else {\n // Yes, take the next item from the sortedSubset\n current = sortedSubset[sortedSubsetIndex++];\n\n if (sortedSubsetIndex < sortedSubsetCount) {\n childOptions.separatorOverride = firstSeparator;\n } else {\n childOptions.separatorOverride = lastSeparator;\n }\n }\n\n current._writeModifiedText(childOptions);\n }\n } else {\n // This is the normal case that does not need to sort children\n const childrenLength: number = this.children.length;\n\n if (!this.modification.omitChildren) {\n if (options.separatorOverride !== undefined) {\n // Special case where the separatorOverride is passed down to the \"last inner separator\" span\n for (let i: number = 0; i < childrenLength; ++i) {\n const child: Span = this.children[i];\n\n if (\n // Only the last child inherits the separatorOverride, because only it can contain\n // the \"last inner separator\" span\n i < childrenLength - 1 ||\n // If this.separator is specified, then we will write separatorOverride below, so don't pass it along\n this.separator\n ) {\n const childOptions: IWriteModifiedTextOptions = { ...options };\n childOptions.separatorOverride = undefined;\n child._writeModifiedText(childOptions);\n } else {\n child._writeModifiedText(options);\n }\n }\n } else {\n // The normal simple case\n for (const child of this.children) {\n child._writeModifiedText(options);\n }\n }\n }\n\n this._write(this.modification.suffix, options);\n\n if (options.separatorOverride !== undefined) {\n if (this.separator || childrenLength === 0) {\n this._write(options.separatorOverride, options);\n }\n } else {\n if (!this.modification.omitSeparatorAfter) {\n this._write(this.separator, options);\n }\n }\n }\n\n if (this.modification.indentDocComment === IndentDocCommentScope.SpanAndChildren) {\n this._endIndentDocComment(options);\n }\n }\n\n private _beginIndentDocComment(options: IWriteModifiedTextOptions): void {\n if (options.indentDocCommentState !== IndentDocCommentState.Inactive) {\n throw new InternalError('indentDocComment cannot be nested');\n }\n options.indentDocCommentState = IndentDocCommentState.AwaitingOpenDelimiter;\n }\n\n private _endIndentDocComment(options: IWriteModifiedTextOptions): void {\n if (options.indentDocCommentState === IndentDocCommentState.AwaitingCloseDelimiter) {\n throw new InternalError('missing \"*/\" delimiter for comment block');\n }\n options.indentDocCommentState = IndentDocCommentState.Inactive;\n }\n\n /**\n * Writes one chunk of `text` to the `options.writer`, applying the `indentDocComment` rewriting.\n */\n private _write(text: string, options: IWriteModifiedTextOptions): void {\n let parsedText: string = text;\n\n if (options.indentDocCommentState === IndentDocCommentState.AwaitingOpenDelimiter) {\n let index: number = parsedText.indexOf('/*');\n if (index >= 0) {\n index += '/*'.length;\n options.writer.write(parsedText.substring(0, index));\n parsedText = parsedText.substring(index);\n options.indentDocCommentState = IndentDocCommentState.AwaitingCloseDelimiter;\n\n options.writer.increaseIndent(' ');\n }\n }\n\n if (options.indentDocCommentState === IndentDocCommentState.AwaitingCloseDelimiter) {\n let index: number = parsedText.indexOf('*/');\n if (index >= 0) {\n index += '*/'.length;\n options.writer.write(parsedText.substring(0, index));\n parsedText = parsedText.substring(index);\n options.indentDocCommentState = IndentDocCommentState.Done;\n\n options.writer.decreaseIndent();\n }\n }\n\n options.writer.write(parsedText);\n }\n\n private _getTrimmed(text: string): string {\n return Text.truncateWithEllipsis(Text.convertToLf(text), 100);\n }\n\n private _getSubstring(startIndex: number, endIndex: number): string {\n if (startIndex === endIndex) {\n return '';\n }\n return this.node.getSourceFile().text.substring(startIndex, endIndex);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Span.js","sourceRoot":"","sources":["../../src/analyzer/Span.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,+CAAiC;AACjC,oEAAyE;AAEzE,iEAA8D;AAQ9D,IAAK,qBAiBJ;AAjBD,WAAK,qBAAqB;IACxB;;OAEG;IACH,yEAAY,CAAA;IACZ;;OAEG;IACH,mGAAyB,CAAA;IACzB;;OAEG;IACH,qGAA0B,CAAA;IAC1B;;OAEG;IACH,iEAAQ,CAAA;AACV,CAAC,EAjBI,qBAAqB,KAArB,qBAAqB,QAiBzB;AAED;;GAEG;AACH,IAAY,qBAeX;AA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AAY;QAC9B,OAAO,wBAAI,CAAC,oBAAoB,CAAC,wBAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;IAChE,CAAC;IAEO,aAAa,CAAC,UAAkB,EAAE,QAAgB;QACxD,IAAI,UAAU,KAAK,QAAQ,EAAE,CAAC;YAC5B,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IACxE,CAAC;CACF;AArdD,oBAqdC","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 ts from 'typescript';\nimport { InternalError, Sort, Text } from '@rushstack/node-core-library';\n\nimport { IndentedWriter } from '../generators/IndentedWriter';\n\ninterface IWriteModifiedTextOptions {\n writer: IndentedWriter;\n separatorOverride: string | undefined;\n indentDocCommentState: IndentDocCommentState;\n}\n\nenum IndentDocCommentState {\n /**\n * `indentDocComment` was not requested for this subtree.\n */\n Inactive = 0,\n /**\n * `indentDocComment` was requested and we are looking for the opening `/` `*`\n */\n AwaitingOpenDelimiter = 1,\n /**\n * `indentDocComment` was requested and we are looking for the closing `*` `/`\n */\n AwaitingCloseDelimiter = 2,\n /**\n * `indentDocComment` was requested and we have finished indenting the comment.\n */\n Done = 3\n}\n\n/**\n * Choices for SpanModification.indentDocComment.\n */\nexport enum IndentDocCommentScope {\n /**\n * Do not detect and indent comments.\n */\n None = 0,\n\n /**\n * Look for one doc comment in the {@link Span.prefix} text only.\n */\n PrefixOnly = 1,\n\n /**\n * Look for one doc comment potentially distributed across the Span and its children.\n */\n SpanAndChildren = 2\n}\n\n/**\n * Specifies various transformations that will be performed by Span.getModifiedText().\n */\nexport class SpanModification {\n /**\n * If true, all of the child spans will be omitted from the Span.getModifiedText() output.\n * @remarks\n * Also, the modify() operation will not recurse into these spans.\n */\n public omitChildren: boolean = false;\n\n /**\n * If true, then the Span.separator will be removed from the Span.getModifiedText() output.\n */\n public omitSeparatorAfter: boolean = false;\n\n /**\n * If true, then Span.getModifiedText() will sort the immediate children according to their Span.sortKey\n * property. The separators will also be fixed up to ensure correct indentation. If the Span.sortKey is undefined\n * for some items, those items will not be moved, i.e. their array indexes will be unchanged.\n */\n public sortChildren: boolean = false;\n\n /**\n * Used if the parent span has Span.sortChildren=true.\n */\n public sortKey: string | undefined;\n\n /**\n * Optionally configures getModifiedText() to search for a \"/*\" doc comment and indent it.\n * At most one comment is detected.\n *\n * @remarks\n * The indentation can be applied to the `Span.modifier.prefix` only, or it can be applied to the\n * full subtree of nodes (as needed for `ts.SyntaxKind.JSDocComment` trees). However the enabled\n * scopes must not overlap.\n *\n * This feature is enabled selectively because (1) we do not want to accidentally match `/*` appearing\n * in a string literal or other expression that is not a comment, and (2) parsing comments is relatively\n * expensive.\n */\n public indentDocComment: IndentDocCommentScope = IndentDocCommentScope.None;\n\n private readonly _span: Span;\n private _prefix: string | undefined;\n private _suffix: string | undefined;\n\n public constructor(span: Span) {\n this._span = span;\n this.reset();\n }\n\n /**\n * Allows the Span.prefix text to be changed.\n */\n public get prefix(): string {\n return this._prefix !== undefined ? this._prefix : this._span.prefix;\n }\n\n public set prefix(value: string) {\n this._prefix = value;\n }\n\n /**\n * Allows the Span.suffix text to be changed.\n */\n public get suffix(): string {\n return this._suffix !== undefined ? this._suffix : this._span.suffix;\n }\n\n public set suffix(value: string) {\n this._suffix = value;\n }\n\n /**\n * Reverts any modifications made to this object.\n */\n public reset(): void {\n this.omitChildren = false;\n this.omitSeparatorAfter = false;\n this.sortChildren = false;\n this.sortKey = undefined;\n this._prefix = undefined;\n this._suffix = undefined;\n if (this._span.kind === ts.SyntaxKind.JSDocComment) {\n this.indentDocComment = IndentDocCommentScope.SpanAndChildren;\n }\n }\n\n /**\n * Effectively deletes the Span from the tree, by skipping its children, skipping its separator,\n * and setting its prefix/suffix to the empty string.\n */\n public skipAll(): void {\n this.prefix = '';\n this.suffix = '';\n this.omitChildren = true;\n this.omitSeparatorAfter = true;\n }\n}\n\n/**\n * The Span class provides a simple way to rewrite TypeScript source files\n * based on simple syntax transformations, i.e. without having to process deeper aspects\n * of the underlying grammar. An example transformation might be deleting JSDoc comments\n * from a source file.\n *\n * @remarks\n * TypeScript's abstract syntax tree (AST) is represented using Node objects.\n * The Node text ignores its surrounding whitespace, and does not have an ordering guarantee.\n * For example, a JSDocComment node can be a child of a FunctionDeclaration node, even though\n * the actual comment precedes the function in the input stream.\n *\n * The Span class is a wrapper for a single Node, that provides access to every character\n * in the input stream, such that Span.getText() will exactly reproduce the corresponding\n * full Node.getText() output.\n *\n * A Span is comprised of these parts, which appear in sequential order:\n * - A prefix\n * - A collection of child spans\n * - A suffix\n * - A separator (e.g. whitespace between this span and the next item in the tree)\n *\n * These parts can be modified via Span.modification. The modification is applied by\n * calling Span.getModifiedText().\n */\nexport class Span {\n public readonly node: ts.Node;\n\n // To improve performance, substrings are not allocated until actually needed\n public readonly startIndex: number;\n public readonly endIndex: number;\n\n public readonly children: Span[];\n\n public readonly modification: SpanModification;\n\n private _parent: Span | undefined;\n private _previousSibling: Span | undefined;\n private _nextSibling: Span | undefined;\n\n private _separatorStartIndex: number;\n private _separatorEndIndex: number;\n\n public constructor(node: ts.Node) {\n this.node = node;\n this.startIndex = node.kind === ts.SyntaxKind.SourceFile ? node.getFullStart() : node.getStart();\n this.endIndex = node.end;\n this._separatorStartIndex = 0;\n this._separatorEndIndex = 0;\n this.children = [];\n this.modification = new SpanModification(this);\n\n let previousChildSpan: Span | undefined = undefined;\n\n for (const childNode of this.node.getChildren() || []) {\n const childSpan: Span = new Span(childNode);\n childSpan._parent = this;\n childSpan._previousSibling = previousChildSpan;\n\n if (previousChildSpan) {\n previousChildSpan._nextSibling = childSpan;\n }\n\n this.children.push(childSpan);\n\n // Normalize the bounds so that a child is never outside its parent\n if (childSpan.startIndex < this.startIndex) {\n this.startIndex = childSpan.startIndex;\n }\n\n if (childSpan.endIndex > this.endIndex) {\n // This has never been observed empirically, but here's how we would handle it\n this.endIndex = childSpan.endIndex;\n throw new InternalError('Unexpected AST case');\n }\n\n if (previousChildSpan) {\n if (previousChildSpan.endIndex < childSpan.startIndex) {\n // There is some leftover text after previous child -- assign it as the separator for\n // the preceding span. If the preceding span has no suffix, then assign it to the\n // deepest preceding span with no suffix. This heuristic simplifies the most\n // common transformations, and otherwise it can be fished out using getLastInnerSeparator().\n let separatorRecipient: Span = previousChildSpan;\n while (separatorRecipient.children.length > 0) {\n const lastChild: Span = separatorRecipient.children[separatorRecipient.children.length - 1];\n if (lastChild.endIndex !== separatorRecipient.endIndex) {\n // There is a suffix, so we cannot push the separator any further down, or else\n // it would get printed before this suffix.\n break;\n }\n separatorRecipient = lastChild;\n }\n separatorRecipient._separatorStartIndex = previousChildSpan.endIndex;\n separatorRecipient._separatorEndIndex = childSpan.startIndex;\n }\n }\n\n previousChildSpan = childSpan;\n }\n }\n\n public get kind(): ts.SyntaxKind {\n return this.node.kind;\n }\n\n /**\n * The parent Span, if any.\n * NOTE: This will be undefined for a root Span, even though the corresponding Node\n * may have a parent in the AST.\n */\n public get parent(): Span | undefined {\n return this._parent;\n }\n\n /**\n * If the current object is this.parent.children[i], then previousSibling corresponds\n * to this.parent.children[i-1] if it exists.\n * NOTE: This will be undefined for a root Span, even though the corresponding Node\n * may have a previous sibling in the AST.\n */\n public get previousSibling(): Span | undefined {\n return this._previousSibling;\n }\n\n /**\n * If the current object is this.parent.children[i], then previousSibling corresponds\n * to this.parent.children[i+1] if it exists.\n * NOTE: This will be undefined for a root Span, even though the corresponding Node\n * may have a previous sibling in the AST.\n */\n public get nextSibling(): Span | undefined {\n return this._nextSibling;\n }\n\n /**\n * The text associated with the underlying Node, up to its first child.\n */\n public get prefix(): string {\n if (this.children.length) {\n // Everything up to the first child\n return this._getSubstring(this.startIndex, this.children[0].startIndex);\n } else {\n return this._getSubstring(this.startIndex, this.endIndex);\n }\n }\n\n /**\n * The text associated with the underlying Node, after its last child.\n * If there are no children, this is always an empty string.\n */\n public get suffix(): string {\n if (this.children.length) {\n // Everything after the last child\n return this._getSubstring(this.children[this.children.length - 1].endIndex, this.endIndex);\n } else {\n return '';\n }\n }\n\n /**\n * Whitespace that appeared after this node, and before the \"next\" node in the tree.\n * Here we mean \"next\" according to an inorder traversal, not necessarily a sibling.\n */\n public get separator(): string {\n return this._getSubstring(this._separatorStartIndex, this._separatorEndIndex);\n }\n\n /**\n * Returns the separator of this Span, or else recursively calls getLastInnerSeparator()\n * on the last child.\n */\n public getLastInnerSeparator(): string {\n if (this.separator) {\n return this.separator;\n }\n if (this.children.length > 0) {\n return this.children[this.children.length - 1].getLastInnerSeparator();\n }\n return '';\n }\n\n /**\n * Returns the first parent node with the specified SyntaxKind, or undefined if there is no match.\n */\n public findFirstParent(kindToMatch: ts.SyntaxKind): Span | undefined {\n let current: Span | undefined = this;\n\n while (current) {\n if (current.kind === kindToMatch) {\n return current;\n }\n current = current.parent;\n }\n\n return undefined;\n }\n\n /**\n * Recursively invokes the callback on this Span and all its children. The callback\n * can make changes to Span.modification for each node.\n */\n public forEach(callback: (span: Span) => void): void {\n callback(this);\n for (const child of this.children) {\n child.forEach(callback);\n }\n }\n\n /**\n * Returns the original unmodified text represented by this Span.\n */\n public getText(): string {\n let result: string = '';\n result += this.prefix;\n\n for (const child of this.children) {\n result += child.getText();\n }\n\n result += this.suffix;\n result += this.separator;\n\n return result;\n }\n\n /**\n * Returns the text represented by this Span, after applying all requested modifications.\n */\n public getModifiedText(): string {\n const writer: IndentedWriter = new IndentedWriter();\n writer.trimLeadingSpaces = true;\n\n this._writeModifiedText({\n writer: writer,\n separatorOverride: undefined,\n indentDocCommentState: IndentDocCommentState.Inactive\n });\n\n return writer.getText();\n }\n\n public writeModifiedText(output: IndentedWriter): void {\n this._writeModifiedText({\n writer: output,\n separatorOverride: undefined,\n indentDocCommentState: IndentDocCommentState.Inactive\n });\n }\n\n /**\n * Returns a diagnostic dump of the tree, showing the prefix/suffix/separator for\n * each node.\n */\n public getDump(indent: string = ''): string {\n let result: string = indent + ts.SyntaxKind[this.node.kind] + ': ';\n\n if (this.prefix) {\n result += ' pre=[' + this._getTrimmed(this.prefix) + ']';\n }\n if (this.suffix) {\n result += ' suf=[' + this._getTrimmed(this.suffix) + ']';\n }\n if (this.separator) {\n result += ' sep=[' + this._getTrimmed(this.separator) + ']';\n }\n result += '\\n';\n\n for (const child of this.children) {\n result += child.getDump(indent + ' ');\n }\n\n return result;\n }\n\n /**\n * Returns a diagnostic dump of the tree, showing the SpanModification settings for each nodde.\n */\n public getModifiedDump(indent: string = ''): string {\n let result: string = indent + ts.SyntaxKind[this.node.kind] + ': ';\n\n if (this.prefix) {\n result += ' pre=[' + this._getTrimmed(this.modification.prefix) + ']';\n }\n if (this.suffix) {\n result += ' suf=[' + this._getTrimmed(this.modification.suffix) + ']';\n }\n if (this.separator) {\n result += ' sep=[' + this._getTrimmed(this.separator) + ']';\n }\n if (this.modification.indentDocComment !== IndentDocCommentScope.None) {\n result += ' indentDocComment=' + IndentDocCommentScope[this.modification.indentDocComment];\n }\n if (this.modification.omitChildren) {\n result += ' omitChildren';\n }\n if (this.modification.omitSeparatorAfter) {\n result += ' omitSeparatorAfter';\n }\n if (this.modification.sortChildren) {\n result += ' sortChildren';\n }\n if (this.modification.sortKey !== undefined) {\n result += ` sortKey=\"${this.modification.sortKey}\"`;\n }\n result += '\\n';\n\n if (!this.modification.omitChildren) {\n for (const child of this.children) {\n result += child.getModifiedDump(indent + ' ');\n }\n } else {\n result += `${indent} (${this.children.length} children)\\n`;\n }\n\n return result;\n }\n\n /**\n * Recursive implementation of `getModifiedText()` and `writeModifiedText()`.\n */\n private _writeModifiedText(options: IWriteModifiedTextOptions): void {\n // Apply indentation based on \"{\" and \"}\"\n if (this.prefix === '{') {\n options.writer.increaseIndent();\n } else if (this.prefix === '}') {\n options.writer.decreaseIndent();\n }\n\n if (this.modification.indentDocComment !== IndentDocCommentScope.None) {\n this._beginIndentDocComment(options);\n }\n\n this._write(this.modification.prefix, options);\n\n if (this.modification.indentDocComment === IndentDocCommentScope.PrefixOnly) {\n this._endIndentDocComment(options);\n }\n\n let sortedSubset: Span[] | undefined;\n\n if (!this.modification.omitChildren) {\n if (this.modification.sortChildren) {\n // We will only sort the items with a sortKey\n const filtered: Span[] = this.children.filter((x) => x.modification.sortKey !== undefined);\n\n // Is there at least one of them?\n if (filtered.length > 1) {\n sortedSubset = filtered;\n }\n }\n }\n\n if (sortedSubset) {\n // This is the complicated special case that sorts an arbitrary subset of the child nodes,\n // preserving the surrounding nodes.\n\n const sortedSubsetCount: number = sortedSubset.length;\n // Remember the separator for the first and last ones\n const firstSeparator: string = sortedSubset[0].getLastInnerSeparator();\n const lastSeparator: string = sortedSubset[sortedSubsetCount - 1].getLastInnerSeparator();\n\n Sort.sortBy(sortedSubset, (x) => x.modification.sortKey);\n\n const childOptions: IWriteModifiedTextOptions = { ...options };\n\n let sortedSubsetIndex: number = 0;\n for (let index: number = 0; index < this.children.length; ++index) {\n let current: Span;\n\n // Is this an item that we sorted?\n if (this.children[index].modification.sortKey === undefined) {\n // No, take the next item from the original array\n current = this.children[index];\n childOptions.separatorOverride = undefined;\n } else {\n // Yes, take the next item from the sortedSubset\n current = sortedSubset[sortedSubsetIndex++];\n\n if (sortedSubsetIndex < sortedSubsetCount) {\n childOptions.separatorOverride = firstSeparator;\n } else {\n childOptions.separatorOverride = lastSeparator;\n }\n }\n\n current._writeModifiedText(childOptions);\n }\n } else {\n // This is the normal case that does not need to sort children\n const childrenLength: number = this.children.length;\n\n if (!this.modification.omitChildren) {\n if (options.separatorOverride !== undefined) {\n // Special case where the separatorOverride is passed down to the \"last inner separator\" span\n for (let i: number = 0; i < childrenLength; ++i) {\n const child: Span = this.children[i];\n\n if (\n // Only the last child inherits the separatorOverride, because only it can contain\n // the \"last inner separator\" span\n i < childrenLength - 1 ||\n // If this.separator is specified, then we will write separatorOverride below, so don't pass it along\n this.separator\n ) {\n const childOptions: IWriteModifiedTextOptions = { ...options };\n childOptions.separatorOverride = undefined;\n child._writeModifiedText(childOptions);\n } else {\n child._writeModifiedText(options);\n }\n }\n } else {\n // The normal simple case\n for (const child of this.children) {\n child._writeModifiedText(options);\n }\n }\n }\n\n this._write(this.modification.suffix, options);\n\n if (options.separatorOverride !== undefined) {\n if (this.separator || childrenLength === 0) {\n this._write(options.separatorOverride, options);\n }\n } else {\n if (!this.modification.omitSeparatorAfter) {\n this._write(this.separator, options);\n }\n }\n }\n\n if (this.modification.indentDocComment === IndentDocCommentScope.SpanAndChildren) {\n this._endIndentDocComment(options);\n }\n }\n\n private _beginIndentDocComment(options: IWriteModifiedTextOptions): void {\n if (options.indentDocCommentState !== IndentDocCommentState.Inactive) {\n throw new InternalError('indentDocComment cannot be nested');\n }\n options.indentDocCommentState = IndentDocCommentState.AwaitingOpenDelimiter;\n }\n\n private _endIndentDocComment(options: IWriteModifiedTextOptions): void {\n if (options.indentDocCommentState === IndentDocCommentState.AwaitingCloseDelimiter) {\n throw new InternalError('missing \"*/\" delimiter for comment block');\n }\n options.indentDocCommentState = IndentDocCommentState.Inactive;\n }\n\n /**\n * Writes one chunk of `text` to the `options.writer`, applying the `indentDocComment` rewriting.\n */\n private _write(text: string, options: IWriteModifiedTextOptions): void {\n let parsedText: string = text;\n\n if (options.indentDocCommentState === IndentDocCommentState.AwaitingOpenDelimiter) {\n let index: number = parsedText.indexOf('/*');\n if (index >= 0) {\n index += '/*'.length;\n options.writer.write(parsedText.substring(0, index));\n parsedText = parsedText.substring(index);\n options.indentDocCommentState = IndentDocCommentState.AwaitingCloseDelimiter;\n\n options.writer.increaseIndent(' ');\n }\n }\n\n if (options.indentDocCommentState === IndentDocCommentState.AwaitingCloseDelimiter) {\n let index: number = parsedText.indexOf('*/');\n if (index >= 0) {\n index += '*/'.length;\n options.writer.write(parsedText.substring(0, index));\n parsedText = parsedText.substring(index);\n options.indentDocCommentState = IndentDocCommentState.Done;\n\n options.writer.decreaseIndent();\n }\n }\n\n options.writer.write(parsedText);\n }\n\n private _getTrimmed(text: string): string {\n return Text.truncateWithEllipsis(Text.convertToLf(text), 100);\n }\n\n private _getSubstring(startIndex: number, endIndex: number): string {\n if (startIndex === endIndex) {\n return '';\n }\n return this.node.getSourceFile().text.substring(startIndex, endIndex);\n }\n}\n"]}
|