mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-06 06:21:16 +07:00
Show return values as a separate group in Variables Pane (PY-13540)
This commit is contained in:
@@ -209,10 +209,7 @@ public class PyDebugValue extends XNamedValue {
|
||||
}
|
||||
|
||||
private Icon getValueIcon() {
|
||||
if (myIsReturnedVal) {
|
||||
return AllIcons.Debugger.WatchLastReturnValue;
|
||||
}
|
||||
else if (!myContainer) {
|
||||
if (!myContainer) {
|
||||
return AllIcons.Debugger.Db_primitive;
|
||||
}
|
||||
else if ("list".equals(myType) || "tuple".equals(myType)) {
|
||||
|
||||
@@ -387,10 +387,10 @@ public class PyDebugProcess extends XDebugProcess implements IPyDebugProcess, Pr
|
||||
private final String myText;
|
||||
|
||||
public WatchLastMethodReturnValueAction(@NotNull PyDebugProcess debugProcess) {
|
||||
super("", "Enables watching last executed method return value", null);
|
||||
super("", "Enables watching executed functions return values", null);
|
||||
myWatchesReturnValues = PyDebuggerSettings.getInstance().WATCH_RETURN_VALUES;
|
||||
myProcess = debugProcess;
|
||||
myText = "Show Method Return Values";
|
||||
myText = "Show Return Values";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.jetbrains.python.debugger;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
@@ -28,12 +29,15 @@ import com.intellij.ui.ColoredTextContainer;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.xdebugger.XSourcePosition;
|
||||
import com.intellij.xdebugger.evaluation.XDebuggerEvaluator;
|
||||
import com.intellij.xdebugger.frame.XCompositeNode;
|
||||
import com.intellij.xdebugger.frame.XStackFrame;
|
||||
import com.intellij.xdebugger.frame.XValueChildrenList;
|
||||
import com.intellij.xdebugger.frame.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class PyStackFrame extends XStackFrame {
|
||||
|
||||
@@ -133,7 +137,48 @@ public class PyStackFrame extends XStackFrame {
|
||||
}
|
||||
|
||||
protected void addChildren(@NotNull final XCompositeNode node, @Nullable final XValueChildrenList children) {
|
||||
node.addChildren(children != null ? children : XValueChildrenList.EMPTY, true);
|
||||
if (children == null) {
|
||||
node.addChildren(XValueChildrenList.EMPTY, true);
|
||||
return;
|
||||
}
|
||||
|
||||
XValueChildrenList filteredChildren = new XValueChildrenList();
|
||||
final HashMap<String, XValue> returnedValues = new HashMap<>();
|
||||
for (int i = 0; i < children.size(); i++) {
|
||||
XValue value = children.getValue(i);
|
||||
String name = children.getName(i);
|
||||
if ((value instanceof PyDebugValue) && ((PyDebugValue)value).isReturnedVal()) {
|
||||
returnedValues.put(name, value);
|
||||
}
|
||||
else {
|
||||
filteredChildren.add(name, value);
|
||||
}
|
||||
}
|
||||
node.addChildren(filteredChildren, returnedValues.isEmpty());
|
||||
if (!returnedValues.isEmpty()) {
|
||||
addReturnedValuesGroup(node, returnedValues);
|
||||
}
|
||||
}
|
||||
|
||||
private static void addReturnedValuesGroup(@NotNull final XCompositeNode node, Map<String, XValue> returnedValues) {
|
||||
final ArrayList<XValueGroup> group = Lists.newArrayList();
|
||||
group.add(new XValueGroup("Return Values") {
|
||||
@Override
|
||||
public void computeChildren(@NotNull XCompositeNode node) {
|
||||
XValueChildrenList list = new XValueChildrenList();
|
||||
for (Map.Entry<String, XValue> entry : returnedValues.entrySet()) {
|
||||
list.add(entry.getKey() + "()", entry.getValue());
|
||||
}
|
||||
node.addChildren(list, true);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return AllIcons.Debugger.WatchLastReturnValue;
|
||||
}
|
||||
});
|
||||
node.addChildren(XValueChildrenList.topGroups(group), true);
|
||||
}
|
||||
|
||||
public String getThreadId() {
|
||||
|
||||
@@ -38,7 +38,7 @@ public class PyDebuggerSettings extends XDebuggerSettings<PyDebuggerSettings> im
|
||||
private boolean mySteppingFiltersEnabled;
|
||||
private @NotNull List<PySteppingFilter> mySteppingFilters;
|
||||
public static final String FILTERS_DIVIDER = ";";
|
||||
public static boolean WATCH_RETURN_VALUES = false;
|
||||
public volatile boolean WATCH_RETURN_VALUES = false;
|
||||
|
||||
public PyDebuggerSettings() {
|
||||
super("python");
|
||||
|
||||
Reference in New Issue
Block a user