mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
GitOrigin-RevId: 630092d3d1005bd814bed89cdc82cf871ed0463e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
e855f5a4f0
commit
ab1d807794
@@ -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;
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ public interface InlayModel {
|
||||
* (higher priority ones appear first). Both visible and invisible (due to folding) elements are returned.
|
||||
*/
|
||||
@NotNull
|
||||
List<Inlay> getBlockElementsInRange(int startOffset, int endOffset);
|
||||
List<Inlay<?>> 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<Inlay> getBlockElementsForVisualLine(int visualLine, boolean above);
|
||||
List<Inlay<?>> 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<Inlay> getAfterLineEndElementsInRange(int startOffset, int endOffset);
|
||||
List<Inlay<?>> 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)
|
||||
|
||||
+2
-3
@@ -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,
|
||||
|
||||
+2
-3
@@ -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,
|
||||
|
||||
+2
-2
@@ -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";
|
||||
|
||||
+2
-4
@@ -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",
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<Inlay<EditorCustomElementRenderer>>) {
|
||||
private fun closeInlays(inlineElements: List<Inlay<*>>) {
|
||||
for (inlay in inlineElements) {
|
||||
if (inlay.renderer !is LinearOrderInlayRenderer<*>) return
|
||||
Disposer.dispose(inlay)
|
||||
|
||||
+9
-9
@@ -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<Inlay> getInlineElementsInRange(int startOffset, int endOffset) {
|
||||
public List<Inlay<?>> getInlineElementsInRange(int startOffset, int endOffset) {
|
||||
logUnsupported();
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<Inlay> getBlockElementsInRange(int startOffset, int endOffset) {
|
||||
public List<Inlay<?>> getBlockElementsInRange(int startOffset, int endOffset) {
|
||||
logUnsupported();
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<Inlay> getBlockElementsForVisualLine(int visualLine, boolean above) {
|
||||
public List<Inlay<?>> 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<Inlay> getAfterLineEndElementsInRange(int startOffset, int endOffset) {
|
||||
public List<Inlay<?>> getAfterLineEndElementsInRange(int startOffset, int endOffset) {
|
||||
logUnsupported();
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<Inlay> getAfterLineEndElementsForLogicalLine(int logicalLine) {
|
||||
public List<Inlay<?>> getAfterLineEndElementsForLogicalLine(int logicalLine) {
|
||||
logUnsupported();
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@@ -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<Inlay> inlays = editor.getInlayModel().getInlineElementsInRange(offset, offset);
|
||||
List<Inlay<?>> inlays = editor.getInlayModel().getInlineElementsInRange(offset, offset);
|
||||
if (!inlays.isEmpty()) {
|
||||
VisualPosition inlaysStart = editor.offsetToVisualPosition(offset);
|
||||
if (inlaysStart.line == visualPosition.line) {
|
||||
|
||||
+4
-4
@@ -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<R extends EditorCustomElementRenderer> extends InlayImpl<R, AfterLineEndInlayImpl> {
|
||||
final class AfterLineEndInlayImpl<R extends EditorCustomElementRenderer> extends InlayImpl<R, AfterLineEndInlayImpl<?>> {
|
||||
private static int ourGlobalCounter = 0;
|
||||
final int myOrder;
|
||||
|
||||
@@ -21,7 +21,7 @@ class AfterLineEndInlayImpl<R extends EditorCustomElementRenderer> extends Inlay
|
||||
}
|
||||
|
||||
@Override
|
||||
RangeMarkerTree<AfterLineEndInlayImpl> getTree() {
|
||||
RangeMarkerTree<AfterLineEndInlayImpl<?>> getTree() {
|
||||
return myEditor.getInlayModel().myAfterLineEndElementsTree;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ class AfterLineEndInlayImpl<R extends EditorCustomElementRenderer> extends Inlay
|
||||
int lineEndOffset = myEditor.getDocument().getLineEndOffset(logicalLine);
|
||||
VisualPosition position = myEditor.offsetToVisualPosition(lineEndOffset, true, true);
|
||||
if (myEditor.getFoldingModel().isOffsetCollapsed(lineEndOffset)) return position;
|
||||
List<Inlay> inlays = myEditor.getInlayModel().getAfterLineEndElementsForLogicalLine(logicalLine);
|
||||
List<Inlay<?>> inlays = myEditor.getInlayModel().getAfterLineEndElementsForLogicalLine(logicalLine);
|
||||
int order = inlays.indexOf(this);
|
||||
return new VisualPosition(position.line, position.column + 1 + order);
|
||||
}
|
||||
|
||||
@@ -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<R extends EditorCustomElementRenderer> extends InlayImpl<R, BlockInlayImpl> implements IntSupplier {
|
||||
final class BlockInlayImpl<R extends EditorCustomElementRenderer> extends InlayImpl<R, BlockInlayImpl<?>> implements IntSupplier {
|
||||
final boolean myShowAbove;
|
||||
final int myPriority;
|
||||
private int myHeightInPixels;
|
||||
@@ -31,7 +31,7 @@ class BlockInlayImpl<R extends EditorCustomElementRenderer> extends InlayImpl<R,
|
||||
}
|
||||
|
||||
@Override
|
||||
MarkerTreeWithPartialSums<BlockInlayImpl> getTree() {
|
||||
MarkerTreeWithPartialSums<BlockInlayImpl<?>> getTree() {
|
||||
return myEditor.getInlayModel().myBlockElementsTree;
|
||||
}
|
||||
|
||||
@@ -56,17 +56,17 @@ class BlockInlayImpl<R extends EditorCustomElementRenderer> extends InlayImpl<R,
|
||||
Point getPosition() {
|
||||
int visualLine = myEditor.offsetToVisualLine(getOffset());
|
||||
int y = myEditor.visualLineToY(visualLine);
|
||||
List<Inlay> allInlays = myEditor.getInlayModel().getBlockElementsForVisualLine(visualLine, myShowAbove);
|
||||
List<Inlay<?>> 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();
|
||||
}
|
||||
|
||||
+2
-2
@@ -2199,7 +2199,7 @@ final class EditorGutterComponentImpl extends EditorGutterComponentEx implements
|
||||
}
|
||||
if (myHasInlaysWithGutterIcons) {
|
||||
if (p.y < startY) {
|
||||
List<Inlay> inlays = myEditor.getInlayModel().getBlockElementsForVisualLine(line, true);
|
||||
List<Inlay<?>> 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<Inlay> inlays = myEditor.getInlayModel().getBlockElementsForVisualLine(line, false);
|
||||
List<Inlay<?>> inlays = myEditor.getInlayModel().getBlockElementsForVisualLine(line, false);
|
||||
int yDiff = p.y - endY;
|
||||
for (Inlay inlay : inlays) {
|
||||
int height = inlay.getHeightInPixels();
|
||||
|
||||
@@ -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<R extends EditorCustomElementRenderer, T extends InlayImpl> extends RangeMarkerWithGetterImpl implements Inlay<R> {
|
||||
abstract class InlayImpl<R extends EditorCustomElementRenderer, T extends InlayImpl<?, ?>> extends RangeMarkerWithGetterImpl implements Inlay<R> {
|
||||
static final Key<Integer> OFFSET_BEFORE_DISPOSAL = Key.create("inlay.offset.before.disposal");
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -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<Inlay> 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<Listener> myDispatcher = EventDispatcher.create(Listener.class);
|
||||
|
||||
private final List<InlayImpl> myInlaysInvalidatedOnMove = new ArrayList<>();
|
||||
final RangeMarkerTree<InlineInlayImpl> myInlineElementsTree;
|
||||
final MarkerTreeWithPartialSums<BlockInlayImpl> myBlockElementsTree;
|
||||
final RangeMarkerTree<AfterLineEndInlayImpl> myAfterLineEndElementsTree;
|
||||
final RangeMarkerTree<InlineInlayImpl<?>> myInlineElementsTree;
|
||||
final MarkerTreeWithPartialSums<BlockInlayImpl<?>> myBlockElementsTree;
|
||||
final RangeMarkerTree<AfterLineEndInlayImpl<?>> 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 <T extends EditorCustomElementRenderer> Inlay<T> addBlockElement(int offset,
|
||||
boolean relatesToPrecedingText,
|
||||
boolean showAbove,
|
||||
int priority,
|
||||
@NotNull T renderer) {
|
||||
public <T extends EditorCustomElementRenderer> @NotNull Inlay<T> 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<T> inlay = new BlockInlayImpl<>(myEditor, offset, relatesToPrecedingText, showAbove, priority, renderer);
|
||||
@@ -147,11 +146,10 @@ public class InlayModelImpl implements InlayModel, PrioritizedDocumentListener,
|
||||
return inlay;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public <T extends EditorCustomElementRenderer> Inlay<T> addAfterLineEndElement(int offset,
|
||||
boolean relatesToPrecedingText,
|
||||
@NotNull T renderer) {
|
||||
public <T extends EditorCustomElementRenderer> @NotNull Inlay<T> 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<Inlay<?>> 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<Inlay> getBlockElementsInRange(int startOffset, int endOffset) {
|
||||
List<BlockInlayImpl> range =
|
||||
public List<Inlay<?>> getBlockElementsInRange(int startOffset, int endOffset) {
|
||||
List<BlockInlayImpl<?>> 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 <T> List<Inlay<? extends T>> getBlockElementsInRange(int startOffset, int endOffset, @NotNull Class<T> type) {
|
||||
List<BlockInlayImpl> range = getElementsInRange(myBlockElementsTree, startOffset, endOffset, inlay -> type.isInstance(inlay.myRenderer),
|
||||
List<BlockInlayImpl<?>> 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<Inlay> getBlockElementsForVisualLine(int visualLine, boolean above) {
|
||||
public List<Inlay<?>> getBlockElementsForVisualLine(int visualLine, boolean above) {
|
||||
int visibleLineCount = myEditor.getVisibleLineCount();
|
||||
if (visualLine < 0 || visualLine >= visibleLineCount || myBlockElementsTree.size() == 0) return Collections.emptyList();
|
||||
List<BlockInlayImpl> 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<Inlay> inlays = getBlockElementsForVisualLine(visualLine, true);
|
||||
List<Inlay<?>> 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<Inlay> inlays = getBlockElementsForVisualLine(visualLine, false);
|
||||
List<Inlay<?>> 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<Inlay> getAfterLineEndElementsInRange(int startOffset, int endOffset) {
|
||||
public List<Inlay<?>> getAfterLineEndElementsInRange(int startOffset, int endOffset) {
|
||||
if (!hasAfterLineEndElements()) return Collections.emptyList();
|
||||
List<AfterLineEndInlayImpl> range =
|
||||
List<AfterLineEndInlayImpl<?>> 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<InlineInlayImpl> {
|
||||
private class InlineElementsTree extends HardReferencingRangeMarkerTree<InlineInlayImpl<?>> {
|
||||
InlineElementsTree(@NotNull Document document) {
|
||||
super(document);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected Node<InlineInlayImpl> createNewNode(@NotNull InlineInlayImpl key, int start, int end,
|
||||
protected Node<InlineInlayImpl<?>> createNewNode(@NotNull InlineInlayImpl key, int start, int end,
|
||||
boolean greedyToLeft, boolean greedyToRight, boolean stickingToRight, int layer) {
|
||||
return new Node<InlineInlayImpl>(this, key, start, end, greedyToLeft, greedyToRight, stickingToRight) {
|
||||
return new Node<InlineInlayImpl<?>>(this, key, start, end, greedyToLeft, greedyToRight, stickingToRight) {
|
||||
@Override
|
||||
void addIntervalsFrom(@NotNull IntervalNode<InlineInlayImpl> otherNode) {
|
||||
void addIntervalsFrom(@NotNull IntervalNode<InlineInlayImpl<?>> otherNode) {
|
||||
super.addIntervalsFrom(otherNode);
|
||||
if (myPutMergedIntervalsAtBeginning) {
|
||||
List<Getter<InlineInlayImpl>> added = ContainerUtil.subList(intervals, intervals.size() - otherNode.intervals.size());
|
||||
List<Getter<InlineInlayImpl>> addedCopy = new ArrayList<>(added);
|
||||
List<Getter<InlineInlayImpl<?>>> added = ContainerUtil.subList(intervals, intervals.size() - otherNode.intervals.size());
|
||||
List<Getter<InlineInlayImpl<?>>> 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<BlockInlayImpl> {
|
||||
private final class BlockElementsTree extends MarkerTreeWithPartialSums<BlockInlayImpl<?>> {
|
||||
BlockElementsTree(@NotNull Document document) {
|
||||
super(document);
|
||||
}
|
||||
@@ -564,7 +561,7 @@ public class InlayModelImpl implements InlayModel, PrioritizedDocumentListener,
|
||||
}
|
||||
}
|
||||
|
||||
private class AfterLineEndElementTree extends HardReferencingRangeMarkerTree<AfterLineEndInlayImpl> {
|
||||
private class AfterLineEndElementTree extends HardReferencingRangeMarkerTree<AfterLineEndInlayImpl<?>> {
|
||||
AfterLineEndElementTree(@NotNull Document document) {
|
||||
super(document);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
|
||||
class InlineInlayImpl<R extends EditorCustomElementRenderer> extends InlayImpl<R, InlineInlayImpl> {
|
||||
final class InlineInlayImpl<R extends EditorCustomElementRenderer> extends InlayImpl<R, InlineInlayImpl<?>> {
|
||||
private static final Key<Integer> ORDER_BEFORE_DISPOSAL = Key.create("inlay.order.before.disposal");
|
||||
|
||||
InlineInlayImpl(@NotNull EditorImpl editor,
|
||||
@@ -24,7 +24,7 @@ class InlineInlayImpl<R extends EditorCustomElementRenderer> extends InlayImpl<R
|
||||
}
|
||||
|
||||
@Override
|
||||
RangeMarkerTree<InlineInlayImpl> getTree() {
|
||||
RangeMarkerTree<InlineInlayImpl<?>> getTree() {
|
||||
return myEditor.getInlayModel().myInlineElementsTree;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ class InlineInlayImpl<R extends EditorCustomElementRenderer> extends InlayImpl<R
|
||||
public void dispose() {
|
||||
if (isValid()) {
|
||||
int offset = getOffset();
|
||||
List<Inlay> inlays = myEditor.getInlayModel().getInlineElementsInRange(offset, offset);
|
||||
List<Inlay<?>> inlays = myEditor.getInlayModel().getInlineElementsInRange(offset, offset);
|
||||
putUserData(ORDER_BEFORE_DISPOSAL, inlays.indexOf(this));
|
||||
}
|
||||
super.dispose();
|
||||
@@ -82,7 +82,7 @@ class InlineInlayImpl<R extends EditorCustomElementRenderer> extends InlayImpl<R
|
||||
public VisualPosition getVisualPosition() {
|
||||
int offset = getOffset();
|
||||
VisualPosition pos = myEditor.offsetToVisualPosition(offset);
|
||||
List<Inlay> inlays = myEditor.getInlayModel().getInlineElementsInRange(offset, offset);
|
||||
List<Inlay<?>> inlays = myEditor.getInlayModel().getInlineElementsInRange(offset, offset);
|
||||
int order = inlays.indexOf(this);
|
||||
return new VisualPosition(pos.line, pos.column + order, true);
|
||||
}
|
||||
|
||||
+8
-10
@@ -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<Inlay> inlays = myView.getEditor().getInlayModel().getAfterLineEndElementsForLogicalLine(logicalLine);
|
||||
List<Inlay<?>> 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<Inlay> inlays = myView.getEditor().getInlayModel().getAfterLineEndElementsForLogicalLine(logicalLine);
|
||||
List<Inlay<?>> inlays = myView.getEditor().getInlayModel().getAfterLineEndElementsForLogicalLine(logicalLine);
|
||||
int inlaysWidth = 0;
|
||||
int inlayCount = 0;
|
||||
for (Inlay inlay : inlays) {
|
||||
|
||||
@@ -426,7 +426,7 @@ public class EditorPainter implements TextDrawingCallback {
|
||||
paintVirtualSelectionIfNecessary(visualLine, columnStart, x, y);
|
||||
myTextDrawingTasks.add(g -> {
|
||||
int logicalLine = myDocument.getLineNumber(offset);
|
||||
List<Inlay> inlays = myEditor.getInlayModel().getAfterLineEndElementsForLogicalLine(logicalLine);
|
||||
List<Inlay<?>> 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<Inlay> inlaysAbove = visLinesIterator.getBlockInlaysAbove();
|
||||
List<Inlay<?>> 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<Inlay> inlaysBelow = visLinesIterator.getBlockInlaysBelow();
|
||||
List<Inlay<?>> inlaysBelow = visLinesIterator.getBlockInlaysBelow();
|
||||
if (!inlaysBelow.isEmpty()) {
|
||||
TextAttributes attributes = getInlayAttributes(visualLine + 1);
|
||||
for (Inlay inlay : inlaysBelow) {
|
||||
|
||||
+3
-4
@@ -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<VisualLineFragmentsIterator.Fragment> {
|
||||
|
||||
final class VisualLineFragmentsIterator implements Iterator<VisualLineFragmentsIterator.Fragment> {
|
||||
@NotNull
|
||||
static Iterable<Fragment> create(@NotNull EditorView view, int offset, boolean beforeSoftWrap) {
|
||||
return create(view, offset, beforeSoftWrap, false);
|
||||
@@ -60,7 +59,7 @@ class VisualLineFragmentsIterator implements Iterator<VisualLineFragmentsIterato
|
||||
private int mySegmentEndOffset;
|
||||
private int myCurrentFoldRegionIndex;
|
||||
private Iterator<LineLayout.VisualFragment> myFragmentIterator;
|
||||
private List<Inlay> myInlays;
|
||||
private List<Inlay<?>> myInlays;
|
||||
private int myCurrentInlayIndex;
|
||||
private float myCurrentX;
|
||||
private int myCurrentVisualColumn;
|
||||
|
||||
+10
-10
@@ -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<? extends SoftWrap> mySoftWraps;
|
||||
private final int myLineHeight;
|
||||
|
||||
private final List<Inlay> myInlaysAbove = new ArrayList<>();
|
||||
private final List<Inlay> myInlaysBelow = new ArrayList<>();
|
||||
private final List<Inlay<?>> myInlaysAbove = new ArrayList<>();
|
||||
private final List<Inlay<?>> 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<Inlay> getBlockInlaysAbove() {
|
||||
public List<Inlay<?>> getBlockInlaysAbove() {
|
||||
checkEnd();
|
||||
setInlays();
|
||||
return myInlaysAbove;
|
||||
}
|
||||
|
||||
public List<Inlay> getBlockInlaysBelow() {
|
||||
public List<Inlay<?>> getBlockInlaysBelow() {
|
||||
checkEnd();
|
||||
setInlays();
|
||||
return myInlaysBelow;
|
||||
@@ -169,9 +169,9 @@ public class VisualLinesIterator {
|
||||
myInlaysAbove.clear();
|
||||
myInlaysBelow.clear();
|
||||
setNextLocation();
|
||||
List<Inlay> inlays = myEditor.getInlayModel()
|
||||
List<Inlay<?>> 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;
|
||||
}
|
||||
|
||||
+5
-5
@@ -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<Inlay> inlineInlays;
|
||||
private final List<Inlay> afterLineEndInlays;
|
||||
private final List<Inlay<?>> inlineInlays;
|
||||
private final List<Inlay<?>> 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();
|
||||
|
||||
+9
-9
@@ -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 <T extends EditorCustomElementRenderer> Inlay<T> addInlineElement(int offset,
|
||||
@@ -42,19 +42,19 @@ class TextComponentInlayModel implements InlayModel {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<Inlay> getInlineElementsInRange(int startOffset, int endOffset) {
|
||||
public List<Inlay<?>> getInlineElementsInRange(int startOffset, int endOffset) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<Inlay> getBlockElementsInRange(int startOffset, int endOffset) {
|
||||
public List<Inlay<?>> getBlockElementsInRange(int startOffset, int endOffset) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<Inlay> getBlockElementsForVisualLine(int visualLine, boolean above) {
|
||||
public List<Inlay<?>> 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<Inlay> getAfterLineEndElementsInRange(int startOffset, int endOffset) {
|
||||
public List<Inlay<?>> getAfterLineEndElementsInRange(int startOffset, int endOffset) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<Inlay> getAfterLineEndElementsForLogicalLine(int logicalLine) {
|
||||
public List<Inlay<?>> getAfterLineEndElementsForLogicalLine(int logicalLine) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
||||
+19
-19
@@ -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<Inlay> list1 = getEditor().getInlayModel().getBlockElementsInRange(0, 0);
|
||||
List<Inlay> list2 = getEditor().getInlayModel().getBlockElementsForVisualLine(0, true);
|
||||
List<Inlay<?>> list1 = getEditor().getInlayModel().getBlockElementsInRange(0, 0);
|
||||
List<Inlay<?>> 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<Inlay> list1 = getEditor().getInlayModel().getBlockElementsInRange(0, 0);
|
||||
List<Inlay> list2 = getEditor().getInlayModel().getBlockElementsForVisualLine(0, false);
|
||||
List<Inlay<?>> list1 = getEditor().getInlayModel().getBlockElementsInRange(0, 0);
|
||||
List<Inlay<?>> 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());
|
||||
|
||||
+8
-6
@@ -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<Inlay> inlays = editor.getInlayModel().getInlineElementsInRange(0, editor.getDocument().getTextLength());
|
||||
if (!inlays.isEmpty()) Disposer.dispose(inlays.get(random.nextInt(inlays.size())));
|
||||
List<Inlay<?>> 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<Inlay<? extends MyInlayRenderer>> inlays =
|
||||
|
||||
+1
-2
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user