ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / src / vs / platform / contextkey / test / browser / contextkey.test.ts 325 строк · изменён 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
import assert from 'assert' ;
import { DeferredPromise } from '../../../../base/common/async.js' ;
import { URI } from '../../../../base/common/uri.js' ;
import { mock } from '../../../../base/test/common/mock.js' ;
import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../base/test/common/utils.js' ;
import { IConfigurationService } from '../../../configuration/common/configuration.js' ;
import { TestConfigurationService } from '../../../configuration/test/common/testConfigurationService.js' ;
import { ContextKeyService, setContext
ContextKeyExpr IContextKeyService
ServiceCollection
TestInstantiationService
ITelemetryService
testDisposables
root testDisposables
parent1 testDisposables root document
parent2 testDisposables root document
child testDisposables parent1 document
parent1
parent1
parent1
parent2
parent2
parent2
err Error
p _complete _reject
complete _complete
reject _reject
testDisposables child e
assert e
assert e
assert e
assert e
assert child
assert child
assert child
assert child
err
err
child parent2
p
root testDisposables
parent1 testDisposables root document
child testDisposables parent1 document
parent1
parent1
parent1
eventFired
testDisposables child e
eventFired
child parent1
assert eventFired
configurationService IConfigurationService
contextKeyService IContextKeyService testDisposables configurationService
instantiationService testDisposables
IConfigurationService configurationService
IContextKeyService contextKeyService
ITelemetryService
override
uri
contextKeyService uri
instantiationService setContext uri
expr ContextKeyExpr
assert contextKeyService expr
root testDisposables
child testDisposables root document
root
child
fired
event testDisposables child e fired
root
assert fired
event
root testDisposables
child testDisposables root document
root
root
root
child
child
child
fired
event testDisposables child e fired
root
root
root
root
assert fired
event
root testDisposables
child testDisposables root document
root
root
root
child
child
child
def
testDisposables child e
assert e
assert e
assert e
err
def err
def
root
root
root
root
def p
root testDisposables
key root
eventFired
testDisposables root e
eventFired
key
assert eventFired
root testDisposables
key root
eventFired
testDisposables root e
eventFired
key
assert eventFired
root testDisposables
initialValue foo count
key root initialValue
eventFired
testDisposables root e
eventFired
key foo count
assert eventFired
root testDisposables
initialValue foo count
key root initialValue
eventFired
testDisposables root e
eventFired
key foo count
assert eventFired
root testDisposables
key root
eventFired
testDisposables root e
eventFired
key
assert eventFired
root testDisposables
initialValue
key root initialValue
eventFired
testDisposables root e
eventFired
key
assert eventFired
root testDisposables
key root
eventFired
testDisposables root e
eventFired
key
assert eventFired
root testDisposables
key root
eventFired
testDisposables root e
eventFired
key
assert eventFired
root testDisposables
scoped root document
child scoped document
child
assert child
scoped
child
assert root
}
from
'../../browser/contextKeyService.js'
;
import
{
,
}
from
'../../common/contextkey.js'
;
import
{
}
from
'../../../instantiation/common/serviceCollection.js'
;
import
{
}
from
'../../../instantiation/test/common/instantiationServiceMock.js'
;
import
{
}
from
'../../../telemetry/common/telemetry.js'
;
suite
(
'ContextKeyService'
,
(
)
=>
{
const
=
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
test
(
'updateParent'
,
(
)
=>
{
const
=
.
add
(
new
ContextKeyService
(
new
TestConfigurationService
(
)
)
)
;
const
=
.
add
(
.
createScoped
(
.
createElement
(
'div'
)
)
)
;
const
=
.
add
(
.
createScoped
(
.
createElement
(
'div'
)
)
)
;
const
=
.
add
(
.
createScoped
(
.
createElement
(
'div'
)
)
)
;
.
createKey
(
'testA'
,
1
)
;
.
createKey
(
'testB'
,
2
)
;
.
createKey
(
'testD'
,
0
)
;
.
createKey
(
'testA'
,
3
)
;
.
createKey
(
'testC'
,
4
)
;
.
createKey
(
'testD'
,
0
)
;
let
complete
:
(
)
=>
void
;
let
reject
:
(
:
)
=>
void
;
const
=
new
Promise < void >
(
(
,
)
=>
{
=
;
=
;
}
)
;
.
add
(
.
onDidChangeContext
(
=>
{
try
{
.
ok
(
.
affectsSome
(
new
Set
(
[
'testA'
]
)
)
,
'testA changed'
)
;
.
ok
(
.
affectsSome
(
new
Set
(
[
'testB'
]
)
)
,
'testB changed'
)
;
.
ok
(
.
affectsSome
(
new
Set
(
[
'testC'
]
)
)
,
'testC changed'
)
;
.
ok
(
!
.
affectsSome
(
new
Set
(
[
'testD'
]
)
)
,
'testD did not change'
)
;
.
strictEqual
(
.
getContextKeyValue
(
'testA'
)
,
3
)
;
.
strictEqual
(
.
getContextKeyValue
(
'testB'
)
,
undefined
)
;
.
strictEqual
(
.
getContextKeyValue
(
'testC'
)
,
4
)
;
.
strictEqual
(
.
getContextKeyValue
(
'testD'
)
,
0
)
;
}
catch
(
)
{
reject
(
)
;
return
;
}
complete
(
)
;
}
)
)
;
.
updateParent
(
)
;
return
;
}
)
;
test
(
'updateParent to same service'
,
(
)
=>
{
const
=
.
add
(
new
ContextKeyService
(
new
TestConfigurationService
(
)
)
)
;
const
=
.
add
(
.
createScoped
(
.
createElement
(
'div'
)
)
)
;
const
=
.
add
(
.
createScoped
(
.
createElement
(
'div'
)
)
)
;
.
createKey
(
'testA'
,
1
)
;
.
createKey
(
'testB'
,
2
)
;
.
createKey
(
'testD'
,
0
)
;
let
=
false
;
.
add
(
.
onDidChangeContext
(
=>
{
=
true
;
}
)
)
;
.
updateParent
(
)
;
.
strictEqual
(
,
false
)
;
}
)
;
test
(
'issue #147732: URIs as context values'
,
(
)
=>
{
const
:
=
new
TestConfigurationService
(
)
;
const
:
=
.
add
(
new
ContextKeyService
(
)
)
;
const
=
.
add
(
new
TestInstantiationService
(
new
ServiceCollection
(
[
,
]
,
[
,
]
,
[
,
new
class
extends
mock< ITelemetryService>
(
)
{
async
publicLog2
(
)
{
}
}
]
)
)
)
;
const
=
URI
.
parse
(
'test://abc'
)
;
.
createKey < string >
(
'notebookCellResource'
,
undefined
)
.
set
(
.
toString
(
)
)
;
.
invokeFunction
(
,
'jupyter.runByLineCells'
,
JSON
.
parse
(
JSON
.
stringify
(
[
]
)
)
)
;
const
=
.
in
(
'notebookCellResource'
,
'jupyter.runByLineCells'
)
;
.
deepStrictEqual
(
.
contextMatchesRules
(
)
,
true
)
;
}
)
;
test
(
'suppress update event from parent when one key is overridden by child'
,
(
)
=>
{
const
=
.
add
(
new
ContextKeyService
(
new
TestConfigurationService
(
)
)
)
;
const
=
.
add
(
.
createScoped
(
.
createElement
(
'div'
)
)
)
;
.
createKey
(
'testA'
,
1
)
;
.
createKey
(
'testA'
,
4
)
;
let
=
false
;
const
=
.
add
(
.
onDidChangeContext
(
=>
=
true
)
)
;
.
setContext
(
'testA'
,
10
)
;
.
strictEqual
(
,
false
,
'Should not fire event when overridden key is updated in parent'
)
;
.
dispose
(
)
;
}
)
;
test
(
'suppress update event from parent when all keys are overridden by child'
,
(
)
=>
{
const
=
.
add
(
new
ContextKeyService
(
new
TestConfigurationService
(
)
)
)
;
const
=
.
add
(
.
createScoped
(
.
createElement
(
'div'
)
)
)
;
.
createKey
(
'testA'
,
1
)
;
.
createKey
(
'testB'
,
2
)
;
.
createKey
(
'testC'
,
3
)
;
.
createKey
(
'testA'
,
4
)
;
.
createKey
(
'testB'
,
5
)
;
.
createKey
(
'testD'
,
6
)
;
let
=
false
;
const
=
.
add
(
.
onDidChangeContext
(
=>
=
true
)
)
;
.
bufferChangeEvents
(
(
)
=>
{
.
setContext
(
'testA'
,
10
)
;
.
setContext
(
'testB'
,
20
)
;
.
setContext
(
'testD'
,
30
)
;
}
)
;
.
strictEqual
(
,
false
,
'Should not fire event when overridden key is updated in parent'
)
;
.
dispose
(
)
;
}
)
;
test
(
'pass through update event from parent when one key is not overridden by child'
,
(
)
=>
{
const
=
.
add
(
new
ContextKeyService
(
new
TestConfigurationService
(
)
)
)
;
const
=
.
add
(
.
createScoped
(
.
createElement
(
'div'
)
)
)
;
.
createKey
(
'testA'
,
1
)
;
.
createKey
(
'testB'
,
2
)
;
.
createKey
(
'testC'
,
3
)
;
.
createKey
(
'testA'
,
4
)
;
.
createKey
(
'testB'
,
5
)
;
.
createKey
(
'testD'
,
6
)
;
const
=
new
DeferredPromise
(
)
;
.
add
(
.
onDidChangeContext
(
=>
{
try
{
.
ok
(
.
affectsSome
(
new
Set
(
[
'testA'
]
)
)
,
'testA changed'
)
;
.
ok
(
.
affectsSome
(
new
Set
(
[
'testB'
]
)
)
,
'testB changed'
)
;
.
ok
(
.
affectsSome
(
new
Set
(
[
'testC'
]
)
)
,
'testC changed'
)
;
}
catch
(
)
{
.
error
(
)
;
return
;
}
.
complete
(
undefined
)
;
}
)
)
;
.
bufferChangeEvents
(
(
)
=>
{
.
setContext
(
'testA'
,
10
)
;
.
setContext
(
'testB'
,
20
)
;
.
setContext
(
'testC'
,
30
)
;
}
)
;
return
.
;
}
)
;
test
(
'setting identical array values should not fire change event'
,
(
)
=>
{
const
=
.
add
(
new
ContextKeyService
(
new
TestConfigurationService
(
)
)
)
;
const
=
.
createKey < string [ ] >
(
'testArray'
,
[
'a'
,
'b'
,
'c'
]
)
;
let
=
false
;
.
add
(
.
onDidChangeContext
(
=>
{
=
true
;
}
)
)
;
.
set
(
[
'a'
,
'b'
,
'c'
]
)
;
.
strictEqual
(
,
false
,
'Should not fire event when setting identical array'
)
;
}
)
;
test
(
'setting different array values should fire change event'
,
(
)
=>
{
const
=
.
add
(
new
ContextKeyService
(
new
TestConfigurationService
(
)
)
)
;
const
=
.
createKey < string [ ] >
(
'testArray'
,
[
'a'
,
'b'
,
'c'
]
)
;
let
=
false
;
.
add
(
.
onDidChangeContext
(
=>
{
=
true
;
}
)
)
;
.
set
(
[
'a'
,
'b'
,
'd'
]
)
;
.
strictEqual
(
,
true
,
'Should fire event when setting different array'
)
;
}
)
;
test
(
'setting identical complex object should not fire change event'
,
(
)
=>
{
const
=
.
add
(
new
ContextKeyService
(
new
TestConfigurationService
(
)
)
)
;
const
=
{
:
'bar'
,
:
42
}
;
const
=
.
createKey < Record< string , string | number >>
(
'testObject'
,
)
;
let
=
false
;
.
add
(
.
onDidChangeContext
(
=>
{
=
true
;
}
)
)
;
.
set
(
{
:
'bar'
,
:
42
}
)
;
.
strictEqual
(
,
false
,
'Should not fire event when setting identical object'
)
;
}
)
;
test
(
'setting different complex object should fire change event'
,
(
)
=>
{
const
=
.
add
(
new
ContextKeyService
(
new
TestConfigurationService
(
)
)
)
;
const
=
{
:
'bar'
,
:
42
}
;
const
=
.
createKey < Record< string , string | number >>
(
'testObject'
,
)
;
let
=
false
;
.
add
(
.
onDidChangeContext
(
=>
{
=
true
;
}
)
)
;
.
set
(
{
:
'bar'
,
:
43
}
)
;
.
strictEqual
(
,
true
,
'Should fire event when setting different object'
)
;
}
)
;
test
(
'setting empty arrays should not fire change event when identical'
,
(
)
=>
{
const
=
.
add
(
new
ContextKeyService
(
new
TestConfigurationService
(
)
)
)
;
const
=
.
createKey < string [ ] >
(
'testArray'
,
[
]
)
;
let
=
false
;
.
add
(
.
onDidChangeContext
(
=>
{
=
true
;
}
)
)
;
.
set
(
[
]
)
;
.
strictEqual
(
,
false
,
'Should not fire event when setting identical empty array'
)
;
}
)
;
test
(
'setting nested arrays should handle deep equality'
,
(
)
=>
{
const
=
.
add
(
new
ContextKeyService
(
new
TestConfigurationService
(
)
)
)
;
const
=
[
'a:b'
,
'c:d'
]
;
const
=
.
createKey < string [ ] >
(
'testComplexArray'
,
)
;
let
=
false
;
.
add
(
.
onDidChangeContext
(
=>
{
=
true
;
}
)
)
;
.
set
(
[
'a:b'
,
'c:d'
]
)
;
.
strictEqual
(
,
false
,
'Should not fire event when setting identical array with complex values'
)
;
}
)
;
test
(
'setting same primitive values should not fire change event'
,
(
)
=>
{
const
=
.
add
(
new
ContextKeyService
(
new
TestConfigurationService
(
)
)
)
;
const
=
.
createKey
(
'testString'
,
'hello'
)
;
let
=
false
;
.
add
(
.
onDidChangeContext
(
=>
{
=
true
;
}
)
)
;
.
set
(
'hello'
)
;
.
strictEqual
(
,
false
,
'Should not fire event when setting identical string'
)
;
}
)
;
test
(
'setting different primitive values should fire change event'
,
(
)
=>
{
const
=
.
add
(
new
ContextKeyService
(
new
TestConfigurationService
(
)
)
)
;
const
=
.
createKey < number >
(
'testNumber'
,
42
)
;
let
=
false
;
.
add
(
.
onDidChangeContext
(
=>
{
=
true
;
}
)
)
;
.
set
(
43
)
;
.
strictEqual
(
,
true
,
'Should fire event when setting different number'
)
;
}
)
;
test
(
'disposeContext forwards through disposed scoped service'
,
(
)
=>
{
const
=
.
add
(
new
ContextKeyService
(
new
TestConfigurationService
(
)
)
)
;
const
=
.
createScoped
(
.
createElement
(
'div'
)
)
;
const
=
.
createScoped
(
.
createElement
(
'div'
)
)
;
.
createKey
(
'testKey'
,
'value'
)
;
.
strictEqual
(
.
getContextKeyValue
(
'testKey'
)
,
'value'
)
;
.
dispose
(
)
;
.
dispose
(
)
;
.
strictEqual
(
.
getContextKeyValue
(
'testKey'
)
,
undefined
,
'Child context should be cleaned up even when parent scoped service was disposed first'
)
;
}
)
;
}
)
;