@microsoft/api-extractor 7.52.15 → 7.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/CHANGELOG.json +29 -0
  2. package/CHANGELOG.md +8 -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
@@ -6,7 +6,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
6
6
  };
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.PackageMetadataManager = exports.PackageMetadata = void 0;
9
- const path_1 = __importDefault(require("path"));
9
+ const node_path_1 = __importDefault(require("node:path"));
10
10
  const semver_1 = __importDefault(require("semver"));
11
11
  const node_core_library_1 = require("@rushstack/node-core-library");
12
12
  const Extractor_1 = require("../api/Extractor");
@@ -43,28 +43,28 @@ function _tryResolveTsdocMetadataFromExportsField({ exports }) {
43
43
  var _a;
44
44
  switch (typeof exports) {
45
45
  case 'string': {
46
- return `${path_1.default.dirname(exports)}/${TSDOC_METADATA_FILENAME}`;
46
+ return `${node_path_1.default.dirname(exports)}/${TSDOC_METADATA_FILENAME}`;
47
47
  }
48
48
  case 'object': {
49
49
  if (Array.isArray(exports)) {
50
50
  const [firstExport] = exports;
51
51
  // Take the first entry in the array
52
52
  if (firstExport) {
53
- return `${path_1.default.dirname(exports[0])}/${TSDOC_METADATA_FILENAME}`;
53
+ return `${node_path_1.default.dirname(exports[0])}/${TSDOC_METADATA_FILENAME}`;
54
54
  }
55
55
  }
56
56
  else {
57
57
  const rootExport = (_a = exports['.']) !== null && _a !== void 0 ? _a : exports['*'];
58
58
  switch (typeof rootExport) {
59
59
  case 'string': {
60
- return `${path_1.default.dirname(rootExport)}/${TSDOC_METADATA_FILENAME}`;
60
+ return `${node_path_1.default.dirname(rootExport)}/${TSDOC_METADATA_FILENAME}`;
61
61
  }
62
62
  case 'object': {
63
63
  let typesExport = rootExport === null || rootExport === void 0 ? void 0 : rootExport.types;
64
64
  while (typesExport) {
65
65
  switch (typeof typesExport) {
66
66
  case 'string': {
67
- return `${path_1.default.dirname(typesExport)}/${TSDOC_METADATA_FILENAME}`;
67
+ return `${node_path_1.default.dirname(typesExport)}/${TSDOC_METADATA_FILENAME}`;
68
68
  }
69
69
  case 'object': {
70
70
  typesExport = typesExport === null || typesExport === void 0 ? void 0 : typesExport.types;
@@ -108,7 +108,7 @@ function _tryResolveTsdocMetadataFromTypesVersionsField({ typesVersions }) {
108
108
  }
109
109
  }
110
110
  if (latestMatchingPath) {
111
- return `${path_1.default.dirname(latestMatchingPath)}/${TSDOC_METADATA_FILENAME}`;
111
+ return `${node_path_1.default.dirname(latestMatchingPath)}/${TSDOC_METADATA_FILENAME}`;
112
112
  }
113
113
  }
114
114
  }
@@ -122,7 +122,7 @@ function _tryResolveTsdocMetadataFromTypesVersionsField({ typesVersions }) {
122
122
  function _tryResolveTsdocMetadataFromTypesOrTypingsFields({ typings, types }) {
123
123
  const typesField = types !== null && types !== void 0 ? types : typings;
124
124
  if (typesField) {
125
- return `${path_1.default.dirname(typesField)}/${TSDOC_METADATA_FILENAME}`;
125
+ return `${node_path_1.default.dirname(typesField)}/${TSDOC_METADATA_FILENAME}`;
126
126
  }
127
127
  }
128
128
  /**
@@ -131,7 +131,7 @@ function _tryResolveTsdocMetadataFromTypesOrTypingsFields({ typings, types }) {
131
131
  */
132
132
  function _tryResolveTsdocMetadataFromMainField({ main }) {
133
133
  if (main) {
134
- return `${path_1.default.dirname(main)}/${TSDOC_METADATA_FILENAME}`;
134
+ return `${node_path_1.default.dirname(main)}/${TSDOC_METADATA_FILENAME}`;
135
135
  }
136
136
  }
137
137
  /**
@@ -163,7 +163,7 @@ class PackageMetadataManager {
163
163
  // As a final fallback, place the file in the root of the package.
164
164
  TSDOC_METADATA_FILENAME;
165
165
  // Always resolve relative to the package folder.
166
- const tsdocMetadataPath = path_1.default.resolve(packageFolder,
166
+ const tsdocMetadataPath = node_path_1.default.resolve(packageFolder,
167
167
  // This non-null assertion is safe because the last entry in TSDOC_METADATA_RESOLUTION_FUNCTIONS
168
168
  // returns a non-undefined value.
169
169
  tsdocMetadataRelativePath);
@@ -176,7 +176,7 @@ class PackageMetadataManager {
176
176
  */
177
177
  static resolveTsdocMetadataPath(packageFolder, packageJson, tsdocMetadataPath) {
178
178
  if (tsdocMetadataPath) {
179
- return path_1.default.resolve(packageFolder, tsdocMetadataPath);
179
+ return node_path_1.default.resolve(packageFolder, tsdocMetadataPath);
180
180
  }
181
181
  return PackageMetadataManager._resolveTsdocMetadataPathFromPackageJson(packageFolder, packageJson);
182
182
  }
@@ -214,7 +214,7 @@ class PackageMetadataManager {
214
214
  let packageMetadata = this._packageMetadataByPackageJsonPath.get(packageJsonFilePath);
215
215
  if (!packageMetadata) {
216
216
  const packageJson = this._packageJsonLookup.loadNodePackageJson(packageJsonFilePath);
217
- const packageJsonFolder = path_1.default.dirname(packageJsonFilePath);
217
+ const packageJsonFolder = node_path_1.default.dirname(packageJsonFilePath);
218
218
  let aedocSupported = false;
219
219
  const tsdocMetadataPath = PackageMetadataManager._resolveTsdocMetadataPathFromPackageJson(packageJsonFolder, packageJson);
220
220
  if (node_core_library_1.FileSystem.exists(tsdocMetadataPath)) {
@@ -1 +1 @@
1
- {"version":3,"file":"PackageMetadataManager.js","sourceRoot":"","sources":["../../src/analyzer/PackageMetadataManager.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;AAE3D,gDAAwB;AACxB,oDAA4B;AAE5B,oEAQsC;AACtC,gDAA6C;AAE7C,8DAA2D;AAE3D;;;GAGG;AACH,MAAa,eAAe;IAgB1B,YAAmB,eAAuB,EAAE,WAA6B,EAAE,cAAuB;QAChG,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;CACF;AArBD,0CAqBC;AAED,MAAM,uBAAuB,GAA0B,qBAAqB,CAAC;AAE7E;;;;GAIG;AACH,SAAS,8CAA8C,CAAC,EACtD,aAAa,EACI;IACjB,OAAO,aAAa,CAAC;AACvB,CAAC;AAED;;;;;;GAMG;AAEH,SAAS,wCAAwC,CAAC,EAAE,OAAO,EAAoB;;IAC7E,QAAQ,OAAO,OAAO,EAAE,CAAC;QACvB,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,OAAO,GAAG,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,uBAAuB,EAAE,CAAC;QAC/D,CAAC;QAED,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC3B,MAAM,CAAC,WAAW,CAAC,G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F,IAAI,CAAC,iCAAiC,CAAC,GAAG,CAAC,mBAAmB,EAAE,eAAe,CAAC,CAAC;QACnF,CAAC;QAED,OAAO,eAAe,CAAC;IACzB,CAAC;IAED;;OAEG;IACI,mBAAmB,CAAC,cAAsB;QAC/C,MAAM,eAAe,GAAgC,IAAI,CAAC,uBAAuB,CAAC,cAAc,CAAC,CAAC;QAClG,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,OAAO,KAAK,CAAC;QACf,CAAC;QACD,OAAO,eAAe,CAAC,cAAc,CAAC;IACxC,CAAC;;AAvIH,wDAwIC;AAvIe,4CAAqB,GAAW,uBAAuB,AAAlC,CAAmC","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 path from 'path';\nimport semver from 'semver';\n\nimport {\n type PackageJsonLookup,\n FileSystem,\n JsonFile,\n type NewlineKind,\n type INodePackageJson,\n type JsonObject,\n type IPackageJsonExports\n} from '@rushstack/node-core-library';\nimport { Extractor } from '../api/Extractor';\nimport type { MessageRouter } from '../collector/MessageRouter';\nimport { ConsoleMessageId } from '../api/ConsoleMessageId';\n\n/**\n * Represents analyzed information for a package.json file.\n * This object is constructed and returned by PackageMetadataManager.\n */\nexport class PackageMetadata {\n /**\n * The absolute path to the package.json file being analyzed.\n */\n public readonly packageJsonPath: string;\n /**\n * The parsed contents of package.json. Note that PackageJsonLookup\n * only includes essential fields.\n */\n public readonly packageJson: INodePackageJson;\n /**\n * If true, then the package's documentation comments can be assumed\n * to contain API Extractor compatible TSDoc tags.\n */\n public readonly aedocSupported: boolean;\n\n public constructor(packageJsonPath: string, packageJson: INodePackageJson, aedocSupported: boolean) {\n this.packageJsonPath = packageJsonPath;\n this.packageJson = packageJson;\n this.aedocSupported = aedocSupported;\n }\n}\n\nconst TSDOC_METADATA_FILENAME: 'tsdoc-metadata.json' = 'tsdoc-metadata.json';\n\n/**\n * 1. If package.json a `\"tsdocMetadata\": \"./path1/path2/tsdoc-metadata.json\"` field\n * then that takes precedence. This convention will be rarely needed, since the other rules below generally\n * produce a good result.\n */\nfunction _tryResolveTsdocMetadataFromTsdocMetadataField({\n tsdocMetadata\n}: INodePackageJson): string | undefined {\n return tsdocMetadata;\n}\n\n/**\n * 2. If package.json contains a `\"exports\": { \".\": { \"types\": \"./path1/path2/index.d.ts\" } }` field,\n * then we look for the file under \"./path1/path2/tsdoc-metadata.json\"\n *\n * This always looks for a \".\" and then a \"*\" entry in the exports field, and then evaluates for\n * a \"types\" field in that entry.\n */\n\nfunction _tryResolveTsdocMetadataFromExportsField({ exports }: INodePackageJson): string | undefined {\n switch (typeof exports) {\n case 'string': {\n return `${path.dirname(exports)}/${TSDOC_METADATA_FILENAME}`;\n }\n\n case 'object': {\n if (Array.isArray(exports)) {\n const [firstExport] = exports;\n // Take the first entry in the array\n if (firstExport) {\n return `${path.dirname(exports[0])}/${TSDOC_METADATA_FILENAME}`;\n }\n } else {\n const rootExport: IPackageJsonExports | string | null | undefined = exports['.'] ?? exports['*'];\n switch (typeof rootExport) {\n case 'string': {\n return `${path.dirname(rootExport)}/${TSDOC_METADATA_FILENAME}`;\n }\n\n case 'object': {\n let typesExport: IPackageJsonExports | string | undefined = rootExport?.types;\n while (typesExport) {\n switch (typeof typesExport) {\n case 'string': {\n return `${path.dirname(typesExport)}/${TSDOC_METADATA_FILENAME}`;\n }\n\n case 'object': {\n typesExport = typesExport?.types;\n break;\n }\n }\n }\n }\n }\n }\n break;\n }\n }\n}\n\n/**\n * 3. If package.json contains a `typesVersions` field, look for the version\n * matching the highest minimum version that either includes a \".\" or \"*\" entry.\n */\nfunction _tryResolveTsdocMetadataFromTypesVersionsField({\n typesVersions\n}: INodePackageJson): string | undefined {\n if (typesVersions) {\n let highestMinimumMatchingSemver: semver.SemVer | undefined;\n let latestMatchingPath: string | undefined;\n for (const [version, paths] of Object.entries(typesVersions)) {\n let range: semver.Range;\n try {\n range = new semver.Range(version);\n } catch {\n continue;\n }\n\n const minimumMatchingSemver: semver.SemVer | null = semver.minVersion(range);\n if (\n minimumMatchingSemver &&\n (!highestMinimumMatchingSemver || semver.gt(minimumMatchingSemver, highestMinimumMatchingSemver))\n ) {\n const pathEntry: string[] | undefined = paths['.'] ?? paths['*'];\n const firstPath: string | undefined = pathEntry?.[0];\n if (firstPath) {\n highestMinimumMatchingSemver = minimumMatchingSemver;\n latestMatchingPath = firstPath;\n }\n }\n }\n\n if (latestMatchingPath) {\n return `${path.dirname(latestMatchingPath)}/${TSDOC_METADATA_FILENAME}`;\n }\n }\n}\n\n/**\n * 4. If package.json contains a `\"types\": \"./path1/path2/index.d.ts\"` or a `\"typings\": \"./path1/path2/index.d.ts\"`\n * field, then we look for the file under \"./path1/path2/tsdoc-metadata.json\".\n *\n * @remarks\n * `types` takes precedence over `typings`.\n */\nfunction _tryResolveTsdocMetadataFromTypesOrTypingsFields({\n typings,\n types\n}: INodePackageJson): string | undefined {\n const typesField: string | undefined = types ?? typings;\n if (typesField) {\n return `${path.dirname(typesField)}/${TSDOC_METADATA_FILENAME}`;\n }\n}\n\n/**\n * 5. If package.json contains a `\"main\": \"./path1/path2/index.js\"` field, then we look for the file under\n * \"./path1/path2/tsdoc-metadata.json\".\n */\nfunction _tryResolveTsdocMetadataFromMainField({ main }: INodePackageJson): string | undefined {\n if (main) {\n return `${path.dirname(main)}/${TSDOC_METADATA_FILENAME}`;\n }\n}\n\n/**\n * This class maintains a cache of analyzed information obtained from package.json\n * files. It is built on top of the PackageJsonLookup class.\n *\n * @remarks\n *\n * IMPORTANT: Don't use PackageMetadataManager to analyze source files from the current project:\n * 1. Files such as tsdoc-metadata.json may not have been built yet, and thus may contain incorrect information.\n * 2. The current project is not guaranteed to have a package.json file at all. For example, API Extractor can\n * be invoked on a bare .d.ts file.\n *\n * Use ts.program.isSourceFileFromExternalLibrary() to test source files before passing the to PackageMetadataManager.\n */\nexport class PackageMetadataManager {\n public static tsdocMetadataFilename: string = TSDOC_METADATA_FILENAME;\n\n private readonly _packageJsonLookup: PackageJsonLookup;\n private readonly _messageRouter: MessageRouter;\n private readonly _packageMetadataByPackageJsonPath: Map<string, PackageMetadata> = new Map<\n string,\n PackageMetadata\n >();\n\n public constructor(packageJsonLookup: PackageJsonLookup, messageRouter: MessageRouter) {\n this._packageJsonLookup = packageJsonLookup;\n this._messageRouter = messageRouter;\n }\n\n /**\n * This feature is still being standardized: https://github.com/microsoft/tsdoc/issues/7\n * In the future we will use the @microsoft/tsdoc library to read this file.\n */\n private static _resolveTsdocMetadataPathFromPackageJson(\n packageFolder: string,\n packageJson: INodePackageJson\n ): string {\n const tsdocMetadataRelativePath: string =\n _tryResolveTsdocMetadataFromTsdocMetadataField(packageJson) ??\n _tryResolveTsdocMetadataFromExportsField(packageJson) ??\n _tryResolveTsdocMetadataFromTypesVersionsField(packageJson) ??\n _tryResolveTsdocMetadataFromTypesOrTypingsFields(packageJson) ??\n _tryResolveTsdocMetadataFromMainField(packageJson) ??\n // As a final fallback, place the file in the root of the package.\n TSDOC_METADATA_FILENAME;\n\n // Always resolve relative to the package folder.\n const tsdocMetadataPath: string = path.resolve(\n packageFolder,\n // This non-null assertion is safe because the last entry in TSDOC_METADATA_RESOLUTION_FUNCTIONS\n // returns a non-undefined value.\n tsdocMetadataRelativePath!\n );\n return tsdocMetadataPath;\n }\n\n /**\n * @param tsdocMetadataPath - An explicit path that can be configured in api-extractor.json.\n * If this parameter is not an empty string, it overrides the normal path calculation.\n * @returns the absolute path to the TSDoc metadata file\n */\n public static resolveTsdocMetadataPath(\n packageFolder: string,\n packageJson: INodePackageJson,\n tsdocMetadataPath?: string\n ): string {\n if (tsdocMetadataPath) {\n return path.resolve(packageFolder, tsdocMetadataPath);\n }\n\n return PackageMetadataManager._resolveTsdocMetadataPathFromPackageJson(packageFolder, packageJson);\n }\n\n /**\n * Writes the TSDoc metadata file to the specified output file.\n */\n public static writeTsdocMetadataFile(tsdocMetadataPath: string, newlineKind: NewlineKind): void {\n const fileObject: JsonObject = {\n tsdocVersion: '0.12',\n toolPackages: [\n {\n packageName: '@microsoft/api-extractor',\n packageVersion: Extractor.version\n }\n ]\n };\n\n const fileContent: string =\n '// This file is read by tools that parse documentation comments conforming to the TSDoc standard.\\n' +\n '// It should be published with your NPM package. It should not be tracked by Git.\\n' +\n JsonFile.stringify(fileObject);\n\n FileSystem.writeFile(tsdocMetadataPath, fileContent, {\n convertLineEndings: newlineKind,\n ensureFolderExists: true\n });\n }\n\n /**\n * Finds the package.json in a parent folder of the specified source file, and\n * returns a PackageMetadata object. If no package.json was found, then undefined\n * is returned. The results are cached.\n */\n public tryFetchPackageMetadata(sourceFilePath: string): PackageMetadata | undefined {\n const packageJsonFilePath: string | undefined =\n this._packageJsonLookup.tryGetPackageJsonFilePathFor(sourceFilePath);\n if (!packageJsonFilePath) {\n return undefined;\n }\n let packageMetadata: PackageMetadata | undefined =\n this._packageMetadataByPackageJsonPath.get(packageJsonFilePath);\n\n if (!packageMetadata) {\n const packageJson: INodePackageJson = this._packageJsonLookup.loadNodePackageJson(packageJsonFilePath);\n\n const packageJsonFolder: string = path.dirname(packageJsonFilePath);\n\n let aedocSupported: boolean = false;\n\n const tsdocMetadataPath: string = PackageMetadataManager._resolveTsdocMetadataPathFromPackageJson(\n packageJsonFolder,\n packageJson\n );\n\n if (FileSystem.exists(tsdocMetadataPath)) {\n this._messageRouter.logVerbose(\n ConsoleMessageId.FoundTSDocMetadata,\n 'Found metadata in ' + tsdocMetadataPath\n );\n // If the file exists at all, assume it was written by API Extractor\n aedocSupported = true;\n }\n\n packageMetadata = new PackageMetadata(packageJsonFilePath, packageJson, aedocSupported);\n this._packageMetadataByPackageJsonPath.set(packageJsonFilePath, packageMetadata);\n }\n\n return packageMetadata;\n }\n\n /**\n * Returns true if the source file is part of a package whose .d.ts files support AEDoc annotations.\n */\n public isAedocSupportedFor(sourceFilePath: string): boolean {\n const packageMetadata: PackageMetadata | undefined = this.tryFetchPackageMetadata(sourceFilePath);\n if (!packageMetadata) {\n return false;\n }\n return packageMetadata.aedocSupported;\n }\n}\n"]}
1
+ {"version":3,"file":"PackageMetadataManager.js","sourceRoot":"","sources":["../../src/analyzer/PackageMetadataManager.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;AAE3D,0DAA6B;AAE7B,oDAA4B;AAE5B,oEAQsC;AAEtC,gDAA6C;AAE7C,8DAA2D;AAE3D;;;GAGG;AACH,MAAa,eAAe;IAgB1B,YAAmB,eAAuB,EAAE,WAA6B,EAAE,cAAuB;QAChG,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;CACF;AArBD,0CAqBC;AAED,MAAM,uBAAuB,GAA0B,qBAAqB,CAAC;AAE7E;;;;GAIG;AACH,SAAS,8CAA8C,CAAC,EACtD,aAAa,EACI;IACjB,OAAO,aAAa,CAAC;AACvB,CAAC;AAED;;;;;;GAMG;AAEH,SAAS,wCAAwC,CAAC,EAAE,OAAO,EAAoB;;IAC7E,QAAQ,OAAO,OAAO,EAAE,CAAC;QACvB,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,OAAO,GAAG,mBAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,uBAAuB,EAAE,CAAC;QAC/D,CAAC;QAED,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC3B,MAAM,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC;gBAC9B,oCAAoC;gBACpC,IAAI,WAAW,EAAE,CAAC;oBAChB,OAAO,GAAG,mBAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,uBAAuB,EAAE,CAAC;gBAClE,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,MAAM,UAAU,GAAoD,MAAA,OAAO,CAAC,GAAG,CAAC,mC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Ae,EAAE,CAAC;YACrB,OAAO,KAAK,CAAC;QACf,CAAC;QACD,OAAO,eAAe,CAAC,cAAc,CAAC;IACxC,CAAC;;AAvIH,wDAwIC;AAvIe,4CAAqB,GAAW,uBAAuB,AAAlC,CAAmC","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 path from 'node:path';\n\nimport semver from 'semver';\n\nimport {\n type PackageJsonLookup,\n FileSystem,\n JsonFile,\n type NewlineKind,\n type INodePackageJson,\n type JsonObject,\n type IPackageJsonExports\n} from '@rushstack/node-core-library';\n\nimport { Extractor } from '../api/Extractor';\nimport type { MessageRouter } from '../collector/MessageRouter';\nimport { ConsoleMessageId } from '../api/ConsoleMessageId';\n\n/**\n * Represents analyzed information for a package.json file.\n * This object is constructed and returned by PackageMetadataManager.\n */\nexport class PackageMetadata {\n /**\n * The absolute path to the package.json file being analyzed.\n */\n public readonly packageJsonPath: string;\n /**\n * The parsed contents of package.json. Note that PackageJsonLookup\n * only includes essential fields.\n */\n public readonly packageJson: INodePackageJson;\n /**\n * If true, then the package's documentation comments can be assumed\n * to contain API Extractor compatible TSDoc tags.\n */\n public readonly aedocSupported: boolean;\n\n public constructor(packageJsonPath: string, packageJson: INodePackageJson, aedocSupported: boolean) {\n this.packageJsonPath = packageJsonPath;\n this.packageJson = packageJson;\n this.aedocSupported = aedocSupported;\n }\n}\n\nconst TSDOC_METADATA_FILENAME: 'tsdoc-metadata.json' = 'tsdoc-metadata.json';\n\n/**\n * 1. If package.json a `\"tsdocMetadata\": \"./path1/path2/tsdoc-metadata.json\"` field\n * then that takes precedence. This convention will be rarely needed, since the other rules below generally\n * produce a good result.\n */\nfunction _tryResolveTsdocMetadataFromTsdocMetadataField({\n tsdocMetadata\n}: INodePackageJson): string | undefined {\n return tsdocMetadata;\n}\n\n/**\n * 2. If package.json contains a `\"exports\": { \".\": { \"types\": \"./path1/path2/index.d.ts\" } }` field,\n * then we look for the file under \"./path1/path2/tsdoc-metadata.json\"\n *\n * This always looks for a \".\" and then a \"*\" entry in the exports field, and then evaluates for\n * a \"types\" field in that entry.\n */\n\nfunction _tryResolveTsdocMetadataFromExportsField({ exports }: INodePackageJson): string | undefined {\n switch (typeof exports) {\n case 'string': {\n return `${path.dirname(exports)}/${TSDOC_METADATA_FILENAME}`;\n }\n\n case 'object': {\n if (Array.isArray(exports)) {\n const [firstExport] = exports;\n // Take the first entry in the array\n if (firstExport) {\n return `${path.dirname(exports[0])}/${TSDOC_METADATA_FILENAME}`;\n }\n } else {\n const rootExport: IPackageJsonExports | string | null | undefined = exports['.'] ?? exports['*'];\n switch (typeof rootExport) {\n case 'string': {\n return `${path.dirname(rootExport)}/${TSDOC_METADATA_FILENAME}`;\n }\n\n case 'object': {\n let typesExport: IPackageJsonExports | string | undefined = rootExport?.types;\n while (typesExport) {\n switch (typeof typesExport) {\n case 'string': {\n return `${path.dirname(typesExport)}/${TSDOC_METADATA_FILENAME}`;\n }\n\n case 'object': {\n typesExport = typesExport?.types;\n break;\n }\n }\n }\n }\n }\n }\n break;\n }\n }\n}\n\n/**\n * 3. If package.json contains a `typesVersions` field, look for the version\n * matching the highest minimum version that either includes a \".\" or \"*\" entry.\n */\nfunction _tryResolveTsdocMetadataFromTypesVersionsField({\n typesVersions\n}: INodePackageJson): string | undefined {\n if (typesVersions) {\n let highestMinimumMatchingSemver: semver.SemVer | undefined;\n let latestMatchingPath: string | undefined;\n for (const [version, paths] of Object.entries(typesVersions)) {\n let range: semver.Range;\n try {\n range = new semver.Range(version);\n } catch {\n continue;\n }\n\n const minimumMatchingSemver: semver.SemVer | null = semver.minVersion(range);\n if (\n minimumMatchingSemver &&\n (!highestMinimumMatchingSemver || semver.gt(minimumMatchingSemver, highestMinimumMatchingSemver))\n ) {\n const pathEntry: string[] | undefined = paths['.'] ?? paths['*'];\n const firstPath: string | undefined = pathEntry?.[0];\n if (firstPath) {\n highestMinimumMatchingSemver = minimumMatchingSemver;\n latestMatchingPath = firstPath;\n }\n }\n }\n\n if (latestMatchingPath) {\n return `${path.dirname(latestMatchingPath)}/${TSDOC_METADATA_FILENAME}`;\n }\n }\n}\n\n/**\n * 4. If package.json contains a `\"types\": \"./path1/path2/index.d.ts\"` or a `\"typings\": \"./path1/path2/index.d.ts\"`\n * field, then we look for the file under \"./path1/path2/tsdoc-metadata.json\".\n *\n * @remarks\n * `types` takes precedence over `typings`.\n */\nfunction _tryResolveTsdocMetadataFromTypesOrTypingsFields({\n typings,\n types\n}: INodePackageJson): string | undefined {\n const typesField: string | undefined = types ?? typings;\n if (typesField) {\n return `${path.dirname(typesField)}/${TSDOC_METADATA_FILENAME}`;\n }\n}\n\n/**\n * 5. If package.json contains a `\"main\": \"./path1/path2/index.js\"` field, then we look for the file under\n * \"./path1/path2/tsdoc-metadata.json\".\n */\nfunction _tryResolveTsdocMetadataFromMainField({ main }: INodePackageJson): string | undefined {\n if (main) {\n return `${path.dirname(main)}/${TSDOC_METADATA_FILENAME}`;\n }\n}\n\n/**\n * This class maintains a cache of analyzed information obtained from package.json\n * files. It is built on top of the PackageJsonLookup class.\n *\n * @remarks\n *\n * IMPORTANT: Don't use PackageMetadataManager to analyze source files from the current project:\n * 1. Files such as tsdoc-metadata.json may not have been built yet, and thus may contain incorrect information.\n * 2. The current project is not guaranteed to have a package.json file at all. For example, API Extractor can\n * be invoked on a bare .d.ts file.\n *\n * Use ts.program.isSourceFileFromExternalLibrary() to test source files before passing the to PackageMetadataManager.\n */\nexport class PackageMetadataManager {\n public static tsdocMetadataFilename: string = TSDOC_METADATA_FILENAME;\n\n private readonly _packageJsonLookup: PackageJsonLookup;\n private readonly _messageRouter: MessageRouter;\n private readonly _packageMetadataByPackageJsonPath: Map<string, PackageMetadata> = new Map<\n string,\n PackageMetadata\n >();\n\n public constructor(packageJsonLookup: PackageJsonLookup, messageRouter: MessageRouter) {\n this._packageJsonLookup = packageJsonLookup;\n this._messageRouter = messageRouter;\n }\n\n /**\n * This feature is still being standardized: https://github.com/microsoft/tsdoc/issues/7\n * In the future we will use the @microsoft/tsdoc library to read this file.\n */\n private static _resolveTsdocMetadataPathFromPackageJson(\n packageFolder: string,\n packageJson: INodePackageJson\n ): string {\n const tsdocMetadataRelativePath: string =\n _tryResolveTsdocMetadataFromTsdocMetadataField(packageJson) ??\n _tryResolveTsdocMetadataFromExportsField(packageJson) ??\n _tryResolveTsdocMetadataFromTypesVersionsField(packageJson) ??\n _tryResolveTsdocMetadataFromTypesOrTypingsFields(packageJson) ??\n _tryResolveTsdocMetadataFromMainField(packageJson) ??\n // As a final fallback, place the file in the root of the package.\n TSDOC_METADATA_FILENAME;\n\n // Always resolve relative to the package folder.\n const tsdocMetadataPath: string = path.resolve(\n packageFolder,\n // This non-null assertion is safe because the last entry in TSDOC_METADATA_RESOLUTION_FUNCTIONS\n // returns a non-undefined value.\n tsdocMetadataRelativePath!\n );\n return tsdocMetadataPath;\n }\n\n /**\n * @param tsdocMetadataPath - An explicit path that can be configured in api-extractor.json.\n * If this parameter is not an empty string, it overrides the normal path calculation.\n * @returns the absolute path to the TSDoc metadata file\n */\n public static resolveTsdocMetadataPath(\n packageFolder: string,\n packageJson: INodePackageJson,\n tsdocMetadataPath?: string\n ): string {\n if (tsdocMetadataPath) {\n return path.resolve(packageFolder, tsdocMetadataPath);\n }\n\n return PackageMetadataManager._resolveTsdocMetadataPathFromPackageJson(packageFolder, packageJson);\n }\n\n /**\n * Writes the TSDoc metadata file to the specified output file.\n */\n public static writeTsdocMetadataFile(tsdocMetadataPath: string, newlineKind: NewlineKind): void {\n const fileObject: JsonObject = {\n tsdocVersion: '0.12',\n toolPackages: [\n {\n packageName: '@microsoft/api-extractor',\n packageVersion: Extractor.version\n }\n ]\n };\n\n const fileContent: string =\n '// This file is read by tools that parse documentation comments conforming to the TSDoc standard.\\n' +\n '// It should be published with your NPM package. It should not be tracked by Git.\\n' +\n JsonFile.stringify(fileObject);\n\n FileSystem.writeFile(tsdocMetadataPath, fileContent, {\n convertLineEndings: newlineKind,\n ensureFolderExists: true\n });\n }\n\n /**\n * Finds the package.json in a parent folder of the specified source file, and\n * returns a PackageMetadata object. If no package.json was found, then undefined\n * is returned. The results are cached.\n */\n public tryFetchPackageMetadata(sourceFilePath: string): PackageMetadata | undefined {\n const packageJsonFilePath: string | undefined =\n this._packageJsonLookup.tryGetPackageJsonFilePathFor(sourceFilePath);\n if (!packageJsonFilePath) {\n return undefined;\n }\n let packageMetadata: PackageMetadata | undefined =\n this._packageMetadataByPackageJsonPath.get(packageJsonFilePath);\n\n if (!packageMetadata) {\n const packageJson: INodePackageJson = this._packageJsonLookup.loadNodePackageJson(packageJsonFilePath);\n\n const packageJsonFolder: string = path.dirname(packageJsonFilePath);\n\n let aedocSupported: boolean = false;\n\n const tsdocMetadataPath: string = PackageMetadataManager._resolveTsdocMetadataPathFromPackageJson(\n packageJsonFolder,\n packageJson\n );\n\n if (FileSystem.exists(tsdocMetadataPath)) {\n this._messageRouter.logVerbose(\n ConsoleMessageId.FoundTSDocMetadata,\n 'Found metadata in ' + tsdocMetadataPath\n );\n // If the file exists at all, assume it was written by API Extractor\n aedocSupported = true;\n }\n\n packageMetadata = new PackageMetadata(packageJsonFilePath, packageJson, aedocSupported);\n this._packageMetadataByPackageJsonPath.set(packageJsonFilePath, packageMetadata);\n }\n\n return packageMetadata;\n }\n\n /**\n * Returns true if the source file is part of a package whose .d.ts files support AEDoc annotations.\n */\n public isAedocSupportedFor(sourceFilePath: string): boolean {\n const packageMetadata: PackageMetadata | undefined = this.tryFetchPackageMetadata(sourceFilePath);\n if (!packageMetadata) {\n return false;\n }\n return packageMetadata.aedocSupported;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SourceFileLocationFormatter.d.ts","sourceRoot":"","sources":["../../src/analyzer/SourceFileLocationFormatter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAItC,MAAM,WAAW,gCAAgC;IAC/C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC;AAED,qBAAa,2BAA2B;IACtC;;;OAGG;WACW,iBAAiB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,wBAAwB,CAAC,EAAE,MAAM,GAAG,MAAM;WAW3E,UAAU,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gCAAgC,GAAG,MAAM;CA+BrG"}
1
+ {"version":3,"file":"SourceFileLocationFormatter.d.ts","sourceRoot":"","sources":["../../src/analyzer/SourceFileLocationFormatter.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAItC,MAAM,WAAW,gCAAgC;IAC/C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC;AAED,qBAAa,2BAA2B;IACtC;;;OAGG;WACW,iBAAiB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,wBAAwB,CAAC,EAAE,MAAM,GAAG,MAAM;WAW3E,UAAU,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gCAAgC,GAAG,MAAM;CA+BrG"}
@@ -36,7 +36,7 @@ var __importStar = (this && this.__importStar) || (function () {
36
36
  })();
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
38
  exports.SourceFileLocationFormatter = void 0;
39
- const path = __importStar(require("path"));
39
+ const path = __importStar(require("node:path"));
40
40
  const node_core_library_1 = require("@rushstack/node-core-library");
41
41
  class SourceFileLocationFormatter {
42
42
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"SourceFileLocationFormatter.js","sourceRoot":"","sources":["../../src/analyzer/SourceFileLocationFormatter.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;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AAE,CAAC;gBAC7B,MAAM,IAAI,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;YAC3C,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA/CD,kEA+CC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type * as ts from 'typescript';\nimport * as path from 'path';\nimport { Path, Text } from '@rushstack/node-core-library';\n\nexport interface ISourceFileLocationFormatOptions {\n sourceFileLine?: number;\n sourceFileColumn?: number;\n workingPackageFolderPath?: string;\n}\n\nexport class SourceFileLocationFormatter {\n /**\n * Returns a string such as this, based on the context information in the provided node:\n * \"[C:\\Folder\\File.ts#123]\"\n */\n public static formatDeclaration(node: ts.Node, workingPackageFolderPath?: string): string {\n const sourceFile: ts.SourceFile = node.getSourceFile();\n const lineAndCharacter: ts.LineAndCharacter = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n\n return SourceFileLocationFormatter.formatPath(sourceFile.fileName, {\n sourceFileLine: lineAndCharacter.line + 1,\n sourceFileColumn: lineAndCharacter.character + 1,\n workingPackageFolderPath\n });\n }\n\n public static formatPath(sourceFilePath: string, options?: ISourceFileLocationFormatOptions): string {\n if (!options) {\n options = {};\n }\n\n let result: string = '';\n\n // Make the path relative to the workingPackageFolderPath\n let scrubbedPath: string = sourceFilePath;\n\n if (options.workingPackageFolderPath) {\n // If it's under the working folder, make it a relative path\n if (Path.isUnderOrEqual(sourceFilePath, options.workingPackageFolderPath)) {\n scrubbedPath = path.relative(options.workingPackageFolderPath, sourceFilePath);\n }\n }\n\n // Convert it to a Unix-style path\n scrubbedPath = Text.replaceAll(scrubbedPath, '\\\\', '/');\n result += scrubbedPath;\n\n if (options.sourceFileLine) {\n result += `:${options.sourceFileLine}`;\n\n if (options.sourceFileColumn) {\n result += `:${options.sourceFileColumn}`;\n }\n }\n\n return result;\n }\n}\n"]}
1
+ {"version":3,"file":"SourceFileLocationFormatter.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AO,CAAC,cAAc,EAAE,CAAC;YAC3B,MAAM,IAAI,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;YAEvC,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;gBAC7B,MAAM,IAAI,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;YAC3C,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA/CD,kEA+CC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as path from 'node:path';\n\nimport type * as ts from 'typescript';\n\nimport { Path, Text } from '@rushstack/node-core-library';\n\nexport interface ISourceFileLocationFormatOptions {\n sourceFileLine?: number;\n sourceFileColumn?: number;\n workingPackageFolderPath?: string;\n}\n\nexport class SourceFileLocationFormatter {\n /**\n * Returns a string such as this, based on the context information in the provided node:\n * \"[C:\\Folder\\File.ts#123]\"\n */\n public static formatDeclaration(node: ts.Node, workingPackageFolderPath?: string): string {\n const sourceFile: ts.SourceFile = node.getSourceFile();\n const lineAndCharacter: ts.LineAndCharacter = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n\n return SourceFileLocationFormatter.formatPath(sourceFile.fileName, {\n sourceFileLine: lineAndCharacter.line + 1,\n sourceFileColumn: lineAndCharacter.character + 1,\n workingPackageFolderPath\n });\n }\n\n public static formatPath(sourceFilePath: string, options?: ISourceFileLocationFormatOptions): string {\n if (!options) {\n options = {};\n }\n\n let result: string = '';\n\n // Make the path relative to the workingPackageFolderPath\n let scrubbedPath: string = sourceFilePath;\n\n if (options.workingPackageFolderPath) {\n // If it's under the working folder, make it a relative path\n if (Path.isUnderOrEqual(sourceFilePath, options.workingPackageFolderPath)) {\n scrubbedPath = path.relative(options.workingPackageFolderPath, sourceFilePath);\n }\n }\n\n // Convert it to a Unix-style path\n scrubbedPath = Text.replaceAll(scrubbedPath, '\\\\', '/');\n result += scrubbedPath;\n\n if (options.sourceFileLine) {\n result += `:${options.sourceFileLine}`;\n\n if (options.sourceFileColumn) {\n result += `:${options.sourceFileColumn}`;\n }\n }\n\n return result;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Span.d.ts","sourceRoot":"","sources":["../../src/analyzer/Span.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAGjC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AA2B9D;;GAEG;AACH,oBAAY,qBAAqB;IAC/B;;OAEG;IACH,IAAI,IAAI;IAER;;OAEG;IACH,UAAU,IAAI;IAEd;;OAEG;IACH,eAAe,IAAI;CACpB;AAED;;GAEG;AACH,qBAAa,gBAAgB;IAC3B;;;;OAIG;IACI,YAAY,EAAE,OAAO,CAAS;IAErC;;OAEG;IACI,kBAAkB,EAAE,OAAO,CAAS;IAE3C;;;;OAIG;IACI,YAAY,EAAE,OAAO,CAAS;IAErC;;OAEG;IACI,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAEnC;;;;;;;;;;;;OAYG;IACI,gBAAgB,EAAE,qBAAqB,CAA8B;IAE5E,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAO;IAC7B,OAAO,CAAC,OAAO,CAAqB;IACpC,OAAO,CAAC,OAAO,CAAqB;gBAEjB,IAAI,EAAE,IAAI;IAK7B;;OAEG;IACH,IAAW,MAAM,IAAI,MAAM,CAE1B;IAED,IAAW,MAAM,CAAC,KAAK,EAAE,MAAM,EAE9B;IAED;;OAEG;IACH,IAAW,MAAM,IAAI,MAAM,CAE1B;IAED,IAAW,MAAM,CAAC,KAAK,EAAE,MAAM,EAE9B;IAED;;OAEG;IACI,KAAK,IAAI,IAAI;IAYpB;;;OAGG;IACI,OAAO,IAAI,IAAI;CAMvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,IAAI;IACf,SAAgB,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;IAG9B,SAAgB,UAAU,EAAE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AE7E,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;YACrC,CAAC;QACH,CAAC;QAED,IAAI,OAAO,CAAC,qBAAqB,KAAK,qBAAqB,CAAC,sBAAsB,EAAE,CAAC;YACnF,IAAI,KAAK,GAAW,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC7C,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;gBACf,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC;gBACrB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;gBACrD,UAAU,GAAG,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;gBACzC,OAAO,CAAC,qBAAqB,GAAG,qBAAqB,CAAC,IAAI,CAAC;gBAE3D,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;YAClC,CAAC;QACH,CAAC;QAED,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACnC,CAAC;IAEO,WAAW,CAAC,IAAY;QAC9B,OAAO,wBAAI,CAAC,oBAAoB,CAAC,wBAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;IAChE,CAAC;IAEO,aAAa,CAAC,UAAkB,EAAE,QAAgB;QACxD,IAAI,UAAU,KAAK,QAAQ,EAAE,CAAC;YAC5B,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IACxE,CAAC;CACF;AArdD,oBAqdC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as ts from 'typescript';\nimport { InternalError, Sort, Text } from '@rushstack/node-core-library';\n\nimport { IndentedWriter } from '../generators/IndentedWriter';\n\ninterface IWriteModifiedTextOptions {\n writer: IndentedWriter;\n separatorOverride: string | undefined;\n indentDocCommentState: IndentDocCommentState;\n}\n\nenum IndentDocCommentState {\n /**\n * `indentDocComment` was not requested for this subtree.\n */\n Inactive = 0,\n /**\n * `indentDocComment` was requested and we are looking for the opening `/` `*`\n */\n AwaitingOpenDelimiter = 1,\n /**\n * `indentDocComment` was requested and we are looking for the closing `*` `/`\n */\n AwaitingCloseDelimiter = 2,\n /**\n * `indentDocComment` was requested and we have finished indenting the comment.\n */\n Done = 3\n}\n\n/**\n * Choices for SpanModification.indentDocComment.\n */\nexport enum IndentDocCommentScope {\n /**\n * Do not detect and indent comments.\n */\n None = 0,\n\n /**\n * Look for one doc comment in the {@link Span.prefix} text only.\n */\n PrefixOnly = 1,\n\n /**\n * Look for one doc comment potentially distributed across the Span and its children.\n */\n SpanAndChildren = 2\n}\n\n/**\n * Specifies various transformations that will be performed by Span.getModifiedText().\n */\nexport class SpanModification {\n /**\n * If true, all of the child spans will be omitted from the Span.getModifiedText() output.\n * @remarks\n * Also, the modify() operation will not recurse into these spans.\n */\n public omitChildren: boolean = false;\n\n /**\n * If true, then the Span.separator will be removed from the Span.getModifiedText() output.\n */\n public omitSeparatorAfter: boolean = false;\n\n /**\n * If true, then Span.getModifiedText() will sort the immediate children according to their Span.sortKey\n * property. The separators will also be fixed up to ensure correct indentation. If the Span.sortKey is undefined\n * for some items, those items will not be moved, i.e. their array indexes will be unchanged.\n */\n public sortChildren: boolean = false;\n\n /**\n * Used if the parent span has Span.sortChildren=true.\n */\n public sortKey: string | undefined;\n\n /**\n * Optionally configures getModifiedText() to search for a \"/*\" doc comment and indent it.\n * At most one comment is detected.\n *\n * @remarks\n * The indentation can be applied to the `Span.modifier.prefix` only, or it can be applied to the\n * full subtree of nodes (as needed for `ts.SyntaxKind.JSDocComment` trees). However the enabled\n * scopes must not overlap.\n *\n * This feature is enabled selectively because (1) we do not want to accidentally match `/*` appearing\n * in a string literal or other expression that is not a comment, and (2) parsing comments is relatively\n * expensive.\n */\n public indentDocComment: IndentDocCommentScope = IndentDocCommentScope.None;\n\n private readonly _span: Span;\n private _prefix: string | undefined;\n private _suffix: string | undefined;\n\n public constructor(span: Span) {\n this._span = span;\n this.reset();\n }\n\n /**\n * Allows the Span.prefix text to be changed.\n */\n public get prefix(): string {\n return this._prefix !== undefined ? this._prefix : this._span.prefix;\n }\n\n public set prefix(value: string) {\n this._prefix = value;\n }\n\n /**\n * Allows the Span.suffix text to be changed.\n */\n public get suffix(): string {\n return this._suffix !== undefined ? this._suffix : this._span.suffix;\n }\n\n public set suffix(value: string) {\n this._suffix = value;\n }\n\n /**\n * Reverts any modifications made to this object.\n */\n public reset(): void {\n this.omitChildren = false;\n this.omitSeparatorAfter = false;\n this.sortChildren = false;\n this.sortKey = undefined;\n this._prefix = undefined;\n this._suffix = undefined;\n if (this._span.kind === ts.SyntaxKind.JSDocComment) {\n this.indentDocComment = IndentDocCommentScope.SpanAndChildren;\n }\n }\n\n /**\n * Effectively deletes the Span from the tree, by skipping its children, skipping its separator,\n * and setting its prefix/suffix to the empty string.\n */\n public skipAll(): void {\n this.prefix = '';\n this.suffix = '';\n this.omitChildren = true;\n this.omitSeparatorAfter = true;\n }\n}\n\n/**\n * The Span class provides a simple way to rewrite TypeScript source files\n * based on simple syntax transformations, i.e. without having to process deeper aspects\n * of the underlying grammar. An example transformation might be deleting JSDoc comments\n * from a source file.\n *\n * @remarks\n * TypeScript's abstract syntax tree (AST) is represented using Node objects.\n * The Node text ignores its surrounding whitespace, and does not have an ordering guarantee.\n * For example, a JSDocComment node can be a child of a FunctionDeclaration node, even though\n * the actual comment precedes the function in the input stream.\n *\n * The Span class is a wrapper for a single Node, that provides access to every character\n * in the input stream, such that Span.getText() will exactly reproduce the corresponding\n * full Node.getText() output.\n *\n * A Span is comprised of these parts, which appear in sequential order:\n * - A prefix\n * - A collection of child spans\n * - A suffix\n * - A separator (e.g. whitespace between this span and the next item in the tree)\n *\n * These parts can be modified via Span.modification. The modification is applied by\n * calling Span.getModifiedText().\n */\nexport class Span {\n public readonly node: ts.Node;\n\n // To improve performance, substrings are not allocated until actually needed\n public readonly startIndex: number;\n public readonly endIndex: number;\n\n public readonly children: Span[];\n\n public readonly modification: SpanModification;\n\n private _parent: Span | undefined;\n private _previousSibling: Span | undefined;\n private _nextSibling: Span | undefined;\n\n private _separatorStartIndex: number;\n private _separatorEndIndex: number;\n\n public constructor(node: ts.Node) {\n this.node = node;\n this.startIndex = node.kind === ts.SyntaxKind.SourceFile ? node.getFullStart() : node.getStart();\n this.endIndex = node.end;\n this._separatorStartIndex = 0;\n this._separatorEndIndex = 0;\n this.children = [];\n this.modification = new SpanModification(this);\n\n let previousChildSpan: Span | undefined = undefined;\n\n for (const childNode of this.node.getChildren() || []) {\n const childSpan: Span = new Span(childNode);\n childSpan._parent = this;\n childSpan._previousSibling = previousChildSpan;\n\n if (previousChildSpan) {\n previousChildSpan._nextSibling = childSpan;\n }\n\n this.children.push(childSpan);\n\n // Normalize the bounds so that a child is never outside its parent\n if (childSpan.startIndex < this.startIndex) {\n this.startIndex = childSpan.startIndex;\n }\n\n if (childSpan.endIndex > this.endIndex) {\n // This has never been observed empirically, but here's how we would handle it\n this.endIndex = childSpan.endIndex;\n throw new InternalError('Unexpected AST case');\n }\n\n if (previousChildSpan) {\n if (previousChildSpan.endIndex < childSpan.startIndex) {\n // There is some leftover text after previous child -- assign it as the separator for\n // the preceding span. If the preceding span has no suffix, then assign it to the\n // deepest preceding span with no suffix. This heuristic simplifies the most\n // common transformations, and otherwise it can be fished out using getLastInnerSeparator().\n let separatorRecipient: Span = previousChildSpan;\n while (separatorRecipient.children.length > 0) {\n const lastChild: Span = separatorRecipient.children[separatorRecipient.children.length - 1];\n if (lastChild.endIndex !== separatorRecipient.endIndex) {\n // There is a suffix, so we cannot push the separator any further down, or else\n // it would get printed before this suffix.\n break;\n }\n separatorRecipient = lastChild;\n }\n separatorRecipient._separatorStartIndex = previousChildSpan.endIndex;\n separatorRecipient._separatorEndIndex = childSpan.startIndex;\n }\n }\n\n previousChildSpan = childSpan;\n }\n }\n\n public get kind(): ts.SyntaxKind {\n return this.node.kind;\n }\n\n /**\n * The parent Span, if any.\n * NOTE: This will be undefined for a root Span, even though the corresponding Node\n * may have a parent in the AST.\n */\n public get parent(): Span | undefined {\n return this._parent;\n }\n\n /**\n * If the current object is this.parent.children[i], then previousSibling corresponds\n * to this.parent.children[i-1] if it exists.\n * NOTE: This will be undefined for a root Span, even though the corresponding Node\n * may have a previous sibling in the AST.\n */\n public get previousSibling(): Span | undefined {\n return this._previousSibling;\n }\n\n /**\n * If the current object is this.parent.children[i], then previousSibling corresponds\n * to this.parent.children[i+1] if it exists.\n * NOTE: This will be undefined for a root Span, even though the corresponding Node\n * may have a previous sibling in the AST.\n */\n public get nextSibling(): Span | undefined {\n return this._nextSibling;\n }\n\n /**\n * The text associated with the underlying Node, up to its first child.\n */\n public get prefix(): string {\n if (this.children.length) {\n // Everything up to the first child\n return this._getSubstring(this.startIndex, this.children[0].startIndex);\n } else {\n return this._getSubstring(this.startIndex, this.endIndex);\n }\n }\n\n /**\n * The text associated with the underlying Node, after its last child.\n * If there are no children, this is always an empty string.\n */\n public get suffix(): string {\n if (this.children.length) {\n // Everything after the last child\n return this._getSubstring(this.children[this.children.length - 1].endIndex, this.endIndex);\n } else {\n return '';\n }\n }\n\n /**\n * Whitespace that appeared after this node, and before the \"next\" node in the tree.\n * Here we mean \"next\" according to an inorder traversal, not necessarily a sibling.\n */\n public get separator(): string {\n return this._getSubstring(this._separatorStartIndex, this._separatorEndIndex);\n }\n\n /**\n * Returns the separator of this Span, or else recursively calls getLastInnerSeparator()\n * on the last child.\n */\n public getLastInnerSeparator(): string {\n if (this.separator) {\n return this.separator;\n }\n if (this.children.length > 0) {\n return this.children[this.children.length - 1].getLastInnerSeparator();\n }\n return '';\n }\n\n /**\n * Returns the first parent node with the specified SyntaxKind, or undefined if there is no match.\n */\n public findFirstParent(kindToMatch: ts.SyntaxKind): Span | undefined {\n let current: Span | undefined = this;\n\n while (current) {\n if (current.kind === kindToMatch) {\n return current;\n }\n current = current.parent;\n }\n\n return undefined;\n }\n\n /**\n * Recursively invokes the callback on this Span and all its children. The callback\n * can make changes to Span.modification for each node.\n */\n public forEach(callback: (span: Span) => void): void {\n callback(this);\n for (const child of this.children) {\n child.forEach(callback);\n }\n }\n\n /**\n * Returns the original unmodified text represented by this Span.\n */\n public getText(): string {\n let result: string = '';\n result += this.prefix;\n\n for (const child of this.children) {\n result += child.getText();\n }\n\n result += this.suffix;\n result += this.separator;\n\n return result;\n }\n\n /**\n * Returns the text represented by this Span, after applying all requested modifications.\n */\n public getModifiedText(): string {\n const writer: IndentedWriter = new IndentedWriter();\n writer.trimLeadingSpaces = true;\n\n this._writeModifiedText({\n writer: writer,\n separatorOverride: undefined,\n indentDocCommentState: IndentDocCommentState.Inactive\n });\n\n return writer.getText();\n }\n\n public writeModifiedText(output: IndentedWriter): void {\n this._writeModifiedText({\n writer: output,\n separatorOverride: undefined,\n indentDocCommentState: IndentDocCommentState.Inactive\n });\n }\n\n /**\n * Returns a diagnostic dump of the tree, showing the prefix/suffix/separator for\n * each node.\n */\n public getDump(indent: string = ''): string {\n let result: string = indent + ts.SyntaxKind[this.node.kind] + ': ';\n\n if (this.prefix) {\n result += ' pre=[' + this._getTrimmed(this.prefix) + ']';\n }\n if (this.suffix) {\n result += ' suf=[' + this._getTrimmed(this.suffix) + ']';\n }\n if (this.separator) {\n result += ' sep=[' + this._getTrimmed(this.separator) + ']';\n }\n result += '\\n';\n\n for (const child of this.children) {\n result += child.getDump(indent + ' ');\n }\n\n return result;\n }\n\n /**\n * Returns a diagnostic dump of the tree, showing the SpanModification settings for each nodde.\n */\n public getModifiedDump(indent: string = ''): string {\n let result: string = indent + ts.SyntaxKind[this.node.kind] + ': ';\n\n if (this.prefix) {\n result += ' pre=[' + this._getTrimmed(this.modification.prefix) + ']';\n }\n if (this.suffix) {\n result += ' suf=[' + this._getTrimmed(this.modification.suffix) + ']';\n }\n if (this.separator) {\n result += ' sep=[' + this._getTrimmed(this.separator) + ']';\n }\n if (this.modification.indentDocComment !== IndentDocCommentScope.None) {\n result += ' indentDocComment=' + IndentDocCommentScope[this.modification.indentDocComment];\n }\n if (this.modification.omitChildren) {\n result += ' omitChildren';\n }\n if (this.modification.omitSeparatorAfter) {\n result += ' omitSeparatorAfter';\n }\n if (this.modification.sortChildren) {\n result += ' sortChildren';\n }\n if (this.modification.sortKey !== undefined) {\n result += ` sortKey=\"${this.modification.sortKey}\"`;\n }\n result += '\\n';\n\n if (!this.modification.omitChildren) {\n for (const child of this.children) {\n result += child.getModifiedDump(indent + ' ');\n }\n } else {\n result += `${indent} (${this.children.length} children)\\n`;\n }\n\n return result;\n }\n\n /**\n * Recursive implementation of `getModifiedText()` and `writeModifiedText()`.\n */\n private _writeModifiedText(options: IWriteModifiedTextOptions): void {\n // Apply indentation based on \"{\" and \"}\"\n if (this.prefix === '{') {\n options.writer.increaseIndent();\n } else if (this.prefix === '}') {\n options.writer.decreaseIndent();\n }\n\n if (this.modification.indentDocComment !== IndentDocCommentScope.None) {\n this._beginIndentDocComment(options);\n }\n\n this._write(this.modification.prefix, options);\n\n if (this.modification.indentDocComment === IndentDocCommentScope.PrefixOnly) {\n this._endIndentDocComment(options);\n }\n\n let sortedSubset: Span[] | undefined;\n\n if (!this.modification.omitChildren) {\n if (this.modification.sortChildren) {\n // We will only sort the items with a sortKey\n const filtered: Span[] = this.children.filter((x) => x.modification.sortKey !== undefined);\n\n // Is there at least one of them?\n if (filtered.length > 1) {\n sortedSubset = filtered;\n }\n }\n }\n\n if (sortedSubset) {\n // This is the complicated special case that sorts an arbitrary subset of the child nodes,\n // preserving the surrounding nodes.\n\n const sortedSubsetCount: number = sortedSubset.length;\n // Remember the separator for the first and last ones\n const firstSeparator: string = sortedSubset[0].getLastInnerSeparator();\n const lastSeparator: string = sortedSubset[sortedSubsetCount - 1].getLastInnerSeparator();\n\n Sort.sortBy(sortedSubset, (x) => x.modification.sortKey);\n\n const childOptions: IWriteModifiedTextOptions = { ...options };\n\n let sortedSubsetIndex: number = 0;\n for (let index: number = 0; index < this.children.length; ++index) {\n let current: Span;\n\n // Is this an item that we sorted?\n if (this.children[index].modification.sortKey === undefined) {\n // No, take the next item from the original array\n current = this.children[index];\n childOptions.separatorOverride = undefined;\n } else {\n // Yes, take the next item from the sortedSubset\n current = sortedSubset[sortedSubsetIndex++];\n\n if (sortedSubsetIndex < sortedSubsetCount) {\n childOptions.separatorOverride = firstSeparator;\n } else {\n childOptions.separatorOverride = lastSeparator;\n }\n }\n\n current._writeModifiedText(childOptions);\n }\n } else {\n // This is the normal case that does not need to sort children\n const childrenLength: number = this.children.length;\n\n if (!this.modification.omitChildren) {\n if (options.separatorOverride !== undefined) {\n // Special case where the separatorOverride is passed down to the \"last inner separator\" span\n for (let i: number = 0; i < childrenLength; ++i) {\n const child: Span = this.children[i];\n\n if (\n // Only the last child inherits the separatorOverride, because only it can contain\n // the \"last inner separator\" span\n i < childrenLength - 1 ||\n // If this.separator is specified, then we will write separatorOverride below, so don't pass it along\n this.separator\n ) {\n const childOptions: IWriteModifiedTextOptions = { ...options };\n childOptions.separatorOverride = undefined;\n child._writeModifiedText(childOptions);\n } else {\n child._writeModifiedText(options);\n }\n }\n } else {\n // The normal simple case\n for (const child of this.children) {\n child._writeModifiedText(options);\n }\n }\n }\n\n this._write(this.modification.suffix, options);\n\n if (options.separatorOverride !== undefined) {\n if (this.separator || childrenLength === 0) {\n this._write(options.separatorOverride, options);\n }\n } else {\n if (!this.modification.omitSeparatorAfter) {\n this._write(this.separator, options);\n }\n }\n }\n\n if (this.modification.indentDocComment === IndentDocCommentScope.SpanAndChildren) {\n this._endIndentDocComment(options);\n }\n }\n\n private _beginIndentDocComment(options: IWriteModifiedTextOptions): void {\n if (options.indentDocCommentState !== IndentDocCommentState.Inactive) {\n throw new InternalError('indentDocComment cannot be nested');\n }\n options.indentDocCommentState = IndentDocCommentState.AwaitingOpenDelimiter;\n }\n\n private _endIndentDocComment(options: IWriteModifiedTextOptions): void {\n if (options.indentDocCommentState === IndentDocCommentState.AwaitingCloseDelimiter) {\n throw new InternalError('missing \"*/\" delimiter for comment block');\n }\n options.indentDocCommentState = IndentDocCommentState.Inactive;\n }\n\n /**\n * Writes one chunk of `text` to the `options.writer`, applying the `indentDocComment` rewriting.\n */\n private _write(text: string, options: IWriteModifiedTextOptions): void {\n let parsedText: string = text;\n\n if (options.indentDocCommentState === IndentDocCommentState.AwaitingOpenDelimiter) {\n let index: number = parsedText.indexOf('/*');\n if (index >= 0) {\n index += '/*'.length;\n options.writer.write(parsedText.substring(0, index));\n parsedText = parsedText.substring(index);\n options.indentDocCommentState = IndentDocCommentState.AwaitingCloseDelimiter;\n\n options.writer.increaseIndent(' ');\n }\n }\n\n if (options.indentDocCommentState === IndentDocCommentState.AwaitingCloseDelimiter) {\n let index: number = parsedText.indexOf('*/');\n if (index >= 0) {\n index += '*/'.length;\n options.writer.write(parsedText.substring(0, index));\n parsedText = parsedText.substring(index);\n options.indentDocCommentState = IndentDocCommentState.Done;\n\n options.writer.decreaseIndent();\n }\n }\n\n options.writer.write(parsedText);\n }\n\n private _getTrimmed(text: string): string {\n return Text.truncateWithEllipsis(Text.convertToLf(text), 100);\n }\n\n private _getSubstring(startIndex: number, endIndex: number): string {\n if (startIndex === endIndex) {\n return '';\n }\n return this.node.getSourceFile().text.substring(startIndex, endIndex);\n }\n}\n"]}
1
+ {"version":3,"file":"Span.js","sourceRoot":"","sources":["../../src/analyzer/Span.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,+CAAiC;AAEjC,oEAAyE;AAEzE,iEAA8D;AAQ9D,IAAK,qBAiBJ;AAjBD,WAAK,qBAAqB;IACxB;;OAEG;IACH,yEAAY,CAAA;IACZ;;OAEG;IACH,mGAAyB,CAAA;IACzB;;OAEG;IACH,q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,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;YAClC,CAAC;QACH,CAAC;QAED,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACnC,CAAC;IAEO,WAAW,CAAC,IAAY;QAC9B,OAAO,wBAAI,CAAC,oBAAoB,CAAC,wBAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;IAChE,CAAC;IAEO,aAAa,CAAC,UAAkB,EAAE,QAAgB;QACxD,IAAI,UAAU,KAAK,QAAQ,EAAE,CAAC;YAC5B,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IACxE,CAAC;CACF;AArdD,oBAqdC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as ts from 'typescript';\n\nimport { InternalError, Sort, Text } from '@rushstack/node-core-library';\n\nimport { IndentedWriter } from '../generators/IndentedWriter';\n\ninterface IWriteModifiedTextOptions {\n writer: IndentedWriter;\n separatorOverride: string | undefined;\n indentDocCommentState: IndentDocCommentState;\n}\n\nenum IndentDocCommentState {\n /**\n * `indentDocComment` was not requested for this subtree.\n */\n Inactive = 0,\n /**\n * `indentDocComment` was requested and we are looking for the opening `/` `*`\n */\n AwaitingOpenDelimiter = 1,\n /**\n * `indentDocComment` was requested and we are looking for the closing `*` `/`\n */\n AwaitingCloseDelimiter = 2,\n /**\n * `indentDocComment` was requested and we have finished indenting the comment.\n */\n Done = 3\n}\n\n/**\n * Choices for SpanModification.indentDocComment.\n */\nexport enum IndentDocCommentScope {\n /**\n * Do not detect and indent comments.\n */\n None = 0,\n\n /**\n * Look for one doc comment in the {@link Span.prefix} text only.\n */\n PrefixOnly = 1,\n\n /**\n * Look for one doc comment potentially distributed across the Span and its children.\n */\n SpanAndChildren = 2\n}\n\n/**\n * Specifies various transformations that will be performed by Span.getModifiedText().\n */\nexport class SpanModification {\n /**\n * If true, all of the child spans will be omitted from the Span.getModifiedText() output.\n * @remarks\n * Also, the modify() operation will not recurse into these spans.\n */\n public omitChildren: boolean = false;\n\n /**\n * If true, then the Span.separator will be removed from the Span.getModifiedText() output.\n */\n public omitSeparatorAfter: boolean = false;\n\n /**\n * If true, then Span.getModifiedText() will sort the immediate children according to their Span.sortKey\n * property. The separators will also be fixed up to ensure correct indentation. If the Span.sortKey is undefined\n * for some items, those items will not be moved, i.e. their array indexes will be unchanged.\n */\n public sortChildren: boolean = false;\n\n /**\n * Used if the parent span has Span.sortChildren=true.\n */\n public sortKey: string | undefined;\n\n /**\n * Optionally configures getModifiedText() to search for a \"/*\" doc comment and indent it.\n * At most one comment is detected.\n *\n * @remarks\n * The indentation can be applied to the `Span.modifier.prefix` only, or it can be applied to the\n * full subtree of nodes (as needed for `ts.SyntaxKind.JSDocComment` trees). However the enabled\n * scopes must not overlap.\n *\n * This feature is enabled selectively because (1) we do not want to accidentally match `/*` appearing\n * in a string literal or other expression that is not a comment, and (2) parsing comments is relatively\n * expensive.\n */\n public indentDocComment: IndentDocCommentScope = IndentDocCommentScope.None;\n\n private readonly _span: Span;\n private _prefix: string | undefined;\n private _suffix: string | undefined;\n\n public constructor(span: Span) {\n this._span = span;\n this.reset();\n }\n\n /**\n * Allows the Span.prefix text to be changed.\n */\n public get prefix(): string {\n return this._prefix !== undefined ? this._prefix : this._span.prefix;\n }\n\n public set prefix(value: string) {\n this._prefix = value;\n }\n\n /**\n * Allows the Span.suffix text to be changed.\n */\n public get suffix(): string {\n return this._suffix !== undefined ? this._suffix : this._span.suffix;\n }\n\n public set suffix(value: string) {\n this._suffix = value;\n }\n\n /**\n * Reverts any modifications made to this object.\n */\n public reset(): void {\n this.omitChildren = false;\n this.omitSeparatorAfter = false;\n this.sortChildren = false;\n this.sortKey = undefined;\n this._prefix = undefined;\n this._suffix = undefined;\n if (this._span.kind === ts.SyntaxKind.JSDocComment) {\n this.indentDocComment = IndentDocCommentScope.SpanAndChildren;\n }\n }\n\n /**\n * Effectively deletes the Span from the tree, by skipping its children, skipping its separator,\n * and setting its prefix/suffix to the empty string.\n */\n public skipAll(): void {\n this.prefix = '';\n this.suffix = '';\n this.omitChildren = true;\n this.omitSeparatorAfter = true;\n }\n}\n\n/**\n * The Span class provides a simple way to rewrite TypeScript source files\n * based on simple syntax transformations, i.e. without having to process deeper aspects\n * of the underlying grammar. An example transformation might be deleting JSDoc comments\n * from a source file.\n *\n * @remarks\n * TypeScript's abstract syntax tree (AST) is represented using Node objects.\n * The Node text ignores its surrounding whitespace, and does not have an ordering guarantee.\n * For example, a JSDocComment node can be a child of a FunctionDeclaration node, even though\n * the actual comment precedes the function in the input stream.\n *\n * The Span class is a wrapper for a single Node, that provides access to every character\n * in the input stream, such that Span.getText() will exactly reproduce the corresponding\n * full Node.getText() output.\n *\n * A Span is comprised of these parts, which appear in sequential order:\n * - A prefix\n * - A collection of child spans\n * - A suffix\n * - A separator (e.g. whitespace between this span and the next item in the tree)\n *\n * These parts can be modified via Span.modification. The modification is applied by\n * calling Span.getModifiedText().\n */\nexport class Span {\n public readonly node: ts.Node;\n\n // To improve performance, substrings are not allocated until actually needed\n public readonly startIndex: number;\n public readonly endIndex: number;\n\n public readonly children: Span[];\n\n public readonly modification: SpanModification;\n\n private _parent: Span | undefined;\n private _previousSibling: Span | undefined;\n private _nextSibling: Span | undefined;\n\n private _separatorStartIndex: number;\n private _separatorEndIndex: number;\n\n public constructor(node: ts.Node) {\n this.node = node;\n this.startIndex = node.kind === ts.SyntaxKind.SourceFile ? node.getFullStart() : node.getStart();\n this.endIndex = node.end;\n this._separatorStartIndex = 0;\n this._separatorEndIndex = 0;\n this.children = [];\n this.modification = new SpanModification(this);\n\n let previousChildSpan: Span | undefined = undefined;\n\n for (const childNode of this.node.getChildren() || []) {\n const childSpan: Span = new Span(childNode);\n childSpan._parent = this;\n childSpan._previousSibling = previousChildSpan;\n\n if (previousChildSpan) {\n previousChildSpan._nextSibling = childSpan;\n }\n\n this.children.push(childSpan);\n\n // Normalize the bounds so that a child is never outside its parent\n if (childSpan.startIndex < this.startIndex) {\n this.startIndex = childSpan.startIndex;\n }\n\n if (childSpan.endIndex > this.endIndex) {\n // This has never been observed empirically, but here's how we would handle it\n this.endIndex = childSpan.endIndex;\n throw new InternalError('Unexpected AST case');\n }\n\n if (previousChildSpan) {\n if (previousChildSpan.endIndex < childSpan.startIndex) {\n // There is some leftover text after previous child -- assign it as the separator for\n // the preceding span. If the preceding span has no suffix, then assign it to the\n // deepest preceding span with no suffix. This heuristic simplifies the most\n // common transformations, and otherwise it can be fished out using getLastInnerSeparator().\n let separatorRecipient: Span = previousChildSpan;\n while (separatorRecipient.children.length > 0) {\n const lastChild: Span = separatorRecipient.children[separatorRecipient.children.length - 1];\n if (lastChild.endIndex !== separatorRecipient.endIndex) {\n // There is a suffix, so we cannot push the separator any further down, or else\n // it would get printed before this suffix.\n break;\n }\n separatorRecipient = lastChild;\n }\n separatorRecipient._separatorStartIndex = previousChildSpan.endIndex;\n separatorRecipient._separatorEndIndex = childSpan.startIndex;\n }\n }\n\n previousChildSpan = childSpan;\n }\n }\n\n public get kind(): ts.SyntaxKind {\n return this.node.kind;\n }\n\n /**\n * The parent Span, if any.\n * NOTE: This will be undefined for a root Span, even though the corresponding Node\n * may have a parent in the AST.\n */\n public get parent(): Span | undefined {\n return this._parent;\n }\n\n /**\n * If the current object is this.parent.children[i], then previousSibling corresponds\n * to this.parent.children[i-1] if it exists.\n * NOTE: This will be undefined for a root Span, even though the corresponding Node\n * may have a previous sibling in the AST.\n */\n public get previousSibling(): Span | undefined {\n return this._previousSibling;\n }\n\n /**\n * If the current object is this.parent.children[i], then previousSibling corresponds\n * to this.parent.children[i+1] if it exists.\n * NOTE: This will be undefined for a root Span, even though the corresponding Node\n * may have a previous sibling in the AST.\n */\n public get nextSibling(): Span | undefined {\n return this._nextSibling;\n }\n\n /**\n * The text associated with the underlying Node, up to its first child.\n */\n public get prefix(): string {\n if (this.children.length) {\n // Everything up to the first child\n return this._getSubstring(this.startIndex, this.children[0].startIndex);\n } else {\n return this._getSubstring(this.startIndex, this.endIndex);\n }\n }\n\n /**\n * The text associated with the underlying Node, after its last child.\n * If there are no children, this is always an empty string.\n */\n public get suffix(): string {\n if (this.children.length) {\n // Everything after the last child\n return this._getSubstring(this.children[this.children.length - 1].endIndex, this.endIndex);\n } else {\n return '';\n }\n }\n\n /**\n * Whitespace that appeared after this node, and before the \"next\" node in the tree.\n * Here we mean \"next\" according to an inorder traversal, not necessarily a sibling.\n */\n public get separator(): string {\n return this._getSubstring(this._separatorStartIndex, this._separatorEndIndex);\n }\n\n /**\n * Returns the separator of this Span, or else recursively calls getLastInnerSeparator()\n * on the last child.\n */\n public getLastInnerSeparator(): string {\n if (this.separator) {\n return this.separator;\n }\n if (this.children.length > 0) {\n return this.children[this.children.length - 1].getLastInnerSeparator();\n }\n return '';\n }\n\n /**\n * Returns the first parent node with the specified SyntaxKind, or undefined if there is no match.\n */\n public findFirstParent(kindToMatch: ts.SyntaxKind): Span | undefined {\n let current: Span | undefined = this;\n\n while (current) {\n if (current.kind === kindToMatch) {\n return current;\n }\n current = current.parent;\n }\n\n return undefined;\n }\n\n /**\n * Recursively invokes the callback on this Span and all its children. The callback\n * can make changes to Span.modification for each node.\n */\n public forEach(callback: (span: Span) => void): void {\n callback(this);\n for (const child of this.children) {\n child.forEach(callback);\n }\n }\n\n /**\n * Returns the original unmodified text represented by this Span.\n */\n public getText(): string {\n let result: string = '';\n result += this.prefix;\n\n for (const child of this.children) {\n result += child.getText();\n }\n\n result += this.suffix;\n result += this.separator;\n\n return result;\n }\n\n /**\n * Returns the text represented by this Span, after applying all requested modifications.\n */\n public getModifiedText(): string {\n const writer: IndentedWriter = new IndentedWriter();\n writer.trimLeadingSpaces = true;\n\n this._writeModifiedText({\n writer: writer,\n separatorOverride: undefined,\n indentDocCommentState: IndentDocCommentState.Inactive\n });\n\n return writer.getText();\n }\n\n public writeModifiedText(output: IndentedWriter): void {\n this._writeModifiedText({\n writer: output,\n separatorOverride: undefined,\n indentDocCommentState: IndentDocCommentState.Inactive\n });\n }\n\n /**\n * Returns a diagnostic dump of the tree, showing the prefix/suffix/separator for\n * each node.\n */\n public getDump(indent: string = ''): string {\n let result: string = indent + ts.SyntaxKind[this.node.kind] + ': ';\n\n if (this.prefix) {\n result += ' pre=[' + this._getTrimmed(this.prefix) + ']';\n }\n if (this.suffix) {\n result += ' suf=[' + this._getTrimmed(this.suffix) + ']';\n }\n if (this.separator) {\n result += ' sep=[' + this._getTrimmed(this.separator) + ']';\n }\n result += '\\n';\n\n for (const child of this.children) {\n result += child.getDump(indent + ' ');\n }\n\n return result;\n }\n\n /**\n * Returns a diagnostic dump of the tree, showing the SpanModification settings for each nodde.\n */\n public getModifiedDump(indent: string = ''): string {\n let result: string = indent + ts.SyntaxKind[this.node.kind] + ': ';\n\n if (this.prefix) {\n result += ' pre=[' + this._getTrimmed(this.modification.prefix) + ']';\n }\n if (this.suffix) {\n result += ' suf=[' + this._getTrimmed(this.modification.suffix) + ']';\n }\n if (this.separator) {\n result += ' sep=[' + this._getTrimmed(this.separator) + ']';\n }\n if (this.modification.indentDocComment !== IndentDocCommentScope.None) {\n result += ' indentDocComment=' + IndentDocCommentScope[this.modification.indentDocComment];\n }\n if (this.modification.omitChildren) {\n result += ' omitChildren';\n }\n if (this.modification.omitSeparatorAfter) {\n result += ' omitSeparatorAfter';\n }\n if (this.modification.sortChildren) {\n result += ' sortChildren';\n }\n if (this.modification.sortKey !== undefined) {\n result += ` sortKey=\"${this.modification.sortKey}\"`;\n }\n result += '\\n';\n\n if (!this.modification.omitChildren) {\n for (const child of this.children) {\n result += child.getModifiedDump(indent + ' ');\n }\n } else {\n result += `${indent} (${this.children.length} children)\\n`;\n }\n\n return result;\n }\n\n /**\n * Recursive implementation of `getModifiedText()` and `writeModifiedText()`.\n */\n private _writeModifiedText(options: IWriteModifiedTextOptions): void {\n // Apply indentation based on \"{\" and \"}\"\n if (this.prefix === '{') {\n options.writer.increaseIndent();\n } else if (this.prefix === '}') {\n options.writer.decreaseIndent();\n }\n\n if (this.modification.indentDocComment !== IndentDocCommentScope.None) {\n this._beginIndentDocComment(options);\n }\n\n this._write(this.modification.prefix, options);\n\n if (this.modification.indentDocComment === IndentDocCommentScope.PrefixOnly) {\n this._endIndentDocComment(options);\n }\n\n let sortedSubset: Span[] | undefined;\n\n if (!this.modification.omitChildren) {\n if (this.modification.sortChildren) {\n // We will only sort the items with a sortKey\n const filtered: Span[] = this.children.filter((x) => x.modification.sortKey !== undefined);\n\n // Is there at least one of them?\n if (filtered.length > 1) {\n sortedSubset = filtered;\n }\n }\n }\n\n if (sortedSubset) {\n // This is the complicated special case that sorts an arbitrary subset of the child nodes,\n // preserving the surrounding nodes.\n\n const sortedSubsetCount: number = sortedSubset.length;\n // Remember the separator for the first and last ones\n const firstSeparator: string = sortedSubset[0].getLastInnerSeparator();\n const lastSeparator: string = sortedSubset[sortedSubsetCount - 1].getLastInnerSeparator();\n\n Sort.sortBy(sortedSubset, (x) => x.modification.sortKey);\n\n const childOptions: IWriteModifiedTextOptions = { ...options };\n\n let sortedSubsetIndex: number = 0;\n for (let index: number = 0; index < this.children.length; ++index) {\n let current: Span;\n\n // Is this an item that we sorted?\n if (this.children[index].modification.sortKey === undefined) {\n // No, take the next item from the original array\n current = this.children[index];\n childOptions.separatorOverride = undefined;\n } else {\n // Yes, take the next item from the sortedSubset\n current = sortedSubset[sortedSubsetIndex++];\n\n if (sortedSubsetIndex < sortedSubsetCount) {\n childOptions.separatorOverride = firstSeparator;\n } else {\n childOptions.separatorOverride = lastSeparator;\n }\n }\n\n current._writeModifiedText(childOptions);\n }\n } else {\n // This is the normal case that does not need to sort children\n const childrenLength: number = this.children.length;\n\n if (!this.modification.omitChildren) {\n if (options.separatorOverride !== undefined) {\n // Special case where the separatorOverride is passed down to the \"last inner separator\" span\n for (let i: number = 0; i < childrenLength; ++i) {\n const child: Span = this.children[i];\n\n if (\n // Only the last child inherits the separatorOverride, because only it can contain\n // the \"last inner separator\" span\n i < childrenLength - 1 ||\n // If this.separator is specified, then we will write separatorOverride below, so don't pass it along\n this.separator\n ) {\n const childOptions: IWriteModifiedTextOptions = { ...options };\n childOptions.separatorOverride = undefined;\n child._writeModifiedText(childOptions);\n } else {\n child._writeModifiedText(options);\n }\n }\n } else {\n // The normal simple case\n for (const child of this.children) {\n child._writeModifiedText(options);\n }\n }\n }\n\n this._write(this.modification.suffix, options);\n\n if (options.separatorOverride !== undefined) {\n if (this.separator || childrenLength === 0) {\n this._write(options.separatorOverride, options);\n }\n } else {\n if (!this.modification.omitSeparatorAfter) {\n this._write(this.separator, options);\n }\n }\n }\n\n if (this.modification.indentDocComment === IndentDocCommentScope.SpanAndChildren) {\n this._endIndentDocComment(options);\n }\n }\n\n private _beginIndentDocComment(options: IWriteModifiedTextOptions): void {\n if (options.indentDocCommentState !== IndentDocCommentState.Inactive) {\n throw new InternalError('indentDocComment cannot be nested');\n }\n options.indentDocCommentState = IndentDocCommentState.AwaitingOpenDelimiter;\n }\n\n private _endIndentDocComment(options: IWriteModifiedTextOptions): void {\n if (options.indentDocCommentState === IndentDocCommentState.AwaitingCloseDelimiter) {\n throw new InternalError('missing \"*/\" delimiter for comment block');\n }\n options.indentDocCommentState = IndentDocCommentState.Inactive;\n }\n\n /**\n * Writes one chunk of `text` to the `options.writer`, applying the `indentDocComment` rewriting.\n */\n private _write(text: string, options: IWriteModifiedTextOptions): void {\n let parsedText: string = text;\n\n if (options.indentDocCommentState === IndentDocCommentState.AwaitingOpenDelimiter) {\n let index: number = parsedText.indexOf('/*');\n if (index >= 0) {\n index += '/*'.length;\n options.writer.write(parsedText.substring(0, index));\n parsedText = parsedText.substring(index);\n options.indentDocCommentState = IndentDocCommentState.AwaitingCloseDelimiter;\n\n options.writer.increaseIndent(' ');\n }\n }\n\n if (options.indentDocCommentState === IndentDocCommentState.AwaitingCloseDelimiter) {\n let index: number = parsedText.indexOf('*/');\n if (index >= 0) {\n index += '*/'.length;\n options.writer.write(parsedText.substring(0, index));\n parsedText = parsedText.substring(index);\n options.indentDocCommentState = IndentDocCommentState.Done;\n\n options.writer.decreaseIndent();\n }\n }\n\n options.writer.write(parsedText);\n }\n\n private _getTrimmed(text: string): string {\n return Text.truncateWithEllipsis(Text.convertToLf(text), 100);\n }\n\n private _getSubstring(startIndex: number, endIndex: number): string {\n if (startIndex === endIndex) {\n return '';\n }\n return this.node.getSourceFile().text.substring(startIndex, endIndex);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"TypeScriptHelpers.d.ts","sourceRoot":"","sources":["../../src/analyzer/TypeScriptHelpers.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAKjC,qBAAa,iBAAiB;IAG5B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,0BAA0B,CAAwB;IAI1E,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,uBAAuB,CAAyB;IAExE;;;;;;;;;;OAUG;WACW,aAAa,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,CAAC,WAAW,GAAG,EAAE,CAAC,MAAM;IAgBtF;;;OAGG;WACW,iBAAiB,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,CAAC,WAAW,GAAG,OAAO;IAaxF;;;;OAIG;WACW,kBAAkB,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,GAAG,EAAE,CAAC,WAAW,GAAG,SAAS;IAO/E;;OAEG;WACW,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,CAAC,WAAW,GAAG,OAAO;IA8BhF;;;OAGG;WACW,uBAAuB,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,EAAE,OAAO,EAAE,EAAE,CAAC,WAAW,GAAG,EAAE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,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,EAAE,CAAC,UAAU,GAAG,CAAC,GAAG,SAAS;IAa1G;;;;OAIG;WACW,iBAAiB,CAAC,CAAC,SAAS,EAAE,CAAC,IAAI,EAC/C,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,WAAW,EAAE,EAAE,CAAC,UAAU,GACzB,CAAC,GAAG,SAAS;IAehB;;;;;;;OAOG;WACW,4BAA4B,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,GAAG,MAAM,GAAG,SAAS;IASjF;;OAEG;WACW,kBAAkB,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,GAAG,OAAO;IAI5D;;OAEG;WACW,mBAAmB,CAAC,eAAe,EAAE,EAAE,CAAC,oBAAoB,GAAG,MAAM,GAAG,SAAS;CAsBhG"}
@@ -38,9 +38,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
38
38
  exports.TypeScriptHelpers = void 0;
39
39
  /* eslint-disable no-bitwise */
40
40
  const ts = __importStar(require("typescript"));
41
+ const node_core_library_1 = require("@rushstack/node-core-library");
41
42
  const SourceFileLocationFormatter_1 = require("./SourceFileLocationFormatter");
42
43
  const TypeScriptInternals_1 = require("./TypeScriptInternals");
43
- const node_core_library_1 = require("@rushstack/node-core-library");
44
44
  class TypeScriptHelpers {
45
45
  /**
46
46
  * This traverses any symbol aliases to find the original place where an item was defined.
@@ -1 +1 @@
1
- {"version":3,"file":"TypeScriptHelpers.js","sourceRoot":"","sources":["../../src/analyzer/TypeScriptHelpers.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,+BAA+B;AAE/B,+CAAiC;AACjC,+EAA4E;AAC5E,+DAA4D;AAC5D,oEAA6D;AAE7D,MAAa,iBAAiB;IAS5B;;;;;;;;;;OAUG;IACI,MAAM,CAAC,aAAa,CAAC,MAAiB,EAAE,WAA2B;QAC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served. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n/* eslint-disable no-bitwise */\n\nimport * as ts from 'typescript';\nimport { SourceFileLocationFormatter } from './SourceFileLocationFormatter';\nimport { TypeScriptInternals } from './TypeScriptInternals';\nimport { InternalError } from '@rushstack/node-core-library';\n\nexport class TypeScriptHelpers {\n // Matches TypeScript's encoded names for well-known ECMAScript symbols like\n // \"__@iterator\" or \"__@toStringTag\".\n private static readonly _wellKnownSymbolNameRegExp: RegExp = /^__@(\\w+)$/;\n\n // Matches TypeScript's encoded names for late-bound symbols derived from `unique symbol` declarations\n // which have the form of \"__@<variableName>@<symbolId>\", i.e. \"__@someSymbol@12345\".\n private static readonly _uniqueSymbolNameRegExp: RegExp = /^__@.*@\\d+$/;\n\n /**\n * This traverses any symbol aliases to find the original place where an item was defined.\n * For example, suppose a class is defined as \"export default class MyClass { }\"\n * but exported from the package's index.ts like this:\n *\n * export { default as _MyClass } from './MyClass';\n *\n * In this example, calling followAliases() on the _MyClass symbol will return the\n * original definition of MyClass, traversing any intermediary places where the\n * symbol was imported and re-exported.\n */\n public static followAliases(symbol: ts.Symbol, typeChecker: ts.TypeChecker): ts.Symbol {\n let current: ts.Symbol = symbol;\n for (;;) {\n if (!(current.flags & ts.SymbolFlags.Alias)) {\n break;\n }\n const currentAlias: ts.Symbol = typeChecker.getAliasedSymbol(current);\n if (!currentAlias || currentAlias === current) {\n break;\n }\n current = currentAlias;\n }\n\n return current;\n }\n\n /**\n * Returns true if TypeScriptHelpers.followAliases() would return something different\n * from the input `symbol`.\n */\n public static isFollowableAlias(symbol: ts.Symbol, typeChecker: ts.TypeChecker): boolean {\n if (!(symbol.flags & ts.SymbolFlags.Alias)) {\n return false;\n }\n\n const alias: ts.Symbol = typeChecker.getAliasedSymbol(symbol);\n if (!alias || alias === symbol) {\n return false;\n }\n\n return true;\n }\n\n /**\n * Certain virtual symbols do not have any declarations. For example, `ts.TypeChecker.getExportsOfModule()` can\n * sometimes return a \"prototype\" symbol for an object, even though there is no corresponding declaration in the\n * source code. API Extractor generally ignores such symbols.\n */\n public static tryGetADeclaration(symbol: ts.Symbol): ts.Declaration | undefined {\n if (symbol.declarations && symbol.declarations.length > 0) {\n return symbol.declarations[0];\n }\n return undefined;\n }\n\n /**\n * Returns true if the specified symbol is an ambient declaration.\n */\n public static isAmbient(symbol: ts.Symbol, typeChecker: ts.TypeChecker): boolean {\n const followedSymbol: ts.Symbol = TypeScriptHelpers.followAliases(symbol, typeChecker);\n\n if (followedSymbol.declarations && followedSymbol.declarations.length > 0) {\n const firstDeclaration: ts.Declaration = followedSymbol.declarations[0];\n\n // Test 1: Are we inside the sinister \"declare global {\" construct?\n const highestModuleDeclaration: ts.ModuleDeclaration | undefined = TypeScriptHelpers.findHighestParent(\n firstDeclaration,\n ts.SyntaxKind.ModuleDeclaration\n );\n if (highestModuleDeclaration) {\n if (highestModuleDeclaration.name.getText().trim() === 'global') {\n return true;\n }\n }\n\n // Test 2: Otherwise, the main heuristic for ambient declarations is by looking at the\n // ts.SyntaxKind.SourceFile node to see whether it has a symbol or not (i.e. whether it\n // is acting as a module or not).\n const sourceFile: ts.SourceFile = firstDeclaration.getSourceFile();\n\n if (typeChecker.getSymbolAtLocation(sourceFile)) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Same semantics as tryGetSymbolForDeclaration(), but throws an exception if the symbol\n * cannot be found.\n */\n public static getSymbolForDeclaration(declaration: ts.Declaration, checker: ts.TypeChecker): ts.Symbol {\n const symbol: ts.Symbol | undefined = TypeScriptInternals.tryGetSymbolForDeclaration(\n declaration,\n checker\n );\n if (!symbol) {\n throw new InternalError(\n 'Unable to determine semantic information for declaration:\\n' +\n SourceFileLocationFormatter.formatDeclaration(declaration)\n );\n }\n return symbol;\n }\n\n // Return name of the module, which could be like \"./SomeLocalFile' or like 'external-package/entry/point'\n public static getModuleSpecifier(\n nodeWithModuleSpecifier: ts.ImportDeclaration | ts.ExportDeclaration | ts.ImportTypeNode\n ): string | undefined {\n if (nodeWithModuleSpecifier.kind === ts.SyntaxKind.ImportType) {\n // As specified internally in typescript:/src/compiler/types.ts#ValidImportTypeNode\n if (\n nodeWithModuleSpecifier.argument.kind !== ts.SyntaxKind.LiteralType ||\n (nodeWithModuleSpecifier.argument as ts.LiteralTypeNode).literal.kind !== ts.SyntaxKind.StringLiteral\n ) {\n throw new InternalError(\n `Invalid ImportTypeNode: ${nodeWithModuleSpecifier.getText()}\\n` +\n SourceFileLocationFormatter.formatDeclaration(nodeWithModuleSpecifier)\n );\n }\n const literalTypeNode: ts.LiteralTypeNode = nodeWithModuleSpecifier.argument as ts.LiteralTypeNode;\n const stringLiteral: ts.StringLiteral = literalTypeNode.literal as ts.StringLiteral;\n return stringLiteral.text.trim();\n }\n\n // Node is a declaration\n if (\n nodeWithModuleSpecifier.moduleSpecifier &&\n ts.isStringLiteralLike(nodeWithModuleSpecifier.moduleSpecifier)\n ) {\n return TypeScriptInternals.getTextOfIdentifierOrLiteral(nodeWithModuleSpecifier.moduleSpecifier);\n }\n\n return undefined;\n }\n\n /**\n * Returns an ancestor of \"node\", such that the ancestor, any intermediary nodes,\n * and the starting node match a list of expected kinds. Undefined is returned\n * if there aren't enough ancestors, or if the kinds are incorrect.\n *\n * For example, suppose child \"C\" has parents A --> B --> C.\n *\n * Calling _matchAncestor(C, [ExportSpecifier, NamedExports, ExportDeclaration])\n * would return A only if A is of kind ExportSpecifier, B is of kind NamedExports,\n * and C is of kind ExportDeclaration.\n *\n * Calling _matchAncestor(C, [ExportDeclaration]) would return C.\n */\n public static matchAncestor<T extends ts.Node>(\n node: ts.Node,\n kindsToMatch: ts.SyntaxKind[]\n ): T | undefined {\n // (slice(0) clones an array)\n const reversedParentKinds: ts.SyntaxKind[] = kindsToMatch.slice(0).reverse();\n\n let current: ts.Node | undefined = undefined;\n\n for (const parentKind of reversedParentKinds) {\n if (!current) {\n // The first time through, start with node\n current = node;\n } else {\n // Then walk the parents\n current = current.parent;\n }\n\n // If we ran out of items, or if the kind doesn't match, then fail\n if (!current || current.kind !== parentKind) {\n return undefined;\n }\n }\n\n // If we matched everything, then return the node that matched the last parentKinds item\n return current as T;\n }\n\n /**\n * Does a depth-first search of the children of the specified node. Returns the first child\n * with the specified kind, or undefined if there is no match.\n */\n public static findFirstChildNode<T extends ts.Node>(\n node: ts.Node,\n kindToMatch: ts.SyntaxKind\n ): T | undefined {\n for (const child of node.getChildren()) {\n if (child.kind === kindToMatch) {\n return child as T;\n }\n\n const recursiveMatch: T | undefined = TypeScriptHelpers.findFirstChildNode(child, kindToMatch);\n if (recursiveMatch) {\n return recursiveMatch;\n }\n }\n\n return undefined;\n }\n\n /**\n * Returns the first parent node with the specified SyntaxKind, or undefined if there is no match.\n */\n public static findFirstParent<T extends ts.Node>(node: ts.Node, kindToMatch: ts.SyntaxKind): T | undefined {\n let current: ts.Node | undefined = node.parent;\n\n while (current) {\n if (current.kind === kindToMatch) {\n return current as T;\n }\n current = current.parent;\n }\n\n return undefined;\n }\n\n /**\n * Returns the highest parent node with the specified SyntaxKind, or undefined if there is no match.\n * @remarks\n * Whereas findFirstParent() returns the first match, findHighestParent() returns the last match.\n */\n public static findHighestParent<T extends ts.Node>(\n node: ts.Node,\n kindToMatch: ts.SyntaxKind\n ): T | undefined {\n let current: ts.Node | undefined = node;\n let highest: T | undefined = undefined;\n\n for (;;) {\n current = TypeScriptHelpers.findFirstParent<T>(current, kindToMatch);\n if (!current) {\n break;\n }\n highest = current as T;\n }\n\n return highest;\n }\n\n /**\n * Decodes the names that the compiler generates for a built-in ECMAScript symbol.\n *\n * @remarks\n * TypeScript binds well-known ECMAScript symbols like `[Symbol.iterator]` as `__@iterator`.\n * If `name` is of this form, then `tryGetWellKnownSymbolName()` converts it back into e.g. `[Symbol.iterator]`.\n * If the string does not start with `__@` then `undefined` is returned.\n */\n public static tryDecodeWellKnownSymbolName(name: ts.__String): string | undefined {\n const match: RegExpExecArray | null = TypeScriptHelpers._wellKnownSymbolNameRegExp.exec(name as string);\n if (match) {\n const identifier: string = match[1];\n return `[Symbol.${identifier}]`;\n }\n return undefined;\n }\n\n /**\n * Returns whether the provided name was generated for a TypeScript `unique symbol`.\n */\n public static isUniqueSymbolName(name: ts.__String): boolean {\n return TypeScriptHelpers._uniqueSymbolNameRegExp.test(name as string);\n }\n\n /**\n * Derives the string representation of a TypeScript late-bound symbol.\n */\n public static tryGetLateBoundName(declarationName: ts.ComputedPropertyName): string | undefined {\n // Create a node printer that ignores comments and indentation that we can use to convert\n // declarationName to a string.\n const printer: ts.Printer = ts.createPrinter(\n { removeComments: true },\n {\n onEmitNode(\n hint: ts.EmitHint,\n node: ts.Node,\n emitCallback: (hint: ts.EmitHint, node: ts.Node) => void\n ): void {\n ts.setEmitFlags(declarationName, ts.EmitFlags.NoIndentation | ts.EmitFlags.SingleLine);\n emitCallback(hint, node);\n }\n }\n );\n const sourceFile: ts.SourceFile = declarationName.getSourceFile();\n const text: string = printer.printNode(ts.EmitHint.Unspecified, declarationName, sourceFile);\n // clean up any emit flags we've set on any nodes in the tree.\n ts.disposeEmitNodes(sourceFile);\n return text;\n }\n}\n"]}
1
+ {"version":3,"file":"TypeScriptHelpers.js","sourceRoot":"","sources":["../../src/analyzer/TypeScriptHelpers.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,+BAA+B;AAE/B,+CAAiC;AAEjC,oEAA6D;AAE7D,+EAA4E;AAC5E,+DAA4D;AAE5D,MAAa,iBAAiB;IAS5B;;;;;;;;;;OAUG;IACI,MAAM,CAAC,aAAa,CAAC,MAAiB,EAAE,WAA2B;QACxE,IAAI,OAAO,GAAc,MAAM,CAAC;QAChC,SAAS,CAAC;YACR,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC5C,MAAM;YACR,CAAC;YACD,MAAM,YAAY,GAAc,WAAW,CAAC,gBAAgB,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,CAAC;IACnB,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,kBAAkB,CAAC,IAAiB;QAChD,OAAO,iBAAiB,CAAC,uBAAuB,CAAC,IAAI,CAAC,IAAc,CAAC,CAAC;IACxE,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,mBAAmB,CAAC,eAAwC;QACxE,yFAAyF;QACzF,+BAA+B;QAC/B,MAAM,OAAO,GAAe,EAAE,CAAC,aAAa,CAC1C,EAAE,cAAc,EAAE,IAAI,EAAE,EACxB;YACE,UAAU,CACR,IAAiB,EACjB,IAAa,EACb,YAAwD;gBAExD,EAAE,CAAC,YAAY,CAAC,eAAe,EAAE,EAAE,CAAC,SAAS,CAAC,aAAa,GAAG,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;gBACvF,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAC3B,CAAC;SACF,CACF,CAAC;QACF,MAAM,UAAU,GAAkB,eAAe,CAAC,aAAa,EAAE,CAAC;QAClE,MAAM,IAAI,GAAW,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,QAAQ,CAAC,WAAW,EAAE,eAAe,EAAE,UAAU,CAAC,CAAC;QAC7F,8DAA8D;QAC9D,EAAE,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;;AAzSH,8CA0SC;AAzSC,4EAA4E;AAC5E,qCAAqC;AACb,4CAA0B,GAAW,YAAY,CAAC;AAE1E,sGAAsG;AACtG,qFAAqF;AAC7D,yCAAuB,GAAW,aAAa,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n/* eslint-disable no-bitwise */\n\nimport * as ts from 'typescript';\n\nimport { InternalError } from '@rushstack/node-core-library';\n\nimport { SourceFileLocationFormatter } from './SourceFileLocationFormatter';\nimport { TypeScriptInternals } from './TypeScriptInternals';\n\nexport class TypeScriptHelpers {\n // Matches TypeScript's encoded names for well-known ECMAScript symbols like\n // \"__@iterator\" or \"__@toStringTag\".\n private static readonly _wellKnownSymbolNameRegExp: RegExp = /^__@(\\w+)$/;\n\n // Matches TypeScript's encoded names for late-bound symbols derived from `unique symbol` declarations\n // which have the form of \"__@<variableName>@<symbolId>\", i.e. \"__@someSymbol@12345\".\n private static readonly _uniqueSymbolNameRegExp: RegExp = /^__@.*@\\d+$/;\n\n /**\n * This traverses any symbol aliases to find the original place where an item was defined.\n * For example, suppose a class is defined as \"export default class MyClass { }\"\n * but exported from the package's index.ts like this:\n *\n * export { default as _MyClass } from './MyClass';\n *\n * In this example, calling followAliases() on the _MyClass symbol will return the\n * original definition of MyClass, traversing any intermediary places where the\n * symbol was imported and re-exported.\n */\n public static followAliases(symbol: ts.Symbol, typeChecker: ts.TypeChecker): ts.Symbol {\n let current: ts.Symbol = symbol;\n for (;;) {\n if (!(current.flags & ts.SymbolFlags.Alias)) {\n break;\n }\n const currentAlias: ts.Symbol = typeChecker.getAliasedSymbol(current);\n if (!currentAlias || currentAlias === current) {\n break;\n }\n current = currentAlias;\n }\n\n return current;\n }\n\n /**\n * Returns true if TypeScriptHelpers.followAliases() would return something different\n * from the input `symbol`.\n */\n public static isFollowableAlias(symbol: ts.Symbol, typeChecker: ts.TypeChecker): boolean {\n if (!(symbol.flags & ts.SymbolFlags.Alias)) {\n return false;\n }\n\n const alias: ts.Symbol = typeChecker.getAliasedSymbol(symbol);\n if (!alias || alias === symbol) {\n return false;\n }\n\n return true;\n }\n\n /**\n * Certain virtual symbols do not have any declarations. For example, `ts.TypeChecker.getExportsOfModule()` can\n * sometimes return a \"prototype\" symbol for an object, even though there is no corresponding declaration in the\n * source code. API Extractor generally ignores such symbols.\n */\n public static tryGetADeclaration(symbol: ts.Symbol): ts.Declaration | undefined {\n if (symbol.declarations && symbol.declarations.length > 0) {\n return symbol.declarations[0];\n }\n return undefined;\n }\n\n /**\n * Returns true if the specified symbol is an ambient declaration.\n */\n public static isAmbient(symbol: ts.Symbol, typeChecker: ts.TypeChecker): boolean {\n const followedSymbol: ts.Symbol = TypeScriptHelpers.followAliases(symbol, typeChecker);\n\n if (followedSymbol.declarations && followedSymbol.declarations.length > 0) {\n const firstDeclaration: ts.Declaration = followedSymbol.declarations[0];\n\n // Test 1: Are we inside the sinister \"declare global {\" construct?\n const highestModuleDeclaration: ts.ModuleDeclaration | undefined = TypeScriptHelpers.findHighestParent(\n firstDeclaration,\n ts.SyntaxKind.ModuleDeclaration\n );\n if (highestModuleDeclaration) {\n if (highestModuleDeclaration.name.getText().trim() === 'global') {\n return true;\n }\n }\n\n // Test 2: Otherwise, the main heuristic for ambient declarations is by looking at the\n // ts.SyntaxKind.SourceFile node to see whether it has a symbol or not (i.e. whether it\n // is acting as a module or not).\n const sourceFile: ts.SourceFile = firstDeclaration.getSourceFile();\n\n if (typeChecker.getSymbolAtLocation(sourceFile)) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Same semantics as tryGetSymbolForDeclaration(), but throws an exception if the symbol\n * cannot be found.\n */\n public static getSymbolForDeclaration(declaration: ts.Declaration, checker: ts.TypeChecker): ts.Symbol {\n const symbol: ts.Symbol | undefined = TypeScriptInternals.tryGetSymbolForDeclaration(\n declaration,\n checker\n );\n if (!symbol) {\n throw new InternalError(\n 'Unable to determine semantic information for declaration:\\n' +\n SourceFileLocationFormatter.formatDeclaration(declaration)\n );\n }\n return symbol;\n }\n\n // Return name of the module, which could be like \"./SomeLocalFile' or like 'external-package/entry/point'\n public static getModuleSpecifier(\n nodeWithModuleSpecifier: ts.ImportDeclaration | ts.ExportDeclaration | ts.ImportTypeNode\n ): string | undefined {\n if (nodeWithModuleSpecifier.kind === ts.SyntaxKind.ImportType) {\n // As specified internally in typescript:/src/compiler/types.ts#ValidImportTypeNode\n if (\n nodeWithModuleSpecifier.argument.kind !== ts.SyntaxKind.LiteralType ||\n (nodeWithModuleSpecifier.argument as ts.LiteralTypeNode).literal.kind !== ts.SyntaxKind.StringLiteral\n ) {\n throw new InternalError(\n `Invalid ImportTypeNode: ${nodeWithModuleSpecifier.getText()}\\n` +\n SourceFileLocationFormatter.formatDeclaration(nodeWithModuleSpecifier)\n );\n }\n const literalTypeNode: ts.LiteralTypeNode = nodeWithModuleSpecifier.argument as ts.LiteralTypeNode;\n const stringLiteral: ts.StringLiteral = literalTypeNode.literal as ts.StringLiteral;\n return stringLiteral.text.trim();\n }\n\n // Node is a declaration\n if (\n nodeWithModuleSpecifier.moduleSpecifier &&\n ts.isStringLiteralLike(nodeWithModuleSpecifier.moduleSpecifier)\n ) {\n return TypeScriptInternals.getTextOfIdentifierOrLiteral(nodeWithModuleSpecifier.moduleSpecifier);\n }\n\n return undefined;\n }\n\n /**\n * Returns an ancestor of \"node\", such that the ancestor, any intermediary nodes,\n * and the starting node match a list of expected kinds. Undefined is returned\n * if there aren't enough ancestors, or if the kinds are incorrect.\n *\n * For example, suppose child \"C\" has parents A --> B --> C.\n *\n * Calling _matchAncestor(C, [ExportSpecifier, NamedExports, ExportDeclaration])\n * would return A only if A is of kind ExportSpecifier, B is of kind NamedExports,\n * and C is of kind ExportDeclaration.\n *\n * Calling _matchAncestor(C, [ExportDeclaration]) would return C.\n */\n public static matchAncestor<T extends ts.Node>(\n node: ts.Node,\n kindsToMatch: ts.SyntaxKind[]\n ): T | undefined {\n // (slice(0) clones an array)\n const reversedParentKinds: ts.SyntaxKind[] = kindsToMatch.slice(0).reverse();\n\n let current: ts.Node | undefined = undefined;\n\n for (const parentKind of reversedParentKinds) {\n if (!current) {\n // The first time through, start with node\n current = node;\n } else {\n // Then walk the parents\n current = current.parent;\n }\n\n // If we ran out of items, or if the kind doesn't match, then fail\n if (!current || current.kind !== parentKind) {\n return undefined;\n }\n }\n\n // If we matched everything, then return the node that matched the last parentKinds item\n return current as T;\n }\n\n /**\n * Does a depth-first search of the children of the specified node. Returns the first child\n * with the specified kind, or undefined if there is no match.\n */\n public static findFirstChildNode<T extends ts.Node>(\n node: ts.Node,\n kindToMatch: ts.SyntaxKind\n ): T | undefined {\n for (const child of node.getChildren()) {\n if (child.kind === kindToMatch) {\n return child as T;\n }\n\n const recursiveMatch: T | undefined = TypeScriptHelpers.findFirstChildNode(child, kindToMatch);\n if (recursiveMatch) {\n return recursiveMatch;\n }\n }\n\n return undefined;\n }\n\n /**\n * Returns the first parent node with the specified SyntaxKind, or undefined if there is no match.\n */\n public static findFirstParent<T extends ts.Node>(node: ts.Node, kindToMatch: ts.SyntaxKind): T | undefined {\n let current: ts.Node | undefined = node.parent;\n\n while (current) {\n if (current.kind === kindToMatch) {\n return current as T;\n }\n current = current.parent;\n }\n\n return undefined;\n }\n\n /**\n * Returns the highest parent node with the specified SyntaxKind, or undefined if there is no match.\n * @remarks\n * Whereas findFirstParent() returns the first match, findHighestParent() returns the last match.\n */\n public static findHighestParent<T extends ts.Node>(\n node: ts.Node,\n kindToMatch: ts.SyntaxKind\n ): T | undefined {\n let current: ts.Node | undefined = node;\n let highest: T | undefined = undefined;\n\n for (;;) {\n current = TypeScriptHelpers.findFirstParent<T>(current, kindToMatch);\n if (!current) {\n break;\n }\n highest = current as T;\n }\n\n return highest;\n }\n\n /**\n * Decodes the names that the compiler generates for a built-in ECMAScript symbol.\n *\n * @remarks\n * TypeScript binds well-known ECMAScript symbols like `[Symbol.iterator]` as `__@iterator`.\n * If `name` is of this form, then `tryGetWellKnownSymbolName()` converts it back into e.g. `[Symbol.iterator]`.\n * If the string does not start with `__@` then `undefined` is returned.\n */\n public static tryDecodeWellKnownSymbolName(name: ts.__String): string | undefined {\n const match: RegExpExecArray | null = TypeScriptHelpers._wellKnownSymbolNameRegExp.exec(name as string);\n if (match) {\n const identifier: string = match[1];\n return `[Symbol.${identifier}]`;\n }\n return undefined;\n }\n\n /**\n * Returns whether the provided name was generated for a TypeScript `unique symbol`.\n */\n public static isUniqueSymbolName(name: ts.__String): boolean {\n return TypeScriptHelpers._uniqueSymbolNameRegExp.test(name as string);\n }\n\n /**\n * Derives the string representation of a TypeScript late-bound symbol.\n */\n public static tryGetLateBoundName(declarationName: ts.ComputedPropertyName): string | undefined {\n // Create a node printer that ignores comments and indentation that we can use to convert\n // declarationName to a string.\n const printer: ts.Printer = ts.createPrinter(\n { removeComments: true },\n {\n onEmitNode(\n hint: ts.EmitHint,\n node: ts.Node,\n emitCallback: (hint: ts.EmitHint, node: ts.Node) => void\n ): void {\n ts.setEmitFlags(declarationName, ts.EmitFlags.NoIndentation | ts.EmitFlags.SingleLine);\n emitCallback(hint, node);\n }\n }\n );\n const sourceFile: ts.SourceFile = declarationName.getSourceFile();\n const text: string = printer.printNode(ts.EmitHint.Unspecified, declarationName, sourceFile);\n // clean up any emit flags we've set on any nodes in the tree.\n ts.disposeEmitNodes(sourceFile);\n return text;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"TypeScriptInternals.d.ts","sourceRoot":"","sources":["../../src/analyzer/TypeScriptInternals.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAGjC;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CACtC;AAED,qBAAa,mBAAmB;WAChB,yBAAyB,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,CAAC,WAAW,GAAG,EAAE,CAAC,MAAM;IAMlG;;;;;;;OAOG;WACW,0BAA0B,CACtC,WAAW,EAAE,EAAE,CAAC,WAAW,EAC3B,OAAO,EAAE,EAAE,CAAC,WAAW,GACtB,EAAE,CAAC,MAAM,GAAG,SAAS;IASxB;;;OAGG;WACW,iBAAiB,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,GAAG,OAAO;IAW3D;;OAEG;WACW,qBAAqB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,EAAE,CAAC,YAAY,EAAE,GAAG,SAAS;IAO/F;;OAEG;WACW,4BAA4B,CACxC,IAA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,CAAC,kCAAkC,mCAAI,UAAU,CAAC,cAAc,CAAC;QAE7E,IAAI,CAAC,mBAAmB,EAAE,CAAC;YACzB,MAAM,IAAI,iCAAa,CAAC,8EAA8E,CAAC,CAAC;QAC1G,CAAC;QACD,MAAM,WAAW,GAAQ,mBAAmB,EAAE,CAAC;QAC/C,IAAI,CAAC,WAAW,CAAC,eAAe,EAAE,CAAC;YACjC,MAAM,IAAI,iCAAa,CAAC,qCAAqC,CAAC,CAAC;QACjE,CAAC;QACD,MAAM,QAAQ,GAAQ,WAAW,CAAC,eAAe,EAAE,CAAC;QACpD,IAAI,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAC;YAC5B,MAAM,IAAI,iCAAa,CAAC,oCAAoC,CAAC,CAAC;QAChE,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,UAAU,CAAC,IAAyD;QAChF,0IAA0I;QAC1I,OAAQ,EAAU,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;CACF;AA3ID,kDA2IC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport * as ts from 'typescript';\nimport { InternalError } from '@rushstack/node-core-library';\n\n/**\n * Exposes the TypeScript compiler internals for detecting global variable names.\n */\nexport interface IGlobalVariableAnalyzer {\n hasGlobalName(name: string): boolean;\n}\n\nexport class TypeScriptInternals {\n public static getImmediateAliasedSymbol(symbol: ts.Symbol, typeChecker: ts.TypeChecker): ts.Symbol {\n // Compiler internal:\n // https://github.com/microsoft/TypeScript/blob/v3.2.2/src/compiler/checker.ts\n return (typeChecker as any).getImmediateAliasedSymbol(symbol);\n }\n\n /**\n * Returns the Symbol for the provided Declaration. This is a workaround for a missing\n * feature of the TypeScript Compiler API. It is the only apparent way to reach\n * certain data structures, and seems to always work, but is not officially documented.\n *\n * @returns The associated Symbol. If there is no semantic information (e.g. if the\n * declaration is an extra semicolon somewhere), then \"undefined\" is returned.\n */\n public static tryGetSymbolForDeclaration(\n declaration: ts.Declaration,\n checker: ts.TypeChecker\n ): ts.Symbol | undefined {\n let symbol: ts.Symbol | undefined = (declaration as any).symbol;\n if (symbol && symbol.escapedName === ts.InternalSymbolName.Computed) {\n const name: ts.DeclarationName | undefined = ts.getNameOfDeclaration(declaration);\n symbol = (name && checker.getSymbolAtLocation(name)) || symbol;\n }\n return symbol;\n }\n\n /**\n * Returns whether the provided Symbol is a TypeScript \"late-bound\" Symbol (i.e. was created by the Checker\n * for a computed property based on its type, rather than by the Binder).\n */\n public static isLateBoundSymbol(symbol: ts.Symbol): boolean {\n if (\n // eslint-disable-next-line no-bitwise\n symbol.flags & ts.SymbolFlags.Transient &&\n (ts as any).getCheckFlags(symbol) === (ts as any).CheckFlags.Late\n ) {\n return true;\n }\n return false;\n }\n\n /**\n * Retrieves the comment ranges associated with the specified node.\n */\n public static getJSDocCommentRanges(node: ts.Node, text: string): ts.CommentRange[] | undefined {\n // Compiler internal:\n // https://github.com/microsoft/TypeScript/blob/v2.4.2/src/compiler/utilities.ts#L616\n\n return (ts as any).getJSDocCommentRanges.apply(this, arguments);\n }\n\n /**\n * Retrieves the (unescaped) value of an string literal, numeric literal, or identifier.\n */\n public static getTextOfIdentifierOrLiteral(\n node: ts.Identifier | ts.StringLiteralLike | ts.NumericLiteral\n ): string {\n // Compiler internal:\n // https://github.com/microsoft/TypeScript/blob/v3.2.2/src/compiler/utilities.ts#L2721\n\n return (ts as any).getTextOfIdentifierOrLiteral(node);\n }\n\n /**\n * Retrieves the (cached) module resolution information for a module name that was exported from a SourceFile.\n * The compiler populates this cache as part of analyzing the source file.\n */\n public static getResolvedModule(\n program: ts.Program,\n sourceFile: ts.SourceFile,\n moduleNameText: string,\n mode: ts.ModuleKind.CommonJS | ts.ModuleKind.ESNext | undefined\n ): ts.ResolvedModuleFull | undefined {\n // Compiler internal:\n // https://github.com/microsoft/TypeScript/blob/v5.3.3/src/compiler/types.ts#L4698\n const result: ts.ResolvedModuleWithFailedLookupLocations | undefined = (program as any).getResolvedModule(\n sourceFile,\n moduleNameText,\n mode\n );\n return result?.resolvedModule;\n }\n\n /**\n * Gets the mode required for module resolution required with the addition of Node16/nodenext\n */\n public static getModeForUsageLocation(\n file: ts.SourceFile,\n usage: ts.StringLiteralLike,\n compilerOptions: ts.CompilerOptions\n ): ts.ModuleKind.CommonJS | ts.ModuleKind.ESNext | undefined {\n // Compiler internal:\n // https://github.com/microsoft/TypeScript/blob/v5.8.2/src/compiler/program.ts#L931\n\n return ts.getModeForUsageLocation?.(file, usage, compilerOptions);\n }\n\n /**\n * Returns ts.Symbol.parent if it exists.\n */\n public static getSymbolParent(symbol: ts.Symbol): ts.Symbol | undefined {\n return (symbol as any).parent;\n }\n\n /**\n * In an statement like `export default class X { }`, the `Symbol.name` will be `default`\n * whereas the `localSymbol` is `X`.\n */\n public static tryGetLocalSymbol(declaration: ts.Declaration): ts.Symbol | undefined {\n return (declaration as any).localSymbol;\n }\n\n public static getGlobalVariableAnalyzer(program: ts.Program): IGlobalVariableAnalyzer {\n const anyProgram: any = program;\n const typeCheckerInstance: any =\n anyProgram.getDiagnosticsProducingTypeChecker ?? anyProgram.getTypeChecker;\n\n if (!typeCheckerInstance) {\n throw new InternalError('Missing Program.getDiagnosticsProducingTypeChecker or Program.getTypeChecker');\n }\n const typeChecker: any = typeCheckerInstance();\n if (!typeChecker.getEmitResolver) {\n throw new InternalError('Missing TypeChecker.getEmitResolver');\n }\n const resolver: any = typeChecker.getEmitResolver();\n if (!resolver.hasGlobalName) {\n throw new InternalError('Missing EmitResolver.hasGlobalName');\n }\n return resolver;\n }\n\n /**\n * Returns whether a variable is declared with the const keyword\n */\n public static isVarConst(node: ts.VariableDeclaration | ts.VariableDeclarationList): boolean {\n // Compiler internal: https://github.com/microsoft/TypeScript/blob/71286e3d49c10e0e99faac360a6bbd40f12db7b6/src/compiler/utilities.ts#L925\n return (ts as any).isVarConst(node);\n }\n}\n"]}
1
+ {"version":3,"file":"TypeScriptInternals.js","sourceRoot":"","sources":["../../src/analyzer/TypeScriptInternals.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,uDAAuD;AAEvD,+CAAiC;AAEjC,oEAA6D;AAS7D,MAAa,mBAAmB;IACvB,MAAM,CAAC,yBAAyB,CAAC,MAAiB,EAAE,WAA2B;QACpF,qBAAqB;QACrB,8EAA8E;QAC9E,OAAQ,WAAmB,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC;IAChE,CAAC;IAED;;;;;;;OAOG;IACI,MAAM,CAAC,0BAA0B,CACtC,WAA2B,EAC3B,OAAuB;QAEvB,IAAI,MAAM,GAA2B,WAAmB,CAAC,MAAM,CAAC;QAChE,IAAI,MAAM,IAAI,MAAM,CAAC,WAAW,KAAK,EAAE,CAAC,kBAAkB,CAAC,QAAQ,EAAE,CAAC;YACpE,MAAM,IAAI,GAAmC,EAAE,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC;YAClF,MAAM,GAAG,CAAC,IAAI,IAAI,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,IAAI,MAAM,CAAC;QACjE,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,iBAAiB,CAAC,MAAiB;QAC/C;QACE,sCAAsC;QACtC,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,SAAS;YACtC,EAAU,CAAC,aAAa,CAAC,MAAM,CAAC,KAAM,EAAU,CAAC,UAAU,CAAC,IAAI,EACjE,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,qBAAqB,CAAC,IAAa,EAAE,IAAY;QAC7D,qBAAqB;QACrB,qFAAqF;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,mBAAmB,EAAE,CAAC;QAC/C,IAAI,CAAC,WAAW,CAAC,eAAe,EAAE,CAAC;YACjC,MAAM,IAAI,iCAAa,CAAC,qCAAqC,CAAC,CAAC;QACjE,CAAC;QACD,MAAM,QAAQ,GAAQ,WAAW,CAAC,eAAe,EAAE,CAAC;QACpD,IAAI,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAC;YAC5B,MAAM,IAAI,iCAAa,CAAC,oCAAoC,CAAC,CAAC;QAChE,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,UAAU,CAAC,IAAyD;QAChF,0IAA0I;QAC1I,OAAQ,EAAU,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;CACF;AA3ID,kDA2IC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport * as ts from 'typescript';\n\nimport { InternalError } from '@rushstack/node-core-library';\n\n/**\n * Exposes the TypeScript compiler internals for detecting global variable names.\n */\nexport interface IGlobalVariableAnalyzer {\n hasGlobalName(name: string): boolean;\n}\n\nexport class TypeScriptInternals {\n public static getImmediateAliasedSymbol(symbol: ts.Symbol, typeChecker: ts.TypeChecker): ts.Symbol {\n // Compiler internal:\n // https://github.com/microsoft/TypeScript/blob/v3.2.2/src/compiler/checker.ts\n return (typeChecker as any).getImmediateAliasedSymbol(symbol);\n }\n\n /**\n * Returns the Symbol for the provided Declaration. This is a workaround for a missing\n * feature of the TypeScript Compiler API. It is the only apparent way to reach\n * certain data structures, and seems to always work, but is not officially documented.\n *\n * @returns The associated Symbol. If there is no semantic information (e.g. if the\n * declaration is an extra semicolon somewhere), then \"undefined\" is returned.\n */\n public static tryGetSymbolForDeclaration(\n declaration: ts.Declaration,\n checker: ts.TypeChecker\n ): ts.Symbol | undefined {\n let symbol: ts.Symbol | undefined = (declaration as any).symbol;\n if (symbol && symbol.escapedName === ts.InternalSymbolName.Computed) {\n const name: ts.DeclarationName | undefined = ts.getNameOfDeclaration(declaration);\n symbol = (name && checker.getSymbolAtLocation(name)) || symbol;\n }\n return symbol;\n }\n\n /**\n * Returns whether the provided Symbol is a TypeScript \"late-bound\" Symbol (i.e. was created by the Checker\n * for a computed property based on its type, rather than by the Binder).\n */\n public static isLateBoundSymbol(symbol: ts.Symbol): boolean {\n if (\n // eslint-disable-next-line no-bitwise\n symbol.flags & ts.SymbolFlags.Transient &&\n (ts as any).getCheckFlags(symbol) === (ts as any).CheckFlags.Late\n ) {\n return true;\n }\n return false;\n }\n\n /**\n * Retrieves the comment ranges associated with the specified node.\n */\n public static getJSDocCommentRanges(node: ts.Node, text: string): ts.CommentRange[] | undefined {\n // Compiler internal:\n // https://github.com/microsoft/TypeScript/blob/v2.4.2/src/compiler/utilities.ts#L616\n\n return (ts as any).getJSDocCommentRanges.apply(this, arguments);\n }\n\n /**\n * Retrieves the (unescaped) value of an string literal, numeric literal, or identifier.\n */\n public static getTextOfIdentifierOrLiteral(\n node: ts.Identifier | ts.StringLiteralLike | ts.NumericLiteral\n ): string {\n // Compiler internal:\n // https://github.com/microsoft/TypeScript/blob/v3.2.2/src/compiler/utilities.ts#L2721\n\n return (ts as any).getTextOfIdentifierOrLiteral(node);\n }\n\n /**\n * Retrieves the (cached) module resolution information for a module name that was exported from a SourceFile.\n * The compiler populates this cache as part of analyzing the source file.\n */\n public static getResolvedModule(\n program: ts.Program,\n sourceFile: ts.SourceFile,\n moduleNameText: string,\n mode: ts.ModuleKind.CommonJS | ts.ModuleKind.ESNext | undefined\n ): ts.ResolvedModuleFull | undefined {\n // Compiler internal:\n // https://github.com/microsoft/TypeScript/blob/v5.3.3/src/compiler/types.ts#L4698\n const result: ts.ResolvedModuleWithFailedLookupLocations | undefined = (program as any).getResolvedModule(\n sourceFile,\n moduleNameText,\n mode\n );\n return result?.resolvedModule;\n }\n\n /**\n * Gets the mode required for module resolution required with the addition of Node16/nodenext\n */\n public static getModeForUsageLocation(\n file: ts.SourceFile,\n usage: ts.StringLiteralLike,\n compilerOptions: ts.CompilerOptions\n ): ts.ModuleKind.CommonJS | ts.ModuleKind.ESNext | undefined {\n // Compiler internal:\n // https://github.com/microsoft/TypeScript/blob/v5.8.2/src/compiler/program.ts#L931\n\n return ts.getModeForUsageLocation?.(file, usage, compilerOptions);\n }\n\n /**\n * Returns ts.Symbol.parent if it exists.\n */\n public static getSymbolParent(symbol: ts.Symbol): ts.Symbol | undefined {\n return (symbol as any).parent;\n }\n\n /**\n * In an statement like `export default class X { }`, the `Symbol.name` will be `default`\n * whereas the `localSymbol` is `X`.\n */\n public static tryGetLocalSymbol(declaration: ts.Declaration): ts.Symbol | undefined {\n return (declaration as any).localSymbol;\n }\n\n public static getGlobalVariableAnalyzer(program: ts.Program): IGlobalVariableAnalyzer {\n const anyProgram: any = program;\n const typeCheckerInstance: any =\n anyProgram.getDiagnosticsProducingTypeChecker ?? anyProgram.getTypeChecker;\n\n if (!typeCheckerInstance) {\n throw new InternalError('Missing Program.getDiagnosticsProducingTypeChecker or Program.getTypeChecker');\n }\n const typeChecker: any = typeCheckerInstance();\n if (!typeChecker.getEmitResolver) {\n throw new InternalError('Missing TypeChecker.getEmitResolver');\n }\n const resolver: any = typeChecker.getEmitResolver();\n if (!resolver.hasGlobalName) {\n throw new InternalError('Missing EmitResolver.hasGlobalName');\n }\n return resolver;\n }\n\n /**\n * Returns whether a variable is declared with the const keyword\n */\n public static isVarConst(node: ts.VariableDeclaration | ts.VariableDeclarationList): boolean {\n // Compiler internal: https://github.com/microsoft/TypeScript/blob/71286e3d49c10e0e99faac360a6bbd40f12db7b6/src/compiler/utilities.ts#L925\n return (ts as any).isVarConst(node);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"CompilerState.d.ts","sourceRoot":"","sources":["../../src/api/CompilerState.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAIpD;;;GAGG;AACH,MAAM,WAAW,2BAA2B;IAC1C,qEAAqE;IACrE,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAElC;;OAEG;IACH,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;CAClC;AAED;;;;;GAKG;AACH,qBAAa,aAAa;IACxB;;OAEG;IACH,SAAgB,OAAO,EAAE,OAAO,CAAC;IAEjC,OAAO;IAIP;;OAEG;WACW,MAAM,CAClB,eAAe,EAAE,eAAe,EAChC,OAAO,CAAC,EAAE,2BAA2B,GACpC,aAAa;IAoDhB;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,MAAM,CAAC,6BAA6B;IAuB5C,OAAO,CAAC,MAAM,CAAC,mBAAmB;CAwEnC"}
1
+ {"version":3,"file":"CompilerState.d.ts","sourceRoot":"","sources":["../../src/api/CompilerState.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD;;;GAGG;AACH,MAAM,WAAW,2BAA2B;IAC1C,qEAAqE;IACrE,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAElC;;OAEG;IACH,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;CAClC;AAED;;;;;GAKG;AACH,qBAAa,aAAa;IACxB;;OAEG;IACH,SAAgB,OAAO,EAAE,OAAO,CAAC;IAEjC,OAAO;IAIP;;OAEG;WACW,MAAM,CAClB,eAAe,EAAE,eAAe,EAChC,OAAO,CAAC,EAAE,2BAA2B,GACpC,aAAa;IAoDhB;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,MAAM,CAAC,6BAA6B;IAuB5C,OAAO,CAAC,MAAM,CAAC,mBAAmB;CAwEnC"}
@@ -36,11 +36,11 @@ var __importStar = (this && this.__importStar) || (function () {
36
36
  })();
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
38
  exports.CompilerState = void 0;
39
- const path = __importStar(require("path"));
39
+ const path = __importStar(require("node:path"));
40
40
  const ts = __importStar(require("typescript"));
41
41
  const node_core_library_1 = require("@rushstack/node-core-library");
42
- const ExtractorConfig_1 = require("./ExtractorConfig");
43
42
  const terminal_1 = require("@rushstack/terminal");
43
+ const ExtractorConfig_1 = require("./ExtractorConfig");
44
44
  /**
45
45
  * This class represents the TypeScript compiler state. This allows an optimization where multiple invocations
46
46
  * of API Extractor can reuse the same TypeScript compiler analysis.