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 / browser / contextKeyService.ts 686 строк · изменён 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
import { Emitter, Event, PauseableEmitter } from '../../../base/common/event.js' ;
import { Iterable } from '../../../base/common/iterator.js' ;
import { Disposable, DisposableStore, IDisposable, MutableDisposable } from '../../../base/common/lifecycle.js' ;
import { MarshalledObject } from '../../../base/common/marshalling.js' ;
import { MarshalledId } from '../../../base/common/marshallingIds.js' ;
import { cloneAndChange, distinct, equals } from '../../../base/common/objects.js' ;
import { TernarySearchTree
localize
CommandsRegistry
ConfigurationTarget IConfigurationService
ContextKeyExpression ContextKeyInfo ContextKeyValue IContext IContextKey IContextKeyChangeEvent IContextKeyService IContextKeyServiceTarget IReadableSet IScopedContextKeyService RawContextKey
ServicesAccessor
InputFocusedContext
mainWindow
addDisposableListener EventType getActiveWindow isEditableElement onDidRegisterWindow trackFocus
_parent Context
_value Record
_id
id parent Context
_id id
_parent parent
_value Object
_value id
Record
_value
key value
_value key value
_value key value
key
key _value
_value key
key
ret _value key
ret _parent
_parent key
ret
parent Context
_parent parent
Record
result _parent _parent Object
result result _value
result
result
override key value
override key
override key
override key
Object
_keyPrefix
_values TernarySearchTree
_listener IDisposable
id
_configurationService IConfigurationService
emitter Emitter IContextKeyChangeEvent
id
_listener _configurationService event
event source ConfigurationTarget
allKeys _values k k
_values
emitter allKeys
changedKeys
configKey event affectedKeys
contextKey
cachedItems _values contextKey
cachedItems
changedKeys Iterable cachedItems key key
_values contextKey
_values contextKey
changedKeys contextKey
_values contextKey
emitter changedKeys
_listener
override key
key ConfigAwareContextValuesContainer _keyPrefix
key
_values key
_values key
configKey key ConfigAwareContextValuesContainer _keyPrefix length
configValue _configurationService configKey
value
configValue
value configValue
configValue
value configValue
value configValue
_values key value
value
override key value
key value
override key
key
override key
result key Object
_values value index result index value
result
_service AbstractContextKeyService
_key
_defaultValue
service AbstractContextKeyService key defaultValue
_service service
_key key
_defaultValue defaultValue
value
_service _key value
_defaultValue
_service _key
_service _key _defaultValue
_service _key
key
keys IReadableSet
keys key
keys IReadableSet
keys
keys
keys IReadableSet
key keys
keys key
keys IReadableSet
keys key keys key
events IContextKeyChangeEvent
keys IReadableSet
e events
e keys
keys IReadableSet
events evt evt keys
event IContextKeyChangeEvent context Record
event Object context
_serviceBrand
_isDisposed
_myContextId
_onDidChangeContext input input
_onDidChangeContext event
myContextId
_isDisposed
_myContextId myContextId
_myContextId
key defaultValue IContextKey
_isDisposed
key defaultValue
callback
_onDidChangeContext
_onDidChangeContext
domNode IContextKeyServiceTarget IScopedContextKeyService
_isDisposed
domNode
overlay Iterable Iterable IContextKeyService
_isDisposed
overlay
rules ContextKeyExpression
_isDisposed
context _myContextId
result rules rules context
result
key
_isDisposed
_myContextId key
key value
_isDisposed
myContext _myContextId
myContext
myContext key value
_onDidChangeContext key
key
_isDisposed
_myContextId key
_onDidChangeContext key
target IContextKeyServiceTarget IContext
_isDisposed
NullContext
target
contextId Context
parentContextId
contextId
parentContextKeyService IContextKeyService
override
_isDisposed
_lastContextId
_contexts
inputFocusedContext IContextKey
configurationService IConfigurationService
_lastContextId
inputFocusedContext InputFocusedContext
myContext _myContextId configurationService _onDidChangeContext
_contexts _myContextId myContext
Event onDidRegisterWindow window disposables
onFocusDisposables disposables
disposables window EventType
onFocusDisposables value
window document onFocusDisposables value
window mainWindow disposables _store
ownerDocument Document disposables DisposableStore
ownerDocument activeElement ownerDocument activeElement
isInputFocused
inputFocusedContext isInputFocused
isInputFocused
tracker disposables ownerDocument activeElement HTMLElement
Event tracker onDidBlur
document ownerDocument
inputFocusedContext
tracker
disposables
contextId Context
_isDisposed
NullContext
_contexts contextId NullContext
parentContextId _myContextId
_isDisposed
id _lastContextId
_contexts id id parentContextId
id
contextId
_isDisposed
_contexts contextId
_parentContextKeyService IContextKeyService
_parent AbstractContextKeyService
_domNode IContextKeyServiceTarget
_parentChangeListener
parent AbstractContextKeyService domNode IContextKeyServiceTarget
parent
_parent parent
_domNode domNode
_domNode
extraInfo
_domNode HTMLElement classList
extraInfo _domNode HTMLElement classList
_domNode _myContextId
_parentChangeListener value _parent e
thisContainer _parent _myContextId
thisContextValues thisContainer value
e thisContextValues
_onDidChangeContext e
override
_isDisposed
_parentChangeListener
_parent _myContextId
_domNode
contextId Context
_isDisposed
NullContext
_parent contextId
parentContextId _myContextId
_isDisposed
_parent parentContextId
contextId
_parent contextId
parentContextKeyService AbstractContextKeyService
_parent parentContextKeyService
thisContainer _parent _myContextId
oldAllValues thisContainer
_parent parentContextKeyService
newParentContainer _parent _parent contextId
thisContainer newParentContainer
newAllValues thisContainer
allValuesDiff
oldAllValues newAllValues
newAllValues oldAllValues
changedKeys Object allValuesDiff
_onDidChangeContext changedKeys
parent IContext overlay ReadonlyMap
key
overlay key overlay key parent key
_serviceBrand
overlay Map
parent contextId
Event IContextKeyChangeEvent
parent onDidChangeContext
parent AbstractContextKeyService OverlayContextKeyService overlay Iterable
overlay overlay
callback
parent callback
IContextKey
target IContextKeyServiceTarget IContext
parent target overlay
contextId IContext
parentContext parent contextId
parentContext overlay
rules ContextKeyExpression
context contextId
result rules rules context
result
key
overlay key overlay key parent key
IScopedContextKeyService
overlay Iterable Iterable IContextKeyService
overlay
domNode IContextKeyServiceTarget
domNode
domNode
attr domNode
attr
attr
domNode domNode parentElement
accessor ServicesAccessor contextKey contextValue
contextKeyService accessor IContextKeyService
contextKeyService contextKey contextValue
contextValue
contextValue obj
obj MarshalledObject obj $mid MarshalledId Uri
obj
obj
obj
CommandsRegistry setContext
CommandsRegistry
id
RawContextKey a b a key b key
metadata
description
args
CommandsRegistry
result ContextKeyInfo
seen
info RawContextKey
seen info key
seen info key
result info
result a b a key b key
result
}
from
'../../../base/common/ternarySearchTree.js'
;
import
{
URI
}
from
'../../../base/common/uri.js'
;
import
{
}
from
'../../../nls.js'
;
import
{
}
from
'../../commands/common/commands.js'
;
import
{
,
}
from
'../../configuration/common/configuration.js'
;
import
{
,
,
,
,
,
,
,
,
,
,
}
from
'../common/contextkey.js'
;
import
{
}
from
'../../instantiation/common/instantiation.js'
;
import
{
}
from
'../common/contextkeys.js'
;
import
{
}
from
'../../../base/browser/window.js'
;
import
{
,
,
,
,
,
}
from
'../../../base/browser/dom.js'
;
const
KEYBINDING_CONTEXT_ATTR
=
'data-keybinding-context'
;
export
class
Context
implements
IContext
{
protected
:
|
null
;
protected
:
<
string
,
any
>
;
protected
:
number
;
constructor
(
:
number
,
:
|
null
)
{
this
.
=
;
this
.
=
;
this
.
=
.
create
(
null
)
;
this
.
[
'_contextId'
]
=
;
}
public
get
value
(
)
:
<
string
,
any
>
{
return
{
...
this
.
}
;
}
public
setValue
(
:
string
,
:
any
)
:
boolean
{
if
(
!
equals
(
this
.
[
]
,
)
)
{
this
.
[
]
=
;
return
true
;
}
return
false
;
}
public
removeValue
(
:
string
)
:
boolean
{
if
(
in
this
.
)
{
delete
this
.
[
]
;
return
true
;
}
return
false
;
}
public
getValue < T >
(
:
string
)
:
T
|
undefined
{
const
=
this
.
[
]
;
if
(
typeof
===
'undefined'
&&
this
.
)
{
return
this
.
.
getValue < T >
(
)
;
}
return
;
}
public
updateParent
(
:
)
:
void
{
this
.
=
;
}
public
collectAllValues
(
)
:
<
string
,
any
>
{
let
=
this
.
?
this
.
.
collectAllValues
(
)
:
.
create
(
null
)
;
=
{
...
,
...
this
.
}
;
delete
[
'_contextId'
]
;
return
;
}
}
class
NullContext
extends
Context
{
static
readonly
INSTANCE
=
new
NullContext
(
)
;
constructor
(
)
{
super
(
-
1
,
null
)
;
}
public
setValue
(
:
string
,
:
any
)
:
boolean
{
return
false
;
}
public
removeValue
(
:
string
)
:
boolean
{
return
false
;
}
public
getValue < T >
(
:
string
)
:
T
|
undefined
{
return
undefined
;
}
collectAllValues
(
)
:
{
[
:
string
]
:
any
}
{
return
.
create
(
null
)
;
}
}
class
ConfigAwareContextValuesContainer
extends
Context
{
private
static
readonly
=
'config.'
;
private
readonly
=
.
forConfigKeys < any >
(
)
;
private
readonly
:
;
constructor
(
:
number
,
private
readonly
:
,
:
<
>
)
{
super
(
,
null
)
;
this
.
=
this
.
.
onDidChangeConfiguration
(
=>
{
if
(
.
===
.
DEFAULT
)
{
const
=
Array
.
from
(
this
.
,
(
[
]
)
=>
)
;
this
.
.
clear
(
)
;
.
fire
(
new
ArrayContextKeyChangeEvent
(
)
)
;
}
else
{
const
:
string
[
]
=
[
]
;
for
(
const
of
.
)
{
const
=
` config. ${ configKey} `
;
const
=
this
.
.
findSuperstr
(
)
;
if
(
!==
undefined
)
{
.
push
(
...
.
map
(
,
(
[
]
)
=>
)
)
;
this
.
.
deleteSuperstr
(
)
;
}
if
(
this
.
.
has
(
)
)
{
.
push
(
)
;
this
.
.
delete
(
)
;
}
}
.
fire
(
new
ArrayContextKeyChangeEvent
(
)
)
;
}
}
)
;
}
dispose
(
)
:
void
{
this
.
.
dispose
(
)
;
}
getValue
(
:
string
)
:
any
{
if
(
.
indexOf
(
.
)
!==
0
)
{
return
super
.
getValue
(
)
;
}
if
(
this
.
.
has
(
)
)
{
return
this
.
.
get
(
)
;
}
const
=
.
substr
(
.
.
)
;
const
=
this
.
.
getValue
(
)
;
let
:
any
=
undefined
;
switch
(
typeof
)
{
case
'number'
:
case
'boolean'
:
case
'string'
:
=
;
break
;
default
:
if
(
Array
.
isArray
(
)
)
{
=
JSON
.
stringify
(
)
;
}
else
{
=
;
}
}
this
.
.
set
(
,
)
;
return
;
}
setValue
(
:
string
,
:
any
)
:
boolean
{
return
super
.
setValue
(
,
)
;
}
removeValue
(
:
string
)
:
boolean
{
return
super
.
removeValue
(
)
;
}
collectAllValues
(
)
:
{
[
:
string
]
:
any
}
{
const
:
{
[
:
string
]
:
any
}
=
.
create
(
null
)
;
this
.
.
forEach
(
(
,
)
=>
[
]
=
)
;
return
{
...
,
...
super
.
collectAllValues
(
)
}
;
}
}
class
ContextKey< T extends ContextKeyValue>
implements
IContextKey< T >
{
private
:
;
private
:
string
;
private
:
T
|
undefined
;
constructor
(
:
,
:
string
,
:
T
|
undefined
)
{
this
.
=
;
this
.
=
;
this
.
=
;
this
.
reset
(
)
;
}
public
set
(
:
T
)
:
void
{
this
.
.
setContext
(
this
.
,
)
;
}
public
reset
(
)
:
void
{
if
(
typeof
this
.
===
'undefined'
)
{
this
.
.
removeContext
(
this
.
)
;
}
else
{
this
.
.
setContext
(
this
.
,
this
.
)
;
}
}
public
get
(
)
:
T
|
undefined
{
return
this
.
.
getContextKeyValue < T >
(
this
.
)
;
}
}
class
SimpleContextKeyChangeEvent
implements
IContextKeyChangeEvent
{
constructor
(
readonly
:
string
)
{
}
affectsSome
(
:
<
string
>
)
:
boolean
{
return
.
has
(
this
.
)
;
}
allKeysContainedIn
(
:
<
string
>
)
:
boolean
{
return
this
.
affectsSome
(
)
;
}
}
class
ArrayContextKeyChangeEvent
implements
IContextKeyChangeEvent
{
constructor
(
readonly
:
string
[
]
)
{
}
affectsSome
(
:
<
string
>
)
:
boolean
{
for
(
const
of
this
.
)
{
if
(
.
has
(
)
)
{
return
true
;
}
}
return
false
;
}
allKeysContainedIn
(
:
<
string
>
)
:
boolean
{
return
this
.
.
every
(
=>
.
has
(
)
)
;
}
}
class
CompositeContextKeyChangeEvent
implements
IContextKeyChangeEvent
{
constructor
(
readonly
:
[
]
)
{
}
affectsSome
(
:
<
string
>
)
:
boolean
{
for
(
const
of
this
.
)
{
if
(
.
affectsSome
(
)
)
{
return
true
;
}
}
return
false
;
}
allKeysContainedIn
(
:
<
string
>
)
:
boolean
{
return
this
.
.
every
(
=>
.
allKeysContainedIn
(
)
)
;
}
}
function
allEventKeysInContext
(
:
,
:
<
string
,
any
>
)
:
boolean
{
return
.
allKeysContainedIn
(
new
Set
(
.
keys
(
)
)
)
;
}
export
abstract
class
AbstractContextKeyService
extends
Disposable
implements
IContextKeyService
{
declare
:
undefined
;
protected
:
boolean
;
protected
:
number
;
protected
=
this
.
_register
(
new
PauseableEmitter< IContextKeyChangeEvent>
(
{
merge
:
=>
new
CompositeContextKeyChangeEvent
(
)
}
)
)
;
get
onDidChangeContext
(
)
{
return
this
.
.
;
}
constructor
(
:
number
)
{
super
(
)
;
this
.
=
false
;
this
.
=
;
}
public
get
contextId
(
)
:
number
{
return
this
.
;
}
public
createKey < T extends ContextKeyValue>
(
:
string
,
:
T
|
undefined
)
:
<
T
>
{
if
(
this
.
)
{
throw
new
Error
(
` AbstractContextKeyService has been disposed `
)
;
}
return
new
ContextKey
(
this
,
,
)
;
}
bufferChangeEvents
(
:
Function
)
:
void
{
this
.
.
pause
(
)
;
try
{
callback
(
)
;
}
finally
{
this
.
.
resume
(
)
;
}
}
public
createScoped
(
:
)
:
{
if
(
this
.
)
{
throw
new
Error
(
` AbstractContextKeyService has been disposed `
)
;
}
return
new
ScopedContextKeyService
(
this
,
)
;
}
createOverlay
(
:
<
[
string
,
any
]
>
=
.
empty
(
)
)
:
{
if
(
this
.
)
{
throw
new
Error
(
` AbstractContextKeyService has been disposed `
)
;
}
return
new
OverlayContextKeyService
(
this
,
)
;
}
public
contextMatchesRules
(
:
|
undefined
)
:
boolean
{
if
(
this
.
)
{
throw
new
Error
(
` AbstractContextKeyService has been disposed `
)
;
}
const
=
this
.
getContextValuesContainer
(
this
.
)
;
const
=
(
?
.
evaluate
(
)
:
true
)
;
return
;
}
public
getContextKeyValue < T >
(
:
string
)
:
T
|
undefined
{
if
(
this
.
)
{
return
undefined
;
}
return
this
.
getContextValuesContainer
(
this
.
)
.
getValue < T >
(
)
;
}
public
setContext
(
:
string
,
:
any
)
:
void
{
if
(
this
.
)
{
return
;
}
const
=
this
.
getContextValuesContainer
(
this
.
)
;
if
(
!
)
{
return
;
}
if
(
.
setValue
(
,
)
)
{
this
.
.
fire
(
new
SimpleContextKeyChangeEvent
(
)
)
;
}
}
public
removeContext
(
:
string
)
:
void
{
if
(
this
.
)
{
return
;
}
if
(
this
.
getContextValuesContainer
(
this
.
)
.
removeValue
(
)
)
{
this
.
.
fire
(
new
SimpleContextKeyChangeEvent
(
)
)
;
}
}
public
getContext
(
:
|
null
)
:
{
if
(
this
.
)
{
return
.
INSTANCE
;
}
return
this
.
getContextValuesContainer
(
findContextAttr
(
)
)
;
}
public
abstract
getContextValuesContainer
(
:
number
)
:
;
public
abstract
createChildContext
(
?
:
number
)
:
number
;
public
abstract
disposeContext
(
:
number
)
:
void
;
public
abstract
updateParent
(
?
:
)
:
void
;
public
dispose
(
)
:
void
{
super
.
dispose
(
)
;
this
.
=
true
;
}
}
export
class
ContextKeyService
extends
AbstractContextKeyService
implements
IContextKeyService
{
private
:
number
;
private
readonly
=
new
Map< number , Context>
(
)
;
private
:
<
boolean
>
;
constructor
(
@ IConfigurationService
:
)
{
super
(
0
)
;
this
.
=
0
;
this
.
=
.
bindTo
(
this
)
;
const
=
this
.
_register
(
new
ConfigAwareContextValuesContainer
(
this
.
,
,
this
.
)
)
;
this
.
.
set
(
this
.
,
)
;
this
.
_register
(
.
runAndSubscribe
(
,
(
{
,
}
)
=>
{
const
=
.
add
(
new
MutableDisposable< DisposableStore>
(
)
)
;
.
add
(
addDisposableListener
(
,
.
FOCUS_IN
,
(
)
=>
{
.
=
new
DisposableStore
(
)
;
this
.
updateInputContextKeys
(
.
,
.
)
;
}
,
true
)
)
;
}
,
{
:
,
:
this
.
}
)
)
;
}
private
updateInputContextKeys
(
:
,
:
)
:
void
{
function
activeElementIsInput
(
)
:
boolean
{
return
!
!
.
&&
isEditableElement
(
.
)
;
}
const
=
activeElementIsInput
(
)
;
this
.
.
set
(
)
;
if
(
)
{
const
=
.
add
(
trackFocus
(
.
as
)
)
;
.
once
(
.
)
(
(
)
=>
{
if
(
getActiveWindow
(
)
.
===
)
{
this
.
.
set
(
activeElementIsInput
(
)
)
;
}
.
dispose
(
)
;
}
,
undefined
,
)
;
}
}
public
getContextValuesContainer
(
:
number
)
:
{
if
(
this
.
)
{
return
.
INSTANCE
;
}
return
this
.
.
get
(
)
||
.
INSTANCE
;
}
public
createChildContext
(
:
number
=
this
.
)
:
number
{
if
(
this
.
)
{
throw
new
Error
(
` ContextKeyService has been disposed `
)
;
}
const
=
(
++
this
.
)
;
this
.
.
set
(
,
new
Context
(
,
this
.
getContextValuesContainer
(
)
)
)
;
return
;
}
public
disposeContext
(
:
number
)
:
void
{
if
(
!
this
.
)
{
this
.
.
delete
(
)
;
}
}
public
updateParent
(
:
)
:
void
{
throw
new
Error
(
'Cannot update parent of root ContextKeyService'
)
;
}
}
class
ScopedContextKeyService
extends
AbstractContextKeyService
{
private
:
;
private
:
;
private
readonly
=
this
.
_register
(
new
MutableDisposable
(
)
)
;
constructor
(
:
,
:
)
{
super
(
.
createChildContext
(
)
)
;
this
.
=
;
this
.
_updateParentChangeListener
(
)
;
this
.
=
;
if
(
this
.
.
hasAttribute
(
KEYBINDING_CONTEXT_ATTR
)
)
{
let
=
''
;
if
(
(
this
.
as
)
.
)
{
=
Array
.
from
(
(
this
.
as
)
.
.
values
(
)
)
.
join
(
', '
)
;
}
console
.
error
(
` Element already has context attribute ${ extraInfo ? ': ' + extraInfo : '' } `
)
;
}
this
.
.
setAttribute
(
KEYBINDING_CONTEXT_ATTR
,
String
(
this
.
)
)
;
}
private
_updateParentChangeListener
(
)
:
void
{
this
.
.
=
this
.
.
onDidChangeContext
(
=>
{
const
=
this
.
.
getContextValuesContainer
(
this
.
)
;
const
=
.
;
if
(
!
allEventKeysInContext
(
,
)
)
{
this
.
.
fire
(
)
;
}
}
)
;
}
public
dispose
(
)
:
void
{
if
(
this
.
)
{
return
;
}
this
.
.
clear
(
)
;
this
.
.
disposeContext
(
this
.
)
;
this
.
.
removeAttribute
(
KEYBINDING_CONTEXT_ATTR
)
;
super
.
dispose
(
)
;
}
public
getContextValuesContainer
(
:
number
)
:
{
if
(
this
.
)
{
return
.
INSTANCE
;
}
return
this
.
.
getContextValuesContainer
(
)
;
}
public
createChildContext
(
:
number
=
this
.
)
:
number
{
if
(
this
.
)
{
throw
new
Error
(
` ScopedContextKeyService has been disposed `
)
;
}
return
this
.
.
createChildContext
(
)
;
}
public
disposeContext
(
:
number
)
:
void
{
this
.
.
disposeContext
(
)
;
}
public
updateParent
(
:
)
:
void
{
if
(
this
.
===
)
{
return
;
}
const
=
this
.
.
getContextValuesContainer
(
this
.
)
;
const
=
.
collectAllValues
(
)
;
this
.
=
;
this
.
_updateParentChangeListener
(
)
;
const
=
this
.
.
getContextValuesContainer
(
this
.
.
)
;
.
updateParent
(
)
;
const
=
.
collectAllValues
(
)
;
const
=
{
...
distinct
(
,
)
,
...
distinct
(
,
)
}
;
const
=
.
keys
(
)
;
this
.
.
fire
(
new
ArrayContextKeyChangeEvent
(
)
)
;
}
}
class
OverlayContext
implements
IContext
{
constructor
(
private
:
,
private
:
<
string
,
any
>
)
{
}
getValue < T extends ContextKeyValue>
(
:
string
)
:
T
|
undefined
{
return
this
.
.
has
(
)
?
this
.
.
get
(
)
:
this
.
.
getValue < T >
(
)
;
}
}
class
OverlayContextKeyService
implements
IContextKeyService
{
declare
:
undefined
;
private
:
<
string
,
any
>
;
get
contextId
(
)
:
number
{
return
this
.
.
;
}
get
onDidChangeContext
(
)
:
<
>
{
return
this
.
.
;
}
constructor
(
private
:
|
,
:
<
[
string
,
any
]
>
)
{
this
.
=
new
Map
(
)
;
}
bufferChangeEvents
(
:
Function
)
:
void
{
this
.
.
bufferChangeEvents
(
)
;
}
createKey < T extends ContextKeyValue>
(
)
:
<
T
>
{
throw
new
Error
(
'Not supported.'
)
;
}
getContext
(
:
|
null
)
:
{
return
new
OverlayContext
(
this
.
.
getContext
(
)
,
this
.
)
;
}
getContextValuesContainer
(
:
number
)
:
{
const
=
this
.
.
getContextValuesContainer
(
)
;
return
new
OverlayContext
(
,
this
.
)
;
}
contextMatchesRules
(
:
|
undefined
)
:
boolean
{
const
=
this
.
getContextValuesContainer
(
this
.
)
;
const
=
(
?
.
evaluate
(
)
:
true
)
;
return
;
}
getContextKeyValue < T >
(
:
string
)
:
T
|
undefined
{
return
this
.
.
has
(
)
?
this
.
.
get
(
)
:
this
.
.
getContextKeyValue
(
)
;
}
createScoped
(
)
:
{
throw
new
Error
(
'Not supported.'
)
;
}
createOverlay
(
:
<
[
string
,
any
]
>
=
.
empty
(
)
)
:
{
return
new
OverlayContextKeyService
(
this
,
)
;
}
updateParent
(
)
:
void
{
throw
new
Error
(
'Not supported.'
)
;
}
}
function
findContextAttr
(
:
|
null
)
:
number
{
while
(
)
{
if
(
.
hasAttribute
(
KEYBINDING_CONTEXT_ATTR
)
)
{
const
=
.
getAttribute
(
KEYBINDING_CONTEXT_ATTR
)
;
if
(
)
{
return
parseInt
(
,
10
)
;
}
return
NaN
;
}
=
.
;
}
return
0
;
}
export
function
setContext
(
:
,
:
any
,
:
any
)
{
const
=
.
get
(
)
;
.
createKey
(
String
(
)
,
stringifyURIs
(
)
)
;
}
function
stringifyURIs
(
:
any
)
:
any
{
return
cloneAndChange
(
,
(
)
=>
{
if
(
typeof
===
'object'
&&
(
<
>
)
.
===
.
)
{
return
URI
.
revive
(
)
.
toString
(
)
;
}
if
(
instanceof
URI
)
{
return
.
toString
(
)
;
}
return
undefined
;
}
)
;
}
.
registerCommand
(
'_setContext'
,
)
;
.
registerCommand
(
{
:
'getContextKeyInfo'
,
handler
(
)
{
return
[
...
.
all
(
)
]
.
sort
(
(
,
)
=>
.
.
localeCompare
(
.
)
)
;
}
,
:
{
:
localize
(
'getContextKeyInfo'
,
"A command that returns information about context keys"
)
,
:
[
]
}
}
)
;
.
registerCommand
(
'_generateContextKeyInfo'
,
function
(
)
{
const
:
[
]
=
[
]
;
const
=
new
Set< string >
(
)
;
for
(
const
of
.
all
(
)
)
{
if
(
!
.
has
(
.
)
)
{
.
add
(
.
)
;
.
push
(
)
;
}
}
.
sort
(
(
,
)
=>
.
.
localeCompare
(
.
)
)
;
console
.
log
(
JSON
.
stringify
(
,
undefined
,
2
)
)
;
}
)
;