Skip to content
Open
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
22 changes: 22 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import { documentationLinkMap, getPremiumCertLink } from './util/documentation';
import { runCommand } from './util/scripts';
import { looksLikePath, resolvePath, findWorkspaceRoot } from './util/path';

let cppcheckProgressIndicator: vscode.StatusBarItem;
let checksRunning = false;

enum SeverityNumber {
Info = 0,
Warning = 1,
Expand Down Expand Up @@ -64,6 +67,15 @@ function parseMinSeverity(str: string): SeverityNumber {
}
}

function updateProgressIndicator(): void {
if (checksRunning) {
cppcheckProgressIndicator.text = `$(loading~spin) Cppcheck Running ..`;
cppcheckProgressIndicator.show();
} else {
cppcheckProgressIndicator.hide();
}
}

// This method is called when your extension is activated.
// Your extension is activated the very first time the command is executed.
export async function activate(context: vscode.ExtensionContext) {
Expand All @@ -81,6 +93,10 @@ export async function activate(context: vscode.ExtensionContext) {
)
);

// ProgressIndicator status bar item to show when checks are running
cppcheckProgressIndicator = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 10);
context.subscriptions.push(cppcheckProgressIndicator);

// Create a diagnostic collection.
const diagnosticCollection = vscode.languages.createDiagnosticCollection("Cppcheck");
context.subscriptions.push(diagnosticCollection);
Expand Down Expand Up @@ -203,6 +219,9 @@ async function runCppcheckOnFileXML(
minSevString: string,
diagnosticCollection: vscode.DiagnosticCollection
): Promise<void> {
checksRunning = true;
updateProgressIndicator();

// Clear existing diagnostics for this file
diagnosticCollection.delete(document.uri);

Expand Down Expand Up @@ -352,6 +371,9 @@ async function runCppcheckOnFileXML(
diagnosticCollection.set(document.uri, diagnostics);
});
});

checksRunning = false;
updateProgressIndicator();
}

// This method is called when your extension is deactivated
Expand Down
Loading