bracketPairsTree.ts ×8

Frontier kind: Code frontier

unlabeled · c_10c6d1c990f3

3 tests · 41721 LOC · 238 files · introduces 0 tests · 97 LOC · 3 files

Introduces — evidence that enters the hierarchy at this concept

Code
14 ranges97 lines · 3 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
5245 ranges41721 lines · 238 files · Browse complete extent
All tests (intent)
3 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

3 files ranked by introduced lines: 97 introduced LOC across 14 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/bracketPairsTree.ts 77 introduced LOC · 8 ranges

Open complete file

266 switch (node.kind) {
267 case AstNodeKind.List: {
268 > const childCount = node.childrenLength; bracketPairsTree.ts
269 > for (let i = 0; i < childCount; i++) {
270 > const child = node.getChild(i);
271 > if (!child) {
272 continue;
273 }
274 > nodeOffsetEnd = lengthAdd(nodeOffsetStart, child.length); bracketPairsTree.ts
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 }
317 > nodeOffsetEnd = lengthAdd(nodeOffsetStart, child.length); bracketPairsTree.ts
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
333 continue whileLoop;
334 }
336 > if (colorize || child.kind !== AstNodeKind.Bracket || !node.closingBracket) {
337 > const shouldContinue = collectBrackets(
338 > child,
339 > nodeOffsetStart,
340 > nodeOffsetEnd,
341 > startOffset,
342 > endOffset,
343 > push,
344 > colorize ? level + 1 : level,
345 > colorize ? levelPerBracket + 1 : levelPerBracket,
346 > levelPerBracketType,
347 > onlyColorizedBrackets,
348 > !node.closingBracket,
349 > );
350 > if (!shouldContinue) {
351 return false;
352 }
354 > }
355 > nodeOffsetStart = nodeOffsetEnd;
356 > }
357 >
358 > levelPerBracketType?.set(node.openingBracket.text, levelPerBracket);
359 >
360 > return true;
361 > }
362 case AstNodeKind.UnexpectedClosingBracket: {
363 const range = lengthsToRange(nodeOffsetStart, nodeOffsetEnd);
365 }
366 case AstNodeKind.Bracket: {
367 > const range = lengthsToRange(nodeOffsetStart, nodeOffsetEnd); bracketPairsTree.ts
368 > return push(new BracketInfo(range, level - 1, nestingLevelOfEqualBracketType - 1, parentPairIsIncomplete));
369 > }
370 case AstNodeKind.Text:
371 return true;
src/vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/ast.ts 14 introduced LOC · 5 ranges

Open complete file

112 }
113 public get childrenLength(): number {
114 > return 3; ast.ts
115 > }
116 public getChild(idx: number): AstNode | null {
117 > switch (idx) { ast.ts
118 > case 0: return this.openingBracket;
119 > case 1: return this.child;
120 > case 2: return this.closingBracket;
121 > }
122 throw new Error('Invalid child index');
123 > } ast.ts
124
125 /**
382 }
383 public getChild(idx: number): AstNode | null {
384 > switch (idx) { ast.ts
385 > case 0: return this._item1;
386 > case 1: return this._item2;
387 > case 2: return this._item3;
388 > }
389 throw new Error('Invalid child index');
390 > } ast.ts
391 protected setChild(idx: number, node: AstNode): void {
392 switch (idx) {
src/vs/editor/common/textModelBracketPairs.ts 6 introduced LOC · 1 range

Open complete file

74 export class BracketInfo {
75 constructor(
76 > public readonly range: Range, textModelBracketPairs.ts
77 > /** 0-based level */
78 > public readonly nestingLevel: number,
79 > public readonly nestingLevelOfEqualBracketType: number,
80 > public readonly isInvalid: boolean,
81 > ) { }
82 }
83