From 04b4daeec8f571c2584d14f84a3e41cd381e1121 Mon Sep 17 00:00:00 2001 From: Greg Thornton Date: Sun, 26 May 2024 06:53:53 -0500 Subject: [PATCH] Add iwyu.fix.fix_header setting Signed-off-by: Greg Thornton --- README.md | 1 + package.json | 5 +++++ src/extension.ts | 4 +++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 315986e..b80d6fb 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,7 @@ The `fix_includes.py` tool can be configered with the following settings (names - `iwyu.fix.reorder`: Re-order lines relative to other similar lines (e.g. headers relative to other headers). - `iwyu.fix.safe_headers`: Do not remove unused #includes/fwd-declares from header files; just add new ones. - `iwyu.fix.update_comments`: Replace *why* comments with the ones provided by IWYU. +- `iwyu.fix.fix_header`: Fix includes in the corresponding header for a given implementation file (e.g. foo.h when fixing foo.cpp). Note that settings `iwyu.fix.ignore_re` and `iwyu.fix.only_re` are also used to determine whether execution can be skipped. diff --git a/package.json b/package.json index 44de9f4..85ed22a 100644 --- a/package.json +++ b/package.json @@ -170,6 +170,11 @@ "type": "boolean", "default": false, "markdownDescription": "Replace *why* comments with the ones provided by IWYU." + }, + "iwyu.fix.fix_header": { + "type": "boolean", + "default": false, + "markdownDescription": "Fix includes in the corresponding header for a given implementation file (e.g. foo.h when fixing foo.cpp)." } } } diff --git a/src/extension.ts b/src/extension.ts index c6862a1..53a4fed 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -376,7 +376,9 @@ class Extension { args.push(this.configData.config.get("fix.update_comments", false) ? "--update_comments" : "--noupdate_comments"); - args.push(compileCommand.file); // Restrict what to change + if (!this.configData.config.get("fix.fix_header", false)) { + args.push(compileCommand.file); // Restrict what to change + } let cmd = args.join(" "); log(TRACE, "fix:\n(cat <