From ab1d80779449da502a845eed4cc58e94f52f0a4d Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Fri, 8 May 2020 11:22:13 +0200 Subject: [PATCH] cleanup GitOrigin-RevId: 630092d3d1005bd814bed89cdc82cf871ed0463e --- .../com/intellij/openapi/editor/Editor.java | 3 +- .../intellij/openapi/editor/InlayModel.java | 14 ++-- .../properties/BraceStyleAccessor.java | 5 +- .../properties/ForceBracesAccessor.java | 5 +- .../GeneralCodeStylePropertyMapper.java | 4 +- .../properties/WrappingAccessor.java | 6 +- .../hints/InlayUnloadingListener.kt | 4 +- .../tree/injected/InlayModelWindow.java | 18 ++--- .../openapi/editor/ex/util/EditorUtil.java | 4 +- .../editor/impl/AfterLineEndInlayImpl.java | 8 +-- .../openapi/editor/impl/BlockInlayImpl.java | 12 ++-- .../impl/EditorGutterComponentImpl.java | 4 +- .../openapi/editor/impl/InlayImpl.java | 4 +- .../openapi/editor/impl/InlayModelImpl.java | 67 +++++++++---------- .../openapi/editor/impl/InlineInlayImpl.java | 8 +-- .../impl/view/EditorCoordinateMapper.java | 18 +++-- .../editor/impl/view/EditorPainter.java | 6 +- .../view/VisualLineFragmentsIterator.java | 7 +- .../editor/impl/view/VisualLinesIterator.java | 20 +++--- .../view/WrapElementMeasuringIterator.java | 10 +-- .../textarea/TextComponentInlayModel.java | 18 ++--- .../openapi/editor/impl/EditorInlayTest.java | 38 +++++------ .../openapi/editor/impl/EditorStressTest.java | 14 ++-- ...tiesLanguageCodeStyleSettingsProvider.java | 3 +- 24 files changed, 144 insertions(+), 156 deletions(-) diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/Editor.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/Editor.java index 3b31c95a1c1a..413a123ec84e 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/Editor.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/Editor.java @@ -1,4 +1,4 @@ -// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.editor; import com.intellij.openapi.Disposable; @@ -12,7 +12,6 @@ import com.intellij.openapi.editor.markup.MarkupModel; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.UserDataHolder; -import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/InlayModel.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/InlayModel.java index 21b21b7b10d3..e049f1dfc97a 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/InlayModel.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/InlayModel.java @@ -91,7 +91,7 @@ public interface InlayModel { * (higher priority ones appear first). Both visible and invisible (due to folding) elements are returned. */ @NotNull - List getBlockElementsInRange(int startOffset, int endOffset); + List> getBlockElementsInRange(int startOffset, int endOffset); /** * Same as {@link #getBlockElementsInRange(int, int)}, but returned list contains only inlays with renderer of given type. @@ -106,7 +106,7 @@ public interface InlayModel { * Only visible (not folded) elements are returned. */ @NotNull - List getBlockElementsForVisualLine(int visualLine, boolean above); + List> getBlockElementsForVisualLine(int visualLine, boolean above); /** * Tells whether there exists at least one block element currently. @@ -173,7 +173,7 @@ public interface InlayModel { * @see #addAfterLineEndElement(int, boolean, EditorCustomElementRenderer) */ @NotNull - List getAfterLineEndElementsInRange(int startOffset, int endOffset); + List> getAfterLineEndElementsInRange(int startOffset, int endOffset); /** * Same as {@link #getAfterLineEndElementsInRange(int, int)}, but returned list contains only inlays with renderer of given type. @@ -231,18 +231,18 @@ public interface InlayModel { void addListener(@NotNull Listener listener, @NotNull Disposable disposable); interface Listener extends EventListener { - default void onAdded(@NotNull Inlay inlay) {} + default void onAdded(@NotNull Inlay inlay) {} - default void onUpdated(@NotNull Inlay inlay) {} + default void onUpdated(@NotNull Inlay inlay) {} /** * @param changeFlags see {@link ChangeFlags} */ - default void onUpdated(@NotNull Inlay inlay, @MagicConstant(flagsFromClass = ChangeFlags.class) int changeFlags) { + default void onUpdated(@NotNull Inlay inlay, @MagicConstant(flagsFromClass = ChangeFlags.class) int changeFlags) { onUpdated(inlay); } - default void onRemoved(@NotNull Inlay inlay) {} + default void onRemoved(@NotNull Inlay inlay) {} /** * @see #execute(boolean, Runnable) diff --git a/platform/lang-api/src/com/intellij/application/options/codeStyle/properties/BraceStyleAccessor.java b/platform/lang-api/src/com/intellij/application/options/codeStyle/properties/BraceStyleAccessor.java index f795d40d0033..96987955a9cd 100644 --- a/platform/lang-api/src/com/intellij/application/options/codeStyle/properties/BraceStyleAccessor.java +++ b/platform/lang-api/src/com/intellij/application/options/codeStyle/properties/BraceStyleAccessor.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.application.options.codeStyle.properties; import com.intellij.psi.codeStyle.CommonCodeStyleSettings; @@ -6,8 +6,7 @@ import org.jetbrains.annotations.NotNull; import java.lang.reflect.Field; -class BraceStyleAccessor extends MagicIntegerConstAccessor { - +final class BraceStyleAccessor extends MagicIntegerConstAccessor { BraceStyleAccessor(@NotNull Object object, @NotNull Field field) { super(object, field, diff --git a/platform/lang-api/src/com/intellij/application/options/codeStyle/properties/ForceBracesAccessor.java b/platform/lang-api/src/com/intellij/application/options/codeStyle/properties/ForceBracesAccessor.java index f4ce69982cf2..31bdbedae8ef 100644 --- a/platform/lang-api/src/com/intellij/application/options/codeStyle/properties/ForceBracesAccessor.java +++ b/platform/lang-api/src/com/intellij/application/options/codeStyle/properties/ForceBracesAccessor.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.application.options.codeStyle.properties; import com.intellij.psi.codeStyle.CommonCodeStyleSettings; @@ -6,8 +6,7 @@ import org.jetbrains.annotations.NotNull; import java.lang.reflect.Field; -class ForceBracesAccessor extends MagicIntegerConstAccessor { - +final class ForceBracesAccessor extends MagicIntegerConstAccessor { ForceBracesAccessor(@NotNull Object object, @NotNull Field field) { super(object, field, diff --git a/platform/lang-api/src/com/intellij/application/options/codeStyle/properties/GeneralCodeStylePropertyMapper.java b/platform/lang-api/src/com/intellij/application/options/codeStyle/properties/GeneralCodeStylePropertyMapper.java index 9899aa8b9a28..e30f56d9d376 100644 --- a/platform/lang-api/src/com/intellij/application/options/codeStyle/properties/GeneralCodeStylePropertyMapper.java +++ b/platform/lang-api/src/com/intellij/application/options/codeStyle/properties/GeneralCodeStylePropertyMapper.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.application.options.codeStyle.properties; import com.intellij.openapi.diagnostic.Logger; @@ -15,7 +15,7 @@ import java.util.List; import java.util.Map; import java.util.Set; -public class GeneralCodeStylePropertyMapper extends AbstractCodeStylePropertyMapper { +public final class GeneralCodeStylePropertyMapper extends AbstractCodeStylePropertyMapper { private static final Logger LOG = Logger.getInstance(AbstractCodeStylePropertyMapper.class); public static final String COMMON_DOMAIN_ID = "all"; diff --git a/platform/lang-api/src/com/intellij/application/options/codeStyle/properties/WrappingAccessor.java b/platform/lang-api/src/com/intellij/application/options/codeStyle/properties/WrappingAccessor.java index 9dfd58cd9d0c..b1040d9ea28b 100644 --- a/platform/lang-api/src/com/intellij/application/options/codeStyle/properties/WrappingAccessor.java +++ b/platform/lang-api/src/com/intellij/application/options/codeStyle/properties/WrappingAccessor.java @@ -1,4 +1,4 @@ -// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.application.options.codeStyle.properties; import com.intellij.psi.codeStyle.CommonCodeStyleSettings; @@ -6,8 +6,7 @@ import org.jetbrains.annotations.NotNull; import java.lang.reflect.Field; -class WrappingAccessor extends MagicIntegerConstAccessor { - +final class WrappingAccessor extends MagicIntegerConstAccessor { WrappingAccessor(@NotNull Object object, @NotNull Field field) { super(object, field, new int[]{ @@ -25,5 +24,4 @@ class WrappingAccessor extends MagicIntegerConstAccessor { "split_into_lines", }); } - } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hints/InlayUnloadingListener.kt b/platform/lang-impl/src/com/intellij/codeInsight/hints/InlayUnloadingListener.kt index aa82a7a5c93a..6753997d7550 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/hints/InlayUnloadingListener.kt +++ b/platform/lang-impl/src/com/intellij/codeInsight/hints/InlayUnloadingListener.kt @@ -3,11 +3,9 @@ package com.intellij.codeInsight.hints import com.intellij.ide.plugins.DynamicPluginListener import com.intellij.ide.plugins.IdeaPluginDescriptor -import com.intellij.openapi.editor.EditorCustomElementRenderer import com.intellij.openapi.editor.EditorFactory import com.intellij.openapi.editor.Inlay import com.intellij.openapi.util.Disposer -import org.jetbrains.annotations.NotNull class InlayUnloadingListener : DynamicPluginListener { override fun beforePluginUnload(pluginDescriptor: IdeaPluginDescriptor, isUpdate: Boolean) { @@ -19,7 +17,7 @@ class InlayUnloadingListener : DynamicPluginListener { } } - private fun closeInlays(inlineElements: @NotNull List>) { + private fun closeInlays(inlineElements: List>) { for (inlay in inlineElements) { if (inlay.renderer !is LinearOrderInlayRenderer<*>) return Disposer.dispose(inlay) diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InlayModelWindow.java b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InlayModelWindow.java index 79dd5406e7e9..bba26e44d17f 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InlayModelWindow.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InlayModelWindow.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.psi.impl.source.tree.injected; import com.intellij.openapi.Disposable; @@ -14,7 +14,7 @@ import java.awt.*; import java.util.Collections; import java.util.List; -class InlayModelWindow implements InlayModel { +final class InlayModelWindow implements InlayModel { private static final Logger LOG = Logger.getInstance(InlayModelWindow.class); @Nullable @@ -48,21 +48,21 @@ class InlayModelWindow implements InlayModel { @NotNull @Override - public List getInlineElementsInRange(int startOffset, int endOffset) { + public List> getInlineElementsInRange(int startOffset, int endOffset) { logUnsupported(); return Collections.emptyList(); } @NotNull @Override - public List getBlockElementsInRange(int startOffset, int endOffset) { + public List> getBlockElementsInRange(int startOffset, int endOffset) { logUnsupported(); return Collections.emptyList(); } @NotNull @Override - public List getBlockElementsForVisualLine(int visualLine, boolean above) { + public List> getBlockElementsForVisualLine(int visualLine, boolean above) { logUnsupported(); return Collections.emptyList(); } @@ -75,28 +75,28 @@ class InlayModelWindow implements InlayModel { @Nullable @Override - public Inlay getInlineElementAt(@NotNull VisualPosition visualPosition) { + public Inlay getInlineElementAt(@NotNull VisualPosition visualPosition) { logUnsupported(); return null; } @Nullable @Override - public Inlay getElementAt(@NotNull Point point) { + public Inlay getElementAt(@NotNull Point point) { logUnsupported(); return null; } @NotNull @Override - public List getAfterLineEndElementsInRange(int startOffset, int endOffset) { + public List> getAfterLineEndElementsInRange(int startOffset, int endOffset) { logUnsupported(); return Collections.emptyList(); } @NotNull @Override - public List getAfterLineEndElementsForLogicalLine(int logicalLine) { + public List> getAfterLineEndElementsForLogicalLine(int logicalLine) { logUnsupported(); return Collections.emptyList(); } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/EditorUtil.java b/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/EditorUtil.java index 2cf05a52ac62..6809852e6772 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/EditorUtil.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/EditorUtil.java @@ -1,4 +1,4 @@ -// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.editor.ex.util; import com.intellij.diagnostic.AttachmentFactory; @@ -975,7 +975,7 @@ public final class EditorUtil { LogicalPosition logicalPosition = editor.visualToLogicalPosition(visualPosition); int offset = editor.logicalPositionToOffset(logicalPosition); if (!logicalPosition.equals(editor.offsetToLogicalPosition(offset))) return false; // virtual space - List inlays = editor.getInlayModel().getInlineElementsInRange(offset, offset); + List> inlays = editor.getInlayModel().getInlineElementsInRange(offset, offset); if (!inlays.isEmpty()) { VisualPosition inlaysStart = editor.offsetToVisualPosition(offset); if (inlaysStart.line == visualPosition.line) { diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/AfterLineEndInlayImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/AfterLineEndInlayImpl.java index 8839e45980c9..ee01ea93ac99 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/AfterLineEndInlayImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/AfterLineEndInlayImpl.java @@ -1,4 +1,4 @@ -// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.editor.impl; import com.intellij.diagnostic.PluginException; @@ -10,7 +10,7 @@ import org.jetbrains.annotations.NotNull; import java.awt.*; import java.util.List; -class AfterLineEndInlayImpl extends InlayImpl { +final class AfterLineEndInlayImpl extends InlayImpl> { private static int ourGlobalCounter = 0; final int myOrder; @@ -21,7 +21,7 @@ class AfterLineEndInlayImpl extends Inlay } @Override - RangeMarkerTree getTree() { + RangeMarkerTree> getTree() { return myEditor.getInlayModel().myAfterLineEndElementsTree; } @@ -54,7 +54,7 @@ class AfterLineEndInlayImpl extends Inlay int lineEndOffset = myEditor.getDocument().getLineEndOffset(logicalLine); VisualPosition position = myEditor.offsetToVisualPosition(lineEndOffset, true, true); if (myEditor.getFoldingModel().isOffsetCollapsed(lineEndOffset)) return position; - List inlays = myEditor.getInlayModel().getAfterLineEndElementsForLogicalLine(logicalLine); + List> inlays = myEditor.getInlayModel().getAfterLineEndElementsForLogicalLine(logicalLine); int order = inlays.indexOf(this); return new VisualPosition(position.line, position.column + 1 + order); } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/BlockInlayImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/BlockInlayImpl.java index 5503292c4e19..fca808d3c457 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/BlockInlayImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/BlockInlayImpl.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.editor.impl; import com.intellij.diagnostic.PluginException; @@ -13,7 +13,7 @@ import java.awt.*; import java.util.List; import java.util.function.IntSupplier; -class BlockInlayImpl extends InlayImpl implements IntSupplier { +final class BlockInlayImpl extends InlayImpl> implements IntSupplier { final boolean myShowAbove; final int myPriority; private int myHeightInPixels; @@ -31,7 +31,7 @@ class BlockInlayImpl extends InlayImpl getTree() { + MarkerTreeWithPartialSums> getTree() { return myEditor.getInlayModel().myBlockElementsTree; } @@ -56,17 +56,17 @@ class BlockInlayImpl extends InlayImpl allInlays = myEditor.getInlayModel().getBlockElementsForVisualLine(visualLine, myShowAbove); + List> allInlays = myEditor.getInlayModel().getBlockElementsForVisualLine(visualLine, myShowAbove); if (myShowAbove) { boolean found = false; - for (Inlay inlay : allInlays) { + for (Inlay inlay : allInlays) { if (inlay == this) found = true; if (found) y -= inlay.getHeightInPixels(); } } else { y += myEditor.getLineHeight(); - for (Inlay inlay : allInlays) { + for (Inlay inlay : allInlays) { if (inlay == this) break; y += inlay.getHeightInPixels(); } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java index 4b372d73ff5e..d0951beb77ba 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java @@ -2199,7 +2199,7 @@ final class EditorGutterComponentImpl extends EditorGutterComponentEx implements } if (myHasInlaysWithGutterIcons) { if (p.y < startY) { - List inlays = myEditor.getInlayModel().getBlockElementsForVisualLine(line, true); + List> inlays = myEditor.getInlayModel().getBlockElementsForVisualLine(line, true); int yDiff = startY - p.y; for (int i = inlays.size() - 1; i >= 0; i--) { Inlay inlay = inlays.get(i); @@ -2211,7 +2211,7 @@ final class EditorGutterComponentImpl extends EditorGutterComponentEx implements } } else { - List inlays = myEditor.getInlayModel().getBlockElementsForVisualLine(line, false); + List> inlays = myEditor.getInlayModel().getBlockElementsForVisualLine(line, false); int yDiff = p.y - endY; for (Inlay inlay : inlays) { int height = inlay.getHeightInPixels(); diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/InlayImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/InlayImpl.java index 4d2d17c26906..560ab39887d5 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/InlayImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/InlayImpl.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.editor.impl; import com.intellij.openapi.editor.Editor; @@ -15,7 +15,7 @@ import javax.swing.*; import java.awt.*; import java.util.Objects; -abstract class InlayImpl extends RangeMarkerWithGetterImpl implements Inlay { +abstract class InlayImpl> extends RangeMarkerWithGetterImpl implements Inlay { static final Key OFFSET_BEFORE_DISPOSAL = Key.create("inlay.offset.before.disposal"); @NotNull diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/InlayModelImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/InlayModelImpl.java index e799687634b2..dfee0e70aff1 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/InlayModelImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/InlayModelImpl.java @@ -26,7 +26,7 @@ import java.util.List; import java.util.*; import java.util.function.Predicate; -public class InlayModelImpl implements InlayModel, PrioritizedDocumentListener, Disposable, Dumpable { +public final class InlayModelImpl implements InlayModel, PrioritizedDocumentListener, Disposable, Dumpable { private static final Logger LOG = Logger.getInstance(InlayModelImpl.class); private static final Comparator INLINE_ELEMENTS_COMPARATOR = Comparator.comparingInt((Inlay i) -> i.getOffset()) .thenComparing(i -> i.isRelatedToPrecedingText()); @@ -45,9 +45,9 @@ public class InlayModelImpl implements InlayModel, PrioritizedDocumentListener, private final EventDispatcher myDispatcher = EventDispatcher.create(Listener.class); private final List myInlaysInvalidatedOnMove = new ArrayList<>(); - final RangeMarkerTree myInlineElementsTree; - final MarkerTreeWithPartialSums myBlockElementsTree; - final RangeMarkerTree myAfterLineEndElementsTree; + final RangeMarkerTree> myInlineElementsTree; + final MarkerTreeWithPartialSums> myBlockElementsTree; + final RangeMarkerTree> myAfterLineEndElementsTree; boolean myMoveInProgress; boolean myPutMergedIntervalsAtBeginning; @@ -83,7 +83,7 @@ public class InlayModelImpl implements InlayModel, PrioritizedDocumentListener, caretPosition.column >= inlaysStartPosition.column && caretPosition.column <= inlaysStartPosition.column + inlayCount) { myInlaysAtCaret = inlays; for (int i = 0; i < inlayCount; i++) { - ((InlayImpl)inlays.get(i)).setStickingToRight(i >= caretPosition.column - inlaysStartPosition.column); + ((InlayImpl)inlays.get(i)).setStickingToRight(i >= caretPosition.column - inlaysStartPosition.column); } } } @@ -93,13 +93,13 @@ public class InlayModelImpl implements InlayModel, PrioritizedDocumentListener, @Override public void documentChanged(@NotNull DocumentEvent event) { if (myInlaysAtCaret != null) { - for (Inlay inlay : myInlaysAtCaret) { - ((InlayImpl)inlay).setStickingToRight(inlay.isRelatedToPrecedingText()); + for (Inlay inlay : myInlaysAtCaret) { + ((InlayImpl)inlay).setStickingToRight(inlay.isRelatedToPrecedingText()); } myInlaysAtCaret = null; } if (DocumentEventUtil.isMoveInsertion(event)) { - for (InlayImpl inlay : myInlaysInvalidatedOnMove) { + for (InlayImpl inlay : myInlaysInvalidatedOnMove) { notifyRemoved(inlay); } myInlaysInvalidatedOnMove.clear(); @@ -133,13 +133,12 @@ public class InlayModelImpl implements InlayModel, PrioritizedDocumentListener, return inlay; } - @Nullable @Override - public Inlay addBlockElement(int offset, - boolean relatesToPrecedingText, - boolean showAbove, - int priority, - @NotNull T renderer) { + public @NotNull Inlay addBlockElement(int offset, + boolean relatesToPrecedingText, + boolean showAbove, + int priority, + @NotNull T renderer) { EditorImpl.assertIsDispatchThread(); offset = Math.max(0, Math.min(myEditor.getDocument().getTextLength(), offset)); BlockInlayImpl inlay = new BlockInlayImpl<>(myEditor, offset, relatesToPrecedingText, showAbove, priority, renderer); @@ -147,11 +146,10 @@ public class InlayModelImpl implements InlayModel, PrioritizedDocumentListener, return inlay; } - @Nullable @Override - public Inlay addAfterLineEndElement(int offset, - boolean relatesToPrecedingText, - @NotNull T renderer) { + public @NotNull Inlay addAfterLineEndElement(int offset, + boolean relatesToPrecedingText, + @NotNull T renderer) { EditorImpl.assertIsDispatchThread(); Document document = myEditor.getDocument(); offset = Math.max(0, Math.min(document.getTextLength(), offset)); @@ -163,7 +161,6 @@ public class InlayModelImpl implements InlayModel, PrioritizedDocumentListener, @NotNull @Override public List> getInlineElementsInRange(int startOffset, int endOffset) { - //noinspection unchecked return getElementsInRange(myInlineElementsTree, startOffset, endOffset, inlay -> true, INLINE_ELEMENTS_COMPARATOR); } @@ -179,8 +176,8 @@ public class InlayModelImpl implements InlayModel, PrioritizedDocumentListener, @NotNull @Override - public List getBlockElementsInRange(int startOffset, int endOffset) { - List range = + public List> getBlockElementsInRange(int startOffset, int endOffset) { + List> range = getElementsInRange(myBlockElementsTree, startOffset, endOffset, inlay -> true, BLOCK_ELEMENTS_PRIORITY_COMPARATOR); //noinspection unchecked return (List)range; @@ -189,7 +186,7 @@ public class InlayModelImpl implements InlayModel, PrioritizedDocumentListener, @NotNull @Override public List> getBlockElementsInRange(int startOffset, int endOffset, @NotNull Class type) { - List range = getElementsInRange(myBlockElementsTree, startOffset, endOffset, inlay -> type.isInstance(inlay.myRenderer), + List> range = getElementsInRange(myBlockElementsTree, startOffset, endOffset, inlay -> type.isInstance(inlay.myRenderer), BLOCK_ELEMENTS_PRIORITY_COMPARATOR); //noinspection unchecked return (List)range; @@ -211,7 +208,7 @@ public class InlayModelImpl implements InlayModel, PrioritizedDocumentListener, @NotNull @Override - public List getBlockElementsForVisualLine(int visualLine, boolean above) { + public List> getBlockElementsForVisualLine(int visualLine, boolean above) { int visibleLineCount = myEditor.getVisibleLineCount(); if (visualLine < 0 || visualLine >= visibleLineCount || myBlockElementsTree.size() == 0) return Collections.emptyList(); List result = new ArrayList<>(); @@ -319,7 +316,7 @@ public class InlayModelImpl implements InlayModel, PrioritizedDocumentListener, int visualLine = visualPosition.line; int baseY = location.getVisualLineBaseY(); if (point.y < baseY) { - List inlays = getBlockElementsForVisualLine(visualLine, true); + List> inlays = getBlockElementsForVisualLine(visualLine, true); int yDiff = baseY - point.y; for (int i = inlays.size() - 1; i >= 0; i--) { Inlay inlay = inlays.get(i); @@ -335,7 +332,7 @@ public class InlayModelImpl implements InlayModel, PrioritizedDocumentListener, else { int lineBottom = baseY + myEditor.getLineHeight(); if (point.y >= lineBottom) { - List inlays = getBlockElementsForVisualLine(visualLine, false); + List> inlays = getBlockElementsForVisualLine(visualLine, false); int yDiff = point.y - lineBottom; for (Inlay inlay : inlays) { yDiff -= inlay.getHeightInPixels(); @@ -388,9 +385,9 @@ public class InlayModelImpl implements InlayModel, PrioritizedDocumentListener, @NotNull @Override - public List getAfterLineEndElementsInRange(int startOffset, int endOffset) { + public List> getAfterLineEndElementsInRange(int startOffset, int endOffset) { if (!hasAfterLineEndElements()) return Collections.emptyList(); - List range = + List> range = getElementsInRange(myAfterLineEndElementsTree, startOffset, endOffset, inlay -> true, AFTER_LINE_END_ELEMENTS_OFFSET_COMPARATOR); //noinspection unchecked return (List)range; @@ -513,22 +510,22 @@ public class InlayModelImpl implements InlayModel, PrioritizedDocumentListener, return joiner.toString(); } - private class InlineElementsTree extends HardReferencingRangeMarkerTree { + private class InlineElementsTree extends HardReferencingRangeMarkerTree> { InlineElementsTree(@NotNull Document document) { super(document); } @NotNull @Override - protected Node createNewNode(@NotNull InlineInlayImpl key, int start, int end, + protected Node> createNewNode(@NotNull InlineInlayImpl key, int start, int end, boolean greedyToLeft, boolean greedyToRight, boolean stickingToRight, int layer) { - return new Node(this, key, start, end, greedyToLeft, greedyToRight, stickingToRight) { + return new Node>(this, key, start, end, greedyToLeft, greedyToRight, stickingToRight) { @Override - void addIntervalsFrom(@NotNull IntervalNode otherNode) { + void addIntervalsFrom(@NotNull IntervalNode> otherNode) { super.addIntervalsFrom(otherNode); if (myPutMergedIntervalsAtBeginning) { - List> added = ContainerUtil.subList(intervals, intervals.size() - otherNode.intervals.size()); - List> addedCopy = new ArrayList<>(added); + List>> added = ContainerUtil.subList(intervals, intervals.size() - otherNode.intervals.size()); + List>> addedCopy = new ArrayList<>(added); added.clear(); intervals.addAll(0, addedCopy); } @@ -551,7 +548,7 @@ public class InlayModelImpl implements InlayModel, PrioritizedDocumentListener, } } - private class BlockElementsTree extends MarkerTreeWithPartialSums { + private final class BlockElementsTree extends MarkerTreeWithPartialSums> { BlockElementsTree(@NotNull Document document) { super(document); } @@ -564,7 +561,7 @@ public class InlayModelImpl implements InlayModel, PrioritizedDocumentListener, } } - private class AfterLineEndElementTree extends HardReferencingRangeMarkerTree { + private class AfterLineEndElementTree extends HardReferencingRangeMarkerTree> { AfterLineEndElementTree(@NotNull Document document) { super(document); } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/InlineInlayImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/InlineInlayImpl.java index 7658bdab825c..1ce505126ce4 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/InlineInlayImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/InlineInlayImpl.java @@ -13,7 +13,7 @@ import org.jetbrains.annotations.NotNull; import java.awt.*; import java.util.List; -class InlineInlayImpl extends InlayImpl { +final class InlineInlayImpl extends InlayImpl> { private static final Key ORDER_BEFORE_DISPOSAL = Key.create("inlay.order.before.disposal"); InlineInlayImpl(@NotNull EditorImpl editor, @@ -24,7 +24,7 @@ class InlineInlayImpl extends InlayImpl getTree() { + RangeMarkerTree> getTree() { return myEditor.getInlayModel().myInlineElementsTree; } @@ -56,7 +56,7 @@ class InlineInlayImpl extends InlayImpl inlays = myEditor.getInlayModel().getInlineElementsInRange(offset, offset); + List> inlays = myEditor.getInlayModel().getInlineElementsInRange(offset, offset); putUserData(ORDER_BEFORE_DISPOSAL, inlays.indexOf(this)); } super.dispose(); @@ -82,7 +82,7 @@ class InlineInlayImpl extends InlayImpl inlays = myEditor.getInlayModel().getInlineElementsInRange(offset, offset); + List> inlays = myEditor.getInlayModel().getInlineElementsInRange(offset, offset); int order = inlays.indexOf(this); return new VisualPosition(pos.line, pos.column + order, true); } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/view/EditorCoordinateMapper.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/view/EditorCoordinateMapper.java index 6d5305f5b330..fead0bd99910 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/view/EditorCoordinateMapper.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/view/EditorCoordinateMapper.java @@ -1,6 +1,4 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. - */ +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.editor.impl.view; import com.intellij.openapi.editor.*; @@ -19,17 +17,17 @@ import java.awt.geom.Point2D; import java.util.List; /** - * Performs transformations between various location representations in editor + * Performs transformations between various location representations in editor * (offset, logical position, visual position, pixel coordinates). - * + * * @see LogicalPosition * @see VisualPosition */ -class EditorCoordinateMapper { +final class EditorCoordinateMapper { private final EditorView myView; private final Document myDocument; private final FoldingModelImpl myFoldingModel; - + EditorCoordinateMapper(EditorView view) { myView = view; myDocument = myView.getEditor().getDocument(); @@ -195,7 +193,7 @@ class EditorCoordinateMapper { // delaying result to check whether there's an 'invisible' fold region going next if (column != maxColumn) return delayedResult; } - maxLogicalColumn = logicalLine == fragment.getEndLogicalLine() ? Math.max(maxLogicalColumn, fragment.getMaxLogicalColumn()) : + maxLogicalColumn = logicalLine == fragment.getEndLogicalLine() ? Math.max(maxLogicalColumn, fragment.getMaxLogicalColumn()) : fragment.getMaxLogicalColumn(); maxVisualColumn = maxColumn; logicalLine = fragment.getEndLogicalLine(); @@ -354,7 +352,7 @@ class EditorCoordinateMapper { float plainSpaceWidth = myView.getPlainSpaceWidth(); float remainingShift = px - x; if (remainingShift > plainSpaceWidth && logicalLine >= 0) { - List inlays = myView.getEditor().getInlayModel().getAfterLineEndElementsForLogicalLine(logicalLine); + List> inlays = myView.getEditor().getInlayModel().getAfterLineEndElementsForLogicalLine(logicalLine); int inlaysWidth = 0; int inlayCount = 0; for (Inlay inlay : inlays) { @@ -408,7 +406,7 @@ class EditorCoordinateMapper { } } if (column > lastColumn + 1 && logicalLine >= 0) { - List inlays = myView.getEditor().getInlayModel().getAfterLineEndElementsForLogicalLine(logicalLine); + List> inlays = myView.getEditor().getInlayModel().getAfterLineEndElementsForLogicalLine(logicalLine); int inlaysWidth = 0; int inlayCount = 0; for (Inlay inlay : inlays) { diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/view/EditorPainter.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/view/EditorPainter.java index 9b71f4b62c64..29eb545223e6 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/view/EditorPainter.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/view/EditorPainter.java @@ -426,7 +426,7 @@ public class EditorPainter implements TextDrawingCallback { paintVirtualSelectionIfNecessary(visualLine, columnStart, x, y); myTextDrawingTasks.add(g -> { int logicalLine = myDocument.getLineNumber(offset); - List inlays = myEditor.getInlayModel().getAfterLineEndElementsForLogicalLine(logicalLine); + List> inlays = myEditor.getInlayModel().getAfterLineEndElementsForLogicalLine(logicalLine); if (!inlays.isEmpty()) { float curX = x + myView.getPlainSpaceWidth(); for (Inlay inlay : inlays) { @@ -1147,7 +1147,7 @@ public class EditorPainter implements TextDrawingCallback { int y = visLinesIterator.getY() + myYShift; int curY = y; - List inlaysAbove = visLinesIterator.getBlockInlaysAbove(); + List> inlaysAbove = visLinesIterator.getBlockInlaysAbove(); if (!inlaysAbove.isEmpty()) { TextAttributes attributes = getInlayAttributes(visualLine); for (Inlay inlay : inlaysAbove) { @@ -1161,7 +1161,7 @@ public class EditorPainter implements TextDrawingCallback { } } curY = y + myLineHeight; - List inlaysBelow = visLinesIterator.getBlockInlaysBelow(); + List> inlaysBelow = visLinesIterator.getBlockInlaysBelow(); if (!inlaysBelow.isEmpty()) { TextAttributes attributes = getInlayAttributes(visualLine + 1); for (Inlay inlay : inlaysBelow) { diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/view/VisualLineFragmentsIterator.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/view/VisualLineFragmentsIterator.java index 2be5e3289d18..4f1568fc544f 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/view/VisualLineFragmentsIterator.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/view/VisualLineFragmentsIterator.java @@ -1,4 +1,4 @@ -// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.editor.impl.view; import com.intellij.openapi.editor.Document; @@ -25,8 +25,7 @@ import java.util.function.Consumer; * Iterator over visual line's fragments. Fragment's text has the same font and directionality. Collapsed fold regions are also represented * as fragments. */ -class VisualLineFragmentsIterator implements Iterator { - +final class VisualLineFragmentsIterator implements Iterator { @NotNull static Iterable create(@NotNull EditorView view, int offset, boolean beforeSoftWrap) { return create(view, offset, beforeSoftWrap, false); @@ -60,7 +59,7 @@ class VisualLineFragmentsIterator implements Iterator myFragmentIterator; - private List myInlays; + private List> myInlays; private int myCurrentInlayIndex; private float myCurrentX; private int myCurrentVisualColumn; diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/view/VisualLinesIterator.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/view/VisualLinesIterator.java index a90ffa4090fd..ce3001f20933 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/view/VisualLinesIterator.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/view/VisualLinesIterator.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.editor.impl.view; import com.intellij.openapi.editor.Document; @@ -17,7 +17,7 @@ import java.util.List; * If one needs to perform some actions for a continuous range of visual lines, using this class would be most surely faster than * calculating various values (e.g. start/end offsets) for all visual lines in the range individually. */ -public class VisualLinesIterator { +public final class VisualLinesIterator { private static final int UNSET = -1; private final EditorImpl myEditor; @@ -26,8 +26,8 @@ public class VisualLinesIterator { private final List mySoftWraps; private final int myLineHeight; - private final List myInlaysAbove = new ArrayList<>(); - private final List myInlaysBelow = new ArrayList<>(); + private final List> myInlaysAbove = new ArrayList<>(); + private final List> myInlaysBelow = new ArrayList<>(); private boolean myInlaysSet; @NotNull @@ -49,7 +49,7 @@ public class VisualLinesIterator { public boolean atEnd() { return myLocation.atEnd(); } - + public void advance() { checkEnd(); if (y != UNSET) { @@ -140,13 +140,13 @@ public class VisualLinesIterator { return myLocation.softWrap < mySoftWraps.size() && mySoftWraps.get(myLocation.softWrap).getStart() == getVisualLineEndOffset(); } - public List getBlockInlaysAbove() { + public List> getBlockInlaysAbove() { checkEnd(); setInlays(); return myInlaysAbove; } - public List getBlockInlaysBelow() { + public List> getBlockInlaysBelow() { checkEnd(); setInlays(); return myInlaysBelow; @@ -169,9 +169,9 @@ public class VisualLinesIterator { myInlaysAbove.clear(); myInlaysBelow.clear(); setNextLocation(); - List inlays = myEditor.getInlayModel() + List> inlays = myEditor.getInlayModel() .getBlockElementsInRange(myLocation.offset, myNextLocation.atEnd() ? myDocument.getTextLength() : myNextLocation.offset - 1); - for (Inlay inlay : inlays) { + for (Inlay inlay : inlays) { int inlayOffset = inlay.getOffset() - (inlay.isRelatedToPrecedingText() ? 0 : 1); int foldIndex = myLocation.foldRegion; while (foldIndex < myFoldRegions.length && myFoldRegions[foldIndex].getEndOffset() <= inlayOffset) foldIndex++; @@ -239,7 +239,7 @@ public class VisualLinesIterator { } return false; } - + private boolean atEnd() { return offset == -1; } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/view/WrapElementMeasuringIterator.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/view/WrapElementMeasuringIterator.java index d9b75c2b76a4..472a573d6695 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/view/WrapElementMeasuringIterator.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/view/WrapElementMeasuringIterator.java @@ -1,4 +1,4 @@ -// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.editor.impl.view; import com.intellij.openapi.editor.Document; @@ -14,11 +14,11 @@ import java.util.List; /** * {@link WrapElementIterator} extension that also calculates widths of elements. */ -public class WrapElementMeasuringIterator extends WrapElementIterator { +public final class WrapElementMeasuringIterator extends WrapElementIterator { private final EditorView myView; private final Document myDocument; - private final List inlineInlays; - private final List afterLineEndInlays; + private final List> inlineInlays; + private final List> afterLineEndInlays; private int inlineInlayIndex; private int afterLineEndInlayIndex; @@ -85,7 +85,7 @@ public class WrapElementMeasuringIterator extends WrapElementIterator { } int width = 0; while (afterLineEndInlayIndex < afterLineEndInlays.size()) { - Inlay inlay = afterLineEndInlays.get(afterLineEndInlayIndex); + Inlay inlay = afterLineEndInlays.get(afterLineEndInlayIndex); int offset = inlay.getOffset(); if (offset < startOffset || offset > endOffset) break; width += inlay.getWidthInPixels(); diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/textarea/TextComponentInlayModel.java b/platform/platform-impl/src/com/intellij/openapi/editor/textarea/TextComponentInlayModel.java index 428ac4a674c5..c780030fc3c2 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/textarea/TextComponentInlayModel.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/textarea/TextComponentInlayModel.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.editor.textarea; import com.intellij.openapi.Disposable; @@ -13,7 +13,7 @@ import java.awt.*; import java.util.Collections; import java.util.List; -class TextComponentInlayModel implements InlayModel { +final class TextComponentInlayModel implements InlayModel { @Nullable @Override public Inlay addInlineElement(int offset, @@ -42,19 +42,19 @@ class TextComponentInlayModel implements InlayModel { @NotNull @Override - public List getInlineElementsInRange(int startOffset, int endOffset) { + public List> getInlineElementsInRange(int startOffset, int endOffset) { return Collections.emptyList(); } @NotNull @Override - public List getBlockElementsInRange(int startOffset, int endOffset) { + public List> getBlockElementsInRange(int startOffset, int endOffset) { return Collections.emptyList(); } @NotNull @Override - public List getBlockElementsForVisualLine(int visualLine, boolean above) { + public List> getBlockElementsForVisualLine(int visualLine, boolean above) { return Collections.emptyList(); } @@ -65,25 +65,25 @@ class TextComponentInlayModel implements InlayModel { @Nullable @Override - public Inlay getInlineElementAt(@NotNull VisualPosition visualPosition) { + public Inlay getInlineElementAt(@NotNull VisualPosition visualPosition) { return null; } @Nullable @Override - public Inlay getElementAt(@NotNull Point point) { + public Inlay getElementAt(@NotNull Point point) { return null; } @NotNull @Override - public List getAfterLineEndElementsInRange(int startOffset, int endOffset) { + public List> getAfterLineEndElementsInRange(int startOffset, int endOffset) { return Collections.emptyList(); } @NotNull @Override - public List getAfterLineEndElementsForLogicalLine(int logicalLine) { + public List> getAfterLineEndElementsForLogicalLine(int logicalLine) { return Collections.emptyList(); } diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/EditorInlayTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/EditorInlayTest.java index 8823161eae4e..5eadf9768098 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/EditorInlayTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/EditorInlayTest.java @@ -1,4 +1,4 @@ -// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.editor.impl; import com.intellij.openapi.command.WriteCommandAction; @@ -129,7 +129,7 @@ public class EditorInlayTest extends AbstractEditorTest { public void testDocumentEditingWithSoftWraps() { initText("long line"); configureSoftWraps(7); - Inlay inlay = addInlay(1); + Inlay inlay = addInlay(1); assertNotNull(getEditor().getSoftWrapModel().getSoftWrap(5)); runWriteCommand(() -> getEditor().getDocument().setText(" ")); assertFalse(inlay.isValid()); @@ -138,7 +138,7 @@ public class EditorInlayTest extends AbstractEditorTest { public void testInlayDoesntGetInsideSurrogatePair() { initText(""); // Cannot set up text with singular surrogate characters directly runWriteCommand(() -> getEditor().getDocument().setText(HIGH_SURROGATE + LOW_SURROGATE + LOW_SURROGATE)); - Inlay inlay = addInlay(2); + Inlay inlay = addInlay(2); assertNotNull(inlay); assertTrue(inlay.isValid()); runWriteCommand(() -> ((DocumentEx)getEditor().getDocument()).moveText(2, 3, 1)); @@ -169,8 +169,8 @@ public class EditorInlayTest extends AbstractEditorTest { public void testTypingBetweenInlaysAtSameOffset() { initText("ab"); - Inlay inlay1 = addInlay(1); - Inlay inlay2 = addInlay(1); + Inlay inlay1 = addInlay(1); + Inlay inlay2 = addInlay(1); right(); right(); type(' '); @@ -263,7 +263,7 @@ public class EditorInlayTest extends AbstractEditorTest { public void testCaretPositionAfterInlayDisposalToTheLeft() { initText("ab"); - Inlay inlay = addInlay(1); + Inlay inlay = addInlay(1); addInlay(1); right(); right(); @@ -274,7 +274,7 @@ public class EditorInlayTest extends AbstractEditorTest { public void testCaretPositionAfterInlayDisposalToTheRight() { initText("ab"); addInlay(1); - Inlay inlay = addInlay(1); + Inlay inlay = addInlay(1); right(); right(); Disposer.dispose(inlay); @@ -303,8 +303,8 @@ public class EditorInlayTest extends AbstractEditorTest { public void testBehaviourOnTextInsertion() { initText("abc"); - Inlay i1 = addInlay(1, false); - Inlay i2 = addInlay(2, true); + Inlay i1 = addInlay(1, false); + Inlay i2 = addInlay(2, true); runWriteCommand(() -> { getEditor().getDocument().insertString(2, " "); getEditor().getDocument().insertString(1, " "); @@ -331,9 +331,9 @@ public class EditorInlayTest extends AbstractEditorTest { public void testInlayOrderAfterMerge() { initText("ab"); - Inlay i0 = addInlay(0); - Inlay i1 = addInlay(1); - Inlay i2 = addInlay(2); + Inlay i0 = addInlay(0); + Inlay i1 = addInlay(1); + Inlay i2 = addInlay(2); runWriteCommand(() -> { getEditor().getDocument().deleteString(0, 1); getEditor().getDocument().deleteString(0, 1); @@ -343,9 +343,9 @@ public class EditorInlayTest extends AbstractEditorTest { public void testInlayOrderAfterDocumentModification() { initText("abc"); - Inlay i1 = addInlay(2); + Inlay i1 = addInlay(2); runWriteCommand(() -> getEditor().getDocument().deleteString(1, 2)); - Inlay i2 = addInlay(1); + Inlay i2 = addInlay(1); assertEquals(Arrays.asList(i1, i2), getEditor().getInlayModel().getInlineElementsInRange(1, 1)); } @@ -410,8 +410,8 @@ public class EditorInlayTest extends AbstractEditorTest { initText("text"); addBlockInlay(0, true); addBlockInlay(0, true); - List list1 = getEditor().getInlayModel().getBlockElementsInRange(0, 0); - List list2 = getEditor().getInlayModel().getBlockElementsForVisualLine(0, true); + List> list1 = getEditor().getInlayModel().getBlockElementsInRange(0, 0); + List> list2 = getEditor().getInlayModel().getBlockElementsForVisualLine(0, true); Collections.reverse(list2); assertEquals(list1, list2); } @@ -420,8 +420,8 @@ public class EditorInlayTest extends AbstractEditorTest { initText("text"); addBlockInlay(0, false); addBlockInlay(0, false); - List list1 = getEditor().getInlayModel().getBlockElementsInRange(0, 0); - List list2 = getEditor().getInlayModel().getBlockElementsForVisualLine(0, false); + List> list1 = getEditor().getInlayModel().getBlockElementsInRange(0, 0); + List> list2 = getEditor().getInlayModel().getBlockElementsForVisualLine(0, false); assertEquals(list1, list2); } @@ -448,7 +448,7 @@ public class EditorInlayTest extends AbstractEditorTest { public void testInlayForDisposedEditor() { Editor editor = EditorFactory.getInstance().createEditor(new DocumentImpl("")); - Inlay inlay = EditorTestUtil.addInlay(editor, 0); + Inlay inlay = EditorTestUtil.addInlay(editor, 0); assertTrue(inlay.isValid()); EditorFactory.getInstance().releaseEditor(editor); assertFalse(inlay.isValid()); diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/EditorStressTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/EditorStressTest.java index a7456901d10f..83ea2167c7f0 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/EditorStressTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/EditorStressTest.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.editor.impl; import com.intellij.openapi.command.WriteCommandAction; @@ -180,7 +180,7 @@ public class EditorStressTest extends AbstractEditorTest { foldingModel.runBatchFoldingOperation(foldingModel::clearFoldRegions); } } - + private static class ChangeBulkModeState implements Action { @Override public void perform(EditorEx editor, Random random) { @@ -188,7 +188,7 @@ public class EditorStressTest extends AbstractEditorTest { document.setInBulkUpdate(!document.isInBulkUpdate()); } } - + private static class ChangeEditorVisibility implements Action { @Override public void perform(EditorEx editor, Random random) { @@ -210,12 +210,14 @@ public class EditorStressTest extends AbstractEditorTest { private static class RemoveInlay implements Action { @Override public void perform(EditorEx editor, Random random) { - List inlays = editor.getInlayModel().getInlineElementsInRange(0, editor.getDocument().getTextLength()); - if (!inlays.isEmpty()) Disposer.dispose(inlays.get(random.nextInt(inlays.size()))); + List> inlays = editor.getInlayModel().getInlineElementsInRange(0, editor.getDocument().getTextLength()); + if (!inlays.isEmpty()) { + Disposer.dispose(inlays.get(random.nextInt(inlays.size()))); + } } } - private static class UpdateInlay implements Action { + private static final class UpdateInlay implements Action { @Override public void perform(EditorEx editor, Random random) { List> inlays = diff --git a/plugins/properties/src/com/intellij/lang/properties/psi/codeStyle/PropertiesLanguageCodeStyleSettingsProvider.java b/plugins/properties/src/com/intellij/lang/properties/psi/codeStyle/PropertiesLanguageCodeStyleSettingsProvider.java index 56443a0ccf7d..9ef39002bc19 100644 --- a/plugins/properties/src/com/intellij/lang/properties/psi/codeStyle/PropertiesLanguageCodeStyleSettingsProvider.java +++ b/plugins/properties/src/com/intellij/lang/properties/psi/codeStyle/PropertiesLanguageCodeStyleSettingsProvider.java @@ -13,8 +13,7 @@ import org.jetbrains.annotations.Nullable; import java.lang.reflect.Field; -public class PropertiesLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSettingsProvider { - +final class PropertiesLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSettingsProvider { @NotNull @Override public CodeStyleConfigurable createConfigurable(@NotNull CodeStyleSettings baseSettings,