From fc4bbfaa6ee1c6d83e2aeb512d6de41060948573 Mon Sep 17 00:00:00 2001 From: Dirk Baeumer Date: Mon, 13 Nov 2017 14:12:47 +0100 Subject: [PATCH] Fixes #35525: Review your deepClone usages --- .../tasks/common/taskDefinitionRegistry.ts | 2 +- .../tasks/electron-browser/jsonSchema_v1.ts | 8 ++-- .../tasks/electron-browser/jsonSchema_v2.ts | 44 +++++++++---------- .../parts/tasks/node/taskConfiguration.ts | 4 +- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/vs/workbench/parts/tasks/common/taskDefinitionRegistry.ts b/src/vs/workbench/parts/tasks/common/taskDefinitionRegistry.ts index 77406c82d73..0b2ccd7a2f4 100644 --- a/src/vs/workbench/parts/tasks/common/taskDefinitionRegistry.ts +++ b/src/vs/workbench/parts/tasks/common/taskDefinitionRegistry.ts @@ -64,7 +64,7 @@ namespace Configuration { } } } - return { extensionId, taskType, required: required.length >= 0 ? required : undefined, properties: value.properties ? Objects.deepClone(value.properties) : undefined }; + return { extensionId, taskType, required: required.length >= 0 ? required : undefined, properties: value.properties ? Objects.clone(value.properties) : undefined }; } } diff --git a/src/vs/workbench/parts/tasks/electron-browser/jsonSchema_v1.ts b/src/vs/workbench/parts/tasks/electron-browser/jsonSchema_v1.ts index a82c294c6c7..8ff97de4161 100644 --- a/src/vs/workbench/parts/tasks/electron-browser/jsonSchema_v1.ts +++ b/src/vs/workbench/parts/tasks/electron-browser/jsonSchema_v1.ts @@ -62,11 +62,11 @@ const shellCommand: IJSONSchema = { description: nls.localize('JsonSchema.shell', 'Specifies whether the command is a shell command or an external program. Defaults to false if omitted.') }; -schema.definitions = Objects.deepClone(commonSchema.definitions); +schema.definitions = Objects.clone(commonSchema.definitions); let definitions = schema.definitions; -definitions['commandConfiguration']['properties']['isShellCommand'] = Objects.deepClone(shellCommand); -definitions['taskDescription']['properties']['isShellCommand'] = Objects.deepClone(shellCommand); -definitions['taskRunnerConfiguration']['properties']['isShellCommand'] = Objects.deepClone(shellCommand); +definitions['commandConfiguration']['properties']['isShellCommand'] = Objects.clone(shellCommand); +definitions['taskDescription']['properties']['isShellCommand'] = Objects.clone(shellCommand); +definitions['taskRunnerConfiguration']['properties']['isShellCommand'] = Objects.clone(shellCommand); Object.getOwnPropertyNames(definitions).forEach(key => { let newKey = key + '1'; diff --git a/src/vs/workbench/parts/tasks/electron-browser/jsonSchema_v2.ts b/src/vs/workbench/parts/tasks/electron-browser/jsonSchema_v2.ts index 37fc4bb43dd..7f8c99c7bda 100644 --- a/src/vs/workbench/parts/tasks/electron-browser/jsonSchema_v2.ts +++ b/src/vs/workbench/parts/tasks/electron-browser/jsonSchema_v2.ts @@ -101,7 +101,7 @@ const presentation: IJSONSchema = { } }; -const terminal: IJSONSchema = Objects.deepClone(presentation); +const terminal: IJSONSchema = Objects.clone(presentation); terminal.deprecationMessage = nls.localize('JsonSchema.tasks.terminal', 'The terminal property is deprecated. Use presentation instead'); const group: IJSONSchema = { @@ -178,8 +178,8 @@ let taskConfiguration: IJSONSchema = { description: nls.localize('JsonSchema.tasks.taskName', 'The task\'s name'), deprecationMessage: nls.localize('JsonSchema.tasks.taskName.deprecated', 'The task\'s name property is deprecated. Use the label property instead.') }, - identifier: Objects.deepClone(identifier), - group: Objects.deepClone(group), + identifier: Objects.clone(identifier), + group: Objects.clone(group), isBackground: { type: 'boolean', description: nls.localize('JsonSchema.tasks.background', 'Whether the executed task is kept alive and is running in the background.'), @@ -190,7 +190,7 @@ let taskConfiguration: IJSONSchema = { description: nls.localize('JsonSchema.tasks.promptOnClose', 'Whether the user is prompted when VS Code closes with a running task.'), default: false }, - presentation: Objects.deepClone(presentation), + presentation: Objects.clone(presentation), problemMatcher: { $ref: '#/definitions/problemMatcherType', description: nls.localize('JsonSchema.tasks.matchers', 'The problem matcher(s) to use. Can either be a string or a problem matcher definition or an array of strings and problem matchers.') @@ -201,7 +201,7 @@ let taskConfiguration: IJSONSchema = { let taskDefinitions: IJSONSchema[] = []; TaskDefinitionRegistry.onReady().then(() => { for (let taskType of TaskDefinitionRegistry.all()) { - let schema: IJSONSchema = Objects.deepClone(taskConfiguration); + let schema: IJSONSchema = Objects.clone(taskConfiguration); // Since we do this after the schema is assigned we need to patch the refs. schema.properties.type = { type: 'string', @@ -213,31 +213,31 @@ TaskDefinitionRegistry.onReady().then(() => { } for (let key of Object.keys(taskType.properties)) { let property = taskType.properties[key]; - schema.properties[key] = Objects.deepClone(property); + schema.properties[key] = Objects.clone(property); } fixReferences(schema); taskDefinitions.push(schema); } }); -let customize = Objects.deepClone(taskConfiguration); +let customize = Objects.clone(taskConfiguration); customize.properties.customize = { type: 'string', deprecationMessage: nls.localize('JsonSchema.tasks.customize.deprecated', 'The customize property is deprecated. See the 1.14 release notes on how to migrate to the new task customization approach') }; taskDefinitions.push(customize); -let definitions = Objects.deepClone(commonSchema.definitions); +let definitions = Objects.clone(commonSchema.definitions); let taskDescription: IJSONSchema = definitions.taskDescription; taskDescription.required = ['label']; -taskDescription.properties.label = Objects.deepClone(label); -taskDescription.properties.isShellCommand = Objects.deepClone(shellCommand); +taskDescription.properties.label = Objects.clone(label); +taskDescription.properties.isShellCommand = Objects.clone(shellCommand); taskDescription.properties.dependsOn = dependsOn; -taskDescription.properties.identifier = Objects.deepClone(identifier); -taskDescription.properties.type = Objects.deepClone(taskType); -taskDescription.properties.presentation = Objects.deepClone(presentation); +taskDescription.properties.identifier = Objects.clone(identifier); +taskDescription.properties.type = Objects.clone(taskType); +taskDescription.properties.presentation = Objects.clone(presentation); taskDescription.properties.terminal = terminal; -taskDescription.properties.group = Objects.deepClone(group); +taskDescription.properties.group = Objects.clone(group); taskDescription.properties.taskName.deprecationMessage = nls.localize( 'JsonSchema.tasks.taskName.deprecated', 'The task\'s name property is deprecated. Use the label property instead.' @@ -278,15 +278,15 @@ tasks.items = { oneOf: taskDefinitions }; -definitions.commandConfiguration.properties.isShellCommand = Objects.deepClone(shellCommand); +definitions.commandConfiguration.properties.isShellCommand = Objects.clone(shellCommand); definitions.options.properties.shell = { $ref: '#/definitions/shellConfiguration' }; -definitions.taskRunnerConfiguration.properties.isShellCommand = Objects.deepClone(shellCommand); -definitions.taskRunnerConfiguration.properties.type = Objects.deepClone(taskType); -definitions.taskRunnerConfiguration.properties.group = Objects.deepClone(group); -definitions.taskRunnerConfiguration.properties.presentation = Objects.deepClone(presentation); +definitions.taskRunnerConfiguration.properties.isShellCommand = Objects.clone(shellCommand); +definitions.taskRunnerConfiguration.properties.type = Objects.clone(taskType); +definitions.taskRunnerConfiguration.properties.group = Objects.clone(group); +definitions.taskRunnerConfiguration.properties.presentation = Objects.clone(presentation); definitions.taskRunnerConfiguration.properties.suppressTaskName.deprecationMessage = nls.localize( 'JsonSchema.tasks.suppressTaskName.deprecated', 'The property suppressTaskName is deprecated. Inline the command with its arguments into the task instead. See also the 1.14 release notes.' @@ -296,11 +296,11 @@ definitions.taskRunnerConfiguration.properties.taskSelector.deprecationMessage = 'The property taskSelector is deprecated. Inline the command with its arguments into the task instead. See also the 1.14 release notes.' ); -let osSpecificTaskRunnerConfiguration = Objects.deepClone(definitions.taskRunnerConfiguration); +let osSpecificTaskRunnerConfiguration = Objects.clone(definitions.taskRunnerConfiguration); delete osSpecificTaskRunnerConfiguration.properties.tasks; osSpecificTaskRunnerConfiguration.additionalProperties = false; definitions.osSpecificTaskRunnerConfiguration = osSpecificTaskRunnerConfiguration; -definitions.taskRunnerConfiguration.properties.version = Objects.deepClone(version); +definitions.taskRunnerConfiguration.properties.version = Objects.clone(version); const schema: IJSONSchema = { oneOf: [ @@ -310,7 +310,7 @@ const schema: IJSONSchema = { type: 'object', required: ['version'], properties: { - version: Objects.deepClone(version), + version: Objects.clone(version), windows: { '$ref': '#/definitions/osSpecificTaskRunnerConfiguration', 'description': nls.localize('JsonSchema.windows', 'Windows specific command configuration') diff --git a/src/vs/workbench/parts/tasks/node/taskConfiguration.ts b/src/vs/workbench/parts/tasks/node/taskConfiguration.ts index eaf473e96d8..0c67b6dc143 100644 --- a/src/vs/workbench/parts/tasks/node/taskConfiguration.ts +++ b/src/vs/workbench/parts/tasks/node/taskConfiguration.ts @@ -519,7 +519,7 @@ function _fillDefaults(this: void, target: T, defaults: T, properties: MetaDa } if (target === void 0 || target === null) { if (defaults !== void 0 && defaults !== null) { - return Objects.deepClone(defaults); + return Objects.clone(defaults); } else { return undefined; } @@ -1166,7 +1166,7 @@ namespace ConfiguringTask { } else if (required.has(property)) { let schema = properties[property]; if (schema.default !== void 0) { - identifier[property] = Objects.deepClone(schema.default); + identifier[property] = Objects.clone(schema.default); } else { switch (schema.type) { case 'boolean': -- GitLab