📄 convert-comments¶
📊 Analysis Summary¶
| Metric | Count |
|---|---|
| 🔧 Functions | 1 |
| 📦 Imports | 3 |
📚 Table of Contents¶
🛠️ File Location:¶
📂 packages/typescript-estree/src/convert-comments.ts
📦 Imports¶
| Name | Source |
|---|---|
TSESTree |
./ts-estree |
getLocFor |
./node-utils |
AST_TOKEN_TYPES |
./ts-estree |
Functions¶
convertComments(ast: ts.SourceFile): TSESTree.Comment[]¶
Convert all comments for the given AST.
Parameters:
astany: the AST object
Returns: undefined
the converted ESTreeComment
Tags: @private
Raw JSDoc
Calls:
Array.fromtsutils.iterateCommentsgetLocFor (from ./node-utils)
Code
export function convertComments(ast: ts.SourceFile): TSESTree.Comment[] {
return Array.from(
tsutils.iterateComments(ast),
({ end, kind, pos, value }) => {
const type =
kind === ts.SyntaxKind.SingleLineCommentTrivia
? AST_TOKEN_TYPES.Line
: AST_TOKEN_TYPES.Block;
const range: TSESTree.Range = [pos, end];
const loc = getLocFor(range, ast);
return {
type,
loc,
range,
value,
};
},
);
}
Generated by Syntax Scribe