From 24209c67986b3fa2c1ca295b3945391f195e8dd0 Mon Sep 17 00:00:00 2001 From: Gabriel DeBacker Date: Wed, 15 Jan 2020 13:16:19 -0800 Subject: [PATCH 1/5] Fix formatting --- .../browser/extensions.contribution.ts | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/vs/workbench/contrib/extensions/browser/extensions.contribution.ts b/src/vs/workbench/contrib/extensions/browser/extensions.contribution.ts index f5fe47a7c09..08e0ec52ccb 100644 --- a/src/vs/workbench/contrib/extensions/browser/extensions.contribution.ts +++ b/src/vs/workbench/contrib/extensions/browser/extensions.contribution.ts @@ -232,26 +232,35 @@ CommandsRegistry.registerCommand({ schema: { 'type': ['object', 'string'] } + }, + { + name: localize('workbench.extensions.installExtension.arg.throwOnFailure', "Indicates whether to re-throw any exception as well as log it"), + schema: { + 'type': 'boolean' + } } ] }, - handler: async (accessor, arg: string | UriComponents) => { + handler: async (accessor, extensionId: string | UriComponents, throwOnFailure?: boolean) => { const extensionManagementService = accessor.get(IExtensionManagementService); const extensionGalleryService = accessor.get(IExtensionGalleryService); try { - if (typeof arg === 'string') { - const extension = await extensionGalleryService.getCompatibleExtension({ id: arg }); + if (typeof extensionId === 'string') { + const extension = await extensionGalleryService.getCompatibleExtension({ id: extensionId }); if (extension) { await extensionManagementService.installFromGallery(extension); } else { - throw new Error(localize('notFound', "Extension '{0}' not found.", arg)); + throw new Error(localize('notFound', "Extension '{0}' not found.", extensionId)); } } else { - const vsix = URI.revive(arg); + const vsix = URI.revive(extensionId); await extensionManagementService.install(vsix); } } catch (e) { onUnexpectedError(e); + if (throwOnFailure) { + throw e; + } } } }); @@ -266,10 +275,16 @@ CommandsRegistry.registerCommand({ schema: { 'type': 'string' } + }, + { + name: localize('workbench.extensions.uninstallExtension.arg.throwOnFailure', "Indicates whether to re-throw any exception as well as log it"), + schema: { + 'type': 'boolean' + } } ] }, - handler: async (accessor, id: string) => { + handler: async (accessor, id: string, throwOnFailure?: boolean) => { if (!id) { throw new Error(localize('id required', "Extension id required.")); } @@ -284,6 +299,9 @@ CommandsRegistry.registerCommand({ await extensionManagementService.uninstall(extensionToUninstall, true); } catch (e) { onUnexpectedError(e); + if (throwOnFailure) { + throw e; + } } } }); From d03d84f5a6aeb1d0b6196c60a3549bf720f6f9b8 Mon Sep 17 00:00:00 2001 From: Gabriel DeBacker Date: Tue, 21 Jan 2020 08:10:40 -0800 Subject: [PATCH 2/5] Throw all the time without additional parameter --- .../browser/extensions.contribution.ts | 32 +++++-------------- 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/src/vs/workbench/contrib/extensions/browser/extensions.contribution.ts b/src/vs/workbench/contrib/extensions/browser/extensions.contribution.ts index 08e0ec52ccb..5f0ea863439 100644 --- a/src/vs/workbench/contrib/extensions/browser/extensions.contribution.ts +++ b/src/vs/workbench/contrib/extensions/browser/extensions.contribution.ts @@ -228,20 +228,14 @@ CommandsRegistry.registerCommand({ description: localize('workbench.extensions.installExtension.description', "Install the given extension"), args: [ { - name: localize('workbench.extensions.installExtension.arg.name', "Extension id or VSIX resource uri"), + name: localize('workbench.extensions.installExtension.extensionId.name', "Extension id or VSIX resource uri"), schema: { 'type': ['object', 'string'] } - }, - { - name: localize('workbench.extensions.installExtension.arg.throwOnFailure', "Indicates whether to re-throw any exception as well as log it"), - schema: { - 'type': 'boolean' - } } ] }, - handler: async (accessor, extensionId: string | UriComponents, throwOnFailure?: boolean) => { + handler: async (accessor, extensionId: string | UriComponents) => { const extensionManagementService = accessor.get(IExtensionManagementService); const extensionGalleryService = accessor.get(IExtensionGalleryService); try { @@ -258,9 +252,7 @@ CommandsRegistry.registerCommand({ } } catch (e) { onUnexpectedError(e); - if (throwOnFailure) { - throw e; - } + throw e; } } }); @@ -271,26 +263,20 @@ CommandsRegistry.registerCommand({ description: localize('workbench.extensions.uninstallExtension.description', "Uninstall the given extension"), args: [ { - name: localize('workbench.extensions.uninstallExtension.arg.name', "Id of the extension to uninstall"), + name: localize('workbench.extensions.uninstallExtension.extensionId.name', "Id of the extension to uninstall"), schema: { 'type': 'string' } - }, - { - name: localize('workbench.extensions.uninstallExtension.arg.throwOnFailure', "Indicates whether to re-throw any exception as well as log it"), - schema: { - 'type': 'boolean' - } } ] }, - handler: async (accessor, id: string, throwOnFailure?: boolean) => { - if (!id) { + handler: async (accessor, extensionId: string) => { + if (!extensionId) { throw new Error(localize('id required', "Extension id required.")); } const extensionManagementService = accessor.get(IExtensionManagementService); const installed = await extensionManagementService.getInstalled(ExtensionType.User); - const [extensionToUninstall] = installed.filter(e => areSameExtensions(e.identifier, { id })); + const [extensionToUninstall] = installed.filter(e => areSameExtensions(e.identifier, { id: extensionId })); if (!extensionToUninstall) { throw new Error(localize('notInstalled', "Extension '{0}' is not installed. Make sure you use the full extension ID, including the publisher, e.g.: ms-vscode.csharp.", id)); } @@ -299,9 +285,7 @@ CommandsRegistry.registerCommand({ await extensionManagementService.uninstall(extensionToUninstall, true); } catch (e) { onUnexpectedError(e); - if (throwOnFailure) { - throw e; - } + throw e; } } }); From 136e1b07e91ec792cc8a4af9d2baeb069dc821d3 Mon Sep 17 00:00:00 2001 From: Gabriel DeBacker Date: Tue, 21 Jan 2020 09:20:35 -0800 Subject: [PATCH 3/5] Forgot one rename --- .../contrib/extensions/browser/extensions.contribution.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/extensions/browser/extensions.contribution.ts b/src/vs/workbench/contrib/extensions/browser/extensions.contribution.ts index 5f0ea863439..cb6b40bc536 100644 --- a/src/vs/workbench/contrib/extensions/browser/extensions.contribution.ts +++ b/src/vs/workbench/contrib/extensions/browser/extensions.contribution.ts @@ -278,7 +278,7 @@ CommandsRegistry.registerCommand({ const installed = await extensionManagementService.getInstalled(ExtensionType.User); const [extensionToUninstall] = installed.filter(e => areSameExtensions(e.identifier, { id: extensionId })); if (!extensionToUninstall) { - throw new Error(localize('notInstalled', "Extension '{0}' is not installed. Make sure you use the full extension ID, including the publisher, e.g.: ms-vscode.csharp.", id)); + throw new Error(localize('notInstalled', "Extension '{0}' is not installed. Make sure you use the full extension ID, including the publisher, e.g.: ms-vscode.csharp.", extensionId)); } try { From c092ab5a5aa1ef3f4c93cde6bf2d2246686de5a8 Mon Sep 17 00:00:00 2001 From: Gabriel DeBacker Date: Thu, 23 Jan 2020 08:20:20 -0800 Subject: [PATCH 4/5] Remove rename of method arguments --- .../browser/extensions.contribution.ts | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/vs/workbench/contrib/extensions/browser/extensions.contribution.ts b/src/vs/workbench/contrib/extensions/browser/extensions.contribution.ts index cb6b40bc536..3a442314590 100644 --- a/src/vs/workbench/contrib/extensions/browser/extensions.contribution.ts +++ b/src/vs/workbench/contrib/extensions/browser/extensions.contribution.ts @@ -228,26 +228,26 @@ CommandsRegistry.registerCommand({ description: localize('workbench.extensions.installExtension.description', "Install the given extension"), args: [ { - name: localize('workbench.extensions.installExtension.extensionId.name', "Extension id or VSIX resource uri"), + name: localize('workbench.extensions.installExtension.args.name', "Extension id or VSIX resource uri"), schema: { 'type': ['object', 'string'] } } ] }, - handler: async (accessor, extensionId: string | UriComponents) => { + handler: async (accessor, arg: string | UriComponents) => { const extensionManagementService = accessor.get(IExtensionManagementService); const extensionGalleryService = accessor.get(IExtensionGalleryService); try { - if (typeof extensionId === 'string') { - const extension = await extensionGalleryService.getCompatibleExtension({ id: extensionId }); + if (typeof arg === 'string') { + const extension = await extensionGalleryService.getCompatibleExtension({ id: arg }); if (extension) { await extensionManagementService.installFromGallery(extension); } else { - throw new Error(localize('notFound', "Extension '{0}' not found.", extensionId)); + throw new Error(localize('notFound', "Extension '{0}' not found.", arg)); } } else { - const vsix = URI.revive(extensionId); + const vsix = URI.revive(arg); await extensionManagementService.install(vsix); } } catch (e) { @@ -263,22 +263,22 @@ CommandsRegistry.registerCommand({ description: localize('workbench.extensions.uninstallExtension.description', "Uninstall the given extension"), args: [ { - name: localize('workbench.extensions.uninstallExtension.extensionId.name', "Id of the extension to uninstall"), + name: localize('workbench.extensions.uninstallExtension.arg.name', "Id of the extension to uninstall"), schema: { 'type': 'string' } } ] }, - handler: async (accessor, extensionId: string) => { - if (!extensionId) { + handler: async (accessor, id: string) => { + if (!id) { throw new Error(localize('id required', "Extension id required.")); } const extensionManagementService = accessor.get(IExtensionManagementService); const installed = await extensionManagementService.getInstalled(ExtensionType.User); - const [extensionToUninstall] = installed.filter(e => areSameExtensions(e.identifier, { id: extensionId })); + const [extensionToUninstall] = installed.filter(e => areSameExtensions(e.identifier, { id })); if (!extensionToUninstall) { - throw new Error(localize('notInstalled', "Extension '{0}' is not installed. Make sure you use the full extension ID, including the publisher, e.g.: ms-vscode.csharp.", extensionId)); + throw new Error(localize('notInstalled', "Extension '{0}' is not installed. Make sure you use the full extension ID, including the publisher, e.g.: ms-vscode.csharp.", id)); } try { From 3756f10310386d7ff2819b3343898769abebafa3 Mon Sep 17 00:00:00 2001 From: Gabriel DeBacker Date: Thu, 23 Jan 2020 08:21:19 -0800 Subject: [PATCH 5/5] Remove 's' from args --- .../contrib/extensions/browser/extensions.contribution.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/extensions/browser/extensions.contribution.ts b/src/vs/workbench/contrib/extensions/browser/extensions.contribution.ts index 3a442314590..2ec7478dfa0 100644 --- a/src/vs/workbench/contrib/extensions/browser/extensions.contribution.ts +++ b/src/vs/workbench/contrib/extensions/browser/extensions.contribution.ts @@ -228,7 +228,7 @@ CommandsRegistry.registerCommand({ description: localize('workbench.extensions.installExtension.description', "Install the given extension"), args: [ { - name: localize('workbench.extensions.installExtension.args.name', "Extension id or VSIX resource uri"), + name: localize('workbench.extensions.installExtension.arg.name', "Extension id or VSIX resource uri"), schema: { 'type': ['object', 'string'] }