json.ts ×17

Frontier kind: Code frontier

unlabeled · c_933ae5fa9eca

497 tests · 3928 LOC · 19 files · introduces 0 tests · 61 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
17 ranges61 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
534 ranges3928 lines · 19 files · Browse complete extent
All tests (intent)
497 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: 61 introduced LOC across 17 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/base/common/json.ts 61 introduced LOC · 17 ranges

Open complete file

1068 */
1069 export function visit(text: string, visitor: JSONVisitor, options: ParseOptions = ParseOptions.DEFAULT): any {
1070 > json.ts
1071 > const _scanner = createScanner(text, false);
1072 >
1073 > function toNoArgVisit(visitFunction?: (offset: number, length: number) => void): () => void {
1074 > return visitFunction ? () => visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength()) : () => true;
1075 > }
1076 > function toOneArgVisit<T>(visitFunction?: (arg: T, offset: number, length: number) => void): (arg: T) => void {
1077 > return visitFunction ? (arg: T) => visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength()) : () => true;
1078 > }
1079 >
1080 > const onObjectBegin = toNoArgVisit(visitor.onObjectBegin),
1081 > onObjectProperty = toOneArgVisit(visitor.onObjectProperty),
1082 > onObjectEnd = toNoArgVisit(visitor.onObjectEnd),
1083 > onArrayBegin = toNoArgVisit(visitor.onArrayBegin),
1084 > onArrayEnd = toNoArgVisit(visitor.onArrayEnd),
1085 > onLiteralValue = toOneArgVisit(visitor.onLiteralValue),
1086 > onSeparator = toOneArgVisit(visitor.onSeparator),
1087 > onComment = toNoArgVisit(visitor.onComment),
1088 > onError = toOneArgVisit(visitor.onError);
1089 >
1090 > const disallowComments = options && options.disallowComments;
1091 > const allowTrailingComma = options && options.allowTrailingComma;
1092 > function scanNext(): SyntaxKind {
1093 > while (true) {
1094 > const token = _scanner.scan();
1095 > switch (_scanner.getTokenError()) {
1096 > case ScanError.InvalidUnicode:
1097 handleError(ParseErrorCode.InvalidUnicode);
1098 break;
1099 > case ScanError.InvalidEscapeCharacter: json.ts
1100 handleError(ParseErrorCode.InvalidEscapeCharacter);
1101 break;
1102 > case ScanError.UnexpectedEndOfNumber: json.ts
1103 handleError(ParseErrorCode.UnexpectedEndOfNumber);
1104 break;
1105 > case ScanError.UnexpectedEndOfComment: json.ts
1106 if (!disallowComments) {
1107 handleError(ParseErrorCode.UnexpectedEndOfComment);
1108 }
1109 break;
1110 > case ScanError.UnexpectedEndOfString: json.ts
1111 handleError(ParseErrorCode.UnexpectedEndOfString);
1112 break;
1113 > case ScanError.InvalidCharacter: json.ts
1114 handleError(ParseErrorCode.InvalidCharacter);
1115 break;
1116 > } json.ts
1117 > switch (token) {
1118 > case SyntaxKind.LineCommentTrivia:
1119 > case SyntaxKind.BlockCommentTrivia:
1120 if (disallowComments) {
1121 handleError(ParseErrorCode.InvalidCommentToken);
1124 }
1125 break;
1126 > case SyntaxKind.Unknown: json.ts
1127 handleError(ParseErrorCode.InvalidSymbol);
1128 break;
1129 > case SyntaxKind.Trivia: json.ts
1130 > case SyntaxKind.LineBreakTrivia:
1131 break;
1132 > default: json.ts
1133 > return token;
1134 > }
1135 > }
1136 > }
1137 >
1138 > function handleError(error: ParseErrorCode, skipUntilAfter: SyntaxKind[] = [], skipUntil: SyntaxKind[] = []): void {
1139 onError(error);
1140 if (skipUntilAfter.length + skipUntil.length > 0) {
1151 }
1152 }
1153 > json.ts
1154 > function parseString(isValue: boolean): boolean {
1155 const value = _scanner.getTokenValue();
1156 if (isValue) {
1162 return true;
1163 }
1164 > json.ts
1165 > function parseLiteral(): boolean {
1166 switch (_scanner.getToken()) {
1167 case SyntaxKind.NumericLiteral: {
1194 return true;
1195 }
1196 > json.ts
1197 > function parseProperty(): boolean {
1198 if (_scanner.getToken() !== SyntaxKind.StringLiteral) {
1199 handleError(ParseErrorCode.PropertyNameExpected, [], [SyntaxKind.CloseBraceToken, SyntaxKind.CommaToken]);
1213 return true;
1214 }
1215 > json.ts
1216 > function parseObject(): boolean {
1217 onObjectBegin();
1218 scanNext(); // consume open brace
1245 return true;
1246 }
1247 > json.ts
1248 > function parseArray(): boolean {
1249 onArrayBegin();
1250 scanNext(); // consume open bracket
1277 return true;
1278 }
1279 > json.ts
1280 > function parseValue(): boolean {
1281 switch (_scanner.getToken()) {
1282 case SyntaxKind.OpenBracketToken:
1290 }
1291 }
1292 > json.ts
1293 > scanNext();
1294 > if (_scanner.getToken() === SyntaxKind.EOF) {
1295 if (options.allowEmptyContent) {
1296 return true;