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

Function findEnclosingNode

test/fixtures/snapshot/typescript.js:147106–147118  ·  view source on GitHub ↗

find node that fully contains given text range

(range, sourceFile)

Source from the content-addressed store, hash-verified

147104 }
147105 /** find node that fully contains given text range */
147106 function findEnclosingNode(range, sourceFile) {
147107 return find(sourceFile);
147108 function find(n) {
147109 var candidate = ts.forEachChild(n, function (c) { return ts.startEndContainsRange(c.getStart(sourceFile), c.end, range) && c; });
147110 if (candidate) {
147111 var result = find(candidate);
147112 if (result) {
147113 return result;
147114 }
147115 }
147116 return n;
147117 }
147118 }
147119 /** formatting is not applied to ranges that contain parse errors.
147120 * This function will return a predicate that for a given text range will tell
147121 * if there are any parse errors that overlap with the range.

Callers 1

formatSpanFunction · 0.85

Calls 1

findFunction · 0.70

Tested by

no test coverage detected