MCPcopy Create free account
hub / github.com/nodejs/node / findNextToken

Function findNextToken

test/fixtures/snapshot/typescript.js:127535–127551  ·  view source on GitHub ↗
(previousToken, parent, sourceFile)

Source from the content-addressed store, hash-verified

127533 }
127534 ts.findTokenOnLeftOfPosition = findTokenOnLeftOfPosition;
127535 function findNextToken(previousToken, parent, sourceFile) {
127536 return find(parent);
127537 function find(n) {
127538 if (ts.isToken(n) && n.pos === previousToken.end) {
127539 // this is token that starts at the end of previous token - return it
127540 return n;
127541 }
127542 return ts.firstDefined(n.getChildren(sourceFile), function (child) {
127543 var shouldDiveInChildNode =
127544 // previous token is enclosed somewhere in the child
127545 (child.pos <= previousToken.pos && child.end > previousToken.end) ||
127546 // previous token ends exactly at the beginning of child
127547 (child.pos === previousToken.end);
127548 return shouldDiveInChildNode && nodeHasTokens(child, sourceFile) ? find(child) : undefined;
127549 });
127550 }
127551 }
127552 ts.findNextToken = findNextToken;
127553 function findPrecedingToken(position, sourceFile, startNode, excludeJsdoc) {
127554 var result = find((startNode || sourceFile));

Callers 2

nodeIsASICandidateFunction · 0.85

Calls 1

findFunction · 0.70

Tested by

no test coverage detected