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 @@ -2,6 +2,7 @@

# [0.0.19]

* 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).

# [0.0.18]
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"Include What You Use",
"include-what-you-use"
],
"version": "0.0.18",
"version": "0.0.19",
"publisher": "helly25",
"license": "Apache-2.0",
"repository": {
Expand All @@ -16,13 +16,14 @@
},
"icon": "images/logo.png",
"engines": {
"vscode": "^1.78.0"
"vscode": "^1.92.0"
},
"categories": [
"Other"
],
"activationEvents": [
"onLanguage:cpp"
"onLanguage:cpp",
"onLanguage:c"
],
"main": "./out/extension.js",
"contributes": {
Expand Down
24 changes: 18 additions & 6 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export const ERROR = vscode.LogLevel.Error;

const logger: vscode.LogOutputChannel = vscode.window.createOutputChannel("IWYU", { log: true });

const supportedLanguages = ["cpp", "c"];

function log(severity: vscode.LogLevel, message: string, ...args: any[]) {
switch (severity) {
case vscode.LogLevel.Off: return;
Expand Down Expand Up @@ -395,11 +397,13 @@ class Extension {

this.subscribeToDocumentChanges(context, iwyuDiagnostics);

context.subscriptions.push(
vscode.languages.registerCodeActionsProvider('cpp', new IwyuQuickFix(this.configData), {
providedCodeActionKinds: IwyuQuickFix.providedCodeActionKinds
})
);
for (const lang of supportedLanguages) {
context.subscriptions.push(
vscode.languages.registerCodeActionsProvider(lang, new IwyuQuickFix(this.configData), {
providedCodeActionKinds: IwyuQuickFix.providedCodeActionKinds,
})
);
}

context.subscriptions.push(vscode.commands.registerCommand(IWYU_COMMAND_ONE, () => { this.iwyuCommandOne(); }));
context.subscriptions.push(vscode.commands.registerCommand(IWYU_COMMAND_ALL, () => { this.iwyuCommandAll(); }));
Expand Down Expand Up @@ -762,9 +766,17 @@ class Extension {
}

private iwyuDiagnosticsRefresh(doc: vscode.TextDocument, iwyuDiagnostics: vscode.DiagnosticCollection) {
if (doc.languageId !== "cpp") {
// Only process real files (not logs, etc.)
if (doc.uri.scheme !== "file") {
return;
}

// Only process supported languages
if (!supportedLanguages.includes(doc.languageId)) {
log(DEBUG, `Unsupported language: ${doc.languageId}. Skipping.`);
return;
}

this.configData.updateConfig();
let diagnosticsOnlyRe: string = this.configData.config.get("diagnostics.only_re", "");
if (typeof diagnosticsOnlyRe !== "string" || String(diagnosticsOnlyRe) === "true") {
Expand Down