Skip to content

Commit

Permalink
fix: duplicate recommendations
Browse files Browse the repository at this point in the history
Signed-off-by: Ilona Shishov <[email protected]>
  • Loading branch information
IlonaShishov committed Dec 18, 2023
1 parent f27471d commit 2bba5ee
Showing 1 changed file with 18 additions and 33 deletions.
51 changes: 18 additions & 33 deletions src/diagnosticsHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,42 +124,27 @@ class DiagnosticsPipeline implements IDiagnosticsPipeline {
* @returns A Promise that resolves when diagnostics are completed.
*/
async function performDiagnostics(diagnosticFilePath: string, contents: string, provider: IDependencyProvider) {

// collect dependencies from manifest file
let dependencies = null;
dependencies = await provider.collect(contents)
.catch(error => {
connection.console.warn(`Component Analysis Error: ${error}`);
connection.sendNotification('caError', {
errorMessage: error.message,
uri: diagnosticFilePath,
});
return;
});
const dependencyMap = new DependencyMap(dependencies);
try {
const dependencies = await provider.collect(contents);
const dependencyMap = new DependencyMap(dependencies);

const diagnosticsPipeline = new DiagnosticsPipeline(provider, dependencyMap, diagnosticFilePath);

clearCodeActionsMap();

diagnosticsPipeline.clearDiagnostics();

const analysis = executeComponentAnalysis(diagnosticFilePath, contents)
.then(response => {
diagnosticsPipeline.runDiagnostics(response.dependencies);
})
.catch(error => {
connection.console.warn(`Component Analysis Error: ${error}`);
connection.sendNotification('caError', {
errorMessage: error.message,
uri: diagnosticFilePath,
});
return;
});
const diagnosticsPipeline = new DiagnosticsPipeline(provider, dependencyMap, diagnosticFilePath);
diagnosticsPipeline.clearDiagnostics();

await analysis;
const response = await executeComponentAnalysis(diagnosticFilePath, contents);

diagnosticsPipeline.reportDiagnostics();
clearCodeActionsMap();

diagnosticsPipeline.runDiagnostics(response.dependencies);

diagnosticsPipeline.reportDiagnostics();
} catch (error) {
connection.console.warn(`Component Analysis Error: ${error}`);
connection.sendNotification('caError', {
errorMessage: error.message,
uri: diagnosticFilePath,
});
}
}

export { performDiagnostics };

0 comments on commit 2bba5ee

Please sign in to comment.