mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Inline debugger: Don't soft-wrap after line debugger hints (IDEA-251309)
GitOrigin-RevId: 616877f04196579f57a506a302a5e4d22769cef1
This commit is contained in:
committed by
intellij-monorepo-bot
parent
2010602bc8
commit
b69b771884
@@ -71,13 +71,6 @@ public interface InlayModel {
|
||||
@Nullable
|
||||
<T extends EditorCustomElementRenderer> Inlay<T> addAfterLineEndElement(int offset, boolean relatesToPrecedingText, @NotNull T renderer);
|
||||
|
||||
/**
|
||||
* Same as {@link #addAfterLineEndElement(int, boolean, EditorCustomElementRenderer)},
|
||||
* but with an option to specify whether the inserted inlay should be the first or the last among other inlays on the same line
|
||||
*/
|
||||
@Nullable
|
||||
<T extends EditorCustomElementRenderer> Inlay<T> addAfterLineEndElement(int offset, boolean relatesToPrecedingText, boolean insertFirst, @NotNull T renderer);
|
||||
|
||||
/**
|
||||
* Returns a list of inline elements for a given offset range (both limits are inclusive). Returned list is sorted by offset.
|
||||
* Both visible and invisible (due to folding) elements are returned.
|
||||
|
||||
-9
@@ -46,15 +46,6 @@ final class InlayModelWindow implements InlayModel {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable <T extends EditorCustomElementRenderer> Inlay<T> addAfterLineEndElement(int offset,
|
||||
boolean relatesToPrecedingText,
|
||||
boolean insertFirst,
|
||||
@NotNull T renderer) {
|
||||
logUnsupported();
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<Inlay<?>> getInlineElementsInRange(int startOffset, int endOffset) {
|
||||
|
||||
+13
-2
@@ -10,12 +10,19 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
|
||||
final class AfterLineEndInlayImpl<R extends EditorCustomElementRenderer> extends InlayImpl<R, AfterLineEndInlayImpl<?>> {
|
||||
public final class AfterLineEndInlayImpl<R extends EditorCustomElementRenderer> extends InlayImpl<R, AfterLineEndInlayImpl<?>> {
|
||||
private static int ourGlobalCounter = 0;
|
||||
private final boolean mySoftWrappable;
|
||||
final int myOrder;
|
||||
|
||||
AfterLineEndInlayImpl(@NotNull EditorImpl editor, int offset, boolean relatesToPrecedingText, boolean insertFirst, @NotNull R renderer) {
|
||||
AfterLineEndInlayImpl(@NotNull EditorImpl editor,
|
||||
int offset,
|
||||
boolean relatesToPrecedingText,
|
||||
boolean insertFirst,
|
||||
boolean softWrappable,
|
||||
@NotNull R renderer) {
|
||||
super(editor, offset, relatesToPrecedingText, renderer);
|
||||
mySoftWrappable = softWrappable;
|
||||
//noinspection AssignmentToStaticFieldFromInstanceMethod
|
||||
int order = ourGlobalCounter++;
|
||||
myOrder = insertFirst ? -order : order;
|
||||
@@ -60,6 +67,10 @@ final class AfterLineEndInlayImpl<R extends EditorCustomElementRenderer> extends
|
||||
return new VisualPosition(position.line, position.column + 1 + order);
|
||||
}
|
||||
|
||||
public boolean isSoftWrappable() {
|
||||
return mySoftWrappable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeightInPixels() {
|
||||
return myEditor.getLineHeight();
|
||||
|
||||
@@ -34,8 +34,9 @@ public final class InlayModelImpl implements InlayModel, PrioritizedDocumentList
|
||||
private static final Comparator<BlockInlayImpl> BLOCK_ELEMENTS_COMPARATOR = Comparator.comparing((BlockInlayImpl i) -> i.getPlacement())
|
||||
.thenComparing(i -> i.getPlacement() == Inlay.Placement.ABOVE_LINE ? i.myPriority : -i.myPriority);
|
||||
private static final Comparator<AfterLineEndInlayImpl> AFTER_LINE_END_ELEMENTS_OFFSET_COMPARATOR =
|
||||
Comparator.comparingInt((AfterLineEndInlayImpl i) -> i.getOffset()).thenComparingInt(i -> i.myOrder);
|
||||
private static final Comparator<AfterLineEndInlayImpl> AFTER_LINE_END_ELEMENTS_COMPARATOR = Comparator.comparingInt(i -> i.myOrder);
|
||||
Comparator.comparingInt((AfterLineEndInlayImpl i) -> i.getOffset()).thenComparing(i -> !i.isSoftWrappable()).thenComparingInt(i -> i.myOrder);
|
||||
private static final Comparator<AfterLineEndInlayImpl> AFTER_LINE_END_ELEMENTS_COMPARATOR =
|
||||
Comparator.comparing((AfterLineEndInlayImpl i) -> !i.isSoftWrappable()).thenComparingInt(i -> i.myOrder);
|
||||
private static final Processor<InlayImpl> UPDATE_PROCESSOR = inlay -> {
|
||||
inlay.update();
|
||||
return true;
|
||||
@@ -150,18 +151,25 @@ public final class InlayModelImpl implements InlayModel, PrioritizedDocumentList
|
||||
public <T extends EditorCustomElementRenderer> @NotNull Inlay<T> addAfterLineEndElement(int offset,
|
||||
boolean relatesToPrecedingText,
|
||||
@NotNull T renderer) {
|
||||
return addAfterLineEndElement(offset, relatesToPrecedingText, false, renderer);
|
||||
return addAfterLineEndElement(offset, relatesToPrecedingText, false, true, renderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull <T extends EditorCustomElementRenderer> Inlay<T> addAfterLineEndElement(int offset,
|
||||
|
||||
public @NotNull <T extends EditorCustomElementRenderer> Inlay<T> addInlineDebuggerHint(int offset,
|
||||
boolean insertFirst,
|
||||
@NotNull T renderer) {
|
||||
return addAfterLineEndElement(offset, false, insertFirst, false, renderer);
|
||||
}
|
||||
|
||||
private @NotNull <T extends EditorCustomElementRenderer> Inlay<T> addAfterLineEndElement(int offset,
|
||||
boolean relatesToPrecedingText,
|
||||
boolean insertFirst,
|
||||
boolean softWrappable,
|
||||
@NotNull T renderer) {
|
||||
EditorImpl.assertIsDispatchThread();
|
||||
Document document = myEditor.getDocument();
|
||||
offset = Math.max(0, Math.min(document.getTextLength(), offset));
|
||||
AfterLineEndInlayImpl<T> inlay = new AfterLineEndInlayImpl<>(myEditor, offset, relatesToPrecedingText, insertFirst, renderer);
|
||||
AfterLineEndInlayImpl<T> inlay = new AfterLineEndInlayImpl<>(myEditor, offset, relatesToPrecedingText, insertFirst, softWrappable, renderer);
|
||||
notifyAdded(inlay);
|
||||
return inlay;
|
||||
}
|
||||
|
||||
+5
@@ -4,6 +4,7 @@ package com.intellij.openapi.editor.impl.view;
|
||||
import com.intellij.openapi.editor.FoldRegion;
|
||||
import com.intellij.openapi.editor.Inlay;
|
||||
import com.intellij.openapi.editor.ex.util.EditorUtil;
|
||||
import com.intellij.openapi.editor.impl.AfterLineEndInlayImpl;
|
||||
import com.intellij.openapi.editor.impl.softwrap.WrapElementIterator;
|
||||
import com.intellij.util.DocumentUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -83,6 +84,10 @@ public final class WrapElementMeasuringIterator extends WrapElementIterator {
|
||||
int width = 0;
|
||||
while (afterLineEndInlayIndex < afterLineEndInlays.size()) {
|
||||
Inlay<?> inlay = afterLineEndInlays.get(afterLineEndInlayIndex);
|
||||
if (inlay instanceof AfterLineEndInlayImpl && !((AfterLineEndInlayImpl)inlay).isSoftWrappable()) {
|
||||
afterLineEndInlayIndex++;
|
||||
continue;
|
||||
}
|
||||
int offset = inlay.getOffset();
|
||||
if (offset < startOffset || offset > endOffset) break;
|
||||
width += inlay.getWidthInPixels();
|
||||
|
||||
-8
@@ -40,14 +40,6 @@ final class TextComponentInlayModel implements InlayModel {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable <T extends EditorCustomElementRenderer> Inlay<T> addAfterLineEndElement(int offset,
|
||||
boolean relatesToPrecedingText,
|
||||
boolean insertFirst,
|
||||
@NotNull T renderer) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<Inlay<?>> getInlineElementsInRange(int startOffset, int endOffset) {
|
||||
|
||||
+2
-3
@@ -1,8 +1,6 @@
|
||||
// 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.xdebugger.impl.inline;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfoType;
|
||||
import com.intellij.facet.ModifiableFacetModel;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.EditorCustomElementRenderer;
|
||||
@@ -11,6 +9,7 @@ import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.editor.colors.FontPreferences;
|
||||
import com.intellij.openapi.editor.impl.ComplementaryFontsRegistry;
|
||||
import com.intellij.openapi.editor.impl.FontInfo;
|
||||
import com.intellij.openapi.editor.impl.InlayModelImpl;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.fileEditor.FileEditor;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
@@ -111,7 +110,7 @@ public final class XDebuggerInlayUtil {
|
||||
return false;
|
||||
};
|
||||
InlineDebugRenderer renderer = new InlineDebugRenderer(variablePresentation, valueNode, view, isOnExecutionLine, onClick);
|
||||
Inlay<InlineDebugRenderer> inlay = e.getInlayModel().addAfterLineEndElement(offset, false, customNode, renderer);
|
||||
Inlay<InlineDebugRenderer> inlay = ((InlayModelImpl)e.getInlayModel()).addInlineDebuggerHint(offset, customNode, renderer);
|
||||
if (customNode) {
|
||||
((InlineWatchNodeImpl)valueNode).inlayCreated(inlay);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user