@microsoft/api-extractor 7.52.15 → 7.53.1

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.
Files changed (94) hide show
  1. package/CHANGELOG.json +50 -0
  2. package/CHANGELOG.md +13 -1
  3. package/dist/tsdoc-metadata.json +1 -1
  4. package/lib/aedoc/PackageDocComment.d.ts.map +1 -1
  5. package/lib/aedoc/PackageDocComment.js.map +1 -1
  6. package/lib/analyzer/AstDeclaration.d.ts.map +1 -1
  7. package/lib/analyzer/AstDeclaration.js +1 -1
  8. package/lib/analyzer/AstDeclaration.js.map +1 -1
  9. package/lib/analyzer/AstImport.d.ts.map +1 -1
  10. package/lib/analyzer/AstImport.js.map +1 -1
  11. package/lib/analyzer/AstReferenceResolver.d.ts.map +1 -1
  12. package/lib/analyzer/AstReferenceResolver.js.map +1 -1
  13. package/lib/analyzer/AstSymbol.d.ts.map +1 -1
  14. package/lib/analyzer/AstSymbol.js.map +1 -1
  15. package/lib/analyzer/AstSymbolTable.d.ts.map +1 -1
  16. package/lib/analyzer/AstSymbolTable.js.map +1 -1
  17. package/lib/analyzer/ExportAnalyzer.d.ts.map +1 -1
  18. package/lib/analyzer/ExportAnalyzer.js.map +1 -1
  19. package/lib/analyzer/PackageMetadataManager.d.ts.map +1 -1
  20. package/lib/analyzer/PackageMetadataManager.js +11 -11
  21. package/lib/analyzer/PackageMetadataManager.js.map +1 -1
  22. package/lib/analyzer/SourceFileLocationFormatter.d.ts.map +1 -1
  23. package/lib/analyzer/SourceFileLocationFormatter.js +1 -1
  24. package/lib/analyzer/SourceFileLocationFormatter.js.map +1 -1
  25. package/lib/analyzer/Span.d.ts.map +1 -1
  26. package/lib/analyzer/Span.js.map +1 -1
  27. package/lib/analyzer/TypeScriptHelpers.d.ts.map +1 -1
  28. package/lib/analyzer/TypeScriptHelpers.js +1 -1
  29. package/lib/analyzer/TypeScriptHelpers.js.map +1 -1
  30. package/lib/analyzer/TypeScriptInternals.d.ts.map +1 -1
  31. package/lib/analyzer/TypeScriptInternals.js.map +1 -1
  32. package/lib/api/CompilerState.d.ts.map +1 -1
  33. package/lib/api/CompilerState.js +2 -2
  34. package/lib/api/CompilerState.js.map +1 -1
  35. package/lib/api/Extractor.d.ts.map +1 -1
  36. package/lib/api/Extractor.js +2 -2
  37. package/lib/api/Extractor.js.map +1 -1
  38. package/lib/api/ExtractorConfig.d.ts +2 -2
  39. package/lib/api/ExtractorConfig.d.ts.map +1 -1
  40. package/lib/api/ExtractorConfig.js +3 -3
  41. package/lib/api/ExtractorConfig.js.map +1 -1
  42. package/lib/api/ExtractorMessage.d.ts.map +1 -1
  43. package/lib/api/ExtractorMessage.js.map +1 -1
  44. package/lib/api/IConfigFile.d.ts.map +1 -1
  45. package/lib/api/IConfigFile.js.map +1 -1
  46. package/lib/cli/ApiExtractorCommandLine.js +1 -1
  47. package/lib/cli/ApiExtractorCommandLine.js.map +1 -1
  48. package/lib/cli/InitAction.d.ts.map +1 -1
  49. package/lib/cli/InitAction.js +1 -1
  50. package/lib/cli/InitAction.js.map +1 -1
  51. package/lib/cli/RunAction.d.ts.map +1 -1
  52. package/lib/cli/RunAction.js +2 -2
  53. package/lib/cli/RunAction.js.map +1 -1
  54. package/lib/collector/ApiItemMetadata.d.ts.map +1 -1
  55. package/lib/collector/ApiItemMetadata.js.map +1 -1
  56. package/lib/collector/Collector.d.ts.map +1 -1
  57. package/lib/collector/Collector.js +2 -2
  58. package/lib/collector/Collector.js.map +1 -1
  59. package/lib/collector/CollectorEntity.d.ts.map +1 -1
  60. package/lib/collector/CollectorEntity.js +1 -1
  61. package/lib/collector/CollectorEntity.js.map +1 -1
  62. package/lib/collector/DeclarationMetadata.d.ts.map +1 -1
  63. package/lib/collector/DeclarationMetadata.js.map +1 -1
  64. package/lib/collector/MessageRouter.d.ts.map +1 -1
  65. package/lib/collector/MessageRouter.js.map +1 -1
  66. package/lib/collector/SourceMapper.d.ts.map +1 -1
  67. package/lib/collector/SourceMapper.js +1 -1
  68. package/lib/collector/SourceMapper.js.map +1 -1
  69. package/lib/collector/WorkingPackage.d.ts.map +1 -1
  70. package/lib/collector/WorkingPackage.js.map +1 -1
  71. package/lib/enhancers/DocCommentEnhancer.d.ts.map +1 -1
  72. package/lib/enhancers/DocCommentEnhancer.js +1 -1
  73. package/lib/enhancers/DocCommentEnhancer.js.map +1 -1
  74. package/lib/enhancers/ValidationEnhancer.d.ts.map +1 -1
  75. package/lib/enhancers/ValidationEnhancer.js +2 -2
  76. package/lib/enhancers/ValidationEnhancer.js.map +1 -1
  77. package/lib/generators/ApiModelGenerator.d.ts.map +1 -1
  78. package/lib/generators/ApiModelGenerator.js +1 -1
  79. package/lib/generators/ApiModelGenerator.js.map +1 -1
  80. package/lib/generators/ApiReportGenerator.d.ts.map +1 -1
  81. package/lib/generators/ApiReportGenerator.js +1 -1
  82. package/lib/generators/ApiReportGenerator.js.map +1 -1
  83. package/lib/generators/DeclarationReferenceGenerator.d.ts.map +1 -1
  84. package/lib/generators/DeclarationReferenceGenerator.js.map +1 -1
  85. package/lib/generators/DtsEmitHelpers.d.ts.map +1 -1
  86. package/lib/generators/DtsEmitHelpers.js.map +1 -1
  87. package/lib/generators/DtsRollupGenerator.d.ts.map +1 -1
  88. package/lib/generators/DtsRollupGenerator.js +1 -1
  89. package/lib/generators/DtsRollupGenerator.js.map +1 -1
  90. package/lib/generators/ExcerptBuilder.d.ts.map +1 -1
  91. package/lib/generators/ExcerptBuilder.js.map +1 -1
  92. package/lib/start.js +1 -1
  93. package/lib/start.js.map +1 -1
  94. package/package.json +7 -7
