Skip to content

Commit

Permalink
fix: Clear diagnostics before generating new set of diagnostics (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
arajkumar authored Dec 21, 2020
1 parent e34e974 commit 9c13996
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,21 +251,19 @@ function slicePayload(payload, batchSize, ecosystem): any {

const regexVersion = new RegExp(/^([a-zA-Z0-9]+\.)?([a-zA-Z0-9]+\.)?([a-zA-Z0-9]+\.)?([a-zA-Z0-9]+)$/);
const sendDiagnostics = async (ecosystem: string, diagnosticFilePath: string, contents: string, collector: IDependencyCollector) => {
// clear all diagnostics
connection.sendDiagnostics({ uri: diagnosticFilePath, diagnostics: [] });
connection.sendNotification('caNotification', {data: caDefaultMsg, done: false, uri: diagnosticFilePath});
let deps = null;
try {
const start = new Date().getTime();
deps = await collector.collect(contents);
const end = new Date().getTime();
connection.console.log(`manifest parse took ${end - start} ms`);
connection.console.log(`manifest parse took ${end - start} ms, found ${deps.length} deps`);
} catch (error) {
// Error can be raised during golang `go list ` command only.
if (ecosystem == "golang") {
connection.console.warn(`Command execution failed with error: ${error}`);
connection.sendNotification('caError', {data: error, uri: diagnosticFilePath});
connection.sendDiagnostics({ uri: diagnosticFilePath, diagnostics: [] });
return;
}
connection.console.warn(`Error: ${error}`);
connection.sendNotification('caError', {data: error, uri: diagnosticFilePath});
return;
}

let validPackages = deps;
Expand Down

0 comments on commit 9c13996

Please sign in to comment.