From 7a67a54e5e8fa3fff5333b43f88cad062da3795c Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Thu, 5 Sep 2019 15:39:01 +0200 Subject: [PATCH] extensionDevelopmentPath is string[] --- src/bootstrap-window.js | 2 +- .../electron-browser/workbench/workbench.js | 2 +- src/vs/code/electron-main/window.ts | 2 +- src/vs/code/electron-main/windows.ts | 6 +--- src/vs/code/node/cliProcessMain.ts | 15 ++-------- src/vs/code/node/windowsFinder.ts | 25 ++++------------- .../environment/common/environment.ts | 16 +++++------ .../environment/node/environmentService.ts | 5 ---- .../platform/windows/electron-main/windows.ts | 4 +-- .../windows/electron-main/windowsService.ts | 5 ++-- .../workbench/browser/web.simpleservices.ts | 28 ++++--------------- .../extensionsTipsService.test.ts | 2 +- .../common/remoteAgentEnvironmentChannel.ts | 2 +- 13 files changed, 33 insertions(+), 81 deletions(-) diff --git a/src/bootstrap-window.js b/src/bootstrap-window.js index 85548f51965..72403b1e413 100644 --- a/src/bootstrap-window.js +++ b/src/bootstrap-window.js @@ -34,7 +34,7 @@ exports.load = function (modulePaths, resultCallback, options) { * // configuration: IWindowConfiguration * @type {{ * zoomLevel?: number, - * extensionDevelopmentPath?: string | string[], + * extensionDevelopmentPath?: string[], * extensionTestsPath?: string, * userEnv?: { [key: string]: string | undefined }, * appRoot?: string, diff --git a/src/vs/code/electron-browser/workbench/workbench.js b/src/vs/code/electron-browser/workbench/workbench.js index 22d5dbe329c..2a2c6981c7d 100644 --- a/src/vs/code/electron-browser/workbench/workbench.js +++ b/src/vs/code/electron-browser/workbench/workbench.js @@ -49,7 +49,7 @@ bootstrapWindow.load([ * @param {{ * partsSplashPath?: string, * highContrast?: boolean, - * extensionDevelopmentPath?: string | string[], + * extensionDevelopmentPath?: string[], * folderUri?: object, * workspace?: object * }} configuration diff --git a/src/vs/code/electron-main/window.ts b/src/vs/code/electron-main/window.ts index c6d2f29b1ba..157300bb64b 100644 --- a/src/vs/code/electron-main/window.ts +++ b/src/vs/code/electron-main/window.ts @@ -32,7 +32,7 @@ const RUN_TEXTMATE_IN_WORKER = false; export interface IWindowCreationOptions { state: IWindowState; - extensionDevelopmentPath?: string | string[]; + extensionDevelopmentPath?: string[]; isExtensionTestHost?: boolean; } diff --git a/src/vs/code/electron-main/windows.ts b/src/vs/code/electron-main/windows.ts index 8541606e61a..d4b330e55c5 100644 --- a/src/vs/code/electron-main/windows.ts +++ b/src/vs/code/electron-main/windows.ts @@ -1170,7 +1170,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService { return { openFolderInNewWindow: !!openFolderInNewWindow, openFilesInNewWindow }; } - openExtensionDevelopmentHostWindow(extensionDevelopmentPath: string | string[], openConfig: IOpenConfiguration): void { + openExtensionDevelopmentHostWindow(extensionDevelopmentPath: string[], openConfig: IOpenConfiguration): void { // Reload an existing extension development host window on the same path // We currently do not allow more than one extension development window @@ -1207,10 +1207,6 @@ export class WindowsManager extends Disposable implements IWindowsMainService { } } - if (!Array.isArray(extensionDevelopmentPath)) { - extensionDevelopmentPath = [extensionDevelopmentPath]; - } - let authority = ''; for (let p of extensionDevelopmentPath) { if (p.match(/^[a-zA-Z][a-zA-Z0-9\+\-\.]+:/)) { diff --git a/src/vs/code/node/cliProcessMain.ts b/src/vs/code/node/cliProcessMain.ts index ee828c29374..94bb62a7518 100644 --- a/src/vs/code/node/cliProcessMain.ts +++ b/src/vs/code/node/cliProcessMain.ts @@ -83,23 +83,14 @@ export class Main { async run(argv: ParsedArgs): Promise { if (argv['install-source']) { await this.setInstallSource(argv['install-source']); - } else if (argv['list-extensions']) { await this.listExtensions(!!argv['show-versions'], argv['category']); - } else if (argv['install-extension']) { - const arg = argv['install-extension']; - const args: string[] = typeof arg === 'string' ? [arg] : arg; - await this.installExtensions(args, !!argv['force']); - + await this.installExtensions(argv['install-extension'], !!argv['force']); } else if (argv['uninstall-extension']) { - const arg = argv['uninstall-extension']; - const ids: string[] = typeof arg === 'string' ? [arg] : arg; - await this.uninstallExtension(ids); + await this.uninstallExtension(argv['uninstall-extension']); } else if (argv['locate-extension']) { - const arg = argv['locate-extension']; - const ids: string[] = typeof arg === 'string' ? [arg] : arg; - await this.locateExtension(ids); + await this.locateExtension(argv['locate-extension']); } else if (argv['telemetry']) { console.log(buildTelemetryMessage(this.environmentService.appRoot, this.environmentService.extensionsPath ? this.environmentService.extensionsPath : undefined)); } diff --git a/src/vs/code/node/windowsFinder.ts b/src/vs/code/node/windowsFinder.ts index dc4b62e41ff..03e836c4827 100644 --- a/src/vs/code/node/windowsFinder.ts +++ b/src/vs/code/node/windowsFinder.ts @@ -14,7 +14,7 @@ export interface ISimpleWindow { openedWorkspace?: IWorkspaceIdentifier; openedFolderUri?: URI; - extensionDevelopmentPath?: string | string[]; + extensionDevelopmentPath?: string[]; lastFocusTime: number; } @@ -95,30 +95,17 @@ export function findWindowOnWorkspace(windows: W[], wor return null; } -export function findWindowOnExtensionDevelopmentPath(windows: W[], extensionDevelopmentPath: string | string[]): W | null { +export function findWindowOnExtensionDevelopmentPath(windows: W[], extensionDevelopmentPaths: string[]): W | null { const matches = (uriString: string): boolean => { - if (Array.isArray(extensionDevelopmentPath)) { - return extensionDevelopmentPath.some(p => extpath.isEqual(p, uriString, !platform.isLinux /* ignorecase */)); - } else if (extensionDevelopmentPath) { - return extpath.isEqual(extensionDevelopmentPath, uriString, !platform.isLinux /* ignorecase */); - } - return false; + return extensionDevelopmentPaths.some(p => extpath.isEqual(p, uriString, !platform.isLinux /* ignorecase */)); }; for (const window of windows) { // match on extension development path. The path can be one or more paths or uri strings, using paths.isEqual is not 100% correct but good enough - - if (window.extensionDevelopmentPath) { - if (Array.isArray(window.extensionDevelopmentPath)) { - if (window.extensionDevelopmentPath.some(p => matches(p))) { - return window; - } - } else if (window.extensionDevelopmentPath) { - if (matches(window.extensionDevelopmentPath)) { - return window; - } - } + const currPaths = window.extensionDevelopmentPath; + if (currPaths && currPaths.some(p => matches(p))) { + return window; } } diff --git a/src/vs/platform/environment/common/environment.ts b/src/vs/platform/environment/common/environment.ts index 338a392f360..413381155d4 100644 --- a/src/vs/platform/environment/common/environment.ts +++ b/src/vs/platform/environment/common/environment.ts @@ -8,8 +8,8 @@ import { URI } from 'vs/base/common/uri'; export interface ParsedArgs { _: string[]; - 'folder-uri'?: string[]; - 'file-uri'?: string[]; + 'folder-uri'?: string[]; // undefined or array of 1 or more + 'file-uri'?: string[]; // undefined or array of 1 or more _urls?: string[]; help?: boolean; version?: boolean; @@ -36,7 +36,7 @@ export interface ParsedArgs { logExtensionHostCommunication?: boolean; 'extensions-dir'?: string; 'builtin-extensions-dir'?: string; - extensionDevelopmentPath?: string[]; // one or more local paths or URIs + extensionDevelopmentPath?: string[]; // // undefined or array of 1 or more local paths or URIs extensionTestsPath?: string; // either a local path or a URI 'extension-development-confirm-save'?: boolean; 'inspect-extensions'?: string; @@ -45,14 +45,14 @@ export interface ParsedArgs { 'inspect-search'?: string; 'inspect-brk-search'?: string; 'disable-extensions'?: boolean; - 'disable-extension'?: string[]; + 'disable-extension'?: string[]; // undefined or array of 1 or more 'list-extensions'?: boolean; 'show-versions'?: boolean; 'category'?: string; - 'install-extension'?: string[]; - 'uninstall-extension'?: string[]; - 'locate-extension'?: string[]; - 'enable-proposed-api'?: string[]; + 'install-extension'?: string[]; // undefined or array of 1 or more + 'uninstall-extension'?: string[]; // undefined or array of 1 or more + 'locate-extension'?: string[]; // undefined or array of 1 or more + 'enable-proposed-api'?: string[]; // undefined or array of 1 or more 'open-url'?: boolean; 'skip-getting-started'?: boolean; 'skip-release-notes'?: boolean; diff --git a/src/vs/platform/environment/node/environmentService.ts b/src/vs/platform/environment/node/environmentService.ts index 3eb487a5c44..e0cc96ad33b 100644 --- a/src/vs/platform/environment/node/environmentService.ts +++ b/src/vs/platform/environment/node/environmentService.ts @@ -198,11 +198,6 @@ export class EnvironmentService implements IEnvironmentService { } return URI.file(path.normalize(p)); }); - } else if (s) { - if (/^[^:/?#]+?:\/\//.test(s)) { - return [URI.parse(s)]; - } - return [URI.file(path.normalize(s))]; } return undefined; } diff --git a/src/vs/platform/windows/electron-main/windows.ts b/src/vs/platform/windows/electron-main/windows.ts index 71479f9009e..d98d0727c57 100644 --- a/src/vs/platform/windows/electron-main/windows.ts +++ b/src/vs/platform/windows/electron-main/windows.ts @@ -96,7 +96,7 @@ export interface IWindowsMainService { enterWorkspace(win: ICodeWindow, path: URI): Promise; closeWorkspace(win: ICodeWindow): void; open(openConfig: IOpenConfiguration): ICodeWindow[]; - openExtensionDevelopmentHostWindow(extensionDevelopmentPath: string | string[], openConfig: IOpenConfiguration): void; + openExtensionDevelopmentHostWindow(extensionDevelopmentPath: string[], openConfig: IOpenConfiguration): void; pickFileFolderAndOpen(options: INativeOpenDialogOptions): Promise; pickFolderAndOpen(options: INativeOpenDialogOptions): Promise; pickFileAndOpen(options: INativeOpenDialogOptions): Promise; @@ -140,4 +140,4 @@ export interface IOpenConfiguration { export interface ISharedProcess { whenReady(): Promise; toggle(): void; -} \ No newline at end of file +} diff --git a/src/vs/platform/windows/electron-main/windowsService.ts b/src/vs/platform/windows/electron-main/windowsService.ts index b02f54433d2..68863b9f480 100644 --- a/src/vs/platform/windows/electron-main/windowsService.ts +++ b/src/vs/platform/windows/electron-main/windowsService.ts @@ -309,8 +309,9 @@ export class WindowsService extends Disposable implements IWindowsService, IURLH async openExtensionDevelopmentHostWindow(args: ParsedArgs, env: IProcessEnvironment): Promise { this.logService.trace('windowsService#openExtensionDevelopmentHostWindow ' + JSON.stringify(args)); - if (args.extensionDevelopmentPath) { - this.windowsMainService.openExtensionDevelopmentHostWindow(args.extensionDevelopmentPath, { + const extDevPaths = args.extensionDevelopmentPath; + if (extDevPaths) { + this.windowsMainService.openExtensionDevelopmentHostWindow(extDevPaths, { context: OpenContext.API, cli: args, userEnv: Object.keys(env).length > 0 ? env : undefined diff --git a/src/vs/workbench/browser/web.simpleservices.ts b/src/vs/workbench/browser/web.simpleservices.ts index caf44465e73..83f0c3b53c6 100644 --- a/src/vs/workbench/browser/web.simpleservices.ts +++ b/src/vs/workbench/browser/web.simpleservices.ts @@ -520,18 +520,9 @@ export class SimpleWindowsService implements IWindowsService { const f = args['folder-uri']; if (f) { - let u: URI | undefined; - if (Array.isArray(f)) { - if (f.length > 0) { - u = URI.parse(f[0]); - } - } else { - u = URI.parse(f); - } - if (u) { - gotFolder = true; - addQueryParameter('folder', u.path); - } + const u = URI.parse(f[0]); + gotFolder = true; + addQueryParameter('folder', u.path); } if (!gotFolder) { // request empty window @@ -540,17 +531,8 @@ export class SimpleWindowsService implements IWindowsService { const ep = args['extensionDevelopmentPath']; if (ep) { - let u: string | undefined; - if (Array.isArray(ep)) { - if (ep.length > 0) { - u = ep[0]; - } - } else { - u = ep; - } - if (u) { - addQueryParameter('edp', u); - } + let u = ep[0]; + addQueryParameter('edp', u); } const di = args['debugId']; diff --git a/src/vs/workbench/contrib/extensions/test/electron-browser/extensionsTipsService.test.ts b/src/vs/workbench/contrib/extensions/test/electron-browser/extensionsTipsService.test.ts index 87deffa1001..c019fde285d 100644 --- a/src/vs/workbench/contrib/extensions/test/electron-browser/extensionsTipsService.test.ts +++ b/src/vs/workbench/contrib/extensions/test/electron-browser/extensionsTipsService.test.ts @@ -235,7 +235,7 @@ suite('ExtensionsTipsService Test', () => { }); setup(() => { - instantiationService.stub(IEnvironmentService, >{ extensionDevelopmentPath: false }); + instantiationService.stub(IEnvironmentService, >{}); instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', []); instantiationService.stub(IExtensionGalleryService, 'isEnabled', true); instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(...mockExtensionGallery)); diff --git a/src/vs/workbench/services/remote/common/remoteAgentEnvironmentChannel.ts b/src/vs/workbench/services/remote/common/remoteAgentEnvironmentChannel.ts index fe15f2b644e..a1877e037aa 100644 --- a/src/vs/workbench/services/remote/common/remoteAgentEnvironmentChannel.ts +++ b/src/vs/workbench/services/remote/common/remoteAgentEnvironmentChannel.ts @@ -14,7 +14,7 @@ import { RemoteAuthorities } from 'vs/base/common/network'; export interface IGetEnvironmentDataArguments { language: string; remoteAuthority: string; - extensionDevelopmentPath: UriComponents | UriComponents[] | undefined; + extensionDevelopmentPath: UriComponents[] | undefined; } export interface IRemoteAgentEnvironmentDTO { -- GitLab