Skip to content
Merged
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
26 changes: 0 additions & 26 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,6 @@ export async function activate(context: vscode.ExtensionContext) {
const diagnosticCollection = vscode.languages.createDiagnosticCollection("Cppcheck");
context.subscriptions.push(diagnosticCollection);

// set up a map of timers per document URI for debounce for continuous analysis triggers
// I.e. document has been changed -> DEBOUNCE_MS time passed since last change -> run cppcheck
const debounceTimers: Map<string, NodeJS.Timeout> = new Map();
const DEBOUNCE_MS = 1000;

async function handleDocument(document: vscode.TextDocument) {
// Only process C/C++ files.
if (!["c", "cpp"].includes(document.languageId)) {
Expand Down Expand Up @@ -155,27 +150,6 @@ export async function activate(context: vscode.ExtensionContext) {
);
}

// TODO: Reimplement continuous analysis. Requires cppcheck update (expected in 2.20)
async function handleDocumentContinuous(e: vscode.TextDocumentChangeEvent) {
const document : vscode.TextDocument = e.document;
const uriKey = document.uri.toString();

// clear any existing timer for this document
if (debounceTimers.has(uriKey)) {
clearTimeout(debounceTimers.get(uriKey)!);
}

// schedule a new run
const timer = setTimeout(async () => {
debounceTimers.delete(uriKey);
await handleDocument(document);
}, DEBOUNCE_MS);
debounceTimers.set(uriKey, timer);
}

// Run cppcheck when document is changed, with debounce
// vscode.workspace.onDidChangeTextDocument(handleDocumentContinuous, null, context.subscriptions);

// Listen for file saves.
vscode.workspace.onDidSaveTextDocument(handleDocument, null, context.subscriptions);

Expand Down
Loading