From 124f82fa6157abf1676f4b7a00e85f1c05e643d3 Mon Sep 17 00:00:00 2001 From: "Alexander.Kirsanov" Date: Fri, 24 Apr 2020 01:23:03 +0300 Subject: [PATCH] One more portion of API migration GitOrigin-RevId: 704c03377a28da2d483ede45438c22c70f681ba5 --- .../src/com/intellij/codeInsight/hints/BlackListPanel.kt | 3 +-- .../codeInsight/template/impl/TemplateState.java | 9 +++------ .../intellij/xdebugger/impl/XDebuggerManagerImpl.java | 9 +++------ .../actions/handlers/XDebuggerSmartStepIntoHandler.java | 4 ++-- .../com/intellij/util/xml/ui/EditorTextFieldControl.java | 9 ++------- 5 files changed, 11 insertions(+), 23 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hints/BlackListPanel.kt b/platform/lang-impl/src/com/intellij/codeInsight/hints/BlackListPanel.kt index 11ec37d0dba7..5f4397ee8b78 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/hints/BlackListPanel.kt +++ b/platform/lang-impl/src/com/intellij/codeInsight/hints/BlackListPanel.kt @@ -145,7 +145,6 @@ private fun createBlacklistEditorField(text: String): EditorTextField { } private fun highlightErrorLines(lines: List, editor: Editor) { - val attributes = editor.colorsScheme.getAttributes(ERRORS_ATTRIBUTES) val document = editor.document val totalLines = document.lineCount @@ -153,7 +152,7 @@ private fun highlightErrorLines(lines: List, editor: Editor) { model.removeAllHighlighters() lines.stream() .filter { current -> current < totalLines } - .forEach { line -> model.addLineHighlighter(line!!, HighlighterLayer.ERROR, attributes) } + .forEach { line -> model.addLineHighlighter(ERRORS_ATTRIBUTES, line!!, HighlighterLayer.ERROR) } } private fun getBlacklistExplanationHTML(language: Language): String { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateState.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateState.java index 507873997d04..3035940e889b 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateState.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateState.java @@ -26,7 +26,7 @@ import com.intellij.openapi.diagnostic.Attachment; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.*; import com.intellij.openapi.editor.colors.EditorColors; -import com.intellij.openapi.editor.colors.EditorColorsManager; +import com.intellij.openapi.editor.colors.TextAttributesKey; import com.intellij.openapi.editor.event.CaretEvent; import com.intellij.openapi.editor.event.CaretListener; import com.intellij.openapi.editor.event.DocumentEvent; @@ -35,7 +35,6 @@ import com.intellij.openapi.editor.ex.DocumentEx; import com.intellij.openapi.editor.markup.HighlighterLayer; import com.intellij.openapi.editor.markup.HighlighterTargetArea; import com.intellij.openapi.editor.markup.RangeHighlighter; -import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.fileEditor.impl.text.AsyncEditorLoader; import com.intellij.openapi.keymap.KeymapUtil; import com.intellij.openapi.project.DumbService; @@ -1218,14 +1217,12 @@ public final class TemplateState implements Disposable { } private RangeHighlighter getSegmentHighlighter(int segmentNumber, boolean isSelected, boolean isEnd) { - final TextAttributes lvAttr = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.LIVE_TEMPLATE_ATTRIBUTES); - TextAttributes attributes = isSelected ? lvAttr : new TextAttributes(); - TextAttributes endAttributes = new TextAttributes(); + TextAttributesKey attributesKey = isSelected && !isEnd ? EditorColors.LIVE_TEMPLATE_ATTRIBUTES : null; int start = mySegments.getSegmentStart(segmentNumber); int end = mySegments.getSegmentEnd(segmentNumber); RangeHighlighter segmentHighlighter = myEditor.getMarkupModel() - .addRangeHighlighter(start, end, HighlighterLayer.LAST + 1, isEnd ? endAttributes : attributes, HighlighterTargetArea.EXACT_RANGE); + .addRangeHighlighter(attributesKey, start, end, HighlighterLayer.LAST + 1, HighlighterTargetArea.EXACT_RANGE); segmentHighlighter.setGreedyToLeft(true); segmentHighlighter.setGreedyToRight(true); return segmentHighlighter; diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java index fa767bcad512..9431b71f7617 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java @@ -27,14 +27,12 @@ import com.intellij.openapi.components.StoragePathMacros; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.EditorFactory; -import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.event.*; import com.intellij.openapi.editor.ex.EditorEx; import com.intellij.openapi.editor.ex.util.EditorUtil; import com.intellij.openapi.editor.impl.EditorImpl; import com.intellij.openapi.editor.markup.GutterIconRenderer; import com.intellij.openapi.editor.markup.RangeHighlighter; -import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.fileEditor.FileDocumentManagerListener; import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.openapi.fileEditor.FileEditorManagerListener; @@ -420,11 +418,10 @@ public class XDebuggerManagerImpl extends XDebuggerManager implements Persistent return; } - TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(DebuggerColors.NOT_TOP_FRAME_ATTRIBUTES); Editor editor = e.getEditor(); - myCurrentHighlighter = editor.getMarkupModel().addLineHighlighter(lineNumber, - DebuggerColors.EXECUTION_LINE_HIGHLIGHTERLAYER, - attributes); + myCurrentHighlighter = editor.getMarkupModel().addLineHighlighter(DebuggerColors.NOT_TOP_FRAME_ATTRIBUTES, + lineNumber, + DebuggerColors.EXECUTION_LINE_HIGHLIGHTERLAYER); HintHint hint = new HintHint(e.getMouseEvent()).setAwtTooltip(true).setPreferredPosition(Balloon.Position.above); String text = UIUtil.removeMnemonic(ActionsBundle.actionText(XDebuggerActions.RUN_TO_CURSOR)); diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/handlers/XDebuggerSmartStepIntoHandler.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/handlers/XDebuggerSmartStepIntoHandler.java index ec49041dcf9e..aadb01382c2d 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/handlers/XDebuggerSmartStepIntoHandler.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/handlers/XDebuggerSmartStepIntoHandler.java @@ -357,11 +357,11 @@ public class XDebuggerSmartStepIntoHandler extends XDebuggerSuspendedActionHandl setCurrentVariantHighlighterAttributes(DebuggerColors.SMART_STEP_INTO_SELECTION); } - private void setCurrentVariantHighlighterAttributes(TextAttributesKey attributes) { + private void setCurrentVariantHighlighterAttributes(TextAttributesKey attributesKey) { int index = myVariants.indexOf(myCurrentVariant); if (index != -1) { ((RangeHighlighterEx)myHighlighters.get(index)) - .setTextAttributes(EditorColorsManager.getInstance().getGlobalScheme().getAttributes(attributes)); + .setTextAttributesKey(attributesKey); } } diff --git a/xml/dom-impl/src/com/intellij/util/xml/ui/EditorTextFieldControl.java b/xml/dom-impl/src/com/intellij/util/xml/ui/EditorTextFieldControl.java index 40b1eeca57c8..742a391f4201 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/ui/EditorTextFieldControl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/ui/EditorTextFieldControl.java @@ -7,15 +7,13 @@ import com.intellij.openapi.application.WriteAction; import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.editor.colors.CodeInsightColors; import com.intellij.openapi.editor.event.DocumentEvent; import com.intellij.openapi.editor.event.DocumentListener; -import com.intellij.openapi.editor.markup.EffectType; import com.intellij.openapi.editor.markup.MarkupModel; -import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.project.Project; import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.ui.EditorTextField; -import com.intellij.ui.SimpleTextAttributes; import com.intellij.util.xml.DomElement; import com.intellij.util.xml.highlighting.DomElementAnnotationsManager; import com.intellij.util.xml.highlighting.DomElementProblemDescriptor; @@ -145,10 +143,7 @@ public abstract class EditorTextFieldControl extends BaseM final MarkupModel markupModel = editor.getMarkupModel(); markupModel.removeAllHighlighters(); if (!errorProblems.isEmpty() && editor.getDocument().getLineCount() > 0) { - final TextAttributes attributes = SimpleTextAttributes.ERROR_ATTRIBUTES.toTextAttributes(); - attributes.setEffectType(EffectType.WAVE_UNDERSCORE); - attributes.setEffectColor(attributes.getForegroundColor()); - markupModel.addLineHighlighter(0, 0, attributes); + markupModel.addLineHighlighter(CodeInsightColors.ERRORS_ATTRIBUTES, 0, 0); editor.getContentComponent().setToolTipText(errorProblems.get(0).getDescriptionTemplate()); } }