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

Function isInString

test/fixtures/snapshot/typescript.js:127639–127656  ·  view source on GitHub ↗
(sourceFile, position, previousToken)

Source from the content-addressed store, hash-verified

127637 }
127638 }
127639 function isInString(sourceFile, position, previousToken) {
127640 if (previousToken === void 0) { previousToken = findPrecedingToken(position, sourceFile); }
127641 if (previousToken && ts.isStringTextContainingNode(previousToken)) {
127642 var start = previousToken.getStart(sourceFile);
127643 var end = previousToken.getEnd();
127644 // To be "in" one of these literals, the position has to be:
127645 // 1. entirely within the token text.
127646 // 2. at the end position of an unterminated token.
127647 // 3. at the end of a regular expression (due to trailing flags like '/foo/g').
127648 if (start < position && position < end) {
127649 return true;
127650 }
127651 if (position === end) {
127652 return !!previousToken.isUnterminated;
127653 }
127654 }
127655 return false;
127656 }
127657 ts.isInString = isInString;
127658 /**
127659 * returns true if the position is in between the open and close elements of an JSX expression.

Callers

nothing calls this directly

Calls 1

findPrecedingTokenFunction · 0.85

Tested by

no test coverage detected