Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

# [0.0.19]

* Added activation support for C language.

# [0.0.18]

* Fixed issue with `iwyu.diagnostics.only_re` setting default (needs to be `""`).
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 @@ -760,9 +764,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