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

Function nodeContainsPosition

test/fixtures/snapshot/typescript.js:127482–127500  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

127480 }
127481 }
127482 function nodeContainsPosition(node) {
127483 var start = allowPositionInLeadingTrivia ? node.getFullStart() : node.getStart(sourceFile, /*includeJsDoc*/ true);
127484 if (start > position) {
127485 // If this child begins after position, then all subsequent children will as well.
127486 return false;
127487 }
127488 var end = node.getEnd();
127489 if (position < end || (position === end && (node.kind === 1 /* SyntaxKind.EndOfFileToken */ || includeEndPosition))) {
127490 return true;
127491 }
127492 else if (includePrecedingTokenAtEndPosition && end === position) {
127493 var previousToken = findPrecedingToken(position, sourceFile, node);
127494 if (previousToken && includePrecedingTokenAtEndPosition(previousToken)) {
127495 foundToken = previousToken;
127496 return true;
127497 }
127498 }
127499 return false;
127500 }
127501 }
127502 /**
127503 * Returns the first token where position is in [start, end),

Callers 1

_loop_1Function · 0.85

Calls 1

findPrecedingTokenFunction · 0.85

Tested by

no test coverage detected