mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-144791 Smart Step Into (Shift+F7): Focus issue in debugger
This commit is contained in:
@@ -26,7 +26,6 @@ import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.fileEditor.TextEditor;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.ui.popup.list.ListPopupImpl;
|
||||
import com.intellij.xdebugger.impl.actions.XDebuggerActions;
|
||||
@@ -87,8 +86,7 @@ public abstract class JvmSmartStepIntoHandler {
|
||||
}
|
||||
});
|
||||
highlightTarget(popupStep, firstTarget);
|
||||
final RelativePoint point = DebuggerUIUtil.calcPopupLocation(editor, position.getLine());
|
||||
popup.show(point);
|
||||
DebuggerUIUtil.showPopupForEditorLine(popup, editor, position.getLine());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ public class XDebuggerUtilImpl extends XDebuggerUtil {
|
||||
else {
|
||||
List<? extends XLineBreakpointType<P>.XLineBreakpointVariant> variants = type.computeVariants(project, position);
|
||||
if (!variants.isEmpty() && editor != null) {
|
||||
RelativePoint relativePoint = DebuggerUIUtil.calcPopupLocation(editor, line);
|
||||
RelativePoint relativePoint = DebuggerUIUtil.getPositionForPopup(editor, line);
|
||||
if (variants.size() > 1 && relativePoint != null) {
|
||||
final AsyncResult<XLineBreakpoint> res = new AsyncResult<XLineBreakpoint>();
|
||||
class MySelectionListener implements ListSelectionListener {
|
||||
|
||||
+16
-13
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,13 +16,14 @@
|
||||
package com.intellij.xdebugger.impl.actions.handlers;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.fileEditor.FileEditor;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.fileEditor.TextEditor;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.ui.popup.ListPopup;
|
||||
import com.intellij.openapi.ui.popup.PopupStep;
|
||||
import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.xdebugger.XDebugSession;
|
||||
import com.intellij.xdebugger.XSourcePosition;
|
||||
import com.intellij.xdebugger.impl.actions.XDebuggerSuspendedActionHandler;
|
||||
@@ -46,20 +47,21 @@ public class XDebuggerSmartStepIntoHandler extends XDebuggerSuspendedActionHandl
|
||||
|
||||
@Override
|
||||
protected void perform(@NotNull XDebugSession session, DataContext dataContext) {
|
||||
final XSmartStepIntoHandler<?> handler = session.getDebugProcess().getSmartStepIntoHandler();
|
||||
final XSourcePosition position = session.getTopFramePosition();
|
||||
XSmartStepIntoHandler<?> handler = session.getDebugProcess().getSmartStepIntoHandler();
|
||||
XSourcePosition position = session.getTopFramePosition();
|
||||
if (position == null || handler == null) return;
|
||||
|
||||
final FileEditor editor = FileEditorManager.getInstance(session.getProject()).getSelectedEditor(position.getFile());
|
||||
if (!(editor instanceof TextEditor)) return;
|
||||
|
||||
final RelativePoint relativePoint = DebuggerUIUtil.calcPopupLocation(((TextEditor)editor).getEditor(), position.getLine());
|
||||
doSmartStepInto(handler, position, session, relativePoint);
|
||||
FileEditor editor = FileEditorManager.getInstance(session.getProject()).getSelectedEditor(position.getFile());
|
||||
if (editor instanceof TextEditor) {
|
||||
doSmartStepInto(handler, position, session, ((TextEditor)editor).getEditor());
|
||||
}
|
||||
}
|
||||
|
||||
private static <V extends XSmartStepIntoVariant> void doSmartStepInto(final XSmartStepIntoHandler<V> handler,
|
||||
XSourcePosition position, final XDebugSession session, RelativePoint relativePoint) {
|
||||
final List<V> variants = handler.computeSmartStepVariants(position);
|
||||
XSourcePosition position,
|
||||
final XDebugSession session,
|
||||
Editor editor) {
|
||||
List<V> variants = handler.computeSmartStepVariants(position);
|
||||
if (variants.isEmpty()) {
|
||||
session.stepInto();
|
||||
return;
|
||||
@@ -69,7 +71,7 @@ public class XDebuggerSmartStepIntoHandler extends XDebuggerSuspendedActionHandl
|
||||
return;
|
||||
}
|
||||
|
||||
JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<V>(handler.getPopupTitle(position), variants) {
|
||||
ListPopup popup = JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<V>(handler.getPopupTitle(position), variants) {
|
||||
@Override
|
||||
public Icon getIconFor(V aValue) {
|
||||
return aValue.getIcon();
|
||||
@@ -86,6 +88,7 @@ public class XDebuggerSmartStepIntoHandler extends XDebuggerSuspendedActionHandl
|
||||
session.smartStepInto(handler, selectedValue);
|
||||
return FINAL_CHOICE;
|
||||
}
|
||||
}).show(relativePoint);
|
||||
});
|
||||
DebuggerUIUtil.showPopupForEditorLine(popup, editor, position.getLine());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,11 +21,9 @@ import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.EditorGutter;
|
||||
import com.intellij.openapi.editor.LogicalPosition;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsUtil;
|
||||
import com.intellij.openapi.editor.ex.EditorGutterComponentEx;
|
||||
import com.intellij.openapi.keymap.KeymapUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.*;
|
||||
@@ -97,6 +95,7 @@ public class DebuggerUIUtil {
|
||||
ApplicationManager.getApplication().invokeLater(runnable);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static RelativePoint calcPopupLocation(@NotNull Editor editor, final int line) {
|
||||
Point p = editor.logicalPositionToXY(new LogicalPosition(line + 1, 0));
|
||||
|
||||
@@ -107,6 +106,28 @@ public class DebuggerUIUtil {
|
||||
return new RelativePoint(editor.getContentComponent(), p);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static RelativePoint getPositionForPopup(@NotNull Editor editor, int line) {
|
||||
Point p = editor.logicalPositionToXY(new LogicalPosition(line + 1, 0));
|
||||
return editor.getScrollingModel().getVisibleArea().contains(p) ? new RelativePoint(editor.getContentComponent(), p) : null;
|
||||
}
|
||||
|
||||
public static void showPopupForEditorLine(@NotNull JBPopup popup, @NotNull Editor editor, int line) {
|
||||
RelativePoint point = getPositionForPopup(editor, line);
|
||||
if (point != null) {
|
||||
popup.show(point);
|
||||
}
|
||||
else {
|
||||
Project project = editor.getProject();
|
||||
if (project != null) {
|
||||
popup.showCenteredInCurrentWindow(project);
|
||||
}
|
||||
else {
|
||||
popup.showInFocusCenter();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void showValuePopup(@NotNull XFullValueEvaluator evaluator, @NotNull MouseEvent event, @NotNull Project project, @Nullable Editor editor) {
|
||||
EditorTextField textArea = new TextViewer("Evaluating...", project);
|
||||
textArea.setBackground(HintUtil.INFORMATION_COLOR);
|
||||
|
||||
Reference in New Issue
Block a user