Refactor and fix expression view.
authorincastrix <incastrix>
Wed, 24 Dec 2008 17:39:16 +0000 (17:39 +0000)
committerincastrix <incastrix>
Wed, 24 Dec 2008 17:39:16 +0000 (17:39 +0000)
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugStackFrame.java
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugWatchExpressionDelegate.java

index 2798345..09bed63 100644 (file)
@@ -43,7 +43,7 @@ public class XDebugStackFrame  extends XDebugElement implements IStackFrame {
         * @param id stack frame id (0 is the bottom of the stack)
         */
        public XDebugStackFrame(XDebugThread thread, int id, String type, int lineNumber, String where, /*URL*/String filename) {
-               super(thread == null ? null : (XDebugTarget) thread.getDebugTarget());
+               super(/*thread == null ? null : */(XDebugTarget) thread.getDebugTarget());
                
                fLevel = id;
                fThread = thread;
@@ -334,4 +334,8 @@ public class XDebugStackFrame  extends XDebugElement implements IStackFrame {
        public boolean setVariableValue(XDebugVariable variable, String expression)  throws DebugException {
                return ((XDebugTarget) getDebugTarget()).setVarValue("$" + variable.getName(), expression);
        }
+       
+       public Node eval(String expression) throws DebugException {
+               return ((XDebugTarget) getDebugTarget()).eval(expression);
+       }
 }
\ No newline at end of file
index 9fbfdc2..e90aedd 100644 (file)
@@ -2,8 +2,8 @@ package net.sourceforge.phpeclipse.xdebug.php.model;
 
 
 import net.sourceforge.phpeclipse.xdebug.php.model.XDebugVariable;
-import net.sourceforge.phpeclipse.xdebug.php.model.XDebugTarget;
 
+import org.eclipse.debug.core.DebugException;
 import org.eclipse.debug.core.model.IDebugElement;
 import org.eclipse.debug.core.model.IWatchExpressionDelegate;
 import org.eclipse.debug.core.model.IWatchExpressionListener;
@@ -12,24 +12,28 @@ import org.w3c.dom.Node;
 
 public class XDebugWatchExpressionDelegate implements IWatchExpressionDelegate {
        public void evaluateExpression(String expression, IDebugElement context, IWatchExpressionListener listener) {
-               IWatchExpressionResult x;
+               IWatchExpressionResult x = new XDebugWatchExpressionResult(expression, null, null);
 
-               try {
-                               Node evalProperty = ((XDebugTarget) context.getDebugTarget()).eval(expression);
-                               XDebugVariable variable = new XDebugVariable(null, evalProperty);
-                               XDebugVariable result[] = {variable};
+               /* Active debug session */
+               if (context instanceof XDebugStackFrame) {
+                       XDebugStackFrame frame = (XDebugStackFrame)context;
+                       Node evalProperty = null;
                                
-                               if (result.length == 0) {
-                                       x = new XDebugWatchExpressionResult(expression, null, null);
-                               } else {
-                                       x = new XDebugWatchExpressionResult(expression, result[0].getValue(), null);
-                               }
-               } catch (Exception e) {
-                       String[] s1;
+                       try {   
+                               evalProperty = frame.eval(expression);
+                       } catch (Exception e) {
+                               // 
+                               e.printStackTrace();
+                       }
 
-                       s1 = new String[1];
-                       s1[0] = e.toString();
-                       x = new XDebugWatchExpressionResult(expression, null, s1);
+                       XDebugVariable variable = null;
+                       try {
+                               variable = new XDebugVariable(frame, evalProperty);
+                               x = new XDebugWatchExpressionResult(expression, variable.getValue(), null);
+                       } catch (DebugException e) {
+                               // TODO Auto-generated catch block
+                               e.printStackTrace();
+                       }
                }
 
                listener.watchEvaluationFinished(x);