From c4e1537727fb33c565b45ae051644ab61eb7ca4b Mon Sep 17 00:00:00 2001 From: nik Date: Wed, 19 Jan 2011 17:24:39 +0300 Subject: [PATCH] python debugger adapted to changes in XValueNode/XCompositeNode --- .../python/debugger/IPyDebugProcess.java | 5 ++--- .../python/debugger/PyDebugValue.java | 5 ++--- .../debugger/pydev/GetFrameCommand.java | 11 +++++----- .../python/debugger/pydev/RemoteDebugger.java | 5 +++-- .../python/debugger/PyDebugProcess.java | 22 ++++++++++--------- .../python/debugger/PyStackFrame.java | 3 ++- 6 files changed, 27 insertions(+), 24 deletions(-) diff --git a/python/pydevSrc/com/jetbrains/python/debugger/IPyDebugProcess.java b/python/pydevSrc/com/jetbrains/python/debugger/IPyDebugProcess.java index 2eb50952c5fc..a8b8c3c3787f 100644 --- a/python/pydevSrc/com/jetbrains/python/debugger/IPyDebugProcess.java +++ b/python/pydevSrc/com/jetbrains/python/debugger/IPyDebugProcess.java @@ -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 loadVariable(PyDebugValue pyDebugValue) throws PyDebuggerException; + XValueChildrenList loadVariable(PyDebugValue var) throws PyDebuggerException; void changeVariable(PyDebugValue variable, String expression) throws PyDebuggerException; diff --git a/python/pydevSrc/com/jetbrains/python/debugger/PyDebugValue.java b/python/pydevSrc/com/jetbrains/python/debugger/PyDebugValue.java index 0431a90ebe25..2bc64cac3dc1 100644 --- a/python/pydevSrc/com/jetbrains/python/debugger/PyDebugValue.java +++ b/python/pydevSrc/com/jetbrains/python/debugger/PyDebugValue.java @@ -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 values = myDebugProcess.loadVariable(PyDebugValue.this); + final XValueChildrenList values = myDebugProcess.loadVariable(PyDebugValue.this); if (!node.isObsolete()) { node.addChildren(values, true); } diff --git a/python/pydevSrc/com/jetbrains/python/debugger/pydev/GetFrameCommand.java b/python/pydevSrc/com/jetbrains/python/debugger/pydev/GetFrameCommand.java index ac52168ca436..54cf853e171c 100644 --- a/python/pydevSrc/com/jetbrains/python/debugger/pydev/GetFrameCommand.java +++ b/python/pydevSrc/com/jetbrains/python/debugger/pydev/GetFrameCommand.java @@ -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 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 values = ProtocolParser.parseValues(response.getPayload()); - myFrameVariables = new ArrayList(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 getVariables() { + public XValueChildrenList getVariables() { return myFrameVariables; } diff --git a/python/pydevSrc/com/jetbrains/python/debugger/pydev/RemoteDebugger.java b/python/pydevSrc/com/jetbrains/python/debugger/pydev/RemoteDebugger.java index df0049616dbd..af1ef1cb3221 100644 --- a/python/pydevSrc/com/jetbrains/python/debugger/pydev/RemoteDebugger.java +++ b/python/pydevSrc/com/jetbrains/python/debugger/pydev/RemoteDebugger.java @@ -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 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 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(); diff --git a/python/src/com/jetbrains/python/debugger/PyDebugProcess.java b/python/src/com/jetbrains/python/debugger/PyDebugProcess.java index 94e5c0059742..b5201ca11878 100644 --- a/python/src/com/jetbrains/python/debugger/PyDebugProcess.java +++ b/python/src/com/jetbrains/python/debugger/PyDebugProcess.java @@ -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>(); private final List mySuspendedThreads = Lists.newArrayList(); - private final Map> myStackFrameCache = Maps.newHashMap(); + private final Map myStackFrameCache = Maps.newHashMap(); private final Map 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 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 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 applyNewValue(List pyDebugValues, String threadFrameId) { + private XValueChildrenList applyNewValue(XValueChildrenList pyDebugValues, String threadFrameId) { if (myNewVariableValue.containsKey(threadFrameId)) { PyDebugValue newValue = myNewVariableValue.get(threadFrameId); - List 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 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); } diff --git a/python/src/com/jetbrains/python/debugger/PyStackFrame.java b/python/src/com/jetbrains/python/debugger/PyStackFrame.java index bb1847072911..393761589ae0 100644 --- a/python/src/com/jetbrains/python/debugger/PyStackFrame.java +++ b/python/src/com/jetbrains/python/debugger/PyStackFrame.java @@ -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 values = myDebugProcess.loadFrame(); + final XValueChildrenList values = myDebugProcess.loadFrame(); if (!node.isObsolete()) { node.addChildren(values, true); }