smartSnippetInserter.ts ×10

Frontier kind: Code frontier

unlabeled · c_3a9f5da187bd

6 tests · 41396 LOC · 240 files · introduces 0 tests · 69 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
11 ranges69 lines · 2 files
Tests
0 tests

Contains — complete concept membership

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

src/vs/workbench/contrib/preferences/common/smartSnippetInserter.ts 63 introduced LOC · 10 ranges

Open complete file

18
19 private static hasOpenBrace(scanner: JSONScanner): boolean {
21 > while (scanner.scan() !== JSONSyntaxKind.EOF) {
22 > const kind = scanner.getToken();
23 >
24 > if (kind === JSONSyntaxKind.OpenBraceToken) {
25 return true;
26 }
28
29 return false;
31
32 private static offsetToPosition(model: ITextModel, offset: number): Position {
33 > let offsetBeforeLine = 0; smartSnippetInserter.ts
34 > const eolLength = model.getEOL().length;
35 > const lineCount = model.getLineCount();
36 > for (let lineNumber = 1; lineNumber <= lineCount; lineNumber++) {
37 > const lineTotalLength = model.getLineLength(lineNumber) + eolLength;
38 > const offsetAfterLine = offsetBeforeLine + lineTotalLength;
39 >
40 > if (offsetAfterLine > offset) {
41 > return new Position(
42 > lineNumber,
43 > offset - offsetBeforeLine + 1
44 > );
45 > }
46 > offsetBeforeLine = offsetAfterLine;
47 > }
48 return new Position(
49 lineCount,
50 model.getLineMaxColumn(lineCount)
51 );
53
54 static insertSnippet(model: ITextModel, _position: Position): InsertSnippetResult {
71
72 const checkRangeStatus = (pos: number, state: State) => {
73 > if (state !== State.INVALID && arrayLevel === 1 && objLevel === 0) { smartSnippetInserter.ts
74 > currentState = state;
75 > lastValidPos = pos;
76 > lastValidState = state;
77 > } else {
78 > if (currentState !== State.INVALID) {
79 > currentState = State.INVALID;
80 > lastValidPos = scanner.getTokenOffset();
81 > }
82 > }
83 > };
84
85 while (scanner.scan() !== JSONSyntaxKind.EOF) {
90 switch (kind) {
91 case JSONSyntaxKind.OpenBracketToken:
92 > goodKind = true; smartSnippetInserter.ts
93 > arrayLevel++;
94 > checkRangeStatus(currentPos, State.BEFORE_OBJECT);
95 > break;
96 case JSONSyntaxKind.CloseBracketToken:
97 > goodKind = true; smartSnippetInserter.ts
98 > arrayLevel--;
99 > checkRangeStatus(currentPos, State.INVALID);
100 > break;
101 case JSONSyntaxKind.CommaToken:
102 goodKind = true;
119
120 if (currentPos >= desiredPosition && (currentState !== State.INVALID || lastValidPos !== -1)) {
121 > let acceptPosition: number; smartSnippetInserter.ts
122 > let acceptState: State;
123 >
124 > if (currentState !== State.INVALID) {
125 > acceptPosition = (goodKind ? currentPos : scanner.getTokenOffset());
126 > acceptState = currentState;
127 > } else {
128 > acceptPosition = lastValidPos;
129 > acceptState = lastValidState;
130 > }
131 >
132 > if (acceptState as State === State.AFTER_OBJECT) {
133 return {
134 position: this.offsetToPosition(model, acceptPosition),
136 append: ''
137 };
138 > } else { smartSnippetInserter.ts
139 > scanner.setPosition(acceptPosition);
140 > return {
141 > position: this.offsetToPosition(model, acceptPosition),
142 > prepend: '',
143 > append: this.hasOpenBrace(scanner) ? ',' : ''
144 > };
145 > }
146 > }
147 }
148
src/vs/base/common/json.ts 6 introduced LOC · 1 range

Open complete file

235
236 function setPosition(newPosition: number) {
237 > pos = newPosition; json.ts
238 > value = '';
239 > tokenOffset = 0;
240 > token = SyntaxKind.Unknown;
241 > scanError = ScanError.None;
242 > }
243
244 function scanNumber(): string {