Skip to content
Merged
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* Added activation support for C language.
* Added setting `iwyu.fix.fix_header` which fixes includes in the corresponding header for a given implementation file (e.g. foo.h when fixing foo.cpp).
* Fixed https://github.com/helly25/vscode-iwyu/issues/32. `${workspaceFolder}`, `${workspaceRoot}` and `${fileWorkspaceFolder}` are now also expanded in the `iwyu.include-what-you-use` and `iwyu.iwyu.mapping_file` settings.

# [0.0.18]

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ This extension has the following general settings:
does not result in removing such headers, it merely prevents adding them, so it won't produce diagnostics for such includes.
- `iwyu.fix_includes.py`: Path to the `fix_includes.py` script (finds the script on path if empty).
- `iwyu.include-what-you-use`: Path to the `include-what-you-use` executable (finds the executable on path if empty).
Supports `${workspaceFolder}`, `${workspaceRoot}` and `${fileWorkspaceFolder}`.

The diagnostics can be further configured:

Expand All @@ -82,7 +83,7 @@ The `include-what-you-use` tool can be configured with the following settings (n
- `iwyu.iwyu.keep`: A glob that tells iwyu to always keep these includes. Can be provided multiple times.
- `iwyu.iwyu.mapping_file`: Mapping file to use. See
[IWYU Mappings](https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/IWYUMappings.md) for
details.
details. Supports `${workspaceFolder}`, `${workspaceRoot}` and `${fileWorkspaceFolder}`.
- `iwyu.iwyu.max_line_length`: Maximum line length for includes.Note that this only affects comments and alignment
thereof, the maximum line length can still be exceeded with long file names
- `iwyu.iwyu.no_default_mappings`: Do not add iwyu's default mappings.
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"iwyu.include-what-you-use": {
"type": "string",
"default": "include-what-you-use",
"description": "Path to the `include-what-you-use` executable."
"markdownDescription": "Path to the `include-what-you-use` executable. Supports `${workspaceFolder}`, `${workspaceRoot}` and `${fileWorkspaceFolder}`."
},
"iwyu.iwyu.additional_params": {
"type": "string",
Expand All @@ -115,7 +115,7 @@
"iwyu.iwyu.mapping_file": {
"type": "string",
"default": "",
"description": "Mapping file to use if any."
"markdownDescription": "Mapping file to use if any. Supports `${workspaceFolder}`, `${workspaceRoot}` and `${fileWorkspaceFolder}`."
},
"iwyu.iwyu.max_line_length": {
"type": "integer",
Expand Down
10 changes: 5 additions & 5 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,11 @@ class ConfigData {
}

replaceWorkspaceVars(input: string): string {
input = input.replace("${workspaceRoot}", this.workspacefolder);
input = input.replace("${workspaceFolder}", this.workspacefolder);
input = input.split("${workspaceRoot}").join(this.workspacefolder);
input = input.split("${workspaceFolder}").join(this.workspacefolder);
const uri = vscode.window.activeTextEditor?.document?.uri;
const path = uri ? vscode.workspace.getWorkspaceFolder(uri)?.uri.fsPath : "";
input = input.replace("${fileWorkspaceFolder}", typeof path === "string" ? path : "");
input = input.split("${fileWorkspaceFolder}").join(typeof path === "string" ? path : "");
return input;
}

Expand Down Expand Up @@ -504,13 +504,13 @@ class Extension {

const mapping = this.configData.config.get("iwyu.mapping_file", "").trim();
if (mapping !== "") {
args.push("-Xiwyu --mapping_file=" + mapping);
args.push("-Xiwyu --mapping_file=" + this.configData.replaceWorkspaceVars(mapping));
}
const params = this.configData.config.get("iwyu.additional_params", "");
if (params !== "") {
args.push(params);
}
let iwyu = this.configData.config.get("include-what-you-use", "include-what-you-use");
let iwyu = this.configData.replaceWorkspaceVars(this.configData.config.get("include-what-you-use", "include-what-you-use"));
iwyu += " " + args.concat(compileCommand.arguments).join(" ") + " 2>&1";

log(TRACE, "Directory: `" + compileCommand.directory + "`");
Expand Down
Loading