Refresh master with initial release/0.24 snapshot (#332)

* Initial port of release/0.24 source code

* Fix additional headers

* Fix a typo in launch.json
This commit is contained in:
Karl Burtram
2017-12-15 15:38:57 -08:00
committed by GitHub
parent 271b3a0b82
commit 6ad0df0e3e
7118 changed files with 107999 additions and 56466 deletions

View File

@@ -24,6 +24,7 @@ export interface ICommandAction {
title: string | ILocalizedString;
category?: string | ILocalizedString;
iconClass?: string;
iconPath?: string;
}
export interface IMenuItem {
@@ -36,30 +37,29 @@ export interface IMenuItem {
export class MenuId {
static readonly EditorTitle = new MenuId('1');
static readonly EditorTitleContext = new MenuId('2');
static readonly EditorContext = new MenuId('3');
static readonly ExplorerContext = new MenuId('4');
static readonly ProblemsPanelContext = new MenuId('5');
static readonly DebugVariablesContext = new MenuId('6');
static readonly DebugWatchContext = new MenuId('7');
static readonly DebugCallStackContext = new MenuId('8');
static readonly DebugBreakpointsContext = new MenuId('9');
static readonly DebugConsoleContext = new MenuId('10');
static readonly SCMTitle = new MenuId('11');
static readonly SCMResourceGroupContext = new MenuId('12');
static readonly SCMResourceContext = new MenuId('13');
static readonly CommandPalette = new MenuId('14');
static readonly ViewTitle = new MenuId('15');
static readonly ViewItemContext = new MenuId('16');
private static ID = 1;
constructor(private _id: string) {
static readonly EditorTitle = new MenuId();
static readonly EditorTitleContext = new MenuId();
static readonly EditorContext = new MenuId();
static readonly ExplorerContext = new MenuId();
static readonly ProblemsPanelContext = new MenuId();
static readonly DebugVariablesContext = new MenuId();
static readonly DebugWatchContext = new MenuId();
static readonly DebugCallStackContext = new MenuId();
static readonly DebugBreakpointsContext = new MenuId();
static readonly DebugConsoleContext = new MenuId();
static readonly SCMTitle = new MenuId();
static readonly SCMSourceControl = new MenuId();
static readonly SCMResourceGroupContext = new MenuId();
static readonly SCMResourceContext = new MenuId();
static readonly SCMChangeContext = new MenuId();
static readonly CommandPalette = new MenuId();
static readonly ViewTitle = new MenuId();
static readonly ViewItemContext = new MenuId();
static readonly TouchBarContext = new MenuId();
}
get id(): string {
return this._id;
}
readonly id: string = String(MenuId.ID++);
}
export interface IMenuActionOptions {
@@ -88,7 +88,7 @@ export interface IMenuRegistry {
getMenuItems(loc: MenuId): IMenuItem[];
}
export const MenuRegistry: IMenuRegistry = new class {
export const MenuRegistry: IMenuRegistry = new class implements IMenuRegistry {
private _commands: { [id: string]: ICommandAction } = Object.create(null);
@@ -186,7 +186,7 @@ export class MenuItemAction extends ExecuteCommandAction {
}
run(...args: any[]): TPromise<any> {
let runArgs = [];
let runArgs: any[] = [];
if (this._options.arg) {
runArgs = [...runArgs, this._options.arg];

View File

@@ -30,14 +30,17 @@ namespace schema {
export function parseMenuId(value: string): MenuId {
switch (value) {
case 'commandPalette': return MenuId.CommandPalette;
case 'touchBar': return MenuId.TouchBarContext;
case 'editor/title': return MenuId.EditorTitle;
case 'editor/context': return MenuId.EditorContext;
case 'explorer/context': return MenuId.ExplorerContext;
case 'editor/title/context': return MenuId.EditorTitleContext;
case 'debug/callstack/context': return MenuId.DebugCallStackContext;
case 'scm/title': return MenuId.SCMTitle;
case 'scm/sourceControl': return MenuId.SCMSourceControl;
case 'scm/resourceGroup/context': return MenuId.SCMResourceGroupContext;
case 'scm/resourceState/context': return MenuId.SCMResourceContext;
case 'scm/change/title': return MenuId.SCMChangeContext;
case 'view/title': return MenuId.ViewTitle;
case 'view/item/context': return MenuId.ViewItemContext;
}
@@ -104,6 +107,11 @@ namespace schema {
type: 'array',
items: menuItem
},
'touchBar': {
description: localize('menus.touchBar', "The touch bar (macOS only)"),
type: 'array',
items: menuItem
},
'editor/title': {
description: localize('menus.editorTitle', "The editor title menu"),
type: 'array',
@@ -134,6 +142,11 @@ namespace schema {
type: 'array',
items: menuItem
},
'scm/sourceControl': {
description: localize('menus.scmSourceControl', "The Source Control menu"),
type: 'array',
items: menuItem
},
'scm/resourceGroup/context': {
description: localize('menus.resourceGroupContext', "The Source Control resource group context menu"),
type: 'array',
@@ -278,20 +291,23 @@ ExtensionsRegistry.registerExtensionPoint<schema.IUserFriendlyCommand | schema.I
let { icon, category, title, command } = userFriendlyCommand;
let iconClass: string;
let iconPath: string;
if (icon) {
iconClass = ids.nextId();
if (typeof icon === 'string') {
const path = join(extension.description.extensionFolderPath, icon);
createCSSRule(`.icon.${iconClass}`, `background-image: url("${URI.file(path).toString()}")`);
iconPath = join(extension.description.extensionFolderPath, icon);
createCSSRule(`.icon.${iconClass}`, `background-image: url("${URI.file(iconPath).toString()}")`);
} else {
const light = join(extension.description.extensionFolderPath, icon.light);
const dark = join(extension.description.extensionFolderPath, icon.dark);
createCSSRule(`.icon.${iconClass}`, `background-image: url("${URI.file(light).toString()}")`);
createCSSRule(`.vs-dark .icon.${iconClass}, .hc-black .icon.${iconClass}`, `background-image: url("${URI.file(dark).toString()}")`);
iconPath = join(extension.description.extensionFolderPath, icon.dark);
}
}
if (MenuRegistry.addCommand({ id: command, title, category, iconClass })) {
if (MenuRegistry.addCommand({ id: command, title, category, iconClass, iconPath })) {
extension.collector.info(localize('dup', "Command `{0}` appears multiple times in the `commands` section.", userFriendlyCommand.command));
}
}

View File

@@ -46,6 +46,14 @@ class MockExtensionService implements IExtensionService {
public restartExtensionHost(): void {
throw new Error('Method not implemented.');
}
public startExtensionHost(): void {
throw new Error('Method not implemented.');
}
public stopExtensionHost(): void {
throw new Error('Method not implemented.');
}
}
const extensionService = new MockExtensionService();
@@ -219,11 +227,19 @@ suite('MenuService', function () {
MenuRegistry.addCommand({ id: 'b', title: 'Implicit' });
const [first, second] = MenuRegistry.getMenuItems(MenuId.CommandPalette);
assert.equal(first.command.id, 'a');
assert.equal(first.command.title, 'Explicit');
assert.equal(second.command.id, 'b');
assert.equal(second.command.title, 'Implicit');
let foundA = false;
let foundB = false;
for (const item of MenuRegistry.getMenuItems(MenuId.CommandPalette)) {
if (item.command.id === 'a') {
assert.equal(item.command.title, 'Explicit');
foundA = true;
}
if (item.command.id === 'b') {
assert.equal(item.command.title, 'Implicit');
foundB = true;
}
}
assert.equal(foundA, true);
assert.equal(foundB, true);
});
});