提交 5ba46755 编写于 作者: A Alex Dima

Clean-up

上级 a9701d86
...@@ -15,7 +15,7 @@ import {IEditor, IEditorInput, IEditorOptions, IEditorService, IResourceInput, I ...@@ -15,7 +15,7 @@ import {IEditor, IEditorInput, IEditorOptions, IEditorService, IResourceInput, I
import {AbstractExtensionService, ActivatedExtension} from 'vs/platform/extensions/common/abstractExtensionService'; import {AbstractExtensionService, ActivatedExtension} from 'vs/platform/extensions/common/abstractExtensionService';
import {IExtensionDescription} from 'vs/platform/extensions/common/extensions'; import {IExtensionDescription} from 'vs/platform/extensions/common/extensions';
import {ICommandService, ICommandHandler} from 'vs/platform/commands/common/commands'; import {ICommandService, ICommandHandler} from 'vs/platform/commands/common/commands';
import {KeybindingService2} from 'vs/platform/keybinding/browser/keybindingServiceImpl'; import {KeybindingService} from 'vs/platform/keybinding/browser/keybindingServiceImpl';
import {IOSupport} from 'vs/platform/keybinding/common/keybindingResolver'; import {IOSupport} from 'vs/platform/keybinding/common/keybindingResolver';
import {IKeybindingItem} from 'vs/platform/keybinding/common/keybinding'; import {IKeybindingItem} from 'vs/platform/keybinding/common/keybinding';
import {IContextKeyService} from 'vs/platform/contextkey/common/contextkey'; import {IContextKeyService} from 'vs/platform/contextkey/common/contextkey';
...@@ -199,7 +199,7 @@ export class SimpleMessageService implements IMessageService { ...@@ -199,7 +199,7 @@ export class SimpleMessageService implements IMessageService {
} }
} }
export class StandaloneKeybindingService2 extends KeybindingService2 { export class StandaloneKeybindingService extends KeybindingService {
private static LAST_GENERATED_ID = 0; private static LAST_GENERATED_ID = 0;
private _dynamicKeybindings: IKeybindingItem[]; private _dynamicKeybindings: IKeybindingItem[];
...@@ -221,7 +221,7 @@ export class StandaloneKeybindingService2 extends KeybindingService2 { ...@@ -221,7 +221,7 @@ export class StandaloneKeybindingService2 extends KeybindingService2 {
public addDynamicKeybinding(keybinding: number, handler:ICommandHandler, when:string, commandId:string = null): string { public addDynamicKeybinding(keybinding: number, handler:ICommandHandler, when:string, commandId:string = null): string {
if (commandId === null) { if (commandId === null) {
commandId = 'DYNAMIC_' + (++StandaloneKeybindingService2.LAST_GENERATED_ID); commandId = 'DYNAMIC_' + (++StandaloneKeybindingService.LAST_GENERATED_ID);
} }
var parsedContext = IOSupport.readKeybindingWhen(when); var parsedContext = IOSupport.readKeybindingWhen(when);
this._dynamicKeybindings.push({ this._dynamicKeybindings.push({
......
...@@ -16,7 +16,7 @@ import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry'; ...@@ -16,7 +16,7 @@ import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
import {IActionDescriptor, ICodeEditorWidgetCreationOptions, IDiffEditorOptions, IModel, IModelChangedEvent, EventType} from 'vs/editor/common/editorCommon'; import {IActionDescriptor, ICodeEditorWidgetCreationOptions, IDiffEditorOptions, IModel, IModelChangedEvent, EventType} from 'vs/editor/common/editorCommon';
import {ICodeEditorService} from 'vs/editor/common/services/codeEditorService'; import {ICodeEditorService} from 'vs/editor/common/services/codeEditorService';
import {IEditorWorkerService} from 'vs/editor/common/services/editorWorkerService'; import {IEditorWorkerService} from 'vs/editor/common/services/editorWorkerService';
import {StandaloneKeybindingService2} from 'vs/editor/browser/standalone/simpleServices'; import {StandaloneKeybindingService} from 'vs/editor/browser/standalone/simpleServices';
import {IEditorContextViewService, IEditorOverrideServices, ensureStaticPlatformServices, getOrCreateStaticServices} from 'vs/editor/browser/standalone/standaloneServices'; import {IEditorContextViewService, IEditorOverrideServices, ensureStaticPlatformServices, getOrCreateStaticServices} from 'vs/editor/browser/standalone/standaloneServices';
import {CodeEditorWidget} from 'vs/editor/browser/widget/codeEditorWidget'; import {CodeEditorWidget} from 'vs/editor/browser/widget/codeEditorWidget';
import {DiffEditorWidget} from 'vs/editor/browser/widget/diffEditorWidget'; import {DiffEditorWidget} from 'vs/editor/browser/widget/diffEditorWidget';
...@@ -58,7 +58,7 @@ export interface IStandaloneDiffEditor extends IDiffEditor { ...@@ -58,7 +58,7 @@ export interface IStandaloneDiffEditor extends IDiffEditor {
export class StandaloneEditor extends CodeEditorWidget implements IStandaloneCodeEditor { export class StandaloneEditor extends CodeEditorWidget implements IStandaloneCodeEditor {
private _standaloneKeybindingService: StandaloneKeybindingService2; private _standaloneKeybindingService: StandaloneKeybindingService;
private _contextViewService:IEditorContextViewService; private _contextViewService:IEditorContextViewService;
private _ownsModel:boolean; private _ownsModel:boolean;
private _toDispose2: IDisposable[]; private _toDispose2: IDisposable[];
...@@ -78,7 +78,7 @@ export class StandaloneEditor extends CodeEditorWidget implements IStandaloneCod ...@@ -78,7 +78,7 @@ export class StandaloneEditor extends CodeEditorWidget implements IStandaloneCod
options = options || {}; options = options || {};
super(domElement, options, instantiationService, codeEditorService, commandService, contextKeyService.createScoped(domElement), telemetryService); super(domElement, options, instantiationService, codeEditorService, commandService, contextKeyService.createScoped(domElement), telemetryService);
if (keybindingService instanceof StandaloneKeybindingService2) { if (keybindingService instanceof StandaloneKeybindingService) {
this._standaloneKeybindingService = keybindingService; this._standaloneKeybindingService = keybindingService;
} }
...@@ -165,7 +165,7 @@ export class StandaloneEditor extends CodeEditorWidget implements IStandaloneCod ...@@ -165,7 +165,7 @@ export class StandaloneEditor extends CodeEditorWidget implements IStandaloneCod
export class StandaloneDiffEditor extends DiffEditorWidget implements IStandaloneDiffEditor { export class StandaloneDiffEditor extends DiffEditorWidget implements IStandaloneDiffEditor {
private _contextViewService:IEditorContextViewService; private _contextViewService:IEditorContextViewService;
private _standaloneKeybindingService: StandaloneKeybindingService2; private _standaloneKeybindingService: StandaloneKeybindingService;
private _toDispose2: IDisposable[]; private _toDispose2: IDisposable[];
constructor( constructor(
...@@ -180,7 +180,7 @@ export class StandaloneDiffEditor extends DiffEditorWidget implements IStandalon ...@@ -180,7 +180,7 @@ export class StandaloneDiffEditor extends DiffEditorWidget implements IStandalon
) { ) {
super(domElement, options, editorWorkerService, contextKeyService, instantiationService); super(domElement, options, editorWorkerService, contextKeyService, instantiationService);
if (keybindingService instanceof StandaloneKeybindingService2) { if (keybindingService instanceof StandaloneKeybindingService) {
this._standaloneKeybindingService = keybindingService; this._standaloneKeybindingService = keybindingService;
} }
......
...@@ -38,7 +38,7 @@ import {MainThreadModeServiceImpl} from 'vs/editor/common/services/modeServiceIm ...@@ -38,7 +38,7 @@ import {MainThreadModeServiceImpl} from 'vs/editor/common/services/modeServiceIm
import {IModelService} from 'vs/editor/common/services/modelService'; import {IModelService} from 'vs/editor/common/services/modelService';
import {ModelServiceImpl} from 'vs/editor/common/services/modelServiceImpl'; import {ModelServiceImpl} from 'vs/editor/common/services/modelServiceImpl';
import {CodeEditorServiceImpl} from 'vs/editor/browser/services/codeEditorServiceImpl'; import {CodeEditorServiceImpl} from 'vs/editor/browser/services/codeEditorServiceImpl';
import {SimpleConfigurationService, SimpleMessageService, SimpleExtensionService, StandaloneKeybindingService2} from 'vs/editor/browser/standalone/simpleServices'; import {SimpleConfigurationService, SimpleMessageService, SimpleExtensionService, StandaloneKeybindingService} from 'vs/editor/browser/standalone/simpleServices';
import {ContextKeyService} from 'vs/platform/contextkey/browser/contextKeyService'; import {ContextKeyService} from 'vs/platform/contextkey/browser/contextKeyService';
import {IMenuService} from 'vs/platform/actions/common/actions'; import {IMenuService} from 'vs/platform/actions/common/actions';
import {MenuService} from 'vs/platform/actions/common/menuService'; import {MenuService} from 'vs/platform/actions/common/menuService';
...@@ -204,7 +204,7 @@ export function ensureDynamicPlatformServices(domElement:HTMLElement, services: ...@@ -204,7 +204,7 @@ export function ensureDynamicPlatformServices(domElement:HTMLElement, services:
contextKeyService = services.contextKeyService; contextKeyService = services.contextKeyService;
} }
if (typeof services.keybindingService === 'undefined') { if (typeof services.keybindingService === 'undefined') {
let keybindingService = new StandaloneKeybindingService2(contextKeyService, services.commandService, services.messageService, domElement); let keybindingService = new StandaloneKeybindingService(contextKeyService, services.commandService, services.messageService, domElement);
r.push(keybindingService); r.push(keybindingService);
services.keybindingService = keybindingService; services.keybindingService = keybindingService;
} }
......
...@@ -66,6 +66,7 @@ export class MockCodeEditor extends CommonCodeEditor { ...@@ -66,6 +66,7 @@ export class MockCodeEditor extends CommonCodeEditor {
} }
export class MockScopeLocation implements IContextKeyServiceTarget { export class MockScopeLocation implements IContextKeyServiceTarget {
parentElement:IContextKeyServiceTarget = null;
setAttribute(attr:string, value:string): void { } setAttribute(attr:string, value:string): void { }
removeAttribute(attr:string): void { } removeAttribute(attr:string): void { }
hasAttribute(attr: string): boolean { return false; } hasAttribute(attr: string): boolean { return false; }
......
...@@ -7,16 +7,18 @@ ...@@ -7,16 +7,18 @@
import {IDisposable, dispose} from 'vs/base/common/lifecycle'; import {IDisposable, dispose} from 'vs/base/common/lifecycle';
import {CommandsRegistry} from 'vs/platform/commands/common/commands'; import {CommandsRegistry} from 'vs/platform/commands/common/commands';
import {KeybindingResolver} from 'vs/platform/keybinding/common/keybindingResolver'; import {KeybindingResolver} from 'vs/platform/keybinding/common/keybindingResolver';
import {IContextKey, IContextKeyServiceTarget, IContextKeyService, SET_CONTEXT_COMMAND_ID, KEYBINDING_CONTEXT_ATTR, ContextKeyExpr} from 'vs/platform/contextkey/common/contextkey'; import {IContextKey, IContextKeyServiceTarget, IContextKeyService, SET_CONTEXT_COMMAND_ID, ContextKeyExpr} from 'vs/platform/contextkey/common/contextkey';
import {IConfigurationService} from 'vs/platform/configuration/common/configuration'; import {IConfigurationService} from 'vs/platform/configuration/common/configuration';
import Event, {Emitter, debounceEvent} from 'vs/base/common/event'; import Event, {Emitter, debounceEvent} from 'vs/base/common/event';
export class ContextValuesProvider { const KEYBINDING_CONTEXT_ATTR = 'data-keybinding-context';
protected _parent: ContextValuesProvider;
protected _value: any; export class ContextValuesContainer {
protected _parent: ContextValuesContainer;
protected _value: {[key:string]:any;};
protected _id: number; protected _id: number;
constructor(id: number, parent: ContextValuesProvider) { constructor(id: number, parent: ContextValuesContainer) {
this._id = id; this._id = id;
this._parent = parent; this._parent = parent;
this._value = Object.create(null); this._value = Object.create(null);
...@@ -54,7 +56,7 @@ export class ContextValuesProvider { ...@@ -54,7 +56,7 @@ export class ContextValuesProvider {
} }
} }
class ConfigAwareContextValuesProvider extends ContextValuesProvider { class ConfigAwareContextValuesContainer extends ContextValuesContainer {
private _emitter: Emitter<string>; private _emitter: Emitter<string>;
private _subscription: IDisposable; private _subscription: IDisposable;
...@@ -127,7 +129,7 @@ class ContextKey<T> implements IContextKey<T> { ...@@ -127,7 +129,7 @@ class ContextKey<T> implements IContextKey<T> {
} }
public get(): T { public get(): T {
return this._parent.getContextValue<T>(this._key); return this._parent.getContextKeyValue<T>(this._key);
} }
} }
...@@ -167,7 +169,7 @@ export abstract class AbstractContextKeyService { ...@@ -167,7 +169,7 @@ export abstract class AbstractContextKeyService {
public contextMatchesRules(rules: ContextKeyExpr): boolean { public contextMatchesRules(rules: ContextKeyExpr): boolean {
const ctx = Object.create(null); const ctx = Object.create(null);
this.getContext(this._myContextId).fillInContext(ctx); this.getContextValuesContainer(this._myContextId).fillInContext(ctx);
const result = KeybindingResolver.contextMatchesRules(ctx, rules); const result = KeybindingResolver.contextMatchesRules(ctx, rules);
// console.group(rules.serialize() + ' -> ' + result); // console.group(rules.serialize() + ' -> ' + result);
// rules.keys().forEach(key => { console.log(key, ctx[key]); }); // rules.keys().forEach(key => { console.log(key, ctx[key]); });
...@@ -175,23 +177,29 @@ export abstract class AbstractContextKeyService { ...@@ -175,23 +177,29 @@ export abstract class AbstractContextKeyService {
return result; return result;
} }
public getContextValue<T>(key: string): T { public getContextKeyValue<T>(key: string): T {
return this.getContext(this._myContextId).getValue<T>(key); return this.getContextValuesContainer(this._myContextId).getValue<T>(key);
} }
public setContext(key: string, value: any): void { public setContext(key: string, value: any): void {
if(this.getContext(this._myContextId).setValue(key, value)) { if(this.getContextValuesContainer(this._myContextId).setValue(key, value)) {
this._onDidChangeContextKey.fire(key); this._onDidChangeContextKey.fire(key);
} }
} }
public removeContext(key: string): void { public removeContext(key: string): void {
if(this.getContext(this._myContextId).removeValue(key)) { if(this.getContextValuesContainer(this._myContextId).removeValue(key)) {
this._onDidChangeContextKey.fire(key); this._onDidChangeContextKey.fire(key);
} }
} }
public abstract getContext(contextId: number): ContextValuesProvider; public getContextValue(target: IContextKeyServiceTarget): any {
let res = Object.create(null);
this.getContextValuesContainer(findContextAttr(target)).fillInContext(res);
return res;
}
public abstract getContextValuesContainer(contextId: number): ContextValuesContainer;
public abstract createChildContext(parentContextId?: number): number; public abstract createChildContext(parentContextId?: number): number;
public abstract disposeContext(contextId: number): void; public abstract disposeContext(contextId: number): void;
} }
...@@ -200,7 +208,7 @@ export class ContextKeyService extends AbstractContextKeyService implements ICon ...@@ -200,7 +208,7 @@ export class ContextKeyService extends AbstractContextKeyService implements ICon
private _lastContextId: number; private _lastContextId: number;
private _contexts: { private _contexts: {
[contextId: string]: ContextValuesProvider; [contextId: string]: ContextValuesContainer;
}; };
private _toDispose: IDisposable[] = []; private _toDispose: IDisposable[] = [];
...@@ -210,7 +218,7 @@ export class ContextKeyService extends AbstractContextKeyService implements ICon ...@@ -210,7 +218,7 @@ export class ContextKeyService extends AbstractContextKeyService implements ICon
this._lastContextId = 0; this._lastContextId = 0;
this._contexts = Object.create(null); this._contexts = Object.create(null);
const myContext = new ConfigAwareContextValuesProvider(this._myContextId, configurationService, this._onDidChangeContextKey); const myContext = new ConfigAwareContextValuesContainer(this._myContextId, configurationService, this._onDidChangeContextKey);
this._contexts[String(this._myContextId)] = myContext; this._contexts[String(this._myContextId)] = myContext;
this._toDispose.push(myContext); this._toDispose.push(myContext);
...@@ -230,13 +238,13 @@ export class ContextKeyService extends AbstractContextKeyService implements ICon ...@@ -230,13 +238,13 @@ export class ContextKeyService extends AbstractContextKeyService implements ICon
this._toDispose = dispose(this._toDispose); this._toDispose = dispose(this._toDispose);
} }
public getContext(contextId: number): ContextValuesProvider { public getContextValuesContainer(contextId: number): ContextValuesContainer {
return this._contexts[String(contextId)]; return this._contexts[String(contextId)];
} }
public createChildContext(parentContextId: number = this._myContextId): number { public createChildContext(parentContextId: number = this._myContextId): number {
let id = (++this._lastContextId); let id = (++this._lastContextId);
this._contexts[String(id)] = new ContextValuesProvider(id, this.getContext(parentContextId)); this._contexts[String(id)] = new ContextValuesContainer(id, this.getContextValuesContainer(parentContextId));
return id; return id;
} }
...@@ -267,8 +275,8 @@ class ScopedContextKeyService extends AbstractContextKeyService { ...@@ -267,8 +275,8 @@ class ScopedContextKeyService extends AbstractContextKeyService {
return this._parent.onDidChangeContext; return this._parent.onDidChangeContext;
} }
public getContext(contextId: number): ContextValuesProvider { public getContextValuesContainer(contextId: number): ContextValuesContainer {
return this._parent.getContext(contextId); return this._parent.getContextValuesContainer(contextId);
} }
public createChildContext(parentContextId: number = this._myContextId): number { public createChildContext(parentContextId: number = this._myContextId): number {
...@@ -280,6 +288,16 @@ class ScopedContextKeyService extends AbstractContextKeyService { ...@@ -280,6 +288,16 @@ class ScopedContextKeyService extends AbstractContextKeyService {
} }
} }
function findContextAttr(domNode: IContextKeyServiceTarget): number {
while (domNode) {
if (domNode.hasAttribute(KEYBINDING_CONTEXT_ATTR)) {
return parseInt(domNode.getAttribute(KEYBINDING_CONTEXT_ATTR), 10);
}
domNode = domNode.parentElement;
}
return 0;
}
CommandsRegistry.registerCommand(SET_CONTEXT_COMMAND_ID, function (accessor, contextKey: any, contextValue: any) { CommandsRegistry.registerCommand(SET_CONTEXT_COMMAND_ID, function (accessor, contextKey: any, contextValue: any) {
accessor.get(IContextKeyService).createKey(String(contextKey), contextValue); accessor.get(IContextKeyService).createKey(String(contextKey), contextValue);
}); });
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
import {createDecorator} from 'vs/platform/instantiation/common/instantiation'; import {createDecorator} from 'vs/platform/instantiation/common/instantiation';
import Event from 'vs/base/common/event'; import Event from 'vs/base/common/event';
export const KEYBINDING_CONTEXT_ATTR = 'data-keybinding-context';
export enum ContextKeyExprType { export enum ContextKeyExprType {
Defined = 1, Defined = 1,
Not = 2, Not = 2,
...@@ -430,7 +428,7 @@ export class RawContextKey<T> extends ContextKeyDefinedExpr { ...@@ -430,7 +428,7 @@ export class RawContextKey<T> extends ContextKeyDefinedExpr {
} }
public getValue(target:IContextKeyService): T { public getValue(target:IContextKeyService): T {
return target.getContextValue<T>(this.key); return target.getContextKeyValue<T>(this.key);
} }
public toNegated(): ContextKeyExpr { public toNegated(): ContextKeyExpr {
...@@ -449,12 +447,11 @@ export interface IContextKey<T> { ...@@ -449,12 +447,11 @@ export interface IContextKey<T> {
} }
export interface IContextKeyServiceTarget { export interface IContextKeyServiceTarget {
parentElement: IContextKeyServiceTarget;
setAttribute(attr: string, value: string): void; setAttribute(attr: string, value: string): void;
removeAttribute(attr: string): void; removeAttribute(attr: string): void;
} hasAttribute(attr: string): boolean;
getAttribute(attr: string): string;
export interface IContextValuesProvider {
fillInContext(bucket: any): void;
} }
export let IContextKeyService = createDecorator<IContextKeyService>('contextKeyService'); export let IContextKeyService = createDecorator<IContextKeyService>('contextKeyService');
...@@ -466,11 +463,10 @@ export interface IContextKeyService { ...@@ -466,11 +463,10 @@ export interface IContextKeyService {
onDidChangeContext: Event<string[]>; onDidChangeContext: Event<string[]>;
createKey<T>(key: string, defaultValue: T): IContextKey<T>; createKey<T>(key: string, defaultValue: T): IContextKey<T>;
contextMatchesRules(rules: ContextKeyExpr): boolean; contextMatchesRules(rules: ContextKeyExpr): boolean;
getContextValue<T>(key: string): T; getContextKeyValue<T>(key: string): T;
createScoped(domNode: IContextKeyServiceTarget): IContextKeyService;
getContext(contextId: number): IContextValuesProvider; createScoped(target: IContextKeyServiceTarget): IContextKeyService;
getContextValue(target: IContextKeyServiceTarget): any;
} }
export const SET_CONTEXT_COMMAND_ID = 'setContext'; export const SET_CONTEXT_COMMAND_ID = 'setContext';
...@@ -16,12 +16,12 @@ import {IKeyboardEvent, StandardKeyboardEvent} from 'vs/base/browser/keyboardEve ...@@ -16,12 +16,12 @@ import {IKeyboardEvent, StandardKeyboardEvent} from 'vs/base/browser/keyboardEve
import {ICommandService, CommandsRegistry, ICommandHandler, ICommandHandlerDescription} from 'vs/platform/commands/common/commands'; import {ICommandService, CommandsRegistry, ICommandHandler, ICommandHandlerDescription} from 'vs/platform/commands/common/commands';
import {KeybindingResolver} from 'vs/platform/keybinding/common/keybindingResolver'; import {KeybindingResolver} from 'vs/platform/keybinding/common/keybindingResolver';
import {IKeybindingItem, IKeybindingService} from 'vs/platform/keybinding/common/keybinding'; import {IKeybindingItem, IKeybindingService} from 'vs/platform/keybinding/common/keybinding';
import {IContextKeyService, KEYBINDING_CONTEXT_ATTR} from 'vs/platform/contextkey/common/contextkey'; import {IContextKeyService} from 'vs/platform/contextkey/common/contextkey';
import {KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry'; import {KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry';
import {IStatusbarService} from 'vs/platform/statusbar/common/statusbar'; import {IStatusbarService} from 'vs/platform/statusbar/common/statusbar';
import {IMessageService} from 'vs/platform/message/common/message'; import {IMessageService} from 'vs/platform/message/common/message';
export abstract class KeybindingService2 implements IKeybindingService { export abstract class KeybindingService implements IKeybindingService {
public _serviceBrand: any; public _serviceBrand: any;
private _toDispose: IDisposable[] = []; private _toDispose: IDisposable[] = [];
...@@ -141,8 +141,7 @@ export abstract class KeybindingService2 implements IKeybindingService { ...@@ -141,8 +141,7 @@ export abstract class KeybindingService2 implements IKeybindingService {
return; return;
} }
let contextValue = Object.create(null); let contextValue = this._contextKeyService.getContextValue(e.target);
this._contextKeyService.getContext(this._findContextAttr(e.target)).fillInContext(contextValue);
// console.log(JSON.stringify(contextValue, null, '\t')); // console.log(JSON.stringify(contextValue, null, '\t'));
let resolveResult = this._getResolver().resolve(contextValue, this._currentChord, e.asKeybinding()); let resolveResult = this._getResolver().resolve(contextValue, this._currentChord, e.asKeybinding());
...@@ -182,13 +181,5 @@ export abstract class KeybindingService2 implements IKeybindingService { ...@@ -182,13 +181,5 @@ export abstract class KeybindingService2 implements IKeybindingService {
} }
} }
private _findContextAttr(domNode: HTMLElement): number {
while (domNode) {
if (domNode.hasAttribute(KEYBINDING_CONTEXT_ATTR)) {
return parseInt(domNode.getAttribute(KEYBINDING_CONTEXT_ATTR), 10);
}
domNode = domNode.parentElement;
}
return 0;
}
} }
...@@ -8,7 +8,7 @@ import {IHTMLContentElement} from 'vs/base/common/htmlContent'; ...@@ -8,7 +8,7 @@ import {IHTMLContentElement} from 'vs/base/common/htmlContent';
import {Keybinding} from 'vs/base/common/keyCodes'; import {Keybinding} from 'vs/base/common/keyCodes';
import Event from 'vs/base/common/event'; import Event from 'vs/base/common/event';
import {IKeybindingService} from 'vs/platform/keybinding/common/keybinding'; import {IKeybindingService} from 'vs/platform/keybinding/common/keybinding';
import {IContextKey, IContextKeyService, IContextValuesProvider, ContextKeyExpr} from 'vs/platform/contextkey/common/contextkey'; import {IContextKey, IContextKeyService, ContextKeyExpr} from 'vs/platform/contextkey/common/contextkey';
class MockKeybindingContextKey<T> implements IContextKey<T> { class MockKeybindingContextKey<T> implements IContextKey<T> {
private _key: string; private _key: string;
...@@ -48,10 +48,10 @@ export class MockKeybindingService implements IContextKeyService { ...@@ -48,10 +48,10 @@ export class MockKeybindingService implements IContextKeyService {
public get onDidChangeContext(): Event<string[]> { public get onDidChangeContext(): Event<string[]> {
return Event.None; return Event.None;
} }
public getContextValue(key: string) { public getContextKeyValue(key: string) {
return; return;
} }
public getContext(contextId: number): IContextValuesProvider { public getContextValue(domNode: HTMLElement): any {
return null; return null;
} }
public createScoped(domNode: HTMLElement): IContextKeyService { public createScoped(domNode: HTMLElement): IContextKeyService {
......
...@@ -44,7 +44,7 @@ import {Position, Parts, IPartService} from 'vs/workbench/services/part/common/p ...@@ -44,7 +44,7 @@ import {Position, Parts, IPartService} from 'vs/workbench/services/part/common/p
import {IWorkspaceContextService as IWorkbenchWorkspaceContextService} from 'vs/workbench/services/workspace/common/contextService'; import {IWorkspaceContextService as IWorkbenchWorkspaceContextService} from 'vs/workbench/services/workspace/common/contextService';
import {IStorageService, StorageScope} from 'vs/platform/storage/common/storage'; import {IStorageService, StorageScope} from 'vs/platform/storage/common/storage';
import {ContextMenuService} from 'vs/workbench/services/contextview/electron-browser/contextmenuService'; import {ContextMenuService} from 'vs/workbench/services/contextview/electron-browser/contextmenuService';
import {WorkbenchKeybindingService2} from 'vs/workbench/services/keybinding/electron-browser/keybindingService'; import {WorkbenchKeybindingService} from 'vs/workbench/services/keybinding/electron-browser/keybindingService';
import {ContextKeyService} from 'vs/platform/contextkey/browser/contextKeyService'; import {ContextKeyService} from 'vs/platform/contextkey/browser/contextKeyService';
import {IWorkspace, IConfiguration} from 'vs/platform/workspace/common/workspace'; import {IWorkspace, IConfiguration} from 'vs/platform/workspace/common/workspace';
import {IKeybindingService} from 'vs/platform/keybinding/common/keybinding'; import {IKeybindingService} from 'vs/platform/keybinding/common/keybinding';
...@@ -356,7 +356,7 @@ export class Workbench implements IPartService { ...@@ -356,7 +356,7 @@ export class Workbench implements IPartService {
this.contextKeyService = this.instantiationService.createInstance(ContextKeyService); this.contextKeyService = this.instantiationService.createInstance(ContextKeyService);
serviceCollection.set(IContextKeyService, this.contextKeyService); serviceCollection.set(IContextKeyService, this.contextKeyService);
this.keybindingService = this.instantiationService.createInstance(WorkbenchKeybindingService2, <any>window); this.keybindingService = this.instantiationService.createInstance(WorkbenchKeybindingService, <any>window);
serviceCollection.set(IKeybindingService, this.keybindingService); serviceCollection.set(IKeybindingService, this.keybindingService);
// Context Menu // Context Menu
......
...@@ -12,7 +12,7 @@ import * as platform from 'vs/base/common/platform'; ...@@ -12,7 +12,7 @@ import * as platform from 'vs/base/common/platform';
import {IEventService} from 'vs/platform/event/common/event'; import {IEventService} from 'vs/platform/event/common/event';
import {IExtensionMessageCollector, ExtensionsRegistry} from 'vs/platform/extensions/common/extensionsRegistry'; import {IExtensionMessageCollector, ExtensionsRegistry} from 'vs/platform/extensions/common/extensionsRegistry';
import {Extensions, IJSONContributionRegistry} from 'vs/platform/jsonschemas/common/jsonContributionRegistry'; import {Extensions, IJSONContributionRegistry} from 'vs/platform/jsonschemas/common/jsonContributionRegistry';
import {KeybindingService2} from 'vs/platform/keybinding/browser/keybindingServiceImpl'; import {KeybindingService} from 'vs/platform/keybinding/browser/keybindingServiceImpl';
import {IStatusbarService} from 'vs/platform/statusbar/common/statusbar'; import {IStatusbarService} from 'vs/platform/statusbar/common/statusbar';
import {IOSupport} from 'vs/platform/keybinding/common/keybindingResolver'; import {IOSupport} from 'vs/platform/keybinding/common/keybindingResolver';
import {ICommandService} from 'vs/platform/commands/common/commands'; import {ICommandService} from 'vs/platform/commands/common/commands';
...@@ -114,7 +114,7 @@ let keybindingsExtPoint = ExtensionsRegistry.registerExtensionPoint<ContributedK ...@@ -114,7 +114,7 @@ let keybindingsExtPoint = ExtensionsRegistry.registerExtensionPoint<ContributedK
] ]
}); });
export class WorkbenchKeybindingService2 extends KeybindingService2 { export class WorkbenchKeybindingService extends KeybindingService {
private contextService: IWorkspaceContextService; private contextService: IWorkspaceContextService;
private eventService: IEventService; private eventService: IEventService;
private telemetryService: ITelemetryService; private telemetryService: ITelemetryService;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册