From cb8997261e89b5a2eb63ec69f614d1f4a3bd8cc8 Mon Sep 17 00:00:00 2001 From: Rustam Vishnyakov Date: Tue, 15 Jan 2013 15:47:41 +0400 Subject: [PATCH] Tests fix --- .../codeInsight/daemon/impl/HighlightInfo.java | 11 +++++++---- .../editor/colors/impl/AbstractColorsScheme.java | 11 +++++++++++ .../editor/colors/impl/DefaultColorsScheme.java | 10 +++++++++- .../editor/colors/impl/EditorColorsSchemeImpl.java | 10 ---------- 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java index 8e8953a402d1..3eb01c1477f3 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java @@ -140,10 +140,13 @@ public class HighlightInfo implements Segment { return null; } if (forcedTextAttributesKey != null) { - final Color errorStripeColor = scheme.getAttributes(forcedTextAttributesKey).getErrorStripeColor(); - // let's copy above behaviour of forcedTextAttributes stripe color, but I'm not sure that the behaviour is correct in general - if (errorStripeColor != null) { - return errorStripeColor; + TextAttributes forcedTextAttributes = scheme.getAttributes(forcedTextAttributesKey); + if (forcedTextAttributes != null) { + final Color errorStripeColor = forcedTextAttributes.getErrorStripeColor(); + // let's copy above behaviour of forcedTextAttributes stripe color, but I'm not sure that the behaviour is correct in general + if (errorStripeColor != null) { + return errorStripeColor; + } } } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java index 913e02f738d4..261f072e13d9 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java @@ -558,4 +558,15 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme { return "Monospaced"; } + protected TextAttributes getFallbackAttributes(TextAttributesKey fallbackKey) { + if (fallbackKey == null) return null; + if (myAttributesMap.containsKey(fallbackKey)) { + TextAttributes fallbackAttributes = myAttributesMap.get(fallbackKey); + if (fallbackAttributes != null && (!fallbackAttributes.isEmpty() || fallbackKey.getFallbackAttributeKey() == null)) { + return fallbackAttributes; + } + } + return getFallbackAttributes(fallbackKey.getFallbackAttributeKey()); + } + } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/DefaultColorsScheme.java b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/DefaultColorsScheme.java index 720ea714a256..e2f8d3bb30f7 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/DefaultColorsScheme.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/DefaultColorsScheme.java @@ -26,6 +26,7 @@ import com.intellij.openapi.editor.colors.ex.DefaultColorSchemesManager; import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.util.InvalidDataException; import org.jdom.Element; +import org.jetbrains.annotations.Nullable; import java.awt.*; @@ -37,10 +38,17 @@ public class DefaultColorsScheme extends AbstractColorsScheme implements ReadOnl } @Override + @Nullable public TextAttributes getAttributes(TextAttributesKey key) { if (key == null) return null; TextAttributes attrs = myAttributesMap.get(key); - return attrs != null ? attrs : key.getDefaultAttributes(); + if (attrs == null) { + attrs = getFallbackAttributes(key.getFallbackAttributeKey()); + if (attrs == null) { + attrs = key.getDefaultAttributes(); + } + } + return attrs; } @Override diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImpl.java index c9f0f00d9a4b..9d9c86981004 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImpl.java @@ -68,16 +68,6 @@ public class EditorColorsSchemeImpl extends AbstractColorsScheme implements Exte return myParentScheme.getAttributes(key); } - private TextAttributes getFallbackAttributes(TextAttributesKey fallbackKey) { - if (fallbackKey == null) return null; - if (myAttributesMap.containsKey(fallbackKey)) { - TextAttributes fallbackAttributes = myAttributesMap.get(fallbackKey); - if (fallbackAttributes != null && (!fallbackAttributes.isEmpty() || fallbackKey.getFallbackAttributeKey() == null)) { - return fallbackAttributes; - } - } - return getFallbackAttributes(fallbackKey.getFallbackAttributeKey()); - } public boolean containsKey(TextAttributesKey key) { return myAttributesMap.containsKey(key);