From ac9aaac9b65a6cd001e0683004de718eb615cd05 Mon Sep 17 00:00:00 2001 From: incastrix Date: Sun, 14 Sep 2008 04:46:14 +0000 Subject: [PATCH] Remove XDebugConnection dependence from XDebugWatchExpressionDelegate and add XdebugTarget#eval(String). --- .../phpeclipse/xdebug/php/model/XDebugTarget.java | 16 ++++++- .../php/model/XDebugWatchExpressionDelegate.java | 49 ++++++-------------- 2 files changed, 30 insertions(+), 35 deletions(-) diff --git a/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugTarget.java b/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugTarget.java index be31843..9b7b206 100644 --- a/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugTarget.java +++ b/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugTarget.java @@ -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]; diff --git a/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugWatchExpressionDelegate.java b/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugWatchExpressionDelegate.java index a14bc08..9fbfdc2 100644 --- a/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugWatchExpressionDelegate.java +++ b/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugWatchExpressionDelegate.java @@ -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); -- 1.7.1