Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: trusted content support enhancements and fixes #232

Merged
merged 2 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/codeActionHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
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 };