毕设专用git仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
224 KiB

{"version":3,"sources":["../src/index.ts","../src/comments.ts","../src/tokens.ts","../src/compilerOptions.ts","../src/flags.ts","../src/modifiers.ts","../src/nodes/access.ts","../src/syntax.ts","../src/nodes/typeGuards/compound.ts","../src/nodes/typeGuards/single.ts","../src/nodes/typeGuards/union.ts","../src/utils.ts","../src/scopes.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":["export * from \"./comments\";\nexport * from \"./compilerOptions\";\nexport * from \"./flags\";\nexport * from \"./modifiers\";\nexport * from \"./nodes\";\nexport * from \"./scopes\";\nexport * from \"./syntax\";\nexport * from \"./tokens\";\nexport * from \"./types\";\nexport * from \"./usage\";\n","// 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 n