diff --git a/build/monaco/monaco.d.ts.recipe b/build/monaco/monaco.d.ts.recipe index 3e408f5dc0c..9aa2240fa04 100644 --- a/build/monaco/monaco.d.ts.recipe +++ b/build/monaco/monaco.d.ts.recipe @@ -57,7 +57,7 @@ declare module monaco.editor { export interface ICommandHandler { (...args:any[]): void; } -#include(vs/platform/keybinding/common/keybinding): IKeybindingContextKey +#include(vs/platform/contextkey/common/contextkey): IKeybindingContextKey #include(vs/editor/browser/standalone/standaloneServices): IEditorOverrideServices #include(vs/platform/markers/common/markers): IMarkerData #include(vs/editor/browser/standalone/colorizer): IColorizerOptions, IColorizerElementOptions diff --git a/src/vs/editor/browser/standalone/simpleServices.ts b/src/vs/editor/browser/standalone/simpleServices.ts index 9b426660600..2522c23c3aa 100644 --- a/src/vs/editor/browser/standalone/simpleServices.ts +++ b/src/vs/editor/browser/standalone/simpleServices.ts @@ -16,9 +16,11 @@ import {IEditor, IEditorInput, IEditorOptions, IEditorService, IResourceInput, I import {AbstractExtensionService, ActivatedExtension} from 'vs/platform/extensions/common/abstractExtensionService'; import {IExtensionDescription} from 'vs/platform/extensions/common/extensions'; import {ICommandService, ICommandHandler} from 'vs/platform/commands/common/commands'; -import {KeybindingService, KeybindingService2} from 'vs/platform/keybinding/browser/keybindingServiceImpl'; +import {KeybindingService2} from 'vs/platform/keybinding/browser/keybindingServiceImpl'; +import {KeybindingService} from 'vs/platform/contextkey/browser/contextKeyService'; import {IOSupport} from 'vs/platform/keybinding/common/keybindingResolver'; -import {IKeybindingService, IKeybindingItem} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingItem} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService} from 'vs/platform/contextkey/common/contextkey'; import {IConfirmation, IMessageService} from 'vs/platform/message/common/message'; import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace'; import * as editorCommon from 'vs/editor/common/editorCommon'; diff --git a/src/vs/editor/browser/standalone/standaloneCodeEditor.ts b/src/vs/editor/browser/standalone/standaloneCodeEditor.ts index 11a81ddcbd0..c42bae0922b 100644 --- a/src/vs/editor/browser/standalone/standaloneCodeEditor.ts +++ b/src/vs/editor/browser/standalone/standaloneCodeEditor.ts @@ -9,7 +9,8 @@ import {IDisposable, dispose} from 'vs/base/common/lifecycle'; import {IContextViewService} from 'vs/platform/contextview/browser/contextView'; import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation'; import {ICommandService} from 'vs/platform/commands/common/commands'; -import {IKeybindingContextKey, IKeybindingService, IKeybindingService2} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService2} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingContextKey, IKeybindingService} from 'vs/platform/contextkey/common/contextkey'; import {ICommandHandler} from 'vs/platform/commands/common/commands'; import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry'; import {IActionDescriptor, ICodeEditorWidgetCreationOptions, IDiffEditorOptions, IModel, IModelChangedEvent, EventType} from 'vs/editor/common/editorCommon'; diff --git a/src/vs/editor/browser/standalone/standaloneServices.ts b/src/vs/editor/browser/standalone/standaloneServices.ts index b0887ca9394..0388c5810e1 100644 --- a/src/vs/editor/browser/standalone/standaloneServices.ts +++ b/src/vs/editor/browser/standalone/standaloneServices.ts @@ -20,7 +20,8 @@ import {ServiceCollection} from 'vs/platform/instantiation/common/serviceCollect import {ICommandService} from 'vs/platform/commands/common/commands'; import {CommandService} from 'vs/platform/commands/common/commandService'; import {IOpenerService} from 'vs/platform/opener/common/opener'; -import {IKeybindingService, IKeybindingService2} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService2} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService} from 'vs/platform/contextkey/common/contextkey'; import {MarkerService} from 'vs/platform/markers/common/markerService'; import {IMarkerService} from 'vs/platform/markers/common/markers'; import {IMessageService} from 'vs/platform/message/common/message'; diff --git a/src/vs/editor/browser/view/viewImpl.ts b/src/vs/editor/browser/view/viewImpl.ts index a028f595846..923cdc5d9e5 100644 --- a/src/vs/editor/browser/view/viewImpl.ts +++ b/src/vs/editor/browser/view/viewImpl.ts @@ -11,7 +11,7 @@ import * as timer from 'vs/base/common/timer'; import * as browser from 'vs/base/browser/browser'; import * as dom from 'vs/base/browser/dom'; import {StyleMutator} from 'vs/base/browser/styleMutator'; -import {IKeybindingContextKey, IKeybindingService} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingContextKey, IKeybindingService} from 'vs/platform/contextkey/common/contextkey'; import {ICommandService} from 'vs/platform/commands/common/commands'; import {Range} from 'vs/editor/common/core/range'; import * as editorCommon from 'vs/editor/common/editorCommon'; diff --git a/src/vs/editor/browser/widget/codeEditorWidget.ts b/src/vs/editor/browser/widget/codeEditorWidget.ts index 736f88977be..6c68919ed57 100644 --- a/src/vs/editor/browser/widget/codeEditorWidget.ts +++ b/src/vs/editor/browser/widget/codeEditorWidget.ts @@ -12,7 +12,7 @@ import * as browser from 'vs/base/browser/browser'; import * as dom from 'vs/base/browser/dom'; import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation'; import {ICommandService} from 'vs/platform/commands/common/commands'; -import {IKeybindingService} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService} from 'vs/platform/contextkey/common/contextkey'; import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry'; import {CommonCodeEditor} from 'vs/editor/common/commonCodeEditor'; import {CommonEditorConfiguration} from 'vs/editor/common/config/commonEditorConfig'; diff --git a/src/vs/editor/browser/widget/diffEditorWidget.ts b/src/vs/editor/browser/widget/diffEditorWidget.ts index 4a9529dc9d9..5e36d837384 100644 --- a/src/vs/editor/browser/widget/diffEditorWidget.ts +++ b/src/vs/editor/browser/widget/diffEditorWidget.ts @@ -14,7 +14,7 @@ import * as dom from 'vs/base/browser/dom'; import {StyleMutator} from 'vs/base/browser/styleMutator'; import {ISashEvent, IVerticalSashLayoutProvider, Sash} from 'vs/base/browser/ui/sash/sash'; import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation'; -import {IKeybindingService} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService} from 'vs/platform/contextkey/common/contextkey'; import {ServiceCollection} from 'vs/platform/instantiation/common/serviceCollection'; import {DefaultConfig} from 'vs/editor/common/config/defaultConfig'; import {Range} from 'vs/editor/common/core/range'; diff --git a/src/vs/editor/browser/widget/embeddedCodeEditorWidget.ts b/src/vs/editor/browser/widget/embeddedCodeEditorWidget.ts index de80b7f38c3..129ef0eaf26 100644 --- a/src/vs/editor/browser/widget/embeddedCodeEditorWidget.ts +++ b/src/vs/editor/browser/widget/embeddedCodeEditorWidget.ts @@ -7,7 +7,7 @@ import * as objects from 'vs/base/common/objects'; import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation'; import {ICommandService} from 'vs/platform/commands/common/commands'; -import {IKeybindingService} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService} from 'vs/platform/contextkey/common/contextkey'; import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry'; import {ICodeEditorWidgetCreationOptions, IConfigurationChangedEvent, IEditorOptions} from 'vs/editor/common/editorCommon'; import {ICodeEditorService} from 'vs/editor/common/services/codeEditorService'; diff --git a/src/vs/editor/common/commonCodeEditor.ts b/src/vs/editor/common/commonCodeEditor.ts index cfedcab7daf..722a43fb8a4 100644 --- a/src/vs/editor/common/commonCodeEditor.ts +++ b/src/vs/editor/common/commonCodeEditor.ts @@ -12,7 +12,7 @@ import {TPromise} from 'vs/base/common/winjs.base'; import {ServicesAccessor, IInstantiationService} from 'vs/platform/instantiation/common/instantiation'; import {ServiceCollection} from 'vs/platform/instantiation/common/serviceCollection'; import {ICommandService} from 'vs/platform/commands/common/commands'; -import {IKeybindingContextKey, IKeybindingScopeLocation, IKeybindingService} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingContextKey, IKeybindingScopeLocation, IKeybindingService} from 'vs/platform/contextkey/common/contextkey'; import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry'; import {CommonEditorConfiguration} from 'vs/editor/common/config/commonEditorConfig'; import {DefaultConfig} from 'vs/editor/common/config/defaultConfig'; diff --git a/src/vs/editor/common/config/config.ts b/src/vs/editor/common/config/config.ts index 83f9de7c2d5..e8d84488739 100644 --- a/src/vs/editor/common/config/config.ts +++ b/src/vs/editor/common/config/config.ts @@ -8,7 +8,8 @@ import {TPromise} from 'vs/base/common/winjs.base'; 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 {IKeybindingService, IKeybindings, KbExpr} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindings} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService, KbExpr} 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'; diff --git a/src/vs/editor/common/editorAction.ts b/src/vs/editor/common/editorAction.ts index 9381ba909f0..0fdba65a057 100644 --- a/src/vs/editor/common/editorAction.ts +++ b/src/vs/editor/common/editorAction.ts @@ -8,7 +8,7 @@ import {TPromise} from 'vs/base/common/winjs.base'; import {IActionDescriptor, ICommonCodeEditor, IEditorAction} from 'vs/editor/common/editorCommon'; import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation'; import {EditorAction} from 'vs/editor/common/editorCommonExtensions'; -import {IKeybindingService} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService} from 'vs/platform/contextkey/common/contextkey'; export abstract class AbstractInternalEditorAction { diff --git a/src/vs/editor/common/editorCommon.ts b/src/vs/editor/common/editorCommon.ts index cc746c6b631..e77320ecd14 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/keybinding/common/keybinding'; +import {KbExpr, KbCtxKey} from 'vs/platform/contextkey/common/contextkey'; /** * @internal diff --git a/src/vs/editor/common/modes/editorModeContext.ts b/src/vs/editor/common/modes/editorModeContext.ts index d34313a5e87..619bfd00cbd 100644 --- a/src/vs/editor/common/modes/editorModeContext.ts +++ b/src/vs/editor/common/modes/editorModeContext.ts @@ -5,7 +5,7 @@ 'use strict'; import {IDisposable, dispose} from 'vs/base/common/lifecycle'; -import {IKeybindingContextKey, IKeybindingService} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingContextKey, IKeybindingService} from 'vs/platform/contextkey/common/contextkey'; import * as modes from 'vs/editor/common/modes'; import {ICommonCodeEditor, ModeContextKeys} from 'vs/editor/common/editorCommon'; diff --git a/src/vs/editor/contrib/accessibility/browser/accessibility.ts b/src/vs/editor/contrib/accessibility/browser/accessibility.ts index 71eef638c51..f4bb0e4453b 100644 --- a/src/vs/editor/contrib/accessibility/browser/accessibility.ts +++ b/src/vs/editor/contrib/accessibility/browser/accessibility.ts @@ -15,7 +15,8 @@ import {renderHtml} from 'vs/base/browser/htmlContentRenderer'; import {StyleMutator} from 'vs/base/browser/styleMutator'; import {Widget} from 'vs/base/browser/ui/widget'; import {ServicesAccessor} from 'vs/platform/instantiation/common/instantiation'; -import {KbCtxKey, IKeybindingContextKey, IKeybindingService, IKeybindingService2} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService2} from 'vs/platform/keybinding/common/keybinding'; +import {KbCtxKey, IKeybindingContextKey, IKeybindingService} from 'vs/platform/contextkey/common/contextkey'; import {KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry'; import {GlobalScreenReaderNVDA} from 'vs/editor/common/config/commonEditorConfig'; import {ICommonCodeEditor, IEditorContribution, EditorContextKeys} from 'vs/editor/common/editorCommon'; diff --git a/src/vs/editor/contrib/contextmenu/browser/contextmenu.ts b/src/vs/editor/contrib/contextmenu/browser/contextmenu.ts index 2de65a775cf..f7701f13184 100644 --- a/src/vs/editor/contrib/contextmenu/browser/contextmenu.ts +++ b/src/vs/editor/contrib/contextmenu/browser/contextmenu.ts @@ -13,7 +13,8 @@ import * as dom from 'vs/base/browser/dom'; import {IKeyboardEvent} from 'vs/base/browser/keyboardEvent'; import {ActionItem, Separator} from 'vs/base/browser/ui/actionbar/actionbar'; import {IContextMenuService, IContextViewService} from 'vs/platform/contextview/browser/contextView'; -import {IKeybindingService, IKeybindingService2} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService2} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService} from 'vs/platform/contextkey/common/contextkey'; import {IMenuService, IMenu, MenuId} from 'vs/platform/actions/common/actions'; import {ICommonCodeEditor, IEditorContribution, MouseTargetType, EditorContextKeys} from 'vs/editor/common/editorCommon'; import {editorAction, ServicesAccessor, EditorAction} from 'vs/editor/common/editorCommonExtensions'; diff --git a/src/vs/editor/contrib/defineKeybinding/browser/defineKeybinding.ts b/src/vs/editor/contrib/defineKeybinding/browser/defineKeybinding.ts index 49ae26a0130..4aea67a76e9 100644 --- a/src/vs/editor/contrib/defineKeybinding/browser/defineKeybinding.ts +++ b/src/vs/editor/contrib/defineKeybinding/browser/defineKeybinding.ts @@ -16,7 +16,8 @@ import {renderHtml} from 'vs/base/browser/htmlContentRenderer'; import {StandardKeyboardEvent} from 'vs/base/browser/keyboardEvent'; import {StyleMutator} from 'vs/base/browser/styleMutator'; import {IOSupport} from 'vs/platform/keybinding/common/keybindingResolver'; -import {KbExpr, IKeybindingService2} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService2} from 'vs/platform/keybinding/common/keybinding'; +import {KbExpr} 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'; diff --git a/src/vs/editor/contrib/find/browser/find.ts b/src/vs/editor/contrib/find/browser/find.ts index ee2231d9b4d..31229bb9f33 100644 --- a/src/vs/editor/contrib/find/browser/find.ts +++ b/src/vs/editor/contrib/find/browser/find.ts @@ -5,7 +5,8 @@ 'use strict'; import {IContextViewService} from 'vs/platform/contextview/browser/contextView'; -import {IKeybindingService, IKeybindingService2} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService2} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService} from 'vs/platform/contextkey/common/contextkey'; import {ICodeEditor} from 'vs/editor/browser/editorBrowser'; import {EditorBrowserRegistry} from 'vs/editor/browser/editorBrowserExtensions'; import {FindWidget, IFindController} from 'vs/editor/contrib/find/browser/findWidget'; diff --git a/src/vs/editor/contrib/find/common/findController.ts b/src/vs/editor/contrib/find/common/findController.ts index 57b516c6efc..d4aa8540d8a 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, IKeybindingService} from 'vs/platform/keybinding/common/keybinding'; +import {KbExpr, KbCtxKey, IKeybindingContextKey, IKeybindingService} 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'; diff --git a/src/vs/editor/contrib/format/common/formatActions.ts b/src/vs/editor/contrib/format/common/formatActions.ts index e734d15c806..7641c2a3bec 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/keybinding/common/keybinding'; +import {KbExpr} 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'; diff --git a/src/vs/editor/contrib/goToDeclaration/browser/goToDeclaration.ts b/src/vs/editor/contrib/goToDeclaration/browser/goToDeclaration.ts index e67f27f6245..6ce563b420f 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/keybinding/common/keybinding'; +import {KbExpr} from 'vs/platform/contextkey/common/contextkey'; import ModeContextKeys = editorCommon.ModeContextKeys; import EditorContextKeys = editorCommon.EditorContextKeys; diff --git a/src/vs/editor/contrib/gotoError/browser/gotoError.ts b/src/vs/editor/contrib/gotoError/browser/gotoError.ts index ccb41e1ecb1..54486ab95a4 100644 --- a/src/vs/editor/contrib/gotoError/browser/gotoError.ts +++ b/src/vs/editor/contrib/gotoError/browser/gotoError.ts @@ -17,7 +17,7 @@ import {TPromise} from 'vs/base/common/winjs.base'; import * as dom from 'vs/base/browser/dom'; import {renderHtml} from 'vs/base/browser/htmlContentRenderer'; import {ICommandService} from 'vs/platform/commands/common/commands'; -import {KbCtxKey, IKeybindingContextKey, IKeybindingService} from 'vs/platform/keybinding/common/keybinding'; +import {KbCtxKey, IKeybindingContextKey, IKeybindingService} from 'vs/platform/contextkey/common/contextkey'; import {IMarker, IMarkerService} from 'vs/platform/markers/common/markers'; import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry'; import {Position} from 'vs/editor/common/core/position'; diff --git a/src/vs/editor/contrib/parameterHints/browser/parameterHints.ts b/src/vs/editor/contrib/parameterHints/browser/parameterHints.ts index 1c352b0e6c8..23c2d8d1ee9 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/keybinding/common/keybinding'; +import { KbExpr } 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'; diff --git a/src/vs/editor/contrib/parameterHints/browser/parameterHintsWidget.ts b/src/vs/editor/contrib/parameterHints/browser/parameterHintsWidget.ts index 2011f50e4d5..32378c4f119 100644 --- a/src/vs/editor/contrib/parameterHints/browser/parameterHintsWidget.ts +++ b/src/vs/editor/contrib/parameterHints/browser/parameterHintsWidget.ts @@ -17,7 +17,7 @@ import { RunOnceScheduler } from 'vs/base/common/async'; import { onUnexpectedError } from 'vs/base/common/errors'; import Event, {Emitter} from 'vs/base/common/event'; import { ICommonCodeEditor, ICursorSelectionChangedEvent } from 'vs/editor/common/editorCommon'; -import { IKeybindingContextKey, IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; +import { IKeybindingContextKey, IKeybindingService } from 'vs/platform/contextkey/common/contextkey'; import { Context, provideSignatureHelp } from '../common/parameterHints'; const $ = dom.emmet; diff --git a/src/vs/editor/contrib/parameterHints/common/parameterHints.ts b/src/vs/editor/contrib/parameterHints/common/parameterHints.ts index fd9c2164545..73a493a2ff2 100644 --- a/src/vs/editor/contrib/parameterHints/common/parameterHints.ts +++ b/src/vs/editor/contrib/parameterHints/common/parameterHints.ts @@ -11,7 +11,7 @@ import { CommonEditorRegistry } from 'vs/editor/common/editorCommonExtensions'; import { SignatureHelp, SignatureHelpProviderRegistry } from 'vs/editor/common/modes'; import { asWinJsPromise } from 'vs/base/common/async'; import { Position } from 'vs/editor/common/core/position'; -import { KbCtxKey } from 'vs/platform/keybinding/common/keybinding'; +import { KbCtxKey } from 'vs/platform/contextkey/common/contextkey'; export const Context = { Visible: new KbCtxKey('parameterHintsVisible', false), diff --git a/src/vs/editor/contrib/quickFix/browser/quickFix.ts b/src/vs/editor/contrib/quickFix/browser/quickFix.ts index e7b760b25c7..1448b9ce020 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, IKeybindingService} from 'vs/platform/keybinding/common/keybinding'; +import {KbExpr, KbCtxKey, IKeybindingContextKey, IKeybindingService} 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'; diff --git a/src/vs/editor/contrib/referenceSearch/browser/referenceSearch.ts b/src/vs/editor/contrib/referenceSearch/browser/referenceSearch.ts index 209e40455e5..58d1dbf6759 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 {IKeybindingService, KbExpr} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService, KbExpr} 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'; diff --git a/src/vs/editor/contrib/referenceSearch/browser/referencesController.ts b/src/vs/editor/contrib/referenceSearch/browser/referencesController.ts index 174428be481..f7634fedb05 100644 --- a/src/vs/editor/contrib/referenceSearch/browser/referencesController.ts +++ b/src/vs/editor/contrib/referenceSearch/browser/referencesController.ts @@ -11,7 +11,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 {IInstantiationService, optional} from 'vs/platform/instantiation/common/instantiation'; -import {IKeybindingContextKey, IKeybindingService, KbCtxKey} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingContextKey, IKeybindingService, KbCtxKey} from 'vs/platform/contextkey/common/contextkey'; import {IMessageService} from 'vs/platform/message/common/message'; import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry'; import {IConfigurationService, getConfigurationValue} from 'vs/platform/configuration/common/configuration'; diff --git a/src/vs/editor/contrib/rename/browser/rename.ts b/src/vs/editor/contrib/rename/browser/rename.ts index d8b10997c9c..eeed73b5e35 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, IKeybindingService, KbExpr} from 'vs/platform/keybinding/common/keybinding'; +import {KbCtxKey, IKeybindingContextKey, IKeybindingService, KbExpr} 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'; diff --git a/src/vs/editor/contrib/selectionClipboard/electron-browser/selectionClipboard.ts b/src/vs/editor/contrib/selectionClipboard/electron-browser/selectionClipboard.ts index af29136a973..a85578f0ea7 100644 --- a/src/vs/editor/contrib/selectionClipboard/electron-browser/selectionClipboard.ts +++ b/src/vs/editor/contrib/selectionClipboard/electron-browser/selectionClipboard.ts @@ -11,7 +11,7 @@ import {ICodeEditor, IEditorMouseEvent} from 'vs/editor/browser/editorBrowser'; import {Disposable} from 'vs/base/common/lifecycle'; import {EndOfLinePreference, IEditorContribution, ICursorSelectionChangedEvent, IConfigurationChangedEvent} from 'vs/editor/common/editorCommon'; import {EditorBrowserRegistry} from 'vs/editor/browser/editorBrowserExtensions'; -import {IKeybindingService} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService} from 'vs/platform/contextkey/common/contextkey'; import {RunOnceScheduler} from 'vs/base/common/async'; import {Range} from 'vs/editor/common/core/range'; diff --git a/src/vs/editor/contrib/snippet/common/snippet.ts b/src/vs/editor/contrib/snippet/common/snippet.ts index e2185c70767..b70d7360137 100644 --- a/src/vs/editor/contrib/snippet/common/snippet.ts +++ b/src/vs/editor/contrib/snippet/common/snippet.ts @@ -8,7 +8,7 @@ import * as collections from 'vs/base/common/collections'; import {KeyCode, KeyMod} from 'vs/base/common/keyCodes'; import * as strings from 'vs/base/common/strings'; -import {KbCtxKey, IKeybindingContextKey, IKeybindingService} from 'vs/platform/keybinding/common/keybinding'; +import {KbCtxKey, IKeybindingContextKey, IKeybindingService} from 'vs/platform/contextkey/common/contextkey'; import {EditOperation} from 'vs/editor/common/core/editOperation'; import {Range} from 'vs/editor/common/core/range'; import {Selection} from 'vs/editor/common/core/selection'; diff --git a/src/vs/editor/contrib/suggest/browser/suggest.ts b/src/vs/editor/contrib/suggest/browser/suggest.ts index a9183eeac19..6fb484d5490 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/keybinding/common/keybinding'; +import { KbExpr } 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'; diff --git a/src/vs/editor/contrib/suggest/browser/suggestWidget.ts b/src/vs/editor/contrib/suggest/browser/suggestWidget.ts index f4043cb7f76..3def13ef0fb 100644 --- a/src/vs/editor/contrib/suggest/browser/suggestWidget.ts +++ b/src/vs/editor/contrib/suggest/browser/suggestWidget.ts @@ -17,7 +17,8 @@ import { IDelegate, IFocusChangeEvent, IRenderer, ISelectionChangeEvent } from ' import { List } from 'vs/base/browser/ui/list/listWidget'; import { DomScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; -import { IKeybindingContextKey, IKeybindingService, IKeybindingService2 } from 'vs/platform/keybinding/common/keybinding'; +import { IKeybindingService2 } from 'vs/platform/keybinding/common/keybinding'; +import { IKeybindingContextKey, IKeybindingService } from 'vs/platform/contextkey/common/contextkey'; import { IConfigurationChangedEvent } from 'vs/editor/common/editorCommon'; import { ContentWidgetPositionPreference, ICodeEditor, IContentWidget, IContentWidgetPosition } from 'vs/editor/browser/editorBrowser'; import { Context as SuggestContext } from '../common/suggest'; diff --git a/src/vs/editor/contrib/suggest/browser/tabCompletion.ts b/src/vs/editor/contrib/suggest/browser/tabCompletion.ts index 2a1a2e0aecd..ce67ab28aa2 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, IKeybindingService, KbExpr} from 'vs/platform/keybinding/common/keybinding'; +import {KbCtxKey, IKeybindingService, KbExpr} 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'; diff --git a/src/vs/editor/contrib/suggest/common/suggest.ts b/src/vs/editor/contrib/suggest/common/suggest.ts index 86f747e12ce..06b1fb8cc72 100644 --- a/src/vs/editor/contrib/suggest/common/suggest.ts +++ b/src/vs/editor/contrib/suggest/common/suggest.ts @@ -16,7 +16,7 @@ import {ISuggestResult, ISuggestSupport, ISuggestion, SuggestRegistry} from 'vs/ import {ISnippetsRegistry, Extensions} from 'vs/editor/common/modes/snippetsRegistry'; import {Position} from 'vs/editor/common/core/position'; import {Registry} from 'vs/platform/platform'; -import {KbCtxKey} from 'vs/platform/keybinding/common/keybinding'; +import {KbCtxKey} from 'vs/platform/contextkey/common/contextkey'; export const Context = { Visible: new KbCtxKey('suggestWidgetVisible', false), diff --git a/src/vs/editor/contrib/zoneWidget/browser/peekViewWidget.ts b/src/vs/editor/contrib/zoneWidget/browser/peekViewWidget.ts index 5d7a1077736..52df1840c64 100644 --- a/src/vs/editor/contrib/zoneWidget/browser/peekViewWidget.ts +++ b/src/vs/editor/contrib/zoneWidget/browser/peekViewWidget.ts @@ -19,7 +19,7 @@ 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/keybinding/common/keybinding'; +import {KbExpr, KbCtxKey} from 'vs/platform/contextkey/common/contextkey'; export var IPeekViewService = createDecorator('peekViewService'); diff --git a/src/vs/editor/test/common/mocks/mockCodeEditor.ts b/src/vs/editor/test/common/mocks/mockCodeEditor.ts index 58a9e825cc2..98ed7cb77af 100644 --- a/src/vs/editor/test/common/mocks/mockCodeEditor.ts +++ b/src/vs/editor/test/common/mocks/mockCodeEditor.ts @@ -9,7 +9,7 @@ import {ICodeEditorService} from 'vs/editor/common/services/codeEditorService'; import {ServiceCollection} from 'vs/platform/instantiation/common/serviceCollection'; import {InstantiationService} from 'vs/platform/instantiation/common/instantiationService'; import {ICommandService, NullCommandService} from 'vs/platform/commands/common/commands'; -import {IKeybindingService, IKeybindingScopeLocation} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService, IKeybindingScopeLocation} from 'vs/platform/contextkey/common/contextkey'; import {MockKeybindingService} from 'vs/platform/keybinding/test/common/mockKeybindingService'; import {ITelemetryService, NullTelemetryService} from 'vs/platform/telemetry/common/telemetry'; import {CommonCodeEditor} from 'vs/editor/common/commonCodeEditor'; diff --git a/src/vs/platform/actions/browser/menusExtensionPoint.ts b/src/vs/platform/actions/browser/menusExtensionPoint.ts index 6057a293b49..7be271a09c1 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/keybinding/common/keybinding'; +import {KbExpr} from 'vs/platform/contextkey/common/contextkey'; import {MenuId, MenuRegistry} from 'vs/platform/actions/common/actions'; namespace schema { diff --git a/src/vs/platform/actions/common/actions.ts b/src/vs/platform/actions/common/actions.ts index fff332c4d10..f0adc9b57ee 100644 --- a/src/vs/platform/actions/common/actions.ts +++ b/src/vs/platform/actions/common/actions.ts @@ -9,7 +9,8 @@ import Actions = require('vs/base/common/actions'); 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 {KbExpr, IKeybindings, IKeybindingService} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindings} from 'vs/platform/keybinding/common/keybinding'; +import {KbExpr, IKeybindingService} 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'; diff --git a/src/vs/platform/actions/common/menuService.ts b/src/vs/platform/actions/common/menuService.ts index 30ce157f5bd..f59123b4490 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, IKeybindingService} from 'vs/platform/keybinding/common/keybinding'; +import {KbExpr, IKeybindingService} 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'; diff --git a/src/vs/platform/actions/common/resourceContextKey.ts b/src/vs/platform/actions/common/resourceContextKey.ts index 45340cc91f5..0b5c5243729 100644 --- a/src/vs/platform/actions/common/resourceContextKey.ts +++ b/src/vs/platform/actions/common/resourceContextKey.ts @@ -5,7 +5,7 @@ 'use strict'; import URI from 'vs/base/common/uri'; -import {KbCtxKey, IKeybindingService, IKeybindingContextKey} from 'vs/platform/keybinding/common/keybinding'; +import {KbCtxKey, IKeybindingService, IKeybindingContextKey} from 'vs/platform/contextkey/common/contextkey'; import {IModeService} from 'vs/editor/common/services/modeService'; export class ResourceContextKey implements IKeybindingContextKey { diff --git a/src/vs/platform/contextkey/browser/contextKeyService.ts b/src/vs/platform/contextkey/browser/contextKeyService.ts new file mode 100644 index 00000000000..965b1a7b2f4 --- /dev/null +++ b/src/vs/platform/contextkey/browser/contextKeyService.ts @@ -0,0 +1,288 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +'use strict'; + +import 'vs/css!./keybindings'; +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, IKeybindingService, SET_CONTEXT_COMMAND_ID, KEYBINDING_CONTEXT_ATTR, KbExpr} from 'vs/platform/contextkey/common/contextkey'; +import {IConfigurationService} from 'vs/platform/configuration/common/configuration'; +import Event, {Emitter, debounceEvent} from 'vs/base/common/event'; + +export class KeybindingContext { + protected _parent: KeybindingContext; + protected _value: any; + protected _id: number; + + constructor(id: number, parent: KeybindingContext) { + this._id = id; + this._parent = parent; + this._value = Object.create(null); + this._value['_contextId'] = id; + } + + public setValue(key: string, value: any): boolean { + // console.log('SET ' + key + ' = ' + value + ' ON ' + this._id); + if (this._value[key] !== value) { + this._value[key] = value; + return true; + } + } + + public removeValue(key: string): boolean { + // console.log('REMOVE ' + key + ' FROM ' + this._id); + return delete this._value[key]; + } + + public getValue(key: string): T { + const ret = this._value[key]; + if (typeof ret === 'undefined' && this._parent) { + return this._parent.getValue(key); + } + return ret; + } + + public fillInContext(bucket: any): void { + if (this._parent) { + this._parent.fillInContext(bucket); + } + for (let key in this._value) { + bucket[key] = this._value[key]; + } + } +} + +class ConfigAwareKeybindingContext extends KeybindingContext { + + private _emitter: Emitter; + private _subscription: IDisposable; + + constructor(id: number, configurationService: IConfigurationService, emitter:Emitter) { + super(id, null); + + this._emitter = emitter; + this._subscription = configurationService.onDidUpdateConfiguration(e => this._updateConfigurationContext(e.config)); + this._updateConfigurationContext(configurationService.getConfiguration()); + } + + public dispose() { + this._subscription.dispose(); + } + + private _updateConfigurationContext(config: any) { + + // remove old config.xyz values + for (let key in this._value) { + if (key.indexOf('config.') === 0) { + delete this._value[key]; + } + } + + // add new value from config + const walk = (obj: any, keys: string[]) => { + for (let key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + keys.push(key); + let value = obj[key]; + if (typeof value === 'boolean') { + const configKey = keys.join('.'); + this._value[configKey] = value; + this._emitter.fire(configKey); + } else if (typeof value === 'object') { + walk(value, keys); + } + keys.pop(); + } + } + }; + walk(config, ['config']); + } +} + +class KeybindingContextKey implements IKeybindingContextKey { + + private _parent: AbstractKeybindingService; + private _key: string; + private _defaultValue: T; + + constructor(parent: AbstractKeybindingService, key: string, defaultValue: T) { + this._parent = parent; + this._key = key; + this._defaultValue = defaultValue; + this.reset(); + } + + public set(value: T): void { + this._parent.setContext(this._key, value); + } + + public reset(): void { + if (typeof this._defaultValue === 'undefined') { + this._parent.removeContext(this._key); + } else { + this._parent.setContext(this._key, this._defaultValue); + } + } + + public get(): T { + return this._parent.getContextValue(this._key); + } + +} + +export abstract class AbstractKeybindingService { + public _serviceBrand: any; + + protected _onDidChangeContext: Event; + protected _onDidChangeContextKey: Emitter; + protected _myContextId: number; + + constructor(myContextId: number) { + this._myContextId = myContextId; + this._onDidChangeContextKey = new Emitter(); + } + + public createKey(key: string, defaultValue: T): IKeybindingContextKey { + return new KeybindingContextKey(this, key, defaultValue); + } + + public get onDidChangeContext(): Event { + if (!this._onDidChangeContext) { + this._onDidChangeContext = debounceEvent(this._onDidChangeContextKey.event, (prev: string[], cur) => { + if (!prev) { + prev = [cur]; + } else if (prev.indexOf(cur) < 0) { + prev.push(cur); + } + return prev; + }, 25); + } + return this._onDidChangeContext; + } + + public createScoped(domNode: IKeybindingScopeLocation): IKeybindingService { + return new ScopedKeybindingService(this, this._onDidChangeContextKey, domNode); + } + + public contextMatchesRules(rules: KbExpr): boolean { + const ctx = Object.create(null); + this.getContext(this._myContextId).fillInContext(ctx); + const result = KeybindingResolver.contextMatchesRules(ctx, rules); + // console.group(rules.serialize() + ' -> ' + result); + // rules.keys().forEach(key => { console.log(key, ctx[key]); }); + // console.groupEnd(); + return result; + } + + public getContextValue(key: string): T { + return this.getContext(this._myContextId).getValue(key); + } + + public setContext(key: string, value: any): void { + if(this.getContext(this._myContextId).setValue(key, value)) { + this._onDidChangeContextKey.fire(key); + } + } + + public removeContext(key: string): void { + if(this.getContext(this._myContextId).removeValue(key)) { + this._onDidChangeContextKey.fire(key); + } + } + + public abstract getContext(contextId: number): KeybindingContext; + public abstract createChildContext(parentContextId?: number): number; + public abstract disposeContext(contextId: number): void; + +} + +export abstract class KeybindingService extends AbstractKeybindingService implements IKeybindingService { + + private _lastContextId: number; + private _contexts: { + [contextId: string]: KeybindingContext; + }; + + private _toDispose: IDisposable[] = []; + + constructor(configurationService: IConfigurationService) { + super(0); + this._lastContextId = 0; + this._contexts = Object.create(null); + + const myContext = new ConfigAwareKeybindingContext(this._myContextId, configurationService, this._onDidChangeContextKey); + this._contexts[String(this._myContextId)] = myContext; + this._toDispose.push(myContext); + + // Uncomment this to see the contexts continuously logged + // let lastLoggedValue: string = null; + // setInterval(() => { + // let values = Object.keys(this._contexts).map((key) => this._contexts[key]); + // let logValue = values.map(v => JSON.stringify(v._value, null, '\t')).join('\n'); + // if (lastLoggedValue !== logValue) { + // lastLoggedValue = logValue; + // console.log(lastLoggedValue); + // } + // }, 2000); + } + + public dispose(): void { + this._toDispose = dispose(this._toDispose); + } + + public getContext(contextId: number): KeybindingContext { + return this._contexts[String(contextId)]; + } + + public createChildContext(parentContextId: number = this._myContextId): number { + let id = (++this._lastContextId); + this._contexts[String(id)] = new KeybindingContext(id, this.getContext(parentContextId)); + return id; + } + + public disposeContext(contextId: number): void { + delete this._contexts[String(contextId)]; + } +} + +CommandsRegistry.registerCommand(SET_CONTEXT_COMMAND_ID, function (accessor, contextKey: any, contextValue: any) { + accessor.get(IKeybindingService).createKey(String(contextKey), contextValue); +}); + +class ScopedKeybindingService extends AbstractKeybindingService { + + private _parent: AbstractKeybindingService; + private _domNode: IKeybindingScopeLocation; + + constructor(parent: AbstractKeybindingService, emitter: Emitter, domNode: IKeybindingScopeLocation) { + super(parent.createChildContext()); + this._parent = parent; + this._onDidChangeContextKey = emitter; + this._domNode = domNode; + this._domNode.setAttribute(KEYBINDING_CONTEXT_ATTR, String(this._myContextId)); + } + + public dispose(): void { + this._parent.disposeContext(this._myContextId); + this._domNode.removeAttribute(KEYBINDING_CONTEXT_ATTR); + } + + public get onDidChangeContext(): Event { + return this._parent.onDidChangeContext; + } + + public getContext(contextId: number): KeybindingContext { + return this._parent.getContext(contextId); + } + + public createChildContext(parentContextId: number = this._myContextId): number { + return this._parent.createChildContext(parentContextId); + } + + public disposeContext(contextId: number): void { + this._parent.disposeContext(contextId); + } +} diff --git a/src/vs/platform/contextkey/common/contextkey.ts b/src/vs/platform/contextkey/common/contextkey.ts new file mode 100644 index 00000000000..a8d11c3aa9f --- /dev/null +++ b/src/vs/platform/contextkey/common/contextkey.ts @@ -0,0 +1,462 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +'use strict'; + +import {createDecorator} from 'vs/platform/instantiation/common/instantiation'; +import Event from 'vs/base/common/event'; + +export const KEYBINDING_CONTEXT_ATTR = 'data-keybinding-context'; + +export enum KbExprType { + KbDefinedExpression = 1, + KbNotExpression = 2, + KbEqualsExpression = 3, + KbNotEqualsExpression = 4, + KbAndExpression = 5 +} + +export interface KbExpr { + getType(): KbExprType; + equals(other: KbExpr): boolean; + evaluate(context: any): boolean; + normalize(): KbExpr; + serialize(): string; + keys(): string[]; +} + +function cmp(a:KbExpr, b:KbExpr): number { + let aType = a.getType(); + let bType = b.getType(); + if (aType !== bType) { + return aType - bType; + } + switch(aType) { + case KbExprType.KbDefinedExpression: + return (a).cmp(b); + case KbExprType.KbNotExpression: + return (a).cmp(b); + case KbExprType.KbEqualsExpression: + return (a).cmp(b); + case KbExprType.KbNotEqualsExpression: + return (a).cmp(b); + default: + throw new Error('Unknown KbExpr!'); + } +} + +export class KbDefinedExpression implements KbExpr { + constructor(protected key: string) { + } + + public getType(): KbExprType { + return KbExprType.KbDefinedExpression; + } + + public cmp(other:KbDefinedExpression): number { + if (this.key < other.key) { + return -1; + } + if (this.key > other.key) { + return 1; + } + return 0; + } + + public equals(other: KbExpr): boolean { + if (other instanceof KbDefinedExpression) { + return (this.key === other.key); + } + return false; + } + + public evaluate(context: any): boolean { + return (!!context[this.key]); + } + + public normalize(): KbExpr { + return this; + } + + public serialize(): string { + return this.key; + } + + public keys(): string[]{ + return [this.key]; + } +} + +export class KbEqualsExpression implements KbExpr { + constructor(private key: string, private value: any) { + } + + public getType(): KbExprType { + return KbExprType.KbEqualsExpression; + } + + public cmp(other:KbEqualsExpression): number { + if (this.key < other.key) { + return -1; + } + if (this.key > other.key) { + return 1; + } + if (this.value < other.value) { + return -1; + } + if (this.value > other.value) { + return 1; + } + return 0; + } + + public equals(other: KbExpr): boolean { + if (other instanceof KbEqualsExpression) { + return (this.key === other.key && this.value === other.value); + } + return false; + } + + public evaluate(context: any): boolean { + /* tslint:disable:triple-equals */ + // Intentional == + return (context[this.key] == this.value); + /* tslint:enable:triple-equals */ + } + + public normalize(): KbExpr { + if (typeof this.value === 'boolean') { + if (this.value) { + return new KbDefinedExpression(this.key); + } + return new KbNotExpression(this.key); + } + return this; + } + + public serialize(): string { + if (typeof this.value === 'boolean') { + return this.normalize().serialize(); + } + + return this.key + ' == \'' + this.value + '\''; + } + + public keys(): string[]{ + return [this.key]; + } +} + +export class KbNotEqualsExpression implements KbExpr { + constructor(private key: string, private value: any) { + } + + public getType(): KbExprType { + return KbExprType.KbNotEqualsExpression; + } + + public cmp(other:KbNotEqualsExpression): number { + if (this.key < other.key) { + return -1; + } + if (this.key > other.key) { + return 1; + } + if (this.value < other.value) { + return -1; + } + if (this.value > other.value) { + return 1; + } + return 0; + } + + public equals(other: KbExpr): boolean { + if (other instanceof KbNotEqualsExpression) { + return (this.key === other.key && this.value === other.value); + } + return false; + } + + public evaluate(context: any): boolean { + /* tslint:disable:triple-equals */ + // Intentional != + return (context[this.key] != this.value); + /* tslint:enable:triple-equals */ + } + + public normalize(): KbExpr { + if (typeof this.value === 'boolean') { + if (this.value) { + return new KbNotExpression(this.key); + } + return new KbDefinedExpression(this.key); + } + return this; + } + + public serialize(): string { + if (typeof this.value === 'boolean') { + return this.normalize().serialize(); + } + + return this.key + ' != \'' + this.value + '\''; + } + + public keys(): string[]{ + return [this.key]; + } +} + +export class KbNotExpression implements KbExpr { + constructor(private key: string) { + } + + public getType(): KbExprType { + return KbExprType.KbNotExpression; + } + + public cmp(other:KbNotExpression): number { + if (this.key < other.key) { + return -1; + } + if (this.key > other.key) { + return 1; + } + return 0; + } + + public equals(other: KbExpr): boolean { + if (other instanceof KbNotExpression) { + return (this.key === other.key); + } + return false; + } + + public evaluate(context: any): boolean { + return (!context[this.key]); + } + + public normalize(): KbExpr { + return this; + } + + public serialize(): string { + return '!' + this.key; + } + + public keys(): string[]{ + return [this.key]; + } +} + +export class KbAndExpression implements KbExpr { + private expr: KbExpr[]; + + constructor(expr: KbExpr[]) { + this.expr = KbAndExpression._normalizeArr(expr); + } + + public getType(): KbExprType { + return KbExprType.KbAndExpression; + } + + public equals(other: KbExpr): boolean { + if (other instanceof KbAndExpression) { + if (this.expr.length !== other.expr.length) { + return false; + } + for (let i = 0, len = this.expr.length; i < len; i++) { + if (!this.expr[i].equals(other.expr[i])) { + return false; + } + } + return true; + } + } + + public evaluate(context: any): boolean { + for (let i = 0, len = this.expr.length; i < len; i++) { + if (!this.expr[i].evaluate(context)) { + return false; + } + } + return true; + } + + private static _normalizeArr(arr:KbExpr[]): KbExpr[] { + let expr: KbExpr[] = []; + + if (arr) { + for (let i = 0, len = arr.length; i < len; i++) { + let e = arr[i]; + if (!e) { + continue; + } + + e = e.normalize(); + if (!e) { + continue; + } + + if (e instanceof KbAndExpression) { + expr = expr.concat(e.expr); + continue; + } + + expr.push(e); + } + + expr.sort(cmp); + } + + return expr; + } + + public normalize(): KbExpr { + if (this.expr.length === 0) { + return null; + } + + if (this.expr.length === 1) { + return this.expr[0]; + } + + return this; + } + + public serialize(): string { + if (this.expr.length === 0) { + return ''; + } + if (this.expr.length === 1) { + return this.normalize().serialize(); + } + return this.expr.map(e => e.serialize()).join(' && '); + } + + public keys(): string[]{ + const result: string[] = []; + for (let expr of this.expr) { + result.push(...expr.keys()); + } + return result; + } +} + +export class KbCtxKey extends KbDefinedExpression { + + private _defaultValue: T; + + constructor(key:string, defaultValue:T) { + super(key); + this._defaultValue = defaultValue; + } + + public bindTo(target:IKeybindingService): IKeybindingContextKey { + return target.createKey(this.key, this._defaultValue); + } + + public getValue(target:IKeybindingService): T { + return target.getContextValue(this.key); + } + + public toNegated(): KbExpr { + return KbExpr.not(this.key); + } + + public isEqualTo(value:string): KbExpr { + return KbExpr.equals(this.key, value); + } +} + +export let KbExpr = { + 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 => { + if (!serialized) { + return null; + } + + let pieces = serialized.split('&&'); + let result = new KbAndExpression(pieces.map(p => KbExpr._deserializeOne(p))); + return result.normalize(); + }, + + _deserializeOne: (serializedOne: string): KbExpr => { + serializedOne = serializedOne.trim(); + + if (serializedOne.indexOf('!=') >= 0) { + let pieces = serializedOne.split('!='); + return new KbNotEqualsExpression(pieces[0].trim(), KbExpr._deserializeValue(pieces[1])); + } + + if (serializedOne.indexOf('==') >= 0) { + let pieces = serializedOne.split('=='); + return new KbEqualsExpression(pieces[0].trim(), KbExpr._deserializeValue(pieces[1])); + } + + if (/^\!\s*/.test(serializedOne)) { + return new KbNotExpression(serializedOne.substr(1).trim()); + } + + return new KbDefinedExpression(serializedOne); + }, + + _deserializeValue: (serializedValue: string): any => { + serializedValue = serializedValue.trim(); + + if (serializedValue === 'true') { + return true; + } + + if (serializedValue === 'false') { + return false; + } + + let m = /^'([^']*)'$/.exec(serializedValue); + if (m) { + return m[1].trim(); + } + + return serializedValue; + } +}; + +export interface IKeybindingContextKey { + set(value: T): void; + reset(): void; + get(): T; +} + +export interface IKeybindingScopeLocation { + setAttribute(attr: string, value: string): void; + removeAttribute(attr: string): void; +} + +export interface IKeybindingContext { + fillInContext(bucket: any): void; +} + +export let IKeybindingService = createDecorator('keybindingService'); + +export interface IKeybindingService { + _serviceBrand: any; + dispose(): void; + + onDidChangeContext: Event; + createKey(key: string, defaultValue: T): IKeybindingContextKey; + contextMatchesRules(rules: KbExpr): boolean; + getContextValue(key: string): T; + + createScoped(domNode: IKeybindingScopeLocation): IKeybindingService; + + getContext(contextId: number): IKeybindingContext; +} + +export const SET_CONTEXT_COMMAND_ID = 'setContext'; diff --git a/src/vs/platform/keybinding/browser/keybindingServiceImpl.ts b/src/vs/platform/keybinding/browser/keybindingServiceImpl.ts index 518f027faf8..9eadc4d2d70 100644 --- a/src/vs/platform/keybinding/browser/keybindingServiceImpl.ts +++ b/src/vs/platform/keybinding/browser/keybindingServiceImpl.ts @@ -15,137 +15,13 @@ import * as dom from 'vs/base/browser/dom'; import {IKeyboardEvent, StandardKeyboardEvent} from 'vs/base/browser/keyboardEvent'; import {ICommandService, CommandsRegistry, ICommandHandler, ICommandHandlerDescription} from 'vs/platform/commands/common/commands'; import {KeybindingResolver} from 'vs/platform/keybinding/common/keybindingResolver'; -import {IKeybindingContextKey, IKeybindingItem, IKeybindingScopeLocation, IKeybindingService, IKeybindingService2, SET_CONTEXT_COMMAND_ID, KbExpr} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingItem, IKeybindingService2} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService, KEYBINDING_CONTEXT_ATTR} from 'vs/platform/contextkey/common/contextkey'; import {KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry'; import {IStatusbarService} from 'vs/platform/statusbar/common/statusbar'; import {IMessageService} from 'vs/platform/message/common/message'; -import {IConfigurationService} from 'vs/platform/configuration/common/configuration'; -import Event, {Emitter, debounceEvent} from 'vs/base/common/event'; -let KEYBINDING_CONTEXT_ATTR = 'data-keybinding-context'; - -export class KeybindingContext { - protected _parent: KeybindingContext; - protected _value: any; - protected _id: number; - - constructor(id: number, parent: KeybindingContext) { - this._id = id; - this._parent = parent; - this._value = Object.create(null); - this._value['_contextId'] = id; - } - - public setValue(key: string, value: any): boolean { - // console.log('SET ' + key + ' = ' + value + ' ON ' + this._id); - if (this._value[key] !== value) { - this._value[key] = value; - return true; - } - } - - public removeValue(key: string): boolean { - // console.log('REMOVE ' + key + ' FROM ' + this._id); - return delete this._value[key]; - } - - public getValue(key: string): T { - const ret = this._value[key]; - if (typeof ret === 'undefined' && this._parent) { - return this._parent.getValue(key); - } - return ret; - } - - public fillInContext(bucket: any): void { - if (this._parent) { - this._parent.fillInContext(bucket); - } - for (let key in this._value) { - bucket[key] = this._value[key]; - } - } -} - -class ConfigAwareKeybindingContext extends KeybindingContext { - - private _emitter: Emitter; - private _subscription: IDisposable; - - constructor(id: number, configurationService: IConfigurationService, emitter:Emitter) { - super(id, null); - - this._emitter = emitter; - this._subscription = configurationService.onDidUpdateConfiguration(e => this._updateConfigurationContext(e.config)); - this._updateConfigurationContext(configurationService.getConfiguration()); - } - - public dispose() { - this._subscription.dispose(); - } - - private _updateConfigurationContext(config: any) { - - // remove old config.xyz values - for (let key in this._value) { - if (key.indexOf('config.') === 0) { - delete this._value[key]; - } - } - - // add new value from config - const walk = (obj: any, keys: string[]) => { - for (let key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key)) { - keys.push(key); - let value = obj[key]; - if (typeof value === 'boolean') { - const configKey = keys.join('.'); - this._value[configKey] = value; - this._emitter.fire(configKey); - } else if (typeof value === 'object') { - walk(value, keys); - } - keys.pop(); - } - } - }; - walk(config, ['config']); - } -} - -class KeybindingContextKey implements IKeybindingContextKey { - - private _parent: AbstractKeybindingService; - private _key: string; - private _defaultValue: T; - - constructor(parent: AbstractKeybindingService, key: string, defaultValue: T) { - this._parent = parent; - this._key = key; - this._defaultValue = defaultValue; - this.reset(); - } - - public set(value: T): void { - this._parent.setContext(this._key, value); - } - - public reset(): void { - if (typeof this._defaultValue === 'undefined') { - this._parent.removeContext(this._key); - } else { - this._parent.setContext(this._key, this._defaultValue); - } - } - - public get(): T { - return this._parent.getContextValue(this._key); - } - -} - -export class KeybindingService2 implements IKeybindingService2 { +export abstract class KeybindingService2 implements IKeybindingService2 { public _serviceBrand: any; private _toDispose: IDisposable[] = []; @@ -316,157 +192,3 @@ export class KeybindingService2 implements IKeybindingService2 { return 0; } } - -export abstract class AbstractKeybindingService { - public _serviceBrand: any; - - protected _onDidChangeContext: Event; - protected _onDidChangeContextKey: Emitter; - protected _myContextId: number; - - constructor(myContextId: number) { - this._myContextId = myContextId; - this._onDidChangeContextKey = new Emitter(); - } - - public createKey(key: string, defaultValue: T): IKeybindingContextKey { - return new KeybindingContextKey(this, key, defaultValue); - } - - public get onDidChangeContext(): Event { - if (!this._onDidChangeContext) { - this._onDidChangeContext = debounceEvent(this._onDidChangeContextKey.event, (prev: string[], cur) => { - if (!prev) { - prev = [cur]; - } else if (prev.indexOf(cur) < 0) { - prev.push(cur); - } - return prev; - }, 25); - } - return this._onDidChangeContext; - } - - public createScoped(domNode: IKeybindingScopeLocation): IKeybindingService { - return new ScopedKeybindingService(this, this._onDidChangeContextKey, domNode); - } - - public contextMatchesRules(rules: KbExpr): boolean { - const ctx = Object.create(null); - this.getContext(this._myContextId).fillInContext(ctx); - const result = KeybindingResolver.contextMatchesRules(ctx, rules); - // console.group(rules.serialize() + ' -> ' + result); - // rules.keys().forEach(key => { console.log(key, ctx[key]); }); - // console.groupEnd(); - return result; - } - - public getContextValue(key: string): T { - return this.getContext(this._myContextId).getValue(key); - } - - public setContext(key: string, value: any): void { - if(this.getContext(this._myContextId).setValue(key, value)) { - this._onDidChangeContextKey.fire(key); - } - } - - public removeContext(key: string): void { - if(this.getContext(this._myContextId).removeValue(key)) { - this._onDidChangeContextKey.fire(key); - } - } - - public abstract getContext(contextId: number): KeybindingContext; - public abstract createChildContext(parentContextId?: number): number; - public abstract disposeContext(contextId: number): void; - -} - -export abstract class KeybindingService extends AbstractKeybindingService implements IKeybindingService { - - private _lastContextId: number; - private _contexts: { - [contextId: string]: KeybindingContext; - }; - - private _toDispose: IDisposable[] = []; - - constructor(configurationService: IConfigurationService) { - super(0); - this._lastContextId = 0; - this._contexts = Object.create(null); - - const myContext = new ConfigAwareKeybindingContext(this._myContextId, configurationService, this._onDidChangeContextKey); - this._contexts[String(this._myContextId)] = myContext; - this._toDispose.push(myContext); - - // Uncomment this to see the contexts continuously logged - // let lastLoggedValue: string = null; - // setInterval(() => { - // let values = Object.keys(this._contexts).map((key) => this._contexts[key]); - // let logValue = values.map(v => JSON.stringify(v._value, null, '\t')).join('\n'); - // if (lastLoggedValue !== logValue) { - // lastLoggedValue = logValue; - // console.log(lastLoggedValue); - // } - // }, 2000); - } - - public dispose(): void { - this._toDispose = dispose(this._toDispose); - } - - public getContext(contextId: number): KeybindingContext { - return this._contexts[String(contextId)]; - } - - public createChildContext(parentContextId: number = this._myContextId): number { - let id = (++this._lastContextId); - this._contexts[String(id)] = new KeybindingContext(id, this.getContext(parentContextId)); - return id; - } - - public disposeContext(contextId: number): void { - delete this._contexts[String(contextId)]; - } -} - -CommandsRegistry.registerCommand(SET_CONTEXT_COMMAND_ID, function (accessor, contextKey: any, contextValue: any) { - accessor.get(IKeybindingService).createKey(String(contextKey), contextValue); -}); - -class ScopedKeybindingService extends AbstractKeybindingService { - - private _parent: AbstractKeybindingService; - private _domNode: IKeybindingScopeLocation; - - constructor(parent: AbstractKeybindingService, emitter: Emitter, domNode: IKeybindingScopeLocation) { - super(parent.createChildContext()); - this._parent = parent; - this._onDidChangeContextKey = emitter; - this._domNode = domNode; - this._domNode.setAttribute(KEYBINDING_CONTEXT_ATTR, String(this._myContextId)); - } - - public dispose(): void { - this._parent.disposeContext(this._myContextId); - this._domNode.removeAttribute(KEYBINDING_CONTEXT_ATTR); - } - - public get onDidChangeContext(): Event { - return this._parent.onDidChangeContext; - } - - public getContext(contextId: number): KeybindingContext { - return this._parent.getContext(contextId); - } - - public createChildContext(parentContextId: number = this._myContextId): number { - return this._parent.createChildContext(parentContextId); - } - - public disposeContext(contextId: number): void { - this._parent.disposeContext(contextId); - } -} diff --git a/src/vs/platform/keybinding/common/keybinding.ts b/src/vs/platform/keybinding/common/keybinding.ts index eeeb9304254..d7f598743d5 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 Event from 'vs/base/common/event'; +import {KbExpr} from 'vs/platform/contextkey/common/contextkey'; export interface IUserFriendlyKeybinding { key: string; @@ -32,425 +32,6 @@ export interface IKeybindings { }; } -export enum KbExprType { - KbDefinedExpression = 1, - KbNotExpression = 2, - KbEqualsExpression = 3, - KbNotEqualsExpression = 4, - KbAndExpression = 5 -} - -export interface KbExpr { - getType(): KbExprType; - equals(other: KbExpr): boolean; - evaluate(context: any): boolean; - normalize(): KbExpr; - serialize(): string; - keys(): string[]; -} - -function cmp(a:KbExpr, b:KbExpr): number { - let aType = a.getType(); - let bType = b.getType(); - if (aType !== bType) { - return aType - bType; - } - switch(aType) { - case KbExprType.KbDefinedExpression: - return (a).cmp(b); - case KbExprType.KbNotExpression: - return (a).cmp(b); - case KbExprType.KbEqualsExpression: - return (a).cmp(b); - case KbExprType.KbNotEqualsExpression: - return (a).cmp(b); - default: - throw new Error('Unknown KbExpr!'); - } -} - -export class KbDefinedExpression implements KbExpr { - constructor(protected key: string) { - } - - public getType(): KbExprType { - return KbExprType.KbDefinedExpression; - } - - public cmp(other:KbDefinedExpression): number { - if (this.key < other.key) { - return -1; - } - if (this.key > other.key) { - return 1; - } - return 0; - } - - public equals(other: KbExpr): boolean { - if (other instanceof KbDefinedExpression) { - return (this.key === other.key); - } - return false; - } - - public evaluate(context: any): boolean { - return (!!context[this.key]); - } - - public normalize(): KbExpr { - return this; - } - - public serialize(): string { - return this.key; - } - - public keys(): string[]{ - return [this.key]; - } -} - -export class KbEqualsExpression implements KbExpr { - constructor(private key: string, private value: any) { - } - - public getType(): KbExprType { - return KbExprType.KbEqualsExpression; - } - - public cmp(other:KbEqualsExpression): number { - if (this.key < other.key) { - return -1; - } - if (this.key > other.key) { - return 1; - } - if (this.value < other.value) { - return -1; - } - if (this.value > other.value) { - return 1; - } - return 0; - } - - public equals(other: KbExpr): boolean { - if (other instanceof KbEqualsExpression) { - return (this.key === other.key && this.value === other.value); - } - return false; - } - - public evaluate(context: any): boolean { - /* tslint:disable:triple-equals */ - // Intentional == - return (context[this.key] == this.value); - /* tslint:enable:triple-equals */ - } - - public normalize(): KbExpr { - if (typeof this.value === 'boolean') { - if (this.value) { - return new KbDefinedExpression(this.key); - } - return new KbNotExpression(this.key); - } - return this; - } - - public serialize(): string { - if (typeof this.value === 'boolean') { - return this.normalize().serialize(); - } - - return this.key + ' == \'' + this.value + '\''; - } - - public keys(): string[]{ - return [this.key]; - } -} - -export class KbNotEqualsExpression implements KbExpr { - constructor(private key: string, private value: any) { - } - - public getType(): KbExprType { - return KbExprType.KbNotEqualsExpression; - } - - public cmp(other:KbNotEqualsExpression): number { - if (this.key < other.key) { - return -1; - } - if (this.key > other.key) { - return 1; - } - if (this.value < other.value) { - return -1; - } - if (this.value > other.value) { - return 1; - } - return 0; - } - - public equals(other: KbExpr): boolean { - if (other instanceof KbNotEqualsExpression) { - return (this.key === other.key && this.value === other.value); - } - return false; - } - - public evaluate(context: any): boolean { - /* tslint:disable:triple-equals */ - // Intentional != - return (context[this.key] != this.value); - /* tslint:enable:triple-equals */ - } - - public normalize(): KbExpr { - if (typeof this.value === 'boolean') { - if (this.value) { - return new KbNotExpression(this.key); - } - return new KbDefinedExpression(this.key); - } - return this; - } - - public serialize(): string { - if (typeof this.value === 'boolean') { - return this.normalize().serialize(); - } - - return this.key + ' != \'' + this.value + '\''; - } - - public keys(): string[]{ - return [this.key]; - } -} - -export class KbNotExpression implements KbExpr { - constructor(private key: string) { - } - - public getType(): KbExprType { - return KbExprType.KbNotExpression; - } - - public cmp(other:KbNotExpression): number { - if (this.key < other.key) { - return -1; - } - if (this.key > other.key) { - return 1; - } - return 0; - } - - public equals(other: KbExpr): boolean { - if (other instanceof KbNotExpression) { - return (this.key === other.key); - } - return false; - } - - public evaluate(context: any): boolean { - return (!context[this.key]); - } - - public normalize(): KbExpr { - return this; - } - - public serialize(): string { - return '!' + this.key; - } - - public keys(): string[]{ - return [this.key]; - } -} - -export class KbAndExpression implements KbExpr { - private expr: KbExpr[]; - - constructor(expr: KbExpr[]) { - this.expr = KbAndExpression._normalizeArr(expr); - } - - public getType(): KbExprType { - return KbExprType.KbAndExpression; - } - - public equals(other: KbExpr): boolean { - if (other instanceof KbAndExpression) { - if (this.expr.length !== other.expr.length) { - return false; - } - for (let i = 0, len = this.expr.length; i < len; i++) { - if (!this.expr[i].equals(other.expr[i])) { - return false; - } - } - return true; - } - } - - public evaluate(context: any): boolean { - for (let i = 0, len = this.expr.length; i < len; i++) { - if (!this.expr[i].evaluate(context)) { - return false; - } - } - return true; - } - - private static _normalizeArr(arr:KbExpr[]): KbExpr[] { - let expr: KbExpr[] = []; - - if (arr) { - for (let i = 0, len = arr.length; i < len; i++) { - let e = arr[i]; - if (!e) { - continue; - } - - e = e.normalize(); - if (!e) { - continue; - } - - if (e instanceof KbAndExpression) { - expr = expr.concat(e.expr); - continue; - } - - expr.push(e); - } - - expr.sort(cmp); - } - - return expr; - } - - public normalize(): KbExpr { - if (this.expr.length === 0) { - return null; - } - - if (this.expr.length === 1) { - return this.expr[0]; - } - - return this; - } - - public serialize(): string { - if (this.expr.length === 0) { - return ''; - } - if (this.expr.length === 1) { - return this.normalize().serialize(); - } - return this.expr.map(e => e.serialize()).join(' && '); - } - - public keys(): string[]{ - const result: string[] = []; - for (let expr of this.expr) { - result.push(...expr.keys()); - } - return result; - } -} - -export class KbCtxKey extends KbDefinedExpression { - - private _defaultValue: T; - - constructor(key:string, defaultValue:T) { - super(key); - this._defaultValue = defaultValue; - } - - public bindTo(target:IKeybindingService): IKeybindingContextKey { - return target.createKey(this.key, this._defaultValue); - } - - public getValue(target:IKeybindingService): T { - return target.getContextValue(this.key); - } - - public toNegated(): KbExpr { - return KbExpr.not(this.key); - } - - public isEqualTo(value:string): KbExpr { - return KbExpr.equals(this.key, value); - } -} - -export let KbExpr = { - 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 => { - if (!serialized) { - return null; - } - - let pieces = serialized.split('&&'); - let result = new KbAndExpression(pieces.map(p => KbExpr._deserializeOne(p))); - return result.normalize(); - }, - - _deserializeOne: (serializedOne: string): KbExpr => { - serializedOne = serializedOne.trim(); - - if (serializedOne.indexOf('!=') >= 0) { - let pieces = serializedOne.split('!='); - return new KbNotEqualsExpression(pieces[0].trim(), KbExpr._deserializeValue(pieces[1])); - } - - if (serializedOne.indexOf('==') >= 0) { - let pieces = serializedOne.split('=='); - return new KbEqualsExpression(pieces[0].trim(), KbExpr._deserializeValue(pieces[1])); - } - - if (/^\!\s*/.test(serializedOne)) { - return new KbNotExpression(serializedOne.substr(1).trim()); - } - - return new KbDefinedExpression(serializedOne); - }, - - _deserializeValue: (serializedValue: string): any => { - serializedValue = serializedValue.trim(); - - if (serializedValue === 'true') { - return true; - } - - if (serializedValue === 'false') { - return false; - } - - let m = /^'([^']*)'$/.exec(serializedValue); - if (m) { - return m[1].trim(); - } - - return serializedValue; - } -}; - export interface IKeybindingItem { keybinding: number; command: string; @@ -459,38 +40,8 @@ export interface IKeybindingItem { weight2: number; } -export interface IKeybindingContextKey { - set(value: T): void; - reset(): void; - get(): T; -} - -export let IKeybindingService = createDecorator('keybindingService'); - -export interface IKeybindingScopeLocation { - setAttribute(attr: string, value: string): void; - removeAttribute(attr: string): void; -} - -export interface IKeybindingService { - _serviceBrand: any; - dispose(): void; - - onDidChangeContext: Event; - createKey(key: string, defaultValue: T): IKeybindingContextKey; - contextMatchesRules(rules: KbExpr): boolean; - getContextValue(key: string): T; - - createScoped(domNode: IKeybindingScopeLocation): IKeybindingService; - - getContext(contextId: number): IKeybindingContext; -} - -export interface IKeybindingContext { - fillInContext(bucket: any): void; -} - export let IKeybindingService2 = createDecorator('keybindingService2'); + export interface IKeybindingService2 { _serviceBrand: any; @@ -504,4 +55,3 @@ export interface IKeybindingService2 { customKeybindingsCount(): number; } -export const SET_CONTEXT_COMMAND_ID = 'setContext'; diff --git a/src/vs/platform/keybinding/common/keybindingResolver.ts b/src/vs/platform/keybinding/common/keybindingResolver.ts index 8313f701ba4..0e2691b8c12 100644 --- a/src/vs/platform/keybinding/common/keybindingResolver.ts +++ b/src/vs/platform/keybinding/common/keybindingResolver.ts @@ -6,7 +6,8 @@ import {BinaryKeybindings, ISimplifiedPlatform, Keybinding} from 'vs/base/common/keyCodes'; import * as platform from 'vs/base/common/platform'; -import {IKeybindingItem, IUserFriendlyKeybinding, KbExpr} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingItem, IUserFriendlyKeybinding} from 'vs/platform/keybinding/common/keybinding'; +import {KbExpr} from 'vs/platform/contextkey/common/contextkey'; export interface IResolveResult { enterChord: number; diff --git a/src/vs/platform/keybinding/common/keybindingsRegistry.ts b/src/vs/platform/keybinding/common/keybindingsRegistry.ts index 47da74b865e..cb74e5bec7f 100644 --- a/src/vs/platform/keybinding/common/keybindingsRegistry.ts +++ b/src/vs/platform/keybinding/common/keybindingsRegistry.ts @@ -6,7 +6,8 @@ import {BinaryKeybindings, KeyCode} from 'vs/base/common/keyCodes'; import * as platform from 'vs/base/common/platform'; -import {IKeybindingItem, IKeybindings, KbExpr} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingItem, IKeybindings} from 'vs/platform/keybinding/common/keybinding'; +import {KbExpr} from 'vs/platform/contextkey/common/contextkey'; import {CommandsRegistry, ICommandHandler, ICommandHandlerDescription} from 'vs/platform/commands/common/commands'; import {Registry} from 'vs/platform/platform'; diff --git a/src/vs/platform/keybinding/test/common/keybindingService.test.ts b/src/vs/platform/keybinding/test/common/keybindingService.test.ts index 7d4937cb7a5..40c308feced 100644 --- a/src/vs/platform/keybinding/test/common/keybindingService.test.ts +++ b/src/vs/platform/keybinding/test/common/keybindingService.test.ts @@ -7,7 +7,8 @@ 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, KbAndExpression, KbExpr} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingItem} from 'vs/platform/keybinding/common/keybinding'; +import {KbAndExpression, KbExpr} from 'vs/platform/contextkey/common/contextkey'; suite('Keybinding Service', () => { diff --git a/src/vs/platform/keybinding/test/common/mockKeybindingService.ts b/src/vs/platform/keybinding/test/common/mockKeybindingService.ts index 07bd4e19d5c..7ee666664ff 100644 --- a/src/vs/platform/keybinding/test/common/mockKeybindingService.ts +++ b/src/vs/platform/keybinding/test/common/mockKeybindingService.ts @@ -7,7 +7,8 @@ import {IHTMLContentElement} from 'vs/base/common/htmlContent'; import {Keybinding} from 'vs/base/common/keyCodes'; import Event from 'vs/base/common/event'; -import {IKeybindingContextKey, IKeybindingService, IKeybindingContext, IKeybindingService2, KbExpr} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService2} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingContextKey, IKeybindingService, IKeybindingContext, KbExpr} from 'vs/platform/contextkey/common/contextkey'; class MockKeybindingContextKey implements IKeybindingContextKey { private _key: string; diff --git a/src/vs/workbench/browser/parts/editor/editor.contribution.ts b/src/vs/workbench/browser/parts/editor/editor.contribution.ts index 603ab23efb6..671ff7af6d3 100644 --- a/src/vs/workbench/browser/parts/editor/editor.contribution.ts +++ b/src/vs/workbench/browser/parts/editor/editor.contribution.ts @@ -18,7 +18,8 @@ import {UntitledEditorInput} from 'vs/workbench/common/editor/untitledEditorInpu import {ResourceEditorInput} from 'vs/workbench/common/editor/resourceEditorInput'; import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation'; import {KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry'; -import {KbExpr, IKeybindings} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindings} from 'vs/platform/keybinding/common/keybinding'; +import {KbExpr} 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'; diff --git a/src/vs/workbench/browser/parts/editor/sideBySideEditorControl.ts b/src/vs/workbench/browser/parts/editor/sideBySideEditorControl.ts index 7cf4f44beb5..db4eefe8d7a 100644 --- a/src/vs/workbench/browser/parts/editor/sideBySideEditorControl.ts +++ b/src/vs/workbench/browser/parts/editor/sideBySideEditorControl.ts @@ -30,7 +30,7 @@ import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry'; import {IConfigurationService} from 'vs/platform/configuration/common/configuration'; import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation'; import {ServiceCollection} from 'vs/platform/instantiation/common/serviceCollection'; -import {IKeybindingService} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService} from 'vs/platform/contextkey/common/contextkey'; import {IExtensionService} from 'vs/platform/extensions/common/extensions'; import {IDisposable, dispose} from 'vs/base/common/lifecycle'; import {TabsTitleControl} from 'vs/workbench/browser/parts/editor/tabsTitleControl'; diff --git a/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts b/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts index f85b073beb6..728e4e48737 100644 --- a/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts +++ b/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts @@ -24,7 +24,8 @@ import {IUntitledEditorService} from 'vs/workbench/services/untitled/common/unti import {IMessageService} from 'vs/platform/message/common/message'; import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry'; import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation'; -import {IKeybindingService, IKeybindingService2} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService2} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService} from 'vs/platform/contextkey/common/contextkey'; import {IMenuService} from 'vs/platform/actions/common/actions'; import {TitleControl} from 'vs/workbench/browser/parts/editor/titleControl'; import {IQuickOpenService} from 'vs/workbench/services/quickopen/common/quickOpenService'; diff --git a/src/vs/workbench/browser/parts/editor/textDiffEditor.ts b/src/vs/workbench/browser/parts/editor/textDiffEditor.ts index 7b200beb811..52dff74994c 100644 --- a/src/vs/workbench/browser/parts/editor/textDiffEditor.ts +++ b/src/vs/workbench/browser/parts/editor/textDiffEditor.ts @@ -35,7 +35,7 @@ import {ServiceCollection} from 'vs/platform/instantiation/common/serviceCollect import {IMessageService} from 'vs/platform/message/common/message'; import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService'; import {IModeService} from 'vs/editor/common/services/modeService'; -import {KbCtxKey, IKeybindingService, IKeybindingContextKey} from 'vs/platform/keybinding/common/keybinding'; +import {KbCtxKey, IKeybindingService, IKeybindingContextKey} from 'vs/platform/contextkey/common/contextkey'; import {IThemeService} from 'vs/workbench/services/themes/common/themeService'; export const TextCompareEditorVisible = new KbCtxKey('textCompareEditorVisible', false); diff --git a/src/vs/workbench/browser/parts/editor/titleControl.ts b/src/vs/workbench/browser/parts/editor/titleControl.ts index ea89e2b45c0..b3aac60adaa 100644 --- a/src/vs/workbench/browser/parts/editor/titleControl.ts +++ b/src/vs/workbench/browser/parts/editor/titleControl.ts @@ -29,7 +29,8 @@ import {StandardMouseEvent} from 'vs/base/browser/mouseEvent'; import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry'; import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation'; import {IQuickOpenService} from 'vs/workbench/services/quickopen/common/quickOpenService'; -import {IKeybindingService, IKeybindingService2} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService2} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService} from 'vs/platform/contextkey/common/contextkey'; import {CloseEditorsInGroupAction, SplitEditorAction, CloseEditorAction, KeepEditorAction, CloseOtherEditorsInGroupAction, CloseRightEditorsInGroupAction, ShowEditorsInGroupAction} from 'vs/workbench/browser/parts/editor/editorActions'; import {IDisposable, dispose} from 'vs/base/common/lifecycle'; import {createActionItem, fillInActions} from 'vs/platform/actions/browser/menuItemActionItem'; diff --git a/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts b/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts index 11b1a554deb..56c56db8a83 100644 --- a/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts +++ b/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts @@ -37,7 +37,7 @@ import {IInstantiationService} from 'vs/platform/instantiation/common/instantiat import {IMessageService, Severity} from 'vs/platform/message/common/message'; import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry'; import {IWorkspaceContextService} from 'vs/workbench/services/workspace/common/contextService'; -import {IKeybindingService, KbCtxKey, IKeybindingContextKey} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService, KbCtxKey, IKeybindingContextKey} from 'vs/platform/contextkey/common/contextkey'; import {IHistoryService} from 'vs/workbench/services/history/common/history'; const HELP_PREFIX = '?'; diff --git a/src/vs/workbench/electron-browser/workbench.ts b/src/vs/workbench/electron-browser/workbench.ts index 9cd984e579e..0bb764f7b00 100644 --- a/src/vs/workbench/electron-browser/workbench.ts +++ b/src/vs/workbench/electron-browser/workbench.ts @@ -46,7 +46,8 @@ import {IStorageService, StorageScope} from 'vs/platform/storage/common/storage' import {ContextMenuService} from 'vs/workbench/services/contextview/electron-browser/contextmenuService'; import {WorkbenchKeybindingService, WorkbenchKeybindingService2} from 'vs/workbench/services/keybinding/electron-browser/keybindingService'; import {IWorkspace, IConfiguration} from 'vs/platform/workspace/common/workspace'; -import {KbExpr, KbCtxKey, IKeybindingService, IKeybindingService2, IKeybindingContextKey} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService2} from 'vs/platform/keybinding/common/keybinding'; +import {KbExpr, KbCtxKey, IKeybindingService, 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'; diff --git a/src/vs/workbench/parts/debug/browser/breakpointWidget.ts b/src/vs/workbench/parts/debug/browser/breakpointWidget.ts index 3bca0c85198..9ad227c5f04 100644 --- a/src/vs/workbench/parts/debug/browser/breakpointWidget.ts +++ b/src/vs/workbench/parts/debug/browser/breakpointWidget.ts @@ -18,7 +18,7 @@ import editorbrowser = require('vs/editor/browser/editorBrowser'); import {ZoneWidget} from 'vs/editor/contrib/zoneWidget/browser/zoneWidget'; import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation'; import {IContextViewService} from 'vs/platform/contextview/browser/contextView'; -import {KbCtxKey, IKeybindingService, IKeybindingContextKey} from 'vs/platform/keybinding/common/keybinding'; +import {KbCtxKey, IKeybindingService, IKeybindingContextKey} from 'vs/platform/contextkey/common/contextkey'; import debug = require('vs/workbench/parts/debug/common/debug'); import {IKeyboardEvent} from 'vs/base/browser/keyboardEvent'; diff --git a/src/vs/workbench/parts/debug/browser/debugActions.ts b/src/vs/workbench/parts/debug/browser/debugActions.ts index 169f81d8bb7..df37da7034c 100644 --- a/src/vs/workbench/parts/debug/browser/debugActions.ts +++ b/src/vs/workbench/parts/debug/browser/debugActions.ts @@ -10,7 +10,8 @@ import {TPromise} from 'vs/base/common/winjs.base'; import {Range} from 'vs/editor/common/core/range'; import editorCommon = require('vs/editor/common/editorCommon'); import editorbrowser = require('vs/editor/browser/editorBrowser'); -import {KbExpr, IKeybindingService2} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService2} from 'vs/platform/keybinding/common/keybinding'; +import {KbExpr} 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'); diff --git a/src/vs/workbench/parts/debug/common/debug.ts b/src/vs/workbench/parts/debug/common/debug.ts index 9e055fba8a3..6ace8245c6c 100644 --- a/src/vs/workbench/parts/debug/common/debug.ts +++ b/src/vs/workbench/parts/debug/common/debug.ts @@ -11,7 +11,7 @@ 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/keybinding/common/keybinding'; +import {KbCtxKey, KbExpr} from 'vs/platform/contextkey/common/contextkey'; export const VIEWLET_ID = 'workbench.view.debug'; export const REPL_ID = 'workbench.panel.repl'; diff --git a/src/vs/workbench/parts/debug/electron-browser/debugService.ts b/src/vs/workbench/parts/debug/electron-browser/debugService.ts index 2b8a925f314..c5f963c1e59 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debugService.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debugService.ts @@ -17,7 +17,7 @@ import severity from 'vs/base/common/severity'; import {TPromise} from 'vs/base/common/winjs.base'; import aria = require('vs/base/browser/ui/aria/aria'); import editorbrowser = require('vs/editor/browser/editorBrowser'); -import {IKeybindingService, IKeybindingContextKey} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService, IKeybindingContextKey} from 'vs/platform/contextkey/common/contextkey'; import {IMarkerService} from 'vs/platform/markers/common/markers'; import {ILifecycleService} from 'vs/platform/lifecycle/common/lifecycle'; import {IExtensionService} from 'vs/platform/extensions/common/extensions'; diff --git a/src/vs/workbench/parts/emmet/node/actions/expandAbbreviation.ts b/src/vs/workbench/parts/emmet/node/actions/expandAbbreviation.ts index 219d30254b6..e99967a0320 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/keybinding/common/keybinding'; +import {KbExpr} from 'vs/platform/contextkey/common/contextkey'; @editorAction class ExpandAbbreviationAction extends BasicEmmetEditorAction { diff --git a/src/vs/workbench/parts/files/browser/explorerViewlet.ts b/src/vs/workbench/parts/files/browser/explorerViewlet.ts index bf720310833..0b93a5237ec 100644 --- a/src/vs/workbench/parts/files/browser/explorerViewlet.ts +++ b/src/vs/workbench/parts/files/browser/explorerViewlet.ts @@ -30,7 +30,7 @@ import {EditorInput, EditorOptions} from 'vs/workbench/common/editor'; import {BaseEditor} from 'vs/workbench/browser/parts/editor/baseEditor'; import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService'; import {IEditorGroupService} from 'vs/workbench/services/group/common/groupService'; -import {IKeybindingService, IKeybindingContextKey} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService, IKeybindingContextKey} from 'vs/platform/contextkey/common/contextkey'; export class ExplorerViewlet extends Viewlet { private viewletContainer: Builder; diff --git a/src/vs/workbench/parts/files/browser/views/explorerViewer.ts b/src/vs/workbench/parts/files/browser/views/explorerViewer.ts index a3b07f48359..e1dfe1df30a 100644 --- a/src/vs/workbench/parts/files/browser/views/explorerViewer.ts +++ b/src/vs/workbench/parts/files/browser/views/explorerViewer.ts @@ -38,7 +38,7 @@ import {IPartService} from 'vs/workbench/services/part/common/partService'; import {IWorkspaceContextService} from 'vs/workbench/services/workspace/common/contextService'; import {IWorkspace} from 'vs/platform/workspace/common/workspace'; import {IConfigurationService} from 'vs/platform/configuration/common/configuration'; -import {IKeybindingService} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService} from 'vs/platform/contextkey/common/contextkey'; import {IContextViewService, IContextMenuService} from 'vs/platform/contextview/browser/contextView'; import {IEventService} from 'vs/platform/event/common/event'; import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation'; diff --git a/src/vs/workbench/parts/files/common/files.ts b/src/vs/workbench/parts/files/common/files.ts index 4d5e864f9d3..92836c27cc8 100644 --- a/src/vs/workbench/parts/files/common/files.ts +++ b/src/vs/workbench/parts/files/common/files.ts @@ -14,7 +14,7 @@ import {EncodingMode, EditorInput, IFileEditorInput, ConfirmResult, IWorkbenchEd import {IFileStat, IFilesConfiguration, IBaseStat, IResolveContentOptions} from 'vs/platform/files/common/files'; import {createDecorator} from 'vs/platform/instantiation/common/instantiation'; import {FileStat} from 'vs/workbench/parts/files/common/explorerViewModel'; -import {KbCtxKey} from 'vs/platform/keybinding/common/keybinding'; +import {KbCtxKey} from 'vs/platform/contextkey/common/contextkey'; /** * Explorer viewlet id. diff --git a/src/vs/workbench/parts/output/browser/output.contribution.ts b/src/vs/workbench/parts/output/browser/output.contribution.ts index 595787aa69b..620c2cd8dbe 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/keybinding/common/keybinding'; +import {KbExpr} from 'vs/platform/contextkey/common/contextkey'; // Register Service registerSingleton(IOutputService, OutputService); diff --git a/src/vs/workbench/parts/search/browser/searchViewlet.ts b/src/vs/workbench/parts/search/browser/searchViewlet.ts index d410a82153f..28581e8f10a 100644 --- a/src/vs/workbench/parts/search/browser/searchViewlet.ts +++ b/src/vs/workbench/parts/search/browser/searchViewlet.ts @@ -45,7 +45,8 @@ import {IMessageService} from 'vs/platform/message/common/message'; import {ISearchService} from 'vs/platform/search/common/search'; import {IProgressService} from 'vs/platform/progress/common/progress'; import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace'; -import {IKeybindingService, IKeybindingService2, IKeybindingContextKey} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService2} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService, IKeybindingContextKey} from 'vs/platform/contextkey/common/contextkey'; import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry'; import {KeyCode, CommonKeybindings} from 'vs/base/common/keyCodes'; import { PatternInputWidget } from 'vs/workbench/parts/search/browser/patternInputWidget'; diff --git a/src/vs/workbench/parts/search/browser/searchWidget.ts b/src/vs/workbench/parts/search/browser/searchWidget.ts index 83dfa1f8b15..4906512ec84 100644 --- a/src/vs/workbench/parts/search/browser/searchWidget.ts +++ b/src/vs/workbench/parts/search/browser/searchWidget.ts @@ -15,7 +15,8 @@ import { InputBox } from 'vs/base/browser/ui/inputbox/inputBox'; 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 { KbExpr, KbCtxKey, IKeybindingService, IKeybindingService2, IKeybindingContextKey } from 'vs/platform/keybinding/common/keybinding'; +import { IKeybindingService2 } from 'vs/platform/keybinding/common/keybinding'; +import { KbExpr, KbCtxKey, IKeybindingService, 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'; diff --git a/src/vs/workbench/parts/search/common/constants.ts b/src/vs/workbench/parts/search/common/constants.ts index 6710c749f4a..655a342ef35 100644 --- a/src/vs/workbench/parts/search/common/constants.ts +++ b/src/vs/workbench/parts/search/common/constants.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import {KbCtxKey} from 'vs/platform/keybinding/common/keybinding'; +import {KbCtxKey} from 'vs/platform/contextkey/common/contextkey'; export const VIEWLET_ID = 'workbench.view.search'; diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminal.ts b/src/vs/workbench/parts/terminal/electron-browser/terminal.ts index 96e170dde67..aa11a6806f8 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/keybinding/common/keybinding'; +import {KbCtxKey, KbExpr} from 'vs/platform/contextkey/common/contextkey'; export const TERMINAL_PANEL_ID = 'workbench.panel.terminal'; diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts index c1b232cdab6..fc209225ccb 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts @@ -11,7 +11,8 @@ import xterm = require('xterm'); import {Dimension} from 'vs/base/browser/builder'; import {IContextMenuService} from 'vs/platform/contextview/browser/contextView'; import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation'; -import {IKeybindingService2, IKeybindingContextKey} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService2} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingContextKey} from 'vs/platform/contextkey/common/contextkey'; import {IMessageService, Severity} from 'vs/platform/message/common/message'; import {ITerminalFont} from 'vs/workbench/parts/terminal/electron-browser/terminalConfigHelper'; import {ITerminalProcess, ITerminalService} from 'vs/workbench/parts/terminal/electron-browser/terminal'; diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts index d015ee41b39..82f30fe9d72 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts @@ -14,7 +14,8 @@ import {IActionItem} from 'vs/base/browser/ui/actionbar/actionbar'; import {IConfigurationService} from 'vs/platform/configuration/common/configuration'; import {IContextMenuService} from 'vs/platform/contextview/browser/contextView'; import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation'; -import {IKeybindingService2, IKeybindingContextKey} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService2} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingContextKey} from 'vs/platform/contextkey/common/contextkey'; import {IMessageService} from 'vs/platform/message/common/message'; import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry'; import {ITerminalFont, TerminalConfigHelper} from 'vs/workbench/parts/terminal/electron-browser/terminalConfigHelper'; diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalService.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalService.ts index 7b7283383f0..7ec7ee3cf42 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalService.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalService.ts @@ -14,7 +14,7 @@ import {Builder} from 'vs/base/browser/builder'; import {EndOfLinePreference} from 'vs/editor/common/editorCommon'; import {ICodeEditorService} from 'vs/editor/common/services/codeEditorService'; import {IConfigurationService} from 'vs/platform/configuration/common/configuration'; -import {IKeybindingContextKey, IKeybindingService} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingContextKey, IKeybindingService} from 'vs/platform/contextkey/common/contextkey'; import {IMessageService, Severity} from 'vs/platform/message/common/message'; import {IPanelService} from 'vs/workbench/services/panel/common/panelService'; import {IPartService} from 'vs/workbench/services/part/common/partService'; diff --git a/src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts b/src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts index 84be79a8b60..39eba476048 100644 --- a/src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts +++ b/src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts @@ -12,11 +12,13 @@ import * as platform from 'vs/base/common/platform'; import {IEventService} from 'vs/platform/event/common/event'; import {IExtensionMessageCollector, ExtensionsRegistry} from 'vs/platform/extensions/common/extensionsRegistry'; import {Extensions, IJSONContributionRegistry} from 'vs/platform/jsonschemas/common/jsonContributionRegistry'; -import {KeybindingService, KeybindingService2} from 'vs/platform/keybinding/browser/keybindingServiceImpl'; +import {KeybindingService2} from 'vs/platform/keybinding/browser/keybindingServiceImpl'; +import {KeybindingService} from 'vs/platform/contextkey/browser/contextKeyService'; import {IStatusbarService} from 'vs/platform/statusbar/common/statusbar'; import {IOSupport} from 'vs/platform/keybinding/common/keybindingResolver'; import {ICommandService} from 'vs/platform/commands/common/commands'; -import {IKeybindingService, IKeybindingItem, IUserFriendlyKeybinding} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingItem, IUserFriendlyKeybinding} from 'vs/platform/keybinding/common/keybinding'; +import {IKeybindingService} from 'vs/platform/contextkey/common/contextkey'; import {IKeybindingRule, KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry'; import {Registry} from 'vs/platform/platform'; import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';