json.ts ×22

Frontier kind: Code frontier

unlabeled · c_f3842ad23810

533 tests · 3863 LOC · 19 files · introduces 0 tests · 86 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
22 ranges86 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
516 ranges3863 lines · 19 files · Browse complete extent
All tests (intent)
533 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.

1 file ranked by introduced lines: 86 introduced LOC across 22 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/base/common/json.ts 86 introduced LOC · 22 ranges

Open complete file

200 */
201 export function createScanner(text: string, ignoreTrivia: boolean = false): JSONScanner {
202 > json.ts
203 > let pos = 0;
204 > const len = text.length;
205 > let value: string = '';
206 > let tokenOffset = 0;
207 > let token: SyntaxKind = SyntaxKind.Unknown;
208 > let scanError: ScanError = ScanError.None;
209 >
210 > function scanHexDigits(count: number): number {
211 let digits = 0;
212 let hexValue = 0;
233 return hexValue;
234 }
235 > json.ts
236 > function setPosition(newPosition: number) {
237 pos = newPosition;
238 value = '';
241 scanError = ScanError.None;
242 }
243 > json.ts
244 > function scanNumber(): string {
245 const start = pos;
246 if (text.charCodeAt(pos) === CharacterCodes._0) {
282 return text.substring(start, end);
283 }
284 > json.ts
285 > function scanString(): string {
286
287 let result = '',
362 return result;
363 }
364 > json.ts
365 > function scanNext(): SyntaxKind {
366 >
367 > value = '';
368 > scanError = ScanError.None;
369 >
370 > tokenOffset = pos;
371 >
372 > if (pos >= len) {
373 // at the end
374 tokenOffset = len;
375 return token = SyntaxKind.EOF;
376 }
377 > json.ts
378 > let code = text.charCodeAt(pos);
379 > // trivia: whitespace
380 > if (isWhitespace(code)) {
381 do {
382 pos++;
387 return token = SyntaxKind.Trivia;
388 }
389 > json.ts
390 > // trivia: newlines
391 > if (isLineBreak(code)) {
392 pos++;
393 value += String.fromCharCode(code);
404 pos++;
405 return token = SyntaxKind.OpenBraceToken;
406 > case CharacterCodes.closeBrace: json.ts
407 pos++;
408 return token = SyntaxKind.CloseBraceToken;
409 > case CharacterCodes.openBracket: json.ts
410 pos++;
411 return token = SyntaxKind.OpenBracketToken;
412 > case CharacterCodes.closeBracket: json.ts
413 pos++;
414 return token = SyntaxKind.CloseBracketToken;
415 > case CharacterCodes.colon: json.ts
416 pos++;
417 return token = SyntaxKind.ColonToken;
418 > case CharacterCodes.comma: json.ts
419 pos++;
420 return token = SyntaxKind.CommaToken;
421 > json.ts
422 > // strings
423 > case CharacterCodes.doubleQuote:
424 pos++;
425 value = scanString();
426 return token = SyntaxKind.StringLiteral;
427 > json.ts
428 > // comments
429 > case CharacterCodes.slash: {
430 const start = pos - 1;
431 // Single-line comment
474 return token = SyntaxKind.Unknown;
475 }
476 > // numbers json.ts
477 > case CharacterCodes.minus:
478 value += String.fromCharCode(code);
479 pos++;
481 return token = SyntaxKind.Unknown;
482 }
483 > // found a minus, followed by a number so json.ts
484 > // we fall through to proceed with scanning
485 > // numbers
486 > case CharacterCodes._0:
487 > case CharacterCodes._1:
488 > case CharacterCodes._2:
489 > case CharacterCodes._3:
490 > case CharacterCodes._4:
491 > case CharacterCodes._5:
492 > case CharacterCodes._6:
493 > case CharacterCodes._7:
494 > case CharacterCodes._8:
495 > case CharacterCodes._9:
496 value += scanNumber();
497 return token = SyntaxKind.NumericLiteral;
498 > // literals and unknown symbols json.ts
499 > default:
500 // is a literal? Read the full word.
501 while (pos < len && isUnknownContentCharacter(code)) {
517 pos++;
518 return token = SyntaxKind.Unknown;
519 > } json.ts
520 > }
521 >
522 > function isUnknownContentCharacter(code: CharacterCodes) {
523 if (isWhitespace(code) || isLineBreak(code)) {
524 return false;
537 return true;
538 }
539 > json.ts
540 >
541 > function scanNextNonTrivia(): SyntaxKind {
542 let result: SyntaxKind;
543 do {
546 return result;
547 }
548 > json.ts
549 > return {
550 > setPosition: setPosition,
551 > getPosition: () => pos,
552 > scan: ignoreTrivia ? scanNextNonTrivia : scanNext,
553 > getToken: () => token,
554 > getTokenValue: () => value,
555 > getTokenOffset: () => tokenOffset,
556 > getTokenLength: () => pos - tokenOffset,
557 > getTokenError: () => scanError
558 > };
559 > }
560
561 > function isWhitespace(ch: number): boolean { json.ts
562 > return ch === CharacterCodes.space || ch === CharacterCodes.tab || ch === CharacterCodes.verticalTab || ch === CharacterCodes.formFeed ||
563 > ch === CharacterCodes.nonBreakingSpace || ch === CharacterCodes.ogham || ch >= CharacterCodes.enQuad && ch <= CharacterCodes.zeroWidthSpace ||
564 > ch === CharacterCodes.narrowNoBreakSpace || ch === CharacterCodes.mathematicalSpace || ch === CharacterCodes.ideographicSpace || ch === CharacterCodes.byteOrderMark;
565 > }
566
567 > function isLineBreak(ch: number): boolean { json.ts
568 > return ch === CharacterCodes.lineFeed || ch === CharacterCodes.carriageReturn || ch === CharacterCodes.lineSeparator || ch === CharacterCodes.paragraphSeparator;
569 > }
570
571 function isDigit(ch: number): boolean {