Skip to content

Commit 0c29fa3

Browse files
committed
Distinguish context key factory from type
1 parent 0cd0f7d commit 0c29fa3

30 files changed

Lines changed: 167 additions & 162 deletions

File tree

src/vs/editor/browser/editorExtensions.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { IModelService } from 'vs/editor/common/services/modelService';
1515
import { ITextModelService } from 'vs/editor/common/services/resolverService';
1616
import { MenuId, MenuRegistry } from 'vs/platform/actions/common/actions';
1717
import { CommandsRegistry, ICommandHandlerDescription } from 'vs/platform/commands/common/commands';
18-
import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
18+
import { ContextKeyExpr, IContextKeyService, ContextKeyExpression } from 'vs/platform/contextkey/common/contextkey';
1919
import { IConstructorSignature1, ServicesAccessor as InstantiationServicesAccessor, BrandedService } from 'vs/platform/instantiation/common/instantiation';
2020
import { IKeybindings, KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
2121
import { Registry } from 'vs/platform/registry/common/platform';
@@ -39,26 +39,26 @@ export interface IDiffEditorContributionDescription {
3939
//#region Command
4040

4141
export interface ICommandKeybindingsOptions extends IKeybindings {
42-
kbExpr?: ContextKeyExpr | null;
42+
kbExpr?: ContextKeyExpression | null;
4343
weight: number;
4444
}
4545
export interface ICommandMenuOptions {
4646
menuId: MenuId;
4747
group: string;
4848
order: number;
49-
when?: ContextKeyExpr;
49+
when?: ContextKeyExpression;
5050
title: string;
5151
}
5252
export interface ICommandOptions {
5353
id: string;
54-
precondition: ContextKeyExpr | undefined;
54+
precondition: ContextKeyExpression | undefined;
5555
kbOpts?: ICommandKeybindingsOptions;
5656
description?: ICommandHandlerDescription;
5757
menuOpts?: ICommandMenuOptions | ICommandMenuOptions[];
5858
}
5959
export abstract class Command {
6060
public readonly id: string;
61-
public readonly precondition: ContextKeyExpr | undefined;
61+
public readonly precondition: ContextKeyExpression | undefined;
6262
private readonly _kbOpts: ICommandKeybindingsOptions | undefined;
6363
private readonly _menuOpts: ICommandMenuOptions | ICommandMenuOptions[] | undefined;
6464
private readonly _description: ICommandHandlerDescription | undefined;
@@ -193,7 +193,7 @@ export abstract class EditorCommand extends Command {
193193
export interface IEditorActionContextMenuOptions {
194194
group: string;
195195
order: number;
196-
when?: ContextKeyExpr;
196+
when?: ContextKeyExpression;
197197
menuId?: MenuId;
198198
}
199199
export interface IActionOptions extends ICommandOptions {

src/vs/editor/common/editorAction.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { IEditorAction } from 'vs/editor/common/editorCommon';
7-
import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
7+
import { IContextKeyService, ContextKeyExpression } from 'vs/platform/contextkey/common/contextkey';
88

99
export class InternalEditorAction implements IEditorAction {
1010

1111
public readonly id: string;
1212
public readonly label: string;
1313
public readonly alias: string;
1414

15-
private readonly _precondition: ContextKeyExpr | undefined;
15+
private readonly _precondition: ContextKeyExpression | undefined;
1616
private readonly _run: () => Promise<void>;
1717
private readonly _contextKeyService: IContextKeyService;
1818

1919
constructor(
2020
id: string,
2121
label: string,
2222
alias: string,
23-
precondition: ContextKeyExpr | undefined,
23+
precondition: ContextKeyExpression | undefined,
2424
run: () => Promise<void>,
2525
contextKeyService: IContextKeyService
2626
) {

src/vs/editor/common/editorContextKeys.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { ContextKeyExpr, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
6+
import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
77

88
export namespace EditorContextKeys {
99

@@ -24,13 +24,13 @@ export namespace EditorContextKeys {
2424

2525
export const readOnly = new RawContextKey<boolean>('editorReadonly', false);
2626
export const columnSelection = new RawContextKey<boolean>('editorColumnSelection', false);
27-
export const writable: ContextKeyExpr = readOnly.toNegated();
27+
export const writable = readOnly.toNegated();
2828
export const hasNonEmptySelection = new RawContextKey<boolean>('editorHasSelection', false);
29-
export const hasOnlyEmptySelection: ContextKeyExpr = hasNonEmptySelection.toNegated();
29+
export const hasOnlyEmptySelection = hasNonEmptySelection.toNegated();
3030
export const hasMultipleSelections = new RawContextKey<boolean>('editorHasMultipleSelections', false);
31-
export const hasSingleSelection: ContextKeyExpr = hasMultipleSelections.toNegated();
31+
export const hasSingleSelection = hasMultipleSelections.toNegated();
3232
export const tabMovesFocus = new RawContextKey<boolean>('editorTabMovesFocus', false);
33-
export const tabDoesNotMoveFocus: ContextKeyExpr = tabMovesFocus.toNegated();
33+
export const tabDoesNotMoveFocus = tabMovesFocus.toNegated();
3434
export const isInEmbeddedEditor = new RawContextKey<boolean>('isInEmbeddedEditor', false);
3535
export const canUndo = new RawContextKey<boolean>('canUndo', false);
3636
export const canRedo = new RawContextKey<boolean>('canRedo', false);

src/vs/editor/contrib/find/findModel.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ import { FindDecorations } from 'vs/editor/contrib/find/findDecorations';
2020
import { FindReplaceState, FindReplaceStateChangedEvent } from 'vs/editor/contrib/find/findState';
2121
import { ReplaceAllCommand } from 'vs/editor/contrib/find/replaceAllCommand';
2222
import { ReplacePattern, parseReplaceString } from 'vs/editor/contrib/find/replacePattern';
23-
import { ContextKeyExpr, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
23+
import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
2424
import { IKeybindings } from 'vs/platform/keybinding/common/keybindingsRegistry';
2525
import { EditorOption } from 'vs/editor/common/config/editorOptions';
2626

2727
export const CONTEXT_FIND_WIDGET_VISIBLE = new RawContextKey<boolean>('findWidgetVisible', false);
28-
export const CONTEXT_FIND_WIDGET_NOT_VISIBLE: ContextKeyExpr = CONTEXT_FIND_WIDGET_VISIBLE.toNegated();
28+
export const CONTEXT_FIND_WIDGET_NOT_VISIBLE = CONTEXT_FIND_WIDGET_VISIBLE.toNegated();
2929
// Keep ContextKey use of 'Focussed' to not break when clauses
3030
export const CONTEXT_FIND_INPUT_FOCUSED = new RawContextKey<boolean>('findInputFocussed', false);
3131
export const CONTEXT_REPLACE_INPUT_FOCUSED = new RawContextKey<boolean>('replaceInputFocussed', false);

src/vs/editor/contrib/peekView/peekView.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService
1717
import { EmbeddedCodeEditorWidget } from 'vs/editor/browser/widget/embeddedCodeEditorWidget';
1818
import { IOptions, IStyles, ZoneWidget } from 'vs/editor/contrib/zoneWidget/zoneWidget';
1919
import * as nls from 'vs/nls';
20-
import { ContextKeyExpr, RawContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
20+
import { RawContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
2121
import { ServicesAccessor, createDecorator } from 'vs/platform/instantiation/common/instantiation';
2222
import { IDisposable } from 'vs/base/common/lifecycle';
2323
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
@@ -57,7 +57,7 @@ registerSingleton(IPeekViewService, class implements IPeekViewService {
5757

5858
export namespace PeekContext {
5959
export const inPeekEditor = new RawContextKey<boolean>('inReferenceSearchEditor', true);
60-
export const notInPeekEditor: ContextKeyExpr = inPeekEditor.toNegated();
60+
export const notInPeekEditor = inPeekEditor.toNegated();
6161
}
6262

6363
class PeekContextController implements IEditorContribution {

src/vs/editor/standalone/browser/simpleServices.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { ITextResourceConfigurationService, ITextResourcePropertiesService, ITex
2727
import { CommandsRegistry, ICommand, ICommandEvent, ICommandHandler, ICommandService } from 'vs/platform/commands/common/commands';
2828
import { IConfigurationChangeEvent, IConfigurationData, IConfigurationOverrides, IConfigurationService, IConfigurationModel, IConfigurationValue, ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
2929
import { Configuration, ConfigurationModel, DefaultConfigurationModel, ConfigurationChangeEvent } from 'vs/platform/configuration/common/configurationModels';
30-
import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
30+
import { IContextKeyService, ContextKeyExpression } from 'vs/platform/contextkey/common/contextkey';
3131
import { IConfirmation, IConfirmationResult, IDialogOptions, IDialogService, IShowResult } from 'vs/platform/dialogs/common/dialogs';
3232
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
3333
import { AbstractKeybindingService } from 'vs/platform/keybinding/common/abstractKeybindingService';
@@ -318,7 +318,7 @@ export class StandaloneKeybindingService extends AbstractKeybindingService {
318318
}));
319319
}
320320

321-
public addDynamicKeybinding(commandId: string, _keybinding: number, handler: ICommandHandler, when: ContextKeyExpr | undefined): IDisposable {
321+
public addDynamicKeybinding(commandId: string, _keybinding: number, handler: ICommandHandler, when: ContextKeyExpression | undefined): IDisposable {
322322
const keybinding = createKeybinding(_keybinding, OS);
323323

324324
const toDispose = new DisposableStore();

src/vs/platform/actions/common/actions.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Action } from 'vs/base/common/actions';
77
import { SyncDescriptor0, createSyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
88
import { IConstructorSignature2, createDecorator, BrandedService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
99
import { IKeybindings, KeybindingsRegistry, IKeybindingRule } from 'vs/platform/keybinding/common/keybindingsRegistry';
10-
import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
10+
import { ContextKeyExpr, IContextKeyService, ContextKeyExpression } from 'vs/platform/contextkey/common/contextkey';
1111
import { ICommandService, CommandsRegistry, ICommandHandlerDescription } from 'vs/platform/commands/common/commands';
1212
import { IDisposable, DisposableStore } from 'vs/base/common/lifecycle';
1313
import { Event, Emitter } from 'vs/base/common/event';
@@ -25,24 +25,24 @@ export interface ICommandAction {
2525
title: string | ILocalizedString;
2626
category?: string | ILocalizedString;
2727
icon?: { dark?: URI; light?: URI; } | ThemeIcon;
28-
precondition?: ContextKeyExpr;
29-
toggled?: ContextKeyExpr;
28+
precondition?: ContextKeyExpression;
29+
toggled?: ContextKeyExpression;
3030
}
3131

3232
export type ISerializableCommandAction = UriDto<ICommandAction>;
3333

3434
export interface IMenuItem {
3535
command: ICommandAction;
3636
alt?: ICommandAction;
37-
when?: ContextKeyExpr;
37+
when?: ContextKeyExpression;
3838
group?: 'navigation' | string;
3939
order?: number;
4040
}
4141

4242
export interface ISubmenuItem {
4343
title: string | ILocalizedString;
4444
submenu: MenuId;
45-
when?: ContextKeyExpr;
45+
when?: ContextKeyExpression;
4646
group?: 'navigation' | string;
4747
order?: number;
4848
}
@@ -314,17 +314,17 @@ export class SyncActionDescriptor {
314314
private readonly _id: string;
315315
private readonly _label?: string;
316316
private readonly _keybindings: IKeybindings | undefined;
317-
private readonly _keybindingContext: ContextKeyExpr | undefined;
317+
private readonly _keybindingContext: ContextKeyExpression | undefined;
318318
private readonly _keybindingWeight: number | undefined;
319319

320320
public static create<Services extends BrandedService[]>(ctor: { new(id: string, label: string, ...services: Services): Action },
321-
id: string, label: string | undefined, keybindings?: IKeybindings, keybindingContext?: ContextKeyExpr, keybindingWeight?: number
321+
id: string, label: string | undefined, keybindings?: IKeybindings, keybindingContext?: ContextKeyExpression, keybindingWeight?: number
322322
): SyncActionDescriptor {
323323
return new SyncActionDescriptor(ctor as IConstructorSignature2<string, string | undefined, Action>, id, label, keybindings, keybindingContext, keybindingWeight);
324324
}
325325

326326
private constructor(ctor: IConstructorSignature2<string, string | undefined, Action>,
327-
id: string, label: string | undefined, keybindings?: IKeybindings, keybindingContext?: ContextKeyExpr, keybindingWeight?: number
327+
id: string, label: string | undefined, keybindings?: IKeybindings, keybindingContext?: ContextKeyExpression, keybindingWeight?: number
328328
) {
329329
this._id = id;
330330
this._label = label;
@@ -350,7 +350,7 @@ export class SyncActionDescriptor {
350350
return this._keybindings;
351351
}
352352

353-
public get keybindingContext(): ContextKeyExpr | undefined {
353+
public get keybindingContext(): ContextKeyExpression | undefined {
354354
return this._keybindingContext;
355355
}
356356

src/vs/platform/contextkey/browser/contextKeyService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { IDisposable, DisposableStore } from 'vs/base/common/lifecycle';
88
import { keys } from 'vs/base/common/map';
99
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
1010
import { ConfigurationTarget, IConfigurationService } from 'vs/platform/configuration/common/configuration';
11-
import { ContextKeyExpr, IContext, IContextKey, IContextKeyChangeEvent, IContextKeyService, IContextKeyServiceTarget, IReadableSet, SET_CONTEXT_COMMAND_ID } from 'vs/platform/contextkey/common/contextkey';
11+
import { IContext, IContextKey, IContextKeyChangeEvent, IContextKeyService, IContextKeyServiceTarget, IReadableSet, SET_CONTEXT_COMMAND_ID, ContextKeyExpression } from 'vs/platform/contextkey/common/contextkey';
1212
import { KeybindingResolver } from 'vs/platform/keybinding/common/keybindingResolver';
1313

1414
const KEYBINDING_CONTEXT_ATTR = 'data-keybinding-context';
@@ -265,7 +265,7 @@ export abstract class AbstractContextKeyService implements IContextKeyService {
265265
return new ScopedContextKeyService(this, domNode);
266266
}
267267

268-
public contextMatchesRules(rules: ContextKeyExpr | undefined): boolean {
268+
public contextMatchesRules(rules: ContextKeyExpression | undefined): boolean {
269269
if (this._isDisposed) {
270270
throw new Error(`AbstractContextKeyService has been disposed`);
271271
}

0 commit comments

Comments
 (0)