From 9e845508b11e2d8f7436bfa3472fb3d9528d1478 Mon Sep 17 00:00:00 2001 From: "Alexander.Kirsanov" Date: Thu, 23 Apr 2020 23:44:10 +0300 Subject: [PATCH] Remove methods for adding highlighters with both attributes and attributesKey. Migrate platform and feature usages to use either attributes or attributesKey GitOrigin-RevId: fba6df6b5a9c8de805a8137fc4dbd031cf2e080b --- .../daemon/impl/JavaTextBlockIndentPass.java | 2 +- .../IntroduceParameterHandler.java | 3 +- .../daemon/impl/UpdateHighlightersUtil.java | 2 +- .../UnifiedEditorRangeHighlighter.java | 4 +- .../com/intellij/diff/util/DiffDrawUtil.java | 4 +- .../diff/util/DiffGutterOperation.java | 3 +- .../vcs/ex/LineStatusMarkerRenderer.java | 4 +- .../openapi/editor/markup/MarkupModel.java | 34 ++++--------- .../editor/markup/RangeHighlighter.java | 4 +- .../injected/editor/MarkupModelWindow.java | 33 ++++++------ .../openapi/editor/ex/MarkupModelEx.java | 50 +++++++++++++++---- .../openapi/editor/impl/EmptyMarkupModel.java | 20 +++----- .../openapi/editor/impl/MarkupModelImpl.java | 30 ++++------- .../impl/PersistentRangeHighlighterImpl.java | 7 +-- .../editor/impl/RangeHighlighterImpl.java | 2 - .../options/CodeStyleAbstractPanel.java | 2 +- .../codeInsight/daemon/impl/IndentsPass.java | 4 +- .../daemon/impl/LineMarkersUtil.java | 4 +- .../documentation/render/DocRenderItem.java | 3 +- .../BraceHighlightingHandler.java | 6 +-- .../highlighting/HighlightManagerImpl.java | 48 ++++++++++-------- .../navigation/IncrementalSearchHandler.java | 4 +- .../codeInsight/unwrap/ScopeHighlighter.java | 4 +- .../console/LanguageConsoleBuilder.java | 4 +- .../console/LanguageConsoleImpl.java | 4 +- .../execution/impl/ConsoleViewImpl.java | 16 ++++-- .../src/com/intellij/find/FindUtil.java | 3 +- .../com/intellij/ide/bookmarks/Bookmark.java | 7 ++- .../inplace/InplaceChangeSignature.java | 8 +-- .../introduce/inplace/OccurrencesChooser.java | 3 +- .../rename/inplace/RenameChooser.java | 6 +-- .../suggested/PerformSuggestedRefactoring.kt | 2 +- .../colors/highlighting/HighlightData.java | 13 +++-- .../impl/EditorHyperlinkSupport.java | 18 ++++--- .../ide/actions/RecentLocationsRenderer.java | 12 +++-- .../ide/impl/SelectInEditorManagerImpl.java | 8 +-- .../notification/EventLogConsole.java | 2 +- .../ShowEditorHighlighterTokensAction.java | 5 +- .../impl/EditorFilteringMarkupModelEx.java | 27 ++++------ .../editor/impl/DocumentMarkupModelTest.java | 2 +- .../openapi/editor/impl/EditorImplTest.java | 4 +- .../editor/impl/MarkupModelStressTest.java | 4 +- .../openapi/editor/impl/RangeMarkerTest.java | 16 +++--- .../replace/ui/ReplacementPreviewDialog.java | 3 +- .../usages/impl/UsagePreviewPanel.java | 8 +-- .../changes/patch/tool/ApplyPatchChange.java | 4 +- .../xdebugger/impl/XDebuggerUtilImpl.java | 4 +- .../impl/breakpoints/XLineBreakpointImpl.java | 18 ++++--- .../impl/ui/ExecutionPointHighlighter.java | 6 +-- .../modifiers/ChangeModifierIntention.java | 4 +- .../intellij/coverage/SrcFileAnnotator.java | 2 +- .../TestDataHighlightingPass.java | 1 - .../GHPREditorCommentableRangesController.kt | 2 +- .../ui/MethodOrClosureScopeChooser.java | 4 +- .../XmlTagTreeHighlightingPass.java | 2 +- 55 files changed, 252 insertions(+), 247 deletions(-) diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/JavaTextBlockIndentPass.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/JavaTextBlockIndentPass.java index 9ed01397e40e..0fb4f35ffda9 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/JavaTextBlockIndentPass.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/JavaTextBlockIndentPass.java @@ -81,7 +81,7 @@ public class JavaTextBlockIndentPass extends TextEditorHighlightingPass { } else { RangeHighlighter newHighlighter = - model.addRangeHighlighter(indent.startOffset, indent.endOffset, 0, null, null, HighlighterTargetArea.EXACT_RANGE); + model.addRangeHighlighter(null, indent.startOffset, indent.endOffset, 0, HighlighterTargetArea.EXACT_RANGE); newHighlighter.setCustomRenderer(RENDERER); StringContentIndentUtil.setIndent(newHighlighter, newIndent); newHighlighters.add(newHighlighter); diff --git a/java/java-impl/src/com/intellij/refactoring/introduceParameter/IntroduceParameterHandler.java b/java/java-impl/src/com/intellij/refactoring/introduceParameter/IntroduceParameterHandler.java index ffb0b20b8c0a..b893556c68b7 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceParameter/IntroduceParameterHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceParameter/IntroduceParameterHandler.java @@ -265,8 +265,7 @@ public class IntroduceParameterHandler extends IntroduceHandlerBase { if (nameIdentifier != null) { final TextRange textRange = nameIdentifier.getTextRange(); final RangeHighlighter rangeHighlighter = markupModel.addRangeHighlighter( - textRange.getStartOffset(), textRange.getEndOffset(), HighlighterLayer.SELECTION - 1, - null, attributesKey, + attributesKey, textRange.getStartOffset(), textRange.getEndOffset(), HighlighterLayer.SELECTION - 1, HighlighterTargetArea.EXACT_RANGE); highlighters.add(rangeHighlighter); } 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 b41abec2eac7..2c1c7e1b4293 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 @@ -418,7 +418,7 @@ public class UpdateHighlightersUtil { }; if (highlighter == null) { - highlighter = markup.addRangeHighlighterAndChangeAttributes(infoStartOffset, infoEndOffset, layer, null, null, + highlighter = markup.addRangeHighlighterAndChangeAttributes(null, infoStartOffset, infoEndOffset, layer, HighlighterTargetArea.EXACT_RANGE, false, changeAttributes); if (HighlightInfoType.VISIBLE_IF_FOLDED.contains(info.type)) { highlighter.setVisibleIfFolded(true); diff --git a/platform/diff-impl/src/com/intellij/diff/tools/fragmented/UnifiedEditorRangeHighlighter.java b/platform/diff-impl/src/com/intellij/diff/tools/fragmented/UnifiedEditorRangeHighlighter.java index 7e79f8657dda..37ad065a6d29 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/fragmented/UnifiedEditorRangeHighlighter.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/fragmented/UnifiedEditorRangeHighlighter.java @@ -89,8 +89,8 @@ class UnifiedEditorRangeHighlighter { if (!delegate.isValid()) continue; model.addRangeHighlighterAndChangeAttributes( - piece.getStart(), piece.getEnd(), delegate.getLayer(), delegate.getForcedTextAttributes(), - delegate.getTextAttributesKey(), delegate.getTargetArea(), false, ex -> { + delegate.getTextAttributesKey(), piece.getStart(), piece.getEnd(), delegate.getLayer(), + delegate.getTargetArea(), false, ex -> { ex.copyFrom(delegate); }); } diff --git a/platform/diff-impl/src/com/intellij/diff/util/DiffDrawUtil.java b/platform/diff-impl/src/com/intellij/diff/util/DiffDrawUtil.java index 85daae5781dc..8d9c70c32b95 100644 --- a/platform/diff-impl/src/com/intellij/diff/util/DiffDrawUtil.java +++ b/platform/diff-impl/src/com/intellij/diff/util/DiffDrawUtil.java @@ -451,7 +451,7 @@ public class DiffDrawUtil { @NotNull BooleanGetter condition, @Nullable Computable description) { RangeHighlighter marker = editor.getMarkupModel() - .addRangeHighlighter(offset1, offset2, LINE_MARKER_LAYER, null, null, HighlighterTargetArea.LINES_IN_RANGE); + .addRangeHighlighter(null, offset1, offset2, LINE_MARKER_LAYER, HighlighterTargetArea.LINES_IN_RANGE); DiffLineSeparatorRenderer renderer = new DiffLineSeparatorRenderer(editor, condition, description); marker.setLineSeparatorPlacement(SeparatorPlacement.TOP); @@ -641,7 +641,7 @@ public class DiffDrawUtil { offset = DocumentUtil.getFirstNonSpaceCharOffset(editor.getDocument(), line); highlighter = editor.getMarkupModel() - .addRangeHighlighter(offset, offset, LINE_MARKER_LAYER, null, null, HighlighterTargetArea.LINES_IN_RANGE); + .addRangeHighlighter(null, offset, offset, LINE_MARKER_LAYER, HighlighterTargetArea.LINES_IN_RANGE); } @NotNull diff --git a/platform/diff-impl/src/com/intellij/diff/util/DiffGutterOperation.java b/platform/diff-impl/src/com/intellij/diff/util/DiffGutterOperation.java index 899cf407b4ad..1bf311c29658 100644 --- a/platform/diff-impl/src/com/intellij/diff/util/DiffGutterOperation.java +++ b/platform/diff-impl/src/com/intellij/diff/util/DiffGutterOperation.java @@ -15,9 +15,8 @@ public abstract class DiffGutterOperation { @NotNull private final RangeHighlighter myHighlighter; public DiffGutterOperation(@NotNull Editor editor, int offset) { - myHighlighter = editor.getMarkupModel().addRangeHighlighter(offset, offset, + myHighlighter = editor.getMarkupModel().addRangeHighlighter(null, offset, offset, HighlighterLayer.ADDITIONAL_SYNTAX, - null, null, HighlighterTargetArea.LINES_IN_RANGE); } diff --git a/platform/diff-impl/src/com/intellij/openapi/vcs/ex/LineStatusMarkerRenderer.java b/platform/diff-impl/src/com/intellij/openapi/vcs/ex/LineStatusMarkerRenderer.java index 6a1290b9037f..c666ce58e09d 100644 --- a/platform/diff-impl/src/com/intellij/openapi/vcs/ex/LineStatusMarkerRenderer.java +++ b/platform/diff-impl/src/com/intellij/openapi/vcs/ex/LineStatusMarkerRenderer.java @@ -58,8 +58,8 @@ public abstract class LineStatusMarkerRenderer { Document document = myTracker.getDocument(); MarkupModel markupModel = DocumentMarkupModel.forDocument(document, myTracker.getProject(), true); - myHighlighter = markupModel.addRangeHighlighter(0, document.getTextLength(), DiffDrawUtil.LST_LINE_MARKER_LAYER, - null, null, HighlighterTargetArea.LINES_IN_RANGE); + myHighlighter = markupModel.addRangeHighlighter(null, 0, document.getTextLength(), DiffDrawUtil.LST_LINE_MARKER_LAYER, + HighlighterTargetArea.LINES_IN_RANGE); myHighlighter.setGreedyToLeft(true); myHighlighter.setGreedyToRight(true); diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/MarkupModel.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/MarkupModel.java index 430bc73aa135..876756e8a4a8 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/MarkupModel.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/MarkupModel.java @@ -29,26 +29,22 @@ public interface MarkupModel extends UserDataHolder { * {@link com.intellij.openapi.editor.RangeMarker} instances and use the same rules for tracking * the range after document changes. * + * @param textAttributesKey the key to use for highlighting with the current color scheme, + * or {@code null} if it doesn't modify the text attributes. * @param startOffset the start offset of the range to highlight. * @param endOffset the end offset of the range to highlight. * @param layer relative priority of the highlighter (highlighters with higher * layer number override highlighters with lower layer number; * layer number values for standard IDE highlighters are defined in * {@link HighlighterLayer}) - * @param forcedTextAttributes forced attributes to use for highlighting, - * or {@code null} if the textAttributeKey should be used, - * or it doesn't modify the text attributes. - * @param textAttributesKey the key to use for highlighting with the current color scheme, - * or {@code null} if it doesn't modify the text attributes. * @param targetArea type of highlighting (specific range or all full lines covered by the range). * @return the highlighter instance. */ @NotNull - RangeHighlighter addRangeHighlighter(int startOffset, + RangeHighlighter addRangeHighlighter(@Nullable TextAttributesKey textAttributesKey, + int startOffset, int endOffset, int layer, - @Nullable TextAttributes forcedTextAttributes, - @Nullable TextAttributesKey textAttributesKey, @NotNull HighlighterTargetArea targetArea); /** @@ -56,43 +52,33 @@ public interface MarkupModel extends UserDataHolder { */ @Deprecated @NotNull - default RangeHighlighter addRangeHighlighter(int startOffset, + RangeHighlighter addRangeHighlighter(int startOffset, int endOffset, int layer, @Nullable TextAttributes textAttributes, - @NotNull HighlighterTargetArea targetArea) { - return addRangeHighlighter(startOffset, endOffset, layer, textAttributes, null, targetArea); - } + @NotNull HighlighterTargetArea targetArea); /** * Adds a highlighter covering the specified line in the document. * + * @param textAttributesKey the key to use for highlighting with the current color scheme, + * or {@code null} if it doesn't modify the text attributes. * @param line the line number of the line to highlight. * @param layer relative priority of the highlighter (highlighters with higher * layer number override highlighters with lower layer number; * layer number values for standard IDE highlighters are defined in * {@link HighlighterLayer}) - * @param forcedTextAttributes forced attributes to use for highlighting, - * or {@code null} if the textAttributeKey should be used, - * or it doesn't modify the text attributes. - * @param textAttributesKey the key to use for highlighting with the current color scheme, - * or {@code null} if it doesn't modify the text attributes. * @return the highlighter instance. */ @NotNull - RangeHighlighter addLineHighlighter(int line, - int layer, - @Nullable TextAttributes forcedTextAttributes, - @Nullable TextAttributesKey textAttributesKey); + RangeHighlighter addLineHighlighter(@Nullable TextAttributesKey textAttributesKey, int line, int layer); /** * @deprecated Use the overload with TextAttributeKey */ @Deprecated @NotNull - default RangeHighlighter addLineHighlighter(int line, int layer, @Nullable TextAttributes textAttributes) { - return addLineHighlighter(line, layer, textAttributes, null); - } + RangeHighlighter addLineHighlighter(int line, int layer, @Nullable TextAttributes textAttributes); /** * Removes the specified highlighter instance. diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/RangeHighlighter.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/RangeHighlighter.java index 44560e22e139..b806c2aa9cdc 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/RangeHighlighter.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/RangeHighlighter.java @@ -14,8 +14,8 @@ import java.awt.*; * Represents a range of text in the document which has specific markup (special text attributes, * line marker, gutter icon, error stripe marker or line separator). * - * @see MarkupModel#addRangeHighlighter(int, int, int, TextAttributes, TextAttributesKey, HighlighterTargetArea) - * @see MarkupModel#addLineHighlighter(int, int, TextAttributes, TextAttributesKey) + * @see MarkupModel#addRangeHighlighter(TextAttributesKey, int, int, int, HighlighterTargetArea) + * @see MarkupModel#addLineHighlighter(TextAttributesKey, int, int) * @see com.intellij.lang.annotation.Annotation */ public interface RangeHighlighter extends RangeMarker { diff --git a/platform/editor-ui-ex/src/com/intellij/injected/editor/MarkupModelWindow.java b/platform/editor-ui-ex/src/com/intellij/injected/editor/MarkupModelWindow.java index 675589edb1df..511fbaec6bdb 100644 --- a/platform/editor-ui-ex/src/com/intellij/injected/editor/MarkupModelWindow.java +++ b/platform/editor-ui-ex/src/com/intellij/injected/editor/MarkupModelWindow.java @@ -54,30 +54,27 @@ public class MarkupModelWindow extends UserDataHolderBase implements MarkupModel @Override @NotNull - public RangeHighlighter addRangeHighlighter(final int startOffset, + public RangeHighlighter addRangeHighlighter(final @Nullable TextAttributesKey textAttributesKey, + final int startOffset, final int endOffset, final int layer, - final @Nullable TextAttributes forcedTextAttributes, - final @Nullable TextAttributesKey textAttributesKey, @NotNull final HighlighterTargetArea targetArea) { TextRange hostRange = myDocument.injectedToHost(new ProperTextRange(startOffset, endOffset)); return myHostModel.addRangeHighlighter( - hostRange.getStartOffset(), hostRange.getEndOffset(), layer, forcedTextAttributes, textAttributesKey, targetArea); + textAttributesKey, hostRange.getStartOffset(), hostRange.getEndOffset(), layer, targetArea); } @NotNull @Override - public RangeHighlighterEx addRangeHighlighterAndChangeAttributes(int startOffset, + public RangeHighlighterEx addRangeHighlighterAndChangeAttributes(@Nullable TextAttributesKey textAttributesKey, + int startOffset, int endOffset, int layer, - @Nullable TextAttributes forcedTextAttributes, - @Nullable TextAttributesKey textAttributesKey, @NotNull HighlighterTargetArea targetArea, boolean isPersistent, Consumer changeAttributesAction) { TextRange hostRange = myDocument.injectedToHost(new ProperTextRange(startOffset, endOffset)); - return myHostModel.addRangeHighlighterAndChangeAttributes(hostRange.getStartOffset(), hostRange.getEndOffset(), layer, - forcedTextAttributes, textAttributesKey, + return myHostModel.addRangeHighlighterAndChangeAttributes(textAttributesKey, hostRange.getStartOffset(), hostRange.getEndOffset(), layer, targetArea, isPersistent, changeAttributesAction); } @@ -89,12 +86,11 @@ public class MarkupModelWindow extends UserDataHolderBase implements MarkupModel @Override @NotNull - public RangeHighlighter addLineHighlighter(final int line, - final int layer, - final @Nullable TextAttributes forcedTextAttributes, - final @Nullable TextAttributesKey textAttributesKey) { + public RangeHighlighter addLineHighlighter(final @Nullable TextAttributesKey textAttributesKey, + final int line, + final int layer) { int hostLine = myDocument.injectedToHostLine(line); - return myHostModel.addLineHighlighter(hostLine, layer, forcedTextAttributes, textAttributesKey); + return myHostModel.addLineHighlighter(textAttributesKey, hostLine, layer); } @Override @@ -118,12 +114,11 @@ public class MarkupModelWindow extends UserDataHolderBase implements MarkupModel } @Override - public RangeHighlighterEx addPersistentLineHighlighter(final int line, - final int layer, - final @Nullable TextAttributes forcedTextAttributes, - final @Nullable TextAttributesKey textAttributesKey) { + public RangeHighlighterEx addPersistentLineHighlighter(final @Nullable TextAttributesKey textAttributesKey, + final int line, + final int layer) { int hostLine = myDocument.injectedToHostLine(line); - return myHostModel.addPersistentLineHighlighter(hostLine, layer, forcedTextAttributes, textAttributesKey); + return myHostModel.addPersistentLineHighlighter(textAttributesKey, hostLine, layer); } diff --git a/platform/editor-ui-ex/src/com/intellij/openapi/editor/ex/MarkupModelEx.java b/platform/editor-ui-ex/src/com/intellij/openapi/editor/ex/MarkupModelEx.java index 6c7727073b4c..eb63e5407faf 100644 --- a/platform/editor-ui-ex/src/com/intellij/openapi/editor/ex/MarkupModelEx.java +++ b/platform/editor-ui-ex/src/com/intellij/openapi/editor/ex/MarkupModelEx.java @@ -18,10 +18,7 @@ public interface MarkupModelEx extends MarkupModel { @Nullable - RangeHighlighterEx addPersistentLineHighlighter(int lineNumber, - int layer, - @Nullable TextAttributes forcedTextAttributes, - @Nullable TextAttributesKey textAttributesKey); + RangeHighlighterEx addPersistentLineHighlighter(@Nullable TextAttributesKey textAttributesKey, int lineNumber, int layer); /** * @deprecated Use the overload with TextAttributeKey @@ -29,7 +26,11 @@ public interface MarkupModelEx extends MarkupModel { @Deprecated @Nullable default RangeHighlighterEx addPersistentLineHighlighter(int lineNumber, int layer, @Nullable TextAttributes textAttributes) { - return addPersistentLineHighlighter(lineNumber, layer, textAttributes, null); + RangeHighlighterEx highlighter = addPersistentLineHighlighter(null, lineNumber, layer); + if (textAttributes != null && highlighter != null) { + highlighter.setTextAttributes(textAttributes); + } + return highlighter; } void fireAttributesChanged(@NotNull RangeHighlighterEx segmentHighlighter, boolean renderersChanged, boolean fontStyleChanged); @@ -65,11 +66,10 @@ public interface MarkupModelEx extends MarkupModel { // optimization: creates highlighter and fires only one event: highlighterCreated @NotNull - RangeHighlighterEx addRangeHighlighterAndChangeAttributes(int startOffset, + RangeHighlighterEx addRangeHighlighterAndChangeAttributes(@Nullable TextAttributesKey textAttributesKey, + int startOffset, int endOffset, int layer, - @Nullable TextAttributes forcedTextAttributes, - @Nullable TextAttributesKey textAttributesKey, @NotNull HighlighterTargetArea targetArea, boolean isPersistent, Consumer changeAttributesAction); @@ -86,10 +86,40 @@ public interface MarkupModelEx extends MarkupModel { @NotNull HighlighterTargetArea targetArea, boolean isPersistent, Consumer changeAttributesAction) { - return addRangeHighlighterAndChangeAttributes(startOffset, endOffset, layer, textAttributes, null, targetArea, isPersistent, - changeAttributesAction); + return addRangeHighlighterAndChangeAttributes(null, startOffset, endOffset, layer, targetArea, isPersistent, ex -> { + if (textAttributes != null) { + ex.setTextAttributes(textAttributes); + } + changeAttributesAction.consume(ex); + }); } // runs change attributes action and fires highlighterChanged event if there were changes void changeAttributesInBatch(@NotNull RangeHighlighterEx highlighter, @NotNull Consumer changeAttributesAction); + + @Override + @Deprecated + @NotNull + default RangeHighlighter addRangeHighlighter(int startOffset, + int endOffset, + int layer, + @Nullable TextAttributes textAttributes, + @NotNull HighlighterTargetArea targetArea) { + RangeHighlighterEx highlighter = (RangeHighlighterEx)addRangeHighlighter(null, startOffset, endOffset, layer, targetArea); + if (textAttributes != null) { + highlighter.setTextAttributes(textAttributes); + } + return highlighter; + } + + @Override + @Deprecated + @NotNull + default RangeHighlighter addLineHighlighter(int line, int layer, @Nullable TextAttributes textAttributes) { + RangeHighlighterEx highlighter = (RangeHighlighterEx)addLineHighlighter(null, line, layer); + if (textAttributes != null) { + highlighter.setTextAttributes(textAttributes); + } + return highlighter; + } } diff --git a/platform/editor-ui-ex/src/com/intellij/openapi/editor/impl/EmptyMarkupModel.java b/platform/editor-ui-ex/src/com/intellij/openapi/editor/impl/EmptyMarkupModel.java index cf3fca88badf..caa523a0a849 100644 --- a/platform/editor-ui-ex/src/com/intellij/openapi/editor/impl/EmptyMarkupModel.java +++ b/platform/editor-ui-ex/src/com/intellij/openapi/editor/impl/EmptyMarkupModel.java @@ -51,22 +51,20 @@ public class EmptyMarkupModel implements MarkupModelEx { @Override @NotNull - public RangeHighlighter addRangeHighlighter(int startOffset, + public RangeHighlighter addRangeHighlighter(@Nullable TextAttributesKey textAttributesKey, + int startOffset, int endOffset, int layer, - @Nullable TextAttributes forcedTextAttributes, - @Nullable TextAttributesKey textAttributesKey, @NotNull HighlighterTargetArea targetArea) { throw new ProcessCanceledException(); } @NotNull @Override - public RangeHighlighterEx addRangeHighlighterAndChangeAttributes(int startOffset, + public RangeHighlighterEx addRangeHighlighterAndChangeAttributes(@Nullable TextAttributesKey textAttributesKey, + int startOffset, int endOffset, int layer, - TextAttributes forcedTextAttributes, - @Nullable TextAttributesKey textAttributesKey, @NotNull HighlighterTargetArea targetArea, boolean isPersistent, Consumer changeAttributesAction) { @@ -80,10 +78,7 @@ public class EmptyMarkupModel implements MarkupModelEx { @Override @NotNull - public RangeHighlighter addLineHighlighter(int line, - int layer, - @Nullable TextAttributes forcedTextAttributes, - @Nullable TextAttributesKey textAttributesKey) { + public RangeHighlighter addLineHighlighter(@Nullable TextAttributesKey textAttributesKey, int line, int layer) { throw new ProcessCanceledException(); } @@ -114,10 +109,7 @@ public class EmptyMarkupModel implements MarkupModelEx { } @Override - public RangeHighlighterEx addPersistentLineHighlighter(int lineNumber, - int layer, - @Nullable TextAttributes forcedTextAttributes, - @Nullable TextAttributesKey textAttributesKey) { + public RangeHighlighterEx addPersistentLineHighlighter(@Nullable TextAttributesKey textAttributesKey, int lineNumber, int layer) { return null; } diff --git a/platform/editor-ui-ex/src/com/intellij/openapi/editor/impl/MarkupModelImpl.java b/platform/editor-ui-ex/src/com/intellij/openapi/editor/impl/MarkupModelImpl.java index 46bcc0ff4340..c7e5a389c25f 100644 --- a/platform/editor-ui-ex/src/com/intellij/openapi/editor/impl/MarkupModelImpl.java +++ b/platform/editor-ui-ex/src/com/intellij/openapi/editor/impl/MarkupModelImpl.java @@ -62,24 +62,18 @@ public class MarkupModelImpl extends UserDataHolderBase implements MarkupModelEx @Override @NotNull - public RangeHighlighter addLineHighlighter(int lineNumber, - int layer, - @Nullable TextAttributes forcedTextAttributes, - @Nullable TextAttributesKey textAttributesKey) { + public RangeHighlighter addLineHighlighter(@Nullable TextAttributesKey textAttributesKey, int lineNumber, int layer) { if (isNotValidLine(lineNumber)) { throw new IndexOutOfBoundsException("lineNumber:" + lineNumber + ". Must be in [0, " + (getDocument().getLineCount() - 1) + "]"); } int offset = DocumentUtil.getFirstNonSpaceCharOffset(getDocument(), lineNumber); - return addRangeHighlighter(offset, offset, layer, forcedTextAttributes, textAttributesKey, HighlighterTargetArea.LINES_IN_RANGE); + return addRangeHighlighter(textAttributesKey, offset, offset, layer, HighlighterTargetArea.LINES_IN_RANGE); } @Override @Nullable - public RangeHighlighterEx addPersistentLineHighlighter(int lineNumber, - int layer, - @Nullable TextAttributes forcedTextAttributes, - @Nullable TextAttributesKey textAttributesKey) { + public RangeHighlighterEx addPersistentLineHighlighter(@Nullable TextAttributesKey textAttributesKey, int lineNumber, int layer) { if (isNotValidLine(lineNumber)) { return null; } @@ -87,7 +81,7 @@ public class MarkupModelImpl extends UserDataHolderBase implements MarkupModelEx int offset = DocumentUtil.getFirstNonSpaceCharOffset(getDocument(), lineNumber); return addRangeHighlighter( PersistentRangeHighlighterImpl.create( - this, offset, layer, HighlighterTargetArea.LINES_IN_RANGE, forcedTextAttributes, textAttributesKey, false), + this, offset, layer, HighlighterTargetArea.LINES_IN_RANGE, textAttributesKey, false), null); } @@ -113,18 +107,17 @@ public class MarkupModelImpl extends UserDataHolderBase implements MarkupModelEx @NotNull @Override - public RangeHighlighterEx addRangeHighlighterAndChangeAttributes(int startOffset, + public RangeHighlighterEx addRangeHighlighterAndChangeAttributes(@Nullable TextAttributesKey textAttributesKey, + int startOffset, int endOffset, int layer, - @Nullable TextAttributes forcedTextAttributes, - @Nullable TextAttributesKey textAttributesKey, @NotNull HighlighterTargetArea targetArea, boolean isPersistent, @Nullable Consumer changeAttributesAction) { return addRangeHighlighter(isPersistent - ? PersistentRangeHighlighterImpl.create(this, startOffset, layer, targetArea, forcedTextAttributes, + ? PersistentRangeHighlighterImpl.create(this, startOffset, layer, targetArea, textAttributesKey, true) - : new RangeHighlighterImpl(this, startOffset, endOffset, layer, targetArea, forcedTextAttributes, textAttributesKey, false, + : new RangeHighlighterImpl(this, startOffset, endOffset, layer, targetArea, textAttributesKey, false, false), changeAttributesAction); } @@ -169,13 +162,12 @@ public class MarkupModelImpl extends UserDataHolderBase implements MarkupModelEx @Override @NotNull - public RangeHighlighter addRangeHighlighter(int startOffset, + public RangeHighlighter addRangeHighlighter(@Nullable TextAttributesKey textAttributesKey, + int startOffset, int endOffset, int layer, - @Nullable TextAttributes forcedTextAttributes, - @Nullable TextAttributesKey textAttributesKey, @NotNull HighlighterTargetArea targetArea) { - return addRangeHighlighterAndChangeAttributes(startOffset, endOffset, layer, forcedTextAttributes, textAttributesKey, targetArea, false, + return addRangeHighlighterAndChangeAttributes(textAttributesKey, startOffset, endOffset, layer, targetArea, false, null); } diff --git a/platform/editor-ui-ex/src/com/intellij/openapi/editor/impl/PersistentRangeHighlighterImpl.java b/platform/editor-ui-ex/src/com/intellij/openapi/editor/impl/PersistentRangeHighlighterImpl.java index d1524858dfe0..e8bb0c54e5d2 100644 --- a/platform/editor-ui-ex/src/com/intellij/openapi/editor/impl/PersistentRangeHighlighterImpl.java +++ b/platform/editor-ui-ex/src/com/intellij/openapi/editor/impl/PersistentRangeHighlighterImpl.java @@ -20,7 +20,6 @@ import com.intellij.openapi.editor.event.DocumentEvent; import com.intellij.openapi.editor.ex.DocumentEx; import com.intellij.openapi.editor.impl.event.DocumentEventImpl; import com.intellij.openapi.editor.markup.HighlighterTargetArea; -import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.util.DocumentUtil; import com.intellij.util.diff.FilesTooBigForDiffException; import org.jetbrains.annotations.NotNull; @@ -36,12 +35,11 @@ class PersistentRangeHighlighterImpl extends RangeHighlighterImpl { int offset, int layer, @NotNull HighlighterTargetArea target, - @Nullable TextAttributes textAttributes, @Nullable TextAttributesKey textAttributesKey, boolean normalizeStartOffset) { int line = model.getDocument().getLineNumber(offset); int startOffset = normalizeStartOffset ? model.getDocument().getLineStartOffset(line) : offset; - return new PersistentRangeHighlighterImpl(model, startOffset, line, layer, target, textAttributes, textAttributesKey); + return new PersistentRangeHighlighterImpl(model, startOffset, line, layer, target, textAttributesKey); } private PersistentRangeHighlighterImpl(@NotNull MarkupModelImpl model, @@ -49,9 +47,8 @@ class PersistentRangeHighlighterImpl extends RangeHighlighterImpl { int line, int layer, @NotNull HighlighterTargetArea target, - @Nullable TextAttributes textAttributes, @Nullable TextAttributesKey textAttributesKey) { - super(model, startOffset, model.getDocument().getLineEndOffset(line), layer, target, textAttributes, textAttributesKey, false, false); + super(model, startOffset, model.getDocument().getLineEndOffset(line), layer, target, textAttributesKey, false, false); myLine = line; } diff --git a/platform/editor-ui-ex/src/com/intellij/openapi/editor/impl/RangeHighlighterImpl.java b/platform/editor-ui-ex/src/com/intellij/openapi/editor/impl/RangeHighlighterImpl.java index caf5198f1143..e8e631ad5520 100644 --- a/platform/editor-ui-ex/src/com/intellij/openapi/editor/impl/RangeHighlighterImpl.java +++ b/platform/editor-ui-ex/src/com/intellij/openapi/editor/impl/RangeHighlighterImpl.java @@ -67,12 +67,10 @@ class RangeHighlighterImpl extends RangeMarkerImpl implements RangeHighlighterEx int end, int layer, @NotNull HighlighterTargetArea target, - @Nullable TextAttributes textAttributes, @Nullable TextAttributesKey textAttributesKey, boolean greedyToLeft, boolean greedyToRight) { super((DocumentEx)model.getDocument(), start, end, false, false); - myForcedTextAttributes = textAttributes; myTextAttributesKey = textAttributesKey; setFlag(TARGET_AREA_IS_EXACT_MASK, target == HighlighterTargetArea.EXACT_RANGE); myModel = model; diff --git a/platform/lang-impl/src/com/intellij/application/options/CodeStyleAbstractPanel.java b/platform/lang-impl/src/com/intellij/application/options/CodeStyleAbstractPanel.java index c28760922aac..87cd25d912f4 100644 --- a/platform/lang-impl/src/com/intellij/application/options/CodeStyleAbstractPanel.java +++ b/platform/lang-impl/src/com/intellij/application/options/CodeStyleAbstractPanel.java @@ -552,7 +552,7 @@ public abstract class CodeStyleAbstractPanel implements Disposable, ComponentHig TextAttributes attributesToUse = range.getLength() > 0 ? backgroundAttributes : borderAttributes; markupModel.addRangeHighlighter( - range.getStartOffset(), range.getEndOffset(), HighlighterLayer.SELECTION, attributesToUse, null, HighlighterTargetArea.EXACT_RANGE + range.getStartOffset(), range.getEndOffset(), HighlighterLayer.SELECTION, attributesToUse, HighlighterTargetArea.EXACT_RANGE ); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/IndentsPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/IndentsPass.java index 4dc30b863fbd..786ff3bb92af 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/IndentsPass.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/IndentsPass.java @@ -344,8 +344,8 @@ public class IndentsPass extends TextEditorHighlightingPass implements DumbAware @NotNull private static RangeHighlighter createHighlighter(MarkupModel mm, TextRange range) { - final RangeHighlighter highlighter = mm.addRangeHighlighter(range.getStartOffset(), range.getEndOffset(), 0, - null, null, HighlighterTargetArea.EXACT_RANGE); + final RangeHighlighter highlighter = mm.addRangeHighlighter(null, range.getStartOffset(), range.getEndOffset(), 0, + HighlighterTargetArea.EXACT_RANGE); highlighter.setCustomRenderer(RENDERER); return highlighter; } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LineMarkersUtil.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LineMarkersUtil.java index bb999778fc60..e21436b6c6b9 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LineMarkersUtil.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LineMarkersUtil.java @@ -94,8 +94,8 @@ class LineMarkersUtil { if (highlighter == null) { newHighlighter = true; highlighter = markupModel.addRangeHighlighterAndChangeAttributes( - info.startOffset, info.endOffset, - HighlighterLayer.ADDITIONAL_SYNTAX, null, null, HighlighterTargetArea.LINES_IN_RANGE, false, + null, info.startOffset, info.endOffset, + HighlighterLayer.ADDITIONAL_SYNTAX, HighlighterTargetArea.LINES_IN_RANGE, false, markerEx -> { markerEx.setGutterIconRenderer(newRenderer); markerEx.setLineSeparatorColor(info.separatorColor); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/documentation/render/DocRenderItem.java b/platform/lang-impl/src/com/intellij/codeInsight/documentation/render/DocRenderItem.java index 15da29ae1a54..bd15cc7d6dee 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/documentation/render/DocRenderItem.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/documentation/render/DocRenderItem.java @@ -224,8 +224,7 @@ public class DocRenderItem { this.editor = editor; this.textToRender = textToRender; highlighter = editor.getMarkupModel() - .addRangeHighlighter(textRange.getStartOffset(), textRange.getEndOffset(), 0, - null, null, HighlighterTargetArea.EXACT_RANGE); + .addRangeHighlighter(null, textRange.getStartOffset(), textRange.getEndOffset(), 0, HighlighterTargetArea.EXACT_RANGE); updateIcon(); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceHighlightingHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceHighlightingHandler.java index b2ac9e0aab4a..8ee1afeae578 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceHighlightingHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceHighlightingHandler.java @@ -332,8 +332,8 @@ public class BraceHighlightingHandler { private void highlightBrace(@NotNull TextRange braceRange, boolean matched) { TextAttributesKey attributesKey = matched ? CodeInsightColors.MATCHED_BRACE_ATTRIBUTES : CodeInsightColors.UNMATCHED_BRACE_ATTRIBUTES; RangeHighlighter rbraceHighlighter = - myEditor.getMarkupModel().addRangeHighlighter(braceRange.getStartOffset(), braceRange.getEndOffset(), - LAYER, null, attributesKey, HighlighterTargetArea.EXACT_RANGE); + myEditor.getMarkupModel().addRangeHighlighter(attributesKey, braceRange.getStartOffset(), braceRange.getEndOffset(), + LAYER, HighlighterTargetArea.EXACT_RANGE); rbraceHighlighter.setGreedyToLeft(false); rbraceHighlighter.setGreedyToRight(false); registerHighlighter(rbraceHighlighter); @@ -436,7 +436,7 @@ public class BraceHighlightingHandler { LineMarkerRenderer renderer = createLineMarkerRenderer(matched); RangeHighlighter highlighter = editor.getMarkupModel() - .addRangeHighlighterAndChangeAttributes(startOffset, endOffset, 0, null, null, HighlighterTargetArea.LINES_IN_RANGE, false, + .addRangeHighlighterAndChangeAttributes(null, startOffset, endOffset, 0, HighlighterTargetArea.LINES_IN_RANGE, false, h -> h.setLineMarkerRenderer(renderer)); editor.putUserData(LINE_MARKER_IN_EDITOR_KEY, highlighter); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/highlighting/HighlightManagerImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/highlighting/HighlightManagerImpl.java index e85a96bf786d..7bfc54b5e076 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/highlighting/HighlightManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/highlighting/HighlightManagerImpl.java @@ -18,7 +18,6 @@ import com.intellij.openapi.editor.colors.TextAttributesKey; import com.intellij.openapi.editor.event.DocumentEvent; import com.intellij.openapi.editor.event.DocumentListener; import com.intellij.openapi.editor.ex.MarkupModelEx; -import com.intellij.openapi.editor.ex.RangeHighlighterEx; import com.intellij.openapi.editor.impl.ImaginaryEditor; import com.intellij.openapi.editor.markup.*; import com.intellij.openapi.project.Project; @@ -187,29 +186,34 @@ public final class HighlightManagerImpl extends HighlightManager { } private void addOccurrenceHighlight(@NotNull Editor editor, - int start, - int end, - @Nullable TextAttributes forcedAttributes, - @Nullable TextAttributesKey attributesKey, - int flags, - @Nullable Collection outHighlighters, - @Nullable Color scrollMarkColor) { - RangeHighlighter highlighter = editor.getMarkupModel() - .addRangeHighlighter(start, end, HighlighterLayer.SELECTION - 1, - forcedAttributes, attributesKey, - HighlighterTargetArea.EXACT_RANGE); - HighlightFlags info = new HighlightFlags(editor instanceof EditorWindow ? ((EditorWindow)editor).getDelegate() : editor, flags); - Map map = getHighlightInfoMap(editor, true); - map.put(highlighter, info); + int start, + int end, + @Nullable TextAttributes forcedAttributes, + @Nullable TextAttributesKey attributesKey, + int flags, + @Nullable Collection outHighlighters, + @Nullable Color scrollMarkColor) { + MarkupModelEx markupModel = (MarkupModelEx)editor.getMarkupModel(); + markupModel.addRangeHighlighterAndChangeAttributes(attributesKey, start, end, HighlighterLayer.SELECTION - 1, + HighlighterTargetArea.EXACT_RANGE, false, highlighter -> { - if (highlighter instanceof RangeHighlighterEx) ((RangeHighlighterEx)highlighter).setVisibleIfFolded(true); - if (outHighlighters != null) { - outHighlighters.add(highlighter); - } + HighlightFlags info = new HighlightFlags(editor instanceof EditorWindow ? ((EditorWindow)editor).getDelegate() : editor, flags); + Map map = getHighlightInfoMap(editor, true); + map.put(highlighter, info); - if (scrollMarkColor != null) { - highlighter.setErrorStripeMarkColor(scrollMarkColor); - } + highlighter.setVisibleIfFolded(true); + if (outHighlighters != null) { + outHighlighters.add(highlighter); + } + + if (forcedAttributes != null) { + highlighter.setTextAttributes(forcedAttributes); + } + + if (scrollMarkColor != null) { + highlighter.setErrorStripeMarkColor(scrollMarkColor); + } + }); } @Override diff --git a/platform/lang-impl/src/com/intellij/codeInsight/navigation/IncrementalSearchHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/navigation/IncrementalSearchHandler.java index 1b4e1944c774..317e457dbbdc 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/IncrementalSearchHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/IncrementalSearchHandler.java @@ -288,8 +288,8 @@ public final class IncrementalSearchHandler { data.label.setForeground(JBColor.foreground()); if (matchLength > 0) { data.segmentHighlighter = editor.getMarkupModel() - .addRangeHighlighter(index, index + matchLength, HighlighterLayer.LAST + 1, - null, EditorColors.SEARCH_RESULT_ATTRIBUTES, HighlighterTargetArea.EXACT_RANGE); + .addRangeHighlighter(EditorColors.SEARCH_RESULT_ATTRIBUTES, index, index + matchLength, HighlighterLayer.LAST + 1, + HighlighterTargetArea.EXACT_RANGE); } data.ignoreCaretMove = true; editor.getCaretModel().moveToOffset(index); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/unwrap/ScopeHighlighter.java b/platform/lang-impl/src/com/intellij/codeInsight/unwrap/ScopeHighlighter.java index 6b7ac6b19a8d..d1738ae71669 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/unwrap/ScopeHighlighter.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/unwrap/ScopeHighlighter.java @@ -86,8 +86,8 @@ public class ScopeHighlighter { private void addHighlighter(TextRange r, int level, TextAttributesKey key) { MarkupModel markupModel = myEditor.getMarkupModel(); - RangeHighlighter highlighter = markupModel.addRangeHighlighter(r.getStartOffset(), r.getEndOffset(), level, - null, key, HighlighterTargetArea.EXACT_RANGE); + RangeHighlighter highlighter = markupModel.addRangeHighlighter(key, r.getStartOffset(), r.getEndOffset(), level, + HighlighterTargetArea.EXACT_RANGE); myActiveHighliters.add(highlighter); } diff --git a/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleBuilder.java b/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleBuilder.java index efefe92df518..1e3bef49edcd 100644 --- a/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleBuilder.java +++ b/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleBuilder.java @@ -364,8 +364,8 @@ public final class LanguageConsoleBuilder { } RangeHighlighter highlighter = getHistoryViewer().getMarkupModel() - .addRangeHighlighter(0, getDocument().getTextLength(), HighlighterLayer.ADDITIONAL_SYNTAX, - null, null, HighlighterTargetArea.EXACT_RANGE); + .addRangeHighlighter(null, 0, getDocument().getTextLength(), HighlighterLayer.ADDITIONAL_SYNTAX, + HighlighterTargetArea.EXACT_RANGE); highlighter.setGreedyToRight(true); highlighter.setCustomRenderer(renderer); lineSeparatorPainter = highlighter; diff --git a/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java b/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java index 9808e3a49538..0c08b44ca488 100644 --- a/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java @@ -439,8 +439,8 @@ public class LanguageConsoleImpl extends ConsoleViewImpl implements LanguageCons private void addPromptToHistoryImpl(@NotNull String prompt) { DocumentEx document = getHistoryViewer().getDocument(); RangeHighlighter highlighter = - this.getHistoryViewer().getMarkupModel().addRangeHighlighter(document.getTextLength(), document.getTextLength(), 0, - null, null, HighlighterTargetArea.EXACT_RANGE); + this.getHistoryViewer().getMarkupModel().addRangeHighlighter(null, document.getTextLength(), document.getTextLength(), 0, + HighlighterTargetArea.EXACT_RANGE); print(prompt, myConsoleExecutionEditor.getPromptAttributes()); highlighter.putUserData(ConsoleHistoryCopyHandler.PROMPT_LENGTH_MARKER, prompt.length()); } diff --git a/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java b/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java index 8603b2b14148..ce0e0b26c473 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java @@ -815,13 +815,19 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo int startOffset, int endOffset) { ApplicationManager.getApplication().assertIsDispatchThread(); - TextAttributes attributes = contentType.getForcedAttributes(); TextAttributesKey attributesKey = contentType.getAttributesKey(); - MarkupModel model = DocumentMarkupModel.forDocument(myEditor.getDocument(), getProject(), true); + MarkupModelEx model = (MarkupModelEx)DocumentMarkupModel.forDocument(myEditor.getDocument(), getProject(), true); int layer = HighlighterLayer.SYNTAX + 1; // make custom filters able to draw their text attributes over the default ones - RangeHighlighter tokenMarker = model.addRangeHighlighter(startOffset, endOffset, layer, - attributes, attributesKey, HighlighterTargetArea.EXACT_RANGE); - tokenMarker.putUserData(CONTENT_TYPE, contentType); + model.addRangeHighlighterAndChangeAttributes( + attributesKey, startOffset, endOffset, layer, HighlighterTargetArea.EXACT_RANGE, false, + ex -> { + // fallback for contentTypes which provide only attributes + TextAttributes attributes = contentType.getForcedAttributes(); + if (attributes != null) { + ex.setTextAttributes(attributes); + } + ex.putUserData(CONTENT_TYPE, contentType); + }); } private boolean isDisposed() { diff --git a/platform/lang-impl/src/com/intellij/find/FindUtil.java b/platform/lang-impl/src/com/intellij/find/FindUtil.java index 7085f2a3e717..f59855cb41bd 100644 --- a/platform/lang-impl/src/com/intellij/find/FindUtil.java +++ b/platform/lang-impl/src/com/intellij/find/FindUtil.java @@ -722,10 +722,11 @@ public class FindUtil { if (!model.isGlobal()) { final RangeHighlighterEx segmentHighlighter = (RangeHighlighterEx)editor.getMarkupModel().addRangeHighlighter( + EditorColors.SEARCH_RESULT_ATTRIBUTES, result.getStartOffset(), result.getEndOffset(), HighlighterLayer.SELECTION + 1, - null, EditorColors.SEARCH_RESULT_ATTRIBUTES, HighlighterTargetArea.EXACT_RANGE); + HighlighterTargetArea.EXACT_RANGE); MyListener listener = new MyListener(editor, segmentHighlighter); caretModel.addCaretListener(listener); } diff --git a/platform/lang-impl/src/com/intellij/ide/bookmarks/Bookmark.java b/platform/lang-impl/src/com/intellij/ide/bookmarks/Bookmark.java index df1fed110811..3401532c923f 100644 --- a/platform/lang-impl/src/com/intellij/ide/bookmarks/Bookmark.java +++ b/platform/lang-impl/src/com/intellij/ide/bookmarks/Bookmark.java @@ -14,7 +14,10 @@ import com.intellij.openapi.actionSystem.ActionGroup; import com.intellij.openapi.actionSystem.ActionManager; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.RangeMarker; -import com.intellij.openapi.editor.colors.*; +import com.intellij.openapi.editor.colors.CodeInsightColors; +import com.intellij.openapi.editor.colors.EditorColors; +import com.intellij.openapi.editor.colors.EditorColorsManager; +import com.intellij.openapi.editor.colors.EditorFontType; import com.intellij.openapi.editor.ex.MarkupModelEx; import com.intellij.openapi.editor.ex.RangeHighlighterEx; import com.intellij.openapi.editor.impl.DocumentMarkupModel; @@ -148,7 +151,7 @@ public final class Bookmark implements Navigatable, Comparable { final RangeHighlighterEx highlighter; int line = getLine(); if (line >= 0) { - highlighter = markup.addPersistentLineHighlighter(line, HighlighterLayer.ERROR + 1, null, CodeInsightColors.BOOKMARKS_ATTRIBUTES); + highlighter = markup.addPersistentLineHighlighter(CodeInsightColors.BOOKMARKS_ATTRIBUTES, line, HighlighterLayer.ERROR + 1); if (highlighter != null) { highlighter.setGutterIconRenderer(new MyGutterIconRenderer(this)); highlighter.setErrorStripeTooltip(getBookmarkTooltip()); diff --git a/platform/lang-impl/src/com/intellij/refactoring/changeSignature/inplace/InplaceChangeSignature.java b/platform/lang-impl/src/com/intellij/refactoring/changeSignature/inplace/InplaceChangeSignature.java index dc507dfabae5..f68764ff7c2a 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/changeSignature/inplace/InplaceChangeSignature.java +++ b/platform/lang-impl/src/com/intellij/refactoring/changeSignature/inplace/InplaceChangeSignature.java @@ -186,12 +186,12 @@ public class InplaceChangeSignature implements DocumentListener { myPreview.getMarkupModel().removeAllHighlighters(); WriteCommandAction.writeCommandAction(null).run(() -> myPreview.getDocument().replaceString(0, myPreview.getDocument().getTextLength(), methodSignature)); for (TextRange range : deleteRanges) { - myPreview.getMarkupModel().addRangeHighlighter(range.getStartOffset(), range.getEndOffset(), HighlighterLayer.ADDITIONAL_SYNTAX, - null, CodeInsightColors.DEPRECATED_ATTRIBUTES, HighlighterTargetArea.EXACT_RANGE); + myPreview.getMarkupModel().addRangeHighlighter(CodeInsightColors.DEPRECATED_ATTRIBUTES, range.getStartOffset(), range.getEndOffset(), HighlighterLayer.ADDITIONAL_SYNTAX, + HighlighterTargetArea.EXACT_RANGE); } for (TextRange range : newRanges) { - myPreview.getMarkupModel().addRangeHighlighter(range.getStartOffset(), range.getEndOffset(), HighlighterLayer.ADDITIONAL_SYNTAX, - null, CodeInsightColors.TODO_DEFAULT_ATTRIBUTES, HighlighterTargetArea.EXACT_RANGE); + myPreview.getMarkupModel().addRangeHighlighter(CodeInsightColors.TODO_DEFAULT_ATTRIBUTES, range.getStartOffset(), range.getEndOffset(), HighlighterLayer.ADDITIONAL_SYNTAX, + HighlighterTargetArea.EXACT_RANGE); } } diff --git a/platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/OccurrencesChooser.java b/platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/OccurrencesChooser.java index acc64ec88897..a5cf3480a7ca 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/OccurrencesChooser.java +++ b/platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/OccurrencesChooser.java @@ -129,8 +129,7 @@ public abstract class OccurrencesChooser { for (T occurrence : occurrenceList) { final TextRange textRange = getOccurrenceRange(occurrence); final RangeHighlighter rangeHighlighter = markupModel.addRangeHighlighter( - textRange.getStartOffset(), textRange.getEndOffset(), HighlighterLayer.SELECTION - 1, - null, EditorColors.SEARCH_RESULT_ATTRIBUTES, + EditorColors.SEARCH_RESULT_ATTRIBUTES, textRange.getStartOffset(), textRange.getEndOffset(), HighlighterLayer.SELECTION - 1, HighlighterTargetArea.EXACT_RANGE); myRangeHighlighters.add(rangeHighlighter); } diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/RenameChooser.java b/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/RenameChooser.java index c59c45bf6b72..3fb8012777cf 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/RenameChooser.java +++ b/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/RenameChooser.java @@ -58,8 +58,7 @@ abstract class RenameChooser { for (Pair pair : stringUsages) { final TextRange textRange = pair.second.shiftRight(pair.first.getTextOffset()); final RangeHighlighter rangeHighlighter = markupModel.addRangeHighlighter( - textRange.getStartOffset(), textRange.getEndOffset(), HighlighterLayer.SELECTION - 1, - null, EditorColors.SEARCH_RESULT_ATTRIBUTES, + EditorColors.SEARCH_RESULT_ATTRIBUTES, textRange.getStartOffset(), textRange.getEndOffset(), HighlighterLayer.SELECTION - 1, HighlighterTargetArea.EXACT_RANGE); myRangeHighlighters.add(rangeHighlighter); } @@ -69,8 +68,7 @@ abstract class RenameChooser { final PsiElement element = reference.getElement(); final TextRange textRange = element.getTextRange(); final RangeHighlighter rangeHighlighter = markupModel.addRangeHighlighter( - textRange.getStartOffset(), textRange.getEndOffset(), HighlighterLayer.SELECTION - 1, - null, EditorColors.SEARCH_RESULT_ATTRIBUTES, + EditorColors.SEARCH_RESULT_ATTRIBUTES, textRange.getStartOffset(), textRange.getEndOffset(), HighlighterLayer.SELECTION - 1, HighlighterTargetArea.EXACT_RANGE); myRangeHighlighters.add(rangeHighlighter); } diff --git a/platform/lang-impl/src/com/intellij/refactoring/suggested/PerformSuggestedRefactoring.kt b/platform/lang-impl/src/com/intellij/refactoring/suggested/PerformSuggestedRefactoring.kt index 2879f94ee160..cf36447d8901 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/suggested/PerformSuggestedRefactoring.kt +++ b/platform/lang-impl/src/com/intellij/refactoring/suggested/PerformSuggestedRefactoring.kt @@ -247,7 +247,7 @@ private fun createAndShowBalloon( rangeToHighlight.startOffset, rangeToHighlight.endOffset, HighlighterLayer.FIRST, - attributes, null, + attributes, HighlighterTargetArea.LINES_IN_RANGE ) diff --git a/platform/platform-impl/src/com/intellij/application/options/colors/highlighting/HighlightData.java b/platform/platform-impl/src/com/intellij/application/options/colors/highlighting/HighlightData.java index 99f004f87006..d6c30f331482 100644 --- a/platform/platform-impl/src/com/intellij/application/options/colors/highlighting/HighlightData.java +++ b/platform/platform-impl/src/com/intellij/application/options/colors/highlighting/HighlightData.java @@ -62,11 +62,16 @@ public class HighlightData { UIUtil.invokeAndWaitIfNeeded((Runnable)() -> { try { // IDEA-53203: add ERASE_MARKER for manually defined attributes - view.getMarkupModel().addRangeHighlighter(myStartOffset, myEndOffset, HighlighterLayer.ADDITIONAL_SYNTAX, - TextAttributes.ERASE_MARKER, myHighlightType, HighlighterTargetArea.EXACT_RANGE); + RangeHighlighter erasedHighlighter = view.getMarkupModel() + .addRangeHighlighter(myHighlightType, myStartOffset, myEndOffset, HighlighterLayer.ADDITIONAL_SYNTAX, + HighlighterTargetArea.EXACT_RANGE); + if (erasedHighlighter instanceof RangeHighlighterEx) { + ((RangeHighlighterEx)erasedHighlighter).setTextAttributes(TextAttributes.ERASE_MARKER); + } + RangeHighlighter highlighter = view.getMarkupModel() - .addRangeHighlighter(myStartOffset, myEndOffset, HighlighterLayer.ADDITIONAL_SYNTAX, - null, myHighlightType, HighlighterTargetArea.EXACT_RANGE); + .addRangeHighlighter(myHighlightType, myStartOffset, myEndOffset, HighlighterLayer.ADDITIONAL_SYNTAX, + HighlighterTargetArea.EXACT_RANGE); final Color errorStripeColor = attr.getErrorStripeColor(); highlighter.setErrorStripeMarkColor(errorStripeColor); final String tooltip = displayText.get(myHighlightType); diff --git a/platform/platform-impl/src/com/intellij/execution/impl/EditorHyperlinkSupport.java b/platform/platform-impl/src/com/intellij/execution/impl/EditorHyperlinkSupport.java index e598eeb747a2..d317c85f6756 100644 --- a/platform/platform-impl/src/com/intellij/execution/impl/EditorHyperlinkSupport.java +++ b/platform/platform-impl/src/com/intellij/execution/impl/EditorHyperlinkSupport.java @@ -238,11 +238,17 @@ public class EditorHyperlinkSupport { @NotNull final HyperlinkInfo hyperlinkInfo, @Nullable TextAttributes followedHyperlinkAttributes, int layer) { - final RangeHighlighter highlighter = myEditor.getMarkupModel().addRangeHighlighter(highlightStartOffset, - highlightEndOffset, - layer, - highlightAttributes, CodeInsightColors.HYPERLINK_ATTRIBUTES, - HighlighterTargetArea.EXACT_RANGE); + final RangeHighlighter highlighter = + myEditor.getMarkupModel().addRangeHighlighterAndChangeAttributes(CodeInsightColors.HYPERLINK_ATTRIBUTES, + highlightStartOffset, + highlightEndOffset, + layer, + HighlighterTargetArea.EXACT_RANGE, + false, ex -> { + if (highlightAttributes != null) { + ex.setTextAttributes(highlightAttributes); + } + }); associateHyperlink(highlighter, hyperlinkInfo, followedHyperlinkAttributes); return highlighter; } @@ -397,7 +403,7 @@ public class EditorHyperlinkSupport { } } //refresh highlighter text attributes - markupModel.addRangeHighlighter(0, 0, link.getLayer(), null, CodeInsightColors.HYPERLINK_ATTRIBUTES, HighlighterTargetArea.EXACT_RANGE).dispose(); + markupModel.addRangeHighlighter(CodeInsightColors.HYPERLINK_ATTRIBUTES, 0, 0, link.getLayer(), HighlighterTargetArea.EXACT_RANGE).dispose(); } diff --git a/platform/platform-impl/src/com/intellij/ide/actions/RecentLocationsRenderer.java b/platform/platform-impl/src/com/intellij/ide/actions/RecentLocationsRenderer.java index e0ecee90cff7..64c1b013201e 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/RecentLocationsRenderer.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/RecentLocationsRenderer.java @@ -129,14 +129,10 @@ class RecentLocationsRenderer extends ColoredListCellRenderer list, RecentLocationItem value, diff --git a/platform/platform-impl/src/com/intellij/ide/impl/SelectInEditorManagerImpl.java b/platform/platform-impl/src/com/intellij/ide/impl/SelectInEditorManagerImpl.java index 673b04a8c563..7f84b26c49ea 100644 --- a/platform/platform-impl/src/com/intellij/ide/impl/SelectInEditorManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/ide/impl/SelectInEditorManagerImpl.java @@ -90,18 +90,18 @@ public class SelectInEditorManagerImpl extends SelectInEditorManager implements DocumentEx doc = (DocumentEx) editor.getDocument(); int lineNumber = doc.getLineNumber(startOffset); if (lineNumber >= 0 && lineNumber < doc.getLineCount()){ - mySegmentHighlighter = editor.getMarkupModel().addRangeHighlighter(doc.getLineStartOffset(lineNumber), + mySegmentHighlighter = editor.getMarkupModel().addRangeHighlighter(EditorColors.SEARCH_RESULT_ATTRIBUTES, + doc.getLineStartOffset(lineNumber), doc.getLineEndOffset(lineNumber) + doc.getLineSeparatorLength(lineNumber), HighlighterLayer.LAST + 1, - null, EditorColors.SEARCH_RESULT_ATTRIBUTES, HighlighterTargetArea.EXACT_RANGE); } } else{ - mySegmentHighlighter = editor.getMarkupModel().addRangeHighlighter(startOffset, + mySegmentHighlighter = editor.getMarkupModel().addRangeHighlighter(EditorColors.SEARCH_RESULT_ATTRIBUTES, + startOffset, endOffset, HighlighterLayer.LAST + 1, - null, EditorColors.SEARCH_RESULT_ATTRIBUTES, HighlighterTargetArea.EXACT_RANGE); } myEditor = editor; diff --git a/platform/platform-impl/src/com/intellij/notification/EventLogConsole.java b/platform/platform-impl/src/com/intellij/notification/EventLogConsole.java index d08c7006af80..a4a5e7585ad4 100644 --- a/platform/platform-impl/src/com/intellij/notification/EventLogConsole.java +++ b/platform/platform-impl/src/com/intellij/notification/EventLogConsole.java @@ -269,7 +269,7 @@ final class EventLogConsole { int layer = HighlighterLayer.CARET_ROW + 1; RangeHighlighter highlighter = editor.getMarkupModel() - .addRangeHighlighter(msgStart, document.getTextLength(), layer, null, key, HighlighterTargetArea.LINES_IN_RANGE); + .addRangeHighlighter(key, msgStart, document.getTextLength(), layer, HighlighterTargetArea.LINES_IN_RANGE); GROUP_ID.set(highlighter, notification.getGroupId()); NOTIFICATION_ID.set(highlighter, notification.id); diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/actions/ShowEditorHighlighterTokensAction.java b/platform/platform-impl/src/com/intellij/openapi/editor/actions/ShowEditorHighlighterTokensAction.java index f9fbf4c7900d..90b7dc74f919 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/actions/ShowEditorHighlighterTokensAction.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/actions/ShowEditorHighlighterTokensAction.java @@ -108,9 +108,8 @@ class ShowEditorHighlighterTokensAction extends EditorAction { HighlighterIterator it = ((EditorEx)editor).getHighlighter().createIterator(0); while (!it.atEnd()) { - RangeHighlighter h = editor.getMarkupModel().addRangeHighlighter(it.getStart(), it.getEnd(), 0, - Holder.OUR_TEXT_ATTRIBUTES, null, - HighlighterTargetArea.EXACT_RANGE); + RangeHighlighter h = editor.getMarkupModel().addRangeHighlighter(it.getStart(), it.getEnd(), + 0, Holder.OUR_TEXT_ATTRIBUTES, HighlighterTargetArea.EXACT_RANGE); IElementType tokenType = it.getTokenType(); h.putUserData(Holder.TOKEN_NAME, String.valueOf(tokenType)); it.advance(); diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorFilteringMarkupModelEx.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorFilteringMarkupModelEx.java index fc1ce87fc395..71dfb0068764 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorFilteringMarkupModelEx.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorFilteringMarkupModelEx.java @@ -118,11 +118,8 @@ public class EditorFilteringMarkupModelEx implements MarkupModelEx { @Override @Nullable - public RangeHighlighterEx addPersistentLineHighlighter(int lineNumber, - int layer, - @Nullable TextAttributes forcedTextAttributes, - @Nullable TextAttributesKey textAttributesKey) { - return myDelegate.addPersistentLineHighlighter(lineNumber, layer, forcedTextAttributes, textAttributesKey); + public RangeHighlighterEx addPersistentLineHighlighter(@Nullable TextAttributesKey textAttributesKey, int lineNumber, int layer) { + return myDelegate.addPersistentLineHighlighter(textAttributesKey, lineNumber, layer); } @Override @@ -137,35 +134,29 @@ public class EditorFilteringMarkupModelEx implements MarkupModelEx { @Override @NotNull - public RangeHighlighter addRangeHighlighter(int startOffset, + public RangeHighlighter addRangeHighlighter(@Nullable TextAttributesKey textAttributesKey, int startOffset, int endOffset, int layer, - @Nullable TextAttributes forcedTextAttributes, - @Nullable TextAttributesKey textAttributesKey, @NotNull HighlighterTargetArea targetArea) { - return myDelegate.addRangeHighlighter(startOffset, endOffset, layer, forcedTextAttributes, textAttributesKey, targetArea); + return myDelegate.addRangeHighlighter(textAttributesKey, startOffset, endOffset, layer, targetArea); } @Override @NotNull - public RangeHighlighter addLineHighlighter(int line, - int layer, - @Nullable TextAttributes forcedTextAttributes, - @Nullable TextAttributesKey textAttributesKey) { - return myDelegate.addLineHighlighter(line, layer, forcedTextAttributes, textAttributesKey); + public RangeHighlighter addLineHighlighter(@Nullable TextAttributesKey textAttributesKey, int line, int layer) { + return myDelegate.addLineHighlighter(textAttributesKey, line, layer); } @Override @NotNull - public RangeHighlighterEx addRangeHighlighterAndChangeAttributes(int startOffset, + public RangeHighlighterEx addRangeHighlighterAndChangeAttributes(@Nullable TextAttributesKey textAttributesKey, + int startOffset, int endOffset, int layer, - @Nullable TextAttributes forcedTextAttributes, - @Nullable TextAttributesKey textAttributesKey, @NotNull HighlighterTargetArea targetArea, boolean isPersistent, Consumer changeAttributesAction) { - return myDelegate.addRangeHighlighterAndChangeAttributes(startOffset, endOffset, layer, forcedTextAttributes, textAttributesKey, + return myDelegate.addRangeHighlighterAndChangeAttributes(textAttributesKey, startOffset, endOffset, layer, targetArea, isPersistent, changeAttributesAction); } diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/DocumentMarkupModelTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/DocumentMarkupModelTest.java index f0d35f18da84..4e121f72d595 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/DocumentMarkupModelTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/DocumentMarkupModelTest.java @@ -55,7 +55,7 @@ public class DocumentMarkupModelTest extends BasePlatformTestCase { public void testPersistentHighlighterUpdateOnPartialDocumentUpdate() { Document document = new DocumentImpl("line0\nline1\nline2"); MarkupModelEx model = (MarkupModelEx)DocumentMarkupModel.forDocument(document, getProject(), true); - RangeHighlighterEx highlighter = model.addPersistentLineHighlighter(2, 0, null, null); + RangeHighlighterEx highlighter = model.addPersistentLineHighlighter(null, 2, 0); WriteCommandAction.runWriteCommandAction(getProject(), () -> document.deleteString(document.getLineStartOffset(1), document.getTextLength())); assertFalse(highlighter.isValid()); } diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/EditorImplTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/EditorImplTest.java index f7b7467b6bd9..df2b813ee7d2 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/EditorImplTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/EditorImplTest.java @@ -308,7 +308,7 @@ public class EditorImplTest extends AbstractEditorTest { document.addDocumentListener(new DocumentListener() { @Override public void bulkUpdateFinished(@NotNull Document document) { - getEditor().getMarkupModel().addRangeHighlighter(7, 8, 0, null, null, HighlighterTargetArea.EXACT_RANGE); + getEditor().getMarkupModel().addRangeHighlighter(null, 7, 8, 0, HighlighterTargetArea.EXACT_RANGE); } }, getTestRootDisposable()); runWriteCommand(() -> DocumentUtil.executeInBulk(document, true, ()-> document.insertString(3, "\n\n"))); @@ -324,7 +324,7 @@ public class EditorImplTest extends AbstractEditorTest { runFoldingOperation(() -> { ((FoldingModelEx)getEditor().getFoldingModel()).clearFoldRegions(); getEditor().getMarkupModel().addRangeHighlighter(7, 8, 0, - new TextAttributes(null, null, null, null, Font.BOLD), null, + new TextAttributes(null, null, null, null, Font.BOLD), HighlighterTargetArea.EXACT_RANGE); }); RangeHighlighter[] highlighters = getEditor().getMarkupModel().getAllHighlighters(); diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/MarkupModelStressTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/MarkupModelStressTest.java index 58e50dc47897..82bb61f2b111 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/MarkupModelStressTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/MarkupModelStressTest.java @@ -82,8 +82,8 @@ public class MarkupModelStressTest extends AbstractEditorTest { int bound = getEditor().getDocument().getTextLength() + 1; int offset1 = myRandom.nextInt(bound); int offset2 = myRandom.nextInt(bound); - getEditor().getMarkupModel().addRangeHighlighter(Math.min(offset1, offset2), Math.max(offset1, offset2), 0, - null, null, HighlighterTargetArea.EXACT_RANGE); + getEditor().getMarkupModel().addRangeHighlighter(null, Math.min(offset1, offset2), Math.max(offset1, offset2), 0, + HighlighterTargetArea.EXACT_RANGE); } } diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/RangeMarkerTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/RangeMarkerTest.java index bf68b3c7f516..accb055824b5 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/RangeMarkerTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/RangeMarkerTest.java @@ -955,9 +955,9 @@ public class RangeMarkerTest extends LightPlatformTestCase { MarkupModel markupModel = DocumentMarkupModel.forDocument(document, getProject(), true); for (int i=0; i<2; i++) { - RangeMarker m = markupModel.addRangeHighlighter(1, 6, 0, null, null,HighlighterTargetArea.EXACT_RANGE); - RangeMarker m2 = markupModel.addRangeHighlighter(2, 7, 0, null, null, HighlighterTargetArea.EXACT_RANGE); - RangeMarker m3 = markupModel.addRangeHighlighter(1, 6, 0, null, null, HighlighterTargetArea.EXACT_RANGE); + RangeMarker m = markupModel.addRangeHighlighter(null, 1, 6, 0, HighlighterTargetArea.EXACT_RANGE); + RangeMarker m2 = markupModel.addRangeHighlighter(null, 2, 7, 0, HighlighterTargetArea.EXACT_RANGE); + RangeMarker m3 = markupModel.addRangeHighlighter(null, 1, 6, 0, HighlighterTargetArea.EXACT_RANGE); markupModel.removeAllHighlighters(); assertFalse(m.isValid()); assertFalse(m2.isValid()); @@ -1042,7 +1042,7 @@ public class RangeMarkerTest extends LightPlatformTestCase { Document document = EditorFactory.getInstance().createDocument("[xxxxxxxxxxxxxx]"); MarkupModel markupModel = DocumentMarkupModel.forDocument(document, getProject(), true); - RangeMarker m = markupModel.addRangeHighlighter(1, 6, 0, null, null, HighlighterTargetArea.EXACT_RANGE); + RangeMarker m = markupModel.addRangeHighlighter(null, 1, 6, 0, HighlighterTargetArea.EXACT_RANGE); assertTrue(m.isValid()); markupModel.removeAllHighlighters(); assertFalse(m.isValid()); @@ -1057,9 +1057,9 @@ public class RangeMarkerTest extends LightPlatformTestCase { final MarkupModelEx markupModel = (MarkupModelEx)DocumentMarkupModel.forDocument(document, getProject(), true); for (int i=0; i { List list = new ArrayList<>(); @@ -1076,8 +1076,8 @@ public class RangeMarkerTest extends LightPlatformTestCase { Document document = EditorFactory.getInstance().createDocument("1234567890"); final MarkupModelEx markupModel = (MarkupModelEx)DocumentMarkupModel.forDocument(document, getProject(), true); - RangeHighlighter exact = markupModel.addRangeHighlighter(3, 6, 0, null, null, HighlighterTargetArea.EXACT_RANGE); - RangeHighlighter line = markupModel.addRangeHighlighter(4, 5, 0, null, null, HighlighterTargetArea.LINES_IN_RANGE); + RangeHighlighter exact = markupModel.addRangeHighlighter(null, 3, 6, 0, HighlighterTargetArea.EXACT_RANGE); + RangeHighlighter line = markupModel.addRangeHighlighter(null, 4, 5, 0, HighlighterTargetArea.LINES_IN_RANGE); List list = new ArrayList<>(); markupModel.processRangeHighlightersOverlappingWith(2, 9, new CommonProcessors.CollectProcessor<>(list)); assertEquals(Arrays.asList(line, exact), list); diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/ui/ReplacementPreviewDialog.java b/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/ui/ReplacementPreviewDialog.java index 758875672d96..66a253aa5053 100644 --- a/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/ui/ReplacementPreviewDialog.java +++ b/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/ui/ReplacementPreviewDialog.java @@ -63,11 +63,10 @@ public final class ReplacementPreviewDialog extends DialogWrapper { return; } myHighlighter = editor.getMarkupModel().addRangeHighlighter( + EditorColors.SEARCH_RESULT_ATTRIBUTES, start, end, HighlighterLayer.SELECTION - 100, - null, - EditorColors.SEARCH_RESULT_ATTRIBUTES, HighlighterTargetArea.EXACT_RANGE ); } diff --git a/platform/usageView/src/com/intellij/usages/impl/UsagePreviewPanel.java b/platform/usageView/src/com/intellij/usages/impl/UsagePreviewPanel.java index 2cf5095f7bba..b04d717afdb8 100644 --- a/platform/usageView/src/com/intellij/usages/impl/UsagePreviewPanel.java +++ b/platform/usageView/src/com/intellij/usages/impl/UsagePreviewPanel.java @@ -197,9 +197,11 @@ public class UsagePreviewPanel extends UsageContextPanelBase implements DataProv // highlight injected element in host document textrange textRange = InjectedLanguageManager.getInstance(project).injectedToHost(psiElement, textRange); - RangeHighlighter highlighter = markupModel.addRangeHighlighter(textRange.getStartOffset(), textRange.getEndOffset(), - highlightLayer, null, EditorColors.SEARCH_RESULT_ATTRIBUTES, - HighlighterTargetArea.EXACT_RANGE); + RangeHighlighter highlighter = markupModel.addRangeHighlighter(EditorColors.SEARCH_RESULT_ATTRIBUTES, + textRange.getStartOffset(), + textRange.getEndOffset(), + highlightLayer, + HighlighterTargetArea.EXACT_RANGE); highlighter.putUserData(IN_PREVIEW_USAGE_FLAG, Boolean.TRUE); if (infoRange != null && findModel != null && findModel.isReplaceState()) { RangeHighlighter boxHighlighter diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/tool/ApplyPatchChange.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/tool/ApplyPatchChange.java index e412bf50c675..90c622878dc6 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/tool/ApplyPatchChange.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/tool/ApplyPatchChange.java @@ -121,8 +121,8 @@ class ApplyPatchChange { TextRange textRange = DiffUtil.getLinesRange(document, line1, line2); RangeHighlighter highlighter = markupModel - .addRangeHighlighter(textRange.getStartOffset(), textRange.getEndOffset(), HighlighterLayer.LAST, - null, null, HighlighterTargetArea.LINES_IN_RANGE); + .addRangeHighlighter(null, textRange.getStartOffset(), textRange.getEndOffset(), HighlighterLayer.LAST, + HighlighterTargetArea.LINES_IN_RANGE); highlighter.setLineMarkerRenderer(new MyGutterRenderer(line1, line2, color, tooltip)); diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerUtilImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerUtilImpl.java index b5b7434ff645..180b4f5d4411 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerUtilImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerUtilImpl.java @@ -231,8 +231,8 @@ public class XDebuggerUtilImpl extends XDebuggerUtil { } if (!range.isEmpty() && range.intersects(lineRange)) { myHighlighter = editor.getMarkupModel().addRangeHighlighter( - range.getStartOffset(), range.getEndOffset(), DebuggerColors.BREAKPOINT_HIGHLIGHTER_LAYER, - null, DebuggerColors.BREAKPOINT_ATTRIBUTES, HighlighterTargetArea.EXACT_RANGE); + DebuggerColors.BREAKPOINT_ATTRIBUTES, range.getStartOffset(), range.getEndOffset(), DebuggerColors.BREAKPOINT_HIGHLIGHTER_LAYER, + HighlighterTargetArea.EXACT_RANGE); } } } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointImpl.java index 83a07831199e..b13257f12e83 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointImpl.java @@ -6,10 +6,14 @@ import com.intellij.openapi.application.WriteAction; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.LazyRangeMarkerFactory; import com.intellij.openapi.editor.RangeMarker; +import com.intellij.openapi.editor.colors.TextAttributesKey; import com.intellij.openapi.editor.ex.MarkupModelEx; import com.intellij.openapi.editor.ex.RangeHighlighterEx; import com.intellij.openapi.editor.impl.DocumentMarkupModel; -import com.intellij.openapi.editor.markup.*; +import com.intellij.openapi.editor.markup.GutterDraggableObject; +import com.intellij.openapi.editor.markup.HighlighterTargetArea; +import com.intellij.openapi.editor.markup.MarkupEditorFilterFactory; +import com.intellij.openapi.editor.markup.RangeHighlighter; import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.TextRange; @@ -95,13 +99,13 @@ public final class XLineBreakpointImpl

extends } // todo separate attribute key for disabled breakpoints with settings in Colors | Debugger - TextAttributes forcedAttributes = isEnabled() ? null : new TextAttributes(); + TextAttributesKey textAttributesKey = isEnabled() ? DebuggerColors.BREAKPOINT_ATTRIBUTES : null; RangeHighlighter highlighter = (RangeHighlighter)myHighlighter; if (highlighter != null && (!highlighter.isValid() || !DocumentUtil.isValidOffset(highlighter.getStartOffset(), document) - || !Comparing.equal(highlighter.getTextAttributes(null), forcedAttributes) + || !Comparing.equal(highlighter.getTextAttributesKey(), textAttributesKey) // it seems that this check is not needed - we always update line number from the highlighter // and highlighter is removed on line and file change anyway /*|| document.getLineNumber(highlighter.getStartOffset()) != getLine()*/)) { @@ -116,15 +120,15 @@ public final class XLineBreakpointImpl

extends if (range != null && !range.isEmpty()) { TextRange lineRange = DocumentUtil.getLineTextRange(document, getLine()); if (range.intersects(lineRange)) { - highlighter = markupModel.addRangeHighlighter(range.getStartOffset(), range.getEndOffset(), + highlighter = markupModel.addRangeHighlighter(textAttributesKey, + range.getStartOffset(), + range.getEndOffset(), DebuggerColors.BREAKPOINT_HIGHLIGHTER_LAYER, - forcedAttributes, DebuggerColors.BREAKPOINT_ATTRIBUTES, HighlighterTargetArea.EXACT_RANGE); } } if (highlighter == null) { - highlighter = markupModel.addPersistentLineHighlighter(getLine(), DebuggerColors.BREAKPOINT_HIGHLIGHTER_LAYER, - forcedAttributes, DebuggerColors.BREAKPOINT_ATTRIBUTES); + highlighter = markupModel.addPersistentLineHighlighter(textAttributesKey, getLine(), DebuggerColors.BREAKPOINT_HIGHLIGHTER_LAYER); } if (highlighter == null) { return; diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/ExecutionPointHighlighter.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/ExecutionPointHighlighter.java index 8ad93d13ff8e..6f7a3dafda50 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/ExecutionPointHighlighter.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/ExecutionPointHighlighter.java @@ -191,13 +191,13 @@ public class ExecutionPointHighlighter { TextRange lineRange = DocumentUtil.getLineTextRange(document, line); if (!range.equals(lineRange)) { myRangeHighlighter = markupModel - .addRangeHighlighter(range.getStartOffset(), range.getEndOffset(), DebuggerColors.EXECUTION_LINE_HIGHLIGHTERLAYER, - null, attributesKey, HighlighterTargetArea.EXACT_RANGE); + .addRangeHighlighter(attributesKey, range.getStartOffset(), range.getEndOffset(), DebuggerColors.EXECUTION_LINE_HIGHLIGHTERLAYER, + HighlighterTargetArea.EXACT_RANGE); } } } if (myRangeHighlighter == null) { - myRangeHighlighter = markupModel.addLineHighlighter(line, DebuggerColors.EXECUTION_LINE_HIGHLIGHTERLAYER, null, attributesKey); + myRangeHighlighter = markupModel.addLineHighlighter(attributesKey, line, DebuggerColors.EXECUTION_LINE_HIGHLIGHTERLAYER); } myRangeHighlighter.putUserData(EXECUTION_POINT_HIGHLIGHTER_TOP_FRAME_KEY, !myNotTopFrame); myRangeHighlighter.setEditorFilter(MarkupEditorFilterFactory.createIsNotDiffFilter()); diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/modifiers/ChangeModifierIntention.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/modifiers/ChangeModifierIntention.java index 5412e23f797d..38bb02c72b98 100644 --- a/plugins/IntentionPowerPak/src/com/siyeh/ipp/modifiers/ChangeModifierIntention.java +++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/modifiers/ChangeModifierIntention.java @@ -161,8 +161,8 @@ public class ChangeModifierIntention extends BaseElementAtCaretIntentionAction { } RangeHighlighter highlighter = editor.getMarkupModel() - .addRangeHighlighter(range.getStartOffset(), range.getEndOffset(), HighlighterLayer.LAST + 1, - null, EditorColors.LIVE_TEMPLATE_ATTRIBUTES, HighlighterTargetArea.EXACT_RANGE); + .addRangeHighlighter(EditorColors.LIVE_TEMPLATE_ATTRIBUTES, range.getStartOffset(), range.getEndOffset(), HighlighterLayer.LAST + 1, + HighlighterTargetArea.EXACT_RANGE); highlighter.setGreedyToRight(true); highlighter.setGreedyToLeft(true); ModifierUpdater updater = new ModifierUpdater(file, document, range, getFamilyName()); diff --git a/plugins/coverage-common/src/com/intellij/coverage/SrcFileAnnotator.java b/plugins/coverage-common/src/com/intellij/coverage/SrcFileAnnotator.java index fe99404c539c..b061844ce10d 100644 --- a/plugins/coverage-common/src/com/intellij/coverage/SrcFileAnnotator.java +++ b/plugins/coverage-common/src/com/intellij/coverage/SrcFileAnnotator.java @@ -471,7 +471,7 @@ public class SrcFileAnnotator implements Disposable { final int endOffset = document.getLineEndOffset(lineNumberInCurrent); final TextAttributesKey attributesKey = CoverageLineMarkerRenderer.getAttributesKey(line, executableLines); final RangeHighlighter highlighter = - markupModel.addRangeHighlighter(startOffset, endOffset, HighlighterLayer.SELECTION - 1, null, attributesKey, HighlighterTargetArea.LINES_IN_RANGE); + markupModel.addRangeHighlighter(attributesKey, startOffset, endOffset, HighlighterLayer.SELECTION - 1, HighlighterTargetArea.LINES_IN_RANGE); final Function newToOldConverter = newLine -> { if (editor == null) return -1; final TIntIntHashMap oldLineMapping = getNewToOldLineMapping(date, editorBean); diff --git a/plugins/devkit/devkit-core/src/testAssistant/TestDataHighlightingPass.java b/plugins/devkit/devkit-core/src/testAssistant/TestDataHighlightingPass.java index a5384f4419c7..9a8e79fdc748 100644 --- a/plugins/devkit/devkit-core/src/testAssistant/TestDataHighlightingPass.java +++ b/plugins/devkit/devkit-core/src/testAssistant/TestDataHighlightingPass.java @@ -63,7 +63,6 @@ public class TestDataHighlightingPass extends TextEditorHighlightingPass { ind + CARET.length(), HighlighterLayer.ADDITIONAL_SYNTAX, CARET_ATTRIBUTES, - null, HighlighterTargetArea.EXACT_RANGE); highlighter.setGutterIconRenderer(ICON_RENDERER); highlighter.putUserData(KEY, VALUE); diff --git a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/comment/ui/GHPREditorCommentableRangesController.kt b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/comment/ui/GHPREditorCommentableRangesController.kt index 13fc2328eaa6..27a773368e86 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/comment/ui/GHPREditorCommentableRangesController.kt +++ b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/comment/ui/GHPREditorCommentableRangesController.kt @@ -42,7 +42,7 @@ class GHPREditorCommentableRangesController(commentableRanges: SingleValueModel< val start = editor.document.getLineStartOffset(i) val end = editor.document.getLineEndOffset(i) editor.markupModel - .addRangeHighlighterAndChangeAttributes(start, end, HighlighterLayer.LAST, null, null, HighlighterTargetArea.EXACT_RANGE, + .addRangeHighlighterAndChangeAttributes(null, start, end, HighlighterLayer.LAST, HighlighterTargetArea.EXACT_RANGE, false) { highlighter -> highlighter.gutterIconRenderer = gutterIconRendererFactory.createCommentRenderer(i) } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/ui/MethodOrClosureScopeChooser.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/ui/MethodOrClosureScopeChooser.java index 0050450d5640..6a43a2862899 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/ui/MethodOrClosureScopeChooser.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/ui/MethodOrClosureScopeChooser.java @@ -165,8 +165,8 @@ public final class MethodOrClosureScopeChooser { final MarkupModel markupModel = editor.getMarkupModel(); final TextRange textRange = selectedMethod.getTextRange(); final RangeHighlighter rangeHighlighter = - markupModel.addRangeHighlighter(textRange.getStartOffset(), textRange.getEndOffset(), HighlighterLayer.SELECTION - 1, - null, attributesKey, HighlighterTargetArea.EXACT_RANGE); + markupModel.addRangeHighlighter(attributesKey, textRange.getStartOffset(), textRange.getEndOffset(), HighlighterLayer.SELECTION - 1, + HighlighterTargetArea.EXACT_RANGE); highlighters.add(rangeHighlighter); if (selectedMethod instanceof GrMethod) { superMethod.setText(USE_SUPER_METHOD_OF); diff --git a/xml/impl/src/com/intellij/codeInsight/daemon/impl/tagTreeHighlighting/XmlTagTreeHighlightingPass.java b/xml/impl/src/com/intellij/codeInsight/daemon/impl/tagTreeHighlighting/XmlTagTreeHighlightingPass.java index 3a92fa76f0cd..b3a0d1d16cdf 100644 --- a/xml/impl/src/com/intellij/codeInsight/daemon/impl/tagTreeHighlighting/XmlTagTreeHighlightingPass.java +++ b/xml/impl/src/com/intellij/codeInsight/daemon/impl/tagTreeHighlighting/XmlTagTreeHighlightingPass.java @@ -244,7 +244,7 @@ public class XmlTagTreeHighlightingPass extends TextEditorHighlightingPass { @NotNull private static RangeHighlighter createHighlighter(MarkupModel mm, @NotNull TextRange range, Color color) { RangeHighlighter highlighter = - mm.addRangeHighlighter(range.getStartOffset(), range.getEndOffset(), 0, null, null, HighlighterTargetArea.LINES_IN_RANGE); + mm.addRangeHighlighter(null, range.getStartOffset(), range.getEndOffset(), 0, HighlighterTargetArea.LINES_IN_RANGE); highlighter.setLineMarkerRenderer((__, g, r) -> { g.setColor(color);