Remove XDebugConnection dependence from XDebugWatchExpressionDelegate and add XdebugT...
authorincastrix <incastrix>
Sun, 14 Sep 2008 04:46:14 +0000 (04:46 +0000)
committerincastrix <incastrix>
Sun, 14 Sep 2008 04:46:14 +0000 (04:46 +0000)
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugTarget.java
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugWatchExpressionDelegate.java

index be31843..9b7b206 100644 (file)
@@ -489,6 +489,16 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, IDebugE
                }
        }
        
+       public Node eval(String expression) {
+               int id = fDebugConnection.eval(expression);
+               XDebugResponse response = getResponse(id);
+
+               Node evalResponse = response.getParentNode();
+               Node evalProperty = evalResponse.getFirstChild();
+               
+               return evalProperty;
+       }
+       
        public void handleDebugEvents(DebugEvent[] events) {
                for (int i = 0; i < events.length; i++) {
                        DebugEvent event = events[i];
@@ -620,11 +630,15 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, IDebugE
                return response.getParentNode();
        }
        
+       public void stop() {
+               fDebugConnection.stop();
+       }
+       
        protected IBreakpoint breakpointHit(Node node) {
                Node child = node.getFirstChild();
                if (child.getNodeName().equals("stack")) {
                        int lineNumber = Integer.parseInt(PHPDebugUtils.getAttributeValue(child, "lineno"));
-                       String filename=PHPDebugUtils.getAttributeValue(child, "filename");  
+                       String filename = PHPDebugUtils.getAttributeValue(child, "filename");  
                        IBreakpoint[] breakpoints = XDebugCorePlugin.getBreakpoints();
                        for (int i = 0; i < breakpoints.length; i++) {
                                IBreakpoint breakpoint = breakpoints[i];
index a14bc08..9fbfdc2 100644 (file)
@@ -1,8 +1,6 @@
 package net.sourceforge.phpeclipse.xdebug.php.model;
 
 
-import net.sourceforge.phpeclipse.xdebug.core.xdebug.XDebugConnection;
-import net.sourceforge.phpeclipse.xdebug.core.xdebug.ResponseListener.XDebugResponse;
 import net.sourceforge.phpeclipse.xdebug.php.model.XDebugVariable;
 import net.sourceforge.phpeclipse.xdebug.php.model.XDebugTarget;
 
@@ -15,40 +13,23 @@ import org.w3c.dom.Node;
 public class XDebugWatchExpressionDelegate implements IWatchExpressionDelegate {
        public void evaluateExpression(String expression, IDebugElement context, IWatchExpressionListener listener) {
                IWatchExpressionResult x;
-               XDebugConnection connection;
-               XDebugTarget s;
 
-               x = new XDebugWatchExpressionResult(expression, null, null);
-               
-               s = (XDebugTarget) context.getDebugTarget();
-               connection = (XDebugConnection) s.getDebugConnection();
-
-               if( connection != null ) {
-                       try {
-                               if( ! connection.isClosed() ) {
-                                       /*XDebugResponse*/ int evalCommand = connection.eval(expression);
-                                       
-                                       XDebugResponse response = s.getResponse(evalCommand);
-
-                                       
-                                       Node evalResponse = response.getParentNode();
-                                       Node evalProperty = evalResponse.getFirstChild();
-                                       XDebugVariable variable = new XDebugVariable(null, evalProperty);
-                                       XDebugVariable result[] = {variable};
-                                       
-                                       if (result.length == 0) {
-                                               x = new XDebugWatchExpressionResult(expression, null, null);
-                                       } else {
-                                               x = new XDebugWatchExpressionResult(expression, result[0].getValue(), null);
-                                       }
+               try {
+                               Node evalProperty = ((XDebugTarget) context.getDebugTarget()).eval(expression);
+                               XDebugVariable variable = new XDebugVariable(null, evalProperty);
+                               XDebugVariable result[] = {variable};
+                               
+                               if (result.length == 0) {
+                                       x = new XDebugWatchExpressionResult(expression, null, null);
+                               } else {
+                                       x = new XDebugWatchExpressionResult(expression, result[0].getValue(), null);
                                }
-                       } catch (Exception e) {
-                               String[] s1;
-       
-                               s1 = new String[1];
-                               s1[0] = e.toString();
-                               x = new XDebugWatchExpressionResult(expression, null, s1);
-                       }
+               } catch (Exception e) {
+                       String[] s1;
+
+                       s1 = new String[1];
+                       s1[0] = e.toString();
+                       x = new XDebugWatchExpressionResult(expression, null, s1);
                }
 
                listener.watchEvaluationFinished(x);