mirror of
https://github.com/Microsoft/vscode
synced 2024-09-19 02:26:04 +00:00
Merge pull request #91766 from microsoft/alex/85058
Special handling for isMax, isWindows, isLinux
This commit is contained in:
commit
53293cbb5d
|
@ -15,7 +15,7 @@ import { IModelService } from 'vs/editor/common/services/modelService';
|
|||
import { ITextModelService } from 'vs/editor/common/services/resolverService';
|
||||
import { MenuId, MenuRegistry } from 'vs/platform/actions/common/actions';
|
||||
import { CommandsRegistry, ICommandHandlerDescription } from 'vs/platform/commands/common/commands';
|
||||
import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ContextKeyExpr, IContextKeyService, ContextKeyExpression } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IConstructorSignature1, ServicesAccessor as InstantiationServicesAccessor, BrandedService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IKeybindings, KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
|
@ -39,26 +39,26 @@ export interface IDiffEditorContributionDescription {
|
|||
//#region Command
|
||||
|
||||
export interface ICommandKeybindingsOptions extends IKeybindings {
|
||||
kbExpr?: ContextKeyExpr | null;
|
||||
kbExpr?: ContextKeyExpression | null;
|
||||
weight: number;
|
||||
}
|
||||
export interface ICommandMenuOptions {
|
||||
menuId: MenuId;
|
||||
group: string;
|
||||
order: number;
|
||||
when?: ContextKeyExpr;
|
||||
when?: ContextKeyExpression;
|
||||
title: string;
|
||||
}
|
||||
export interface ICommandOptions {
|
||||
id: string;
|
||||
precondition: ContextKeyExpr | undefined;
|
||||
precondition: ContextKeyExpression | undefined;
|
||||
kbOpts?: ICommandKeybindingsOptions;
|
||||
description?: ICommandHandlerDescription;
|
||||
menuOpts?: ICommandMenuOptions | ICommandMenuOptions[];
|
||||
}
|
||||
export abstract class Command {
|
||||
public readonly id: string;
|
||||
public readonly precondition: ContextKeyExpr | undefined;
|
||||
public readonly precondition: ContextKeyExpression | undefined;
|
||||
private readonly _kbOpts: ICommandKeybindingsOptions | undefined;
|
||||
private readonly _menuOpts: ICommandMenuOptions | ICommandMenuOptions[] | undefined;
|
||||
private readonly _description: ICommandHandlerDescription | undefined;
|
||||
|
@ -193,7 +193,7 @@ export abstract class EditorCommand extends Command {
|
|||
export interface IEditorActionContextMenuOptions {
|
||||
group: string;
|
||||
order: number;
|
||||
when?: ContextKeyExpr;
|
||||
when?: ContextKeyExpression;
|
||||
menuId?: MenuId;
|
||||
}
|
||||
export interface IActionOptions extends ICommandOptions {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IEditorAction } from 'vs/editor/common/editorCommon';
|
||||
import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IContextKeyService, ContextKeyExpression } from 'vs/platform/contextkey/common/contextkey';
|
||||
|
||||
export class InternalEditorAction implements IEditorAction {
|
||||
|
||||
|
@ -12,7 +12,7 @@ export class InternalEditorAction implements IEditorAction {
|
|||
public readonly label: string;
|
||||
public readonly alias: string;
|
||||
|
||||
private readonly _precondition: ContextKeyExpr | undefined;
|
||||
private readonly _precondition: ContextKeyExpression | undefined;
|
||||
private readonly _run: () => Promise<void>;
|
||||
private readonly _contextKeyService: IContextKeyService;
|
||||
|
||||
|
@ -20,7 +20,7 @@ export class InternalEditorAction implements IEditorAction {
|
|||
id: string,
|
||||
label: string,
|
||||
alias: string,
|
||||
precondition: ContextKeyExpr | undefined,
|
||||
precondition: ContextKeyExpression | undefined,
|
||||
run: () => Promise<void>,
|
||||
contextKeyService: IContextKeyService
|
||||
) {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ContextKeyExpr, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
|
||||
export namespace EditorContextKeys {
|
||||
|
||||
|
@ -24,13 +24,13 @@ export namespace EditorContextKeys {
|
|||
|
||||
export const readOnly = new RawContextKey<boolean>('editorReadonly', false);
|
||||
export const columnSelection = new RawContextKey<boolean>('editorColumnSelection', false);
|
||||
export const writable: ContextKeyExpr = readOnly.toNegated();
|
||||
export const writable = readOnly.toNegated();
|
||||
export const hasNonEmptySelection = new RawContextKey<boolean>('editorHasSelection', false);
|
||||
export const hasOnlyEmptySelection: ContextKeyExpr = hasNonEmptySelection.toNegated();
|
||||
export const hasOnlyEmptySelection = hasNonEmptySelection.toNegated();
|
||||
export const hasMultipleSelections = new RawContextKey<boolean>('editorHasMultipleSelections', false);
|
||||
export const hasSingleSelection: ContextKeyExpr = hasMultipleSelections.toNegated();
|
||||
export const hasSingleSelection = hasMultipleSelections.toNegated();
|
||||
export const tabMovesFocus = new RawContextKey<boolean>('editorTabMovesFocus', false);
|
||||
export const tabDoesNotMoveFocus: ContextKeyExpr = tabMovesFocus.toNegated();
|
||||
export const tabDoesNotMoveFocus = tabMovesFocus.toNegated();
|
||||
export const isInEmbeddedEditor = new RawContextKey<boolean>('isInEmbeddedEditor', false);
|
||||
export const canUndo = new RawContextKey<boolean>('canUndo', false);
|
||||
export const canRedo = new RawContextKey<boolean>('canRedo', false);
|
||||
|
|
|
@ -20,12 +20,12 @@ import { FindDecorations } from 'vs/editor/contrib/find/findDecorations';
|
|||
import { FindReplaceState, FindReplaceStateChangedEvent } from 'vs/editor/contrib/find/findState';
|
||||
import { ReplaceAllCommand } from 'vs/editor/contrib/find/replaceAllCommand';
|
||||
import { ReplacePattern, parseReplaceString } from 'vs/editor/contrib/find/replacePattern';
|
||||
import { ContextKeyExpr, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IKeybindings } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
export const CONTEXT_FIND_WIDGET_VISIBLE = new RawContextKey<boolean>('findWidgetVisible', false);
|
||||
export const CONTEXT_FIND_WIDGET_NOT_VISIBLE: ContextKeyExpr = CONTEXT_FIND_WIDGET_VISIBLE.toNegated();
|
||||
export const CONTEXT_FIND_WIDGET_NOT_VISIBLE = CONTEXT_FIND_WIDGET_VISIBLE.toNegated();
|
||||
// Keep ContextKey use of 'Focussed' to not break when clauses
|
||||
export const CONTEXT_FIND_INPUT_FOCUSED = new RawContextKey<boolean>('findInputFocussed', false);
|
||||
export const CONTEXT_REPLACE_INPUT_FOCUSED = new RawContextKey<boolean>('replaceInputFocussed', false);
|
||||
|
|
|
@ -17,7 +17,7 @@ import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService
|
|||
import { EmbeddedCodeEditorWidget } from 'vs/editor/browser/widget/embeddedCodeEditorWidget';
|
||||
import { IOptions, IStyles, ZoneWidget } from 'vs/editor/contrib/zoneWidget/zoneWidget';
|
||||
import * as nls from 'vs/nls';
|
||||
import { ContextKeyExpr, RawContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { RawContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ServicesAccessor, createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
|
@ -57,7 +57,7 @@ registerSingleton(IPeekViewService, class implements IPeekViewService {
|
|||
|
||||
export namespace PeekContext {
|
||||
export const inPeekEditor = new RawContextKey<boolean>('inReferenceSearchEditor', true);
|
||||
export const notInPeekEditor: ContextKeyExpr = inPeekEditor.toNegated();
|
||||
export const notInPeekEditor = inPeekEditor.toNegated();
|
||||
}
|
||||
|
||||
class PeekContextController implements IEditorContribution {
|
||||
|
|
|
@ -27,7 +27,7 @@ import { ITextResourceConfigurationService, ITextResourcePropertiesService, ITex
|
|||
import { CommandsRegistry, ICommand, ICommandEvent, ICommandHandler, ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { IConfigurationChangeEvent, IConfigurationData, IConfigurationOverrides, IConfigurationService, IConfigurationModel, IConfigurationValue, ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
|
||||
import { Configuration, ConfigurationModel, DefaultConfigurationModel, ConfigurationChangeEvent } from 'vs/platform/configuration/common/configurationModels';
|
||||
import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IContextKeyService, ContextKeyExpression } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IConfirmation, IConfirmationResult, IDialogOptions, IDialogService, IShowResult } from 'vs/platform/dialogs/common/dialogs';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { AbstractKeybindingService } from 'vs/platform/keybinding/common/abstractKeybindingService';
|
||||
|
@ -318,7 +318,7 @@ export class StandaloneKeybindingService extends AbstractKeybindingService {
|
|||
}));
|
||||
}
|
||||
|
||||
public addDynamicKeybinding(commandId: string, _keybinding: number, handler: ICommandHandler, when: ContextKeyExpr | undefined): IDisposable {
|
||||
public addDynamicKeybinding(commandId: string, _keybinding: number, handler: ICommandHandler, when: ContextKeyExpression | undefined): IDisposable {
|
||||
const keybinding = createKeybinding(_keybinding, OS);
|
||||
|
||||
const toDispose = new DisposableStore();
|
||||
|
|
|
@ -7,7 +7,7 @@ import { Action } from 'vs/base/common/actions';
|
|||
import { SyncDescriptor0, createSyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { IConstructorSignature2, createDecorator, BrandedService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IKeybindings, KeybindingsRegistry, IKeybindingRule } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ContextKeyExpr, IContextKeyService, ContextKeyExpression } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ICommandService, CommandsRegistry, ICommandHandlerDescription } from 'vs/platform/commands/common/commands';
|
||||
import { IDisposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
|
@ -25,8 +25,8 @@ export interface ICommandAction {
|
|||
title: string | ILocalizedString;
|
||||
category?: string | ILocalizedString;
|
||||
icon?: { dark?: URI; light?: URI; } | ThemeIcon;
|
||||
precondition?: ContextKeyExpr;
|
||||
toggled?: ContextKeyExpr;
|
||||
precondition?: ContextKeyExpression;
|
||||
toggled?: ContextKeyExpression;
|
||||
}
|
||||
|
||||
export type ISerializableCommandAction = UriDto<ICommandAction>;
|
||||
|
@ -34,7 +34,7 @@ export type ISerializableCommandAction = UriDto<ICommandAction>;
|
|||
export interface IMenuItem {
|
||||
command: ICommandAction;
|
||||
alt?: ICommandAction;
|
||||
when?: ContextKeyExpr;
|
||||
when?: ContextKeyExpression;
|
||||
group?: 'navigation' | string;
|
||||
order?: number;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ export interface IMenuItem {
|
|||
export interface ISubmenuItem {
|
||||
title: string | ILocalizedString;
|
||||
submenu: MenuId;
|
||||
when?: ContextKeyExpr;
|
||||
when?: ContextKeyExpression;
|
||||
group?: 'navigation' | string;
|
||||
order?: number;
|
||||
}
|
||||
|
@ -314,17 +314,17 @@ export class SyncActionDescriptor {
|
|||
private readonly _id: string;
|
||||
private readonly _label?: string;
|
||||
private readonly _keybindings: IKeybindings | undefined;
|
||||
private readonly _keybindingContext: ContextKeyExpr | undefined;
|
||||
private readonly _keybindingContext: ContextKeyExpression | undefined;
|
||||
private readonly _keybindingWeight: number | undefined;
|
||||
|
||||
public static create<Services extends BrandedService[]>(ctor: { new(id: string, label: string, ...services: Services): Action },
|
||||
id: string, label: string | undefined, keybindings?: IKeybindings, keybindingContext?: ContextKeyExpr, keybindingWeight?: number
|
||||
id: string, label: string | undefined, keybindings?: IKeybindings, keybindingContext?: ContextKeyExpression, keybindingWeight?: number
|
||||
): SyncActionDescriptor {
|
||||
return new SyncActionDescriptor(ctor as IConstructorSignature2<string, string | undefined, Action>, id, label, keybindings, keybindingContext, keybindingWeight);
|
||||
}
|
||||
|
||||
private constructor(ctor: IConstructorSignature2<string, string | undefined, Action>,
|
||||
id: string, label: string | undefined, keybindings?: IKeybindings, keybindingContext?: ContextKeyExpr, keybindingWeight?: number
|
||||
id: string, label: string | undefined, keybindings?: IKeybindings, keybindingContext?: ContextKeyExpression, keybindingWeight?: number
|
||||
) {
|
||||
this._id = id;
|
||||
this._label = label;
|
||||
|
@ -350,7 +350,7 @@ export class SyncActionDescriptor {
|
|||
return this._keybindings;
|
||||
}
|
||||
|
||||
public get keybindingContext(): ContextKeyExpr | undefined {
|
||||
public get keybindingContext(): ContextKeyExpression | undefined {
|
||||
return this._keybindingContext;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import { Emitter, Event } from 'vs/base/common/event';
|
|||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { IMenu, IMenuActionOptions, IMenuItem, IMenuService, isIMenuItem, ISubmenuItem, MenuId, MenuItemAction, MenuRegistry, SubmenuItemAction, ILocalizedString } from 'vs/platform/actions/common/actions';
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { ContextKeyExpr, IContextKeyService, IContextKeyChangeEvent } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IContextKeyService, IContextKeyChangeEvent, ContextKeyExpression } from 'vs/platform/contextkey/common/contextkey';
|
||||
|
||||
export class MenuService implements IMenuService {
|
||||
|
||||
|
@ -125,7 +125,7 @@ class Menu implements IMenu {
|
|||
return result;
|
||||
}
|
||||
|
||||
private static _fillInKbExprKeys(exp: ContextKeyExpr | undefined, set: Set<string>): void {
|
||||
private static _fillInKbExprKeys(exp: ContextKeyExpression | undefined, set: Set<string>): void {
|
||||
if (exp) {
|
||||
for (let key of exp.keys()) {
|
||||
set.add(key);
|
||||
|
|
|
@ -8,7 +8,7 @@ import { IDisposable, DisposableStore } from 'vs/base/common/lifecycle';
|
|||
import { keys } from 'vs/base/common/map';
|
||||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { ConfigurationTarget, IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ContextKeyExpr, IContext, IContextKey, IContextKeyChangeEvent, IContextKeyService, IContextKeyServiceTarget, IReadableSet, SET_CONTEXT_COMMAND_ID } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IContext, IContextKey, IContextKeyChangeEvent, IContextKeyService, IContextKeyServiceTarget, IReadableSet, SET_CONTEXT_COMMAND_ID, ContextKeyExpression } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { KeybindingResolver } from 'vs/platform/keybinding/common/keybindingResolver';
|
||||
|
||||
const KEYBINDING_CONTEXT_ATTR = 'data-keybinding-context';
|
||||
|
@ -265,7 +265,7 @@ export abstract class AbstractContextKeyService implements IContextKeyService {
|
|||
return new ScopedContextKeyService(this, domNode);
|
||||
}
|
||||
|
||||
public contextMatchesRules(rules: ContextKeyExpr | undefined): boolean {
|
||||
public contextMatchesRules(rules: ContextKeyExpression | undefined): boolean {
|
||||
if (this._isDisposed) {
|
||||
throw new Error(`AbstractContextKeyService has been disposed`);
|
||||
}
|
||||
|
|
|
@ -6,57 +6,92 @@
|
|||
import { Event } from 'vs/base/common/event';
|
||||
import { isFalsyOrWhitespace } from 'vs/base/common/strings';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { isMacintosh, isLinux, isWindows } from 'vs/base/common/platform';
|
||||
|
||||
const STATIC_VALUES = new Map<string, boolean>();
|
||||
STATIC_VALUES.set('false', false);
|
||||
STATIC_VALUES.set('true', true);
|
||||
STATIC_VALUES.set('isMac', isMacintosh);
|
||||
STATIC_VALUES.set('isLinux', isLinux);
|
||||
STATIC_VALUES.set('isWindows', isWindows);
|
||||
|
||||
export const enum ContextKeyExprType {
|
||||
Defined = 1,
|
||||
Not = 2,
|
||||
Equals = 3,
|
||||
NotEquals = 4,
|
||||
And = 5,
|
||||
Regex = 6,
|
||||
NotRegex = 7,
|
||||
Or = 8
|
||||
False = 0,
|
||||
True = 1,
|
||||
Defined = 2,
|
||||
Not = 3,
|
||||
Equals = 4,
|
||||
NotEquals = 5,
|
||||
And = 6,
|
||||
Regex = 7,
|
||||
NotRegex = 8,
|
||||
Or = 9
|
||||
}
|
||||
|
||||
export interface IContextKeyExprMapper {
|
||||
mapDefined(key: string): ContextKeyExpr;
|
||||
mapNot(key: string): ContextKeyExpr;
|
||||
mapEquals(key: string, value: any): ContextKeyExpr;
|
||||
mapNotEquals(key: string, value: any): ContextKeyExpr;
|
||||
mapDefined(key: string): ContextKeyExpression;
|
||||
mapNot(key: string): ContextKeyExpression;
|
||||
mapEquals(key: string, value: any): ContextKeyExpression;
|
||||
mapNotEquals(key: string, value: any): ContextKeyExpression;
|
||||
mapRegex(key: string, regexp: RegExp | null): ContextKeyRegexExpr;
|
||||
}
|
||||
|
||||
export interface IContextKeyExpression {
|
||||
cmp(other: ContextKeyExpression): number;
|
||||
equals(other: ContextKeyExpression): boolean;
|
||||
evaluate(context: IContext): boolean;
|
||||
serialize(): string;
|
||||
keys(): string[];
|
||||
map(mapFnc: IContextKeyExprMapper): ContextKeyExpression;
|
||||
negate(): ContextKeyExpression;
|
||||
|
||||
}
|
||||
|
||||
export type ContextKeyExpression = (
|
||||
ContextKeyFalseExpr | ContextKeyTrueExpr | ContextKeyDefinedExpr | ContextKeyNotExpr
|
||||
| ContextKeyEqualsExpr | ContextKeyNotEqualsExpr | ContextKeyRegexExpr
|
||||
| ContextKeyNotRegexExpr | ContextKeyAndExpr | ContextKeyOrExpr
|
||||
);
|
||||
|
||||
export abstract class ContextKeyExpr {
|
||||
|
||||
public static has(key: string): ContextKeyExpr {
|
||||
public static false(): ContextKeyExpression {
|
||||
return ContextKeyFalseExpr.INSTANCE;
|
||||
}
|
||||
|
||||
public static true(): ContextKeyExpression {
|
||||
return ContextKeyTrueExpr.INSTANCE;
|
||||
}
|
||||
|
||||
public static has(key: string): ContextKeyExpression {
|
||||
return ContextKeyDefinedExpr.create(key);
|
||||
}
|
||||
|
||||
public static equals(key: string, value: any): ContextKeyExpr {
|
||||
public static equals(key: string, value: any): ContextKeyExpression {
|
||||
return ContextKeyEqualsExpr.create(key, value);
|
||||
}
|
||||
|
||||
public static notEquals(key: string, value: any): ContextKeyExpr {
|
||||
public static notEquals(key: string, value: any): ContextKeyExpression {
|
||||
return ContextKeyNotEqualsExpr.create(key, value);
|
||||
}
|
||||
|
||||
public static regex(key: string, value: RegExp): ContextKeyExpr {
|
||||
public static regex(key: string, value: RegExp): ContextKeyExpression {
|
||||
return ContextKeyRegexExpr.create(key, value);
|
||||
}
|
||||
|
||||
public static not(key: string): ContextKeyExpr {
|
||||
public static not(key: string): ContextKeyExpression {
|
||||
return ContextKeyNotExpr.create(key);
|
||||
}
|
||||
|
||||
public static and(...expr: Array<ContextKeyExpr | undefined | null>): ContextKeyExpr | undefined {
|
||||
public static and(...expr: Array<ContextKeyExpression | undefined | null>): ContextKeyExpression | undefined {
|
||||
return ContextKeyAndExpr.create(expr);
|
||||
}
|
||||
|
||||
public static or(...expr: Array<ContextKeyExpr | undefined | null>): ContextKeyExpr | undefined {
|
||||
public static or(...expr: Array<ContextKeyExpression | undefined | null>): ContextKeyExpression | undefined {
|
||||
return ContextKeyOrExpr.create(expr);
|
||||
}
|
||||
|
||||
public static deserialize(serialized: string | null | undefined, strict: boolean = false): ContextKeyExpr | undefined {
|
||||
public static deserialize(serialized: string | null | undefined, strict: boolean = false): ContextKeyExpression | undefined {
|
||||
if (!serialized) {
|
||||
return undefined;
|
||||
}
|
||||
|
@ -64,17 +99,17 @@ export abstract class ContextKeyExpr {
|
|||
return this._deserializeOrExpression(serialized, strict);
|
||||
}
|
||||
|
||||
private static _deserializeOrExpression(serialized: string, strict: boolean): ContextKeyExpr | undefined {
|
||||
private static _deserializeOrExpression(serialized: string, strict: boolean): ContextKeyExpression | undefined {
|
||||
let pieces = serialized.split('||');
|
||||
return ContextKeyOrExpr.create(pieces.map(p => this._deserializeAndExpression(p, strict)));
|
||||
}
|
||||
|
||||
private static _deserializeAndExpression(serialized: string, strict: boolean): ContextKeyExpr | undefined {
|
||||
private static _deserializeAndExpression(serialized: string, strict: boolean): ContextKeyExpression | undefined {
|
||||
let pieces = serialized.split('&&');
|
||||
return ContextKeyAndExpr.create(pieces.map(p => this._deserializeOne(p, strict)));
|
||||
}
|
||||
|
||||
private static _deserializeOne(serializedOne: string, strict: boolean): ContextKeyExpr {
|
||||
private static _deserializeOne(serializedOne: string, strict: boolean): ContextKeyExpression {
|
||||
serializedOne = serializedOne.trim();
|
||||
|
||||
if (serializedOne.indexOf('!=') >= 0) {
|
||||
|
@ -153,55 +188,104 @@ export abstract class ContextKeyExpr {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract getType(): ContextKeyExprType;
|
||||
public abstract equals(other: ContextKeyExpr): boolean;
|
||||
public abstract evaluate(context: IContext): boolean;
|
||||
public abstract serialize(): string;
|
||||
public abstract keys(): string[];
|
||||
public abstract map(mapFnc: IContextKeyExprMapper): ContextKeyExpr;
|
||||
public abstract negate(): ContextKeyExpr;
|
||||
}
|
||||
|
||||
function cmp(a: ContextKeyExpr, b: ContextKeyExpr): number {
|
||||
let aType = a.getType();
|
||||
let bType = b.getType();
|
||||
if (aType !== bType) {
|
||||
return aType - bType;
|
||||
function cmp(a: ContextKeyExpression, b: ContextKeyExpression): number {
|
||||
return a.cmp(b);
|
||||
}
|
||||
|
||||
export class ContextKeyFalseExpr implements IContextKeyExpression {
|
||||
public static INSTANCE = new ContextKeyFalseExpr();
|
||||
|
||||
public readonly type = ContextKeyExprType.False;
|
||||
|
||||
protected constructor() {
|
||||
}
|
||||
switch (aType) {
|
||||
case ContextKeyExprType.Defined:
|
||||
return (<ContextKeyDefinedExpr>a).cmp(<ContextKeyDefinedExpr>b);
|
||||
case ContextKeyExprType.Not:
|
||||
return (<ContextKeyNotExpr>a).cmp(<ContextKeyNotExpr>b);
|
||||
case ContextKeyExprType.Equals:
|
||||
return (<ContextKeyEqualsExpr>a).cmp(<ContextKeyEqualsExpr>b);
|
||||
case ContextKeyExprType.NotEquals:
|
||||
return (<ContextKeyNotEqualsExpr>a).cmp(<ContextKeyNotEqualsExpr>b);
|
||||
case ContextKeyExprType.Regex:
|
||||
return (<ContextKeyRegexExpr>a).cmp(<ContextKeyRegexExpr>b);
|
||||
case ContextKeyExprType.NotRegex:
|
||||
return (<ContextKeyNotRegexExpr>a).cmp(<ContextKeyNotRegexExpr>b);
|
||||
case ContextKeyExprType.And:
|
||||
return (<ContextKeyAndExpr>a).cmp(<ContextKeyAndExpr>b);
|
||||
default:
|
||||
throw new Error('Unknown ContextKeyExpr!');
|
||||
|
||||
public cmp(other: ContextKeyExpression): number {
|
||||
return this.type - other.type;
|
||||
}
|
||||
|
||||
public equals(other: ContextKeyExpression): boolean {
|
||||
return (other.type === this.type);
|
||||
}
|
||||
|
||||
public evaluate(context: IContext): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
public serialize(): string {
|
||||
return 'false';
|
||||
}
|
||||
|
||||
public keys(): string[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
public map(mapFnc: IContextKeyExprMapper): ContextKeyExpression {
|
||||
return this;
|
||||
}
|
||||
|
||||
public negate(): ContextKeyExpression {
|
||||
return ContextKeyTrueExpr.INSTANCE;
|
||||
}
|
||||
}
|
||||
|
||||
export class ContextKeyDefinedExpr implements ContextKeyExpr {
|
||||
public static create(key: string): ContextKeyDefinedExpr {
|
||||
export class ContextKeyTrueExpr implements IContextKeyExpression {
|
||||
public static INSTANCE = new ContextKeyTrueExpr();
|
||||
|
||||
public readonly type = ContextKeyExprType.True;
|
||||
|
||||
protected constructor() {
|
||||
}
|
||||
|
||||
public cmp(other: ContextKeyExpression): number {
|
||||
return this.type - other.type;
|
||||
}
|
||||
|
||||
public equals(other: ContextKeyExpression): boolean {
|
||||
return (other.type === this.type);
|
||||
}
|
||||
|
||||
public evaluate(context: IContext): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
public serialize(): string {
|
||||
return 'true';
|
||||
}
|
||||
|
||||
public keys(): string[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
public map(mapFnc: IContextKeyExprMapper): ContextKeyExpression {
|
||||
return this;
|
||||
}
|
||||
|
||||
public negate(): ContextKeyExpression {
|
||||
return ContextKeyFalseExpr.INSTANCE;
|
||||
}
|
||||
}
|
||||
|
||||
export class ContextKeyDefinedExpr implements IContextKeyExpression {
|
||||
public static create(key: string): ContextKeyExpression {
|
||||
const staticValue = STATIC_VALUES.get(key);
|
||||
if (typeof staticValue === 'boolean') {
|
||||
return staticValue ? ContextKeyTrueExpr.INSTANCE : ContextKeyFalseExpr.INSTANCE;
|
||||
}
|
||||
return new ContextKeyDefinedExpr(key);
|
||||
}
|
||||
|
||||
protected constructor(protected key: string) {
|
||||
public readonly type = ContextKeyExprType.Defined;
|
||||
|
||||
protected constructor(protected readonly key: string) {
|
||||
}
|
||||
|
||||
public getType(): ContextKeyExprType {
|
||||
return ContextKeyExprType.Defined;
|
||||
}
|
||||
|
||||
public cmp(other: ContextKeyDefinedExpr): number {
|
||||
public cmp(other: ContextKeyExpression): number {
|
||||
if (other.type !== this.type) {
|
||||
return this.type - other.type;
|
||||
}
|
||||
if (this.key < other.key) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -211,8 +295,8 @@ export class ContextKeyDefinedExpr implements ContextKeyExpr {
|
|||
return 0;
|
||||
}
|
||||
|
||||
public equals(other: ContextKeyExpr): boolean {
|
||||
if (other instanceof ContextKeyDefinedExpr) {
|
||||
public equals(other: ContextKeyExpression): boolean {
|
||||
if (other.type === this.type) {
|
||||
return (this.key === other.key);
|
||||
}
|
||||
return false;
|
||||
|
@ -230,35 +314,38 @@ export class ContextKeyDefinedExpr implements ContextKeyExpr {
|
|||
return [this.key];
|
||||
}
|
||||
|
||||
public map(mapFnc: IContextKeyExprMapper): ContextKeyExpr {
|
||||
public map(mapFnc: IContextKeyExprMapper): ContextKeyExpression {
|
||||
return mapFnc.mapDefined(this.key);
|
||||
}
|
||||
|
||||
public negate(): ContextKeyExpr {
|
||||
public negate(): ContextKeyExpression {
|
||||
return ContextKeyNotExpr.create(this.key);
|
||||
}
|
||||
}
|
||||
|
||||
export class ContextKeyEqualsExpr implements ContextKeyExpr {
|
||||
export class ContextKeyEqualsExpr implements IContextKeyExpression {
|
||||
|
||||
public static create(key: string, value: any): ContextKeyExpr {
|
||||
public static create(key: string, value: any): ContextKeyExpression {
|
||||
if (typeof value === 'boolean') {
|
||||
if (value) {
|
||||
return ContextKeyDefinedExpr.create(key);
|
||||
}
|
||||
return ContextKeyNotExpr.create(key);
|
||||
return (value ? ContextKeyDefinedExpr.create(key) : ContextKeyNotExpr.create(key));
|
||||
}
|
||||
const staticValue = STATIC_VALUES.get(key);
|
||||
if (typeof staticValue === 'boolean') {
|
||||
const trueValue = staticValue ? 'true' : 'false';
|
||||
return (value === trueValue ? ContextKeyTrueExpr.INSTANCE : ContextKeyFalseExpr.INSTANCE);
|
||||
}
|
||||
return new ContextKeyEqualsExpr(key, value);
|
||||
}
|
||||
|
||||
public readonly type = ContextKeyExprType.Equals;
|
||||
|
||||
private constructor(private readonly key: string, private readonly value: any) {
|
||||
}
|
||||
|
||||
public getType(): ContextKeyExprType {
|
||||
return ContextKeyExprType.Equals;
|
||||
}
|
||||
|
||||
public cmp(other: ContextKeyEqualsExpr): number {
|
||||
public cmp(other: ContextKeyExpression): number {
|
||||
if (other.type !== this.type) {
|
||||
return this.type - other.type;
|
||||
}
|
||||
if (this.key < other.key) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -274,8 +361,8 @@ export class ContextKeyEqualsExpr implements ContextKeyExpr {
|
|||
return 0;
|
||||
}
|
||||
|
||||
public equals(other: ContextKeyExpr): boolean {
|
||||
if (other instanceof ContextKeyEqualsExpr) {
|
||||
public equals(other: ContextKeyExpression): boolean {
|
||||
if (other.type === this.type) {
|
||||
return (this.key === other.key && this.value === other.value);
|
||||
}
|
||||
return false;
|
||||
|
@ -295,35 +382,41 @@ export class ContextKeyEqualsExpr implements ContextKeyExpr {
|
|||
return [this.key];
|
||||
}
|
||||
|
||||
public map(mapFnc: IContextKeyExprMapper): ContextKeyExpr {
|
||||
public map(mapFnc: IContextKeyExprMapper): ContextKeyExpression {
|
||||
return mapFnc.mapEquals(this.key, this.value);
|
||||
}
|
||||
|
||||
public negate(): ContextKeyExpr {
|
||||
public negate(): ContextKeyExpression {
|
||||
return ContextKeyNotEqualsExpr.create(this.key, this.value);
|
||||
}
|
||||
}
|
||||
|
||||
export class ContextKeyNotEqualsExpr implements ContextKeyExpr {
|
||||
export class ContextKeyNotEqualsExpr implements IContextKeyExpression {
|
||||
|
||||
public static create(key: string, value: any): ContextKeyExpr {
|
||||
public static create(key: string, value: any): ContextKeyExpression {
|
||||
if (typeof value === 'boolean') {
|
||||
if (value) {
|
||||
return ContextKeyNotExpr.create(key);
|
||||
}
|
||||
return ContextKeyDefinedExpr.create(key);
|
||||
}
|
||||
const staticValue = STATIC_VALUES.get(key);
|
||||
if (typeof staticValue === 'boolean') {
|
||||
const falseValue = staticValue ? 'true' : 'false';
|
||||
return (value === falseValue ? ContextKeyFalseExpr.INSTANCE : ContextKeyTrueExpr.INSTANCE);
|
||||
}
|
||||
return new ContextKeyNotEqualsExpr(key, value);
|
||||
}
|
||||
|
||||
private constructor(private key: string, private value: any) {
|
||||
public readonly type = ContextKeyExprType.NotEquals;
|
||||
|
||||
private constructor(private readonly key: string, private readonly value: any) {
|
||||
}
|
||||
|
||||
public getType(): ContextKeyExprType {
|
||||
return ContextKeyExprType.NotEquals;
|
||||
}
|
||||
|
||||
public cmp(other: ContextKeyNotEqualsExpr): number {
|
||||
public cmp(other: ContextKeyExpression): number {
|
||||
if (other.type !== this.type) {
|
||||
return this.type - other.type;
|
||||
}
|
||||
if (this.key < other.key) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -339,8 +432,8 @@ export class ContextKeyNotEqualsExpr implements ContextKeyExpr {
|
|||
return 0;
|
||||
}
|
||||
|
||||
public equals(other: ContextKeyExpr): boolean {
|
||||
if (other instanceof ContextKeyNotEqualsExpr) {
|
||||
public equals(other: ContextKeyExpression): boolean {
|
||||
if (other.type === this.type) {
|
||||
return (this.key === other.key && this.value === other.value);
|
||||
}
|
||||
return false;
|
||||
|
@ -360,29 +453,34 @@ export class ContextKeyNotEqualsExpr implements ContextKeyExpr {
|
|||
return [this.key];
|
||||
}
|
||||
|
||||
public map(mapFnc: IContextKeyExprMapper): ContextKeyExpr {
|
||||
public map(mapFnc: IContextKeyExprMapper): ContextKeyExpression {
|
||||
return mapFnc.mapNotEquals(this.key, this.value);
|
||||
}
|
||||
|
||||
public negate(): ContextKeyExpr {
|
||||
public negate(): ContextKeyExpression {
|
||||
return ContextKeyEqualsExpr.create(this.key, this.value);
|
||||
}
|
||||
}
|
||||
|
||||
export class ContextKeyNotExpr implements ContextKeyExpr {
|
||||
export class ContextKeyNotExpr implements IContextKeyExpression {
|
||||
|
||||
public static create(key: string): ContextKeyExpr {
|
||||
public static create(key: string): ContextKeyExpression {
|
||||
const staticValue = STATIC_VALUES.get(key);
|
||||
if (typeof staticValue === 'boolean') {
|
||||
return (staticValue ? ContextKeyFalseExpr.INSTANCE : ContextKeyTrueExpr.INSTANCE);
|
||||
}
|
||||
return new ContextKeyNotExpr(key);
|
||||
}
|
||||
|
||||
private constructor(private key: string) {
|
||||
public readonly type = ContextKeyExprType.Not;
|
||||
|
||||
private constructor(private readonly key: string) {
|
||||
}
|
||||
|
||||
public getType(): ContextKeyExprType {
|
||||
return ContextKeyExprType.Not;
|
||||
}
|
||||
|
||||
public cmp(other: ContextKeyNotExpr): number {
|
||||
public cmp(other: ContextKeyExpression): number {
|
||||
if (other.type !== this.type) {
|
||||
return this.type - other.type;
|
||||
}
|
||||
if (this.key < other.key) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -392,8 +490,8 @@ export class ContextKeyNotExpr implements ContextKeyExpr {
|
|||
return 0;
|
||||
}
|
||||
|
||||
public equals(other: ContextKeyExpr): boolean {
|
||||
if (other instanceof ContextKeyNotExpr) {
|
||||
public equals(other: ContextKeyExpression): boolean {
|
||||
if (other.type === this.type) {
|
||||
return (this.key === other.key);
|
||||
}
|
||||
return false;
|
||||
|
@ -411,30 +509,31 @@ export class ContextKeyNotExpr implements ContextKeyExpr {
|
|||
return [this.key];
|
||||
}
|
||||
|
||||
public map(mapFnc: IContextKeyExprMapper): ContextKeyExpr {
|
||||
public map(mapFnc: IContextKeyExprMapper): ContextKeyExpression {
|
||||
return mapFnc.mapNot(this.key);
|
||||
}
|
||||
|
||||
public negate(): ContextKeyExpr {
|
||||
public negate(): ContextKeyExpression {
|
||||
return ContextKeyDefinedExpr.create(this.key);
|
||||
}
|
||||
}
|
||||
|
||||
export class ContextKeyRegexExpr implements ContextKeyExpr {
|
||||
export class ContextKeyRegexExpr implements IContextKeyExpression {
|
||||
|
||||
public static create(key: string, regexp: RegExp | null): ContextKeyRegexExpr {
|
||||
return new ContextKeyRegexExpr(key, regexp);
|
||||
}
|
||||
|
||||
private constructor(private key: string, private regexp: RegExp | null) {
|
||||
public readonly type = ContextKeyExprType.Regex;
|
||||
|
||||
private constructor(private readonly key: string, private readonly regexp: RegExp | null) {
|
||||
//
|
||||
}
|
||||
|
||||
public getType(): ContextKeyExprType {
|
||||
return ContextKeyExprType.Regex;
|
||||
}
|
||||
|
||||
public cmp(other: ContextKeyRegexExpr): number {
|
||||
public cmp(other: ContextKeyExpression): number {
|
||||
if (other.type !== this.type) {
|
||||
return this.type - other.type;
|
||||
}
|
||||
if (this.key < other.key) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -452,8 +551,8 @@ export class ContextKeyRegexExpr implements ContextKeyExpr {
|
|||
return 0;
|
||||
}
|
||||
|
||||
public equals(other: ContextKeyExpr): boolean {
|
||||
if (other instanceof ContextKeyRegexExpr) {
|
||||
public equals(other: ContextKeyExpression): boolean {
|
||||
if (other.type === this.type) {
|
||||
const thisSource = this.regexp ? this.regexp.source : '';
|
||||
const otherSource = other.regexp ? other.regexp.source : '';
|
||||
return (this.key === other.key && thisSource === otherSource);
|
||||
|
@ -481,31 +580,32 @@ export class ContextKeyRegexExpr implements ContextKeyExpr {
|
|||
return mapFnc.mapRegex(this.key, this.regexp);
|
||||
}
|
||||
|
||||
public negate(): ContextKeyExpr {
|
||||
public negate(): ContextKeyExpression {
|
||||
return ContextKeyNotRegexExpr.create(this);
|
||||
}
|
||||
}
|
||||
|
||||
export class ContextKeyNotRegexExpr implements ContextKeyExpr {
|
||||
export class ContextKeyNotRegexExpr implements IContextKeyExpression {
|
||||
|
||||
public static create(actual: ContextKeyRegexExpr): ContextKeyExpr {
|
||||
public static create(actual: ContextKeyRegexExpr): ContextKeyExpression {
|
||||
return new ContextKeyNotRegexExpr(actual);
|
||||
}
|
||||
|
||||
public readonly type = ContextKeyExprType.NotRegex;
|
||||
|
||||
private constructor(private readonly _actual: ContextKeyRegexExpr) {
|
||||
//
|
||||
}
|
||||
|
||||
public getType(): ContextKeyExprType {
|
||||
return ContextKeyExprType.NotRegex;
|
||||
}
|
||||
|
||||
public cmp(other: ContextKeyNotRegexExpr): number {
|
||||
public cmp(other: ContextKeyExpression): number {
|
||||
if (other.type !== this.type) {
|
||||
return this.type - other.type;
|
||||
}
|
||||
return this._actual.cmp(other._actual);
|
||||
}
|
||||
|
||||
public equals(other: ContextKeyExpr): boolean {
|
||||
if (other instanceof ContextKeyNotRegexExpr) {
|
||||
public equals(other: ContextKeyExpression): boolean {
|
||||
if (other.type === this.type) {
|
||||
return this._actual.equals(other._actual);
|
||||
}
|
||||
return false;
|
||||
|
@ -523,18 +623,18 @@ export class ContextKeyNotRegexExpr implements ContextKeyExpr {
|
|||
return this._actual.keys();
|
||||
}
|
||||
|
||||
public map(mapFnc: IContextKeyExprMapper): ContextKeyExpr {
|
||||
public map(mapFnc: IContextKeyExprMapper): ContextKeyExpression {
|
||||
return new ContextKeyNotRegexExpr(this._actual.map(mapFnc));
|
||||
}
|
||||
|
||||
public negate(): ContextKeyExpr {
|
||||
public negate(): ContextKeyExpression {
|
||||
return this._actual;
|
||||
}
|
||||
}
|
||||
|
||||
export class ContextKeyAndExpr implements ContextKeyExpr {
|
||||
export class ContextKeyAndExpr implements IContextKeyExpression {
|
||||
|
||||
public static create(_expr: ReadonlyArray<ContextKeyExpr | null | undefined>): ContextKeyExpr | undefined {
|
||||
public static create(_expr: ReadonlyArray<ContextKeyExpression | null | undefined>): ContextKeyExpression | undefined {
|
||||
const expr = ContextKeyAndExpr._normalizeArr(_expr);
|
||||
if (expr.length === 0) {
|
||||
return undefined;
|
||||
|
@ -547,14 +647,15 @@ export class ContextKeyAndExpr implements ContextKeyExpr {
|
|||
return new ContextKeyAndExpr(expr);
|
||||
}
|
||||
|
||||
private constructor(public readonly expr: ContextKeyExpr[]) {
|
||||
public readonly type = ContextKeyExprType.And;
|
||||
|
||||
private constructor(public readonly expr: ContextKeyExpression[]) {
|
||||
}
|
||||
|
||||
public getType(): ContextKeyExprType {
|
||||
return ContextKeyExprType.And;
|
||||
}
|
||||
|
||||
public cmp(other: ContextKeyAndExpr): number {
|
||||
public cmp(other: ContextKeyExpression): number {
|
||||
if (other.type !== this.type) {
|
||||
return this.type - other.type;
|
||||
}
|
||||
if (this.expr.length < other.expr.length) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -570,8 +671,8 @@ export class ContextKeyAndExpr implements ContextKeyExpr {
|
|||
return 0;
|
||||
}
|
||||
|
||||
public equals(other: ContextKeyExpr): boolean {
|
||||
if (other instanceof ContextKeyAndExpr) {
|
||||
public equals(other: ContextKeyExpression): boolean {
|
||||
if (other.type === this.type) {
|
||||
if (this.expr.length !== other.expr.length) {
|
||||
return false;
|
||||
}
|
||||
|
@ -594,20 +695,32 @@ export class ContextKeyAndExpr implements ContextKeyExpr {
|
|||
return true;
|
||||
}
|
||||
|
||||
private static _normalizeArr(arr: ReadonlyArray<ContextKeyExpr | null | undefined>): ContextKeyExpr[] {
|
||||
const expr: ContextKeyExpr[] = [];
|
||||
private static _normalizeArr(arr: ReadonlyArray<ContextKeyExpression | null | undefined>): ContextKeyExpression[] {
|
||||
const expr: ContextKeyExpression[] = [];
|
||||
let hasTrue = false;
|
||||
|
||||
for (const e of arr) {
|
||||
if (!e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (e instanceof ContextKeyAndExpr) {
|
||||
if (e.type === ContextKeyExprType.True) {
|
||||
// anything && true ==> anything
|
||||
hasTrue = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (e.type === ContextKeyExprType.False) {
|
||||
// anything && false ==> false
|
||||
return [ContextKeyFalseExpr.INSTANCE];
|
||||
}
|
||||
|
||||
if (e.type === ContextKeyExprType.And) {
|
||||
expr.push(...e.expr);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (e instanceof ContextKeyOrExpr) {
|
||||
if (e.type === ContextKeyExprType.Or) {
|
||||
// Not allowed, because we don't have parens!
|
||||
throw new Error(`It is not allowed to have an or expression here due to lack of parens! For example "a && (b||c)" is not supported, use "(a&&b) || (a&&c)" instead.`);
|
||||
}
|
||||
|
@ -615,6 +728,10 @@ export class ContextKeyAndExpr implements ContextKeyExpr {
|
|||
expr.push(e);
|
||||
}
|
||||
|
||||
if (expr.length === 0 && hasTrue) {
|
||||
return [ContextKeyTrueExpr.INSTANCE];
|
||||
}
|
||||
|
||||
expr.sort(cmp);
|
||||
|
||||
return expr;
|
||||
|
@ -632,12 +749,12 @@ export class ContextKeyAndExpr implements ContextKeyExpr {
|
|||
return result;
|
||||
}
|
||||
|
||||
public map(mapFnc: IContextKeyExprMapper): ContextKeyExpr {
|
||||
public map(mapFnc: IContextKeyExprMapper): ContextKeyExpression {
|
||||
return new ContextKeyAndExpr(this.expr.map(expr => expr.map(mapFnc)));
|
||||
}
|
||||
|
||||
public negate(): ContextKeyExpr {
|
||||
let result: ContextKeyExpr[] = [];
|
||||
public negate(): ContextKeyExpression {
|
||||
let result: ContextKeyExpression[] = [];
|
||||
for (let expr of this.expr) {
|
||||
result.push(expr.negate());
|
||||
}
|
||||
|
@ -645,9 +762,9 @@ export class ContextKeyAndExpr implements ContextKeyExpr {
|
|||
}
|
||||
}
|
||||
|
||||
export class ContextKeyOrExpr implements ContextKeyExpr {
|
||||
export class ContextKeyOrExpr implements IContextKeyExpression {
|
||||
|
||||
public static create(_expr: ReadonlyArray<ContextKeyExpr | null | undefined>): ContextKeyExpr | undefined {
|
||||
public static create(_expr: ReadonlyArray<ContextKeyExpression | null | undefined>): ContextKeyExpression | undefined {
|
||||
const expr = ContextKeyOrExpr._normalizeArr(_expr);
|
||||
if (expr.length === 0) {
|
||||
return undefined;
|
||||
|
@ -660,15 +777,32 @@ export class ContextKeyOrExpr implements ContextKeyExpr {
|
|||
return new ContextKeyOrExpr(expr);
|
||||
}
|
||||
|
||||
private constructor(public readonly expr: ContextKeyExpr[]) {
|
||||
public readonly type = ContextKeyExprType.Or;
|
||||
|
||||
private constructor(public readonly expr: ContextKeyExpression[]) {
|
||||
}
|
||||
|
||||
public getType(): ContextKeyExprType {
|
||||
return ContextKeyExprType.Or;
|
||||
public cmp(other: ContextKeyExpression): number {
|
||||
if (other.type !== this.type) {
|
||||
return this.type - other.type;
|
||||
}
|
||||
if (this.expr.length < other.expr.length) {
|
||||
return -1;
|
||||
}
|
||||
if (this.expr.length > other.expr.length) {
|
||||
return 1;
|
||||
}
|
||||
for (let i = 0, len = this.expr.length; i < len; i++) {
|
||||
const r = cmp(this.expr[i], other.expr[i]);
|
||||
if (r !== 0) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public equals(other: ContextKeyExpr): boolean {
|
||||
if (other instanceof ContextKeyOrExpr) {
|
||||
public equals(other: ContextKeyExpression): boolean {
|
||||
if (other.type === this.type) {
|
||||
if (this.expr.length !== other.expr.length) {
|
||||
return false;
|
||||
}
|
||||
|
@ -691,17 +825,29 @@ export class ContextKeyOrExpr implements ContextKeyExpr {
|
|||
return false;
|
||||
}
|
||||
|
||||
private static _normalizeArr(arr: ReadonlyArray<ContextKeyExpr | null | undefined>): ContextKeyExpr[] {
|
||||
let expr: ContextKeyExpr[] = [];
|
||||
private static _normalizeArr(arr: ReadonlyArray<ContextKeyExpression | null | undefined>): ContextKeyExpression[] {
|
||||
let expr: ContextKeyExpression[] = [];
|
||||
let hasFalse = false;
|
||||
|
||||
if (arr) {
|
||||
for (let i = 0, len = arr.length; i < len; i++) {
|
||||
let e: ContextKeyExpr | null | undefined = arr[i];
|
||||
const e = arr[i];
|
||||
if (!e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (e instanceof ContextKeyOrExpr) {
|
||||
if (e.type === ContextKeyExprType.False) {
|
||||
// anything || false ==> anything
|
||||
hasFalse = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (e.type === ContextKeyExprType.True) {
|
||||
// anything || true ==> true
|
||||
return [ContextKeyTrueExpr.INSTANCE];
|
||||
}
|
||||
|
||||
if (e.type === ContextKeyExprType.Or) {
|
||||
expr = expr.concat(e.expr);
|
||||
continue;
|
||||
}
|
||||
|
@ -709,6 +855,10 @@ export class ContextKeyOrExpr implements ContextKeyExpr {
|
|||
expr.push(e);
|
||||
}
|
||||
|
||||
if (expr.length === 0 && hasFalse) {
|
||||
return [ContextKeyFalseExpr.INSTANCE];
|
||||
}
|
||||
|
||||
expr.sort(cmp);
|
||||
}
|
||||
|
||||
|
@ -727,18 +877,18 @@ export class ContextKeyOrExpr implements ContextKeyExpr {
|
|||
return result;
|
||||
}
|
||||
|
||||
public map(mapFnc: IContextKeyExprMapper): ContextKeyExpr {
|
||||
public map(mapFnc: IContextKeyExprMapper): ContextKeyExpression {
|
||||
return new ContextKeyOrExpr(this.expr.map(expr => expr.map(mapFnc)));
|
||||
}
|
||||
|
||||
public negate(): ContextKeyExpr {
|
||||
let result: ContextKeyExpr[] = [];
|
||||
public negate(): ContextKeyExpression {
|
||||
let result: ContextKeyExpression[] = [];
|
||||
for (let expr of this.expr) {
|
||||
result.push(expr.negate());
|
||||
}
|
||||
|
||||
const terminals = (node: ContextKeyExpr) => {
|
||||
if (node instanceof ContextKeyOrExpr) {
|
||||
const terminals = (node: ContextKeyExpression) => {
|
||||
if (node.type === ContextKeyExprType.Or) {
|
||||
return node.expr;
|
||||
}
|
||||
return [node];
|
||||
|
@ -750,7 +900,7 @@ export class ContextKeyOrExpr implements ContextKeyExpr {
|
|||
const LEFT = result.shift()!;
|
||||
const RIGHT = result.shift()!;
|
||||
|
||||
const all: ContextKeyExpr[] = [];
|
||||
const all: ContextKeyExpression[] = [];
|
||||
for (const left of terminals(LEFT)) {
|
||||
for (const right of terminals(RIGHT)) {
|
||||
all.push(ContextKeyExpr.and(left, right)!);
|
||||
|
@ -765,7 +915,7 @@ export class ContextKeyOrExpr implements ContextKeyExpr {
|
|||
|
||||
export class RawContextKey<T> extends ContextKeyDefinedExpr {
|
||||
|
||||
private _defaultValue: T | undefined;
|
||||
private readonly _defaultValue: T | undefined;
|
||||
|
||||
constructor(key: string, defaultValue: T | undefined) {
|
||||
super(key);
|
||||
|
@ -780,15 +930,15 @@ export class RawContextKey<T> extends ContextKeyDefinedExpr {
|
|||
return target.getContextKeyValue<T>(this.key);
|
||||
}
|
||||
|
||||
public toNegated(): ContextKeyExpr {
|
||||
public toNegated(): ContextKeyExpression {
|
||||
return ContextKeyExpr.not(this.key);
|
||||
}
|
||||
|
||||
public isEqualTo(value: string): ContextKeyExpr {
|
||||
public isEqualTo(value: string): ContextKeyExpression {
|
||||
return ContextKeyExpr.equals(this.key, value);
|
||||
}
|
||||
|
||||
public notEqualsTo(value: string): ContextKeyExpr {
|
||||
public notEqualsTo(value: string): ContextKeyExpression {
|
||||
return ContextKeyExpr.notEquals(this.key, value);
|
||||
}
|
||||
}
|
||||
|
@ -830,7 +980,7 @@ export interface IContextKeyService {
|
|||
|
||||
|
||||
createKey<T>(key: string, defaultValue: T | undefined): IContextKey<T>;
|
||||
contextMatchesRules(rules: ContextKeyExpr | undefined): boolean;
|
||||
contextMatchesRules(rules: ContextKeyExpression | undefined): boolean;
|
||||
getContextKeyValue<T>(key: string): T | undefined;
|
||||
|
||||
createScoped(target?: IContextKeyServiceTarget): IContextKeyService;
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { RawContextKey, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
|
||||
export const InputFocusedContextKey = 'inputFocus';
|
||||
export const InputFocusedContext = new RawContextKey<boolean>(InputFocusedContextKey, false);
|
||||
|
||||
export const FalseContext: ContextKeyExpr = new RawContextKey<boolean>('__false', false);
|
||||
export const FalseContext = new RawContextKey<boolean>('__false', false);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as assert from 'assert';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { isMacintosh, isLinux, isWindows } from 'vs/base/common/platform';
|
||||
|
||||
function createContext(ctx: any) {
|
||||
return {
|
||||
|
@ -89,6 +90,8 @@ suite('ContextKeyExpr', () => {
|
|||
testBatch('d', 'd');
|
||||
testBatch('z', undefined);
|
||||
|
||||
testExpression('true', true);
|
||||
testExpression('false', false);
|
||||
testExpression('a && !b', true && !false);
|
||||
testExpression('a && b', true && false);
|
||||
testExpression('a && !b && c == 5', true && !false && '5' === '5');
|
||||
|
@ -107,10 +110,30 @@ suite('ContextKeyExpr', () => {
|
|||
const actual = ContextKeyExpr.deserialize(expr)!.negate().serialize();
|
||||
assert.strictEqual(actual, expected);
|
||||
}
|
||||
testNegate('true', 'false');
|
||||
testNegate('false', 'true');
|
||||
testNegate('a', '!a');
|
||||
testNegate('a && b || c', '!a && !c || !b && !c');
|
||||
testNegate('a && b || c || d', '!a && !c && !d || !b && !c && !d');
|
||||
testNegate('!a && !b || !c && !d', 'a && c || a && d || b && c || b && d');
|
||||
testNegate('!a && !b || !c && !d || !e && !f', 'a && c && e || a && c && f || a && d && e || a && d && f || b && c && e || b && c && f || b && d && e || b && d && f');
|
||||
});
|
||||
|
||||
test('false, true', () => {
|
||||
function testNormalize(expr: string, expected: string): void {
|
||||
const actual = ContextKeyExpr.deserialize(expr)!.serialize();
|
||||
assert.strictEqual(actual, expected);
|
||||
}
|
||||
testNormalize('true', 'true');
|
||||
testNormalize('!true', 'false');
|
||||
testNormalize('false', 'false');
|
||||
testNormalize('!false', 'true');
|
||||
testNormalize('a && true', 'a');
|
||||
testNormalize('a && false', 'false');
|
||||
testNormalize('a || true', 'true');
|
||||
testNormalize('a || false', 'a');
|
||||
testNormalize('isMac', isMacintosh ? 'true' : 'false');
|
||||
testNormalize('isLinux', isLinux ? 'true' : 'false');
|
||||
testNormalize('isWindows', isWindows ? 'true' : 'false');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
import { isNonEmptyArray } from 'vs/base/common/arrays';
|
||||
import { MenuRegistry } from 'vs/platform/actions/common/actions';
|
||||
import { CommandsRegistry, ICommandHandlerDescription } from 'vs/platform/commands/common/commands';
|
||||
import { ContextKeyExpr, IContext, ContextKeyOrExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IContext, ContextKeyExpression, ContextKeyExprType } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKeybindingItem';
|
||||
import { keys } from 'vs/base/common/map';
|
||||
|
||||
|
@ -49,12 +49,17 @@ export class KeybindingResolver {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (k.when && k.when.type === ContextKeyExprType.False) {
|
||||
// when condition is false
|
||||
continue;
|
||||
}
|
||||
|
||||
// TODO@chords
|
||||
this._addKeyPress(k.keypressParts[0], k);
|
||||
}
|
||||
}
|
||||
|
||||
private static _isTargetedForRemoval(defaultKb: ResolvedKeybindingItem, keypressFirstPart: string | null, keypressChordPart: string | null, command: string, when: ContextKeyExpr | undefined): boolean {
|
||||
private static _isTargetedForRemoval(defaultKb: ResolvedKeybindingItem, keypressFirstPart: string | null, keypressChordPart: string | null, command: string, when: ContextKeyExpression | undefined): boolean {
|
||||
if (defaultKb.command !== command) {
|
||||
return false;
|
||||
}
|
||||
|
@ -175,7 +180,7 @@ export class KeybindingResolver {
|
|||
/**
|
||||
* Returns true if it is provable `a` implies `b`.
|
||||
*/
|
||||
public static whenIsEntirelyIncluded(a: ContextKeyExpr | null | undefined, b: ContextKeyExpr | null | undefined): boolean {
|
||||
public static whenIsEntirelyIncluded(a: ContextKeyExpression | null | undefined, b: ContextKeyExpression | null | undefined): boolean {
|
||||
if (!b) {
|
||||
return true;
|
||||
}
|
||||
|
@ -189,11 +194,11 @@ export class KeybindingResolver {
|
|||
/**
|
||||
* Returns true if it is provable `p` implies `q`.
|
||||
*/
|
||||
private static _implies(p: ContextKeyExpr, q: ContextKeyExpr): boolean {
|
||||
private static _implies(p: ContextKeyExpression, q: ContextKeyExpression): boolean {
|
||||
const notP = p.negate();
|
||||
|
||||
const terminals = (node: ContextKeyExpr) => {
|
||||
if (node instanceof ContextKeyOrExpr) {
|
||||
const terminals = (node: ContextKeyExpression) => {
|
||||
if (node.type === ContextKeyExprType.Or) {
|
||||
return node.expr;
|
||||
}
|
||||
return [node];
|
||||
|
@ -318,7 +323,7 @@ export class KeybindingResolver {
|
|||
return null;
|
||||
}
|
||||
|
||||
public static contextMatchesRules(context: IContext, rules: ContextKeyExpr | null | undefined): boolean {
|
||||
public static contextMatchesRules(context: IContext, rules: ContextKeyExpression | null | undefined): boolean {
|
||||
if (!rules) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -6,14 +6,14 @@
|
|||
import { KeyCode, Keybinding, SimpleKeybinding, createKeybinding } from 'vs/base/common/keyCodes';
|
||||
import { OS, OperatingSystem } from 'vs/base/common/platform';
|
||||
import { CommandsRegistry, ICommandHandler, ICommandHandlerDescription } from 'vs/platform/commands/common/commands';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ContextKeyExpression } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
|
||||
export interface IKeybindingItem {
|
||||
keybinding: Keybinding;
|
||||
command: string;
|
||||
commandArgs?: any;
|
||||
when: ContextKeyExpr | null | undefined;
|
||||
when: ContextKeyExpression | null | undefined;
|
||||
weight1: number;
|
||||
weight2: number;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ export interface IKeybindingRule extends IKeybindings {
|
|||
id: string;
|
||||
weight: number;
|
||||
args?: any;
|
||||
when: ContextKeyExpr | null | undefined;
|
||||
when: ContextKeyExpression | null | undefined;
|
||||
}
|
||||
|
||||
export interface IKeybindingRule2 {
|
||||
|
@ -50,7 +50,7 @@ export interface IKeybindingRule2 {
|
|||
id: string;
|
||||
args?: any;
|
||||
weight: number;
|
||||
when: ContextKeyExpr | undefined;
|
||||
when: ContextKeyExpression | undefined;
|
||||
}
|
||||
|
||||
export const enum KeybindingWeight {
|
||||
|
@ -209,7 +209,7 @@ class KeybindingsRegistryImpl implements IKeybindingsRegistry {
|
|||
}
|
||||
}
|
||||
|
||||
private _registerDefaultKeybinding(keybinding: Keybinding, commandId: string, commandArgs: any, weight1: number, weight2: number, when: ContextKeyExpr | null | undefined): void {
|
||||
private _registerDefaultKeybinding(keybinding: Keybinding, commandId: string, commandArgs: any, weight1: number, weight2: number, when: ContextKeyExpression | null | undefined): void {
|
||||
if (OS === OperatingSystem.Windows) {
|
||||
this._assertNoCtrlAlt(keybinding.parts[0], commandId);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
import { CharCode } from 'vs/base/common/charCode';
|
||||
import { ResolvedKeybinding } from 'vs/base/common/keyCodes';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ContextKeyExpression } from 'vs/platform/contextkey/common/contextkey';
|
||||
|
||||
export class ResolvedKeybindingItem {
|
||||
_resolvedKeybindingItemBrand: void;
|
||||
|
@ -15,10 +15,10 @@ export class ResolvedKeybindingItem {
|
|||
public readonly bubble: boolean;
|
||||
public readonly command: string | null;
|
||||
public readonly commandArgs: any;
|
||||
public readonly when: ContextKeyExpr | undefined;
|
||||
public readonly when: ContextKeyExpression | undefined;
|
||||
public readonly isDefault: boolean;
|
||||
|
||||
constructor(resolvedKeybinding: ResolvedKeybinding | undefined, command: string | null, commandArgs: any, when: ContextKeyExpr | undefined, isDefault: boolean) {
|
||||
constructor(resolvedKeybinding: ResolvedKeybinding | undefined, command: string | null, commandArgs: any, when: ContextKeyExpression | undefined, isDefault: boolean) {
|
||||
this.resolvedKeybinding = resolvedKeybinding;
|
||||
this.keypressParts = resolvedKeybinding ? removeElementsAfterNulls(resolvedKeybinding.getDispatchParts()) : [];
|
||||
this.bubble = (command ? command.charCodeAt(0) === CharCode.Caret : false);
|
||||
|
|
|
@ -7,7 +7,7 @@ import { KeyChord, KeyCode, KeyMod, Keybinding, ResolvedKeybinding, SimpleKeybin
|
|||
import { OS } from 'vs/base/common/platform';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { ContextKeyExpr, IContext, IContextKeyService, IContextKeyServiceTarget } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ContextKeyExpr, IContext, IContextKeyService, IContextKeyServiceTarget, ContextKeyExpression } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { AbstractKeybindingService } from 'vs/platform/keybinding/common/abstractKeybindingService';
|
||||
import { IKeyboardEvent } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { KeybindingResolver } from 'vs/platform/keybinding/common/keybindingResolver';
|
||||
|
@ -182,7 +182,7 @@ suite('AbstractKeybindingService', () => {
|
|||
statusMessageCallsDisposed = null;
|
||||
});
|
||||
|
||||
function kbItem(keybinding: number, command: string, when?: ContextKeyExpr): ResolvedKeybindingItem {
|
||||
function kbItem(keybinding: number, command: string, when?: ContextKeyExpression): ResolvedKeybindingItem {
|
||||
const resolvedKeybinding = (keybinding !== 0 ? new USLayoutResolvedKeybinding(createKeybinding(keybinding, OS)!, OS) : undefined);
|
||||
return new ResolvedKeybindingItem(
|
||||
resolvedKeybinding,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
import * as assert from 'assert';
|
||||
import { KeyChord, KeyCode, KeyMod, SimpleKeybinding, createKeybinding, createSimpleKeybinding } from 'vs/base/common/keyCodes';
|
||||
import { OS } from 'vs/base/common/platform';
|
||||
import { ContextKeyExpr, IContext } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ContextKeyExpr, IContext, ContextKeyExpression } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { KeybindingResolver } from 'vs/platform/keybinding/common/keybindingResolver';
|
||||
import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKeybindingItem';
|
||||
import { USLayoutResolvedKeybinding } from 'vs/platform/keybinding/common/usLayoutResolvedKeybinding';
|
||||
|
@ -20,7 +20,7 @@ function createContext(ctx: any) {
|
|||
|
||||
suite('KeybindingResolver', () => {
|
||||
|
||||
function kbItem(keybinding: number, command: string, commandArgs: any, when: ContextKeyExpr | undefined, isDefault: boolean): ResolvedKeybindingItem {
|
||||
function kbItem(keybinding: number, command: string, commandArgs: any, when: ContextKeyExpression | undefined, isDefault: boolean): ResolvedKeybindingItem {
|
||||
const resolvedKeybinding = (keybinding !== 0 ? new USLayoutResolvedKeybinding(createKeybinding(keybinding, OS)!, OS) : undefined);
|
||||
return new ResolvedKeybindingItem(
|
||||
resolvedKeybinding,
|
||||
|
@ -225,7 +225,7 @@ suite('KeybindingResolver', () => {
|
|||
|
||||
test('resolve command', function () {
|
||||
|
||||
function _kbItem(keybinding: number, command: string, when: ContextKeyExpr | undefined): ResolvedKeybindingItem {
|
||||
function _kbItem(keybinding: number, command: string, when: ContextKeyExpression | undefined): ResolvedKeybindingItem {
|
||||
return kbItem(keybinding, command, null, when, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
import { Event } from 'vs/base/common/event';
|
||||
import { Keybinding, ResolvedKeybinding, SimpleKeybinding } from 'vs/base/common/keyCodes';
|
||||
import { OS } from 'vs/base/common/platform';
|
||||
import { ContextKeyExpr, IContextKey, IContextKeyChangeEvent, IContextKeyService, IContextKeyServiceTarget } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IContextKey, IContextKeyChangeEvent, IContextKeyService, IContextKeyServiceTarget, ContextKeyExpression } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IKeybindingEvent, IKeybindingService, IKeyboardEvent } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { IResolveResult } from 'vs/platform/keybinding/common/keybindingResolver';
|
||||
import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKeybindingItem';
|
||||
|
@ -47,7 +47,7 @@ export class MockContextKeyService implements IContextKeyService {
|
|||
this._keys.set(key, ret);
|
||||
return ret;
|
||||
}
|
||||
public contextMatchesRules(rules: ContextKeyExpr): boolean {
|
||||
public contextMatchesRules(rules: ContextKeyExpression): boolean {
|
||||
return false;
|
||||
}
|
||||
public get onDidChangeContext(): Event<IContextKeyChangeEvent> {
|
||||
|
|
|
@ -42,7 +42,7 @@ import * as editorCommands from 'vs/workbench/browser/parts/editor/editorCommand
|
|||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { getQuickNavigateHandler, inQuickOpenContext } from 'vs/workbench/browser/parts/quickopen/quickopen';
|
||||
import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ContextKeyExpr, ContextKeyExpression } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { isMacintosh } from 'vs/base/common/platform';
|
||||
import { AllEditorsByAppearancePicker, ActiveGroupEditorsByMostRecentlyUsedPicker, AllEditorsByMostRecentlyUsedPicker } from 'vs/workbench/browser/parts/editor/editorPicker';
|
||||
import { registerEditorContribution } from 'vs/editor/browser/editorExtensions';
|
||||
|
@ -511,7 +511,7 @@ MenuRegistry.appendMenuItem(MenuId.EditorTitle, { command: { id: editorCommands.
|
|||
|
||||
interface IEditorToolItem { id: string; title: string; icon?: { dark?: URI; light?: URI; } | ThemeIcon; }
|
||||
|
||||
function appendEditorToolItem(primary: IEditorToolItem, when: ContextKeyExpr | undefined, order: number, alternative?: IEditorToolItem, precondition?: ContextKeyExpr | undefined): void {
|
||||
function appendEditorToolItem(primary: IEditorToolItem, when: ContextKeyExpression | undefined, order: number, alternative?: IEditorToolItem, precondition?: ContextKeyExpression | undefined): void {
|
||||
const item: IMenuItem = {
|
||||
command: {
|
||||
id: primary.id,
|
||||
|
|
|
@ -17,7 +17,7 @@ import { ActivityAction, ToggleCompositePinnedAction, ICompositeBar } from 'vs/w
|
|||
import { IActivity } from 'vs/workbench/common/activity';
|
||||
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { ActivePanelContext, PanelPositionContext } from 'vs/workbench/common/panel';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ContextKeyExpression } from 'vs/platform/contextkey/common/contextkey';
|
||||
|
||||
export class ClosePanelAction extends Action {
|
||||
|
||||
|
@ -133,7 +133,7 @@ const PositionPanelActionId = {
|
|||
|
||||
interface PanelActionConfig<T> {
|
||||
id: string;
|
||||
when: ContextKeyExpr;
|
||||
when: ContextKeyExpression;
|
||||
alias: string;
|
||||
label: string;
|
||||
value: T;
|
||||
|
|
|
@ -11,7 +11,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
|
|||
import { IDisposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { ILifecycleService, LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ContextKeyExpr, ContextKeyExpression } from 'vs/platform/contextkey/common/contextkey';
|
||||
|
||||
export const Extensions = {
|
||||
WorkbenchActions: 'workbench.contributions.actions'
|
||||
|
@ -28,11 +28,11 @@ export interface IWorkbenchActionRegistry {
|
|||
|
||||
Registry.add(Extensions.WorkbenchActions, new class implements IWorkbenchActionRegistry {
|
||||
|
||||
registerWorkbenchAction(descriptor: SyncActionDescriptor, alias: string, category?: string, when?: ContextKeyExpr): IDisposable {
|
||||
registerWorkbenchAction(descriptor: SyncActionDescriptor, alias: string, category?: string, when?: ContextKeyExpression): IDisposable {
|
||||
return this.registerWorkbenchCommandFromAction(descriptor, alias, category, when);
|
||||
}
|
||||
|
||||
private registerWorkbenchCommandFromAction(descriptor: SyncActionDescriptor, alias: string, category?: string, when?: ContextKeyExpr): IDisposable {
|
||||
private registerWorkbenchCommandFromAction(descriptor: SyncActionDescriptor, alias: string, category?: string, when?: ContextKeyExpression): IDisposable {
|
||||
const registrations = new DisposableStore();
|
||||
|
||||
// command
|
||||
|
|
|
@ -12,7 +12,7 @@ import { IDisposable, Disposable, toDisposable } from 'vs/base/common/lifecycle'
|
|||
import { IEditor as ICodeEditor, IEditorViewState, ScrollType, IDiffEditor } from 'vs/editor/common/editorCommon';
|
||||
import { IEditorModel, IEditorOptions, ITextEditorOptions, IBaseResourceInput, IResourceInput, EditorActivation, EditorOpenContext, ITextEditorSelection, TextEditorSelectionRevealType } from 'vs/platform/editor/common/editor';
|
||||
import { IInstantiationService, IConstructorSignature0, ServicesAccessor, BrandedService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { RawContextKey, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { IEditorGroup, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
|
@ -38,7 +38,7 @@ export const EditorsVisibleContext = new RawContextKey<boolean>('editorIsOpen',
|
|||
export const EditorPinnedContext = new RawContextKey<boolean>('editorPinned', false);
|
||||
export const EditorGroupActiveEditorDirtyContext = new RawContextKey<boolean>('groupActiveEditorDirty', false);
|
||||
export const EditorGroupEditorsCountContext = new RawContextKey<number>('groupEditorsCount', 0);
|
||||
export const NoEditorsVisibleContext: ContextKeyExpr = EditorsVisibleContext.toNegated();
|
||||
export const NoEditorsVisibleContext = EditorsVisibleContext.toNegated();
|
||||
export const TextCompareEditorVisibleContext = new RawContextKey<boolean>('textCompareEditorVisible', false);
|
||||
export const TextCompareEditorActiveContext = new RawContextKey<boolean>('textCompareEditorActive', false);
|
||||
export const ActiveEditorGroupEmptyContext = new RawContextKey<boolean>('activeEditorGroupEmpty', false);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
import { Command } from 'vs/editor/common/modes';
|
||||
import { UriComponents, URI } from 'vs/base/common/uri';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { ContextKeyExpr, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { RawContextKey, ContextKeyExpression } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { localize } from 'vs/nls';
|
||||
import { IViewlet } from 'vs/workbench/common/viewlet';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
@ -178,7 +178,7 @@ export interface IViewDescriptor {
|
|||
|
||||
readonly ctorDescriptor: SyncDescriptor<IView>;
|
||||
|
||||
readonly when?: ContextKeyExpr;
|
||||
readonly when?: ContextKeyExpression;
|
||||
|
||||
readonly order?: number;
|
||||
|
||||
|
@ -220,13 +220,13 @@ export enum ViewContentPriority {
|
|||
|
||||
export interface IViewContentDescriptor {
|
||||
readonly content: string;
|
||||
readonly when?: ContextKeyExpr | 'default';
|
||||
readonly when?: ContextKeyExpression | 'default';
|
||||
readonly priority?: ViewContentPriority;
|
||||
|
||||
/**
|
||||
* ordered preconditions for each button in the content
|
||||
*/
|
||||
readonly preconditions?: (ContextKeyExpr | undefined)[];
|
||||
readonly preconditions?: (ContextKeyExpression | undefined)[];
|
||||
}
|
||||
|
||||
export interface IViewsRegistry {
|
||||
|
|
|
@ -10,7 +10,7 @@ import { Selection } from 'vs/editor/common/core/selection';
|
|||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import * as modes from 'vs/editor/common/modes';
|
||||
import { CodeActionKind } from 'vs/editor/contrib/codeAction/types';
|
||||
import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ContextKeyExpr, IContextKeyService, ContextKeyExpression } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
|
||||
import { IExtensionPoint } from 'vs/workbench/services/extensions/common/extensionsRegistry';
|
||||
import { DocumentationExtensionPoint } from './documentationExtensionPoint';
|
||||
|
@ -20,7 +20,7 @@ export class CodeActionDocumentationContribution extends Disposable implements I
|
|||
|
||||
private contributions: {
|
||||
title: string;
|
||||
when: ContextKeyExpr;
|
||||
when: ContextKeyExpression;
|
||||
command: string;
|
||||
}[] = [];
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ import { IQuickOpenRegistry, Extensions as QuickOpenExtensions, QuickOpenHandler
|
|||
import { StatusBarColorProvider } from 'vs/workbench/contrib/debug/browser/statusbarColorProvider';
|
||||
import { IViewsRegistry, Extensions as ViewExtensions, IViewContainersRegistry, ViewContainerLocation, ViewContainer } from 'vs/workbench/common/views';
|
||||
import { isMacintosh } from 'vs/base/common/platform';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ContextKeyExpr, ContextKeyExpression } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { DebugQuickOpenHandler } from 'vs/workbench/contrib/debug/browser/debugQuickOpen';
|
||||
import { DebugStatusContribution } from 'vs/workbench/contrib/debug/browser/debugStatus';
|
||||
|
@ -135,7 +135,7 @@ registry.registerWorkbenchAction(SyncActionDescriptor.create(DisableAllBreakpoin
|
|||
registry.registerWorkbenchAction(SyncActionDescriptor.create(SelectAndStartAction, SelectAndStartAction.ID, SelectAndStartAction.LABEL), 'Debug: Select and Start Debugging', debugCategory);
|
||||
registry.registerWorkbenchAction(SyncActionDescriptor.create(ClearReplAction, ClearReplAction.ID, ClearReplAction.LABEL), 'Debug: Clear Console', debugCategory);
|
||||
|
||||
const registerDebugCommandPaletteItem = (id: string, title: string, when?: ContextKeyExpr, precondition?: ContextKeyExpr) => {
|
||||
const registerDebugCommandPaletteItem = (id: string, title: string, when?: ContextKeyExpression, precondition?: ContextKeyExpression) => {
|
||||
MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
|
||||
when,
|
||||
command: {
|
||||
|
@ -290,7 +290,7 @@ Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).regi
|
|||
|
||||
// Debug toolbar
|
||||
|
||||
const registerDebugToolBarItem = (id: string, title: string, order: number, icon: { light?: URI, dark?: URI } | ThemeIcon, when?: ContextKeyExpr, precondition?: ContextKeyExpr) => {
|
||||
const registerDebugToolBarItem = (id: string, title: string, order: number, icon: { light?: URI, dark?: URI } | ThemeIcon, when?: ContextKeyExpression, precondition?: ContextKeyExpression) => {
|
||||
MenuRegistry.appendMenuItem(MenuId.DebugToolBar, {
|
||||
group: 'navigation',
|
||||
when,
|
||||
|
@ -316,7 +316,7 @@ registerDebugToolBarItem(STEP_BACK_ID, nls.localize('stepBackDebug', "Step Back"
|
|||
registerDebugToolBarItem(REVERSE_CONTINUE_ID, nls.localize('reverseContinue', "Reverse"), 60, { id: 'codicon/debug-reverse-continue' }, CONTEXT_STEP_BACK_SUPPORTED, CONTEXT_DEBUG_STATE.isEqualTo('stopped'));
|
||||
|
||||
// Debug callstack context menu
|
||||
const registerDebugCallstackItem = (id: string, title: string, order: number, when?: ContextKeyExpr, precondition?: ContextKeyExpr, group = 'navigation') => {
|
||||
const registerDebugCallstackItem = (id: string, title: string, order: number, when?: ContextKeyExpression, precondition?: ContextKeyExpression, group = 'navigation') => {
|
||||
MenuRegistry.appendMenuItem(MenuId.DebugCallStackContext, {
|
||||
group,
|
||||
when,
|
||||
|
@ -558,7 +558,7 @@ MenuRegistry.appendMenuItem(MenuId.MenubarDebugMenu, {
|
|||
// Touch Bar
|
||||
if (isMacintosh) {
|
||||
|
||||
const registerTouchBarEntry = (id: string, title: string, order: number, when: ContextKeyExpr | undefined, iconUri: URI) => {
|
||||
const registerTouchBarEntry = (id: string, title: string, order: number, when: ContextKeyExpression | undefined, iconUri: URI) => {
|
||||
MenuRegistry.appendMenuItem(MenuId.TouchBarContext, {
|
||||
command: {
|
||||
id,
|
||||
|
|
|
@ -12,7 +12,7 @@ import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/wor
|
|||
import { KeyMod, KeyChord, KeyCode } from 'vs/base/common/keyCodes';
|
||||
import { openWindowCommand, COPY_PATH_COMMAND_ID, REVEAL_IN_EXPLORER_COMMAND_ID, OPEN_TO_SIDE_COMMAND_ID, REVERT_FILE_COMMAND_ID, SAVE_FILE_COMMAND_ID, SAVE_FILE_LABEL, SAVE_FILE_AS_COMMAND_ID, SAVE_FILE_AS_LABEL, SAVE_ALL_IN_GROUP_COMMAND_ID, OpenEditorsGroupContext, COMPARE_WITH_SAVED_COMMAND_ID, COMPARE_RESOURCE_COMMAND_ID, SELECT_FOR_COMPARE_COMMAND_ID, ResourceSelectedForCompareContext, DirtyEditorContext, COMPARE_SELECTED_COMMAND_ID, REMOVE_ROOT_FOLDER_COMMAND_ID, REMOVE_ROOT_FOLDER_LABEL, SAVE_FILES_COMMAND_ID, COPY_RELATIVE_PATH_COMMAND_ID, SAVE_FILE_WITHOUT_FORMATTING_COMMAND_ID, SAVE_FILE_WITHOUT_FORMATTING_LABEL, newWindowCommand, ReadonlyEditorContext } from 'vs/workbench/contrib/files/browser/fileCommands';
|
||||
import { CommandsRegistry, ICommandHandler } from 'vs/platform/commands/common/commands';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ContextKeyExpr, ContextKeyExpression } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { isMacintosh } from 'vs/base/common/platform';
|
||||
import { FilesExplorerFocusCondition, ExplorerRootContext, ExplorerFolderContext, ExplorerResourceNotReadonlyContext, ExplorerResourceCut, IExplorerService, ExplorerResourceMoveableToTrash, ExplorerViewletVisibleContext } from 'vs/workbench/contrib/files/common/files';
|
||||
|
@ -170,7 +170,7 @@ appendEditorTitleContextMenuItem(COPY_PATH_COMMAND_ID, copyPathCommand.title, Re
|
|||
appendEditorTitleContextMenuItem(COPY_RELATIVE_PATH_COMMAND_ID, copyRelativePathCommand.title, ResourceContextKey.IsFileSystemResource, '1_cutcopypaste');
|
||||
appendEditorTitleContextMenuItem(REVEAL_IN_EXPLORER_COMMAND_ID, nls.localize('revealInSideBar', "Reveal in Side Bar"), ResourceContextKey.IsFileSystemResource);
|
||||
|
||||
export function appendEditorTitleContextMenuItem(id: string, title: string, when: ContextKeyExpr | undefined, group?: string): void {
|
||||
export function appendEditorTitleContextMenuItem(id: string, title: string, when: ContextKeyExpression | undefined, group?: string): void {
|
||||
|
||||
// Menu
|
||||
MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, {
|
||||
|
@ -200,7 +200,7 @@ function appendSaveConflictEditorTitleAction(id: string, title: string, icon: Th
|
|||
|
||||
// Menu registration - command palette
|
||||
|
||||
export function appendToCommandPalette(id: string, title: ILocalizedString, category: ILocalizedString, when?: ContextKeyExpr): void {
|
||||
export function appendToCommandPalette(id: string, title: ILocalizedString, category: ILocalizedString, when?: ContextKeyExpression): void {
|
||||
MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
|
||||
command: {
|
||||
id,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
import * as nls from 'vs/nls';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { RawContextKey, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { OperatingSystem } from 'vs/base/common/platform';
|
||||
|
@ -19,25 +19,25 @@ export const KEYBINDING_CONTEXT_TERMINAL_IS_OPEN = new RawContextKey<boolean>('t
|
|||
/** A context key that is set when the integrated terminal has focus. */
|
||||
export const KEYBINDING_CONTEXT_TERMINAL_FOCUS = new RawContextKey<boolean>('terminalFocus', false);
|
||||
/** A context key that is set when the integrated terminal does not have focus. */
|
||||
export const KEYBINDING_CONTEXT_TERMINAL_NOT_FOCUSED: ContextKeyExpr = KEYBINDING_CONTEXT_TERMINAL_FOCUS.toNegated();
|
||||
export const KEYBINDING_CONTEXT_TERMINAL_NOT_FOCUSED = KEYBINDING_CONTEXT_TERMINAL_FOCUS.toNegated();
|
||||
/** A context key that is set when the user is navigating the accessibility tree */
|
||||
export const KEYBINDING_CONTEXT_TERMINAL_A11Y_TREE_FOCUS = new RawContextKey<boolean>('terminalA11yTreeFocus', false);
|
||||
|
||||
/** A keybinding context key that is set when the integrated terminal has text selected. */
|
||||
export const KEYBINDING_CONTEXT_TERMINAL_TEXT_SELECTED = new RawContextKey<boolean>('terminalTextSelected', false);
|
||||
/** A keybinding context key that is set when the integrated terminal does not have text selected. */
|
||||
export const KEYBINDING_CONTEXT_TERMINAL_TEXT_NOT_SELECTED: ContextKeyExpr = KEYBINDING_CONTEXT_TERMINAL_TEXT_SELECTED.toNegated();
|
||||
export const KEYBINDING_CONTEXT_TERMINAL_TEXT_NOT_SELECTED = KEYBINDING_CONTEXT_TERMINAL_TEXT_SELECTED.toNegated();
|
||||
|
||||
/** A context key that is set when the find widget in integrated terminal is visible. */
|
||||
export const KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_VISIBLE = new RawContextKey<boolean>('terminalFindWidgetVisible', false);
|
||||
/** A context key that is set when the find widget in integrated terminal is not visible. */
|
||||
export const KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_NOT_VISIBLE: ContextKeyExpr = KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_VISIBLE.toNegated();
|
||||
export const KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_NOT_VISIBLE = KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_VISIBLE.toNegated();
|
||||
/** A context key that is set when the find widget find input in integrated terminal is focused. */
|
||||
export const KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_INPUT_FOCUSED = new RawContextKey<boolean>('terminalFindWidgetInputFocused', false);
|
||||
/** A context key that is set when the find widget in integrated terminal is focused. */
|
||||
export const KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_FOCUSED = new RawContextKey<boolean>('terminalFindWidgetFocused', false);
|
||||
/** A context key that is set when the find widget find input in integrated terminal is not focused. */
|
||||
export const KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_INPUT_NOT_FOCUSED: ContextKeyExpr = KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_INPUT_FOCUSED.toNegated();
|
||||
export const KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_INPUT_NOT_FOCUSED = KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_INPUT_FOCUSED.toNegated();
|
||||
|
||||
export const IS_WORKSPACE_SHELL_ALLOWED_STORAGE_KEY = 'terminal.integrated.isWorkspaceShellAllowed';
|
||||
export const NEVER_MEASURE_RENDER_TIME_STORAGE_KEY = 'terminal.integrated.neverMeasureRenderTime';
|
||||
|
|
|
@ -23,7 +23,7 @@ import { localize } from 'vs/nls';
|
|||
import { MenuId, MenuRegistry, registerAction2, Action2 } from 'vs/platform/actions/common/actions';
|
||||
import { CommandsRegistry, ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ContextKeyExpr, IContextKey, IContextKeyService, RawContextKey, ContextKeyRegexExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ContextKeyExpr, IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
@ -835,7 +835,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
|||
}
|
||||
|
||||
private registerShowSettingsConflictsAction(): void {
|
||||
const resolveSettingsConflictsWhenContext = ContextKeyRegexExpr.create(CONTEXT_CONFLICTS_SOURCES.keys()[0], /.*settings.*/i);
|
||||
const resolveSettingsConflictsWhenContext = ContextKeyExpr.regex(CONTEXT_CONFLICTS_SOURCES.keys()[0], /.*settings.*/i);
|
||||
CommandsRegistry.registerCommand(resolveSettingsConflictsCommand.id, () => this.handleConflicts(SyncSource.Settings));
|
||||
MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
|
||||
group: '5_sync',
|
||||
|
@ -862,7 +862,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
|
|||
}
|
||||
|
||||
private registerShowKeybindingsConflictsAction(): void {
|
||||
const resolveKeybindingsConflictsWhenContext = ContextKeyRegexExpr.create(CONTEXT_CONFLICTS_SOURCES.keys()[0], /.*keybindings.*/i);
|
||||
const resolveKeybindingsConflictsWhenContext = ContextKeyExpr.regex(CONTEXT_CONFLICTS_SOURCES.keys()[0], /.*keybindings.*/i);
|
||||
CommandsRegistry.registerCommand(resolveKeybindingsConflictsCommand.id, () => this.handleConflicts(SyncSource.Keybindings));
|
||||
MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
|
||||
group: '5_sync',
|
||||
|
|
|
@ -7,7 +7,7 @@ import { Action } from 'vs/base/common/actions';
|
|||
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
import * as nls from 'vs/nls';
|
||||
import { Action2 } from 'vs/platform/actions/common/actions';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ContextKeyExpr, ContextKeyExpression } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_FOCUSED, KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE } from 'vs/workbench/contrib/webview/browser/webview';
|
||||
|
@ -19,7 +19,7 @@ export class ShowWebViewEditorFindWidgetAction extends Action2 {
|
|||
public static readonly ID = 'editor.action.webvieweditor.showFind';
|
||||
public static readonly LABEL = nls.localize('editor.action.webvieweditor.showFind', "Show find");
|
||||
|
||||
constructor(contextKeyExpr: ContextKeyExpr) {
|
||||
constructor(contextKeyExpr: ContextKeyExpression) {
|
||||
super({
|
||||
id: ShowWebViewEditorFindWidgetAction.ID,
|
||||
title: ShowWebViewEditorFindWidgetAction.LABEL,
|
||||
|
@ -40,7 +40,7 @@ export class HideWebViewEditorFindCommand extends Action2 {
|
|||
public static readonly ID = 'editor.action.webvieweditor.hideFind';
|
||||
public static readonly LABEL = nls.localize('editor.action.webvieweditor.hideFind', "Stop find");
|
||||
|
||||
constructor(contextKeyExpr: ContextKeyExpr) {
|
||||
constructor(contextKeyExpr: ContextKeyExpression) {
|
||||
super({
|
||||
id: HideWebViewEditorFindCommand.ID,
|
||||
title: HideWebViewEditorFindCommand.LABEL,
|
||||
|
@ -61,7 +61,7 @@ export class WebViewEditorFindNextCommand extends Action2 {
|
|||
public static readonly ID = 'editor.action.webvieweditor.findNext';
|
||||
public static readonly LABEL = nls.localize('editor.action.webvieweditor.findNext', 'Find next');
|
||||
|
||||
constructor(contextKeyExpr: ContextKeyExpr) {
|
||||
constructor(contextKeyExpr: ContextKeyExpression) {
|
||||
super({
|
||||
id: WebViewEditorFindNextCommand.ID,
|
||||
title: WebViewEditorFindNextCommand.LABEL,
|
||||
|
@ -82,7 +82,7 @@ export class WebViewEditorFindPreviousCommand extends Action2 {
|
|||
public static readonly ID = 'editor.action.webvieweditor.findPrevious';
|
||||
public static readonly LABEL = nls.localize('editor.action.webvieweditor.findPrevious', 'Find previous');
|
||||
|
||||
constructor(contextKeyExpr: ContextKeyExpr) {
|
||||
constructor(contextKeyExpr: ContextKeyExpression) {
|
||||
super({
|
||||
id: WebViewEditorFindPreviousCommand.ID,
|
||||
title: WebViewEditorFindPreviousCommand.LABEL,
|
||||
|
@ -103,7 +103,7 @@ export class SelectAllWebviewEditorCommand extends Action2 {
|
|||
public static readonly ID = 'editor.action.webvieweditor.selectAll';
|
||||
public static readonly LABEL = nls.localize('editor.action.webvieweditor.selectAll', 'Select all');
|
||||
|
||||
constructor(contextKeyExpr: ContextKeyExpr) {
|
||||
constructor(contextKeyExpr: ContextKeyExpression) {
|
||||
const precondition = ContextKeyExpr.and(contextKeyExpr, ContextKeyExpr.not(InputFocusedContextKey));
|
||||
super({
|
||||
id: SelectAllWebviewEditorCommand.ID,
|
||||
|
|
|
@ -9,7 +9,7 @@ import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
|||
import { ServicesAccessor } from 'vs/editor/browser/editorExtensions';
|
||||
import * as nls from 'vs/nls';
|
||||
import { Action2 } from 'vs/platform/actions/common/actions';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ContextKeyExpr, ContextKeyExpression } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { InputFocusedContextKey } from 'vs/platform/contextkey/common/contextkeys';
|
||||
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { WebviewEditorOverlay, webviewHasOwnEditFunctionsContextKey } from 'vs/workbench/contrib/webview/browser/webview';
|
||||
|
@ -42,7 +42,7 @@ export class CopyWebviewEditorCommand extends Action2 {
|
|||
public static readonly ID = 'editor.action.webvieweditor.copy';
|
||||
public static readonly LABEL = nls.localize('editor.action.webvieweditor.copy', "Copy2");
|
||||
|
||||
constructor(contextKeyExpr: ContextKeyExpr) {
|
||||
constructor(contextKeyExpr: ContextKeyExpression) {
|
||||
super({
|
||||
id: CopyWebviewEditorCommand.ID,
|
||||
title: CopyWebviewEditorCommand.LABEL,
|
||||
|
@ -63,7 +63,7 @@ export class PasteWebviewEditorCommand extends Action2 {
|
|||
public static readonly ID = 'editor.action.webvieweditor.paste';
|
||||
public static readonly LABEL = nls.localize('editor.action.webvieweditor.paste', 'Paste');
|
||||
|
||||
constructor(contextKeyExpr: ContextKeyExpr) {
|
||||
constructor(contextKeyExpr: ContextKeyExpression) {
|
||||
super({
|
||||
id: PasteWebviewEditorCommand.ID,
|
||||
title: PasteWebviewEditorCommand.LABEL,
|
||||
|
@ -84,7 +84,7 @@ export class CutWebviewEditorCommand extends Action2 {
|
|||
public static readonly ID = 'editor.action.webvieweditor.cut';
|
||||
public static readonly LABEL = nls.localize('editor.action.webvieweditor.cut', 'Cut');
|
||||
|
||||
constructor(contextKeyExpr: ContextKeyExpr) {
|
||||
constructor(contextKeyExpr: ContextKeyExpression) {
|
||||
super({
|
||||
id: CutWebviewEditorCommand.ID,
|
||||
title: CutWebviewEditorCommand.LABEL,
|
||||
|
@ -105,7 +105,7 @@ export class UndoWebviewEditorCommand extends Action2 {
|
|||
public static readonly ID = 'editor.action.webvieweditor.undo';
|
||||
public static readonly LABEL = nls.localize('editor.action.webvieweditor.undo', "Undo");
|
||||
|
||||
constructor(contextKeyExpr: ContextKeyExpr) {
|
||||
constructor(contextKeyExpr: ContextKeyExpression) {
|
||||
super({
|
||||
id: UndoWebviewEditorCommand.ID,
|
||||
title: UndoWebviewEditorCommand.LABEL,
|
||||
|
@ -126,7 +126,7 @@ export class RedoWebviewEditorCommand extends Action2 {
|
|||
public static readonly ID = 'editor.action.webvieweditor.redo';
|
||||
public static readonly LABEL = nls.localize('editor.action.webvieweditor.redo', "Redo");
|
||||
|
||||
constructor(contextKeyExpr: ContextKeyExpr) {
|
||||
constructor(contextKeyExpr: ContextKeyExpression) {
|
||||
super({
|
||||
id: RedoWebviewEditorCommand.ID,
|
||||
title: RedoWebviewEditorCommand.LABEL,
|
||||
|
|
|
@ -15,7 +15,7 @@ import { OS, OperatingSystem } from 'vs/base/common/platform';
|
|||
import { ICommandService, CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { Extensions as ConfigExtensions, IConfigurationNode, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry';
|
||||
import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ContextKeyExpr, IContextKeyService, ContextKeyExpression } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { Extensions, IJSONContributionRegistry } from 'vs/platform/jsonschemas/common/jsonContributionRegistry';
|
||||
import { AbstractKeybindingService } from 'vs/platform/keybinding/common/abstractKeybindingService';
|
||||
|
@ -510,7 +510,7 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
|
|||
|
||||
let commandAction = MenuRegistry.getCommand(command);
|
||||
let precondition = commandAction && commandAction.precondition;
|
||||
let fullWhen: ContextKeyExpr | undefined;
|
||||
let fullWhen: ContextKeyExpression | undefined;
|
||||
if (when && precondition) {
|
||||
fullWhen = ContextKeyExpr.and(precondition, ContextKeyExpr.deserialize(when));
|
||||
} else if (when) {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
import { SimpleKeybinding } from 'vs/base/common/keyCodes';
|
||||
import { KeybindingParser } from 'vs/base/common/keybindingParser';
|
||||
import { ScanCodeBinding } from 'vs/base/common/scanCode';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ContextKeyExpr, ContextKeyExpression } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IUserFriendlyKeybinding } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKeybindingItem';
|
||||
|
||||
|
@ -14,7 +14,7 @@ export interface IUserKeybindingItem {
|
|||
parts: (SimpleKeybinding | ScanCodeBinding)[];
|
||||
command: string | null;
|
||||
commandArgs?: any;
|
||||
when: ContextKeyExpr | undefined;
|
||||
when: ContextKeyExpression | undefined;
|
||||
}
|
||||
|
||||
export class KeybindingIO {
|
||||
|
|
Loading…
Reference in a new issue