bracketPairsTree.ts ×6

Frontier kind: Joint frontier

unlabeled · c_60bf7629fdbd

1 test · 41671 LOC · 239 files · introduces 1 test · 93 LOC · 4 files

Introduces — evidence that enters the hierarchy at this concept

Code
14 ranges93 lines · 4 files
Tests
1 test

Contains — complete concept membership

All code (extent)
5236 ranges41671 lines · 239 files · Browse complete extent
All tests (intent)
1 testBrowse 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.

1 test introduced at this concept.

Introduced code

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

4 files ranked by introduced lines: 93 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 61 introduced LOC · 6 ranges

Open complete file

176
177 public getFirstBracketAfter(position: Position): IFoundBracket | null {
178 > this.flushQueue(); bracketPairsTree.ts
179 >
180 > const node = this.initialAstWithoutTokens || this.astWithTokens!;
181 > return getFirstBracketAfter(node, lengthZero, node.length, positionToLength(position));
182 > }
183
184 public getFirstBracketBefore(position: Position): IFoundBracket | null {
185 > this.flushQueue(); bracketPairsTree.ts
186 >
187 > const node = this.initialAstWithoutTokens || this.astWithTokens!;
188 > return getFirstBracketBefore(node, lengthZero, node.length, positionToLength(position));
189 > }
190 }
191
192 > function getFirstBracketBefore(node: AstNode, nodeOffsetStart: Length, nodeOffsetEnd: Length, position: Length): IFoundBracket | null { bracketPairsTree.ts
193 > if (node.kind === AstNodeKind.List || node.kind === AstNodeKind.Pair) {
194 > const lengths: { nodeOffsetStart: Length; nodeOffsetEnd: Length }[] = [];
195 > for (const child of node.children) {
196 > nodeOffsetEnd = lengthAdd(nodeOffsetStart, child.length);
197 > lengths.push({ nodeOffsetStart, nodeOffsetEnd });
198 > nodeOffsetStart = nodeOffsetEnd;
199 > }
200 > for (let i = lengths.length - 1; i >= 0; i--) {
201 > const { nodeOffsetStart, nodeOffsetEnd } = lengths[i];
202 > if (lengthLessThan(nodeOffsetStart, position)) {
203 > const result = getFirstBracketBefore(node.children[i], nodeOffsetStart, nodeOffsetEnd, position);
204 > if (result) {
205 > return result;
206 > }
207 > }
208 > }
209 > return null;
210 > } else if (node.kind === AstNodeKind.UnexpectedClosingBracket) {
211 return null;
212 > } else if (node.kind === AstNodeKind.Bracket) { bracketPairsTree.ts
213 > const range = lengthsToRange(nodeOffsetStart, nodeOffsetEnd);
214 > return {
215 > bracketInfo: node.bracketInfo,
216 > range
217 > };
218 > }
219 > return null;
220 > }
221
222 > function getFirstBracketAfter(node: AstNode, nodeOffsetStart: Length, nodeOffsetEnd: Length, position: Length): IFoundBracket | null { bracketPairsTree.ts
223 > if (node.kind === AstNodeKind.List || node.kind === AstNodeKind.Pair) {
224 > for (const child of node.children) {
225 > nodeOffsetEnd = lengthAdd(nodeOffsetStart, child.length);
226 > if (lengthLessThan(position, nodeOffsetEnd)) {
227 > const result = getFirstBracketAfter(child, nodeOffsetStart, nodeOffsetEnd, position);
228 > if (result) {
229 > return result;
230 > }
231 > }
232 > nodeOffsetStart = nodeOffsetEnd;
233 > }
234 > return null;
235 > } else if (node.kind === AstNodeKind.UnexpectedClosingBracket) {
236 return null;
237 > } else if (node.kind === AstNodeKind.Bracket) { bracketPairsTree.ts
238 > const range = lengthsToRange(nodeOffsetStart, nodeOffsetEnd);
239 > return {
240 > bracketInfo: node.bracketInfo,
241 > range
242 > };
243 > }
244 > return null;
245 > }
246
247 function collectBrackets(
src/vs/editor/common/model/bracketPairsTextModelPart/bracketPairsImpl.ts 16 introduced LOC · 4 ranges

Open complete file

496
497 public findPrevBracket(_position: IPosition): IFoundBracket | null {
498 > const position = this.textModel.validatePosition(_position); bracketPairsImpl.ts
499 >
500 > if (this.canBuildAST) {
501 > this.bracketsRequested = true;
502 > this.updateBracketPairsTree();
503 > return this.bracketPairsTree.value?.object.getFirstBracketBefore(position) || null;
504 > }
505
506 let languageId: string | null = null;
579
580 return null;
582
583 public findNextBracket(_position: IPosition): IFoundBracket | null {
584 > const position = this.textModel.validatePosition(_position); bracketPairsImpl.ts
585 >
586 > if (this.canBuildAST) {
587 > this.bracketsRequested = true;
588 > this.updateBracketPairsTree();
589 > return this.bracketPairsTree.value?.object.getFirstBracketAfter(position) || null;
590 > }
591
592 const lineCount = this.textModel.getLineCount();
666
667 return null;
669
670 public findEnclosingBrackets(_position: IPosition, maxDuration?: number): [Range, Range] | null {
src/vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/ast.ts 10 introduced LOC · 1 range

Open complete file

127 */
128 public get children() {
129 > const result: AstNode[] = []; ast.ts
130 > result.push(this.openingBracket);
131 > if (this.child) {
132 > result.push(this.child);
133 > }
134 > if (this.closingBracket) {
135 > result.push(this.closingBracket);
136 > }
137 > return result;
138 > }
139
140 private constructor(
src/vs/editor/common/languages/supports/languageBracketsConfiguration.ts 6 introduced LOC · 3 ranges

Open complete file

84
85 public getOpeningBracketInfo(bracketText: string): OpeningBracketKind | undefined {
86 > return this._openingBrackets.get(bracketText); languageBracketsConfiguration.ts
87 > }
88
89 public getClosingBracketInfo(bracketText: string): ClosingBracketKind | undefined {
90 > return this._closingBrackets.get(bracketText); languageBracketsConfiguration.ts
91 > }
92
93 public getBracketInfo(bracketText: string): BracketKind | undefined {
94 > return this.getOpeningBracketInfo(bracketText) || this.getClosingBracketInfo(bracketText); languageBracketsConfiguration.ts
95 > }
96
97 public getBracketRegExp(options?: RegExpOptions): RegExp {