MCPcopy Index your code
hub / github.com/nodejs/node / getTokenPosOfNode

Function getTokenPosOfNode

test/fixtures/snapshot/typescript.js:14725–14748  ·  view source on GitHub ↗
(node, sourceFile, includeJsDoc)

Source from the content-addressed store, hash-verified

14723 }
14724 ts.createCommentDirectivesMap = createCommentDirectivesMap;
14725 function getTokenPosOfNode(node, sourceFile, includeJsDoc) {
14726 // With nodes that have no width (i.e. 'Missing' nodes), we actually *don't*
14727 // want to skip trivia because this will launch us forward to the next token.
14728 if (nodeIsMissing(node)) {
14729 return node.pos;
14730 }
14731 if (ts.isJSDocNode(node) || node.kind === 11 /* SyntaxKind.JsxText */) {
14732 // JsxText cannot actually contain comments, even though the scanner will think it sees comments
14733 return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, /*stopAfterLineBreak*/ false, /*stopAtComments*/ true);
14734 }
14735 if (includeJsDoc && ts.hasJSDocNodes(node)) {
14736 return getTokenPosOfNode(node.jsDoc[0], sourceFile);
14737 }
14738 // For a syntax list, it is possible that one of its children has JSDocComment nodes, while
14739 // the syntax list itself considers them as normal trivia. Therefore if we simply skip
14740 // trivia for the list, we may have skipped the JSDocComment as well. So we should process its
14741 // first child to determine the actual position of its first token.
14742 if (node.kind === 348 /* SyntaxKind.SyntaxList */ && node._children.length > 0) {
14743 return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc);
14744 }
14745 return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos,
14746 /*stopAfterLineBreak*/ false,
14747 /*stopAtComments*/ false, isInJSDoc(node));
14748 }
14749 ts.getTokenPosOfNode = getTokenPosOfNode;
14750 function getNonDecoratorTokenPosOfNode(node, sourceFile) {
14751 if (nodeIsMissing(node) || !node.decorators) {

Callers 2

rangeOfNodeFunction · 0.85

Calls 3

nodeIsMissingFunction · 0.85
getSourceFileOfNodeFunction · 0.85
isInJSDocFunction · 0.85

Tested by

no test coverage detected