1f38d530e77fce584df1114e787b1c83bfd289fc
[phpeclipse.git] /
1 package net.sourceforge.phpdt.internal.debug.core.watch;
2
3 import net.sourceforge.phpdt.internal.debug.core.PHPDBGProxy;
4 import net.sourceforge.phpdt.internal.debug.core.model.PHPDebugTarget;
5 import net.sourceforge.phpdt.internal.debug.core.model.PHPStackFrame;
6 import net.sourceforge.phpdt.internal.debug.core.model.PHPVariable;
7
8 import org.eclipse.debug.core.model.IDebugElement;
9 import org.eclipse.debug.core.model.IWatchExpressionDelegate;
10 import org.eclipse.debug.core.model.IWatchExpressionListener;
11 import org.eclipse.debug.core.model.IWatchExpressionResult;
12
13 /**
14  * 
15  */
16 public class PHPWatchExpressionDelegate implements IWatchExpressionDelegate {
17
18         public void evaluateExpression(String expression, IDebugElement context,
19                         IWatchExpressionListener listener) {
20                 IWatchExpressionResult x;
21                 PHPDBGProxy dbg;
22                 PHPStackFrame s;
23
24                 dbg = ((PHPDebugTarget) context.getDebugTarget()).getPHPDBGProxy();
25                 s = null;
26
27                 if (context instanceof PHPStackFrame) {
28                         s = (PHPStackFrame) context;
29                 }
30
31                 try {
32                         PHPVariable result[] = dbg.eval(s, expression);
33
34                         if (result.length == 0) {
35                                 x = new PHPWatchExpressionResult(expression, null, null);
36                         } else {
37                                 x = new PHPWatchExpressionResult(expression, result[0]
38                                                 .getValue(), null);
39                         }
40                 } catch (Exception e) {
41                         String[] s1;
42
43                         s1 = new String[1];
44                         s1[0] = e.toString();
45                         x = new PHPWatchExpressionResult(expression, null, s1);
46                 }
47
48                 listener.watchEvaluationFinished(x);
49         }
50 }