提交 9db20374 编写于 作者: A Alex Dima

Rename NormalizedKeybindingItem to ResolvedKeybindingItem

上级 48566c7a
......@@ -32,7 +32,7 @@ import { MenuId, IMenu, IMenuService } from 'vs/platform/actions/common/actions'
import { Menu } from 'vs/platform/actions/common/menu';
import { ITelemetryService, ITelemetryExperiments, ITelemetryInfo } from 'vs/platform/telemetry/common/telemetry';
import { ResolvedKeybinding, Keybinding, createKeybinding } from 'vs/base/common/keyCodes';
import { NormalizedKeybindingItem } from 'vs/platform/keybinding/common/normalizedKeybindingItem';
import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKeybindingItem';
import { OS } from 'vs/base/common/platform';
export class SimpleEditor implements IEditor {
......@@ -380,15 +380,15 @@ export class StandaloneKeybindingService extends AbstractKeybindingService {
return this._cachedResolver;
}
private _toNormalizedKeybindingItems(items: IKeybindingItem[], isDefault: boolean): NormalizedKeybindingItem[] {
let result: NormalizedKeybindingItem[] = [], resultLen = 0;
private _toNormalizedKeybindingItems(items: IKeybindingItem[], isDefault: boolean): ResolvedKeybindingItem[] {
let result: ResolvedKeybindingItem[] = [], resultLen = 0;
for (let i = 0, len = items.length; i < len; i++) {
const item = items[i];
const when = (item.when ? item.when.normalize() : null);
const keybinding = (item.keybinding !== 0 ? createKeybinding(item.keybinding) : null);
const resolvedKeybinding = (keybinding !== null ? this._createResolvedKeybinding(keybinding) : null);
result[resultLen++] = new NormalizedKeybindingItem(resolvedKeybinding, item.command, item.commandArgs, when, isDefault);
result[resultLen++] = new ResolvedKeybindingItem(resolvedKeybinding, item.command, item.commandArgs, when, isDefault);
}
return result;
......
......@@ -5,7 +5,7 @@
'use strict';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { NormalizedKeybindingItem } from 'vs/platform/keybinding/common/normalizedKeybindingItem';
import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKeybindingItem';
export interface IResolveResult {
enterChord: boolean;
......@@ -15,14 +15,14 @@ export interface IResolveResult {
}
export class KeybindingResolver {
private readonly _defaultKeybindings: NormalizedKeybindingItem[];
private readonly _keybindings: NormalizedKeybindingItem[];
private readonly _defaultKeybindings: ResolvedKeybindingItem[];
private readonly _keybindings: ResolvedKeybindingItem[];
private readonly _shouldWarnOnConflict: boolean;
private readonly _defaultBoundCommands: Map<string, boolean>;
private readonly _map: Map<string, NormalizedKeybindingItem[]>;
private readonly _lookupMap: Map<string, NormalizedKeybindingItem[]>;
private readonly _map: Map<string, ResolvedKeybindingItem[]>;
private readonly _lookupMap: Map<string, ResolvedKeybindingItem[]>;
constructor(defaultKeybindings: NormalizedKeybindingItem[], overrides: NormalizedKeybindingItem[], shouldWarnOnConflict: boolean = true) {
constructor(defaultKeybindings: ResolvedKeybindingItem[], overrides: ResolvedKeybindingItem[], shouldWarnOnConflict: boolean = true) {
this._defaultKeybindings = defaultKeybindings;
this._shouldWarnOnConflict = shouldWarnOnConflict;
......@@ -32,8 +32,8 @@ export class KeybindingResolver {
this._defaultBoundCommands.set(command, true);
}
this._map = new Map<string, NormalizedKeybindingItem[]>();
this._lookupMap = new Map<string, NormalizedKeybindingItem[]>();
this._map = new Map<string, ResolvedKeybindingItem[]>();
this._lookupMap = new Map<string, ResolvedKeybindingItem[]>();
this._keybindings = KeybindingResolver.combine(defaultKeybindings, overrides);
for (let i = 0, len = this._keybindings.length; i < len; i++) {
......@@ -47,7 +47,7 @@ export class KeybindingResolver {
}
}
private static _isTargetedForRemoval(defaultKb: NormalizedKeybindingItem, keypressFirstPart: string, keypressChordPart: string, command: string, when: ContextKeyExpr): boolean {
private static _isTargetedForRemoval(defaultKb: ResolvedKeybindingItem, keypressFirstPart: string, keypressChordPart: string, command: string, when: ContextKeyExpr): boolean {
if (defaultKb.command !== command) {
return false;
}
......@@ -72,9 +72,9 @@ export class KeybindingResolver {
/**
* Looks for rules containing -command in `overrides` and removes them directly from `defaults`.
*/
public static combine(defaults: NormalizedKeybindingItem[], rawOverrides: NormalizedKeybindingItem[]): NormalizedKeybindingItem[] {
public static combine(defaults: ResolvedKeybindingItem[], rawOverrides: ResolvedKeybindingItem[]): ResolvedKeybindingItem[] {
defaults = defaults.slice(0);
let overrides: NormalizedKeybindingItem[] = [];
let overrides: ResolvedKeybindingItem[] = [];
for (let i = 0, len = rawOverrides.length; i < len; i++) {
const override = rawOverrides[i];
if (!override.command || override.command.length === 0 || override.command.charAt(0) !== '-') {
......@@ -95,7 +95,7 @@ export class KeybindingResolver {
return defaults.concat(overrides);
}
private _addKeyPress(keypress: string, item: NormalizedKeybindingItem): void {
private _addKeyPress(keypress: string, item: ResolvedKeybindingItem): void {
const conflicts = this._map.get(keypress);
......@@ -136,7 +136,7 @@ export class KeybindingResolver {
this._addToLookupMap(item);
}
private _addToLookupMap(item: NormalizedKeybindingItem): void {
private _addToLookupMap(item: ResolvedKeybindingItem): void {
if (!item.command) {
return;
}
......@@ -150,7 +150,7 @@ export class KeybindingResolver {
}
}
private _removeFromLookupMap(item: NormalizedKeybindingItem): void {
private _removeFromLookupMap(item: ResolvedKeybindingItem): void {
let arr = this._lookupMap.get(item.command);
if (typeof arr === 'undefined') {
return;
......@@ -201,29 +201,29 @@ export class KeybindingResolver {
return this._defaultBoundCommands;
}
public getDefaultKeybindings(): NormalizedKeybindingItem[] {
public getDefaultKeybindings(): ResolvedKeybindingItem[] {
return this._defaultKeybindings;
}
public getKeybindings(): NormalizedKeybindingItem[] {
public getKeybindings(): ResolvedKeybindingItem[] {
return this._keybindings;
}
public lookupKeybindings(commandId: string): NormalizedKeybindingItem[] {
public lookupKeybindings(commandId: string): ResolvedKeybindingItem[] {
let items = this._lookupMap.get(commandId);
if (typeof items === 'undefined' || items.length === 0) {
return [];
}
// Reverse to get the most specific item first
let result: NormalizedKeybindingItem[] = [], resultLen = 0;
let result: ResolvedKeybindingItem[] = [], resultLen = 0;
for (let i = items.length - 1; i >= 0; i--) {
result[resultLen++] = items[i];
}
return result;
}
public lookupPrimaryKeybinding(commandId: string): NormalizedKeybindingItem {
public lookupPrimaryKeybinding(commandId: string): ResolvedKeybindingItem {
let items = this._lookupMap.get(commandId);
if (typeof items === 'undefined' || items.length === 0) {
return null;
......@@ -233,7 +233,7 @@ export class KeybindingResolver {
}
public resolve(context: any, currentChord: string, keypress: string): IResolveResult {
let lookupMap: NormalizedKeybindingItem[] = null;
let lookupMap: ResolvedKeybindingItem[] = null;
if (currentChord !== null) {
// Fetch all chord bindings for `currentChord`
......@@ -283,7 +283,7 @@ export class KeybindingResolver {
};
}
private _findCommand(context: any, matches: NormalizedKeybindingItem[]): NormalizedKeybindingItem {
private _findCommand(context: any, matches: ResolvedKeybindingItem[]): ResolvedKeybindingItem {
for (let i = matches.length - 1; i >= 0; i--) {
let k = matches[i];
......
......@@ -8,8 +8,8 @@ import { ResolvedKeybinding } from 'vs/base/common/keyCodes';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { CharCode } from 'vs/base/common/charCode';
export class NormalizedKeybindingItem {
_normalizedKeybindingItemBrand: void;
export class ResolvedKeybindingItem {
_resolvedKeybindingItemBrand: void;
public readonly resolvedKeybinding: ResolvedKeybinding;
public readonly keypressFirstPart: string;
......
......@@ -15,7 +15,7 @@ import { ContextKeyExpr, IContextKeyService, IContextKeyServiceTarget } from 'vs
import { IStatusbarService } from 'vs/platform/statusbar/common/statusbar';
import { IMessageService } from 'vs/platform/message/common/message';
import { TPromise } from 'vs/base/common/winjs.base';
import { NormalizedKeybindingItem } from 'vs/platform/keybinding/common/normalizedKeybindingItem';
import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKeybindingItem';
import { OS } from 'vs/base/common/platform';
suite('AbstractKeybindingService', () => {
......@@ -47,7 +47,7 @@ suite('AbstractKeybindingService', () => {
}
}
let createTestKeybindingService: (items: NormalizedKeybindingItem[], contextValue?: any) => TestKeybindingService = null;
let createTestKeybindingService: (items: ResolvedKeybindingItem[], contextValue?: any) => TestKeybindingService = null;
let currentContextValue: any = null;
let executeCommandCalls: { commandId: string; args: any[]; }[] = null;
let showMessageCalls: { sev: Severity, message: any; }[] = null;
......@@ -60,7 +60,7 @@ suite('AbstractKeybindingService', () => {
statusMessageCalls = [];
statusMessageCallsDisposed = [];
createTestKeybindingService = (items: NormalizedKeybindingItem[]): TestKeybindingService => {
createTestKeybindingService = (items: ResolvedKeybindingItem[]): TestKeybindingService => {
let contextKeyService: IContextKeyService = {
_serviceBrand: undefined,
......@@ -128,9 +128,9 @@ suite('AbstractKeybindingService', () => {
statusMessageCallsDisposed = null;
});
function kbItem(keybinding: number, command: string, when: ContextKeyExpr = null): NormalizedKeybindingItem {
function kbItem(keybinding: number, command: string, when: ContextKeyExpr = null): ResolvedKeybindingItem {
const resolvedKeybinding = (keybinding !== 0 ? new USLayoutResolvedKeybinding(createKeybinding(keybinding), OS) : null);
return new NormalizedKeybindingItem(
return new ResolvedKeybindingItem(
resolvedKeybinding,
command,
null,
......
......@@ -8,15 +8,15 @@ import * as assert from 'assert';
import { createKeybinding, SimpleKeybinding, KeyCode, KeyMod, KeyChord } from 'vs/base/common/keyCodes';
import { KeybindingResolver } from 'vs/platform/keybinding/common/keybindingResolver';
import { ContextKeyAndExpr, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { NormalizedKeybindingItem } from 'vs/platform/keybinding/common/normalizedKeybindingItem';
import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKeybindingItem';
import { USLayoutResolvedKeybinding } from 'vs/platform/keybinding/common/abstractKeybindingService';
import { OS } from 'vs/base/common/platform';
suite('KeybindingResolver', () => {
function kbItem(keybinding: number, command: string, commandArgs: any, when: ContextKeyExpr, isDefault: boolean): NormalizedKeybindingItem {
function kbItem(keybinding: number, command: string, commandArgs: any, when: ContextKeyExpr, isDefault: boolean): ResolvedKeybindingItem {
const resolvedKeybinding = (keybinding !== 0 ? new USLayoutResolvedKeybinding(createKeybinding(keybinding), OS) : null);
return new NormalizedKeybindingItem(
return new ResolvedKeybindingItem(
resolvedKeybinding,
command,
commandArgs,
......@@ -232,7 +232,7 @@ suite('KeybindingResolver', () => {
test('resolve command', function () {
function _kbItem(keybinding: number, command: string, when: ContextKeyExpr): NormalizedKeybindingItem {
function _kbItem(keybinding: number, command: string, when: ContextKeyExpr): ResolvedKeybindingItem {
return kbItem(keybinding, command, null, when, true);
}
......
......@@ -8,11 +8,11 @@ import { KeyMod, KeyChord, USER_SETTINGS } from 'vs/base/common/keyCodes';
import { OperatingSystem } from 'vs/base/common/platform';
import { IKeybindingItem, IUserFriendlyKeybinding } from 'vs/platform/keybinding/common/keybinding';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { NormalizedKeybindingItem } from 'vs/platform/keybinding/common/normalizedKeybindingItem';
import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKeybindingItem';
export class KeybindingIO {
public static writeKeybindingItem(out: OutputBuilder, item: NormalizedKeybindingItem, OS: OperatingSystem): void {
public static writeKeybindingItem(out: OutputBuilder, item: ResolvedKeybindingItem, OS: OperatingSystem): void {
let quotedSerializedKeybinding = JSON.stringify(item.resolvedKeybinding.getUserSettingsLabel());
out.write(`{ "key": ${rightPaddedString(quotedSerializedKeybinding + ',', 25)} "command": `);
......
......@@ -30,7 +30,7 @@ import { ConfigWatcher } from 'vs/base/node/config';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import * as dom from 'vs/base/browser/dom';
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { NormalizedKeybindingItem } from 'vs/platform/keybinding/common/normalizedKeybindingItem';
import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKeybindingItem';
import { KeybindingIO, OutputBuilder } from 'vs/workbench/services/keybinding/common/keybindingIO';
interface ContributedKeyBinding {
......@@ -321,15 +321,15 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
return this._cachedResolver;
}
private _toNormalizedKeybindingItems(items: IKeybindingItem[], isDefault: boolean): NormalizedKeybindingItem[] {
let result: NormalizedKeybindingItem[] = [], resultLen = 0;
private _toNormalizedKeybindingItems(items: IKeybindingItem[], isDefault: boolean): ResolvedKeybindingItem[] {
let result: ResolvedKeybindingItem[] = [], resultLen = 0;
for (let i = 0, len = items.length; i < len; i++) {
const item = items[i];
const when = (item.when ? item.when.normalize() : null);
const keybinding = (item.keybinding !== 0 ? createKeybinding(item.keybinding) : null);
const resolvedKeybinding = (keybinding !== null ? this._createResolvedKeybinding(keybinding) : null);
result[resultLen++] = new NormalizedKeybindingItem(resolvedKeybinding, item.command, item.commandArgs, when, isDefault);
result[resultLen++] = new ResolvedKeybindingItem(resolvedKeybinding, item.command, item.commandArgs, when, isDefault);
}
return result;
......@@ -428,7 +428,7 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
);
}
private static _getDefaultKeybindings(defaultKeybindings: NormalizedKeybindingItem[]): string {
private static _getDefaultKeybindings(defaultKeybindings: ResolvedKeybindingItem[]): string {
let out = new OutputBuilder();
out.writeLine('[');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册