Skip to content

Commit 34ac59a

Browse files
committed
fix: allow Inline Vulnerability Severity Alerts level change.
Signed-off-by: Chao Wang <[email protected]>
1 parent 51e3b0b commit 34ac59a

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

src/main/java/org/jboss/tools/intellij/componentanalysis/CAAnnotator.java

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.github.packageurl.PackageURL;
1515
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
1616
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
17+
import com.intellij.codeHighlighting.HighlightDisplayLevel;
1718
import com.intellij.codeInspection.InspectionProfile;
1819
import com.intellij.codeInspection.InspectionProfileEntry;
1920
import com.intellij.lang.annotation.AnnotationBuilder;
@@ -165,7 +166,7 @@ public void apply(@NotNull PsiFile file, Map<Dependency, Result> annotationResul
165166
if (!quickfixes.isEmpty() && this.isQuickFixApplicable(e)) {
166167
quickfixes.forEach((source, report) ->{
167168
AnnotationBuilder builder = holder
168-
.newAnnotation(getHighlightSeverity(report), messageBuilder.toString())
169+
.newAnnotation(getHighlightSeverity(report, e), messageBuilder.toString())
169170
.tooltip(tooltipBuilder.toString())
170171
.range(e);
171172
if(CAIntentionAction.isQuickFixAvailable(report)) {
@@ -189,16 +190,24 @@ public void apply(@NotNull PsiFile file, Map<Dependency, Result> annotationResul
189190
}
190191

191192
@NotNull
192-
private static HighlightSeverity getHighlightSeverity(DependencyReport report) {
193-
if(CAIntentionAction.thereAreNoIssues(report) && CAIntentionAction.thereIsRecommendation(report))
194-
{
195-
return HighlightSeverity.WEAK_WARNING;
193+
private HighlightSeverity getHighlightSeverity(DependencyReport report, @NotNull PsiElement context) {
194+
// Get the configured severity from the inspection settings
195+
final InspectionProfileEntry inspection = this.getInspection(context, this.getInspectionShortName());
196+
if (inspection != null) {
197+
final InspectionProfile profile = InspectionProjectProfileManager.getInstance(context.getProject()).getCurrentProfile();
198+
final HighlightDisplayKey key = HighlightDisplayKey.find(this.getInspectionShortName());
199+
if (key != null) {
200+
HighlightDisplayLevel level = profile.getErrorLevel(key, context);
201+
return level.getSeverity();
202+
}
196203
}
197-
else
198-
{
204+
205+
// Fallback to original logic if inspection settings can't be determined
206+
if(CAIntentionAction.thereAreNoIssues(report) && CAIntentionAction.thereIsRecommendation(report)) {
207+
return HighlightSeverity.WEAK_WARNING;
208+
} else {
199209
return HighlightSeverity.ERROR;
200210
}
201-
202211
}
203212

204213
abstract protected String getInspectionShortName();

0 commit comments

Comments
 (0)