From bc51c73b75099dffded87cf84dab5c2d11578263 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Mon, 16 May 2022 12:05:24 +0200 Subject: [PATCH] [highlighting] setup layers for custom highlightings (to resolve text attributes conflicts when any) otherwise conflict between custom severities attributes in `IterationState.LayerComparator.INSTANCE` would not work and if both attributes have foreground, unpredictable one would be used e.g. class name attributes may win over "strong severity" warning GitOrigin-RevId: 40fa8af66e2262c632b0f24eba8d24e05a347fe5 --- .../daemon/impl/UpdateHighlightersUtil.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java index c2e94e1aa686..125f4299858e 100644 --- a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java @@ -1,4 +1,4 @@ -// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.codeInsight.daemon.impl; import com.intellij.codeHighlighting.Pass; @@ -475,15 +475,15 @@ public final class UpdateHighlightersUtil { private static int getLayer(@NotNull HighlightInfo info, @NotNull SeverityRegistrar severityRegistrar) { HighlightSeverity severity = info.getSeverity(); int layer; - if (severity == HighlightSeverity.WARNING) { + if (severityRegistrar.compare(severity, HighlightSeverity.ERROR) >= 0) { + layer = HighlighterLayer.ERROR; + } + else if (severityRegistrar.compare(severity, HighlightSeverity.WARNING) >= 0) { layer = HighlighterLayer.WARNING; } - else if (severity == HighlightSeverity.WEAK_WARNING) { + else if (severityRegistrar.compare(severity, HighlightSeverity.WEAK_WARNING) >= 0) { layer = HighlighterLayer.WEAK_WARNING; } - else if (severityRegistrar.compare(severity, HighlightSeverity.ERROR) >= 0) { - layer = HighlighterLayer.ERROR; - } else if (severity == HighlightInfoType.INJECTED_FRAGMENT_SEVERITY || severity == HighlightInfoType.HIGHLIGHTED_REFERENCE_SEVERITY) { layer = HighlighterLayer.CARET_ROW - 1; }