mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
extend PyFrameAccessor to avoid instanceof (PY-22535)
This commit is contained in:
@@ -2,6 +2,7 @@ package com.jetbrains.python.debugger;
|
||||
|
||||
import com.intellij.xdebugger.XSourcePosition;
|
||||
import com.intellij.xdebugger.frame.XValueChildrenList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
@@ -31,4 +32,6 @@ public interface PyFrameAccessor {
|
||||
XSourcePosition getSourcePositionForType(String type);
|
||||
|
||||
default void showNumericContainer(PyDebugValue value) {}
|
||||
|
||||
default void setDataChangedCallback(@NotNull Runnable runnable) {}
|
||||
}
|
||||
|
||||
@@ -692,4 +692,19 @@ public class PydevConsoleCommunication extends AbstractConsoleCommunication impl
|
||||
public void showNumericContainer(PyDebugValue value) {
|
||||
PyViewNumericContainerAction.showNumericViewer(myProject, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDataChangedCallback(@NotNull Runnable runnable) {
|
||||
addCommunicationListener(new ConsoleCommunicationListener() {
|
||||
@Override
|
||||
public void commandExecuted(boolean more) {
|
||||
runnable.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inputRequested() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1149,6 +1149,16 @@ public class PyDebugProcess extends XDebugProcess implements IPyDebugProcess, Pr
|
||||
PyViewNumericContainerAction.showNumericViewer(getProject(), value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDataChangedCallback(@NotNull Runnable runnable) {
|
||||
getSession().addSessionListener(new XDebugSessionListener() {
|
||||
@Override
|
||||
public void stackFrameChanged() {
|
||||
runnable.run();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static XSourcePosition typeToPosition(PyType pyType) {
|
||||
final PyClassType classType = PyUtil.as(pyType, PyClassType.class);
|
||||
|
||||
@@ -30,14 +30,13 @@ import com.intellij.ui.components.JBLabel;
|
||||
import com.intellij.ui.table.JBTable;
|
||||
import com.intellij.util.TextFieldCompletionProvider;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.xdebugger.XDebugSession;
|
||||
import com.intellij.xdebugger.XDebugSessionListener;
|
||||
import com.intellij.xdebugger.frame.XNamedValue;
|
||||
import com.intellij.xdebugger.frame.XValueChildrenList;
|
||||
import com.jetbrains.python.PythonFileType;
|
||||
import com.jetbrains.python.console.PydevConsoleCommunication;
|
||||
import com.jetbrains.python.console.pydev.ConsoleCommunicationListener;
|
||||
import com.jetbrains.python.debugger.*;
|
||||
import com.jetbrains.python.debugger.ArrayChunk;
|
||||
import com.jetbrains.python.debugger.PyDebugValue;
|
||||
import com.jetbrains.python.debugger.PyDebuggerException;
|
||||
import com.jetbrains.python.debugger.PyFrameAccessor;
|
||||
import com.jetbrains.python.debugger.array.AsyncArrayTableModel;
|
||||
import com.jetbrains.python.debugger.array.JBTableWithRowHeaders;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -83,28 +82,7 @@ public class PyDataViewerPanel extends JPanel {
|
||||
}
|
||||
|
||||
private void setupChangeListener() {
|
||||
if (myFrameAccessor instanceof PyDebugProcess) {
|
||||
XDebugSession session = ((PyDebugProcess)myFrameAccessor).getSession();
|
||||
session.addSessionListener(new XDebugSessionListener() {
|
||||
@Override
|
||||
public void stackFrameChanged() {
|
||||
updateModel();
|
||||
}
|
||||
});
|
||||
}
|
||||
if (myFrameAccessor instanceof PydevConsoleCommunication) {
|
||||
((PydevConsoleCommunication)myFrameAccessor).addCommunicationListener(new ConsoleCommunicationListener() {
|
||||
@Override
|
||||
public void commandExecuted(boolean more) {
|
||||
ApplicationManager.getApplication().invokeLater(() -> updateModel());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inputRequested() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
myFrameAccessor.setDataChangedCallback(() -> ApplicationManager.getApplication().invokeLater(() -> updateModel()));
|
||||
}
|
||||
|
||||
private void updateModel() {
|
||||
|
||||
Reference in New Issue
Block a user