From 1bde5444588c49cf3d000ed8aca0029daf55de6c Mon Sep 17 00:00:00 2001 From: Michelle Matias <38734287+michelleangela@users.noreply.github.com> Date: Wed, 27 Sep 2023 10:51:53 -0700 Subject: [PATCH] Add Include Header setting for refactoring actions (#11449) --- Extension/package.json | 16 ++++++++++++++++ Extension/package.nls.json | 6 +++++- Extension/src/LanguageServer/client.ts | 3 ++- Extension/src/LanguageServer/settings.ts | 2 ++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Extension/package.json b/Extension/package.json index 9ee9d09b03..7d905a5728 100644 --- a/Extension/package.json +++ b/Extension/package.json @@ -561,6 +561,22 @@ "description": "%c_cpp.configuration.inactiveRegionBackgroundColor.description%", "scope": "resource" }, + "C_Cpp.refactoring.includeHeader": { + "type": "string", + "enum": [ + "always", + "ifNeeded", + "never" + ], + "default": "always", + "markdownDescription": "%c_cpp.configuration.refactoring.includeHeader.markdownDescription%", + "enumDescriptions": [ + "%c_cpp.configuration.refactoring.includeHeader.always.description%", + "%c_cpp.configuration.refactoring.includeHeader.ifNeeded.description%", + "%c_cpp.configuration.refactoring.includeHeader.never.description%" + ], + "scope": "resource" + }, "C_Cpp.renameRequiresIdentifier": { "type": "boolean", "default": true, diff --git a/Extension/package.nls.json b/Extension/package.nls.json index 4b412bf9fa..5343b60140 100644 --- a/Extension/package.nls.json +++ b/Extension/package.nls.json @@ -996,5 +996,9 @@ "c_cpp.walkthrough.customize.debugging.windows.description": "You can customize your debug configuration (e.g. to pass arguments to your program at run time) by selecting \"Add Debug Configuration\" to the right of the play button. The custom debug configuration is saved in your project's launch.json file. \n[Learn More](https://code.visualstudio.com/docs/cpp/config-clang-mac#_debug-helloworldcpp)", "c_cpp.walkthrough.customize.debugging.altText": "Image that shows Add Debug Configuration in the drop-down", "c_cpp.codeActions.refactor.inline.macro.title": "Inline macro", - "c_cpp.codeActions.refactor.inline.macro.description": "Replace the macro invocation with the expanded code." + "c_cpp.codeActions.refactor.inline.macro.description": "Replace the macro invocation with the expanded code.", + "c_cpp.configuration.refactoring.includeHeader.markdownDescription": "Controls whether to include the header file of a refactored function/symbol to its corresponding source file when doing a refactoring action, such as create declaration/definition.", + "c_cpp.configuration.refactoring.includeHeader.always.description": "Always include the header file if it is not included explicitly in its source file.", + "c_cpp.configuration.refactoring.includeHeader.ifNeeded.description": "Only include the header file if it is not included explicitly in its source file or through implicit inclusion.", + "c_cpp.configuration.refactoring.includeHeader.never.description": "Never include the header file." } diff --git a/Extension/src/LanguageServer/client.ts b/Extension/src/LanguageServer/client.ts index 15fe52986a..b70cb88b52 100644 --- a/Extension/src/LanguageServer/client.ts +++ b/Extension/src/LanguageServer/client.ts @@ -1415,7 +1415,8 @@ export class DefaultClient implements Client { searchExclude: otherSettings.searchExclude, editorAutoClosingBrackets: otherSettings.editorAutoClosingBrackets, editorInlayHintsEnabled: otherSettings.editorInlayHintsEnabled, - editorParameterHintsEnabled: otherSettings.editorParameterHintsEnabled + editorParameterHintsEnabled: otherSettings.editorParameterHintsEnabled, + refactoringIncludeHeader: settings.refactoringIncludeHeader }; return result; } diff --git a/Extension/src/LanguageServer/settings.ts b/Extension/src/LanguageServer/settings.ts index 1d2152875c..a083e14d84 100644 --- a/Extension/src/LanguageServer/settings.ts +++ b/Extension/src/LanguageServer/settings.ts @@ -132,6 +132,7 @@ export interface WorkspaceFolderSettingsParams { editorAutoClosingBrackets: string | undefined; editorInlayHintsEnabled: boolean | undefined; editorParameterHintsEnabled: boolean | undefined; + refactoringIncludeHeader: string | undefined; } export interface SettingsParams { @@ -368,6 +369,7 @@ export class CppSettings extends Settings { public get workspaceParsingPriority(): string | undefined { return super.Section.get("workspaceParsingPriority"); } public get workspaceSymbols(): string | undefined { return super.Section.get("workspaceSymbols"); } public get exclusionPolicy(): string | undefined { return super.Section.get("exclusionPolicy"); } + public get refactoringIncludeHeader(): string | undefined { return super.Section.get("refactoring.includeHeader"); } public get simplifyStructuredComments(): boolean | undefined { return super.Section.get("simplifyStructuredComments"); } public get doxygenGeneratedCommentStyle(): string | undefined { return super.Section.get("doxygen.generatedStyle"); } public get doxygenGenerateOnType(): boolean | undefined { return super.Section.get("doxygen.generateOnType"); }