json.ts ×10

Frontier kind: Code frontier

unlabeled · c_7a70d754ccfb

93 tests · 3972 LOC · 19 files · introduces 0 tests · 29 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
10 ranges29 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
553 ranges3972 lines · 19 files · Browse complete extent
All tests (intent)
93 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: 29 introduced LOC across 10 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/base/common/json.ts 29 introduced LOC · 10 ranges

Open complete file

895 */
896 export function parseTree(text: string, errors: ParseError[] = [], options: ParseOptions = ParseOptions.DEFAULT): Node {
897 > let currentParent: NodeImpl = { type: 'array', offset: -1, length: -1, children: [], parent: undefined }; // artificial root json.ts
898 >
899 > function ensurePropertyComplete(endOffset: number) {
900 > if (currentParent.type === 'property') {
901 currentParent.length = endOffset - currentParent.offset;
902 currentParent = currentParent.parent!;
903 }
904 > } json.ts
905 >
906 > function onValue(valueNode: Node): Node {
907 > currentParent.children!.push(valueNode);
908 > return valueNode;
909 > }
910 >
911 > const visitor: JSONVisitor = {
912 > onObjectBegin: (offset: number) => {
913 currentParent = onValue({ type: 'object', offset, length: -1, parent: currentParent, children: [] });
914 },
915 > onObjectProperty: (name: string, offset: number, length: number) => { json.ts
916 currentParent = onValue({ type: 'property', offset, length: -1, parent: currentParent, children: [] });
917 currentParent.children!.push({ type: 'string', value: name, offset, length, parent: currentParent });
918 },
919 > onObjectEnd: (offset: number, length: number) => { json.ts
920 currentParent.length = offset + length - currentParent.offset;
921 currentParent = currentParent.parent!;
922 ensurePropertyComplete(offset + length);
923 },
924 > onArrayBegin: (offset: number, length: number) => { json.ts
925 currentParent = onValue({ type: 'array', offset, length: -1, parent: currentParent, children: [] });
926 },
927 > onArrayEnd: (offset: number, length: number) => { json.ts
928 currentParent.length = offset + length - currentParent.offset;
929 currentParent = currentParent.parent!;
930 ensurePropertyComplete(offset + length);
931 },
932 > onLiteralValue: (value: unknown, offset: number, length: number) => { json.ts
933 onValue({ type: getNodeType(value), offset, length, parent: currentParent, value });
934 ensurePropertyComplete(offset + length);
935 },
936 > onSeparator: (sep: string, offset: number, length: number) => { json.ts
937 if (currentParent.type === 'property') {
938 if (sep === ':') {
943 }
944 },
945 > onError: (error: ParseErrorCode, offset: number, length: number) => { json.ts
946 errors.push({ error, offset, length });
947 }
948 > }; json.ts
949 > visit(text, visitor, options);
950 >
951 > const result = currentParent.children![0];
952 > if (result) {
953 > delete result.parent;
954 > }
955 > return result;
956 > }
957
958 /**