mockKeybindingService.ts ×37

Frontier kind: Code frontier

unlabeled · c_84659548e027

539 tests · 8241 LOC · 41 files · introduces 0 tests · 91 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
37 ranges91 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1198 ranges8241 lines · 41 files · Browse complete extent
All tests (intent)
539 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: 91 introduced LOC across 37 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/keybinding/test/common/mockKeybindingService.ts 91 introduced LOC · 37 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- mockKeybindingService.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 { Event } from '../../../../base/common/event.js';
7 > import { KeyCodeChord, Keybinding, ResolvedKeybinding } from '../../../../base/common/keybindings.js';
8 > import { Disposable } from '../../../../base/common/lifecycle.js';
9 > import { OS } from '../../../../base/common/platform.js';
10 > import { ContextKeyExpression, ContextKeyValue, IContextKey, IContextKeyChangeEvent, IContextKeyService, IContextKeyServiceTarget, IScopedContextKeyService } from '../../../contextkey/common/contextkey.js';
11 > import { IKeybindingService, IKeyboardEvent } from '../../common/keybinding.js';
12 > import { NoMatchingKb, ResolutionResult } from '../../common/keybindingResolver.js';
13 > import { ResolvedKeybindingItem } from '../../common/resolvedKeybindingItem.js';
14 > import { USLayoutResolvedKeybinding } from '../../common/usLayoutResolvedKeybinding.js';
15 >
16 > class MockKeybindingContextKey<T extends ContextKeyValue = ContextKeyValue> implements IContextKey<T> {
17 > private _defaultValue: T | undefined;
18 > private _value: T | undefined;
19 >
20 > constructor(defaultValue: T | undefined) {
21 this._defaultValue = defaultValue;
22 this._value = this._defaultValue;
23 }
25 > public set(value: T | undefined): void {
26 this._value = value;
27 }
29 > public reset(): void {
30 this._value = this._defaultValue;
31 }
33 > public get(): T | undefined {
34 return this._value;
35 }
37 >
38 > export class MockContextKeyService implements IContextKeyService {
39
40 public _serviceBrand: undefined;
41 private _keys = new Map<string, IContextKey<any>>();
43 > public dispose(): void {
44 //
45 }
46 > public createKey<T extends ContextKeyValue = ContextKeyValue>(key: string, defaultValue: T | undefined): IContextKey<T> { mockKeybindingService.ts
47 const ret = new MockKeybindingContextKey(defaultValue);
48 this._keys.set(key, ret);
49 return ret;
50 }
51 > public contextMatchesRules(rules: ContextKeyExpression): boolean { mockKeybindingService.ts
52 return false;
53 }
54 > public get onDidChangeContext(): Event<IContextKeyChangeEvent> { mockKeybindingService.ts
55 return Event.None;
56 }
57 > public bufferChangeEvents(callback: () => void) { callback(); } mockKeybindingService.ts
58 > public getContextKeyValue(key: string) {
59 const value = this._keys.get(key);
60 if (value) {
62 }
63 }
64 > public getContext(domNode: HTMLElement): any { mockKeybindingService.ts
65 return null;
66 }
67 > public createScoped(domNode: HTMLElement): IScopedContextKeyService { mockKeybindingService.ts
68 return this;
69 }
70 > public createOverlay(): IContextKeyService { mockKeybindingService.ts
71 return this;
72 }
73 > updateParent(_parentContextKeyService: IContextKeyService): void { mockKeybindingService.ts
74 // no-op
75 }
77 >
78 > export class MockScopableContextKeyService extends MockContextKeyService {
79 > /**
80 > * Don't implement this for all tests since we rarely depend on this behavior and it isn't implemented fully
81 > */
82 > public override createScoped(domNote: HTMLElement): IScopedContextKeyService {
83 return new MockScopableContextKeyService();
84 }
86 >
87 > export class MockKeybindingService implements IKeybindingService {
88 public _serviceBrand: undefined;
89
90 public readonly inChordMode: boolean = false;
92 > public get onDidUpdateKeybindings(): Event<void> {
93 return Event.None;
94 }
96 > public getDefaultKeybindingsContent(): string {
97 return '';
98 }
100 > public getDefaultKeybindings(): ResolvedKeybindingItem[] {
101 return [];
102 }
104 > public getKeybindings(): ResolvedKeybindingItem[] {
105 return [];
106 }
108 > public resolveKeybinding(keybinding: Keybinding): ResolvedKeybinding[] {
109 return USLayoutResolvedKeybinding.resolveKeybinding(keybinding, OS);
110 }
112 > public resolveKeyboardEvent(keyboardEvent: IKeyboardEvent): ResolvedKeybinding {
113 const chord = new KeyCodeChord(
114 keyboardEvent.ctrlKey,
120 return this.resolveKeybinding(chord.toKeybinding())[0];
121 }
123 > public resolveUserBinding(userBinding: string): ResolvedKeybinding[] {
124 return [];
125 }
127 > public lookupKeybindings(commandId: string): ResolvedKeybinding[] {
128 return [];
129 }
131 > public lookupKeybinding(commandId: string): ResolvedKeybinding | undefined {
132 return undefined;
133 }
135 > public customKeybindingsCount(): number {
136 return 0;
137 }
139 > public softDispatch(keybinding: IKeyboardEvent, target: IContextKeyServiceTarget): ResolutionResult {
140 return NoMatchingKb;
141 }
143 > public dispatchByUserSettingsLabel(userSettingsLabel: string, target: IContextKeyServiceTarget): void {
144
145 }
147 > public dispatchEvent(e: IKeyboardEvent, target: IContextKeyServiceTarget): boolean {
148 return false;
149 }
151 > public enableKeybindingHoldMode(commandId: string): undefined {
152 return undefined;
153 }
155 > public mightProducePrintableCharacter(e: IKeyboardEvent): boolean {
156 return false;
157 }
159 > public toggleLogging(): boolean {
160 return false;
161 }
163 > public _dumpDebugInfo(): string {
164 return '';
165 }
167 > public _dumpDebugInfoJSON(): string {
168 return '';
169 }
171 > public registerSchemaContribution() {
172 return Disposable.None;
173 }
175 > public appendKeybinding(label: string, _commandId: string, _context?: IContextKeyService, _enforceContextCheck?: boolean): string {
176 return label;
177 }