find node that fully contains given text range
(range, sourceFile)
| 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. |