astro-ghostcms/.pnpm-store/v3/files/d6/3a46397e12b039bc51a7bc48686...

1 line
208 KiB
Plaintext
Raw Normal View History

2024-02-15 12:55:32 +00:00
{"version":3,"sources":["../src/comments.ts","../src/tokens.ts","../src/compilerOptions.ts","../src/flags.ts","../src/modifiers.ts","../src/nodes/typeGuards/compound.ts","../src/nodes/typeGuards/single.ts","../src/nodes/typeGuards/union.ts","../src/utils.ts","../src/scopes.ts","../src/syntax.ts","../src/types/getters.ts","../src/types/typeGuards/intrinsic.ts","../src/types/typeGuards/objects.ts","../src/types/typeGuards/single.ts","../src/types/typeGuards/compound.ts","../src/types/typeGuards/literal.ts","../src/types/utilities.ts","../src/nodes/utilities.ts","../src/usage/UsageWalker.ts","../src/usage/Scope.ts","../src/usage/declarations.ts","../src/usage/utils.ts","../src/usage/getPropertyName.ts","../src/usage/getUsageDomain.ts","../src/usage/scopes.ts","../src/usage/collectVariableUsage.ts"],"sourcesContent":["// Code largely based on https://github.com/ajafff/tsutils\n// Original license: https://github.com/ajafff/tsutils/blob/26b195358ec36d59f00333115aa3ffd9611ca78b/LICENSE\n\nimport ts from \"typescript\";\n\nimport { forEachToken } from \"./tokens\";\n\n/**\n * Exclude trailing positions that would lead to scanning for trivia inside `JsxText`.\n * @internal\n */\nfunction canHaveTrailingTrivia(token: ts.Node): boolean {\n\tswitch (token.kind) {\n\t\tcase ts.SyntaxKind.CloseBraceToken:\n\t\t\t// after a JsxExpression inside a JsxElement's body can only be other JsxChild, but no trivia\n\t\t\treturn (\n\t\t\t\ttoken.parent.kind !== ts.SyntaxKind.JsxExpression ||\n\t\t\t\t!isJsxElementOrFragment(token.parent.parent)\n\t\t\t);\n\t\tcase ts.SyntaxKind.GreaterThanToken:\n\t\t\tswitch (token.parent.kind) {\n\t\t\t\tcase ts.SyntaxKind.JsxOpeningElement:\n\t\t\t\t\t// if end is not equal, this is part of the type arguments list. in all other cases it would be inside the element body\n\t\t\t\t\treturn token.end !== token.parent.end;\n\t\t\t\tcase ts.SyntaxKind.JsxOpeningFragment:\n\t\t\t\t\treturn false; // would be inside the fragment\n\t\t\t\tcase ts.SyntaxKind.JsxSelfClosingElement:\n\t\t\t\t\treturn (\n\t\t\t\t\t\ttoken.end !== token.parent.end || // if end is not equal, this is part of the type arguments list\n\t\t\t\t\t\t!isJsxElementOrFragment(token.parent.parent)\n\t\t\t\t\t); // there's only trailing trivia if it's the end of the top element\n\t\t\t\tcase ts.SyntaxKind.JsxClosingElement:\n\t\t\t\tcase ts.SyntaxKind.JsxClosingFragment:\n\t\t\t\t\t// there's only trailing trivia if it's the end of the top element\n\t\t\t\t\treturn !isJsxElementOrFragment(token.parent.parent.parent);\n\t\t\t}\n\t}\n\n\treturn true;\n}\n\n/**\n * Test if a node is a `JsxElement` or `JsxFragment`.\n * @internal\n */\nfunction isJsxElementOrFragment(\n\tnode: ts.Node,\n): node is ts.JsxElement | ts.JsxFragment {\n\treturn (\n\t\tnode.kind === ts.SyntaxKind.JsxElement ||\n\t\tnode.kind === ts.SyntaxKind.JsxFragment\n\t);\n}\n\n/**\n * Callback type used for {@link forEachComment}.\n * @category Callbacks\n */\nexport type ForEachCommentCallback = (\n\tfullText: string,\n\tcomment: ts.CommentRange,\n) => void;\n\n/**\n * Iterates over all comments owned by `node` or its children.\n * @category Nodes - Other Utilities\n * @example\n * ```ts\n * declare const node: ts.Node;\n *\n * forEachComment(node, (fullText, comment) => {\n * console.log(`Found comment at position ${comment.pos}: '${fullText}'.`);\n * });\n * ```\n */\nexport function forEachComment(\n\tnode: ts.Node,\n\tcallback: ForEachCommentCallback,\n\tsourceFile: ts.SourceFile = node.getSourceFile(),\n): void {\n\t/* Visit all tokens and skip trivia.\n Comment ranges between tokens are parsed without the need of a scanner.\n forEachTokenWithWhitespace does intentionally not pay attention to the correct comment ownership of nodes as it always\n scans all trivia before each token, which could include trailing comments of the previous token.\n Comment ownership is done right in this function*/\n\tconst fullText = sourceFile.text;\n\tconst notJsx = sourceFile.languageVariant !== ts.LanguageVariant.JSX;\n\treturn forEachToken(\n\t\tnode,\n\t\t(token) => {\n