[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
This commit is contained in:
Anna Kozlova
2022-05-16 11:37:21 +00:00
committed by intellij-monorepo-bot
parent 159c99ae30
commit bc51c73b75
@@ -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;
}