266
switch (node.kind) {
267
case AstNodeKind.List: {
269
>
for (let i = 0; i < childCount; i++) {
270
>
const child = node.getChild(i);
271
>
if (!child) {
272
continue;
273
}
275
>
if (
276
>
lengthLessThanEqual(nodeOffsetStart, endOffset) &&
277
>
lengthGreaterThanEqual(nodeOffsetEnd, startOffset)
278
>
) {
279
>
const childEndsAfterEnd = lengthGreaterThanEqual(nodeOffsetEnd, endOffset);
280
>
if (childEndsAfterEnd) {
281
>
// No child after this child in the requested window, don't recurse
282
>
node = child;
283
>
continue whileLoop;
284
>
}
285
>
286
>
const shouldContinue = collectBrackets(child, nodeOffsetStart, nodeOffsetEnd, startOffset, endOffset, push, level, 0, levelPerBracketType, onlyColorizedBrackets);
287
>
if (!shouldContinue) {
288
return false;
289
}
291
>
nodeOffsetStart = nodeOffsetEnd;
292
>
}
293
>
return true;
294
>
}
295
case AstNodeKind.Pair: {
296
>
const colorize = !onlyColorizedBrackets || !node.closingBracket || (node.closingBracket.bracketInfo as ClosingBracketKind).closesColorized(node.openingBracket.bracketInfo as OpeningBracketKind);
bracketPairsTree.ts
297
>
298
>
let levelPerBracket = 0;
299
>
if (levelPerBracketType) {
300
>
let existing = levelPerBracketType.get(node.openingBracket.text);
301
>
if (existing === undefined) {
302
>
existing = 0;
303
>
}
304
>
levelPerBracket = existing;
305
>
if (colorize) {
306
>
existing++;
307
>
levelPerBracketType.set(node.openingBracket.text, existing);
308
>
}
309
>
}
310
>
311
>
const childCount = node.childrenLength;
312
>
for (let i = 0; i < childCount; i++) {
313
>
const child = node.getChild(i);
314
>
if (!child) {
315
continue;
316
}
318
>
if (
319
>
lengthLessThanEqual(nodeOffsetStart, endOffset) &&
320
>
lengthGreaterThanEqual(nodeOffsetEnd, startOffset)
321
>
) {
322
>
const childEndsAfterEnd = lengthGreaterThanEqual(nodeOffsetEnd, endOffset);
323
>
if (childEndsAfterEnd && child.kind !== AstNodeKind.Bracket) {
324
// No child after this child in the requested window, don't recurse
325
// Don't do this for brackets because of unclosed/unopened brackets