|
14 | 14 | import com.github.packageurl.MalformedPackageURLException; |
15 | 15 | import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; |
16 | 16 | import com.intellij.codeInsight.daemon.HighlightDisplayKey; |
| 17 | +import com.intellij.codeHighlighting.HighlightDisplayLevel; |
17 | 18 | import com.intellij.codeInspection.InspectionProfileEntry; |
18 | 19 | import com.intellij.lang.annotation.AnnotationHolder; |
19 | 20 | import com.intellij.lang.annotation.ExternalAnnotator; |
@@ -234,6 +235,25 @@ static String getRecommendation(AnalysisReport report, ImageRef imageRef) { |
234 | 235 | .orElse(null); |
235 | 236 | } |
236 | 237 |
|
| 238 | + @NotNull |
| 239 | + private static HighlightSeverity getHighlightSeverity(AnalysisReport report, String recommendation, boolean hasIssue, @NotNull PsiElement context) { |
| 240 | + // Get the configured severity from the inspection settings |
| 241 | + final InspectionProfileEntry inspection = getInspection(context); |
| 242 | + if (inspection != null) { |
| 243 | + final var profile = InspectionProjectProfileManager.getInstance(context.getProject()).getCurrentProfile(); |
| 244 | + final HighlightDisplayKey key = HighlightDisplayKey.find(DockerfileInspection.SHORT_NAME); |
| 245 | + if (key != null) { |
| 246 | + HighlightDisplayLevel level = profile.getErrorLevel(key, context); |
| 247 | + return level.getSeverity(); |
| 248 | + } |
| 249 | + } |
| 250 | + |
| 251 | + // Fallback to original logic if inspection settings can't be determined |
| 252 | + return hasIssue || recommendation == null ? |
| 253 | + HighlightSeverity.ERROR : |
| 254 | + HighlightSeverity.WEAK_WARNING; |
| 255 | + } |
| 256 | + |
237 | 257 | @Override |
238 | 258 | public @Nullable Info collectInformation(@NotNull PsiFile file) { |
239 | 259 | // Only process our custom Dockerfile type |
@@ -318,11 +338,8 @@ public void apply(@NotNull PsiFile file, Map<BaseImage, Result> annotationResult |
318 | 338 | var message = generateMessage(key.getImageName(), report, recommendation); |
319 | 339 | var tooltip = generateTooltip(key.getImageName(), report, recommendation); |
320 | 340 |
|
321 | | - var severity = hasIssue || recommendation == null ? |
322 | | - HighlightSeverity.ERROR : |
323 | | - HighlightSeverity.WEAK_WARNING; |
324 | | - |
325 | 341 | elements.forEach(e -> { |
| 342 | + var severity = getHighlightSeverity(report, recommendation, hasIssue, e); |
326 | 343 | if (e != null) { |
327 | 344 | var builder = holder |
328 | 345 | .newAnnotation(severity, message) |
|
0 commit comments