Commits

sk  committed dd7a75c

Now selecting frame shows local variables.

  • Participants
  • Parent commits 45ca35e

Comments (0)

Files changed (6)

File src/org/lispdev/swank/ISwank.java

   void sendDebug(String commandNum, String sldbLevel,
       String threadId, SwankRunnable callBack);
   void sendListThreads(SwankRunnable callBack);
+
+  public LispVariable[] getFrameLocals(int frameNum, String threadId,
+      LispDebugTarget target);
+
 }

File src/org/lispdev/swank/LispStackFrame.java

   private final int index;
   private final String name;
   private final LispThread thread;
+  private IVariable[] vars = null;
 
   public LispStackFrame(LispThread thread, String name, int index)
   {
   @Override
   public IVariable[] getVariables() throws DebugException
   {
-    return new IVariable[0];
+    if( vars == null )
+    {
+      vars = thread.getSwank().getFrameLocals(index,
+          thread.getThreadID(), (LispDebugTarget)getDebugTarget());
+    }
+    return vars;
   }
 
   @Override

File src/org/lispdev/swank/LispValue.java

+package org.lispdev.swank;
+
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IValue;
+import org.eclipse.debug.core.model.IVariable;
+
+public class LispValue extends LispDebugElement implements IValue
+{
+  private final String value;
+
+  public LispValue(LispDebugTarget target, String value)
+  {
+    super(target);
+    this.value = value;
+  }
+
+  @Override
+  public String getReferenceTypeName() throws DebugException
+  {
+    return "lisp";
+  }
+
+  @Override
+  public String getValueString() throws DebugException
+  {
+    return value;
+  }
+
+  @Override
+  public boolean isAllocated() throws DebugException
+  {
+    return true;
+  }
+
+  @Override
+  public IVariable[] getVariables() throws DebugException
+  {
+    return new IVariable[0];
+  }
+
+  @Override
+  public boolean hasVariables() throws DebugException
+  {
+    return false;
+  }
+
+}

File src/org/lispdev/swank/LispVariable.java

+package org.lispdev.swank;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IValue;
+import org.eclipse.debug.core.model.IVariable;
+
+public class LispVariable extends LispDebugElement implements IVariable
+{
+  private final String name;
+  private final LispValue value;
+
+  public LispVariable(LispDebugTarget target, String name, String value)
+  {
+    super(target);
+    this.name = name;
+    this.value = new LispValue(target, value);
+  }
+
+  @Override
+  public void setValue(String expression) throws DebugException
+  {
+    throw new DebugException(new Status(IStatus.ERROR,SwankPlugin.PLUGIN_ID,
+        "Setting variable is not implemented"));
+  }
+
+  @Override
+  public void setValue(IValue value) throws DebugException
+  {
+    throw new DebugException(new Status(IStatus.ERROR,SwankPlugin.PLUGIN_ID,
+      "Setting variable is not implemented"));
+  }
+
+  @Override
+  public boolean supportsValueModification()
+  {
+    return false;
+  }
+
+  @Override
+  public boolean verifyValue(String expression) throws DebugException
+  {
+    return false;
+  }
+
+  @Override
+  public boolean verifyValue(IValue value) throws DebugException
+  {
+    return false;
+  }
+
+  @Override
+  public IValue getValue() throws DebugException
+  {
+    return value;
+  }
+
+  @Override
+  public String getName() throws DebugException
+  {
+    return name;
+  }
+
+  @Override
+  public String getReferenceTypeName() throws DebugException
+  {
+    return "lisp";
+  }
+
+  @Override
+  public boolean hasValueChanged() throws DebugException
+  {
+    return false;
+  }
+
+}

File src/org/lispdev/swank/SwankInterface.java

     swank.sendEvalRawWithThread(msg, "nil", threadId, callBack);
   }
 
+  public LispVariable[] getFrameLocals(int frameNum, String threadId,
+      LispDebugTarget target)
+  {
+    LispNode n = swank.sendEvalAndGrabRawWithThread(
+        "(swank:frame-locals-for-emacs " + frameNum + ")",
+        "nil", threadId, 2000);
+    if( n == null || n.getParamsCount() < 1 )
+    {
+      return new LispVariable[0];
+    }
+    LispVariable[] res = new LispVariable[n.getParamsCount()];
+    for( int i = 0; i < res.length; ++i )
+    {
+      LispNode ni = n.get(i);
+      res[i] = new LispVariable(target,
+          ni.getf(":name").value,ni.getf(":value").value);
+    }
+    return res;
+  }
+
   public synchronized void sendGetFrameSourceLocation(String frameNum,
       String threadId, SwankRunnable callBack)
   {

File src/org/lispdev/swank/SwankInterfaceCore.java

     return callBack;
   }
 
-  private LispNode sendEvalAndGrabRawWithThread(String msg, String pkg,
+  public LispNode sendEvalAndGrabRawWithThread(String msg, String pkg,
       String thread, long timeout)
   {
     SyncCallback callBack = getSyncCallBack();