1 package net.sourceforge.phpeclipse.xdebug.php.model;
4 import net.sourceforge.phpeclipse.xdebug.core.xdebug.XDebugConnection;
5 import net.sourceforge.phpeclipse.xdebug.core.xdebug.ResponseListener.XDebugResponse;
6 import net.sourceforge.phpeclipse.xdebug.php.model.XDebugVariable;
7 import net.sourceforge.phpeclipse.xdebug.php.model.XDebugTarget;
9 import org.eclipse.debug.core.model.IDebugElement;
10 import org.eclipse.debug.core.model.IWatchExpressionDelegate;
11 import org.eclipse.debug.core.model.IWatchExpressionListener;
12 import org.eclipse.debug.core.model.IWatchExpressionResult;
13 import org.w3c.dom.Node;
15 public class XDebugWatchExpressionDelegate implements IWatchExpressionDelegate {
16 public void evaluateExpression(String expression, IDebugElement context, IWatchExpressionListener listener) {
17 IWatchExpressionResult x;
18 XDebugConnection connection;
21 x = new XDebugWatchExpressionResult(expression, null, null);
23 s = (XDebugTarget) context.getDebugTarget();
24 connection = (XDebugConnection) s.getDebugConnection();
26 if( connection != null ) {
28 if( ! connection.isClosed() ) {
29 /*XDebugResponse*/ int evalCommand = connection.eval(expression);
31 XDebugResponse response = s.getResponse(evalCommand);
34 Node evalNode = response.getParentNode();
35 XDebugVariable var = new XDebugVariable(null, evalNode);
36 XDebugVariable result[] = {var};
38 if (result.length == 0) {
39 x = new XDebugWatchExpressionResult(expression, null, null);
41 x = new XDebugWatchExpressionResult(expression, result[0].getValue(), null);
44 } catch (Exception e) {
49 x = new XDebugWatchExpressionResult(expression, null, s1);
53 listener.watchEvaluationFinished(x);