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 evalResponse = response.getParentNode();
35 Node evalProperty = evalResponse.getFirstChild();
36 XDebugVariable variable = new XDebugVariable(null, evalProperty);
37 XDebugVariable result[] = {variable};
39 if (result.length == 0) {
40 x = new XDebugWatchExpressionResult(expression, null, null);
42 x = new XDebugWatchExpressionResult(expression, result[0].getValue(), null);
45 } catch (Exception e) {
50 x = new XDebugWatchExpressionResult(expression, null, s1);
54 listener.watchEvaluationFinished(x);