ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / extensions / copilot / test / codeMapper / codeMapper.stest.ts 695 строк · изменён 14 нояб., 04:52
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
import assert from 'assert' ;
import type { MappedEditsResponseStream } from 'vscode' ;
import { Intent } from '../../src/extension/common/constants' ;
import { IDocumentContext } from '../../src/extension/prompt/node/documentContext' ;
import { CodeMapper, ICodeMapperExistingDocument } from '../../src/extension/prompts/node/codeMapper/codeMapper' ;
import { WorkingCopyOriginalDocument } from '../../src/extension/prompts/node/inline/workingCopies' ;
import { ITabsAndEditorsService } from '../../src/platform/tabs/common/tabsAndEditorsService' ;
import { ITestingServicesAccessor TestingServiceCollection
IFile SimulationWorkspace
isEqual
IInstantiationService
CancellationTokenSource Selection TextEdit
Configuration ISimulationTestRuntime ssuite stest
KnownDiagnosticProviders
setupSimulationWorkspace teardownSimulationWorkspace toIRange
assertJSON assertNoElidedCodeComments getWorkspaceDiagnostics validateConsistentIndentation
IWorkspaceState
fromFixture
OutcomeAnnotation
variant model configurations Configuration
variant model configurations
title variant location configurations
description language testingServiceCollection
testingServiceCollection
files
activeDocument
selection
focusLocations
codeBlock
outcome workspace accessor
assert outcome appliedEdits length
assert outcome editedFile
outcome editedFile
outcome editedFile outcome annotations
description language testingServiceCollection
testingServiceCollection
files
activeDocument
selection
focusLocations
codeBlock
outcome workspace accessor
assert outcome editedFile
assert outcome appliedEdits length
assert outcome editedFile
outcome editedFile
outcome editedFile outcome annotations
description language testingServiceCollection
testingServiceCollection
files
activeDocument
selection
focusLocations
codeBlock
outcome workspace accessor
assert outcome appliedEdits length
assert outcome editedFile
outcome editedFile
outcome editedFile outcome annotations
description language testingServiceCollection
testingServiceCollection
files
activeDocument
selection
focusLocations
codeBlock
outcome workspace accessor
assert outcome appliedEdits length
assert outcome editedFile
assert outcome editedFile
assert outcome editedFile
outcome editedFile
outcome editedFile outcome annotations
description language testingServiceCollection
testingServiceCollection
files
activeDocument
selection
focusLocations
codeBlock
outcome workspace accessor
assert outcome appliedEdits length
assert outcome editedFile
outcome editedFile
outcome editedFile outcome annotations
description language testingServiceCollection
testingServiceCollection
files
activeDocument
selection
focusLocations
codeBlock
outcome workspace accessor
assert outcome appliedEdits length
assert outcome editedFile
assert accessor workspace KnownDiagnosticProviders tsc
outcome editedFile
outcome editedFile outcome annotations
description language testingServiceCollection
testingServiceCollection
files
activeDocument
selection
focusLocations
codeBlock
outcome workspace accessor
assert outcome appliedEdits length
pgkJSON outcome editedFile
assert pgkJSON devDependencies
assert pgkJSON devDependencies
assert pgkJSON keywords
assert pgkJSON scripts
outcome editedFile
outcome editedFile outcome annotations
description language testingServiceCollection
testingServiceCollection
files
activeDocument
selection
focusLocations
textBeforeCodeBlock
codeBlock
outcome workspace accessor
assert outcome appliedEdits length
newText outcome editedFile
assert newText
assert newText length outcome originalFileContent length
outcome editedFile
outcome editedFile outcome annotations
description language testingServiceCollection
testingServiceCollection
files
activeDocument
selection
focusLocations
textBeforeCodeBlock
codeBlock
outcome workspace accessor
assert outcome appliedEdits length
newText outcome editedFile
assert newText
assert newText
outcome editedFile
outcome editedFile outcome annotations
description language model testingServiceCollection
inputFile
testingServiceCollection
files inputFile
activeDocument inputFile fileName
selection
focusLocations
textBeforeCodeBlock
codeBlock
outcome workspace accessor
assert outcome appliedEdits length
newText outcome editedFile
expectedText inputFile fileContents
assert newText expectedText
outcome editedFile
description language model testingServiceCollection
inputFile
testingServiceCollection
files inputFile
activeDocument inputFile fileName
selection
focusLocations
textBeforeCodeBlock
codeBlock
outcome workspace accessor
assert outcome appliedEdits length
newText outcome editedFile
expectedText inputFile fileContents
assert newText expectedText
outcome editedFile
description language model testingServiceCollection
inputFile
testingServiceCollection
files inputFile
activeDocument inputFile fileName
selection
focusLocations
textBeforeCodeBlock
codeBlock
outcome workspace accessor
assert outcome appliedEdits length
assert outcome editedFile
assert outcome editedFile
outcome editedFile
outcome editedFile outcome annotations
description language testingServiceCollection
inputFile
testingServiceCollection
files inputFile
activeDocument inputFile fileName
selection
focusLocations
textBeforeCodeBlock
codeBlock
outcome workspace accessor
assert outcome appliedEdits length
originalFileLineCount outcome originalFileContent length
editedFileLineCount outcome editedFile length
assert editedFileLineCount originalFileLineCount
outcome editedFile
str substr
str substr length
str regex RegExp
matches str regex
matches matches length
appliedEdits TextEdit
annotations OutcomeAnnotation
originalFileContent
editedFile
files IFile
activeDocument
selection
focusLocations
textBeforeCodeBlock
codeBlock
outcome IOutcome workspace SimulationWorkspace accessor ITestingServicesAccessor
testingServiceCollection TestingServiceCollection scenario ICodeMapperScenario
workspace testingServiceCollection files scenario files
accessor testingServiceCollection
testRuntime accessor ISimulationTestRuntime
states IWorkspaceState
source
document workspace scenario activeDocument document
workspace document uri
selection scenario selection
workspace selection
workspacePath workspace document uri
states
kind
file
workspacePath
relativeDiskPath testRuntime workspacePath document
languageId document languageId
additionalFiles
languageId document languageId
selection selection
range selection
diagnostics
editor accessor ITabsAndEditorsService activeTextEditor
documentContext IDocumentContext editor
codeMapper accessor IInstantiationService CodeMapper
workingCopyDocument document
response MappedEditsResponseStream
target edits
target document uri
edits edits edits edits
workspace document uri edits
offsetEdits workingCopyDocument transformer edits
workingCopyDocument offsetEdits
target
target edits
edits edits edits edits
workspace target edits
codeMap scenario codeBlock
input ICodeMapperExistingDocument createNew codeBlock codeMap uri document uri markdownBeforeBlock scenario textBeforeCodeBlock existingDocument documentContext document
originalFileContent document
result codeMapper input response source token
result
testRuntime
kind
files srcUri workspacePath post workspacePath
annotations result annotations
states
kind
changedFiles
workspacePath
relativeDiskPath testRuntime workspacePath document
languageId document languageId
annotations result annotations
fileName workspace editor document uri
languageId document languageId
diagnostics
selection editor selection
range editor selection
interaction
query
actualIntent Intent Unknown
detectedIntent
requestCount
appliedEdits workingCopyDocument transformer workingCopyDocument appliedEdits
scenario
appliedEdits
annotations result annotations
originalFileContent
editedFile document
workspace accessor
source
accessor workspace
testRuntime states
,
}
from
'../../src/platform/test/node/services'
;
import
{
,
}
from
'../../src/platform/test/node/simulationWorkspace'
;
import
{
}
from
'../../src/util/vs/base/common/resources'
;
import
{
}
from
'../../src/util/vs/platform/instantiation/common/instantiation'
;
import
{
,
,
}
from
'../../src/vscodeTypes'
;
import
{
,
,
,
}
from
'../base/stest'
;
import
{
}
from
'../simulation/diagnosticProviders'
;
import
{
,
,
}
from
'../simulation/inlineChatSimulator'
;
import
{
,
,
,
}
from
'../simulation/outcomeValidators'
;
import
{
INLINE_CHANGED_DOC_TAG
,
INLINE_INITIAL_DOC_TAG
,
INLINE_STATE_TAG
,
}
from
'../simulation/shared/sharedTypes'
;
import
{
}
from
'../simulation/stestUtil'
;
import
{
}
from
'../simulation/types'
;
function
forEditsAndAgent
(
callback
:
(
:
string
|
undefined
,
:
string
|
undefined
,
:
<
any
>
[
]
|
undefined
)
=>
void
)
:
void
{
callback
(
''
,
undefined
,
undefined
)
;
}
forEditsAndAgent
(
(
,
,
)
=>
{
ssuite
(
{
:
'codeMapper'
+
,
:
'context'
,
}
,
(
)
=>
{
stest
(
{
:
'add new function at location 1'
,
:
'typescript'
}
,
async
(
)
=>
{
return
simulateCodeMapper
(
,
{
:
[
fromFixture
(
'codeMapper/fibonacci_recursive.ts'
)
]
,
:
'fibonacci_recursive.ts'
,
:
[
5
,
0
,
5
,
0
]
,
:
[
]
,
:
[
'function fibonacci_iterative(n: number): number {'
,
' if (n === 1) return 0;'
,
' if (n === 2) return 1;'
,
' let a = 0, b = 1, sum = 0;'
,
' for (let i = 2; i < n; i++) {'
,
' sum = a + b;'
,
' a = b;'
,
' b = sum;'
,
' }'
,
' return sum;'
,
'}'
]
,
validate
:
async
(
,
,
)
=>
{
.
ok
(
.
.
,
'has edits'
)
;
.
ok
(
.
.
includes
(
'function fibonacci_iterative(n: number): number {'
)
,
'has fibonacci_iterative'
)
;
assertNoElidedCodeComments
(
.
)
;
validateConsistentIndentation
(
.
,
false
,
.
)
;
}
}
)
;
}
)
;
stest
(
{
:
'modify function'
,
:
'typescript'
}
,
async
(
)
=>
{
return
simulateCodeMapper
(
,
{
:
[
fromFixture
(
'codeMapper/fibonacci_recursive.ts'
)
]
,
:
'fibonacci_recursive.ts'
,
:
[
0
,
0
,
4
,
1
]
,
:
[
]
,
:
[
'function fibonacci_recursive(n: number): number {'
,
' // Base case: if n is 1, the first number in the Fibonacci sequence is returned (0).'
,
' if (n === 1) return 0;'
,
' // Base case: if n is 2, the second number in the Fibonacci sequence is returned (1).'
,
' if (n === 2) return 1;'
,
' // Recursive case: return the sum of the two preceding numbers in the sequence.'
,
' // This is done by calling fibonacci_recursive for (n - 1) and (n - 2) and adding their results.'
,
' return fibonacci_recursive(n - 1) + fibonacci_recursive(n - 2);'
,
'}'
]
,
validate
:
async
(
,
,
)
=>
{
.
equal
(
numOccurrences
(
.
,
'function fibonacci_recursive'
)
,
1
,
'only once occurrence of fibonacci_recursive'
)
;
.
ok
(
.
.
,
'has edits'
)
;
.
ok
(
.
.
includes
(
'// Base case: if n is 1'
)
,
'has comments added'
)
;
assertNoElidedCodeComments
(
.
)
;
validateConsistentIndentation
(
.
,
false
,
.
)
;
}
}
)
;
}
)
;
stest
(
{
:
'replace statement with ident change'
,
:
'typescript'
}
,
async
(
)
=>
{
return
simulateCodeMapper
(
,
{
:
[
fromFixture
(
'codeMapper/fibonacci_recursive.ts'
)
]
,
:
'fibonacci_recursive.ts'
,
:
[
7
,
0
,
7
,
93
]
,
:
[
]
,
:
[
'// More readable version of generating a Fibonacci series'
,
'const fibonacci_series = Array.from({ length: n }, (value, index) => {'
,
' return fibonacci_recursive(index + 1);'
,
'});'
]
,
validate
:
async
(
,
,
)
=>
{
.
ok
(
.
.
,
'has edits'
)
;
.
ok
(
.
.
includes
(
'return fibonacci_recursive(index + 1);'
)
,
'has new statement'
)
;
assertNoElidedCodeComments
(
.
)
;
validateConsistentIndentation
(
.
,
false
,
.
)
;
}
}
)
;
}
)
;
stest
(
{
:
'move to class'
,
:
'typescript'
}
,
async
(
)
=>
{
return
simulateCodeMapper
(
,
{
:
[
fromFixture
(
'codeMapper/fibonacci_recursive.ts'
)
]
,
:
'fibonacci_recursive.ts'
,
:
[
0
,
0
,
10
,
0
]
,
:
[
]
,
:
[
'class FibonacciGenerator {'
,
' static fibonacci_recursive(n: number): number {'
,
' if (n === 1) return 0;'
,
' if (n === 2) return 1;'
,
' return FibonacciGenerator.fibonacci_recursive(n - 1) + FibonacciGenerator.fibonacci_recursive(n - 2);'
,
' }'
,
''
,
' static generate_fibonacci_recursive(n: number): number[] {'
,
' const fibonacci_series = Array.from({ length: n }, (_, i) => FibonacciGenerator.fibonacci_recursive(i + 1));'
,
' return fibonacci_series;'
,
' }'
,
'}'
]
,
validate
:
async
(
,
,
)
=>
{
.
ok
(
.
.
,
'has edits'
)
;
.
ok
(
.
.
includes
(
'class FibonacciGenerator {'
)
,
'has class'
)
;
.
equal
(
numOccurrences
(
.
,
'console.log(function generate_fibonacci_recursive'
)
,
0
,
'no references to the old function'
)
;
.
equal
(
numOccurrences
(
.
,
'console.log(FibonacciGenerator.generate_fibonacci_recursive'
)
,
1
,
'references to the new method'
)
;
assertNoElidedCodeComments
(
.
)
;
validateConsistentIndentation
(
.
,
false
,
.
)
;
}
}
)
;
}
)
;
stest
(
{
:
'add import'
,
:
'typescript'
}
,
async
(
)
=>
{
return
simulateCodeMapper
(
,
{
:
[
fromFixture
(
'codeMapper/fibonacci_recursive.ts'
)
]
,
:
'fibonacci_recursive.ts'
,
:
[
11
,
0
,
17
,
0
]
,
:
[
]
,
:
[
'import { readFileSync } from \'fs\';'
,
''
,
'// Assuming the mock_data is stored in a file named \'data.json\' with the structure { "number": 10 }'
,
'const data = JSON.parse(readFileSync(\'data.json\', \'utf8\'));'
,
''
,
'console.log(\'\\nFibonacci Series using recursion:\');'
,
'console.log(generate_fibonacci_recursive(data.number));'
]
,
validate
:
async
(
,
,
)
=>
{
.
ok
(
.
.
,
'has edits'
)
;
.
equal
(
numOccurrences
(
.
,
'import { readFileSync } from \'fs\';'
)
,
1
,
'has import'
)
;
assertNoElidedCodeComments
(
.
)
;
validateConsistentIndentation
(
.
,
false
,
.
)
;
}
}
)
;
}
)
;
stest
(
{
:
'break up function, large file'
,
:
'typescript'
}
,
async
(
)
=>
{
return
simulateCodeMapper
(
,
{
:
[
fromFixture
(
'codeMapper/scanner.ts'
)
,
fromFixture
(
'codeMapper/scannerTypes.ts'
)
]
,
:
'scanner.ts'
,
:
[
25
,
0
,
50
,
0
]
,
:
[
]
,
:
[
'// Checks if a character code is a numeric hex digit (0-9)'
,
'function isNumericHexDigit(ch: number): boolean {'
,
' return ch >= CharacterCodes._0 && ch <= CharacterCodes._9;'
,
'}'
,
''
,
'// Checks if a character code is an alphabetic hex digit (A-F or a-f)'
,
'function isAlphabeticHexDigit(ch: number): boolean {'
,
' return (ch >= CharacterCodes.A && ch <= CharacterCodes.F) || (ch >= CharacterCodes.a && ch <= CharacterCodes.f);'
,
'}'
,
''
,
'// Calculates the numerical value of a hex digit character code'
,
'function calculateHexValue(ch: number): number {'
,
' if (isNumericHexDigit(ch)) {'
,
' return ch - CharacterCodes._0;'
,
' } else if (ch >= CharacterCodes.A && ch <= CharacterCodes.F) {'
,
' return 10 + ch - CharacterCodes.A;'
,
' } else if (ch >= CharacterCodes.a && ch <= CharacterCodes.f) {'
,
' return 10 + ch - CharacterCodes.a;'
,
' }'
,
' // Return -1 if not a hex digit, though this case should be handled before calling this function'
,
' return -1;'
,
'}'
,
''
,
'// The main scanning function, refactored to use the helper functions'
,
'function scanHexDigits(count: number, exact?: boolean): number {'
,
' let digits = 0;'
,
' let value = 0;'
,
' while (digits < count || !exact) {'
,
' let ch = text.charCodeAt(pos);'
,
' if (isNumericHexDigit(ch) || isAlphabeticHexDigit(ch)) {'
,
' value = value * 16 + calculateHexValue(ch);'
,
' } else {'
,
' break;'
,
' }'
,
' pos++;'
,
' digits++;'
,
' }'
,
' if (digits < count) {'
,
' value = -1;'
,
' }'
,
' return value;'
,
'}'
]
,
validate
:
async
(
,
,
)
=>
{
.
ok
(
.
.
,
'has edits'
)
;
.
equal
(
numOccurrences
(
.
,
'\t// Checks if a character code is a numeric hex digit (0-9)'
)
,
1
,
'inserted with indent'
)
;
.
deepEqual
(
await
getWorkspaceDiagnostics
(
,
,
.
)
,
[
]
,
'no diagnostics'
)
;
assertNoElidedCodeComments
(
.
)
;
validateConsistentIndentation
(
.
,
false
,
.
)
;
}
}
)
;
}
)
;
stest
(
{
:
'make changes in package.json'
,
:
'json'
}
,
async
(
)
=>
{
return
simulateCodeMapper
(
,
{
:
[
fromFixture
(
'codeMapper/package.json'
)
]
,
:
'package.json'
,
:
[
11
,
0
,
17
,
0
]
,
:
[
]
,
:
[
` "keywords": [ 'ai' ], `
,
` "devDependencies": { `
,
` "@microsoft/tiktokenizer": "^1.0.6", `
,
` "@types/node": "^20.11.30", `
,
` "@vscode/test-cli": "^0.0.9", `
,
` "@vscode/test-electron": "^2.4.1", `
,
` "@types/vscode": "^1.89.0", `
,
` "esbuild": "0.25.0", `
,
` "npm-dts": "^1.3.12", `
,
` "prettier": "^2.8.7", `
,
` "tsx": "^4.6.2", `
,
` "typescript": "^5.5.0", `
,
` "vitest": "^0.34.0" `
,
` }, `
,
` "scripts": { `
,
` "test": "vitest" `
,
` } `
]
,
validate
:
async
(
,
,
)
=>
{
.
ok
(
.
.
,
'has edits'
)
;
const
=
assertJSON
(
.
)
;
.
equal
(
.
[
'vitest'
]
,
'^0.34.0'
,
'has vitest'
)
;
.
equal
(
.
[
'mocha'
]
,
undefined
,
'no longer has mocha'
)
;
.
deepEqual
(
.
,
[
'ai'
]
,
'keyword added'
)
;
.
equal
(
.
[
'test'
]
,
'vitest'
,
'has test script'
)
;
assertNoElidedCodeComments
(
.
)
;
validateConsistentIndentation
(
.
,
false
,
.
)
;
}
}
)
;
}
)
;
stest
(
{
:
'does not delete random parts of code (big file)'
,
:
'typescript'
}
,
(
)
=>
{
return
simulateCodeMapper
(
,
{
:
[
fromFixture
(
'codeMapper/quickInput.ts'
)
]
,
:
'quickInput.ts'
,
:
[
0
,
0
,
25
,
0
]
,
:
[
]
,
:
'Add a utility function to calculate Fibonacci numbers.'
,
:
[
` // ...existing code... `
,
` `
,
` /** `
,
` * Calculates the nth Fibonacci number. `
,
` * @param n - The position in the Fibonacci sequence (0-based). `
,
` * @returns The nth Fibonacci number. `
,
` */ `
,
` function fibonacci(n: number): number { `
,
` if (n <= 1) { `
,
` return n; `
,
` } `
,
` let a = 0, b = 1; `
,
` for (let i = 2; i <= n; i++) { `
,
` const temp = a + b; `
,
` a = b; `
,
` b = temp; `
,
` } `
,
` return b; `
,
` } `
,
` `
,
` // ...existing code... `
,
]
,
validate
:
async
(
,
,
)
=>
{
.
ok
(
.
.
,
'has edits'
)
;
const
=
.
;
.
ok
(
.
includes
(
'function fibonacci'
)
,
'fibonacci function not added'
)
;
.
ok
(
.
>
.
.
,
'deleted code'
)
;
assertNoElidedCodeComments
(
.
)
;
validateConsistentIndentation
(
.
,
false
,
.
)
;
}
}
)
;
}
)
;
stest
(
{
:
'does not remove stale imports #11766'
,
:
'typescript'
}
,
(
)
=>
{
return
simulateCodeMapper
(
,
{
:
[
fromFixture
(
'codeMapper/index.ts'
)
]
,
:
'index.ts'
,
:
[
0
,
0
,
25
,
0
]
,
:
[
]
,
:
'Update saveCategorization endpoint to use the new CSV utility function.'
,
:
[
` import { saveCategorizationToCSV } from '$lib/csvUtils'; `
,
` `
,
` export const POST: RequestHandler = async ({ request }) => { `
,
` const { respondentId, categories, notActionable, highlight } = await request.json(); `
,
` const filePath = 'data/export.csv'; `
,
` `
,
` saveCategorizationToCSV(filePath, respondentId, categories, notActionable, highlight); `
,
` `
,
` return new Response(null, { status: 200 }); `
,
` }; `
,
]
,
validate
:
async
(
,
,
)
=>
{
.
ok
(
.
.
,
'has edits'
)
;
const
=
.
;
.
ok
(
!
.
includes
(
` 'path' `
)
,
'rewritten file contains unused imports'
)
;
.
ok
(
!
.
includes
(
` 'fs' `
)
,
'rewritten file contains unused imports'
)
;
assertNoElidedCodeComments
(
.
)
;
validateConsistentIndentation
(
.
,
false
,
.
)
;
}
}
)
;
}
)
;
stest
(
{
:
'sorted product icons (60kb) - modify & insert'
,
:
'markdown'
,
}
,
(
)
=>
{
const
=
fromFixture
(
'codeMapper/product-icons-sorted.md'
)
;
return
simulateCodeMapper
(
,
{
:
[
]
,
:
.
,
:
[
0
,
0
,
0
,
0
]
,
:
[
]
,
:
''
,
:
[
` <!-- ... existing content ... --> `
,
` ## Icon Listing `
,
` `
,
` Below is a complete listing of the built-in product icons by identifier. `
,
` `
,
` The ID of the icon identifies the location where the icon is used. The default codicon ID describes which icon from the codicon library is used by default, and the preview shows what that icon looks like. `
,
` <!-- ... existing content ... --> `
,
` |<i class="codicon codicon-wrench"></i>|wrench| `
,
` |<i class="codicon codicon-wrench-extra"></i>|wrench-extra| `
,
` |<i class="codicon codicon-x"></i>|ports-stop-forward-icon|x|Icon for the stop forwarding action.| `
,
` <!-- ... existing content ... --> `
,
]
,
validate
:
async
(
,
,
)
=>
{
.
ok
(
.
.
,
'has edits'
)
;
const
=
.
;
const
=
.
.
replace
(
'Below is a listing'
,
'Below is a complete listing'
)
.
replace
(
'|<i class="codicon codicon-wrench"></i>|wrench|'
,
'|<i class="codicon codicon-wrench"></i>|wrench|\n|<i class="codicon codicon-wrench-extra"></i>|wrench-extra|'
)
;
.
equal
(
,
,
'rewritten file is as expected: '
)
;
assertNoElidedCodeComments
(
.
)
;
}
}
)
;
}
)
;
stest
(
{
:
'mixed product icons (60kb) - modify & insert'
,
:
'markdown'
,
}
,
(
)
=>
{
const
=
fromFixture
(
'codeMapper/product-icons-mixed.md'
)
;
return
simulateCodeMapper
(
,
{
:
[
]
,
:
.
,
:
[
0
,
0
,
0
,
0
]
,
:
[
]
,
:
''
,
:
[
` <!-- ... existing content ... --> `
,
` ## Icon Listing `
,
` `
,
` Below is a complete listing of the built-in product icons by identifier. `
,
` `
,
` The ID of the icon identifies the location where the icon is used. The default codicon ID describes which icon from the codicon library is used by default, and the preview shows what that icon looks like. `
,
` <!-- ... existing content ... --> `
,
` |<i class="codicon codicon-wrench-subaction"></i>|wrench-subaction| `
,
` |<i class="codicon codicon-wrench-extra"></i>|wrench-extra| `
,
` |<i class="codicon codicon-x"></i>|x| `
,
` <!-- ... existing content ... --> `
,
]
,
validate
:
async
(
,
,
)
=>
{
.
ok
(
.
.
,
'has edits'
)
;
const
=
.
;
const
=
.
.
replace
(
'Below is a listing'
,
'Below is a complete listing'
)
.
replace
(
'|<i class="codicon codicon-wrench-subaction"></i>|wrench-subaction|'
,
'|<i class="codicon codicon-wrench-subaction"></i>|wrench-subaction|\n|<i class="codicon codicon-wrench-extra"></i>|wrench-extra|'
)
;
.
equal
(
,
,
'rewritten file is as expected: '
)
;
assertNoElidedCodeComments
(
.
)
;
}
}
)
;
}
)
;
stest
(
{
:
'other tests updated similarly'
,
:
'typescript'
,
}
,
(
)
=>
{
const
=
fromFixture
(
'codeMapper/extHostExtensionActivator.test.ts'
)
;
return
simulateCodeMapper
(
,
{
:
[
]
,
:
.
,
:
[
0
,
0
,
0
,
0
]
,
:
[
]
,
:
''
,
:
[
` suite('ExtensionsActivator', () => { `
,
` `
,
` ensureNoDisposablesAreLeakedInTestSuite(); `
,
` `
,
` let activator: ExtensionsActivator | undefined; `
,
` `
,
` teardown(() => { `
,
` if (activator) { `
,
` activator.dispose(); `
,
` activator = undefined; `
,
` } `
,
` }); `
,
` `
,
` const idA = new ExtensionIdentifier(\`a\`); `
,
` const idB = new ExtensionIdentifier(\`b\`); `
,
` const idC = new ExtensionIdentifier(\`c\`); `
,
` `
,
` test('calls activate only once with sequential activations', async () => { `
,
` const host = new SimpleExtensionsActivatorHost(); `
,
` activator = createActivator(host, [ `
,
` desc(idA) `
,
` ]); `
,
` `
,
` await activator.activateByEvent('*', false); `
,
` assert.deepStrictEqual(host.activateCalls, [idA]); `
,
` `
,
` await activator.activateByEvent('*', false); `
,
` assert.deepStrictEqual(host.activateCalls, [idA]); `
,
` }); `
,
` `
,
` test('calls activate only once with parallel activations', async () => { `
,
` const extActivation = new ExtensionActivationPromiseSource(); `
,
` const host = new PromiseExtensionsActivatorHost([ `
,
` [idA, extActivation] `
,
` ]); `
,
` activator = createActivator(host, [ `
,
` desc(idA, [], ['evt1', 'evt2']) `
,
` ]); `
,
` `
,
` const activate1 = activator.activateByEvent('evt1', false); `
,
` const activate2 = activator.activateByEvent('evt2', false); `
,
` `
,
` extActivation.resolve(); `
,
` `
,
` await activate1; `
,
` await activate2; `
,
` `
,
` assert.deepStrictEqual(host.activateCalls, [idA]); `
,
` }); `
,
` `
,
` // ...other tests updated similarly... `
,
` `
,
` }); `
,
]
,
validate
:
async
(
,
,
)
=>
{
.
ok
(
.
.
,
'has edits'
)
;
.
equal
(
numRegexOccurrences
(
.
,
/ (?! const\s * ) activator = createActivator/ g
)
,
9
)
;
.
equal
(
numOccurrences
(
.
,
'activator.dispose();'
)
,
1
)
;
assertNoElidedCodeComments
(
.
)
;
validateConsistentIndentation
(
.
,
false
,
.
)
;
}
}
)
;
}
)
;
stest
(
{
:
'looping in short yaml file'
,
:
'yaml'
}
,
(
)
=>
{
const
=
fromFixture
(
'codeMapper/product-build-linux.yml'
)
;
return
simulateCodeMapper
(
,
{
:
[
]
,
:
.
,
:
[
363
,
0
,
387
,
0
]
,
:
[
]
,
:
` I'll modify the snap building section to split it into two parts - preparation and building within the FOO container. `
,
:
[
` - script: | `
,
` set -e `
,
` npm run gulp "vscode-linux-$(VSCODE_ARCH)-prepare-snap" `
,
` `
,
` # Create a tarball of the snap content `
,
` SNAP_ROOT="$(pwd)/.build/linux/snap/$(VSCODE_ARCH)" `
,
` SNAP_TARBALL_PATH="$(pwd)/.build/linux/snap-tarball" `
,
` mkdir -p "$SNAP_TARBALL_PATH" `
,
` tar -czf "$SNAP_TARBALL_PATH/snap-$(VSCODE_ARCH).tar.gz" -C "$SNAP_ROOT" . `
,
` displayName: Prepare snap package `
,
` `
,
` - task: 1ES.PublishPipelineArtifact@2 `
,
` displayName: "Publish snap tarball for container build" `
,
` inputs: `
,
` targetPath: .build/linux/snap-tarball `
,
` artifact: snap-$(VSCODE_ARCH) `
,
` `
,
` - task: DownloadPipelineArtifact@2 `
,
` displayName: "Download snap tarball for container build" `
,
` inputs: `
,
` artifact: snap-$(VSCODE_ARCH) `
,
` path: .build/linux/snap-tarball `
,
` `
,
` - script: | `
,
` set -e `
,
` `
,
` # Define variables `
,
` SNAP_ROOT="$(pwd)/.build/linux/snap/$(VSCODE_ARCH)" `
,
` `
,
` # Extract snap tarball content if it doesn't exist `
,
` mkdir -p "$SNAP_ROOT" `
,
` `
,
` # Run build steps inside the FOO container `
,
` sudo docker run \\ `
,
` --rm \\ `
,
` -v "$(pwd):/workspace" \\ `
,
` -e VSCODE_QUALITY \\ `
,
` -e VSCODE_ARCH \\ `
,
` FOO \\ `
,
` /bin/bash -c "cd /workspace && \\ `
,
` # Get snapcraft version `
,
` snapcraft --version && \\ `
,
` `
,
` # Make sure we get latest packages `
,
` apt-get update && \\ `
,
` apt-get upgrade -y && \\ `
,
` apt-get install -y curl apt-transport-https ca-certificates && \\ `
,
` `
,
` # Define variables `
,
` SNAP_ROOT='/workspace/.build/linux/snap/\$VSCODE_ARCH' && \\ `
,
` `
,
` # Unpack snap tarball artifact, in order to preserve file perms `
,
` (cd /workspace/.build/linux && tar -xzf snap-tarball/snap-\$VSCODE_ARCH.tar.gz) && \\ `
,
` `
,
` # Create snap package `
,
` BUILD_VERSION=\$(date +%s) && \\ `
,
` SNAP_FILENAME=code-\$VSCODE_QUALITY-\$VSCODE_ARCH-\$BUILD_VERSION.snap && \\ `
,
` SNAP_PATH=\$SNAP_ROOT/\$SNAP_FILENAME && \\ `
,
` case \$VSCODE_ARCH in \\ `
,
` x64) SNAPCRAFT_TARGET_ARGS=\"\" ;; \\ `
,
` *) SNAPCRAFT_TARGET_ARGS=\"--target-arch \$VSCODE_ARCH\" ;; \\ `
,
` esac && \\ `
,
` (cd \$SNAP_ROOT/code-* && snapcraft snap \$SNAPCRAFT_TARGET_ARGS --output \"\$SNAP_PATH\") && \\ `
,
` `
,
` # Fix permissions for files created inside container `
,
` chown -R $(id -u):$(id -g) /workspace/.build/linux/snap" `
,
` `
,
` # Find the generated snap file `
,
` SNAP_PATH=$(find .build/linux/snap/$(VSCODE_ARCH) -name "*.snap" | head -n 1) `
,
` echo "##vso[task.setvariable variable=SNAP_PATH]$SNAP_PATH" `
,
` `
,
` # Save the directory path for SBOM generation `
,
` SNAP_EXTRACTED_PATH=$(find .build/linux/snap/$(VSCODE_ARCH) -maxdepth 1 -type d -name 'code-*') `
,
` echo "##vso[task.setvariable variable=SNAP_EXTRACTED_PATH]$SNAP_EXTRACTED_PATH" `
,
` env: `
,
` VSCODE_QUALITY: \${{ parameters.VSCODE_QUALITY }} `
,
` VSCODE_ARCH: $(VSCODE_ARCH) `
,
` displayName: Build snap package inside FOO container `
,
]
,
validate
:
async
(
,
,
)
=>
{
.
ok
(
.
.
,
'has edits'
)
;
const
=
.
.
split
(
'\n'
)
.
;
const
=
.
.
split
(
'\n'
)
.
;
.
ok
(
>=
,
'deleted code'
)
;
assertNoElidedCodeComments
(
.
)
;
}
}
)
;
}
)
;
}
)
;
function
numOccurrences
(
:
string
,
:
string
)
:
number
{
return
.
split
(
)
.
-
1
;
}
function
numRegexOccurrences
(
:
string
,
:
)
:
number
{
const
=
.
match
(
)
;
return
?
.
:
0
;
}
interface
IOutcome
{
:
[
]
;
:
[
]
;
:
string
;
:
string
;
}
interface
ICodeMapperScenario
{
:
[
]
;
:
string
;
:
[
number
,
number
,
number
,
number
]
;
:
[
number
,
number
,
number
,
number
]
[
]
;
?
:
string
;
:
string
[
]
;
validate
:
(
:
,
:
,
:
)
=>
Promise
<
void
>
;
}
async
function
simulateCodeMapper
(
:
,
:
)
:
Promise
<
void
>
{
const
=
setupSimulationWorkspace
(
,
{
:
.
}
)
;
const
=
.
createTestingAccessor
(
)
;
const
=
.
get
(
)
;
const
:
[
]
=
[
]
;
const
=
new
CancellationTokenSource
(
)
;
try
{
const
=
.
getDocument
(
.
)
.
;
.
setCurrentDocument
(
.
)
;
const
=
new
Selection
(
...
.
)
;
.
setCurrentSelection
(
)
;
const
=
.
getFilePath
(
.
)
;
.
push
(
{
:
'initial'
,
:
{
,
:
await
.
writeFile
(
+
'.txt'
,
.
getText
(
)
,
INLINE_INITIAL_DOC_TAG
)
,
:
.
}
,
:
[
]
,
:
.
,
:
toIRange
(
)
,
:
toIRange
(
)
,
:
[
]
,
}
)
;
const
=
.
get
(
)
.
!
;
const
=
.
fromEditor
(
)
;
const
=
.
get
(
)
.
createInstance
(
)
;
const
=
new
WorkingCopyOriginalDocument
(
.
getText
(
)
)
;
const
:
=
{
textEdit
(
,
)
{
if
(
isEqual
(
,
.
)
)
{
=
Array
.
isArray
(
)
?
:
[
]
;
.
applyEdits
(
.
,
)
;
const
=
.
.
toOffsetEdit
(
)
;
.
applyOffsetEdits
(
)
;
}
else
{
throw
new
Error
(
'Unexpected target: '
+
)
;
}
}
,
notebookEdit
(
,
)
{
=
Array
.
isArray
(
)
?
:
[
]
;
.
applyNotebookEdits
(
,
)
;
}
,
}
;
const
=
.
.
join
(
'\n'
)
;
const
:
=
{
:
false
,
:
,
:
.
,
:
.
,
:
.
}
;
const
=
.
getText
(
)
;
const
=
await
.
mapCode
(
,
,
undefined
,
.
)
;
if
(
!
)
{
return
;
}
.
setOutcome
(
{
:
'edit'
,
:
[
{
:
,
:
}
]
,
:
.
}
)
;
.
push
(
{
:
'interaction'
,
:
[
{
,
:
await
.
writeFile
(
,
.
getText
(
)
,
INLINE_CHANGED_DOC_TAG
)
,
:
.
}
]
,
:
.
,
:
.
getFilePath
(
.
.
)
,
:
.
,
:
{
}
,
:
toIRange
(
.
)
,
:
toIRange
(
.
)
,
:
{
:
''
,
:
.
,
:
undefined
,
}
,
:
0
}
)
;
const
=
.
.
toTextEdits
(
.
)
;
await
.
validate
(
{
,
:
.
,
,
:
.
getText
(
)
,
}
,
,
)
;
}
finally
{
.
dispose
(
)
;
await
teardownSimulationWorkspace
(
,
)
;
await
.
writeFile
(
'inline-simulator.txt'
,
JSON
.
stringify
(
,
undefined
,
2
)
,
INLINE_STATE_TAG
)
;
}
}
}
)
;