Skip to content

Commit 1bde544

Browse files
Add Include Header setting for refactoring actions (#11449)
1 parent f62cad6 commit 1bde544

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

Extension/package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,22 @@
561561
"description": "%c_cpp.configuration.inactiveRegionBackgroundColor.description%",
562562
"scope": "resource"
563563
},
564+
"C_Cpp.refactoring.includeHeader": {
565+
"type": "string",
566+
"enum": [
567+
"always",
568+
"ifNeeded",
569+
"never"
570+
],
571+
"default": "always",
572+
"markdownDescription": "%c_cpp.configuration.refactoring.includeHeader.markdownDescription%",
573+
"enumDescriptions": [
574+
"%c_cpp.configuration.refactoring.includeHeader.always.description%",
575+
"%c_cpp.configuration.refactoring.includeHeader.ifNeeded.description%",
576+
"%c_cpp.configuration.refactoring.includeHeader.never.description%"
577+
],
578+
"scope": "resource"
579+
},
564580
"C_Cpp.renameRequiresIdentifier": {
565581
"type": "boolean",
566582
"default": true,

Extension/package.nls.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -996,5 +996,9 @@
996996
"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)",
997997
"c_cpp.walkthrough.customize.debugging.altText": "Image that shows Add Debug Configuration in the drop-down",
998998
"c_cpp.codeActions.refactor.inline.macro.title": "Inline macro",
999-
"c_cpp.codeActions.refactor.inline.macro.description": "Replace the macro invocation with the expanded code."
999+
"c_cpp.codeActions.refactor.inline.macro.description": "Replace the macro invocation with the expanded code.",
1000+
"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.",
1001+
"c_cpp.configuration.refactoring.includeHeader.always.description": "Always include the header file if it is not included explicitly in its source file.",
1002+
"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.",
1003+
"c_cpp.configuration.refactoring.includeHeader.never.description": "Never include the header file."
10001004
}

Extension/src/LanguageServer/client.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1415,7 +1415,8 @@ export class DefaultClient implements Client {
14151415
searchExclude: otherSettings.searchExclude,
14161416
editorAutoClosingBrackets: otherSettings.editorAutoClosingBrackets,
14171417
editorInlayHintsEnabled: otherSettings.editorInlayHintsEnabled,
1418-
editorParameterHintsEnabled: otherSettings.editorParameterHintsEnabled
1418+
editorParameterHintsEnabled: otherSettings.editorParameterHintsEnabled,
1419+
refactoringIncludeHeader: settings.refactoringIncludeHeader
14191420
};
14201421
return result;
14211422
}

Extension/src/LanguageServer/settings.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ export interface WorkspaceFolderSettingsParams {
132132
editorAutoClosingBrackets: string | undefined;
133133
editorInlayHintsEnabled: boolean | undefined;
134134
editorParameterHintsEnabled: boolean | undefined;
135+
refactoringIncludeHeader: string | undefined;
135136
}
136137

137138
export interface SettingsParams {
@@ -368,6 +369,7 @@ export class CppSettings extends Settings {
368369
public get workspaceParsingPriority(): string | undefined { return super.Section.get<string>("workspaceParsingPriority"); }
369370
public get workspaceSymbols(): string | undefined { return super.Section.get<string>("workspaceSymbols"); }
370371
public get exclusionPolicy(): string | undefined { return super.Section.get<string>("exclusionPolicy"); }
372+
public get refactoringIncludeHeader(): string | undefined { return super.Section.get<string>("refactoring.includeHeader"); }
371373
public get simplifyStructuredComments(): boolean | undefined { return super.Section.get<boolean>("simplifyStructuredComments"); }
372374
public get doxygenGeneratedCommentStyle(): string | undefined { return super.Section.get<string>("doxygen.generatedStyle"); }
373375
public get doxygenGenerateOnType(): boolean | undefined { return super.Section.get<boolean>("doxygen.generateOnType"); }

0 commit comments

Comments
 (0)