python debugger adapted to changes in XValueNode/XCompositeNode

This commit is contained in:
nik
2011-01-19 17:24:39 +03:00
parent da80a410f6
commit c4e1537727
6 changed files with 27 additions and 24 deletions
@@ -1,8 +1,7 @@
package com.jetbrains.python.debugger;
import com.intellij.execution.ui.ConsoleViewContentType;
import java.util.List;
import com.intellij.xdebugger.frame.XValueChildrenList;
/**
* @author yole
@@ -12,7 +11,7 @@ public interface IPyDebugProcess {
void threadSuspended(PyThreadInfo thread);
List<PyDebugValue> loadVariable(PyDebugValue pyDebugValue) throws PyDebuggerException;
XValueChildrenList loadVariable(PyDebugValue var) throws PyDebuggerException;
void changeVariable(PyDebugValue variable, String expression) throws PyDebuggerException;
@@ -7,7 +7,6 @@ import com.intellij.xdebugger.ui.DebuggerIcons;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.List;
// todo: load long lists by parts
// todo: null modifier for modify modules, class objects etc.
@@ -125,7 +124,7 @@ public class PyDebugValue extends XValue {
value = value.substring(0, MAX_VALUE) + "...";
}
node.setPresentation(myName, getValueIcon(), myType, value, myContainer);
node.setPresentation(getValueIcon(), myType, value, myContainer);
}
@Override
@@ -136,7 +135,7 @@ public class PyDebugValue extends XValue {
if (myDebugProcess == null) return;
try {
final List<PyDebugValue> values = myDebugProcess.loadVariable(PyDebugValue.this);
final XValueChildrenList values = myDebugProcess.loadVariable(PyDebugValue.this);
if (!node.isObsolete()) {
node.addChildren(values, true);
}
@@ -1,17 +1,17 @@
package com.jetbrains.python.debugger.pydev;
import com.intellij.xdebugger.frame.XValueChildrenList;
import com.jetbrains.python.debugger.IPyDebugProcess;
import com.jetbrains.python.debugger.PyDebugValue;
import com.jetbrains.python.debugger.PyDebuggerException;
import java.util.ArrayList;
import java.util.List;
public class GetFrameCommand extends AbstractFrameCommand {
protected final IPyDebugProcess myDebugProcess;
private List<PyDebugValue> myFrameVariables = null;
private XValueChildrenList myFrameVariables = null;
public GetFrameCommand(final RemoteDebugger debugger, final String threadId, final String frameId) {
this(debugger, GET_FRAME, threadId, frameId);
@@ -37,10 +37,11 @@ public class GetFrameCommand extends AbstractFrameCommand {
protected void processResponse(final ProtocolFrame response) throws PyDebuggerException {
super.processResponse(response);
final List<PyDebugValue> values = ProtocolParser.parseValues(response.getPayload());
myFrameVariables = new ArrayList<PyDebugValue>(values.size());
myFrameVariables = new XValueChildrenList(values.size());
for (PyDebugValue value : values) {
if (!value.getName().startsWith(RemoteDebugger.TEMP_VAR_PREFIX)) {
myFrameVariables.add(extend(value));
final PyDebugValue debugValue = extend(value);
myFrameVariables.add(debugValue.getName(), debugValue);
}
}
}
@@ -49,7 +50,7 @@ public class GetFrameCommand extends AbstractFrameCommand {
return new PyDebugValue(value.getName(), value.getType(), value.getValue(), value.isContainer(), value.isErrorOnEval(), null, myDebugProcess);
}
public List<PyDebugValue> getVariables() {
public XValueChildrenList getVariables() {
return myFrameVariables;
}
@@ -10,6 +10,7 @@ import com.intellij.execution.ui.ConsoleViewContentType;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.xdebugger.frame.XValueChildrenList;
import com.jetbrains.python.debugger.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -125,14 +126,14 @@ public class RemoteDebugger {
return command.getValue();
}
public List<PyDebugValue> loadFrame(final String threadId, final String frameId) throws PyDebuggerException {
public XValueChildrenList loadFrame(final String threadId, final String frameId) throws PyDebuggerException {
final GetFrameCommand command = new GetFrameCommand(this, threadId, frameId);
command.execute();
return command.getVariables();
}
// todo: don't generate temp variables for qualified expressions - just split 'em
public List<PyDebugValue> loadVariable(final String threadId, final String frameId, final PyDebugValue var) throws PyDebuggerException {
public XValueChildrenList loadVariable(final String threadId, final String frameId, final PyDebugValue var) throws PyDebuggerException {
setTempVariable(threadId, frameId, var);
final GetVariableCommand command = new GetVariableCommand(this, threadId, frameId, composeName(var), var);
command.execute();
@@ -23,6 +23,7 @@ import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.intellij.xdebugger.breakpoints.XBreakpointHandler;
import com.intellij.xdebugger.breakpoints.XLineBreakpoint;
import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider;
import com.intellij.xdebugger.frame.XValueChildrenList;
import com.jetbrains.python.console.pydev.PydevCompletionVariant;
import com.jetbrains.python.debugger.pydev.*;
import org.jetbrains.annotations.NotNull;
@@ -53,7 +54,7 @@ public class PyDebugProcess extends XDebugProcess implements IPyDebugProcess, Pr
new ConcurrentHashMap<String, XBreakpoint<PyExceptionBreakpointProperties>>();
private final List<PyThreadInfo> mySuspendedThreads = Lists.newArrayList();
private final Map<String, List<PyDebugValue>> myStackFrameCache = Maps.newHashMap();
private final Map<String, XValueChildrenList> myStackFrameCache = Maps.newHashMap();
private final Map<String, PyDebugValue> myNewVariableValue = Maps.newHashMap();
private boolean myClosing = false;
@@ -249,26 +250,27 @@ public class PyDebugProcess extends XDebugProcess implements IPyDebugProcess, Pr
return myDebugger.consoleExec(frame.getThreadId(), frame.getFrameId(), command);
}
public List<PyDebugValue> loadFrame() throws PyDebuggerException {
public XValueChildrenList loadFrame() throws PyDebuggerException {
final PyStackFrame frame = currentFrame();
//do not reload frame every time it is needed, because due to bug in pdb, reloading frame clears all variable changes
if (!myStackFrameCache.containsKey(frame.getThreadFrameId())) {
List<PyDebugValue> values = myDebugger.loadFrame(frame.getThreadId(), frame.getFrameId());
XValueChildrenList values = myDebugger.loadFrame(frame.getThreadId(), frame.getFrameId());
myStackFrameCache.put(frame.getThreadFrameId(), values);
}
return applyNewValue(myStackFrameCache.get(frame.getThreadFrameId()), frame.getThreadFrameId());
}
private List<PyDebugValue> applyNewValue(List<PyDebugValue> pyDebugValues, String threadFrameId) {
private XValueChildrenList applyNewValue(XValueChildrenList pyDebugValues, String threadFrameId) {
if (myNewVariableValue.containsKey(threadFrameId)) {
PyDebugValue newValue = myNewVariableValue.get(threadFrameId);
List<PyDebugValue> res = Lists.newArrayList();
for (PyDebugValue val : pyDebugValues) {
if (val.getName().equals(newValue.getName())) {
res.add(newValue);
XValueChildrenList res = new XValueChildrenList();
for (int i = 0; i < pyDebugValues.size(); i++) {
final String name = pyDebugValues.getName(i);
if (name.equals(newValue.getName())) {
res.add(name, newValue);
}
else {
res.add(val);
res.add(name, pyDebugValues.getValue(i));
}
}
return res;
@@ -279,7 +281,7 @@ public class PyDebugProcess extends XDebugProcess implements IPyDebugProcess, Pr
}
@Override
public List<PyDebugValue> loadVariable(final PyDebugValue var) throws PyDebuggerException {
public XValueChildrenList loadVariable(final PyDebugValue var) throws PyDebuggerException {
final PyStackFrame frame = currentFrame();
return myDebugger.loadVariable(frame.getThreadId(), frame.getFrameId(), var);
}
@@ -13,6 +13,7 @@ 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.ui.DebuggerIcons;
import org.jetbrains.annotations.NotNull;
@@ -83,7 +84,7 @@ public class PyStackFrame extends XStackFrame {
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
public void run() {
try {
final List<PyDebugValue> values = myDebugProcess.loadFrame();
final XValueChildrenList values = myDebugProcess.loadFrame();
if (!node.isObsolete()) {
node.addChildren(values, true);
}