Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add iwyu.fix.fix_header setting #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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)."
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF...IWYU-output...EOF) | " + cmd);
cmd = "(cat <<EOF\n" + iwyuOutput + "\nEOF\n) | " + cmd;
Expand Down