diff --git a/src/vs/editor/common/config/config.ts b/src/vs/editor/common/config/config.ts index 106475f7522..baf31dd4029 100644 --- a/src/vs/editor/common/config/config.ts +++ b/src/vs/editor/common/config/config.ts @@ -9,7 +9,7 @@ import {KeyCode, KeyMod} from 'vs/base/common/keyCodes'; import {IEditorService} from 'vs/platform/editor/common/editor'; import {ServicesAccessor} from 'vs/platform/instantiation/common/instantiation'; import {IKeybindings} from 'vs/platform/keybinding/common/keybinding'; -import {IContextKeyService, KbExpr} from 'vs/platform/contextkey/common/contextkey'; +import {IContextKeyService, ContextKeyExpr} from 'vs/platform/contextkey/common/contextkey'; import {ICommandAndKeybindingRule, KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry'; import * as editorCommon from 'vs/editor/common/editorCommon'; import {ICodeEditorService} from 'vs/editor/common/services/codeEditorService'; @@ -22,19 +22,19 @@ import EditorContextKeys = editorCommon.EditorContextKeys; const CORE_WEIGHT = KeybindingsRegistry.WEIGHT.editorCore(); export interface ICommandKeybindingsOptions extends IKeybindings { - kbExpr?: KbExpr; + kbExpr?: ContextKeyExpr; weight?: number; } export interface ICommandOptions { id: string; - precondition: KbExpr; + precondition: ContextKeyExpr; kbOpts?: ICommandKeybindingsOptions; } export abstract class Command { public id: string; - public precondition: KbExpr; + public precondition: ContextKeyExpr; private kbOpts: ICommandKeybindingsOptions; constructor(opts:ICommandOptions) { @@ -51,7 +51,7 @@ export abstract class Command { let kbWhen = kbOpts.kbExpr; if (this.precondition) { if (kbWhen) { - kbWhen = KbExpr.and(kbWhen, this.precondition); + kbWhen = ContextKeyExpr.and(kbWhen, this.precondition); } else { kbWhen = this.precondition; } @@ -172,7 +172,7 @@ class CoreCommand extends Command { } class UnboundCoreCommand extends CoreCommand { - constructor(handlerId:string, precondition: KbExpr = null) { + constructor(handlerId:string, precondition: ContextKeyExpr = null) { super({ id: handlerId, precondition: precondition @@ -226,7 +226,7 @@ class WordCommand extends CoreCommand { } } - constructor(handlerId: string, shift:boolean, key:KeyCode, precondition: KbExpr = null) { + constructor(handlerId: string, shift:boolean, key:KeyCode, precondition: ContextKeyExpr = null) { super({ id: handlerId, precondition: precondition, @@ -563,7 +563,7 @@ registerCommand(new CoreCommand({ precondition: EditorContextKeys.Writable, kbOpts: { weight: CORE_WEIGHT, - kbExpr: KbExpr.and( + kbExpr: ContextKeyExpr.and( EditorContextKeys.TextFocus, EditorContextKeys.TabDoesNotMoveFocus ), @@ -575,7 +575,7 @@ registerCommand(new CoreCommand({ precondition: EditorContextKeys.Writable, kbOpts: { weight: CORE_WEIGHT, - kbExpr: KbExpr.and( + kbExpr: ContextKeyExpr.and( EditorContextKeys.TextFocus, EditorContextKeys.TabDoesNotMoveFocus ), diff --git a/src/vs/editor/common/editorCommon.ts b/src/vs/editor/common/editorCommon.ts index e77320ecd14..c6c147f38f3 100644 --- a/src/vs/editor/common/editorCommon.ts +++ b/src/vs/editor/common/editorCommon.ts @@ -20,7 +20,7 @@ import {Selection} from 'vs/editor/common/core/selection'; import {ModeTransition} from 'vs/editor/common/core/modeTransition'; import {IndentRange} from 'vs/editor/common/model/indentRanges'; import {ICommandHandlerDescription} from 'vs/platform/commands/common/commands'; -import {KbExpr, KbCtxKey} from 'vs/platform/contextkey/common/contextkey'; +import {ContextKeyExpr, KbCtxKey} from 'vs/platform/contextkey/common/contextkey'; /** * @internal @@ -3046,7 +3046,7 @@ export namespace EditorContextKeys { /** * @internal */ - export const Writable:KbExpr = ReadOnly.toNegated(); + export const Writable:ContextKeyExpr = ReadOnly.toNegated(); /** * A context key that is set when the editor has a non-collapsed selection. @@ -3056,7 +3056,7 @@ export namespace EditorContextKeys { /** * @internal */ - export const HasOnlyEmptySelection:KbExpr = HasNonEmptySelection.toNegated(); + export const HasOnlyEmptySelection:ContextKeyExpr = HasNonEmptySelection.toNegated(); /** * A context key that is set when the editor has multiple selections (multiple cursors). @@ -3066,7 +3066,7 @@ export namespace EditorContextKeys { /** * @internal */ - export const HasSingleSelection:KbExpr = HasMultipleSelections.toNegated(); + export const HasSingleSelection:ContextKeyExpr = HasMultipleSelections.toNegated(); /** * @internal @@ -3075,7 +3075,7 @@ export namespace EditorContextKeys { /** * @internal */ - export const TabDoesNotMoveFocus:KbExpr = TabMovesFocus.toNegated(); + export const TabDoesNotMoveFocus:ContextKeyExpr = TabMovesFocus.toNegated(); /** * A context key that is set to the language associated with the model associated with the editor. diff --git a/src/vs/editor/contrib/defineKeybinding/browser/defineKeybinding.ts b/src/vs/editor/contrib/defineKeybinding/browser/defineKeybinding.ts index 4aea67a76e9..0bc4a539a0f 100644 --- a/src/vs/editor/contrib/defineKeybinding/browser/defineKeybinding.ts +++ b/src/vs/editor/contrib/defineKeybinding/browser/defineKeybinding.ts @@ -17,7 +17,7 @@ import {StandardKeyboardEvent} from 'vs/base/browser/keyboardEvent'; import {StyleMutator} from 'vs/base/browser/styleMutator'; import {IOSupport} from 'vs/platform/keybinding/common/keybindingResolver'; import {IKeybindingService2} from 'vs/platform/keybinding/common/keybinding'; -import {KbExpr} from 'vs/platform/contextkey/common/contextkey'; +import {ContextKeyExpr} from 'vs/platform/contextkey/common/contextkey'; import {Range} from 'vs/editor/common/core/range'; import * as editorCommon from 'vs/editor/common/editorCommon'; import {editorAction, ServicesAccessor, EditorAction} from 'vs/editor/common/editorCommonExtensions'; @@ -456,7 +456,7 @@ export class DefineKeybindingAction extends EditorAction { id: DefineKeybindingAction.ID, label: nls.localize('DefineKeybindingAction',"Define Keybinding"), alias: 'Define Keybinding', - precondition: KbExpr.and(EditorContextKeys.Writable, EditorContextKeys.LanguageId.isEqualTo('json')), + precondition: ContextKeyExpr.and(EditorContextKeys.Writable, EditorContextKeys.LanguageId.isEqualTo('json')), kbOpts: { kbExpr: EditorContextKeys.TextFocus, primary: KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_K) diff --git a/src/vs/editor/contrib/find/common/findController.ts b/src/vs/editor/contrib/find/common/findController.ts index b8541c769af..69826b601ec 100644 --- a/src/vs/editor/contrib/find/common/findController.ts +++ b/src/vs/editor/contrib/find/common/findController.ts @@ -7,7 +7,7 @@ import * as nls from 'vs/nls'; import {KeyCode, KeyMod} from 'vs/base/common/keyCodes'; import {Disposable} from 'vs/base/common/lifecycle'; -import {KbExpr, KbCtxKey, IKeybindingContextKey, IContextKeyService} from 'vs/platform/contextkey/common/contextkey'; +import {ContextKeyExpr, KbCtxKey, IKeybindingContextKey, IContextKeyService} from 'vs/platform/contextkey/common/contextkey'; import {Range} from 'vs/editor/common/core/range'; import {Selection} from 'vs/editor/common/core/selection'; import * as strings from 'vs/base/common/strings'; @@ -34,7 +34,7 @@ export interface IFindStartOptions { } export const CONTEXT_FIND_WIDGET_VISIBLE = new KbCtxKey('findWidgetVisible', false); -export const CONTEXT_FIND_WIDGET_NOT_VISIBLE: KbExpr = CONTEXT_FIND_WIDGET_VISIBLE.toNegated(); +export const CONTEXT_FIND_WIDGET_NOT_VISIBLE: ContextKeyExpr = CONTEXT_FIND_WIDGET_VISIBLE.toNegated(); export class CommonFindController extends Disposable implements editorCommon.IEditorContribution { diff --git a/src/vs/editor/contrib/format/common/formatActions.ts b/src/vs/editor/contrib/format/common/formatActions.ts index 7641c2a3bec..00e17df4632 100644 --- a/src/vs/editor/contrib/format/common/formatActions.ts +++ b/src/vs/editor/contrib/format/common/formatActions.ts @@ -10,7 +10,7 @@ import {KeyCode, KeyMod} from 'vs/base/common/keyCodes'; import {IDisposable, dispose} from 'vs/base/common/lifecycle'; import {TPromise} from 'vs/base/common/winjs.base'; import * as editorCommon from 'vs/editor/common/editorCommon'; -import {KbExpr} from 'vs/platform/contextkey/common/contextkey'; +import {ContextKeyExpr} from 'vs/platform/contextkey/common/contextkey'; import {editorAction, ServicesAccessor, EditorAction, CommonEditorRegistry} from 'vs/editor/common/editorCommonExtensions'; import {OnTypeFormattingEditProviderRegistry} from 'vs/editor/common/modes'; import {getOnTypeFormattingEdits, getDocumentFormattingEdits, getDocumentRangeFormattingEdits} from '../common/format'; @@ -143,7 +143,7 @@ export class FormatAction extends EditorAction { id: 'editor.action.format', label: nls.localize('formatAction.label', "Format Code"), alias: 'Format Code', - precondition: KbExpr.and(EditorContextKeys.Writable, ModeContextKeys.hasFormattingProvider), + precondition: ContextKeyExpr.and(EditorContextKeys.Writable, ModeContextKeys.hasFormattingProvider), kbOpts: { kbExpr: EditorContextKeys.TextFocus, primary: KeyMod.Shift | KeyMod.Alt | KeyCode.KEY_F, diff --git a/src/vs/editor/contrib/goToDeclaration/browser/goToDeclaration.ts b/src/vs/editor/contrib/goToDeclaration/browser/goToDeclaration.ts index 6ce563b420f..e042897822c 100644 --- a/src/vs/editor/contrib/goToDeclaration/browser/goToDeclaration.ts +++ b/src/vs/editor/contrib/goToDeclaration/browser/goToDeclaration.ts @@ -30,7 +30,7 @@ import {ReferencesController} from 'vs/editor/contrib/referenceSearch/browser/re import {ReferencesModel} from 'vs/editor/contrib/referenceSearch/browser/referencesModel'; import {IDisposable, dispose} from 'vs/base/common/lifecycle'; import {PeekContext} from 'vs/editor/contrib/zoneWidget/browser/peekViewWidget'; -import {KbExpr} from 'vs/platform/contextkey/common/contextkey'; +import {ContextKeyExpr} from 'vs/platform/contextkey/common/contextkey'; import ModeContextKeys = editorCommon.ModeContextKeys; import EditorContextKeys = editorCommon.EditorContextKeys; @@ -195,7 +195,7 @@ export class PeekDefinitionAction extends DefinitionAction { id: 'editor.action.previewDeclaration', label: nls.localize('actions.previewDecl.label', "Peek Definition"), alias: 'Peek Definition', - precondition: KbExpr.and(ModeContextKeys.hasDefinitionProvider, PeekContext.notInPeekEditor), + precondition: ContextKeyExpr.and(ModeContextKeys.hasDefinitionProvider, PeekContext.notInPeekEditor), kbOpts: { kbExpr: EditorContextKeys.TextFocus, primary: KeyMod.Alt | KeyCode.F12, diff --git a/src/vs/editor/contrib/parameterHints/browser/parameterHints.ts b/src/vs/editor/contrib/parameterHints/browser/parameterHints.ts index 23c2d8d1ee9..307d3f89d7a 100644 --- a/src/vs/editor/contrib/parameterHints/browser/parameterHints.ts +++ b/src/vs/editor/contrib/parameterHints/browser/parameterHints.ts @@ -9,7 +9,7 @@ import { KeyCode, KeyMod } from 'vs/base/common/keyCodes'; import { dispose } from 'vs/base/common/lifecycle'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { ICommonCodeEditor, IEditorContribution, EditorContextKeys, ModeContextKeys } from 'vs/editor/common/editorCommon'; -import { KbExpr } from 'vs/platform/contextkey/common/contextkey'; +import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; import { editorAction, ServicesAccessor, EditorAction, EditorCommand, CommonEditorRegistry } from 'vs/editor/common/editorCommonExtensions'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { EditorBrowserRegistry } from 'vs/editor/browser/editorBrowserExtensions'; @@ -97,7 +97,7 @@ CommonEditorRegistry.registerEditorCommand(new ParameterHintsCommand({ })); CommonEditorRegistry.registerEditorCommand(new ParameterHintsCommand({ id: 'showPrevParameterHint', - precondition: KbExpr.and(Context.Visible, Context.MultipleSignatures), + precondition: ContextKeyExpr.and(Context.Visible, Context.MultipleSignatures), handler: x => x.previous(), kbOpts: { weight: weight, @@ -109,7 +109,7 @@ CommonEditorRegistry.registerEditorCommand(new ParameterHintsCommand({ })); CommonEditorRegistry.registerEditorCommand(new ParameterHintsCommand({ id: 'showNextParameterHint', - precondition: KbExpr.and(Context.Visible, Context.MultipleSignatures), + precondition: ContextKeyExpr.and(Context.Visible, Context.MultipleSignatures), handler: x => x.next(), kbOpts: { weight: weight, diff --git a/src/vs/editor/contrib/quickFix/browser/quickFix.ts b/src/vs/editor/contrib/quickFix/browser/quickFix.ts index 995f2a6176a..846b4c61ebc 100644 --- a/src/vs/editor/contrib/quickFix/browser/quickFix.ts +++ b/src/vs/editor/contrib/quickFix/browser/quickFix.ts @@ -9,7 +9,7 @@ import {onUnexpectedError} from 'vs/base/common/errors'; import {KeyCode, KeyMod} from 'vs/base/common/keyCodes'; import {IEditorService} from 'vs/platform/editor/common/editor'; import {ICommandService} from 'vs/platform/commands/common/commands'; -import {KbExpr, KbCtxKey, IKeybindingContextKey, IContextKeyService} from 'vs/platform/contextkey/common/contextkey'; +import {ContextKeyExpr, KbCtxKey, IKeybindingContextKey, IContextKeyService} from 'vs/platform/contextkey/common/contextkey'; import {IMarkerService} from 'vs/platform/markers/common/markers'; import {IMessageService} from 'vs/platform/message/common/message'; import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry'; @@ -122,7 +122,7 @@ export class QuickFixAction extends EditorAction { id: 'editor.action.quickFix', label: nls.localize('quickfix.trigger.label', "Quick Fix"), alias: 'Quick Fix', - precondition: KbExpr.and(EditorContextKeys.Writable, ModeContextKeys.hasCodeActionsProvider), + precondition: ContextKeyExpr.and(EditorContextKeys.Writable, ModeContextKeys.hasCodeActionsProvider), kbOpts: { kbExpr: EditorContextKeys.TextFocus, primary: KeyMod.CtrlCmd | KeyCode.US_DOT diff --git a/src/vs/editor/contrib/referenceSearch/browser/referenceSearch.ts b/src/vs/editor/contrib/referenceSearch/browser/referenceSearch.ts index 0c3c8e5a64b..bf8f97a3e81 100644 --- a/src/vs/editor/contrib/referenceSearch/browser/referenceSearch.ts +++ b/src/vs/editor/contrib/referenceSearch/browser/referenceSearch.ts @@ -11,7 +11,7 @@ import {TPromise} from 'vs/base/common/winjs.base'; import {IEditorService} from 'vs/platform/editor/common/editor'; import {optional} from 'vs/platform/instantiation/common/instantiation'; import {CommandsRegistry, ICommandHandler} from 'vs/platform/commands/common/commands'; -import {IContextKeyService, KbExpr} from 'vs/platform/contextkey/common/contextkey'; +import {IContextKeyService, ContextKeyExpr} from 'vs/platform/contextkey/common/contextkey'; import {KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry'; import {Position} from 'vs/editor/common/core/position'; import {Range} from 'vs/editor/common/core/range'; @@ -62,7 +62,7 @@ export class ReferenceAction extends EditorAction { id: 'editor.action.referenceSearch.trigger', label: nls.localize('references.action.label', "Find All References"), alias: 'Find All References', - precondition: KbExpr.and(ModeContextKeys.hasReferenceProvider, PeekContext.notInPeekEditor), + precondition: ContextKeyExpr.and(ModeContextKeys.hasReferenceProvider, PeekContext.notInPeekEditor), kbOpts: { kbExpr: EditorContextKeys.TextFocus, primary: KeyMod.Shift | KeyCode.F12 @@ -160,7 +160,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ weight: CommonEditorRegistry.commandWeight(50), primary: KeyCode.Escape, secondary: [KeyMod.Shift | KeyCode.Escape], - when: KbExpr.and(ctxReferenceSearchVisible, KbExpr.not('config.editor.stablePeek')), + when: ContextKeyExpr.and(ctxReferenceSearchVisible, ContextKeyExpr.not('config.editor.stablePeek')), handler: closeActiveReferenceSearch }); @@ -169,6 +169,6 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ weight: CommonEditorRegistry.commandWeight(-101), primary: KeyCode.Escape, secondary: [KeyMod.Shift | KeyCode.Escape], - when: KbExpr.and(PeekContext.inPeekEditor, KbExpr.not('config.editor.stablePeek')), + when: ContextKeyExpr.and(PeekContext.inPeekEditor, ContextKeyExpr.not('config.editor.stablePeek')), handler: closeActiveReferenceSearch }); diff --git a/src/vs/editor/contrib/rename/browser/rename.ts b/src/vs/editor/contrib/rename/browser/rename.ts index 59f19d24f3d..df0e0089d40 100644 --- a/src/vs/editor/contrib/rename/browser/rename.ts +++ b/src/vs/editor/contrib/rename/browser/rename.ts @@ -12,7 +12,7 @@ import Severity from 'vs/base/common/severity'; import {TPromise} from 'vs/base/common/winjs.base'; import {IEditorService} from 'vs/platform/editor/common/editor'; import {IEventService} from 'vs/platform/event/common/event'; -import {KbCtxKey, IKeybindingContextKey, IContextKeyService, KbExpr} from 'vs/platform/contextkey/common/contextkey'; +import {KbCtxKey, IKeybindingContextKey, IContextKeyService, ContextKeyExpr} from 'vs/platform/contextkey/common/contextkey'; import {IMessageService} from 'vs/platform/message/common/message'; import {IProgressService} from 'vs/platform/progress/common/progress'; import {editorAction, ServicesAccessor, EditorAction, EditorCommand, CommonEditorRegistry} from 'vs/editor/common/editorCommonExtensions'; @@ -153,7 +153,7 @@ export class RenameAction extends EditorAction { id: 'editor.action.rename', label: nls.localize('rename.label', "Rename Symbol"), alias: 'Rename Symbol', - precondition: KbExpr.and(EditorContextKeys.Writable, ModeContextKeys.hasRenameProvider), + precondition: ContextKeyExpr.and(EditorContextKeys.Writable, ModeContextKeys.hasRenameProvider), kbOpts: { kbExpr: EditorContextKeys.TextFocus, primary: KeyCode.F2 diff --git a/src/vs/editor/contrib/suggest/browser/suggest.ts b/src/vs/editor/contrib/suggest/browser/suggest.ts index 6fb484d5490..03813ba9f6f 100644 --- a/src/vs/editor/contrib/suggest/browser/suggest.ts +++ b/src/vs/editor/contrib/suggest/browser/suggest.ts @@ -8,7 +8,7 @@ import * as nls from 'vs/nls'; import { KeyCode, KeyMod } from 'vs/base/common/keyCodes'; import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; -import { KbExpr } from 'vs/platform/contextkey/common/contextkey'; +import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; import { ICommonCodeEditor, IEditorContribution, EditorContextKeys, ModeContextKeys } from 'vs/editor/common/editorCommon'; import { editorAction, ServicesAccessor, EditorAction, EditorCommand, CommonEditorRegistry } from 'vs/editor/common/editorCommonExtensions'; import { ISuggestSupport, SuggestRegistry } from 'vs/editor/common/modes'; @@ -175,7 +175,7 @@ export class TriggerSuggestAction extends EditorAction { id: 'editor.action.triggerSuggest', label: nls.localize('suggest.trigger.label', "Trigger Suggest"), alias: 'Trigger Suggest', - precondition: KbExpr.and(EditorContextKeys.Writable, ModeContextKeys.hasCompletionItemProvider), + precondition: ContextKeyExpr.and(EditorContextKeys.Writable, ModeContextKeys.hasCompletionItemProvider), kbOpts: { kbExpr: EditorContextKeys.TextFocus, primary: KeyMod.CtrlCmd | KeyCode.Space, @@ -211,7 +211,7 @@ CommonEditorRegistry.registerEditorCommand(new SuggestCommand({ handler: x => x.acceptSelectedSuggestion(), kbOpts: { weight: weight, - kbExpr: KbExpr.and(EditorContextKeys.TextFocus, KbExpr.has('config.editor.acceptSuggestionOnEnter')), + kbExpr: ContextKeyExpr.and(EditorContextKeys.TextFocus, ContextKeyExpr.has('config.editor.acceptSuggestionOnEnter')), primary: KeyCode.Enter } })); @@ -230,7 +230,7 @@ CommonEditorRegistry.registerEditorCommand(new SuggestCommand({ CommonEditorRegistry.registerEditorCommand(new SuggestCommand({ id: 'selectNextSuggestion', - precondition: KbExpr.and(SuggestContext.Visible, SuggestContext.MultipleSuggestions), + precondition: ContextKeyExpr.and(SuggestContext.Visible, SuggestContext.MultipleSuggestions), handler: c => c.selectNextSuggestion(), kbOpts: { weight: weight, @@ -243,7 +243,7 @@ CommonEditorRegistry.registerEditorCommand(new SuggestCommand({ CommonEditorRegistry.registerEditorCommand(new SuggestCommand({ id: 'selectNextPageSuggestion', - precondition: KbExpr.and(SuggestContext.Visible, SuggestContext.MultipleSuggestions), + precondition: ContextKeyExpr.and(SuggestContext.Visible, SuggestContext.MultipleSuggestions), handler: c => c.selectNextPageSuggestion(), kbOpts: { weight: weight, @@ -255,7 +255,7 @@ CommonEditorRegistry.registerEditorCommand(new SuggestCommand({ CommonEditorRegistry.registerEditorCommand(new SuggestCommand({ id: 'selectPrevSuggestion', - precondition: KbExpr.and(SuggestContext.Visible, SuggestContext.MultipleSuggestions), + precondition: ContextKeyExpr.and(SuggestContext.Visible, SuggestContext.MultipleSuggestions), handler: c => c.selectPrevSuggestion(), kbOpts: { weight: weight, @@ -268,7 +268,7 @@ CommonEditorRegistry.registerEditorCommand(new SuggestCommand({ CommonEditorRegistry.registerEditorCommand(new SuggestCommand({ id: 'selectPrevPageSuggestion', - precondition: KbExpr.and(SuggestContext.Visible, SuggestContext.MultipleSuggestions), + precondition: ContextKeyExpr.and(SuggestContext.Visible, SuggestContext.MultipleSuggestions), handler: c => c.selectPrevPageSuggestion(), kbOpts: { weight: weight, diff --git a/src/vs/editor/contrib/suggest/browser/tabCompletion.ts b/src/vs/editor/contrib/suggest/browser/tabCompletion.ts index f9b137057ad..1736fd31fc5 100644 --- a/src/vs/editor/contrib/suggest/browser/tabCompletion.ts +++ b/src/vs/editor/contrib/suggest/browser/tabCompletion.ts @@ -6,7 +6,7 @@ 'use strict'; import {KeyCode} from 'vs/base/common/keyCodes'; -import {KbCtxKey, IContextKeyService, KbExpr} from 'vs/platform/contextkey/common/contextkey'; +import {KbCtxKey, IContextKeyService, ContextKeyExpr} from 'vs/platform/contextkey/common/contextkey'; import {KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry'; import {ISnippetsRegistry, Extensions, getNonWhitespacePrefix, ISnippet} from 'vs/editor/common/modes/snippetsRegistry'; import {Registry} from 'vs/platform/platform'; @@ -87,10 +87,10 @@ CommonEditorRegistry.registerEditorCommand(new TabCompletionCommand({ handler: x => x.performSnippetCompletions(), kbOpts: { weight: KeybindingsRegistry.WEIGHT.editorContrib(), - kbExpr: KbExpr.and( + kbExpr: ContextKeyExpr.and( EditorContextKeys.TextFocus, EditorContextKeys.TabDoesNotMoveFocus, - KbExpr.has('config.editor.tabCompletion') + ContextKeyExpr.has('config.editor.tabCompletion') ), primary: KeyCode.Tab } diff --git a/src/vs/editor/contrib/zoneWidget/browser/peekViewWidget.ts b/src/vs/editor/contrib/zoneWidget/browser/peekViewWidget.ts index 52df1840c64..069a0715b6c 100644 --- a/src/vs/editor/contrib/zoneWidget/browser/peekViewWidget.ts +++ b/src/vs/editor/contrib/zoneWidget/browser/peekViewWidget.ts @@ -19,13 +19,13 @@ import {ICodeEditorService} from 'vs/editor/common/services/codeEditorService'; import {ICodeEditor} from 'vs/editor/browser/editorBrowser'; import {IOptions, ZoneWidget} from './zoneWidget'; import {EmbeddedCodeEditorWidget} from 'vs/editor/browser/widget/embeddedCodeEditorWidget'; -import {KbExpr, KbCtxKey} from 'vs/platform/contextkey/common/contextkey'; +import {ContextKeyExpr, KbCtxKey} from 'vs/platform/contextkey/common/contextkey'; export var IPeekViewService = createDecorator('peekViewService'); export namespace PeekContext { export const inPeekEditor = new KbCtxKey('inReferenceSearchEditor', true); - export const notInPeekEditor:KbExpr = inPeekEditor.toNegated(); + export const notInPeekEditor:ContextKeyExpr = inPeekEditor.toNegated(); } export const NOT_INNER_EDITOR_CONTEXT_KEY = new KbCtxKey('inReferenceSearchEditor', true); diff --git a/src/vs/platform/actions/browser/menusExtensionPoint.ts b/src/vs/platform/actions/browser/menusExtensionPoint.ts index 7be271a09c1..3eb906cc83d 100644 --- a/src/vs/platform/actions/browser/menusExtensionPoint.ts +++ b/src/vs/platform/actions/browser/menusExtensionPoint.ts @@ -11,7 +11,7 @@ import {IdGenerator} from 'vs/base/common/idGenerator'; import {IJSONSchema} from 'vs/base/common/jsonSchema'; import {forEach} from 'vs/base/common/collections'; import {IExtensionPointUser, IExtensionMessageCollector, ExtensionsRegistry} from 'vs/platform/extensions/common/extensionsRegistry'; -import {KbExpr} from 'vs/platform/contextkey/common/contextkey'; +import {ContextKeyExpr} from 'vs/platform/contextkey/common/contextkey'; import {MenuId, MenuRegistry} from 'vs/platform/actions/common/actions'; namespace schema { @@ -294,7 +294,7 @@ ExtensionsRegistry.registerExtensionPoint<{ [loc: string]: schema.IUserFriendlyM alt, group, order, - when: KbExpr.deserialize(item.when) + when: ContextKeyExpr.deserialize(item.when) }); } }); diff --git a/src/vs/platform/actions/common/actions.ts b/src/vs/platform/actions/common/actions.ts index 9868febb045..5e8e2c26a78 100644 --- a/src/vs/platform/actions/common/actions.ts +++ b/src/vs/platform/actions/common/actions.ts @@ -10,7 +10,7 @@ import WinJS = require('vs/base/common/winjs.base'); import Descriptors = require('vs/platform/instantiation/common/descriptors'); import Instantiation = require('vs/platform/instantiation/common/instantiation'); import {IKeybindings} from 'vs/platform/keybinding/common/keybinding'; -import {KbExpr, IContextKeyService} from 'vs/platform/contextkey/common/contextkey'; +import {ContextKeyExpr, IContextKeyService} from 'vs/platform/contextkey/common/contextkey'; import {ICommandService} from 'vs/platform/commands/common/commands'; import {IDisposable} from 'vs/base/common/lifecycle'; import {createDecorator} from 'vs/platform/instantiation/common/instantiation'; @@ -31,7 +31,7 @@ export interface IMenu extends IDisposable { export interface IMenuItem { command: ICommandAction; alt?: ICommandAction; - when?: KbExpr; + when?: ContextKeyExpr; group?: 'navigation' | string; order?: number; } @@ -170,11 +170,11 @@ export class SyncActionDescriptor { private _id: string; private _label: string; private _keybindings: IKeybindings; - private _keybindingContext: KbExpr; + private _keybindingContext: ContextKeyExpr; private _keybindingWeight: number; constructor(ctor: Instantiation.IConstructorSignature2, - id: string, label: string, keybindings?: IKeybindings, keybindingContext?: KbExpr, keybindingWeight?: number + id: string, label: string, keybindings?: IKeybindings, keybindingContext?: ContextKeyExpr, keybindingWeight?: number ) { this._id = id; this._label = label; @@ -200,7 +200,7 @@ export class SyncActionDescriptor { return this._keybindings; } - public get keybindingContext(): KbExpr { + public get keybindingContext(): ContextKeyExpr { return this._keybindingContext; } diff --git a/src/vs/platform/actions/common/menuService.ts b/src/vs/platform/actions/common/menuService.ts index fac85f3e42d..8bcfe379130 100644 --- a/src/vs/platform/actions/common/menuService.ts +++ b/src/vs/platform/actions/common/menuService.ts @@ -9,7 +9,7 @@ import Event, {Emitter} from 'vs/base/common/event'; import {IDisposable, dispose} from 'vs/base/common/lifecycle'; import {IAction} from 'vs/base/common/actions'; import {values} from 'vs/base/common/collections'; -import {KbExpr, IContextKeyService} from 'vs/platform/contextkey/common/contextkey'; +import {ContextKeyExpr, IContextKeyService} from 'vs/platform/contextkey/common/contextkey'; import {MenuId, MenuRegistry, ICommandAction, MenuItemAction, IMenu, IMenuItem, IMenuService} from 'vs/platform/actions/common/actions'; import {IExtensionService} from 'vs/platform/extensions/common/extensions'; import {ICommandService} from 'vs/platform/commands/common/commands'; @@ -111,7 +111,7 @@ class Menu implements IMenu { return result; } - private static _fillInKbExprKeys(exp: KbExpr, set: { [k: string]: boolean }): void { + private static _fillInKbExprKeys(exp: ContextKeyExpr, set: { [k: string]: boolean }): void { if (exp) { for (let key of exp.keys()) { set[key] = true; diff --git a/src/vs/platform/contextkey/browser/contextKeyService.ts b/src/vs/platform/contextkey/browser/contextKeyService.ts index 89ec6a18da2..43ec478167c 100644 --- a/src/vs/platform/contextkey/browser/contextKeyService.ts +++ b/src/vs/platform/contextkey/browser/contextKeyService.ts @@ -7,7 +7,7 @@ import {IDisposable, dispose} from 'vs/base/common/lifecycle'; import {CommandsRegistry} from 'vs/platform/commands/common/commands'; import {KeybindingResolver} from 'vs/platform/keybinding/common/keybindingResolver'; -import {IKeybindingContextKey, IKeybindingScopeLocation, IContextKeyService, SET_CONTEXT_COMMAND_ID, KEYBINDING_CONTEXT_ATTR, KbExpr} from 'vs/platform/contextkey/common/contextkey'; +import {IKeybindingContextKey, IKeybindingScopeLocation, IContextKeyService, SET_CONTEXT_COMMAND_ID, KEYBINDING_CONTEXT_ATTR, ContextKeyExpr} from 'vs/platform/contextkey/common/contextkey'; import {IConfigurationService} from 'vs/platform/configuration/common/configuration'; import Event, {Emitter, debounceEvent} from 'vs/base/common/event'; @@ -166,7 +166,7 @@ export abstract class AbstractKeybindingService { return new ScopedKeybindingService(this, this._onDidChangeContextKey, domNode); } - public contextMatchesRules(rules: KbExpr): boolean { + public contextMatchesRules(rules: ContextKeyExpr): boolean { const ctx = Object.create(null); this.getContext(this._myContextId).fillInContext(ctx); const result = KeybindingResolver.contextMatchesRules(ctx, rules); diff --git a/src/vs/platform/contextkey/common/contextkey.ts b/src/vs/platform/contextkey/common/contextkey.ts index c3657d6b7db..68cbf5712d6 100644 --- a/src/vs/platform/contextkey/common/contextkey.ts +++ b/src/vs/platform/contextkey/common/contextkey.ts @@ -17,16 +17,16 @@ export enum KbExprType { KbAndExpression = 5 } -export interface KbExpr { +export interface ContextKeyExpr { getType(): KbExprType; - equals(other: KbExpr): boolean; + equals(other: ContextKeyExpr): boolean; evaluate(context: any): boolean; - normalize(): KbExpr; + normalize(): ContextKeyExpr; serialize(): string; keys(): string[]; } -function cmp(a:KbExpr, b:KbExpr): number { +function cmp(a:ContextKeyExpr, b:ContextKeyExpr): number { let aType = a.getType(); let bType = b.getType(); if (aType !== bType) { @@ -42,11 +42,11 @@ function cmp(a:KbExpr, b:KbExpr): number { case KbExprType.KbNotEqualsExpression: return (a).cmp(b); default: - throw new Error('Unknown KbExpr!'); + throw new Error('Unknown ContextKeyExpr!'); } } -export class KbDefinedExpression implements KbExpr { +export class KbDefinedExpression implements ContextKeyExpr { constructor(protected key: string) { } @@ -64,7 +64,7 @@ export class KbDefinedExpression implements KbExpr { return 0; } - public equals(other: KbExpr): boolean { + public equals(other: ContextKeyExpr): boolean { if (other instanceof KbDefinedExpression) { return (this.key === other.key); } @@ -75,7 +75,7 @@ export class KbDefinedExpression implements KbExpr { return (!!context[this.key]); } - public normalize(): KbExpr { + public normalize(): ContextKeyExpr { return this; } @@ -88,7 +88,7 @@ export class KbDefinedExpression implements KbExpr { } } -export class KbEqualsExpression implements KbExpr { +export class KbEqualsExpression implements ContextKeyExpr { constructor(private key: string, private value: any) { } @@ -112,7 +112,7 @@ export class KbEqualsExpression implements KbExpr { return 0; } - public equals(other: KbExpr): boolean { + public equals(other: ContextKeyExpr): boolean { if (other instanceof KbEqualsExpression) { return (this.key === other.key && this.value === other.value); } @@ -126,7 +126,7 @@ export class KbEqualsExpression implements KbExpr { /* tslint:enable:triple-equals */ } - public normalize(): KbExpr { + public normalize(): ContextKeyExpr { if (typeof this.value === 'boolean') { if (this.value) { return new KbDefinedExpression(this.key); @@ -149,7 +149,7 @@ export class KbEqualsExpression implements KbExpr { } } -export class KbNotEqualsExpression implements KbExpr { +export class KbNotEqualsExpression implements ContextKeyExpr { constructor(private key: string, private value: any) { } @@ -173,7 +173,7 @@ export class KbNotEqualsExpression implements KbExpr { return 0; } - public equals(other: KbExpr): boolean { + public equals(other: ContextKeyExpr): boolean { if (other instanceof KbNotEqualsExpression) { return (this.key === other.key && this.value === other.value); } @@ -187,7 +187,7 @@ export class KbNotEqualsExpression implements KbExpr { /* tslint:enable:triple-equals */ } - public normalize(): KbExpr { + public normalize(): ContextKeyExpr { if (typeof this.value === 'boolean') { if (this.value) { return new KbNotExpression(this.key); @@ -210,7 +210,7 @@ export class KbNotEqualsExpression implements KbExpr { } } -export class KbNotExpression implements KbExpr { +export class KbNotExpression implements ContextKeyExpr { constructor(private key: string) { } @@ -228,7 +228,7 @@ export class KbNotExpression implements KbExpr { return 0; } - public equals(other: KbExpr): boolean { + public equals(other: ContextKeyExpr): boolean { if (other instanceof KbNotExpression) { return (this.key === other.key); } @@ -239,7 +239,7 @@ export class KbNotExpression implements KbExpr { return (!context[this.key]); } - public normalize(): KbExpr { + public normalize(): ContextKeyExpr { return this; } @@ -252,10 +252,10 @@ export class KbNotExpression implements KbExpr { } } -export class KbAndExpression implements KbExpr { - private expr: KbExpr[]; +export class KbAndExpression implements ContextKeyExpr { + private expr: ContextKeyExpr[]; - constructor(expr: KbExpr[]) { + constructor(expr: ContextKeyExpr[]) { this.expr = KbAndExpression._normalizeArr(expr); } @@ -263,7 +263,7 @@ export class KbAndExpression implements KbExpr { return KbExprType.KbAndExpression; } - public equals(other: KbExpr): boolean { + public equals(other: ContextKeyExpr): boolean { if (other instanceof KbAndExpression) { if (this.expr.length !== other.expr.length) { return false; @@ -286,8 +286,8 @@ export class KbAndExpression implements KbExpr { return true; } - private static _normalizeArr(arr:KbExpr[]): KbExpr[] { - let expr: KbExpr[] = []; + private static _normalizeArr(arr:ContextKeyExpr[]): ContextKeyExpr[] { + let expr: ContextKeyExpr[] = []; if (arr) { for (let i = 0, len = arr.length; i < len; i++) { @@ -315,7 +315,7 @@ export class KbAndExpression implements KbExpr { return expr; } - public normalize(): KbExpr { + public normalize(): ContextKeyExpr { if (this.expr.length === 0) { return null; } @@ -363,42 +363,42 @@ export class KbCtxKey extends KbDefinedExpression { return target.getContextValue(this.key); } - public toNegated(): KbExpr { - return KbExpr.not(this.key); + public toNegated(): ContextKeyExpr { + return ContextKeyExpr.not(this.key); } - public isEqualTo(value:string): KbExpr { - return KbExpr.equals(this.key, value); + public isEqualTo(value:string): ContextKeyExpr { + return ContextKeyExpr.equals(this.key, value); } } -export let KbExpr = { +export let ContextKeyExpr = { has: (key: string) => new KbDefinedExpression(key), equals: (key: string, value: any) => new KbEqualsExpression(key, value), notEquals: (key: string, value: any) => new KbNotEqualsExpression(key, value), not: (key: string) => new KbNotExpression(key), - and: (...expr: KbExpr[]) => new KbAndExpression(expr), - deserialize: (serialized: string): KbExpr => { + and: (...expr: ContextKeyExpr[]) => new KbAndExpression(expr), + deserialize: (serialized: string): ContextKeyExpr => { if (!serialized) { return null; } let pieces = serialized.split('&&'); - let result = new KbAndExpression(pieces.map(p => KbExpr._deserializeOne(p))); + let result = new KbAndExpression(pieces.map(p => ContextKeyExpr._deserializeOne(p))); return result.normalize(); }, - _deserializeOne: (serializedOne: string): KbExpr => { + _deserializeOne: (serializedOne: string): ContextKeyExpr => { serializedOne = serializedOne.trim(); if (serializedOne.indexOf('!=') >= 0) { let pieces = serializedOne.split('!='); - return new KbNotEqualsExpression(pieces[0].trim(), KbExpr._deserializeValue(pieces[1])); + return new KbNotEqualsExpression(pieces[0].trim(), ContextKeyExpr._deserializeValue(pieces[1])); } if (serializedOne.indexOf('==') >= 0) { let pieces = serializedOne.split('=='); - return new KbEqualsExpression(pieces[0].trim(), KbExpr._deserializeValue(pieces[1])); + return new KbEqualsExpression(pieces[0].trim(), ContextKeyExpr._deserializeValue(pieces[1])); } if (/^\!\s*/.test(serializedOne)) { @@ -451,7 +451,7 @@ export interface IContextKeyService { onDidChangeContext: Event; createKey(key: string, defaultValue: T): IKeybindingContextKey; - contextMatchesRules(rules: KbExpr): boolean; + contextMatchesRules(rules: ContextKeyExpr): boolean; getContextValue(key: string): T; createScoped(domNode: IKeybindingScopeLocation): IContextKeyService; diff --git a/src/vs/platform/keybinding/common/keybinding.ts b/src/vs/platform/keybinding/common/keybinding.ts index d7f598743d5..cd8ba979a02 100644 --- a/src/vs/platform/keybinding/common/keybinding.ts +++ b/src/vs/platform/keybinding/common/keybinding.ts @@ -7,7 +7,7 @@ import {IHTMLContentElement} from 'vs/base/common/htmlContent'; import {Keybinding} from 'vs/base/common/keyCodes'; import {createDecorator} from 'vs/platform/instantiation/common/instantiation'; -import {KbExpr} from 'vs/platform/contextkey/common/contextkey'; +import {ContextKeyExpr} from 'vs/platform/contextkey/common/contextkey'; export interface IUserFriendlyKeybinding { key: string; @@ -35,7 +35,7 @@ export interface IKeybindings { export interface IKeybindingItem { keybinding: number; command: string; - when: KbExpr; + when: ContextKeyExpr; weight1: number; weight2: number; } diff --git a/src/vs/platform/keybinding/common/keybindingResolver.ts b/src/vs/platform/keybinding/common/keybindingResolver.ts index 0e2691b8c12..b88d37524e2 100644 --- a/src/vs/platform/keybinding/common/keybindingResolver.ts +++ b/src/vs/platform/keybinding/common/keybindingResolver.ts @@ -7,7 +7,7 @@ import {BinaryKeybindings, ISimplifiedPlatform, Keybinding} from 'vs/base/common/keyCodes'; import * as platform from 'vs/base/common/platform'; import {IKeybindingItem, IUserFriendlyKeybinding} from 'vs/platform/keybinding/common/keybinding'; -import {KbExpr} from 'vs/platform/contextkey/common/contextkey'; +import {ContextKeyExpr} from 'vs/platform/contextkey/common/contextkey'; export interface IResolveResult { enterChord: number; @@ -27,7 +27,7 @@ interface IChordsMap { } interface ICommandEntry { - when: KbExpr; + when: ContextKeyExpr; keybinding: number; commandId: string; } @@ -35,19 +35,19 @@ interface ICommandEntry { export class NormalizedKeybindingItem { keybinding: number; command: string; - when: KbExpr; + when: ContextKeyExpr; isDefault: boolean; actualCommand: string; public static fromKeybindingItem(source:IKeybindingItem, isDefault:boolean): NormalizedKeybindingItem { - let when: KbExpr = null; + let when: ContextKeyExpr = null; if (source.when) { when = source.when.normalize(); } return new NormalizedKeybindingItem(source.keybinding, source.command, when, isDefault); } - constructor(keybinding: number, command: string, when: KbExpr, isDefault: boolean) { + constructor(keybinding: number, command: string, when: ContextKeyExpr, isDefault: boolean) { this.keybinding = keybinding; this.command = command; this.actualCommand = this.command ? this.command.replace(/^\^/, '') : this.command; @@ -117,7 +117,7 @@ export class KeybindingResolver { } } - private static _isTargetedForRemoval(defaultKb:NormalizedKeybindingItem, keybinding:number, command:string, when:KbExpr): boolean { + private static _isTargetedForRemoval(defaultKb:NormalizedKeybindingItem, keybinding:number, command:string, when:ContextKeyExpr): boolean { if (defaultKb.actualCommand !== command) { return false; } @@ -202,7 +202,7 @@ export class KeybindingResolver { * Returns true if `b` is a more relaxed `a`. * Return true if (`a` === true implies `b` === true). */ - public static whenIsEntirelyIncluded(inNormalizedForm: boolean, a: KbExpr, b: KbExpr): boolean { + public static whenIsEntirelyIncluded(inNormalizedForm: boolean, a: ContextKeyExpr, b: ContextKeyExpr): boolean { if (!inNormalizedForm) { a = a ? a.normalize() : null; b = b ? b.normalize() : null; @@ -340,7 +340,7 @@ export class KeybindingResolver { return null; } - public static contextMatchesRules(context: any, rules: KbExpr): boolean { + public static contextMatchesRules(context: any, rules: ContextKeyExpr): boolean { if (!rules) { return true; } @@ -427,7 +427,7 @@ export class IOSupport { return Keybinding.fromUserSettingsLabel(input, Platform); } - public static readKeybindingWhen(input: string): KbExpr { - return KbExpr.deserialize(input); + public static readKeybindingWhen(input: string): ContextKeyExpr { + return ContextKeyExpr.deserialize(input); } } diff --git a/src/vs/platform/keybinding/common/keybindingsRegistry.ts b/src/vs/platform/keybinding/common/keybindingsRegistry.ts index cb74e5bec7f..19317b58b28 100644 --- a/src/vs/platform/keybinding/common/keybindingsRegistry.ts +++ b/src/vs/platform/keybinding/common/keybindingsRegistry.ts @@ -7,14 +7,14 @@ import {BinaryKeybindings, KeyCode} from 'vs/base/common/keyCodes'; import * as platform from 'vs/base/common/platform'; import {IKeybindingItem, IKeybindings} from 'vs/platform/keybinding/common/keybinding'; -import {KbExpr} from 'vs/platform/contextkey/common/contextkey'; +import {ContextKeyExpr} from 'vs/platform/contextkey/common/contextkey'; import {CommandsRegistry, ICommandHandler, ICommandHandlerDescription} from 'vs/platform/commands/common/commands'; import {Registry} from 'vs/platform/platform'; export interface IKeybindingRule extends IKeybindings { id: string; weight: number; - when: KbExpr; + when: ContextKeyExpr; } export interface ICommandAndKeybindingRule extends IKeybindingRule { @@ -102,7 +102,7 @@ class KeybindingsRegistryImpl implements IKeybindingsRegistry { CommandsRegistry.registerCommand(desc.id, desc); } - private registerDefaultKeybinding(keybinding: number, commandId: string, weight1: number, weight2: number, when: KbExpr): void { + private registerDefaultKeybinding(keybinding: number, commandId: string, weight1: number, weight2: number, when: ContextKeyExpr): void { if (platform.isWindows) { if (BinaryKeybindings.hasCtrlCmd(keybinding) && !BinaryKeybindings.hasShift(keybinding) && BinaryKeybindings.hasAlt(keybinding) && !BinaryKeybindings.hasWinCtrl(keybinding)) { if (/^[A-Z0-9\[\]\|\;\'\,\.\/\`]$/.test(KeyCode.toString(BinaryKeybindings.extractKeyCode(keybinding)))) { diff --git a/src/vs/platform/keybinding/test/common/keybindingService.test.ts b/src/vs/platform/keybinding/test/common/keybindingService.test.ts index 40c308feced..e7226da9553 100644 --- a/src/vs/platform/keybinding/test/common/keybindingService.test.ts +++ b/src/vs/platform/keybinding/test/common/keybindingService.test.ts @@ -8,13 +8,13 @@ import * as assert from 'assert'; import {BinaryKeybindings, KeyCode, KeyMod} from 'vs/base/common/keyCodes'; import {IOSupport, KeybindingResolver, NormalizedKeybindingItem} from 'vs/platform/keybinding/common/keybindingResolver'; import {IKeybindingItem} from 'vs/platform/keybinding/common/keybinding'; -import {KbAndExpression, KbExpr} from 'vs/platform/contextkey/common/contextkey'; +import {KbAndExpression, ContextKeyExpr} from 'vs/platform/contextkey/common/contextkey'; suite('Keybinding Service', () => { test('resolve key', function() { let keybinding = KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_Z; - let contextRules = KbExpr.equals('bar', 'baz'); + let contextRules = ContextKeyExpr.equals('bar', 'baz'); let keybindingItem: IKeybindingItem = { command: 'yes', when: contextRules, @@ -32,27 +32,27 @@ suite('Keybinding Service', () => { }); test('KbAndExpression.equals', function() { - let a = KbExpr.and( - KbExpr.has('a1'), - KbExpr.and(KbExpr.has('and.a')), - KbExpr.has('a2'), - KbExpr.equals('b1', 'bb1'), - KbExpr.equals('b2', 'bb2'), - KbExpr.notEquals('c1', 'cc1'), - KbExpr.notEquals('c2', 'cc2'), - KbExpr.not('d1'), - KbExpr.not('d2') + let a = ContextKeyExpr.and( + ContextKeyExpr.has('a1'), + ContextKeyExpr.and(ContextKeyExpr.has('and.a')), + ContextKeyExpr.has('a2'), + ContextKeyExpr.equals('b1', 'bb1'), + ContextKeyExpr.equals('b2', 'bb2'), + ContextKeyExpr.notEquals('c1', 'cc1'), + ContextKeyExpr.notEquals('c2', 'cc2'), + ContextKeyExpr.not('d1'), + ContextKeyExpr.not('d2') ); - let b = KbExpr.and( - KbExpr.equals('b2', 'bb2'), - KbExpr.notEquals('c1', 'cc1'), - KbExpr.not('d1'), - KbExpr.notEquals('c2', 'cc2'), - KbExpr.has('a2'), - KbExpr.equals('b1', 'bb1'), - KbExpr.has('a1'), - KbExpr.and(KbExpr.equals('and.a', true)), - KbExpr.not('d2') + let b = ContextKeyExpr.and( + ContextKeyExpr.equals('b2', 'bb2'), + ContextKeyExpr.notEquals('c1', 'cc1'), + ContextKeyExpr.not('d1'), + ContextKeyExpr.notEquals('c2', 'cc2'), + ContextKeyExpr.has('a2'), + ContextKeyExpr.equals('b1', 'bb1'), + ContextKeyExpr.has('a1'), + ContextKeyExpr.and(ContextKeyExpr.equals('and.a', true)), + ContextKeyExpr.not('d2') ); assert(a.equals(b), 'expressions should be equal'); }); @@ -60,174 +60,174 @@ suite('Keybinding Service', () => { test('KeybindingResolver.combine simple 1', function() { let defaults:IKeybindingItem[] = [{ command: 'yes1', - when: KbExpr.equals('1', 'a'), + when: ContextKeyExpr.equals('1', 'a'), keybinding: KeyCode.KEY_A, weight1: 0, weight2: 0 }]; let overrides:IKeybindingItem[] = [{ command: 'yes2', - when: KbExpr.equals('2', 'b'), + when: ContextKeyExpr.equals('2', 'b'), keybinding: KeyCode.KEY_B, weight1: 0, weight2: 0 }]; let actual = KeybindingResolver.combine(defaults, overrides); assert.deepEqual(actual, [ - new NormalizedKeybindingItem(KeyCode.KEY_A, 'yes1', KbExpr.equals('1', 'a'), true), - new NormalizedKeybindingItem(KeyCode.KEY_B, 'yes2', KbExpr.equals('2', 'b'), false), + new NormalizedKeybindingItem(KeyCode.KEY_A, 'yes1', ContextKeyExpr.equals('1', 'a'), true), + new NormalizedKeybindingItem(KeyCode.KEY_B, 'yes2', ContextKeyExpr.equals('2', 'b'), false), ]); }); test('KeybindingResolver.combine simple 2', function() { let defaults:IKeybindingItem[] = [{ command: 'yes1', - when: KbExpr.equals('1', 'a'), + when: ContextKeyExpr.equals('1', 'a'), keybinding: KeyCode.KEY_A, weight1: 0, weight2: 0 }, { command: 'yes2', - when: KbExpr.equals('2', 'b'), + when: ContextKeyExpr.equals('2', 'b'), keybinding: KeyCode.KEY_B, weight1: 0, weight2: 0 }]; let overrides:IKeybindingItem[] = [{ command: 'yes3', - when: KbExpr.equals('3', 'c'), + when: ContextKeyExpr.equals('3', 'c'), keybinding: KeyCode.KEY_C, weight1: 0, weight2: 0 }]; let actual = KeybindingResolver.combine(defaults, overrides); assert.deepEqual(actual, [ - new NormalizedKeybindingItem(KeyCode.KEY_A, 'yes1', KbExpr.equals('1', 'a'), true), - new NormalizedKeybindingItem(KeyCode.KEY_B, 'yes2', KbExpr.equals('2', 'b'), true), - new NormalizedKeybindingItem(KeyCode.KEY_C, 'yes3', KbExpr.equals('3', 'c'), false), + new NormalizedKeybindingItem(KeyCode.KEY_A, 'yes1', ContextKeyExpr.equals('1', 'a'), true), + new NormalizedKeybindingItem(KeyCode.KEY_B, 'yes2', ContextKeyExpr.equals('2', 'b'), true), + new NormalizedKeybindingItem(KeyCode.KEY_C, 'yes3', ContextKeyExpr.equals('3', 'c'), false), ]); }); test('KeybindingResolver.combine removal with not matching when', function() { let defaults:IKeybindingItem[] = [{ command: 'yes1', - when: KbExpr.equals('1', 'a'), + when: ContextKeyExpr.equals('1', 'a'), keybinding: KeyCode.KEY_A, weight1: 0, weight2: 0 }, { command: 'yes2', - when: KbExpr.equals('2', 'b'), + when: ContextKeyExpr.equals('2', 'b'), keybinding: KeyCode.KEY_B, weight1: 0, weight2: 0 }]; let overrides:IKeybindingItem[] = [{ command: '-yes1', - when: KbExpr.equals('1', 'b'), + when: ContextKeyExpr.equals('1', 'b'), keybinding: KeyCode.KEY_A, weight1: 0, weight2: 0 }]; let actual = KeybindingResolver.combine(defaults, overrides); assert.deepEqual(actual, [ - new NormalizedKeybindingItem(KeyCode.KEY_A, 'yes1', KbExpr.equals('1', 'a'), true), - new NormalizedKeybindingItem(KeyCode.KEY_B, 'yes2', KbExpr.equals('2', 'b'), true) + new NormalizedKeybindingItem(KeyCode.KEY_A, 'yes1', ContextKeyExpr.equals('1', 'a'), true), + new NormalizedKeybindingItem(KeyCode.KEY_B, 'yes2', ContextKeyExpr.equals('2', 'b'), true) ]); }); test('KeybindingResolver.combine removal with not matching keybinding', function() { let defaults:IKeybindingItem[] = [{ command: 'yes1', - when: KbExpr.equals('1', 'a'), + when: ContextKeyExpr.equals('1', 'a'), keybinding: KeyCode.KEY_A, weight1: 0, weight2: 0 }, { command: 'yes2', - when: KbExpr.equals('2', 'b'), + when: ContextKeyExpr.equals('2', 'b'), keybinding: KeyCode.KEY_B, weight1: 0, weight2: 0 }]; let overrides:IKeybindingItem[] = [{ command: '-yes1', - when: KbExpr.equals('1', 'a'), + when: ContextKeyExpr.equals('1', 'a'), keybinding: KeyCode.KEY_B, weight1: 0, weight2: 0 }]; let actual = KeybindingResolver.combine(defaults, overrides); assert.deepEqual(actual, [ - new NormalizedKeybindingItem(KeyCode.KEY_A, 'yes1', KbExpr.equals('1', 'a'), true), - new NormalizedKeybindingItem(KeyCode.KEY_B, 'yes2', KbExpr.equals('2', 'b'), true) + new NormalizedKeybindingItem(KeyCode.KEY_A, 'yes1', ContextKeyExpr.equals('1', 'a'), true), + new NormalizedKeybindingItem(KeyCode.KEY_B, 'yes2', ContextKeyExpr.equals('2', 'b'), true) ]); }); test('KeybindingResolver.combine removal with matching keybinding and when', function() { let defaults:IKeybindingItem[] = [{ command: 'yes1', - when: KbExpr.equals('1', 'a'), + when: ContextKeyExpr.equals('1', 'a'), keybinding: KeyCode.KEY_A, weight1: 0, weight2: 0 }, { command: 'yes2', - when: KbExpr.equals('2', 'b'), + when: ContextKeyExpr.equals('2', 'b'), keybinding: KeyCode.KEY_B, weight1: 0, weight2: 0 }]; let overrides:IKeybindingItem[] = [{ command: '-yes1', - when: KbExpr.equals('1', 'a'), + when: ContextKeyExpr.equals('1', 'a'), keybinding: KeyCode.KEY_A, weight1: 0, weight2: 0 }]; let actual = KeybindingResolver.combine(defaults, overrides); assert.deepEqual(actual, [ - new NormalizedKeybindingItem(KeyCode.KEY_B, 'yes2', KbExpr.equals('2', 'b'), true) + new NormalizedKeybindingItem(KeyCode.KEY_B, 'yes2', ContextKeyExpr.equals('2', 'b'), true) ]); }); test('KeybindingResolver.combine removal with unspecified keybinding', function() { let defaults:IKeybindingItem[] = [{ command: 'yes1', - when: KbExpr.equals('1', 'a'), + when: ContextKeyExpr.equals('1', 'a'), keybinding: KeyCode.KEY_A, weight1: 0, weight2: 0 }, { command: 'yes2', - when: KbExpr.equals('2', 'b'), + when: ContextKeyExpr.equals('2', 'b'), keybinding: KeyCode.KEY_B, weight1: 0, weight2: 0 }]; let overrides:IKeybindingItem[] = [{ command: '-yes1', - when: KbExpr.equals('1', 'a'), + when: ContextKeyExpr.equals('1', 'a'), keybinding: 0, weight1: 0, weight2: 0 }]; let actual = KeybindingResolver.combine(defaults, overrides); assert.deepEqual(actual, [ - new NormalizedKeybindingItem(KeyCode.KEY_B, 'yes2', KbExpr.equals('2', 'b'), true) + new NormalizedKeybindingItem(KeyCode.KEY_B, 'yes2', ContextKeyExpr.equals('2', 'b'), true) ]); }); test('KeybindingResolver.combine removal with unspecified when', function() { let defaults:IKeybindingItem[] = [{ command: 'yes1', - when: KbExpr.equals('1', 'a'), + when: ContextKeyExpr.equals('1', 'a'), keybinding: KeyCode.KEY_A, weight1: 0, weight2: 0 }, { command: 'yes2', - when: KbExpr.equals('2', 'b'), + when: ContextKeyExpr.equals('2', 'b'), keybinding: KeyCode.KEY_B, weight1: 0, weight2: 0 @@ -241,20 +241,20 @@ suite('Keybinding Service', () => { }]; let actual = KeybindingResolver.combine(defaults, overrides); assert.deepEqual(actual, [ - new NormalizedKeybindingItem(KeyCode.KEY_B, 'yes2', KbExpr.equals('2', 'b'), true) + new NormalizedKeybindingItem(KeyCode.KEY_B, 'yes2', ContextKeyExpr.equals('2', 'b'), true) ]); }); test('KeybindingResolver.combine removal with unspecified when and unspecified keybinding', function() { let defaults:IKeybindingItem[] = [{ command: 'yes1', - when: KbExpr.equals('1', 'a'), + when: ContextKeyExpr.equals('1', 'a'), keybinding: KeyCode.KEY_A, weight1: 0, weight2: 0 }, { command: 'yes2', - when: KbExpr.equals('2', 'b'), + when: ContextKeyExpr.equals('2', 'b'), keybinding: KeyCode.KEY_B, weight1: 0, weight2: 0 @@ -268,20 +268,20 @@ suite('Keybinding Service', () => { }]; let actual = KeybindingResolver.combine(defaults, overrides); assert.deepEqual(actual, [ - new NormalizedKeybindingItem(KeyCode.KEY_B, 'yes2', KbExpr.equals('2', 'b'), true) + new NormalizedKeybindingItem(KeyCode.KEY_B, 'yes2', ContextKeyExpr.equals('2', 'b'), true) ]); }); test('issue #612#issuecomment-222109084 cannot remove keybindings for commands with ^', function() { let defaults:IKeybindingItem[] = [{ command: '^yes1', - when: KbExpr.equals('1', 'a'), + when: ContextKeyExpr.equals('1', 'a'), keybinding: KeyCode.KEY_A, weight1: 0, weight2: 0 }, { command: 'yes2', - when: KbExpr.equals('2', 'b'), + when: ContextKeyExpr.equals('2', 'b'), keybinding: KeyCode.KEY_B, weight1: 0, weight2: 0 @@ -295,37 +295,37 @@ suite('Keybinding Service', () => { }]; let actual = KeybindingResolver.combine(defaults, overrides); assert.deepEqual(actual, [ - new NormalizedKeybindingItem(KeyCode.KEY_B, 'yes2', KbExpr.equals('2', 'b'), true) + new NormalizedKeybindingItem(KeyCode.KEY_B, 'yes2', ContextKeyExpr.equals('2', 'b'), true) ]); }); test('normalizeRule', function() { - let key1IsTrue = KbExpr.equals('key1', true); - let key1IsNotFalse = KbExpr.notEquals('key1', false); - let key1IsFalse = KbExpr.equals('key1', false); - let key1IsNotTrue = KbExpr.notEquals('key1', true); + let key1IsTrue = ContextKeyExpr.equals('key1', true); + let key1IsNotFalse = ContextKeyExpr.notEquals('key1', false); + let key1IsFalse = ContextKeyExpr.equals('key1', false); + let key1IsNotTrue = ContextKeyExpr.notEquals('key1', true); - assert.ok(key1IsTrue.normalize().equals(KbExpr.has('key1'))); - assert.ok(key1IsNotFalse.normalize().equals(KbExpr.has('key1'))); - assert.ok(key1IsFalse.normalize().equals(KbExpr.not('key1'))); - assert.ok(key1IsNotTrue.normalize().equals(KbExpr.not('key1'))); + assert.ok(key1IsTrue.normalize().equals(ContextKeyExpr.has('key1'))); + assert.ok(key1IsNotFalse.normalize().equals(ContextKeyExpr.has('key1'))); + assert.ok(key1IsFalse.normalize().equals(ContextKeyExpr.not('key1'))); + assert.ok(key1IsNotTrue.normalize().equals(ContextKeyExpr.not('key1'))); }); test('contextIsEntirelyIncluded', function() { - let assertIsIncluded = (a: KbExpr[], b: KbExpr[]) => { + let assertIsIncluded = (a: ContextKeyExpr[], b: ContextKeyExpr[]) => { assert.equal(KeybindingResolver.whenIsEntirelyIncluded(false, new KbAndExpression(a), new KbAndExpression(b)), true); }; - let assertIsNotIncluded = (a: KbExpr[], b: KbExpr[]) => { + let assertIsNotIncluded = (a: ContextKeyExpr[], b: ContextKeyExpr[]) => { assert.equal(KeybindingResolver.whenIsEntirelyIncluded(false, new KbAndExpression(a), new KbAndExpression(b)), false); }; - let key1IsTrue = KbExpr.equals('key1', true); - let key1IsNotFalse = KbExpr.notEquals('key1', false); - let key1IsFalse = KbExpr.equals('key1', false); - let key1IsNotTrue = KbExpr.notEquals('key1', true); - let key2IsTrue = KbExpr.equals('key2', true); - let key2IsNotFalse = KbExpr.notEquals('key2', false); - let key3IsTrue = KbExpr.equals('key3', true); - let key4IsTrue = KbExpr.equals('key4', true); + let key1IsTrue = ContextKeyExpr.equals('key1', true); + let key1IsNotFalse = ContextKeyExpr.notEquals('key1', false); + let key1IsFalse = ContextKeyExpr.equals('key1', false); + let key1IsNotTrue = ContextKeyExpr.notEquals('key1', true); + let key2IsTrue = ContextKeyExpr.equals('key2', true); + let key2IsNotFalse = ContextKeyExpr.notEquals('key2', false); + let key3IsTrue = ContextKeyExpr.equals('key3', true); + let key4IsTrue = ContextKeyExpr.equals('key4', true); assertIsIncluded([key1IsTrue], null); assertIsIncluded([key1IsTrue], []); @@ -369,9 +369,9 @@ suite('Keybinding Service', () => { // This one will never match because its "when" is always overwritten by another one { keybinding: KeyCode.KEY_X, - when: KbExpr.and( - KbExpr.equals('key1', true), - KbExpr.notEquals('key2', false) + when: ContextKeyExpr.and( + ContextKeyExpr.equals('key1', true), + ContextKeyExpr.notEquals('key2', false) ), command: 'first', weight1: 1, @@ -380,7 +380,7 @@ suite('Keybinding Service', () => { // This one always overwrites first { keybinding: KeyCode.KEY_X, - when: KbExpr.equals('key2', true), + when: ContextKeyExpr.equals('key2', true), command: 'second', weight1: 2, weight2: 0 @@ -396,7 +396,7 @@ suite('Keybinding Service', () => { // This one sometimes overwrites first { keybinding: KeyCode.KEY_X, - when: KbExpr.equals('key3', true), + when: ContextKeyExpr.equals('key3', true), command: 'third', weight1: 3, weight2: 0 @@ -404,7 +404,7 @@ suite('Keybinding Service', () => { // This one is always overwritten by another one { keybinding: KeyMod.CtrlCmd | KeyCode.KEY_Y, - when: KbExpr.equals('key4', true), + when: ContextKeyExpr.equals('key4', true), command: 'fourth', weight1: 4, weight2: 0 diff --git a/src/vs/platform/keybinding/test/common/mockKeybindingService.ts b/src/vs/platform/keybinding/test/common/mockKeybindingService.ts index a7ab660c674..2f014645076 100644 --- a/src/vs/platform/keybinding/test/common/mockKeybindingService.ts +++ b/src/vs/platform/keybinding/test/common/mockKeybindingService.ts @@ -8,7 +8,7 @@ import {IHTMLContentElement} from 'vs/base/common/htmlContent'; import {Keybinding} from 'vs/base/common/keyCodes'; import Event from 'vs/base/common/event'; import {IKeybindingService2} from 'vs/platform/keybinding/common/keybinding'; -import {IKeybindingContextKey, IContextKeyService, IKeybindingContext, KbExpr} from 'vs/platform/contextkey/common/contextkey'; +import {IKeybindingContextKey, IContextKeyService, IKeybindingContext, ContextKeyExpr} from 'vs/platform/contextkey/common/contextkey'; class MockKeybindingContextKey implements IKeybindingContextKey { private _key: string; @@ -42,7 +42,7 @@ export class MockKeybindingService implements IContextKeyService { public createKey(key: string, defaultValue: T): IKeybindingContextKey { return new MockKeybindingContextKey(key, defaultValue); } - public contextMatchesRules(rules: KbExpr): boolean { + public contextMatchesRules(rules: ContextKeyExpr): boolean { return false; } public get onDidChangeContext(): Event { diff --git a/src/vs/workbench/browser/parts/editor/editor.contribution.ts b/src/vs/workbench/browser/parts/editor/editor.contribution.ts index 671ff7af6d3..27a14c62b6e 100644 --- a/src/vs/workbench/browser/parts/editor/editor.contribution.ts +++ b/src/vs/workbench/browser/parts/editor/editor.contribution.ts @@ -19,7 +19,7 @@ import {ResourceEditorInput} from 'vs/workbench/common/editor/resourceEditorInpu import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation'; import {KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry'; import {IKeybindings} from 'vs/platform/keybinding/common/keybinding'; -import {KbExpr} from 'vs/platform/contextkey/common/contextkey'; +import {ContextKeyExpr} from 'vs/platform/contextkey/common/contextkey'; import {TextDiffEditor} from 'vs/workbench/browser/parts/editor/textDiffEditor'; import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService'; import {BinaryResourceDiffEditor} from 'vs/workbench/browser/parts/editor/binaryDiffEditor'; @@ -256,8 +256,8 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(GlobalQuickOpenAction, registry.registerWorkbenchAction(new SyncActionDescriptor(OpenPreviousEditorFromHistoryAction, OpenPreviousEditorFromHistoryAction.ID, OpenPreviousEditorFromHistoryAction.LABEL), 'Open Previous Editor from History'); registry.registerWorkbenchAction(new SyncActionDescriptor(ClearEditorHistoryAction, ClearEditorHistoryAction.ID, ClearEditorHistoryAction.LABEL), 'Clear Editor History'); registry.registerWorkbenchAction(new SyncActionDescriptor(RemoveFromEditorHistoryAction, RemoveFromEditorHistoryAction.ID, RemoveFromEditorHistoryAction.LABEL), 'Remove From Editor History'); -registry.registerWorkbenchAction(new SyncActionDescriptor(QuickOpenNavigateNextAction, QuickOpenNavigateNextAction.ID, QuickOpenNavigateNextAction.LABEL, navigateKeybinding(false), KbExpr.has('inQuickOpen')), 'Navigate Next in Quick Open'); -registry.registerWorkbenchAction(new SyncActionDescriptor(QuickOpenNavigatePreviousAction, QuickOpenNavigatePreviousAction.ID, QuickOpenNavigatePreviousAction.LABEL, navigateKeybinding(true), KbExpr.has('inQuickOpen'), KeybindingsRegistry.WEIGHT.workbenchContrib(50)), 'Navigate Previous in Quick Open'); +registry.registerWorkbenchAction(new SyncActionDescriptor(QuickOpenNavigateNextAction, QuickOpenNavigateNextAction.ID, QuickOpenNavigateNextAction.LABEL, navigateKeybinding(false), ContextKeyExpr.has('inQuickOpen')), 'Navigate Next in Quick Open'); +registry.registerWorkbenchAction(new SyncActionDescriptor(QuickOpenNavigatePreviousAction, QuickOpenNavigatePreviousAction.ID, QuickOpenNavigatePreviousAction.LABEL, navigateKeybinding(true), ContextKeyExpr.has('inQuickOpen'), KeybindingsRegistry.WEIGHT.workbenchContrib(50)), 'Navigate Previous in Quick Open'); // Keybindings to focus a specific index in the tab folder if tabs are enabled for (let i = 0; i < 9; i++) { diff --git a/src/vs/workbench/electron-browser/workbench.ts b/src/vs/workbench/electron-browser/workbench.ts index 072294dbb90..12e934751b6 100644 --- a/src/vs/workbench/electron-browser/workbench.ts +++ b/src/vs/workbench/electron-browser/workbench.ts @@ -48,7 +48,7 @@ import {WorkbenchKeybindingService2} from 'vs/workbench/services/keybinding/elec import {KeybindingService} from 'vs/platform/contextkey/browser/contextKeyService'; import {IWorkspace, IConfiguration} from 'vs/platform/workspace/common/workspace'; import {IKeybindingService2} from 'vs/platform/keybinding/common/keybinding'; -import {KbExpr, KbCtxKey, IContextKeyService, IKeybindingContextKey} from 'vs/platform/contextkey/common/contextkey'; +import {ContextKeyExpr, KbCtxKey, IContextKeyService, IKeybindingContextKey} from 'vs/platform/contextkey/common/contextkey'; import {IActivityService} from 'vs/workbench/services/activity/common/activityService'; import {IViewletService} from 'vs/workbench/services/viewlet/common/viewletService'; import {IPanelService} from 'vs/workbench/services/panel/common/panelService'; @@ -71,7 +71,7 @@ import {IContextMenuService} from 'vs/platform/contextview/browser/contextView'; export const MessagesVisibleContext = new KbCtxKey('globalMessageVisible', false); export const EditorsVisibleContext = new KbCtxKey('editorIsOpen', false); -export const NoEditorsVisibleContext:KbExpr = EditorsVisibleContext.toNegated(); +export const NoEditorsVisibleContext:ContextKeyExpr = EditorsVisibleContext.toNegated(); interface WorkbenchParams { workspace?: IWorkspace; diff --git a/src/vs/workbench/parts/debug/browser/debugActions.ts b/src/vs/workbench/parts/debug/browser/debugActions.ts index df37da7034c..f1ad7f0a635 100644 --- a/src/vs/workbench/parts/debug/browser/debugActions.ts +++ b/src/vs/workbench/parts/debug/browser/debugActions.ts @@ -11,7 +11,7 @@ import {Range} from 'vs/editor/common/core/range'; import editorCommon = require('vs/editor/common/editorCommon'); import editorbrowser = require('vs/editor/browser/editorBrowser'); import {IKeybindingService2} from 'vs/platform/keybinding/common/keybinding'; -import {KbExpr} from 'vs/platform/contextkey/common/contextkey'; +import {ContextKeyExpr} from 'vs/platform/contextkey/common/contextkey'; import {ICommandService} from 'vs/platform/commands/common/commands'; import debug = require('vs/workbench/parts/debug/common/debug'); import model = require('vs/workbench/parts/debug/common/debugModel'); @@ -658,7 +658,7 @@ export class SelectionToReplAction extends EditorAction { id: 'editor.debug.action.selectionToRepl', label: nls.localize('debugEvaluate', "Debug: Evaluate"), alias: 'Debug: Evaluate', - precondition: KbExpr.and(EditorContextKeys.HasNonEmptySelection, debug.CONTEXT_IN_DEBUG_MODE), + precondition: ContextKeyExpr.and(EditorContextKeys.HasNonEmptySelection, debug.CONTEXT_IN_DEBUG_MODE), menuOpts: { group: 'debug' } diff --git a/src/vs/workbench/parts/debug/common/debug.ts b/src/vs/workbench/parts/debug/common/debug.ts index 6ace8245c6c..41ee00d6353 100644 --- a/src/vs/workbench/parts/debug/common/debug.ts +++ b/src/vs/workbench/parts/debug/common/debug.ts @@ -11,13 +11,13 @@ import {createDecorator} from 'vs/platform/instantiation/common/instantiation'; import editor = require('vs/editor/common/editorCommon'); import {Source} from 'vs/workbench/parts/debug/common/debugSource'; import {Range} from 'vs/editor/common/core/range'; -import {KbCtxKey, KbExpr} from 'vs/platform/contextkey/common/contextkey'; +import {KbCtxKey, ContextKeyExpr} from 'vs/platform/contextkey/common/contextkey'; export const VIEWLET_ID = 'workbench.view.debug'; export const REPL_ID = 'workbench.panel.repl'; export const DEBUG_SERVICE_ID = 'debugService'; export const CONTEXT_IN_DEBUG_MODE = new KbCtxKey('inDebugMode', false); -export const CONTEXT_NOT_IN_DEBUG_MODE:KbExpr = CONTEXT_IN_DEBUG_MODE.toNegated(); +export const CONTEXT_NOT_IN_DEBUG_MODE:ContextKeyExpr = CONTEXT_IN_DEBUG_MODE.toNegated(); export const EDITOR_CONTRIBUTION_ID = 'editor.contrib.debug'; // raw diff --git a/src/vs/workbench/parts/emmet/node/actions/expandAbbreviation.ts b/src/vs/workbench/parts/emmet/node/actions/expandAbbreviation.ts index e99967a0320..891f2a81370 100644 --- a/src/vs/workbench/parts/emmet/node/actions/expandAbbreviation.ts +++ b/src/vs/workbench/parts/emmet/node/actions/expandAbbreviation.ts @@ -12,7 +12,7 @@ import {editorAction} from 'vs/editor/common/editorCommonExtensions'; import {Handler, ICommonCodeEditor, EditorContextKeys} from 'vs/editor/common/editorCommon'; import {KeyCode} from 'vs/base/common/keyCodes'; -import {KbExpr} from 'vs/platform/contextkey/common/contextkey'; +import {ContextKeyExpr} from 'vs/platform/contextkey/common/contextkey'; @editorAction class ExpandAbbreviationAction extends BasicEmmetEditorAction { @@ -25,12 +25,12 @@ class ExpandAbbreviationAction extends BasicEmmetEditorAction { 'expand_abbreviation', { primary: KeyCode.Tab, - kbExpr: KbExpr.and( + kbExpr: ContextKeyExpr.and( EditorContextKeys.TextFocus, EditorContextKeys.HasOnlyEmptySelection, EditorContextKeys.HasSingleSelection, EditorContextKeys.TabDoesNotMoveFocus, - KbExpr.has('config.emmet.triggerExpansionOnTab') + ContextKeyExpr.has('config.emmet.triggerExpansionOnTab') ) } ); diff --git a/src/vs/workbench/parts/output/browser/output.contribution.ts b/src/vs/workbench/parts/output/browser/output.contribution.ts index 620c2cd8dbe..39afff72d60 100644 --- a/src/vs/workbench/parts/output/browser/output.contribution.ts +++ b/src/vs/workbench/parts/output/browser/output.contribution.ts @@ -19,7 +19,7 @@ import {OUTPUT_MIME, OUTPUT_MODE_ID, OUTPUT_PANEL_ID, IOutputService} from 'vs/w import panel = require('vs/workbench/browser/panel'); import {EditorContextKeys} from 'vs/editor/common/editorCommon'; import {CommandsRegistry, ICommandHandler} from 'vs/platform/commands/common/commands'; -import {KbExpr} from 'vs/platform/contextkey/common/contextkey'; +import {ContextKeyExpr} from 'vs/platform/contextkey/common/contextkey'; // Register Service registerSingleton(IOutputService, OutputService); @@ -66,13 +66,13 @@ interface IActionDescriptor { // menu?: { menuId: MenuId, - when?: KbExpr; + when?: ContextKeyExpr; group?: string; }; // keybinding?: { - when?: KbExpr; + when?: ContextKeyExpr; weight: number; keys: IKeybindings; }; diff --git a/src/vs/workbench/parts/search/browser/searchWidget.ts b/src/vs/workbench/parts/search/browser/searchWidget.ts index d2562c0e9c5..d689db90732 100644 --- a/src/vs/workbench/parts/search/browser/searchWidget.ts +++ b/src/vs/workbench/parts/search/browser/searchWidget.ts @@ -16,7 +16,7 @@ import { Button } from 'vs/base/browser/ui/button/button'; import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent'; import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { IKeybindingService2 } from 'vs/platform/keybinding/common/keybinding'; -import { KbExpr, KbCtxKey, IContextKeyService, IKeybindingContextKey } from 'vs/platform/contextkey/common/contextkey'; +import { ContextKeyExpr, KbCtxKey, IContextKeyService, IKeybindingContextKey } from 'vs/platform/contextkey/common/contextkey'; import { IContextViewService } from 'vs/platform/contextview/browser/contextView'; import { KeyCode, KeyMod } from 'vs/base/common/keyCodes'; import Event, { Emitter } from 'vs/base/common/event'; @@ -339,7 +339,7 @@ export class SearchWidget extends Widget { export function registerContributions() { KeybindingsRegistry.registerCommandAndKeybindingRule({id: ReplaceAllAction.ID, weight: KeybindingsRegistry.WEIGHT.workbenchContrib(), - when: KbExpr.and(KbExpr.has('searchViewletVisible'), SearchWidget.REPLACE_ACTIVE_CONTEXT_KEY, CONTEXT_FIND_WIDGET_NOT_VISIBLE), + when: ContextKeyExpr.and(ContextKeyExpr.has('searchViewletVisible'), SearchWidget.REPLACE_ACTIVE_CONTEXT_KEY, CONTEXT_FIND_WIDGET_NOT_VISIBLE), primary: KeyMod.Alt | KeyMod.CtrlCmd | KeyCode.Enter, handler: accessor => { if (isSearchViewletFocussed(accessor.get(IViewletService))) { diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminal.ts b/src/vs/workbench/parts/terminal/electron-browser/terminal.ts index aa11a6806f8..527dae2063e 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminal.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminal.ts @@ -11,7 +11,7 @@ import processes = require('vs/base/node/processes'); import {Builder} from 'vs/base/browser/builder'; import {TPromise} from 'vs/base/common/winjs.base'; import {createDecorator} from 'vs/platform/instantiation/common/instantiation'; -import {KbCtxKey, KbExpr} from 'vs/platform/contextkey/common/contextkey'; +import {KbCtxKey, ContextKeyExpr} from 'vs/platform/contextkey/common/contextkey'; export const TERMINAL_PANEL_ID = 'workbench.panel.terminal'; @@ -25,7 +25,7 @@ export const TERMINAL_DEFAULT_SHELL_WINDOWS = processes.getWindowsShell(); * A context key that is set when the integrated terminal has focus. */ export const KEYBINDING_CONTEXT_TERMINAL_FOCUS = new KbCtxKey('terminalFocus', undefined); -export const KEYBINDING_CONTEXT_TERMINAL_NOT_FOCUSED:KbExpr = KEYBINDING_CONTEXT_TERMINAL_FOCUS.toNegated(); +export const KEYBINDING_CONTEXT_TERMINAL_NOT_FOCUSED:ContextKeyExpr = KEYBINDING_CONTEXT_TERMINAL_FOCUS.toNegated(); export const ITerminalService = createDecorator(TERMINAL_SERVICE_ID);