From f27471d34ea9ce3de175d6109581940a4d68fa88 Mon Sep 17 00:00:00 2001 From: Ilona Shishov Date: Mon, 18 Dec 2023 11:39:46 +0200 Subject: [PATCH 1/2] chore: recommend Red Hat GA repository on recommendation and remediation Signed-off-by: Ilona Shishov --- src/codeActionHandler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/codeActionHandler.ts b/src/codeActionHandler.ts index a91c9478..88545c6f 100644 --- a/src/codeActionHandler.ts +++ b/src/codeActionHandler.ts @@ -101,7 +101,7 @@ function generateSwitchToRecommendedVersionAction(title: string, versionReplacem newText: versionReplacementString }]; - if (diagnostic.severity !== 1 && path.basename(uri) === 'pom.xml') { + if (path.basename(uri) === 'pom.xml') { codeAction.command = { title: 'RedHat repository recommendation', command: globalConfig.triggerRHRepositoryRecommendationNotification, From 2bba5ee0daf1355334b6e1945f610f6a98cedcc5 Mon Sep 17 00:00:00 2001 From: Ilona Shishov Date: Mon, 18 Dec 2023 13:16:48 +0200 Subject: [PATCH 2/2] fix: duplicate recommendations Signed-off-by: Ilona Shishov --- src/diagnosticsHandler.ts | 51 ++++++++++++++------------------------- 1 file changed, 18 insertions(+), 33 deletions(-) diff --git a/src/diagnosticsHandler.ts b/src/diagnosticsHandler.ts index 515bbb87..98ba4fe7 100644 --- a/src/diagnosticsHandler.ts +++ b/src/diagnosticsHandler.ts @@ -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 }; \ No newline at end of file