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

Function findTokenOnLeftOfPosition

test/fixtures/snapshot/typescript.js:127525–127533  ·  view source on GitHub ↗

* The token on the left of the position is the token that strictly includes the position * or sits to the left of the cursor if it is on a boundary. For example * * fo|o -> will return foo * foo |bar -> will return foo *

(file, position)

Source from the content-addressed store, hash-verified

127523 *
127524 */
127525 function findTokenOnLeftOfPosition(file, position) {
127526 // Ideally, getTokenAtPosition should return a token. However, it is currently
127527 // broken, so we do a check to make sure the result was indeed a token.
127528 var tokenAtPosition = getTokenAtPosition(file, position);
127529 if (ts.isToken(tokenAtPosition) && position > tokenAtPosition.getStart(file) && position < tokenAtPosition.getEnd()) {
127530 return tokenAtPosition;
127531 }
127532 return findPrecedingToken(position, file);
127533 }
127534 ts.findTokenOnLeftOfPosition = findTokenOnLeftOfPosition;
127535 function findNextToken(previousToken, parent, sourceFile) {
127536 return find(parent);

Callers

nothing calls this directly

Calls 2

getTokenAtPositionFunction · 0.85
findPrecedingTokenFunction · 0.85

Tested by

no test coverage detected