313bef5438126f84c7f1da7e62c7d3d3b4bb4e1e
[phpeclipse.git] /
1 package net.sourceforge.phpeclipse.xdebug.php.model;
2
3
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;
8
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;
14
15 public class XDebugWatchExpressionDelegate implements IWatchExpressionDelegate {
16         public void evaluateExpression(String expression, IDebugElement context, IWatchExpressionListener listener) {
17                 IWatchExpressionResult x;
18                 XDebugConnection connection;
19                 XDebugTarget s;
20
21                 x = new XDebugWatchExpressionResult(expression, null, null);
22                 
23                 s = (XDebugTarget) context.getDebugTarget();
24                 connection = (XDebugConnection) s.getDebugConnection();
25
26                 if( connection != null ) {
27                         try {
28                                 if( ! connection.isClosed() ) {
29                                         /*XDebugResponse*/ int evalCommand = connection.eval(expression);
30                                         
31                                         XDebugResponse response = s.getResponse(evalCommand);
32
33                                         
34                                         Node evalNode = response.getParentNode();
35                                         XDebugVariable var = new XDebugVariable(null, evalNode);
36                                         XDebugVariable result[] = {var};
37                                         
38                                         if (result.length == 0) {
39                                                 x = new XDebugWatchExpressionResult(expression, null, null);
40                                         } else {
41                                                 x = new XDebugWatchExpressionResult(expression, result[0].getValue(), null);
42                                         }
43                                 }
44                         } catch (Exception e) {
45                                 String[] s1;
46         
47                                 s1 = new String[1];
48                                 s1[0] = e.toString();
49                                 x = new XDebugWatchExpressionResult(expression, null, s1);
50                         }
51                 }
52
53                 listener.watchEvaluationFinished(x);
54         }
55 }