remove extensionsWorkbenchExtension!

This commit is contained in:
Joao Moreno 2016-09-15 18:18:37 +02:00
parent 9dea73691e
commit b3f39bf739
8 changed files with 17 additions and 123 deletions

View file

@ -84,9 +84,6 @@ export interface IPath {
// indicator to create the file path in the VSCode instance
createFilePath?: boolean;
// indicator to install the extension (path to .vsix) in the VSCode instance
installExtensionPath?: boolean;
}
export interface IWindowConfiguration extends ICommandLineArguments {
@ -102,8 +99,6 @@ export interface IWindowConfiguration extends ICommandLineArguments {
filesToOpen?: IPath[];
filesToCreate?: IPath[];
filesToDiff?: IPath[];
extensionsToInstall: string[];
}
export interface IWindowSettings {
@ -388,7 +383,6 @@ export class VSCodeWindow {
delete configuration.filesToOpen;
delete configuration.filesToCreate;
delete configuration.filesToDiff;
delete configuration.extensionsToInstall;
// Some configuration things get inherited if the window is being reloaded and we are
// in plugin development mode. These options are all development related.

View file

@ -576,13 +576,12 @@ export class WindowsManager implements IWindowsService {
let filesToOpen: IPath[] = [];
let filesToDiff: IPath[] = [];
let foldersToOpen = iPathsToOpen.filter(iPath => iPath.workspacePath && !iPath.filePath && !iPath.installExtensionPath);
let emptyToOpen = iPathsToOpen.filter(iPath => !iPath.workspacePath && !iPath.filePath && !iPath.installExtensionPath);
let extensionsToInstall = iPathsToOpen.filter(iPath => iPath.installExtensionPath).map(ipath => ipath.filePath);
let filesToCreate = iPathsToOpen.filter(iPath => !!iPath.filePath && iPath.createFilePath && !iPath.installExtensionPath);
let foldersToOpen = iPathsToOpen.filter(iPath => iPath.workspacePath && !iPath.filePath);
let emptyToOpen = iPathsToOpen.filter(iPath => !iPath.workspacePath && !iPath.filePath);
let filesToCreate = iPathsToOpen.filter(iPath => !!iPath.filePath && iPath.createFilePath);
// Diff mode needs special care
const candidates = iPathsToOpen.filter(iPath => !!iPath.filePath && !iPath.createFilePath && !iPath.installExtensionPath);
const candidates = iPathsToOpen.filter(iPath => !!iPath.filePath && !iPath.createFilePath);
if (openConfig.diffMode) {
if (candidates.length === 2) {
filesToDiff = candidates;
@ -599,7 +598,7 @@ export class WindowsManager implements IWindowsService {
let configuration: IWindowConfiguration;
// Handle files to open/diff or to create when we dont open a folder
if (!foldersToOpen.length && (filesToOpen.length > 0 || filesToCreate.length > 0 || filesToDiff.length > 0 || extensionsToInstall.length > 0)) {
if (!foldersToOpen.length && (filesToOpen.length > 0 || filesToCreate.length > 0 || filesToDiff.length > 0)) {
// const the user settings override how files are open in a new window or same window unless we are forced
let openFilesInNewWindow: boolean;
@ -621,10 +620,6 @@ export class WindowsManager implements IWindowsService {
lastActiveWindow.focus();
lastActiveWindow.ready().then(readyWindow => {
readyWindow.send('vscode:openFiles', { filesToOpen, filesToCreate, filesToDiff });
if (extensionsToInstall.length) {
readyWindow.send('vscode:installExtensions', { extensionsToInstall });
}
});
usedWindows.push(lastActiveWindow);
@ -632,7 +627,7 @@ export class WindowsManager implements IWindowsService {
// Otherwise open instance with files
else {
configuration = this.toConfiguration(this.getWindowUserEnv(openConfig), openConfig.cli, null, filesToOpen, filesToCreate, filesToDiff, extensionsToInstall);
configuration = this.toConfiguration(this.getWindowUserEnv(openConfig), openConfig.cli, null, filesToOpen, filesToCreate, filesToDiff);
const browserWindow = this.openInBrowserWindow(configuration, true /* new window */);
usedWindows.push(browserWindow);
@ -651,10 +646,6 @@ export class WindowsManager implements IWindowsService {
browserWindow.focus(); // just focus one of them
browserWindow.ready().then(readyWindow => {
readyWindow.send('vscode:openFiles', { filesToOpen, filesToCreate, filesToDiff });
if (extensionsToInstall.length) {
readyWindow.send('vscode:installExtensions', { extensionsToInstall });
}
});
usedWindows.push(browserWindow);
@ -663,7 +654,6 @@ export class WindowsManager implements IWindowsService {
filesToOpen = [];
filesToCreate = [];
filesToDiff = [];
extensionsToInstall = [];
openInNewWindow = true; // any other folders to open must open in new window then
}
@ -674,7 +664,7 @@ export class WindowsManager implements IWindowsService {
return; // ignore folders that are already open
}
configuration = this.toConfiguration(this.getWindowUserEnv(openConfig), openConfig.cli, folderToOpen.workspacePath, filesToOpen, filesToCreate, filesToDiff, extensionsToInstall);
configuration = this.toConfiguration(this.getWindowUserEnv(openConfig), openConfig.cli, folderToOpen.workspacePath, filesToOpen, filesToCreate, filesToDiff);
const browserWindow = this.openInBrowserWindow(configuration, openInNewWindow, openInNewWindow ? void 0 : openConfig.windowToUse);
usedWindows.push(browserWindow);
@ -682,7 +672,6 @@ export class WindowsManager implements IWindowsService {
filesToOpen = [];
filesToCreate = [];
filesToDiff = [];
extensionsToInstall = [];
openInNewWindow = true; // any other folders to open must open in new window then
});
@ -826,7 +815,7 @@ export class WindowsManager implements IWindowsService {
this.open({ cli: openConfig.cli, forceNewWindow: true, forceEmpty: openConfig.cli.paths.length === 0 });
}
private toConfiguration(userEnv: IProcessEnvironment, cli: ICommandLineArguments, workspacePath?: string, filesToOpen?: IPath[], filesToCreate?: IPath[], filesToDiff?: IPath[], extensionsToInstall?: string[]): IWindowConfiguration {
private toConfiguration(userEnv: IProcessEnvironment, cli: ICommandLineArguments, workspacePath?: string, filesToOpen?: IPath[], filesToCreate?: IPath[], filesToDiff?: IPath[]): IWindowConfiguration {
const configuration: IWindowConfiguration = mixin({}, cli); // inherit all properties from CLI
configuration.appRoot = this.envService.appRoot;
configuration.execPath = process.execPath;
@ -835,7 +824,6 @@ export class WindowsManager implements IWindowsService {
configuration.filesToOpen = filesToOpen;
configuration.filesToCreate = filesToCreate;
configuration.filesToDiff = filesToDiff;
configuration.extensionsToInstall = extensionsToInstall;
return configuration;
}
@ -859,8 +847,7 @@ export class WindowsManager implements IWindowsService {
{
filePath: candidate,
lineNumber: gotoLineMode ? parsedPath.line : void 0,
columnNumber: gotoLineMode ? parsedPath.column : void 0,
installExtensionPath: /\.vsix$/i.test(candidate)
columnNumber: gotoLineMode ? parsedPath.column : void 0
} :
{ workspacePath: candidate };
}

View file

@ -8,6 +8,7 @@ import * as platform from 'vs/base/common/platform';
import product from 'vs/platform/product';
import pkg from 'vs/platform/package';
import { serve, Server, connect } from 'vs/base/parts/ipc/node/ipc.net';
import { coalesce } from 'vs/base/common/arrays';
import { TPromise } from 'vs/base/common/winjs.base';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
@ -112,8 +113,9 @@ function main(server: Server, initData: ISharedProcessInitData): void {
(extensionManagementService as ExtensionManagementService).removeDeprecatedExtensions();
// install vsix
environmentService.args['install-vsix']
.forEach(vsix => extensionManagementService.install(vsix));
const vsixArg = environmentService.args['install-vsix'];
const vsix = typeof vsixArg === 'string' ? [vsixArg] : vsixArg;
coalesce(vsix || []).forEach(vsix => extensionManagementService.install(vsix));
});
});
}

View file

@ -7,7 +7,6 @@ import * as os from 'os';
import * as minimist from 'minimist';
import * as assert from 'assert';
import { firstIndex } from 'vs/base/common/arrays';
import { not } from 'vs/base/common/functional';
import { localize } from 'vs/nls';
export interface ParsedArgs extends minimist.ParsedArgs {
@ -32,7 +31,7 @@ export interface ParsedArgs extends minimist.ParsedArgs {
'list-extensions'?: boolean;
'install-extension'?: string | string[];
'uninstall-extension'?: string | string[];
'install-vsix'?: string[];
'install-vsix'?: string | string[];
}
const options: minimist.Opts = {
@ -44,6 +43,7 @@ const options: minimist.Opts = {
'extensionTestsPath',
'install-extension',
'uninstall-extension',
'install-vsix',
'debugBrkPluginHost',
'debugPluginHost'
],
@ -121,13 +121,7 @@ export function parseCLIProcessArgv(processArgv: string[]): ParsedArgs {
* Use this to parse code arguments such as `--verbose --wait`
*/
export function parseArgs(args: string[]): ParsedArgs {
const result = minimist(args, options) as ParsedArgs;
const isVSIX = a => /\.vsix$/i.test(a);
result['install-vsix'] = result._.filter(isVSIX);
result._ = result._.filter(not(isVSIX));
return result;
return minimist(args, options) as ParsedArgs;
}
export const optionsHelp: { [name: string]: string; } = {

View file

@ -22,9 +22,4 @@ export interface IOptions {
* Instructs the workbench to open a diff of the provided files right after startup.
*/
filesToDiff?: IResourceInput[];
/**
* Instructs the workbench to install the extensions from the provided local paths.
*/
extensionsToInstall?: string[];
}

View file

@ -40,8 +40,6 @@ export interface IWindowConfiguration extends ParsedArgs, IOpenFileRequest {
userEnv: any; /* vs/code/electron-main/env/IProcessEnvironment*/
workspacePath?: string;
extensionsToInstall?: string[];
}
export function startup(configuration: IWindowConfiguration): TPromise<void> {
@ -53,8 +51,7 @@ export function startup(configuration: IWindowConfiguration): TPromise<void> {
const shellOptions: IOptions = {
filesToOpen,
filesToCreate,
filesToDiff,
extensionsToInstall: configuration.extensionsToInstall
filesToDiff
};
if (configuration.performance) {

View file

@ -14,7 +14,6 @@ import { ExtensionGalleryService } from 'vs/platform/extensionManagement/node/ex
import { IWorkbenchActionRegistry, Extensions as WorkbenchActionExtensions } from 'vs/workbench/common/actionRegistry';
import { ExtensionTipsService } from 'vs/workbench/parts/extensions/electron-browser/extensionTipsService';
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
import { ExtensionsWorkbenchExtension } from 'vs/workbench/parts/extensions/electron-browser/extensionsWorkbenchExtension';
import { IOutputChannelRegistry, Extensions as OutputExtensions } from 'vs/workbench/parts/output/common/output';
import { EditorDescriptor } from 'vs/workbench/browser/parts/editor/baseEditor';
import { IEditorRegistry, Extensions as EditorExtensions } from 'vs/workbench/common/editor';
@ -36,10 +35,6 @@ registerSingleton(IExtensionGalleryService, ExtensionGalleryService);
registerSingleton(IExtensionTipsService, ExtensionTipsService);
registerSingleton(IExtensionsWorkbenchService, ExtensionsWorkbenchService);
// Workbench contributions
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench)
.registerWorkbenchContribution(ExtensionsWorkbenchExtension);
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench)
.registerWorkbenchContribution(StatusUpdater);

View file

@ -1,70 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { onUnexpectedError } from 'vs/base/common/errors';
import { localize } from 'vs/nls';
import { TPromise } from 'vs/base/common/winjs.base';
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
import { IExtensionManagementService, IExtensionGalleryService, IExtensionTipsService } from 'vs/platform/extensionManagement/common/extensionManagement';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IMessageService } from 'vs/platform/message/common/message';
import Severity from 'vs/base/common/severity';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { LegacyWorkspaceContextService } from 'vs/workbench/services/workspace/common/contextService';
import { ReloadWindowAction } from 'vs/workbench/electron-browser/actions';
import { ipcRenderer as ipc } from 'electron';
interface IInstallExtensionsRequest {
extensionsToInstall: string[];
}
// TODO@Joao retire this beast
export class ExtensionsWorkbenchExtension implements IWorkbenchContribution {
constructor(
@IInstantiationService private instantiationService: IInstantiationService,
@IExtensionManagementService private extensionManagementService: IExtensionManagementService,
@IMessageService private messageService: IMessageService,
@IWorkspaceContextService contextService: IWorkspaceContextService,
@IExtensionTipsService extenstionTips: IExtensionTipsService, // this is to eagerly start the service
@IExtensionGalleryService galleryService: IExtensionGalleryService
) {
this.registerListeners();
const options = (<LegacyWorkspaceContextService>contextService).getOptions();
if (options.extensionsToInstall && options.extensionsToInstall.length) {
this.install(options.extensionsToInstall).done(null, onUnexpectedError);
}
//actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(InstallExtensionAction, InstallExtensionAction.ID, InstallExtensionAction.LABEL), 'Extensions: Install Extension', ExtensionsLabel);
}
private registerListeners(): void {
ipc.on('vscode:installExtensions', (event, request: IInstallExtensionsRequest) => {
if (request.extensionsToInstall) {
this.install(request.extensionsToInstall).done(null, onUnexpectedError);
}
});
}
private install(extensions: string[]): TPromise<void> {
return TPromise.join(extensions.map(extPath => this.extensionManagementService.install(extPath)))
.then(() => {
this.messageService.show(
Severity.Info,
{
message: extensions.length > 1 ? localize('success', "Extensions were successfully installed. Restart to enable them.")
: localize('successSingle', "Extension was successfully installed. Restart to enable it."),
actions: [this.instantiationService.createInstance(ReloadWindowAction, ReloadWindowAction.ID, localize('reloadNow', "Restart Now"))]
}
);
});
}
public getId(): string {
return 'vs.extensions.workbenchextension';
}
}