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, 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