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

Function getScanStartPosition

test/fixtures/snapshot/typescript.js:147164–147180  ·  view source on GitHub ↗

* Start of the original range might fall inside the comment - scanner will not yield appropriate results * This function will look for token that is located before the start of target range * and return its end as start position for the scanner.

(enclosingNode, originalRange, sourceFile)

Source from the content-addressed store, hash-verified

147162 * and return its end as start position for the scanner.
147163 */
147164 function getScanStartPosition(enclosingNode, originalRange, sourceFile) {
147165 var start = enclosingNode.getStart(sourceFile);
147166 if (start === originalRange.pos && enclosingNode.end === originalRange.end) {
147167 return start;
147168 }
147169 var precedingToken = ts.findPrecedingToken(originalRange.pos, sourceFile);
147170 if (!precedingToken) {
147171 // no preceding token found - start from the beginning of enclosing node
147172 return enclosingNode.pos;
147173 }
147174 // preceding token ends after the start of original range (i.e when originalRange.pos falls in the middle of literal)
147175 // start from the beginning of enclosingNode to handle the entire 'originalRange'
147176 if (precedingToken.end >= originalRange.pos) {
147177 return enclosingNode.pos;
147178 }
147179 return precedingToken.end;
147180 }
147181 /*
147182 * For cases like
147183 * if (a ||

Callers 1

formatSpanFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected