Skip to content

Commit a16904a

Browse files
committed
maintenance / cleaned up old unused code related to checks triggering from document text changing
1 parent 8095a22 commit a16904a

1 file changed

Lines changed: 0 additions & 26 deletions

File tree

src/extension.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,6 @@ export async function activate(context: vscode.ExtensionContext) {
8585
const diagnosticCollection = vscode.languages.createDiagnosticCollection("Cppcheck");
8686
context.subscriptions.push(diagnosticCollection);
8787

88-
// set up a map of timers per document URI for debounce for continuous analysis triggers
89-
// I.e. document has been changed -> DEBOUNCE_MS time passed since last change -> run cppcheck
90-
const debounceTimers: Map<string, NodeJS.Timeout> = new Map();
91-
const DEBOUNCE_MS = 1000;
92-
9388
async function handleDocument(document: vscode.TextDocument) {
9489
// Only process C/C++ files.
9590
if (!["c", "cpp"].includes(document.languageId)) {
@@ -155,27 +150,6 @@ export async function activate(context: vscode.ExtensionContext) {
155150
);
156151
}
157152

158-
// TODO: Reimplement continuous analysis. Requires cppcheck update (expected in 2.20)
159-
async function handleDocumentContinuous(e: vscode.TextDocumentChangeEvent) {
160-
const document : vscode.TextDocument = e.document;
161-
const uriKey = document.uri.toString();
162-
163-
// clear any existing timer for this document
164-
if (debounceTimers.has(uriKey)) {
165-
clearTimeout(debounceTimers.get(uriKey)!);
166-
}
167-
168-
// schedule a new run
169-
const timer = setTimeout(async () => {
170-
debounceTimers.delete(uriKey);
171-
await handleDocument(document);
172-
}, DEBOUNCE_MS);
173-
debounceTimers.set(uriKey, timer);
174-
}
175-
176-
// Run cppcheck when document is changed, with debounce
177-
// vscode.workspace.onDidChangeTextDocument(handleDocumentContinuous, null, context.subscriptions);
178-
179153
// Listen for file saves.
180154
vscode.workspace.onDidSaveTextDocument(handleDocument, null, context.subscriptions);
181155

0 commit comments

Comments
 (0)