tokenizer.ts ×6

Frontier kind: Code frontier

unlabeled · c_ff5e95cd8765

43 tests · 41245 LOC · 238 files · introduces 0 tests · 58 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
7 ranges58 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
5113 ranges41245 lines · 238 files · Browse complete extent
All tests (intent)
43 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.

2 files ranked by introduced lines: 58 introduced LOC across 7 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/tokenizer.ts 54 introduced LOC · 6 ranges

Open complete file

286
287 constructor(private readonly text: string, brackets: BracketTokens) {
288 > const regExpStr = brackets.getRegExpStr(); tokenizer.ts
289 > const regexp = regExpStr ? new RegExp(regExpStr + '|\n', 'gi') : null;
290 >
291 > const tokens: Token[] = [];
292 >
293 > let match: RegExpExecArray | null;
294 > let curLineCount = 0;
295 > let lastLineBreakOffset = 0;
296 >
297 > let lastTokenEndOffset = 0;
298 > let lastTokenEndLine = 0;
299 >
300 > const smallTextTokens0Line: Token[] = [];
301 > for (let i = 0; i < 60; i++) {
302 > smallTextTokens0Line.push(
303 > new Token(
304 > toLength(0, i), TokenKind.Text, -1, SmallImmutableSet.getEmpty(),
305 > new TextAstNode(toLength(0, i))
306 > )
307 > );
308 > }
309 >
310 > const smallTextTokens1Line: Token[] = [];
311 > for (let i = 0; i < 60; i++) {
312 > smallTextTokens1Line.push(
313 > new Token(
314 > toLength(1, i), TokenKind.Text, -1, SmallImmutableSet.getEmpty(),
315 > new TextAstNode(toLength(1, i))
316 > )
317 > );
318 > }
319 >
320 > if (regexp) {
321 > regexp.lastIndex = 0;
322 > // If a token contains indentation, it also contains \n{INDENTATION+}(?!{INDENTATION})
323 > while ((match = regexp.exec(text)) !== null) {
324 > const curOffset = match.index;
325 > const value = match[0];
326 > if (value === '\n') {
327 curLineCount++;
328 lastLineBreakOffset = curOffset + 1;
329 > } else { tokenizer.ts
330 if (lastTokenEndOffset !== curOffset) {
331 let token: Token;
357 lastTokenEndLine = curLineCount;
358 }
359 > } tokenizer.ts
360 > }
361 >
362 > const offset = text.length;
363 >
364 > if (lastTokenEndOffset !== offset) {
365 const length = (lastTokenEndLine === curLineCount)
366 ? toLength(0, offset - lastTokenEndOffset)
368 tokens.push(new Token(length, TokenKind.Text, -1, SmallImmutableSet.getEmpty(), new TextAstNode(length)));
369 }
370 > tokenizer.ts
371 > this.length = toLength(curLineCount, offset - lastLineBreakOffset);
372 > this.tokens = tokens;
373 > }
374
375 get offset(): Length {
380
381 read(): Token | null {
382 > return this.tokens[this.idx++] || null; tokenizer.ts
383 > }
384
385 peek(): Token | null {
386 > return this.tokens[this.idx] || null; tokenizer.ts
387 > }
388
389 skip(length: Length): void {
src/vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/bracketPairsTree.ts 4 introduced LOC · 1 range

Open complete file

64
65 if (!textModel.tokenization.hasTokens) {
66 > const brackets = this.brackets.getSingleLanguageBracketTokens(this.textModel.getLanguageId()); bracketPairsTree.ts
67 > const tokenizer = new FastTokenizer(this.textModel.getValue(), brackets);
68 > this.initialAstWithoutTokens = parseDocument(tokenizer, [], undefined, true);
69 > this.astWithTokens = this.initialAstWithoutTokens;
70 } else if (textModel.tokenization.backgroundTokenizationState === BackgroundTokenizationState.Completed) {
71 // Skip the initial ast, as there is no flickering.