IJPL-161819 remove magic wand caret

GitOrigin-RevId: f89323e2548e0a5c45f733b4c3a87be6cfddb466
This commit is contained in:
Alexandr Trushev
2024-09-09 14:59:14 +02:00
committed by intellij-monorepo-bot
parent 4e0df68241
commit df4b25fc79
2 changed files with 6 additions and 76 deletions

View File

@@ -64,7 +64,6 @@ import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.EmptyIcon;
import com.intellij.util.ui.UIUtil;
import com.intellij.util.ui.accessibility.AccessibleContextUtil;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
@@ -126,17 +125,6 @@ public final class IntentionHintComponent implements Disposable, ScrollAwareHint
DynamicPlugins.INSTANCE.onPluginUnload(this, () -> Disposer.dispose(this));
}
private IntentionHintComponent(@NotNull Project project,
@NotNull Editor editor,
@NotNull Icon icon) {
myEditor = editor;
myPopup = null;
myLightBulbPanel = new MagicWandPanel(project, editor, icon);
myComponentHint = new MyComponentHint(myLightBulbPanel, true);
EditorUtil.disposeWithEditor(myEditor, this);
DynamicPlugins.INSTANCE.onPluginUnload(this, () -> Disposer.dispose(this));
}
@RequiresEdt
public static @NotNull IntentionHintComponent showIntentionHint(@NotNull Project project,
@NotNull PsiFile file,
@@ -184,16 +172,6 @@ public final class IntentionHintComponent implements Disposable, ScrollAwareHint
return component;
}
@ApiStatus.Experimental
@ApiStatus.Internal
public static @NotNull IntentionHintComponent showIntentionHint2(@NotNull Project project,
@NotNull Editor editor,
@NotNull Icon icon) {
IntentionHintComponent component = new IntentionHintComponent(project, editor, icon);
component.showIntentionHintImpl2();
return component;
}
public boolean isVisible() {
return myLightBulbPanel.isVisible();
}
@@ -271,20 +249,6 @@ public final class IntentionHintComponent implements Disposable, ScrollAwareHint
}
}
private void showIntentionHintImpl2() {
int offset = myEditor.getCaretModel().getOffset();
myComponentHint.setShouldDelay(false);
Point position = LightBulbUtil.getPosition2(myEditor);
QuestionAction action = new QuestionAction() {
@Override
public boolean execute() {
return false;
}
};
int flags = HintManager.UPDATE_BY_SCROLLING | HintManager.HIDE_IF_OUT_OF_EDITOR | HintManager.DONT_CONSUME_ESCAPE;
HintManagerImpl.showQuestionHint(myEditor, position, offset, offset, myComponentHint, flags, action, HintManager.ABOVE);
}
@TestOnly
public LightweightHint getComponentHint() {
return myComponentHint;
@@ -369,17 +333,11 @@ public final class IntentionHintComponent implements Disposable, ScrollAwareHint
}
private static final class MyComponentHint extends LightweightHint {
private final boolean isNotVisibleHint;
private boolean myVisible;
private boolean myShouldDelay;
private MyComponentHint(JComponent component) {
this(component, false);
}
private MyComponentHint(JComponent component, boolean isNotVisibleHint) {
super(component);
this.isNotVisibleHint = isNotVisibleHint;
}
@Override
@@ -407,9 +365,6 @@ public final class IntentionHintComponent implements Disposable, ScrollAwareHint
@Override
public boolean isVisible() {
if (isNotVisibleHint) {
return false;
}
return myVisible || super.isVisible();
}
@@ -473,14 +428,6 @@ public final class IntentionHintComponent implements Disposable, ScrollAwareHint
: getPositionMultiLine(editor);
}
private static Point getPosition2(Editor editor) {
VisualPosition vp = editor.getCaretModel().getPrimaryCaret().getVisualPosition();
vp = new VisualPosition(vp.getLine() > 0 ? vp.getLine() - 1 : vp.getLine(), vp.getColumn());
Point point = editor.visualPositionToXY(vp);
point = new Point(point.x-4, point.y+11);
return SwingUtilities.convertPoint(editor.getContentComponent(), point, getLayeredPane(editor));
}
private static @NotNull Point getPositionOneLine(Editor editor) {
JComponent convertComponent = editor.getContentComponent();
@@ -558,14 +505,14 @@ public final class IntentionHintComponent implements Disposable, ScrollAwareHint
}
/** The light bulb icon, optionally surrounded by a border. */
private class LightBulbPanel extends JPanel {
private final class LightBulbPanel extends JPanel {
private static final Icon ourInactiveArrowIcon = IconManager.getInstance().createEmptyIcon(AllIcons.General.ArrowDown);
private final RowIcon myHighlightedIcon;
private final RowIcon myInactiveIcon;
private final JLabel myIconLabel;
LightBulbPanel(@NotNull Project project, @Nullable PsiFile file, @NotNull Editor editor, @NotNull Icon smartTagIcon) {
LightBulbPanel(@NotNull Project project, @NotNull PsiFile file, @NotNull Editor editor, @NotNull Icon smartTagIcon) {
setLayout(new BorderLayout());
setOpaque(false);
@@ -575,9 +522,7 @@ public final class IntentionHintComponent implements Disposable, ScrollAwareHint
myIconLabel = new JLabel(myInactiveIcon);
myIconLabel.setOpaque(false);
if (file != null) {
myIconLabel.addMouseListener(new LightBulbMouseListener(project, file));
}
myIconLabel.addMouseListener(new LightBulbMouseListener(project, file));
AccessibleContextUtil.setName(myIconLabel, UIBundle.message("light.bulb.panel.accessible.name"));
add(myIconLabel, BorderLayout.CENTER);
@@ -595,14 +540,14 @@ public final class IntentionHintComponent implements Disposable, ScrollAwareHint
}
@RequiresEdt
protected void onMouseExit() {
private void onMouseExit() {
if (!myPopup.isVisible()) {
myIconLabel.setIcon(myInactiveIcon);
setBorder(LightBulbUtil.createInactiveBorder(myEditor));
}
}
protected void onMouseEnter() {
private void onMouseEnter() {
myIconLabel.setIcon(myHighlightedIcon);
setBorder(LightBulbUtil.createActiveBorder(myEditor));
@@ -614,20 +559,6 @@ public final class IntentionHintComponent implements Disposable, ScrollAwareHint
}
}
private final class MagicWandPanel extends LightBulbPanel {
MagicWandPanel(@NotNull Project project, @NotNull Editor editor, @NotNull Icon smartTagIcon) {
super(project, null, editor, smartTagIcon);
}
@Override
protected void onMouseExit() {
}
@Override
protected void onMouseEnter() {
}
}
// IDEA-313550: Intention light bulb border is calculated wrong
private final class LightBulbMouseListener extends MouseAdapter {
private final @NotNull Project myProject;

View File

@@ -642,8 +642,7 @@ public class HintManagerImpl extends HintManager {
showQuestionHint(editor, p, offset1, offset2, hint, action, constraint);
}
@ApiStatus.Internal
public static void showQuestionHint(final @NotNull Editor editor,
private static void showQuestionHint(final @NotNull Editor editor,
final @NotNull Point p,
final int offset1,
final int offset2,