public boolean isErrorOnEval() {
return myErrorOnEval;
}
-
+
public PyDebugValue setParent(@Nullable PyDebugValue parent) {
return new PyDebugValue(myName, myType, myTypeQualifier, myValue, myContainer, myIsReturnedVal, myIsIPythonHidden, myErrorOnEval,
parent, myFrameAccessor);
@Override
public void computePresentation(@NotNull XValueNode node, @NotNull XValuePlace place) {
String value = PyTypeHandler.format(this);
-
+ setFullValueEvaluator(node, value);
if (value.length() >= MAX_VALUE) {
- node.setFullValueEvaluator(new PyFullValueEvaluator(myFrameAccessor, getFullTreeName()));
value = value.substring(0, MAX_VALUE);
}
-
node.setPresentation(getValueIcon(), myType, value, myContainer);
}
+ private boolean isDataFrame() {
+ return "DataFrame".equals(myType);
+ }
+
+ private boolean isNdarray() {
+ return "ndarray".equals(myType);
+ }
+
+ private void setFullValueEvaluator(XValueNode node, String value) {
+ String treeName = getFullTreeName();
+ if (!isDataFrame() && !isNdarray()) {
+ if (value.length() >= MAX_VALUE) {
+ node.setFullValueEvaluator(new PyFullValueEvaluator(myFrameAccessor, treeName));
+ }
+ return;
+ }
+ String linkText = "...View as " + (isDataFrame() ? "DataFrame" : "Array");
+ node.setFullValueEvaluator(new PyNumericContainerValueEvaluator(linkText, myFrameAccessor, treeName));
+ }
+
@Override
public void computeChildren(@NotNull final XCompositeNode node) {
if (node.isObsolete()) return;
return AllIcons.Debugger.Value;
}
}
-
+
public PyDebugValue setName(String newName) {
PyDebugValue value = new PyDebugValue(newName, myType, myTypeQualifier, myValue, myContainer, myIsReturnedVal, myIsIPythonHidden,
myErrorOnEval, myParent, myFrameAccessor);
@Nullable
XSourcePosition getSourcePositionForType(String type);
+
+ default void showNumericContainer(PyDebugValue value) {}
}
* @param debugProcess
* @param expression
*/
+ protected PyFullValueEvaluator(String linkText, PyFrameAccessor debugProcess, String expression) {
+ super(linkText);
+ myDebugProcess = debugProcess;
+ myExpression = expression;
+ }
+
+
protected PyFullValueEvaluator(PyFrameAccessor debugProcess, String expression) {
myDebugProcess = debugProcess;
myExpression = expression;
try {
final PyDebugValue value = myDebugProcess.evaluate(expression, false, false);
callback.evaluated(value.getValue());
+ showCustomPopup(myDebugProcess, value);
}
catch (PyDebuggerException e) {
callback.errorOccurred(e.getTracebackError());
}
}
+
+ protected void showCustomPopup(PyFrameAccessor debugProcess, PyDebugValue debugValue) {
+
+ }
}
--- /dev/null
+package com.jetbrains.python.debugger;
+
+public class PyNumericContainerValueEvaluator extends PyFullValueEvaluator {
+
+ protected PyNumericContainerValueEvaluator(String linkText, PyFrameAccessor debugProcess, String expression) {
+ super(linkText, debugProcess, expression);
+ }
+
+ @Override
+ protected void showCustomPopup(PyFrameAccessor debugProcess, PyDebugValue debugValue) {
+ debugProcess.showNumericContainer(debugValue);
+ }
+
+ @Override
+ public boolean isShowValuePopup() {
+ return false;
+ }
+}
import com.jetbrains.python.console.PythonConsoleView;
import com.jetbrains.python.console.PythonDebugLanguageConsoleView;
import com.jetbrains.python.console.pydev.PydevCompletionVariant;
+import com.jetbrains.python.debugger.containerview.PyViewNumericContainerAction;
import com.jetbrains.python.debugger.pydev.*;
import com.jetbrains.python.debugger.settings.PyDebuggerSettings;
import com.jetbrains.python.psi.*;
return pyType == null ? null : typeToPosition(pyType);
}
+ @Override
+ public void showNumericContainer(PyDebugValue value) {
+ PyViewNumericContainerAction.showNumericViewer(getProject(), value);
+ }
+
@Nullable
private static XSourcePosition typeToPosition(PyType pyType) {
final PyClassType classType = PyUtil.as(pyType, PyClassType.class);
Project p = e.getProject();
if (p != null && node != null && node.getValueContainer() instanceof PyDebugValue && node.isComputed()) {
PyDebugValue debugValue = (PyDebugValue)node.getValueContainer();
- String nodeType = debugValue.getType();
- final ViewNumericContainerDialog dialog;
- if ("ndarray".equals(nodeType)) {
- dialog = new ViewNumericContainerDialog(p, (dialogWrapper) -> {
- NumpyArrayTable arrayTable = new NumpyArrayTable(p, dialogWrapper, debugValue);
- arrayTable.init();
- return arrayTable.getComponent().getMainPanel();
- });
- }
- else if (("DataFrame".equals(nodeType))) {
- dialog = new ViewNumericContainerDialog(p, (dialogWrapper) -> {
- DataFrameTable dataFrameTable = new DataFrameTable(p, dialogWrapper, debugValue);
- dataFrameTable.init();
- return dataFrameTable.getComponent().getMainPanel();
- });
- }
- else {
- throw new IllegalStateException("Cannot render node type: " + nodeType);
- }
+ showNumericViewer(p, debugValue);
+ }
+ }
- dialog.show();
+ public static void showNumericViewer(Project project, PyDebugValue debugValue) {
+ String nodeType = debugValue.getType();
+ final ViewNumericContainerDialog dialog;
+ if ("ndarray".equals(nodeType)) {
+ dialog = new ViewNumericContainerDialog(project, (dialogWrapper) -> {
+ NumpyArrayTable arrayTable = new NumpyArrayTable(project, dialogWrapper, debugValue);
+ arrayTable.init();
+ return arrayTable.getComponent().getMainPanel();
+ });
+ }
+ else if (("DataFrame".equals(nodeType))) {
+ dialog = new ViewNumericContainerDialog(project, (dialogWrapper) -> {
+ DataFrameTable dataFrameTable = new DataFrameTable(project, dialogWrapper, debugValue);
+ dataFrameTable.init();
+ return dataFrameTable.getComponent().getMainPanel();
+ });
}
+ else {
+ throw new IllegalStateException("Cannot render node type: " + nodeType);
+ }
+
+ dialog.show();
}
@Nullable