diff --git a/platform/lang-impl/src/com/intellij/codeInsight/navigation/CtrlMouseHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/navigation/CtrlMouseHandler.java index 1117578d6fcb..f66fb88a1cea 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/CtrlMouseHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/CtrlMouseHandler.java @@ -897,8 +897,7 @@ public class CtrlMouseHandler extends AbstractProjectComponent { List highlighters = new ArrayList(); TextAttributes attributes = myEditorColorsManager.getGlobalScheme().getAttributes(EditorColors.REFERENCE_HYPERLINK_COLOR); for (TextRange range : info.getRanges()) { - TextAttributes attr = patchAttributesColor(attributes, range, editor, getOrInitDebuggerHighlighterKey()); - attr = patchAttributesColor(attributes, range, editor, getOrInitXDebuggerHighlighterKey()); + TextAttributes attr = patchAttributesColor(attributes, range, editor); final RangeHighlighter highlighter = editor.getMarkupModel().addRangeHighlighter(range.getStartOffset(), range.getEndOffset(), HighlighterLayer.SELECTION + 1, attr, @@ -914,14 +913,15 @@ public class CtrlMouseHandler extends AbstractProjectComponent { * Patches attributes to be visible under debugger active line */ @SuppressWarnings("UseJBColor") - private static TextAttributes patchAttributesColor(TextAttributes attributes, TextRange range, Editor editor, Key key) { - if (key != null) { - int line = editor.offsetToLogicalPosition(range.getStartOffset()).line; - for (RangeHighlighter highlighter : editor.getMarkupModel().getAllHighlighters()) { - - Object hasKey = highlighter.getUserData(key); - if (hasKey instanceof Boolean && ((Boolean)hasKey).booleanValue()) { - if (editor.offsetToLogicalPosition(highlighter.getStartOffset()).line == line) { + private static TextAttributes patchAttributesColor(TextAttributes attributes, TextRange range, Editor editor) { + int line = editor.offsetToLogicalPosition(range.getStartOffset()).line; + for (RangeHighlighter highlighter : editor.getMarkupModel().getAllHighlighters()) { + if (highlighter.getTargetArea() == HighlighterTargetArea.LINES_IN_RANGE && + editor.offsetToLogicalPosition(highlighter.getStartOffset()).line == line) { + TextAttributes textAttributes = highlighter.getTextAttributes(); + if (textAttributes != null) { + Color color = textAttributes.getBackgroundColor(); + if (color.getBlue() > 128 && color.getRed() < 128 && color.getGreen() < 128) { TextAttributes clone = attributes.clone(); clone.setForegroundColor(Color.orange); clone.setEffectColor(Color.orange); @@ -933,18 +933,6 @@ public class CtrlMouseHandler extends AbstractProjectComponent { return attributes; } - private static Key getOrInitDebuggerHighlighterKey() { - if (ourDebuggerHighlighterKey == null) { - ourDebuggerHighlighterKey = Key.findKeyByName("HIGHLIGHTER_USERDATA_KEY"); - } - return ourDebuggerHighlighterKey; - } - private static Key getOrInitXDebuggerHighlighterKey() { - if (ourXDebuggerHighlighterKey == null) { - ourXDebuggerHighlighterKey = Key.findKeyByName("EXECUTION_POINT_HIGHLIGHTER_KEY"); - } - return ourXDebuggerHighlighterKey; - } private class HighlightersSet { private final List myHighlighters; diff --git a/platform/util/src/com/intellij/openapi/util/Key.java b/platform/util/src/com/intellij/openapi/util/Key.java index 6c57ac622c0e..949cb3e1ba46 100644 --- a/platform/util/src/com/intellij/openapi/util/Key.java +++ b/platform/util/src/com/intellij/openapi/util/Key.java @@ -34,7 +34,7 @@ import java.util.concurrent.atomic.AtomicInteger; public class Key { private static final AtomicInteger ourKeysCounter = new AtomicInteger(); private final int myIndex = ourKeysCounter.getAndIncrement(); - private final String myName; + private final String myName; // for debug purposes only private static final ConcurrentWeakValueIntObjectHashMap allKeys = new ConcurrentWeakValueIntObjectHashMap(); public Key(@NotNull @NonNls String name) { @@ -102,6 +102,9 @@ public class Key { return (Key)allKeys.get(index); } + /** + * @deprecated access to Key via its name is a kind of hack, use Key instance directly instead + */ @Nullable public static Key findKeyByName(String name) { for (StripedLockIntObjectConcurrentHashMap.IntEntry key : allKeys.entries()) {