jsonFormatter.ts ×6

Frontier kind: Code frontier

unlabeled · c_95dc93948dde

1185 tests · 3846 LOC · 20 files · introduces 0 tests · 69 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
6 ranges69 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
500 ranges3846 lines · 20 files · Browse complete extent
All tests (intent)
1185 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: 69 introduced LOC across 6 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/base/common/jsonFormatter.ts 69 introduced LOC · 6 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- jsonFormatter.ts
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import { createScanner, ScanError, SyntaxKind } from './json.js';
7 >
8 > export interface FormattingOptions {
9 > /**
10 > * If indentation is based on spaces (`insertSpaces` = true), then what is the number of spaces that make an indent?
11 > */
12 > tabSize?: number;
13 > /**
14 > * Is indentation based on spaces?
15 > */
16 > insertSpaces?: boolean;
17 > /**
18 > * The default 'end of line' character. If not set, '\n' is used as default.
19 > */
20 > eol?: string;
21 > }
22 >
23 > /**
24 > * Represents a text modification
25 > */
26 > export interface Edit {
27 > /**
28 > * The start offset of the modification.
29 > */
30 > offset: number;
31 > /**
32 > * The length of the modification. Must not be negative. Empty length represents an *insert*.
33 > */
34 > length: number;
35 > /**
36 > * The new content. Empty content represents a *remove*.
37 > */
38 > content: string;
39 > }
40 >
41 > /**
42 > * A text range in the document
43 > */
44 > export interface Range {
45 > /**
46 > * The start offset of the range.
47 > */
48 > offset: number;
49 > /**
50 > * The length of the range. Must not be negative.
51 > */
52 > length: number;
53 > }
54 >
55 >
56 > export function format(documentText: string, range: Range | undefined, options: FormattingOptions): Edit[] {
57 let initialIndentLevel: number;
58 let formatText: string;
202 return editOperations;
203 }
205 > /**
206 > * Creates a formatted string out of the object passed as argument, using the given formatting options
207 > * @param any The object to stringify and format
208 > * @param options The formatting options to use
209 > */
210 > export function toFormattedString(obj: unknown, options: FormattingOptions) {
211 const content = JSON.stringify(obj, undefined, options.insertSpaces ? options.tabSize || 4 : '\t');
212 if (options.eol !== undefined) {
215 return content;
216 }
218 function repeat(s: string, count: number): string {
219 let result = '';
223 return result;
224 }
226 function computeIndentLevel(content: string, options: FormattingOptions): number {
227 let i = 0;
241 return Math.floor(nChars / tabSize);
242 }
244 > export function getEOL(options: FormattingOptions, text: string): string {
245 for (let i = 0; i < text.length; i++) {
246 const ch = text.charAt(i);
256 return (options && options.eol) || '\n';
257 }
259 > export function isEOL(text: string, offset: number) {
260 return '\r\n'.indexOf(text.charAt(offset)) !== -1;
261 }