package/CHANGELOG.json CHANGED
@@ -1,6 +1,56 @@
1
1
  {
2
2
  "name": "@microsoft/api-extractor",
3
3
  "entries": [
4
+ {
5
+ "version": "7.53.1",
6
+ "tag": "@microsoft/api-extractor_v7.53.1",
7
+ "date": "Wed, 08 Oct 2025 00:13:28 GMT",
8
+ "comments": {
9
+ "dependency": [
10
+ {
11
+ "comment": "Updating dependency \"@microsoft/api-extractor-model\" to `7.31.1`"
12
+ },
13
+ {
14
+ "comment": "Updating dependency \"@rushstack/node-core-library\" to `5.17.0`"
15
+ },
16
+ {
17
+ "comment": "Updating dependency \"@rushstack/terminal\" to `0.19.1`"
18
+ },
19
+ {
20
+ "comment": "Updating dependency \"@rushstack/ts-command-line\" to `5.1.1`"
21
+ }
22
+ ]
23
+ }
24
+ },
25
+ {
26
+ "version": "7.53.0",
27
+ "tag": "@microsoft/api-extractor_v7.53.0",
28
+ "date": "Fri, 03 Oct 2025 20:09:59 GMT",
29
+ "comments": {
30
+ "minor": [
31
+ {
32
+ "comment": "Normalize import of builtin modules to use the `node:` protocol."
33
+ }
34
+ ],
35
+ "dependency": [
36
+ {
37
+ "comment": "Updating dependency \"@microsoft/api-extractor-model\" to `7.31.0`"
38
+ },
39
+ {
40
+ "comment": "Updating dependency \"@rushstack/node-core-library\" to `5.16.0`"
41
+ },
42
+ {
43
+ "comment": "Updating dependency \"@rushstack/rig-package\" to `0.6.0`"
44
+ },
45
+ {
46
+ "comment": "Updating dependency \"@rushstack/terminal\" to `0.19.0`"
47
+ },
48
+ {
49
+ "comment": "Updating dependency \"@rushstack/ts-command-line\" to `5.1.0`"
50
+ }
51
+ ]
52
+ }
53
+ },
4
54
  {
5
55
  "version": "7.52.15",
6
56
  "tag": "@microsoft/api-extractor_v7.52.15",
package/CHANGELOG.md CHANGED
@@ -1,6 +1,18 @@
1
1
  # Change Log - @microsoft/api-extractor
2
2
 
3
- This log was last generated on Tue, 30 Sep 2025 23:57:45 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 08 Oct 2025 00:13:28 GMT and should not be manually modified.
4
+
5
+ ## 7.53.1
6
+ Wed, 08 Oct 2025 00:13:28 GMT
7
+
8
+ _Version update only_
9
+
10
+ ## 7.53.0
11
+ Fri, 03 Oct 2025 20:09:59 GMT
12
+
13
+ ### Minor changes
14
+
15
+ - Normalize import of builtin modules to use the `node:` protocol.
4
16
 
5
17
  ## 7.52.15
6
18
  Tue, 30 Sep 2025 23:57:45 GMT
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.52.11"
8
+ "packageVersion": "7.52.15"
9
9
  }
10
10
  ]
11
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"PackageDocComment.d.ts","sourceRoot":"","sources":["../../src/aedoc/PackageDocComment.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAGxD,qBAAa,iBAAiB;IAC5B;;OAEG;WACW,mBAAmB,CAC/B,UAAU,EAAE,EAAE,CAAC,UAAU,EACzB,SAAS,EAAE,SAAS,GACnB,EAAE,CAAC,SAAS,GAAG,SAAS;CAyD5B"}
1
+ {"version":3,"file":"PackageDocComment.d.ts","sourceRoot":"","sources":["../../src/aedoc/PackageDocComment.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAGxD,qBAAa,iBAAiB;IAC5B;;OAEG;WACW,mBAAmB,CAC/B,UAAU,EAAE,EAAE,CAAC,UAAU,EACzB,SAAS,EAAE,SAAS,GACnB,EAAE,CAAC,SAAS,GAAG,SAAS;CAyD5B"}
@@ -1 +1 @@
1
- {"version":3,"file":"PackageDocComment.js","sourceRoot":"","sources":["../../src/aedoc/PackageDocComment.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,+CAAiC;AAEjC,kEAA+D;AAE/D,MAAa,iBAAiB;IAC5B;;OAEG;IACI,MAAM,CAAC,mBAAmB,CAC/B,UAAyB,EACzB,SAAoB;QAEpB,oFAAoF;QACpF,mFAAmF;QACnF,6BAA6B;QAC7B,EAAE;QACF,sFAAsF;QAC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AK,MAAM,YAAY,IAAI,MAAM,EAAE,CAAC;oBAClC,MAAM,WAAW,GAAW,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC;oBAE1F,IAAI,yBAAyB,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;wBAChD,SAAS,CAAC,aAAa,CAAC,2BAA2B,CACjD,uCAAkB,CAAC,mBAAmB,EACtC,qFAAqF,EACrF,UAAU,EACV,YAAY,CAAC,GAAG,CACjB,CAAC;wBACF,MAAM;oBACR,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,mBAAmB,CAAC;IAC7B,CAAC;CACF;AAhED,8CAgEC","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 type { Collector } from '../collector/Collector';\nimport { ExtractorMessageId } from '../api/ExtractorMessageId';\n\nexport class PackageDocComment {\n /**\n * For the given source file, see if it starts with a TSDoc comment containing the `@packageDocumentation` tag.\n */\n public static tryFindInSourceFile(\n sourceFile: ts.SourceFile,\n collector: Collector\n ): ts.TextRange | undefined {\n // The @packageDocumentation comment is special because it is not attached to an AST\n // definition. Instead, it is part of the \"trivia\" tokens that the compiler treats\n // as irrelevant white space.\n //\n // WARNING: If the comment doesn't precede an export statement, the compiler will omit\n // it from the *.d.ts file, and API Extractor won't find it. If this happens, you need\n // to rearrange your statements to ensure it is passed through.\n //\n // This implementation assumes that the \"@packageDocumentation\" will be in the first TSDoc comment\n // that appears in the entry point *.d.ts file. We could possibly look in other places,\n // but the above warning suggests enforcing a standardized layout. This design choice is open\n // to feedback.\n let packageCommentRange: ts.TextRange | undefined = undefined; // empty string\n\n for (const commentRange of ts.getLeadingCommentRanges(sourceFile.text, sourceFile.getFullStart()) || []) {\n if (commentRange.kind === ts.SyntaxKind.MultiLineCommentTrivia) {\n const commentBody: string = sourceFile.text.substring(commentRange.pos, commentRange.end);\n\n // Choose the first JSDoc-style comment\n if (/^\\s*\\/\\*\\*/.test(commentBody)) {\n // But only if it looks like it's trying to be @packageDocumentation\n // (The TSDoc parser will validate this more rigorously)\n if (/\\@packageDocumentation/i.test(commentBody)) {\n packageCommentRange = commentRange;\n }\n break;\n }\n }\n }\n\n if (!packageCommentRange) {\n // If we didn't find the @packageDocumentation tag in the expected place, is it in some\n // wrong place? This sanity check helps people to figure out why there comment isn't working.\n for (const statement of sourceFile.statements) {\n const ranges: ts.CommentRange[] = [];\n ranges.push(...(ts.getLeadingCommentRanges(sourceFile.text, statement.getFullStart()) || []));\n ranges.push(...(ts.getTrailingCommentRanges(sourceFile.text, statement.getEnd()) || []));\n\n for (const commentRange of ranges) {\n const commentBody: string = sourceFile.text.substring(commentRange.pos, commentRange.end);\n\n if (/\\@packageDocumentation/i.test(commentBody)) {\n collector.messageRouter.addAnalyzerIssueForPosition(\n ExtractorMessageId.MisplacedPackageTag,\n 'The @packageDocumentation comment must appear at the top of entry point *.d.ts file',\n sourceFile,\n commentRange.pos\n );\n break;\n }\n }\n }\n }\n\n return packageCommentRange;\n }\n}\n"]}
1
+ {"version":3,"file":"PackageDocComment.js","sourceRoot":"","sources":["../../src/aedoc/PackageDocComment.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,+CAAiC;AAGjC,kEAA+D;AAE/D,MAAa,iBAAiB;IAC5B;;OAEG;IACI,MAAM,CAAC,mBAAmB,CAC/B,UAAyB,EACzB,SAAoB;QAEpB,oFAAoF;QACpF,mFAAmF;QACnF,6BAA6B;QAC7B,EAAE;QACF,sFAAsF;QACtF,uFAAuF;QACvF,+DAA+D;QAC/D,EAAE;QACF,kGAAkG;QAClG,wFAAwF;QACxF,8FAA8F;QAC9F,eAAe;QACf,IAAI,mBAAmB,GAA6B,SAAS,CAAC,CAAC,eAAe;QAE9E,K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;oBAE1F,IAAI,yBAAyB,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;wBAChD,SAAS,CAAC,aAAa,CAAC,2BAA2B,CACjD,uCAAkB,CAAC,mBAAmB,EACtC,qFAAqF,EACrF,UAAU,EACV,YAAY,CAAC,GAAG,CACjB,CAAC;wBACF,MAAM;oBACR,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,mBAAmB,CAAC;IAC7B,CAAC;CACF;AAhED,8CAgEC","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';\n\nimport type { Collector } from '../collector/Collector';\nimport { ExtractorMessageId } from '../api/ExtractorMessageId';\n\nexport class PackageDocComment {\n /**\n * For the given source file, see if it starts with a TSDoc comment containing the `@packageDocumentation` tag.\n */\n public static tryFindInSourceFile(\n sourceFile: ts.SourceFile,\n collector: Collector\n ): ts.TextRange | undefined {\n // The @packageDocumentation comment is special because it is not attached to an AST\n // definition. Instead, it is part of the \"trivia\" tokens that the compiler treats\n // as irrelevant white space.\n //\n // WARNING: If the comment doesn't precede an export statement, the compiler will omit\n // it from the *.d.ts file, and API Extractor won't find it. If this happens, you need\n // to rearrange your statements to ensure it is passed through.\n //\n // This implementation assumes that the \"@packageDocumentation\" will be in the first TSDoc comment\n // that appears in the entry point *.d.ts file. We could possibly look in other places,\n // but the above warning suggests enforcing a standardized layout. This design choice is open\n // to feedback.\n let packageCommentRange: ts.TextRange | undefined = undefined; // empty string\n\n for (const commentRange of ts.getLeadingCommentRanges(sourceFile.text, sourceFile.getFullStart()) || []) {\n if (commentRange.kind === ts.SyntaxKind.MultiLineCommentTrivia) {\n const commentBody: string = sourceFile.text.substring(commentRange.pos, commentRange.end);\n\n // Choose the first JSDoc-style comment\n if (/^\\s*\\/\\*\\*/.test(commentBody)) {\n // But only if it looks like it's trying to be @packageDocumentation\n // (The TSDoc parser will validate this more rigorously)\n if (/\\@packageDocumentation/i.test(commentBody)) {\n packageCommentRange = commentRange;\n }\n break;\n }\n }\n }\n\n if (!packageCommentRange) {\n // If we didn't find the @packageDocumentation tag in the expected place, is it in some\n // wrong place? This sanity check helps people to figure out why there comment isn't working.\n for (const statement of sourceFile.statements) {\n const ranges: ts.CommentRange[] = [];\n ranges.push(...(ts.getLeadingCommentRanges(sourceFile.text, statement.getFullStart()) || []));\n ranges.push(...(ts.getTrailingCommentRanges(sourceFile.text, statement.getEnd()) || []));\n\n for (const commentRange of ranges) {\n const commentBody: string = sourceFile.text.substring(commentRange.pos, commentRange.end);\n\n if (/\\@packageDocumentation/i.test(commentBody)) {\n collector.messageRouter.addAnalyzerIssueForPosition(\n ExtractorMessageId.MisplacedPackageTag,\n 'The @packageDocumentation comment must appear at the top of entry point *.d.ts file',\n sourceFile,\n commentRange.pos\n );\n break;\n }\n }\n }\n }\n\n return packageCommentRange;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"AstDeclaration.d.ts","sourceRoot":"","sources":["../../src/analyzer/AstDeclaration.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC;IACrC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,CAAC;CAC7C;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,cAAc;IACzB,SAAgB,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC;IAE5C,SAAgB,SAAS,EAAE,SAAS,CAAC;IAErC;;OAEG;IACH,SAAgB,MAAM,EAAE,cAAc,GAAG,SAAS,CAAC;IAE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;;;;OAKG;IACI,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAAC,cAAc,CAAC;IA4BxE;;;OAGG;WACW,qBAAqB,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,GAAG,OAAO;CAmClE"}
@@ -37,8 +37,8 @@ var __importStar = (this && this.__importStar) || (function () {
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
38
  exports.AstDeclaration = void 0;
39
39
  const ts = __importStar(require("typescript"));
40
- const Span_1 = require("./Span");
41
40
  const node_core_library_1 = require("@rushstack/node-core-library");
41
+ const Span_1 = require("./Span");
42
42
  /**
43
43
  * The AstDeclaration and AstSymbol classes are API Extractor's equivalent of the compiler's
44
44
  * ts.Declaration and ts.Symbol objects. They are created by the `AstSymbolTable` class.
@@ -1 +1 @@
1
- {"version":3,"file":"AstDeclaration.js","sourceRoot":"","sources":["../../src/analyzer/AstDeclaration.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,+CAAiC;AAEjC,iCAA8B;AAC9B,oEAA6D;AAY7D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,cAAc;IAqCzB,YAAmB,OAA+B;QARlD,4FAA4F;QAC3E,sBAAiB,GAAqB,EAAE,CAAC;QAEzC,sCAAiC,GAAmB,IAAI,GAAG,EAAa,CAAC;QAE1F,gDAAgD;QACxC,oBAAe,GAA8C,SAAS,CAAC;QAG7E,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QACvC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAE7B,IAAI,CAAC,SAAS,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC;QAE9C,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC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AAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAvPD,wCAuPC","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 type { AstSymbol } from './AstSymbol';\nimport { Span } from './Span';\nimport { InternalError } from '@rushstack/node-core-library';\nimport type { AstEntity } from './AstEntity';\n\n/**\n * Constructor options for AstDeclaration\n */\nexport interface IAstDeclarationOptions {\n readonly declaration: ts.Declaration;\n readonly astSymbol: AstSymbol;\n readonly parent: AstDeclaration | undefined;\n}\n\n/**\n * The AstDeclaration and AstSymbol classes are API Extractor's equivalent of the compiler's\n * ts.Declaration and ts.Symbol objects. They are created by the `AstSymbolTable` class.\n *\n * @remarks\n * The AstDeclaration represents one or more syntax components of a symbol. Usually there is\n * only one AstDeclaration per AstSymbol, but certain TypeScript constructs can have multiple\n * declarations (e.g. overloaded functions, merged declarations, etc.).\n *\n * Because of this, the `AstDeclaration` manages the parent/child nesting hierarchy (e.g. with\n * declaration merging, each declaration has its own children) and becomes the main focus\n * of analyzing AEDoc and emitting *.d.ts files.\n *\n * The AstDeclarations correspond to items from the compiler's ts.Node hierarchy, but\n * omitting/skipping any nodes that don't match the AstDeclaration.isSupportedSyntaxKind()\n * criteria. This simplification makes the other API Extractor stages easier to implement.\n */\nexport class AstDeclaration {\n public readonly declaration: ts.Declaration;\n\n public readonly astSymbol: AstSymbol;\n\n /**\n * The parent, if this object is nested inside another AstDeclaration.\n */\n public readonly parent: AstDeclaration | undefined;\n\n /**\n * A bit set of TypeScript modifiers such as \"private\", \"protected\", etc.\n */\n public readonly modifierFlags: ts.ModifierFlags;\n\n /**\n * Additional information that is calculated later by the `Collector`. The actual type is `DeclarationMetadata`,\n * but we declare it as `unknown` because consumers must obtain this object by calling\n * `Collector.fetchDeclarationMetadata()`.\n */\n public declarationMetadata: unknown;\n\n /**\n * Additional information that is calculated later by the `Collector`. The actual type is `ApiItemMetadata`,\n * but we declare it as `unknown` because consumers must obtain this object by calling\n * `Collector.fetchApiItemMetadata()`.\n */\n public apiItemMetadata: unknown;\n\n // NOTE: This array becomes immutable after astSymbol.analyze() sets astSymbol.analyzed=true\n private readonly _analyzedChildren: AstDeclaration[] = [];\n\n private readonly _analyzedReferencedAstEntitiesSet: Set<AstEntity> = new Set<AstEntity>();\n\n // Reverse lookup used by findChildrenWithName()\n private _childrenByName: Map<string, AstDeclaration[]> | undefined = undefined;\n\n public constructor(options: IAstDeclarationOptions) {\n this.declaration = options.declaration;\n this.astSymbol = options.astSymbol;\n this.parent = options.parent;\n\n this.astSymbol._notifyDeclarationAttach(this);\n\n if (this.parent) {\n this.parent._notifyChildAttach(this);\n }\n\n this.modifierFlags = ts.getCombinedModifierFlags(this.declaration);\n\n // Check for ECMAScript private fields, for example:\n //\n // class Person { #name: string; }\n //\n const declarationName: ts.DeclarationName | undefined = ts.getNameOfDeclaration(this.declaration);\n if (declarationName) {\n if (ts.isPrivateIdentifier(declarationName)) {\n // eslint-disable-next-line no-bitwise\n this.modifierFlags |= ts.ModifierFlags.Private;\n }\n }\n }\n\n /**\n * Returns the children for this AstDeclaration.\n * @remarks\n * The collection will be empty until AstSymbol.analyzed is true.\n */\n public get children(): ReadonlyArray<AstDeclaration> {\n return this.astSymbol.analyzed ? this._analyzedChildren : [];\n }\n\n /**\n * Returns the AstEntity objects referenced by this node.\n * @remarks\n * NOTE: The collection will be empty until AstSymbol.analyzed is true.\n *\n * Since we assume references are always collected by a traversal starting at the\n * root of the nesting declarations, this array omits the following items because they\n * would be redundant:\n * - symbols corresponding to parents of this declaration (e.g. a method that returns its own class)\n * - symbols already listed in the referencedAstSymbols property for parents of this declaration\n * (e.g. a method that returns its own class's base class)\n * - symbols that are referenced only by nested children of this declaration\n * (e.g. if a method returns an enum, this doesn't imply that the method's class references that enum)\n */\n public get referencedAstEntities(): ReadonlyArray<AstEntity> {\n return this.astSymbol.analyzed ? [...this._analyzedReferencedAstEntitiesSet] : [];\n }\n\n /**\n * This is an internal callback used when the AstSymbolTable attaches a new\n * child AstDeclaration to this object.\n * @internal\n */\n public _notifyChildAttach(child: AstDeclaration): void {\n if (child.parent !== this) {\n throw new InternalError('Invalid call to notifyChildAttach()');\n }\n\n if (this.astSymbol.analyzed) {\n throw new InternalError('_notifyChildAttach() called after analysis is already complete');\n }\n\n this._analyzedChildren.push(child);\n }\n\n /**\n * Returns a diagnostic dump of the tree, which reports the hierarchy of\n * AstDefinition objects.\n */\n public getDump(indent: string = ''): string {\n const declarationKind: string = ts.SyntaxKind[this.declaration.kind];\n let result: string = indent + `+ ${this.astSymbol.localName} (${declarationKind})`;\n if (this.astSymbol.nominalAnalysis) {\n result += ' (nominal)';\n }\n result += '\\n';\n\n for (const referencedAstEntity of this._analyzedReferencedAstEntitiesSet.values()) {\n result += indent + ` ref: ${referencedAstEntity.localName}\\n`;\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 using Span.getDump(), which reports the detailed\n * compiler structure.\n */\n public getSpanDump(indent: string = ''): string {\n const span: Span = new Span(this.declaration);\n return span.getDump(indent);\n }\n\n /**\n * This is an internal callback used when AstSymbolTable.analyze() discovers a new\n * type reference associated with this declaration.\n * @internal\n */\n public _notifyReferencedAstEntity(referencedAstEntity: AstEntity): void {\n if (this.astSymbol.analyzed) {\n throw new InternalError('_notifyReferencedAstEntity() called after analysis is already complete');\n }\n\n for (let current: AstDeclaration | undefined = this; current; current = current.parent) {\n // Don't add references to symbols that are already referenced by a parent\n if (current._analyzedReferencedAstEntitiesSet.has(referencedAstEntity)) {\n return;\n }\n // Don't add the symbols of parents either\n if (referencedAstEntity === current.astSymbol) {\n return;\n }\n }\n\n this._analyzedReferencedAstEntitiesSet.add(referencedAstEntity);\n }\n\n /**\n * Visits all the current declaration and all children recursively in a depth-first traversal,\n * and performs the specified action for each one.\n */\n public forEachDeclarationRecursive(action: (astDeclaration: AstDeclaration) => void): void {\n action(this);\n for (const child of this.children) {\n child.forEachDeclarationRecursive(action);\n }\n }\n\n /**\n * Returns the list of child declarations whose `AstSymbol.localName` matches the provided `name`.\n *\n * @remarks\n * This is an efficient O(1) lookup.\n */\n public findChildrenWithName(name: string): ReadonlyArray<AstDeclaration> {\n // The children property returns:\n //\n // return this.astSymbol.analyzed ? this._analyzedChildren : [];\n //\n if (!this.astSymbol.analyzed || this._analyzedChildren.length === 0) {\n return [];\n }\n\n if (this._childrenByName === undefined) {\n // Build the lookup table\n const childrenByName: Map<string, AstDeclaration[]> = new Map<string, AstDeclaration[]>();\n\n for (const child of this._analyzedChildren) {\n const childName: string = child.astSymbol.localName;\n let array: AstDeclaration[] | undefined = childrenByName.get(childName);\n if (array === undefined) {\n array = [];\n childrenByName.set(childName, array);\n }\n array.push(child);\n }\n this._childrenByName = childrenByName;\n }\n\n return this._childrenByName.get(name) || [];\n }\n\n /**\n * This function determines which ts.Node kinds will generate an AstDeclaration.\n * These correspond to the definitions that we can add AEDoc to.\n */\n public static isSupportedSyntaxKind(kind: ts.SyntaxKind): boolean {\n // (alphabetical order)\n switch (kind) {\n case ts.SyntaxKind.CallSignature:\n case ts.SyntaxKind.ClassDeclaration:\n case ts.SyntaxKind.ConstructSignature: // Example: \"new(x: number): IMyClass\"\n case ts.SyntaxKind.Constructor: // Example: \"constructor(x: number)\"\n case ts.SyntaxKind.EnumDeclaration:\n case ts.SyntaxKind.EnumMember:\n case ts.SyntaxKind.FunctionDeclaration: // Example: \"(x: number): number\"\n case ts.SyntaxKind.GetAccessor:\n case ts.SyntaxKind.SetAccessor:\n case ts.SyntaxKind.IndexSignature: // Example: \"[key: string]: string\"\n case ts.SyntaxKind.InterfaceDeclaration:\n case ts.SyntaxKind.MethodDeclaration:\n case ts.SyntaxKind.MethodSignature:\n case ts.SyntaxKind.ModuleDeclaration: // Used for both \"module\" and \"namespace\" declarations\n case ts.SyntaxKind.PropertyDeclaration:\n case ts.SyntaxKind.PropertySignature:\n case ts.SyntaxKind.TypeAliasDeclaration: // Example: \"type Shape = Circle | Square\"\n case ts.SyntaxKind.VariableDeclaration:\n return true;\n\n // NOTE: Prior to TypeScript 3.7, in the emitted .d.ts files, the compiler would merge a GetAccessor/SetAccessor\n // pair into a single PropertyDeclaration.\n\n // NOTE: In contexts where a source file is treated as a module, we do create \"nominal analysis\"\n // AstSymbol objects corresponding to a ts.SyntaxKind.SourceFile node. However, a source file\n // is NOT considered a nesting structure, and it does NOT act as a root for the declarations\n // appearing in the file. This is because the *.d.ts generator is in the business of rolling up\n // source files, and thus wants to ignore them in general.\n }\n\n return false;\n }\n}\n"]}
1
+ {"version":3,"file":"AstDeclaration.js","sourceRoot":"","sources":["../../src/analyzer/AstDeclaration.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,+CAAiC;AAEjC,oEAA6D;AAG7D,iCAA8B;AAY9B;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,cAAc;IAqCzB,YAAmB,OAA+B;QARlD,4FAA4F;QAC3E,sBAAiB,GAAqB,EAAE,CAAC;QAEzC,sCAAiC,GAAmB,IAAI,GAAG,EAAa,CAAC;QAE1F,gDAAgD;QACxC,oBAAe,GAA8C,SAAS,CAAC;QAG7E,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QACvC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAE7B,IAAI,CAAC,SAAS,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC;QAE9C,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;QACvC,CAAC;QAED,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC,wBAAwB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QA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ENSE in the project root for license information.\n\nimport * as ts from 'typescript';\n\nimport { InternalError } from '@rushstack/node-core-library';\n\nimport type { AstSymbol } from './AstSymbol';\nimport { Span } from './Span';\nimport type { AstEntity } from './AstEntity';\n\n/**\n * Constructor options for AstDeclaration\n */\nexport interface IAstDeclarationOptions {\n readonly declaration: ts.Declaration;\n readonly astSymbol: AstSymbol;\n readonly parent: AstDeclaration | undefined;\n}\n\n/**\n * The AstDeclaration and AstSymbol classes are API Extractor's equivalent of the compiler's\n * ts.Declaration and ts.Symbol objects. They are created by the `AstSymbolTable` class.\n *\n * @remarks\n * The AstDeclaration represents one or more syntax components of a symbol. Usually there is\n * only one AstDeclaration per AstSymbol, but certain TypeScript constructs can have multiple\n * declarations (e.g. overloaded functions, merged declarations, etc.).\n *\n * Because of this, the `AstDeclaration` manages the parent/child nesting hierarchy (e.g. with\n * declaration merging, each declaration has its own children) and becomes the main focus\n * of analyzing AEDoc and emitting *.d.ts files.\n *\n * The AstDeclarations correspond to items from the compiler's ts.Node hierarchy, but\n * omitting/skipping any nodes that don't match the AstDeclaration.isSupportedSyntaxKind()\n * criteria. This simplification makes the other API Extractor stages easier to implement.\n */\nexport class AstDeclaration {\n public readonly declaration: ts.Declaration;\n\n public readonly astSymbol: AstSymbol;\n\n /**\n * The parent, if this object is nested inside another AstDeclaration.\n */\n public readonly parent: AstDeclaration | undefined;\n\n /**\n * A bit set of TypeScript modifiers such as \"private\", \"protected\", etc.\n */\n public readonly modifierFlags: ts.ModifierFlags;\n\n /**\n * Additional information that is calculated later by the `Collector`. The actual type is `DeclarationMetadata`,\n * but we declare it as `unknown` because consumers must obtain this object by calling\n * `Collector.fetchDeclarationMetadata()`.\n */\n public declarationMetadata: unknown;\n\n /**\n * Additional information that is calculated later by the `Collector`. The actual type is `ApiItemMetadata`,\n * but we declare it as `unknown` because consumers must obtain this object by calling\n * `Collector.fetchApiItemMetadata()`.\n */\n public apiItemMetadata: unknown;\n\n // NOTE: This array becomes immutable after astSymbol.analyze() sets astSymbol.analyzed=true\n private readonly _analyzedChildren: AstDeclaration[] = [];\n\n private readonly _analyzedReferencedAstEntitiesSet: Set<AstEntity> = new Set<AstEntity>();\n\n // Reverse lookup used by findChildrenWithName()\n private _childrenByName: Map<string, AstDeclaration[]> | undefined = undefined;\n\n public constructor(options: IAstDeclarationOptions) {\n this.declaration = options.declaration;\n this.astSymbol = options.astSymbol;\n this.parent = options.parent;\n\n this.astSymbol._notifyDeclarationAttach(this);\n\n if (this.parent) {\n this.parent._notifyChildAttach(this);\n }\n\n this.modifierFlags = ts.getCombinedModifierFlags(this.declaration);\n\n // Check for ECMAScript private fields, for example:\n //\n // class Person { #name: string; }\n //\n const declarationName: ts.DeclarationName | undefined = ts.getNameOfDeclaration(this.declaration);\n if (declarationName) {\n if (ts.isPrivateIdentifier(declarationName)) {\n // eslint-disable-next-line no-bitwise\n this.modifierFlags |= ts.ModifierFlags.Private;\n }\n }\n }\n\n /**\n * Returns the children for this AstDeclaration.\n * @remarks\n * The collection will be empty until AstSymbol.analyzed is true.\n */\n public get children(): ReadonlyArray<AstDeclaration> {\n return this.astSymbol.analyzed ? this._analyzedChildren : [];\n }\n\n /**\n * Returns the AstEntity objects referenced by this node.\n * @remarks\n * NOTE: The collection will be empty until AstSymbol.analyzed is true.\n *\n * Since we assume references are always collected by a traversal starting at the\n * root of the nesting declarations, this array omits the following items because they\n * would be redundant:\n * - symbols corresponding to parents of this declaration (e.g. a method that returns its own class)\n * - symbols already listed in the referencedAstSymbols property for parents of this declaration\n * (e.g. a method that returns its own class's base class)\n * - symbols that are referenced only by nested children of this declaration\n * (e.g. if a method returns an enum, this doesn't imply that the method's class references that enum)\n */\n public get referencedAstEntities(): ReadonlyArray<AstEntity> {\n return this.astSymbol.analyzed ? [...this._analyzedReferencedAstEntitiesSet] : [];\n }\n\n /**\n * This is an internal callback used when the AstSymbolTable attaches a new\n * child AstDeclaration to this object.\n * @internal\n */\n public _notifyChildAttach(child: AstDeclaration): void {\n if (child.parent !== this) {\n throw new InternalError('Invalid call to notifyChildAttach()');\n }\n\n if (this.astSymbol.analyzed) {\n throw new InternalError('_notifyChildAttach() called after analysis is already complete');\n }\n\n this._analyzedChildren.push(child);\n }\n\n /**\n * Returns a diagnostic dump of the tree, which reports the hierarchy of\n * AstDefinition objects.\n */\n public getDump(indent: string = ''): string {\n const declarationKind: string = ts.SyntaxKind[this.declaration.kind];\n let result: string = indent + `+ ${this.astSymbol.localName} (${declarationKind})`;\n if (this.astSymbol.nominalAnalysis) {\n result += ' (nominal)';\n }\n result += '\\n';\n\n for (const referencedAstEntity of this._analyzedReferencedAstEntitiesSet.values()) {\n result += indent + ` ref: ${referencedAstEntity.localName}\\n`;\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 using Span.getDump(), which reports the detailed\n * compiler structure.\n */\n public getSpanDump(indent: string = ''): string {\n const span: Span = new Span(this.declaration);\n return span.getDump(indent);\n }\n\n /**\n * This is an internal callback used when AstSymbolTable.analyze() discovers a new\n * type reference associated with this declaration.\n * @internal\n */\n public _notifyReferencedAstEntity(referencedAstEntity: AstEntity): void {\n if (this.astSymbol.analyzed) {\n throw new InternalError('_notifyReferencedAstEntity() called after analysis is already complete');\n }\n\n for (let current: AstDeclaration | undefined = this; current; current = current.parent) {\n // Don't add references to symbols that are already referenced by a parent\n if (current._analyzedReferencedAstEntitiesSet.has(referencedAstEntity)) {\n return;\n }\n // Don't add the symbols of parents either\n if (referencedAstEntity === current.astSymbol) {\n return;\n }\n }\n\n this._analyzedReferencedAstEntitiesSet.add(referencedAstEntity);\n }\n\n /**\n * Visits all the current declaration and all children recursively in a depth-first traversal,\n * and performs the specified action for each one.\n */\n public forEachDeclarationRecursive(action: (astDeclaration: AstDeclaration) => void): void {\n action(this);\n for (const child of this.children) {\n child.forEachDeclarationRecursive(action);\n }\n }\n\n /**\n * Returns the list of child declarations whose `AstSymbol.localName` matches the provided `name`.\n *\n * @remarks\n * This is an efficient O(1) lookup.\n */\n public findChildrenWithName(name: string): ReadonlyArray<AstDeclaration> {\n // The children property returns:\n //\n // return this.astSymbol.analyzed ? this._analyzedChildren : [];\n //\n if (!this.astSymbol.analyzed || this._analyzedChildren.length === 0) {\n return [];\n }\n\n if (this._childrenByName === undefined) {\n // Build the lookup table\n const childrenByName: Map<string, AstDeclaration[]> = new Map<string, AstDeclaration[]>();\n\n for (const child of this._analyzedChildren) {\n const childName: string = child.astSymbol.localName;\n let array: AstDeclaration[] | undefined = childrenByName.get(childName);\n if (array === undefined) {\n array = [];\n childrenByName.set(childName, array);\n }\n array.push(child);\n }\n this._childrenByName = childrenByName;\n }\n\n return this._childrenByName.get(name) || [];\n }\n\n /**\n * This function determines which ts.Node kinds will generate an AstDeclaration.\n * These correspond to the definitions that we can add AEDoc to.\n */\n public static isSupportedSyntaxKind(kind: ts.SyntaxKind): boolean {\n // (alphabetical order)\n switch (kind) {\n case ts.SyntaxKind.CallSignature:\n case ts.SyntaxKind.ClassDeclaration:\n case ts.SyntaxKind.ConstructSignature: // Example: \"new(x: number): IMyClass\"\n case ts.SyntaxKind.Constructor: // Example: \"constructor(x: number)\"\n case ts.SyntaxKind.EnumDeclaration:\n case ts.SyntaxKind.EnumMember:\n case ts.SyntaxKind.FunctionDeclaration: // Example: \"(x: number): number\"\n case ts.SyntaxKind.GetAccessor:\n case ts.SyntaxKind.SetAccessor:\n case ts.SyntaxKind.IndexSignature: // Example: \"[key: string]: string\"\n case ts.SyntaxKind.InterfaceDeclaration:\n case ts.SyntaxKind.MethodDeclaration:\n case ts.SyntaxKind.MethodSignature:\n case ts.SyntaxKind.ModuleDeclaration: // Used for both \"module\" and \"namespace\" declarations\n case ts.SyntaxKind.PropertyDeclaration:\n case ts.SyntaxKind.PropertySignature:\n case ts.SyntaxKind.TypeAliasDeclaration: // Example: \"type Shape = Circle | Square\"\n case ts.SyntaxKind.VariableDeclaration:\n return true;\n\n // NOTE: Prior to TypeScript 3.7, in the emitted .d.ts files, the compiler would merge a GetAccessor/SetAccessor\n // pair into a single PropertyDeclaration.\n\n // NOTE: In contexts where a source file is treated as a module, we do create \"nominal analysis\"\n // AstSymbol objects corresponding to a ts.SyntaxKind.SourceFile node. However, a source file\n // is NOT considered a nesting structure, and it does NOT act as a root for the declarations\n // appearing in the file. This is because the *.d.ts generator is in the business of rolling up\n // source files, and thus wants to ignore them in general.\n }\n\n return false;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"AstImport.d.ts","sourceRoot":"","sources":["../../src/analyzer/AstImport.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD;;GAEG;AACH,oBAAY,aAAa;IACvB;;OAEG;IACH,aAAa,IAAA;IAEb;;OAEG;IACH,WAAW,IAAA;IAEX;;OAEG;IACH,UAAU,IAAA;IAEV;;OAEG;IACH,YAAY,IAAA;IAEZ;;OAEG;IACH,UAAU,IAAA;CACX;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC;IACnC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;CAC9B;AAED;;;GAGG;AACH,qBAAa,SAAU,SAAQ,kBAAkB;IAC/C,SAAgB,UAAU,EAAE,aAAa,CAAC;IAE1C;;;;;OAKG;IACH,SAAgB,UAAU,EAAE,MAAM,CAAC;IAEnC;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,SAAgB,UAAU,EAAE,MAAM,CAAC;IAEnC;;;;;;;;OAQG;IACI,oBAAoB,EAAE,OAAO,CAAC;IAErC;;;;OAIG;IACI,SAAS,EAAE,SAAS,GAAG,SAAS,CAAC;IAExC;;;;;OAKG;IACH,SAA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AO,GAAG,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;YACvD,KAAK,aAAa,CAAC,UAAU;gBAC3B,OAAO,GAAG,OAAO,CAAC,UAAU,IAAI,CAAC;YACnC,KAAK,aAAa,CAAC,YAAY;gBAC7B,OAAO,GAAG,OAAO,CAAC,UAAU,IAAI,CAAC;YACnC,KAAK,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC;gBAC9B,MAAM,MAAM,GAAW,CAAC,OAAO,CAAC,UAAU;oBACxC,CAAC,CAAC,GAAG,CAAC,2BAA2B;oBACjC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,+BAA+B;wBAChE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;wBAClC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC;gBACzB,OAAO,GAAG,OAAO,CAAC,UAAU,IAAI,MAAM,EAAE,CAAC;YAC3C,CAAC;YACD;gBACE,MAAM,IAAI,iCAAa,CAAC,uBAAuB,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;CACF;AA3GD,8BA2GC","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 { AstSymbol } from './AstSymbol';\nimport { InternalError } from '@rushstack/node-core-library';\nimport { AstSyntheticEntity } from './AstEntity';\n\n/**\n * Indicates the import kind for an `AstImport`.\n */\nexport enum AstImportKind {\n /**\n * An import statement such as `import X from \"y\";`.\n */\n DefaultImport,\n\n /**\n * An import statement such as `import { X } from \"y\";`.\n */\n NamedImport,\n\n /**\n * An import statement such as `import * as x from \"y\";`.\n */\n StarImport,\n\n /**\n * An import statement such as `import x = require(\"y\");`.\n */\n EqualsImport,\n\n /**\n * An import statement such as `interface foo { foo: import(\"bar\").a.b.c }`.\n */\n ImportType\n}\n\n/**\n * Constructor parameters for AstImport\n *\n * @privateRemarks\n * Our naming convention is to use I____Parameters for constructor options and\n * I____Options for general function options. However the word \"parameters\" is\n * confusingly similar to the terminology for function parameters modeled by API Extractor,\n * so we use I____Options for both cases in this code base.\n */\nexport interface IAstImportOptions {\n readonly importKind: AstImportKind;\n readonly modulePath: string;\n readonly exportName: string;\n readonly isTypeOnly: boolean;\n}\n\n/**\n * For a symbol that was imported from an external package, this tracks the import\n * statement that was used to reach it.\n */\nexport class AstImport extends AstSyntheticEntity {\n public readonly importKind: AstImportKind;\n\n /**\n * The name of the external package (and possibly module path) that this definition\n * was imported from.\n *\n * Example: \"@rushstack/node-core-library/lib/FileSystem\"\n */\n public readonly modulePath: string;\n\n /**\n * The name of the symbol being imported.\n *\n * @remarks\n *\n * The name depends on the type of import:\n *\n * ```ts\n * // For AstImportKind.DefaultImport style, exportName would be \"X\" in this example:\n * import X from \"y\";\n *\n * // For AstImportKind.NamedImport style, exportName would be \"X\" in this example:\n * import { X } from \"y\";\n *\n * // For AstImportKind.StarImport style, exportName would be \"x\" in this example:\n * import * as x from \"y\";\n *\n * // For AstImportKind.EqualsImport style, exportName would be \"x\" in this example:\n * import x = require(\"y\");\n *\n * // For AstImportKind.ImportType style, exportName would be \"a.b.c\" in this example:\n * interface foo { foo: import('bar').a.b.c };\n * ```\n */\n public readonly exportName: string;\n\n /**\n * Whether it is a type-only import, for example:\n *\n * ```ts\n * import type { X } from \"y\";\n * ```\n *\n * This is set to true ONLY if the type-only form is used in *every* reference to this AstImport.\n */\n public isTypeOnlyEverywhere: boolean;\n\n /**\n * If this import statement refers to an API from an external package that is tracked by API Extractor\n * (according to `PackageMetadataManager.isAedocSupportedFor()`), then this property will return the\n * corresponding AstSymbol. Otherwise, it is undefined.\n */\n public astSymbol: AstSymbol | undefined;\n\n /**\n * If modulePath and exportName are defined, then this is a dictionary key\n * that combines them with a colon (\":\").\n *\n * Example: \"@rushstack/node-core-library/lib/FileSystem:FileSystem\"\n */\n public readonly key: string;\n\n public constructor(options: IAstImportOptions) {\n super();\n\n this.importKind = options.importKind;\n this.modulePath = options.modulePath;\n this.exportName = options.exportName;\n\n // We start with this assumption, but it may get changed later if non-type-only import is encountered.\n this.isTypeOnlyEverywhere = options.isTypeOnly;\n\n this.key = AstImport.getKey(options);\n }\n\n /** {@inheritdoc} */\n public get localName(): string {\n // abstract\n return this.exportName;\n }\n\n /**\n * Calculates the lookup key used with `AstImport.key`\n */\n public static getKey(options: IAstImportOptions): string {\n switch (options.importKind) {\n case AstImportKind.DefaultImport:\n return `${options.modulePath}:${options.exportName}`;\n case AstImportKind.NamedImport:\n return `${options.modulePath}:${options.exportName}`;\n case AstImportKind.StarImport:\n return `${options.modulePath}:*`;\n case AstImportKind.EqualsImport:\n return `${options.modulePath}:=`;\n case AstImportKind.ImportType: {\n const subKey: string = !options.exportName\n ? '*' // Equivalent to StarImport\n : options.exportName.includes('.') // Equivalent to a named export\n ? options.exportName.split('.')[0]\n : options.exportName;\n return `${options.modulePath}:${subKey}`;\n }\n default:\n throw new InternalError('Unknown AstImportKind');\n }\n }\n}\n"]}
1
+ {"version":3,"file":"AstImport.js","sourceRoot":"","sources":["../../src/analyzer/AstImport.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,oEAA6D;AAG7D,2CAAiD;AAEjD;;GAEG;AACH,IAAY,aAyBX;AAzBD,WAAY,aAAa;IACvB;;OAEG;IACH,mEAAa,CAAA;IAEb;;OAEG;IACH,+DAAW,CAAA;IAEX;;OAEG;IACH,6DAAU,CAAA;IAEV;;OAEG;IACH,iEAAY,CAAA;IAEZ;;OAEG;IACH,6DAAU,CAAA;AACZ,CAAC,EAzBW,aAAa,6BAAb,aAAa,QAyBxB;AAkBD;;;GAGG;AACH,MAAa,SAAU,SAAQ,8BAAkB;IA+D/C,YAAmB,OAA0B;QAC3C,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,UAAU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MAAM,IAAI,iCAAa,CAAC,uBAAuB,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;CACF;AA3GD,8BA2GC","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 { InternalError } from '@rushstack/node-core-library';\n\nimport type { AstSymbol } from './AstSymbol';\nimport { AstSyntheticEntity } from './AstEntity';\n\n/**\n * Indicates the import kind for an `AstImport`.\n */\nexport enum AstImportKind {\n /**\n * An import statement such as `import X from \"y\";`.\n */\n DefaultImport,\n\n /**\n * An import statement such as `import { X } from \"y\";`.\n */\n NamedImport,\n\n /**\n * An import statement such as `import * as x from \"y\";`.\n */\n StarImport,\n\n /**\n * An import statement such as `import x = require(\"y\");`.\n */\n EqualsImport,\n\n /**\n * An import statement such as `interface foo { foo: import(\"bar\").a.b.c }`.\n */\n ImportType\n}\n\n/**\n * Constructor parameters for AstImport\n *\n * @privateRemarks\n * Our naming convention is to use I____Parameters for constructor options and\n * I____Options for general function options. However the word \"parameters\" is\n * confusingly similar to the terminology for function parameters modeled by API Extractor,\n * so we use I____Options for both cases in this code base.\n */\nexport interface IAstImportOptions {\n readonly importKind: AstImportKind;\n readonly modulePath: string;\n readonly exportName: string;\n readonly isTypeOnly: boolean;\n}\n\n/**\n * For a symbol that was imported from an external package, this tracks the import\n * statement that was used to reach it.\n */\nexport class AstImport extends AstSyntheticEntity {\n public readonly importKind: AstImportKind;\n\n /**\n * The name of the external package (and possibly module path) that this definition\n * was imported from.\n *\n * Example: \"@rushstack/node-core-library/lib/FileSystem\"\n */\n public readonly modulePath: string;\n\n /**\n * The name of the symbol being imported.\n *\n * @remarks\n *\n * The name depends on the type of import:\n *\n * ```ts\n * // For AstImportKind.DefaultImport style, exportName would be \"X\" in this example:\n * import X from \"y\";\n *\n * // For AstImportKind.NamedImport style, exportName would be \"X\" in this example:\n * import { X } from \"y\";\n *\n * // For AstImportKind.StarImport style, exportName would be \"x\" in this example:\n * import * as x from \"y\";\n *\n * // For AstImportKind.EqualsImport style, exportName would be \"x\" in this example:\n * import x = require(\"y\");\n *\n * // For AstImportKind.ImportType style, exportName would be \"a.b.c\" in this example:\n * interface foo { foo: import('bar').a.b.c };\n * ```\n */\n public readonly exportName: string;\n\n /**\n * Whether it is a type-only import, for example:\n *\n * ```ts\n * import type { X } from \"y\";\n * ```\n *\n * This is set to true ONLY if the type-only form is used in *every* reference to this AstImport.\n */\n public isTypeOnlyEverywhere: boolean;\n\n /**\n * If this import statement refers to an API from an external package that is tracked by API Extractor\n * (according to `PackageMetadataManager.isAedocSupportedFor()`), then this property will return the\n * corresponding AstSymbol. Otherwise, it is undefined.\n */\n public astSymbol: AstSymbol | undefined;\n\n /**\n * If modulePath and exportName are defined, then this is a dictionary key\n * that combines them with a colon (\":\").\n *\n * Example: \"@rushstack/node-core-library/lib/FileSystem:FileSystem\"\n */\n public readonly key: string;\n\n public constructor(options: IAstImportOptions) {\n super();\n\n this.importKind = options.importKind;\n this.modulePath = options.modulePath;\n this.exportName = options.exportName;\n\n // We start with this assumption, but it may get changed later if non-type-only import is encountered.\n this.isTypeOnlyEverywhere = options.isTypeOnly;\n\n this.key = AstImport.getKey(options);\n }\n\n /** {@inheritdoc} */\n public get localName(): string {\n // abstract\n return this.exportName;\n }\n\n /**\n * Calculates the lookup key used with `AstImport.key`\n */\n public static getKey(options: IAstImportOptions): string {\n switch (options.importKind) {\n case AstImportKind.DefaultImport:\n return `${options.modulePath}:${options.exportName}`;\n case AstImportKind.NamedImport:\n return `${options.modulePath}:${options.exportName}`;\n case AstImportKind.StarImport:\n return `${options.modulePath}:*`;\n case AstImportKind.EqualsImport:\n return `${options.modulePath}:=`;\n case AstImportKind.ImportType: {\n const subKey: string = !options.exportName\n ? '*' // Equivalent to StarImport\n : options.exportName.includes('.') // Equivalent to a named export\n ? options.exportName.split('.')[0]\n : options.exportName;\n return `${options.modulePath}:${subKey}`;\n }\n default:\n throw new InternalError('Unknown AstImportKind');\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"AstReferenceResolver.d.ts","sourceRoot":"","sources":["../../src/analyzer/AstReferenceResolver.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAI1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAIxD;;;;;;;GAOG;AACH,qBAAa,eAAe;IAC1B;;OAEG;IACH,SAAgB,MAAM,EAAE,MAAM,CAAC;gBAEZ,MAAM,EAAE,MAAM;CAGlC;AAED;;;;;;;GAOG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAY;IACvC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAiB;IACjD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAiB;gBAE9B,SAAS,EAAE,SAAS;IAMhC,OAAO,CAAC,oBAAoB,EAAE,KAAK,CAAC,uBAAuB,GAAG,cAAc,GAAG,eAAe;IAoFrG,OAAO,CAAC,6BAA6B;IAUrC,OAAO,CAAC,kBAAkB;IAoC1B,OAAO,CAAC,0BAA0B;IA2DlC,OAAO,CAAC,yBAAyB;IAqCjC;;;OAGG;IACH,OAAO,CAAC,gCAAgC;CAgBzC"}
1
+ {"version":3,"file":"AstReferenceResolver.d.ts","sourceRoot":"","sources":["../../src/analyzer/AstReferenceResolver.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAI1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAIxD;;;;;;;GAOG;AACH,qBAAa,eAAe;IAC1B;;OAEG;IACH,SAAgB,MAAM,EAAE,MAAM,CAAC;gBAEZ,MAAM,EAAE,MAAM;CAGlC;AAED;;;;;;;GAOG;AAC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CAAC;IAChB,CAAC;CACF;AAjQD,oDAiQC","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 * as tsdoc from '@microsoft/tsdoc';\n\nimport type { AstSymbolTable } from './AstSymbolTable';\nimport type { AstEntity } from './AstEntity';\nimport type { AstDeclaration } from './AstDeclaration';\nimport type { WorkingPackage } from '../collector/WorkingPackage';\nimport type { AstModule } from './AstModule';\nimport type { Collector } from '../collector/Collector';\nimport type { DeclarationMetadata } from '../collector/DeclarationMetadata';\nimport { AstSymbol } from './AstSymbol';\n\n/**\n * Used by `AstReferenceResolver` to report a failed resolution.\n *\n * @privateRemarks\n * This class is similar to an `Error` object, but the intent of `ResolverFailure` is to describe\n * why a reference could not be resolved. This information could be used to throw an actual `Error` object,\n * but normally it is handed off to the `MessageRouter` instead.\n */\nexport class ResolverFailure {\n /**\n * Details about why the failure occurred.\n */\n public readonly reason: string;\n\n public constructor(reason: string) {\n this.reason = reason;\n }\n}\n\n/**\n * This resolves a TSDoc declaration reference by walking the `AstSymbolTable` compiler state.\n *\n * @remarks\n *\n * This class is analogous to `ModelReferenceResolver` from the `@microsoft/api-extractor-model` project,\n * which resolves declaration references by walking the hierarchy loaded from an .api.json file.\n */\nexport class AstReferenceResolver {\n private readonly _collector: Collector;\n private readonly _astSymbolTable: AstSymbolTable;\n private readonly _workingPackage: WorkingPackage;\n\n public constructor(collector: Collector) {\n this._collector = collector;\n this._astSymbolTable = collector.astSymbolTable;\n this._workingPackage = collector.workingPackage;\n }\n\n public resolve(declarationReference: tsdoc.DocDeclarationReference): AstDeclaration | ResolverFailure {\n // Is it referring to the working package?\n if (\n declarationReference.packageName !== undefined &&\n declarationReference.packageName !== this._workingPackage.name\n ) {\n return new ResolverFailure('External package references are not supported');\n }\n\n // Is it a path-based import?\n if (declarationReference.importPath) {\n return new ResolverFailure('Import paths are not supported');\n }\n\n const astModule: AstModule = this._astSymbolTable.fetchAstModuleFromWorkingPackage(\n this._workingPackage.entryPointSourceFile\n );\n\n if (declarationReference.memberReferences.length === 0) {\n return new ResolverFailure('Package references are not supported');\n }\n\n const rootMemberReference: tsdoc.DocMemberReference = declarationReference.memberReferences[0];\n\n const exportName: string | ResolverFailure = this._getMemberReferenceIdentifier(rootMemberReference);\n if (exportName instanceof ResolverFailure) {\n return exportName;\n }\n\n const rootAstEntity: AstEntity | undefined = this._astSymbolTable.tryGetExportOfAstModule(\n exportName,\n astModule\n );\n\n if (rootAstEntity === undefined) {\n return new ResolverFailure(\n `The package \"${this._workingPackage.name}\" does not have an export \"${exportName}\"`\n );\n }\n\n if (!(rootAstEntity instanceof AstSymbol)) {\n return new ResolverFailure('This type of declaration is not supported yet by the resolver');\n }\n\n let currentDeclaration: AstDeclaration | ResolverFailure = this._selectDeclaration(\n rootAstEntity.astDeclarations,\n rootMemberReference,\n rootAstEntity.localName\n );\n\n if (currentDeclaration instanceof ResolverFailure) {\n return currentDeclaration;\n }\n\n for (let index: number = 1; index < declarationReference.memberReferences.length; ++index) {\n const memberReference: tsdoc.DocMemberReference = declarationReference.memberReferences[index];\n\n const memberName: string | ResolverFailure = this._getMemberReferenceIdentifier(memberReference);\n if (memberName instanceof ResolverFailure) {\n return memberName;\n }\n\n const matchingChildren: ReadonlyArray<AstDeclaration> =\n currentDeclaration.findChildrenWithName(memberName);\n if (matchingChildren.length === 0) {\n return new ResolverFailure(`No member was found with name \"${memberName}\"`);\n }\n\n const selectedDeclaration: AstDeclaration | ResolverFailure = this._selectDeclaration(\n matchingChildren,\n memberReference,\n memberName\n );\n\n if (selectedDeclaration instanceof ResolverFailure) {\n return selectedDeclaration;\n }\n\n currentDeclaration = selectedDeclaration;\n }\n\n return currentDeclaration;\n }\n\n private _getMemberReferenceIdentifier(memberReference: tsdoc.DocMemberReference): string | ResolverFailure {\n if (memberReference.memberSymbol !== undefined) {\n return new ResolverFailure('ECMAScript symbol selectors are not supported');\n }\n if (memberReference.memberIdentifier === undefined) {\n return new ResolverFailure('The member identifier is missing in the root member reference');\n }\n return memberReference.memberIdentifier.identifier;\n }\n\n private _selectDeclaration(\n astDeclarations: ReadonlyArray<AstDeclaration>,\n memberReference: tsdoc.DocMemberReference,\n astSymbolName: string\n ): AstDeclaration | ResolverFailure {\n const memberSelector: tsdoc.DocMemberSelector | undefined = memberReference.selector;\n\n if (memberSelector === undefined) {\n if (astDeclarations.length === 1) {\n return astDeclarations[0];\n } else {\n // If we found multiple matches, but the extra ones are all ancillary declarations,\n // then return the main declaration.\n const nonAncillaryMatch: AstDeclaration | undefined =\n this._tryDisambiguateAncillaryMatches(astDeclarations);\n if (nonAncillaryMatch) {\n return nonAncillaryMatch;\n }\n\n return new ResolverFailure(\n `The reference is ambiguous because \"${astSymbolName}\"` +\n ` has more than one declaration; you need to add a TSDoc member reference selector`\n );\n }\n }\n\n switch (memberSelector.selectorKind) {\n case tsdoc.SelectorKind.System:\n return this._selectUsingSystemSelector(astDeclarations, memberSelector, astSymbolName);\n case tsdoc.SelectorKind.Index:\n return this._selectUsingIndexSelector(astDeclarations, memberSelector, astSymbolName);\n }\n\n return new ResolverFailure(`The selector \"${memberSelector.selector}\" is not a supported selector type`);\n }\n\n private _selectUsingSystemSelector(\n astDeclarations: ReadonlyArray<AstDeclaration>,\n memberSelector: tsdoc.DocMemberSelector,\n astSymbolName: string\n ): AstDeclaration | ResolverFailure {\n const selectorName: string = memberSelector.selector;\n\n let selectorSyntaxKind: ts.SyntaxKind;\n\n switch (selectorName) {\n case 'class':\n selectorSyntaxKind = ts.SyntaxKind.ClassDeclaration;\n break;\n case 'enum':\n selectorSyntaxKind = ts.SyntaxKind.EnumDeclaration;\n break;\n case 'function':\n selectorSyntaxKind = ts.SyntaxKind.FunctionDeclaration;\n break;\n case 'interface':\n selectorSyntaxKind = ts.SyntaxKind.InterfaceDeclaration;\n break;\n case 'namespace':\n selectorSyntaxKind = ts.SyntaxKind.ModuleDeclaration;\n break;\n case 'type':\n selectorSyntaxKind = ts.SyntaxKind.TypeAliasDeclaration;\n break;\n case 'variable':\n selectorSyntaxKind = ts.SyntaxKind.VariableDeclaration;\n break;\n default:\n return new ResolverFailure(`Unsupported system selector \"${selectorName}\"`);\n }\n\n const matches: AstDeclaration[] = astDeclarations.filter(\n (x) => x.declaration.kind === selectorSyntaxKind\n );\n if (matches.length === 0) {\n return new ResolverFailure(\n `A declaration for \"${astSymbolName}\" was not found that matches the` +\n ` TSDoc selector \"${selectorName}\"`\n );\n }\n if (matches.length > 1) {\n // If we found multiple matches, but the extra ones are all ancillary declarations,\n // then return the main declaration.\n const nonAncillaryMatch: AstDeclaration | undefined = this._tryDisambiguateAncillaryMatches(matches);\n if (nonAncillaryMatch) {\n return nonAncillaryMatch;\n }\n\n return new ResolverFailure(\n `More than one declaration \"${astSymbolName}\" matches the TSDoc selector \"${selectorName}\"`\n );\n }\n return matches[0];\n }\n\n private _selectUsingIndexSelector(\n astDeclarations: ReadonlyArray<AstDeclaration>,\n memberSelector: tsdoc.DocMemberSelector,\n astSymbolName: string\n ): AstDeclaration | ResolverFailure {\n const selectorOverloadIndex: number = parseInt(memberSelector.selector, 10);\n\n const matches: AstDeclaration[] = [];\n for (const astDeclaration of astDeclarations) {\n const overloadIndex: number = this._collector.getOverloadIndex(astDeclaration);\n if (overloadIndex === selectorOverloadIndex) {\n matches.push(astDeclaration);\n }\n }\n\n if (matches.length === 0) {\n return new ResolverFailure(\n `An overload for \"${astSymbolName}\" was not found that matches the` +\n ` TSDoc selector \":${selectorOverloadIndex}\"`\n );\n }\n if (matches.length > 1) {\n // If we found multiple matches, but the extra ones are all ancillary declarations,\n // then return the main declaration.\n const nonAncillaryMatch: AstDeclaration | undefined = this._tryDisambiguateAncillaryMatches(matches);\n if (nonAncillaryMatch) {\n return nonAncillaryMatch;\n }\n\n return new ResolverFailure(\n `More than one declaration for \"${astSymbolName}\" matches the` +\n ` TSDoc selector \":${selectorOverloadIndex}\"`\n );\n }\n return matches[0];\n }\n\n /**\n * This resolves an ambiguous match in the case where the extra matches are all ancillary declarations,\n * except for one match that is the main declaration.\n */\n private _tryDisambiguateAncillaryMatches(\n matches: ReadonlyArray<AstDeclaration>\n ): AstDeclaration | undefined {\n let result: AstDeclaration | undefined = undefined;\n\n for (const match of matches) {\n const declarationMetadata: DeclarationMetadata = this._collector.fetchDeclarationMetadata(match);\n if (!declarationMetadata.isAncillary) {\n if (result) {\n return undefined; // more than one match\n }\n result = match;\n }\n }\n return result;\n }\n}\n"]}
1
+ {"version":3,"file":"AstReferenceResolver.js","sourceRoot":"","sources":["../../src/analyzer/AstReferenceResolver.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,+CAAiC;AAEjC,wDAA0C;AAS1C,2CAAwC;AAExC;;;;;;;GAOG;AACH,MAAa,eAAe;IAM1B,YAAmB,MAAc;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AATD,0CASC;AAED;;;;;;;GAOG;AACH,MAAa,oBAAoB;IAK/B,YAAmB,SAAoB;QACrC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC,cAAc,CAAC;QAChD,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC,cAAc,CAAC;IAClD,CAAC;IAEM,OAAO,CAAC,oBAAmD;QAChE,0CAA0C;QAC1C,IACE,oBAAoB,CAAC,WAAW,KAAK,SAAS;YAC9C,oBAAoB,CAAC,WAAW,KAAK,IAAI,CAAC,eAAe,CAAC,IAAI,EAC9D,CAAC;YACD,OAAO,IAAI,eAAe,CAAC,+CAA+C,CAAC,CAAC;QAC9E,CAAC;QAED,6BAA6B;QAC7B,IAAI,oBAAoB,CAAC,UAAU,EAAE,CAAC;YACpC,OAAO,IAAI,eAAe,CAAC,gCAAgC,CAAC,CAAC;QAC/D,CAAC;QAED,MAAM,SAAS,GAAc,I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AAc,CAAC,CAAC;YAC/E,IAAI,aAAa,KAAK,qBAAqB,EAAE,CAAC;gBAC5C,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC;QAED,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,IAAI,eAAe,CACxB,oBAAoB,aAAa,kCAAkC;gBACjE,qBAAqB,qBAAqB,GAAG,CAChD,CAAC;QACJ,CAAC;QACD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,mFAAmF;YACnF,oCAAoC;YACpC,MAAM,iBAAiB,GAA+B,IAAI,CAAC,gCAAgC,CAAC,OAAO,CAAC,CAAC;YACrG,IAAI,iBAAiB,EAAE,CAAC;gBACtB,OAAO,iBAAiB,CAAC;YAC3B,CAAC;YAED,OAAO,IAAI,eAAe,CACxB,kCAAkC,aAAa,eAAe;gBAC5D,qBAAqB,qBAAqB,GAAG,CAChD,CAAC;QACJ,CAAC;QACD,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IAED;;;OAGG;IACK,gCAAgC,CACtC,OAAsC;QAEtC,IAAI,MAAM,GAA+B,SAAS,CAAC;QAEnD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC5B,MAAM,mBAAmB,GAAwB,IAAI,CAAC,UAAU,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC;YACjG,IAAI,CAAC,mBAAmB,CAAC,WAAW,EAAE,CAAC;gBACrC,IAAI,MAAM,EAAE,CAAC;oBACX,OAAO,SAAS,CAAC,CAAC,sBAAsB;gBAC1C,CAAC;gBACD,MAAM,GAAG,KAAK,CAAC;YACjB,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAjQD,oDAiQC","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';\n\nimport * as tsdoc from '@microsoft/tsdoc';\n\nimport type { AstSymbolTable } from './AstSymbolTable';\nimport type { AstEntity } from './AstEntity';\nimport type { AstDeclaration } from './AstDeclaration';\nimport type { WorkingPackage } from '../collector/WorkingPackage';\nimport type { AstModule } from './AstModule';\nimport type { Collector } from '../collector/Collector';\nimport type { DeclarationMetadata } from '../collector/DeclarationMetadata';\nimport { AstSymbol } from './AstSymbol';\n\n/**\n * Used by `AstReferenceResolver` to report a failed resolution.\n *\n * @privateRemarks\n * This class is similar to an `Error` object, but the intent of `ResolverFailure` is to describe\n * why a reference could not be resolved. This information could be used to throw an actual `Error` object,\n * but normally it is handed off to the `MessageRouter` instead.\n */\nexport class ResolverFailure {\n /**\n * Details about why the failure occurred.\n */\n public readonly reason: string;\n\n public constructor(reason: string) {\n this.reason = reason;\n }\n}\n\n/**\n * This resolves a TSDoc declaration reference by walking the `AstSymbolTable` compiler state.\n *\n * @remarks\n *\n * This class is analogous to `ModelReferenceResolver` from the `@microsoft/api-extractor-model` project,\n * which resolves declaration references by walking the hierarchy loaded from an .api.json file.\n */\nexport class AstReferenceResolver {\n private readonly _collector: Collector;\n private readonly _astSymbolTable: AstSymbolTable;\n private readonly _workingPackage: WorkingPackage;\n\n public constructor(collector: Collector) {\n this._collector = collector;\n this._astSymbolTable = collector.astSymbolTable;\n this._workingPackage = collector.workingPackage;\n }\n\n public resolve(declarationReference: tsdoc.DocDeclarationReference): AstDeclaration | ResolverFailure {\n // Is it referring to the working package?\n if (\n declarationReference.packageName !== undefined &&\n declarationReference.packageName !== this._workingPackage.name\n ) {\n return new ResolverFailure('External package references are not supported');\n }\n\n // Is it a path-based import?\n if (declarationReference.importPath) {\n return new ResolverFailure('Import paths are not supported');\n }\n\n const astModule: AstModule = this._astSymbolTable.fetchAstModuleFromWorkingPackage(\n this._workingPackage.entryPointSourceFile\n );\n\n if (declarationReference.memberReferences.length === 0) {\n return new ResolverFailure('Package references are not supported');\n }\n\n const rootMemberReference: tsdoc.DocMemberReference = declarationReference.memberReferences[0];\n\n const exportName: string | ResolverFailure = this._getMemberReferenceIdentifier(rootMemberReference);\n if (exportName instanceof ResolverFailure) {\n return exportName;\n }\n\n const rootAstEntity: AstEntity | undefined = this._astSymbolTable.tryGetExportOfAstModule(\n exportName,\n astModule\n );\n\n if (rootAstEntity === undefined) {\n return new ResolverFailure(\n `The package \"${this._workingPackage.name}\" does not have an export \"${exportName}\"`\n );\n }\n\n if (!(rootAstEntity instanceof AstSymbol)) {\n return new ResolverFailure('This type of declaration is not supported yet by the resolver');\n }\n\n let currentDeclaration: AstDeclaration | ResolverFailure = this._selectDeclaration(\n rootAstEntity.astDeclarations,\n rootMemberReference,\n rootAstEntity.localName\n );\n\n if (currentDeclaration instanceof ResolverFailure) {\n return currentDeclaration;\n }\n\n for (let index: number = 1; index < declarationReference.memberReferences.length; ++index) {\n const memberReference: tsdoc.DocMemberReference = declarationReference.memberReferences[index];\n\n const memberName: string | ResolverFailure = this._getMemberReferenceIdentifier(memberReference);\n if (memberName instanceof ResolverFailure) {\n return memberName;\n }\n\n const matchingChildren: ReadonlyArray<AstDeclaration> =\n currentDeclaration.findChildrenWithName(memberName);\n if (matchingChildren.length === 0) {\n return new ResolverFailure(`No member was found with name \"${memberName}\"`);\n }\n\n const selectedDeclaration: AstDeclaration | ResolverFailure = this._selectDeclaration(\n matchingChildren,\n memberReference,\n memberName\n );\n\n if (selectedDeclaration instanceof ResolverFailure) {\n return selectedDeclaration;\n }\n\n currentDeclaration = selectedDeclaration;\n }\n\n return currentDeclaration;\n }\n\n private _getMemberReferenceIdentifier(memberReference: tsdoc.DocMemberReference): string | ResolverFailure {\n if (memberReference.memberSymbol !== undefined) {\n return new ResolverFailure('ECMAScript symbol selectors are not supported');\n }\n if (memberReference.memberIdentifier === undefined) {\n return new ResolverFailure('The member identifier is missing in the root member reference');\n }\n return memberReference.memberIdentifier.identifier;\n }\n\n private _selectDeclaration(\n astDeclarations: ReadonlyArray<AstDeclaration>,\n memberReference: tsdoc.DocMemberReference,\n astSymbolName: string\n ): AstDeclaration | ResolverFailure {\n const memberSelector: tsdoc.DocMemberSelector | undefined = memberReference.selector;\n\n if (memberSelector === undefined) {\n if (astDeclarations.length === 1) {\n return astDeclarations[0];\n } else {\n // If we found multiple matches, but the extra ones are all ancillary declarations,\n // then return the main declaration.\n const nonAncillaryMatch: AstDeclaration | undefined =\n this._tryDisambiguateAncillaryMatches(astDeclarations);\n if (nonAncillaryMatch) {\n return nonAncillaryMatch;\n }\n\n return new ResolverFailure(\n `The reference is ambiguous because \"${astSymbolName}\"` +\n ` has more than one declaration; you need to add a TSDoc member reference selector`\n );\n }\n }\n\n switch (memberSelector.selectorKind) {\n case tsdoc.SelectorKind.System:\n return this._selectUsingSystemSelector(astDeclarations, memberSelector, astSymbolName);\n case tsdoc.SelectorKind.Index:\n return this._selectUsingIndexSelector(astDeclarations, memberSelector, astSymbolName);\n }\n\n return new ResolverFailure(`The selector \"${memberSelector.selector}\" is not a supported selector type`);\n }\n\n private _selectUsingSystemSelector(\n astDeclarations: ReadonlyArray<AstDeclaration>,\n memberSelector: tsdoc.DocMemberSelector,\n astSymbolName: string\n ): AstDeclaration | ResolverFailure {\n const selectorName: string = memberSelector.selector;\n\n let selectorSyntaxKind: ts.SyntaxKind;\n\n switch (selectorName) {\n case 'class':\n selectorSyntaxKind = ts.SyntaxKind.ClassDeclaration;\n break;\n case 'enum':\n selectorSyntaxKind = ts.SyntaxKind.EnumDeclaration;\n break;\n case 'function':\n selectorSyntaxKind = ts.SyntaxKind.FunctionDeclaration;\n break;\n case 'interface':\n selectorSyntaxKind = ts.SyntaxKind.InterfaceDeclaration;\n break;\n case 'namespace':\n selectorSyntaxKind = ts.SyntaxKind.ModuleDeclaration;\n break;\n case 'type':\n selectorSyntaxKind = ts.SyntaxKind.TypeAliasDeclaration;\n break;\n case 'variable':\n selectorSyntaxKind = ts.SyntaxKind.VariableDeclaration;\n break;\n default:\n return new ResolverFailure(`Unsupported system selector \"${selectorName}\"`);\n }\n\n const matches: AstDeclaration[] = astDeclarations.filter(\n (x) => x.declaration.kind === selectorSyntaxKind\n );\n if (matches.length === 0) {\n return new ResolverFailure(\n `A declaration for \"${astSymbolName}\" was not found that matches the` +\n ` TSDoc selector \"${selectorName}\"`\n );\n }\n if (matches.length > 1) {\n // If we found multiple matches, but the extra ones are all ancillary declarations,\n // then return the main declaration.\n const nonAncillaryMatch: AstDeclaration | undefined = this._tryDisambiguateAncillaryMatches(matches);\n if (nonAncillaryMatch) {\n return nonAncillaryMatch;\n }\n\n return new ResolverFailure(\n `More than one declaration \"${astSymbolName}\" matches the TSDoc selector \"${selectorName}\"`\n );\n }\n return matches[0];\n }\n\n private _selectUsingIndexSelector(\n astDeclarations: ReadonlyArray<AstDeclaration>,\n memberSelector: tsdoc.DocMemberSelector,\n astSymbolName: string\n ): AstDeclaration | ResolverFailure {\n const selectorOverloadIndex: number = parseInt(memberSelector.selector, 10);\n\n const matches: AstDeclaration[] = [];\n for (const astDeclaration of astDeclarations) {\n const overloadIndex: number = this._collector.getOverloadIndex(astDeclaration);\n if (overloadIndex === selectorOverloadIndex) {\n matches.push(astDeclaration);\n }\n }\n\n if (matches.length === 0) {\n return new ResolverFailure(\n `An overload for \"${astSymbolName}\" was not found that matches the` +\n ` TSDoc selector \":${selectorOverloadIndex}\"`\n );\n }\n if (matches.length > 1) {\n // If we found multiple matches, but the extra ones are all ancillary declarations,\n // then return the main declaration.\n const nonAncillaryMatch: AstDeclaration | undefined = this._tryDisambiguateAncillaryMatches(matches);\n if (nonAncillaryMatch) {\n return nonAncillaryMatch;\n }\n\n return new ResolverFailure(\n `More than one declaration for \"${astSymbolName}\" matches the` +\n ` TSDoc selector \":${selectorOverloadIndex}\"`\n );\n }\n return matches[0];\n }\n\n /**\n * This resolves an ambiguous match in the case where the extra matches are all ancillary declarations,\n * except for one match that is the main declaration.\n */\n private _tryDisambiguateAncillaryMatches(\n matches: ReadonlyArray<AstDeclaration>\n ): AstDeclaration | undefined {\n let result: AstDeclaration | undefined = undefined;\n\n for (const match of matches) {\n const declarationMetadata: DeclarationMetadata = this._collector.fetchDeclarationMetadata(match);\n if (!declarationMetadata.isAncillary) {\n if (result) {\n return undefined; // more than one match\n }\n result = match;\n }\n }\n return result;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"AstSymbol.d.ts","sourceRoot":"","sources":["../../src/analyzer/AstSymbol.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,cAAc,EAAE,EAAE,CAAC,MAAM,CAAC;IACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,eAAe,EAAE,SAAS,GAAG,SAAS,CAAC;IAChD,QAAQ,CAAC,aAAa,EAAE,SAAS,GAAG,SAAS,CAAC;CAC/C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,qBAAa,SAAU,SAAQ,SAAS;IACtC,oBAAoB;IACpB,SAAgB,SAAS,EAAE,MAAM,CAAC;IAElC;;;;OAIG;IACH,SAAgB,UAAU,EAAE,OAAO,CAAC;IAEpC;;;;;;;OAOG;IACH,SAAgB,cAAc,EAAE,EAAE,CAAC,MAAM,CAAC;IAE1C;;;;;;OAMG;IACH,SAAgB,eAAe,EAAE,OAAO,CAAC;IAEzC;;;;;;;;OAQG;IACH,SAAgB,eAAe,EAAE,SAAS,GAAG,SAAS,CAAC;IAEvD;;;;OAIG;IACH,SAAgB,aAAa,EAAE,SAAS,CAAC;IAEzC;;;;OAIG;IACI,cAAc,EAAE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AU,CAAC;QACrC,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;QAC/C,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;QAC/C,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,IAAI,CAAC;QACnD,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;IAC7B,CAAC;IAED;;;;;;;OAOG;IACH,IAAW,eAAe;QACxB,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC/B,CAAC;IAED;;;;;;OAMG;IACH,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC;IACtC,CAAC;IAED;;;;OAIG;IACI,wBAAwB,CAAC,cAA8B;QAC5D,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,MAAM,IAAI,iCAAa,CAAC,sEAAsE,CAAC,CAAC;QAClG,CAAC;QACD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAC7C,CAAC;IAED;;;;OAIG;IACI,eAAe;QACpB,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YACzB,MAAM,IAAI,iCAAa,CAAC,iEAAiE,CAAC,CAAC;QAC7F,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;IAED;;OAEG;IACI,2BAA2B,CAAC,MAAgD;QACjF,KAAK,MAAM,cAAc,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YAClD,cAAc,CAAC,2BAA2B,CAAC,MAAM,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;CACF;AAhID,8BAgIC","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 type { AstDeclaration } from './AstDeclaration';\nimport { InternalError } from '@rushstack/node-core-library';\nimport { AstEntity } from './AstEntity';\n\n/**\n * Constructor options for AstSymbol\n */\nexport interface IAstSymbolOptions {\n readonly followedSymbol: ts.Symbol;\n readonly localName: string;\n readonly isExternal: boolean;\n readonly nominalAnalysis: boolean;\n readonly parentAstSymbol: AstSymbol | undefined;\n readonly rootAstSymbol: AstSymbol | undefined;\n}\n\n/**\n * The AstDeclaration and AstSymbol classes are API Extractor's equivalent of the compiler's\n * ts.Declaration and ts.Symbol objects. They are created by the `AstSymbolTable` class.\n *\n * @remarks\n * The AstSymbol represents the ts.Symbol information for an AstDeclaration. For example,\n * if a method has 3 overloads, each overloaded signature will have its own AstDeclaration,\n * but they will all share a common AstSymbol.\n *\n * For nested definitions, the AstSymbol has a unique parent (i.e. AstSymbol.rootAstSymbol),\n * but the parent/children for each AstDeclaration may be different. Consider this example:\n *\n * ```ts\n * export namespace N {\n * export function f(): void { }\n * }\n *\n * export interface N {\n * g(): void;\n * }\n * ```\n *\n * Note how the parent/child relationships are different for the symbol tree versus\n * the declaration tree, and the declaration tree has two roots:\n *\n * ```\n * AstSymbol tree: AstDeclaration tree:\n * - N - N (namespace)\n * - f - f\n * - g - N (interface)\n * - g\n * ```\n */\nexport class AstSymbol extends AstEntity {\n /** {@inheritdoc} */\n public readonly localName: string; // abstract\n\n /**\n * If true, then the `followedSymbol` (i.e. original declaration) of this symbol\n * is not part of the working package. The working package may still export this symbol,\n * but if so it should be emitted as an alias such as `export { X } from \"package1\";`.\n */\n public readonly isExternal: boolean;\n\n /**\n * The compiler symbol where this type was defined, after following any aliases.\n *\n * @remarks\n * This is a normal form that can be reached from any symbol alias by calling\n * `TypeScriptHelpers.followAliases()`. It can be compared to determine whether two\n * symbols refer to the same underlying type.\n */\n public readonly followedSymbol: ts.Symbol;\n\n /**\n * If true, then this AstSymbol represents a foreign object whose structure will be\n * ignored. The AstDeclaration objects will not have any parent or children, and its references\n * will not be analyzed.\n *\n * Nominal symbols are tracked e.g. when they are reexported by the working package.\n */\n public readonly nominalAnalysis: boolean;\n\n /**\n * Returns the symbol of the parent of this AstSymbol, or undefined if there is no parent.\n * @remarks\n * If a symbol has multiple declarations, we assume (as an axiom) that their parent\n * declarations will belong to the same symbol. This means that the \"parent\" of a\n * symbol is a well-defined concept. However, the \"children\" of a symbol are not very\n * meaningful, because different declarations may have different nested members,\n * so we usually need to traverse declarations to find children.\n */\n public readonly parentAstSymbol: AstSymbol | undefined;\n\n /**\n * Returns the symbol of the root of the AstDeclaration hierarchy.\n * @remarks\n * NOTE: If this AstSymbol is the root, then rootAstSymbol will point to itself.\n */\n public readonly rootAstSymbol: AstSymbol;\n\n /**\n * Additional information that is calculated later by the `Collector`. The actual type is `SymbolMetadata`,\n * but we declare it as `unknown` because consumers must obtain this object by calling\n * `Collector.fetchSymbolMetadata()`.\n */\n public symbolMetadata: unknown;\n\n private readonly _astDeclarations: AstDeclaration[];\n\n // This flag is unused if this is not the root symbol.\n // Being \"analyzed\" is a property of the root symbol.\n private _analyzed: boolean = false;\n\n public constructor(options: IAstSymbolOptions) {\n super();\n\n this.followedSymbol = options.followedSymbol;\n this.localName = options.localName;\n this.isExternal = options.isExternal;\n this.nominalAnalysis = options.nominalAnalysis;\n this.parentAstSymbol = options.parentAstSymbol;\n this.rootAstSymbol = options.rootAstSymbol || this;\n this._astDeclarations = [];\n }\n\n /**\n * The one or more declarations for this symbol.\n * @remarks\n * For example, if this symbol is a method, then the declarations might be\n * various method overloads. If this symbol is a namespace, then the declarations\n * might be separate namespace blocks with the same name that get combined via\n * declaration merging.\n */\n public get astDeclarations(): ReadonlyArray<AstDeclaration> {\n return this._astDeclarations;\n }\n\n /**\n * Returns true if the AstSymbolTable.analyze() was called for this object.\n * See that function for details.\n * @remarks\n * AstSymbolTable.analyze() is always performed on the root AstSymbol. This function\n * returns true if-and-only-if the root symbol was analyzed.\n */\n public get analyzed(): boolean {\n return this.rootAstSymbol._analyzed;\n }\n\n /**\n * This is an internal callback used when the AstSymbolTable attaches a new\n * AstDeclaration to this object.\n * @internal\n */\n public _notifyDeclarationAttach(astDeclaration: AstDeclaration): void {\n if (this.analyzed) {\n throw new InternalError('_notifyDeclarationAttach() called after analysis is already complete');\n }\n this._astDeclarations.push(astDeclaration);\n }\n\n /**\n * This is an internal callback used when the AstSymbolTable.analyze()\n * has processed this object.\n * @internal\n */\n public _notifyAnalyzed(): void {\n if (this.parentAstSymbol) {\n throw new InternalError('_notifyAnalyzed() called for an AstSymbol which is not the root');\n }\n this._analyzed = true;\n }\n\n /**\n * Helper that calls AstDeclaration.forEachDeclarationRecursive() for each AstDeclaration.\n */\n public forEachDeclarationRecursive(action: (astDeclaration: AstDeclaration) => void): void {\n for (const astDeclaration of this.astDeclarations) {\n astDeclaration.forEachDeclarationRecursive(action);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"AstSymbol.js","sourceRoot":"","sources":["../../src/analyzer/AstSymbol.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAI3D,oEAA6D;AAG7D,2CAAwC;AAcxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAa,SAAU,SAAQ,qBAAS;IA6DtC,YAAmB,OAA0B;QAC3C,KAAK,EAAE,CAAC;QALV,sDAAsD;QACtD,qDAAqD;QAC7C,cAAS,GAAY,KAAK,CAAC;QAKjC,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;QAC7C,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;QAC/C,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;QAC/C,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,IAAI,CAAC;QACnD,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;IAC7B,CAAC;IAED;;;;;;;OAOG;IACH,IAAW,eAAe;QACxB,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC/B,CAAC;IAED;;;;;;OAMG;IACH,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC;IACtC,CAAC;IAED;;;;OAIG;IACI,wBAAwB,CAAC,cAA8B;QAC5D,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,MAAM,IAAI,iCAAa,CAAC,sEAAsE,CAAC,CAAC;QAClG,CAAC;QACD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAC7C,CAAC;IAED;;;;OAIG;IACI,eAAe;QACpB,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YACzB,MAAM,IAAI,iCAAa,CAAC,iEAAiE,CAAC,CAAC;QAC7F,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;IAED;;OAEG;IACI,2BAA2B,CAAC,MAAgD;QACjF,KAAK,MAAM,cAAc,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YAClD,cAAc,CAAC,2BAA2B,CAAC,MAAM,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;CACF;AAhID,8BAgIC","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';\n\nimport { InternalError } from '@rushstack/node-core-library';\n\nimport type { AstDeclaration } from './AstDeclaration';\nimport { AstEntity } from './AstEntity';\n\n/**\n * Constructor options for AstSymbol\n */\nexport interface IAstSymbolOptions {\n readonly followedSymbol: ts.Symbol;\n readonly localName: string;\n readonly isExternal: boolean;\n readonly nominalAnalysis: boolean;\n readonly parentAstSymbol: AstSymbol | undefined;\n readonly rootAstSymbol: AstSymbol | undefined;\n}\n\n/**\n * The AstDeclaration and AstSymbol classes are API Extractor's equivalent of the compiler's\n * ts.Declaration and ts.Symbol objects. They are created by the `AstSymbolTable` class.\n *\n * @remarks\n * The AstSymbol represents the ts.Symbol information for an AstDeclaration. For example,\n * if a method has 3 overloads, each overloaded signature will have its own AstDeclaration,\n * but they will all share a common AstSymbol.\n *\n * For nested definitions, the AstSymbol has a unique parent (i.e. AstSymbol.rootAstSymbol),\n * but the parent/children for each AstDeclaration may be different. Consider this example:\n *\n * ```ts\n * export namespace N {\n * export function f(): void { }\n * }\n *\n * export interface N {\n * g(): void;\n * }\n * ```\n *\n * Note how the parent/child relationships are different for the symbol tree versus\n * the declaration tree, and the declaration tree has two roots:\n *\n * ```\n * AstSymbol tree: AstDeclaration tree:\n * - N - N (namespace)\n * - f - f\n * - g - N (interface)\n * - g\n * ```\n */\nexport class AstSymbol extends AstEntity {\n /** {@inheritdoc} */\n public readonly localName: string; // abstract\n\n /**\n * If true, then the `followedSymbol` (i.e. original declaration) of this symbol\n * is not part of the working package. The working package may still export this symbol,\n * but if so it should be emitted as an alias such as `export { X } from \"package1\";`.\n */\n public readonly isExternal: boolean;\n\n /**\n * The compiler symbol where this type was defined, after following any aliases.\n *\n * @remarks\n * This is a normal form that can be reached from any symbol alias by calling\n * `TypeScriptHelpers.followAliases()`. It can be compared to determine whether two\n * symbols refer to the same underlying type.\n */\n public readonly followedSymbol: ts.Symbol;\n\n /**\n * If true, then this AstSymbol represents a foreign object whose structure will be\n * ignored. The AstDeclaration objects will not have any parent or children, and its references\n * will not be analyzed.\n *\n * Nominal symbols are tracked e.g. when they are reexported by the working package.\n */\n public readonly nominalAnalysis: boolean;\n\n /**\n * Returns the symbol of the parent of this AstSymbol, or undefined if there is no parent.\n * @remarks\n * If a symbol has multiple declarations, we assume (as an axiom) that their parent\n * declarations will belong to the same symbol. This means that the \"parent\" of a\n * symbol is a well-defined concept. However, the \"children\" of a symbol are not very\n * meaningful, because different declarations may have different nested members,\n * so we usually need to traverse declarations to find children.\n */\n public readonly parentAstSymbol: AstSymbol | undefined;\n\n /**\n * Returns the symbol of the root of the AstDeclaration hierarchy.\n * @remarks\n * NOTE: If this AstSymbol is the root, then rootAstSymbol will point to itself.\n */\n public readonly rootAstSymbol: AstSymbol;\n\n /**\n * Additional information that is calculated later by the `Collector`. The actual type is `SymbolMetadata`,\n * but we declare it as `unknown` because consumers must obtain this object by calling\n * `Collector.fetchSymbolMetadata()`.\n */\n public symbolMetadata: unknown;\n\n private readonly _astDeclarations: AstDeclaration[];\n\n // This flag is unused if this is not the root symbol.\n // Being \"analyzed\" is a property of the root symbol.\n private _analyzed: boolean = false;\n\n public constructor(options: IAstSymbolOptions) {\n super();\n\n this.followedSymbol = options.followedSymbol;\n this.localName = options.localName;\n this.isExternal = options.isExternal;\n this.nominalAnalysis = options.nominalAnalysis;\n this.parentAstSymbol = options.parentAstSymbol;\n this.rootAstSymbol = options.rootAstSymbol || this;\n this._astDeclarations = [];\n }\n\n /**\n * The one or more declarations for this symbol.\n * @remarks\n * For example, if this symbol is a method, then the declarations might be\n * various method overloads. If this symbol is a namespace, then the declarations\n * might be separate namespace blocks with the same name that get combined via\n * declaration merging.\n */\n public get astDeclarations(): ReadonlyArray<AstDeclaration> {\n return this._astDeclarations;\n }\n\n /**\n * Returns true if the AstSymbolTable.analyze() was called for this object.\n * See that function for details.\n * @remarks\n * AstSymbolTable.analyze() is always performed on the root AstSymbol. This function\n * returns true if-and-only-if the root symbol was analyzed.\n */\n public get analyzed(): boolean {\n return this.rootAstSymbol._analyzed;\n }\n\n /**\n * This is an internal callback used when the AstSymbolTable attaches a new\n * AstDeclaration to this object.\n * @internal\n */\n public _notifyDeclarationAttach(astDeclaration: AstDeclaration): void {\n if (this.analyzed) {\n throw new InternalError('_notifyDeclarationAttach() called after analysis is already complete');\n }\n this._astDeclarations.push(astDeclaration);\n }\n\n /**\n * This is an internal callback used when the AstSymbolTable.analyze()\n * has processed this object.\n * @internal\n */\n public _notifyAnalyzed(): void {\n if (this.parentAstSymbol) {\n throw new InternalError('_notifyAnalyzed() called for an AstSymbol which is not the root');\n }\n this._analyzed = true;\n }\n\n /**\n * Helper that calls AstDeclaration.forEachDeclarationRecursive() for each AstDeclaration.\n */\n public forEachDeclarationRecursive(action: (astDeclaration: AstDeclaration) => void): void {\n for (const astDeclaration of this.astDeclarations) {\n astDeclaration.forEachDeclarationRecursive(action);\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"AstSymbolTable.d.ts","sourceRoot":"","sources":["../../src/analyzer/AstSymbolTable.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,KAAK,iBAAiB,EAAiB,MAAM,8BAA8B,CAAC;AAErF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,OAAO,KAAK,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAKhE;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,cAAc,EAAE,EAAE,CAAC,MAAM,CAAC;IAC1B;;OAEG;IACH,UAAU,EAAE,OAAO,CAAC;IAEpB;;;OAGG;IACH,sBAAsB,EAAE,OAAO,CAAC;IAEhC;;;OAGG;IACH,YAAY,EAAE,OAAO,CAAC;IAEtB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;GASG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAa;IACtC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAiB;IAC9C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAgB;IAC/C,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAA0B;IAClE,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAAyB;IACjE,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAiB;IACjD,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAAc;IAExD;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ,CAAC,mB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