package net.sourceforge.phpeclipse.xdebug.php.model;
-import net.sourceforge.phpeclipse.xdebug.core.Base64;
-import net.sourceforge.phpeclipse.xdebug.core.PHPDebugUtils;
import net.sourceforge.phpeclipse.xdebug.core.xdebug.XDebugConnection;
-import net.sourceforge.phpeclipse.xdebug.core.xdebug.ResponseListener.DebugResponse;
+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;
-import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IDebugElement;
-import org.eclipse.debug.core.model.IVariable;
import org.eclipse.debug.core.model.IWatchExpressionDelegate;
import org.eclipse.debug.core.model.IWatchExpressionListener;
import org.eclipse.debug.core.model.IWatchExpressionResult;
import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
public class XDebugWatchExpressionDelegate implements IWatchExpressionDelegate {
public void evaluateExpression(String expression, IDebugElement context, IWatchExpressionListener listener) {
if( connection != null ) {
try {
if( ! connection.isClosed() ) {
- DebugResponse evalCommand = connection.eval(expression);
+ /*XDebugResponse*/ int evalCommand = connection.eval(expression);
- Node evalNode = evalCommand.getParentNode();
- XDebugVariable var= /*connection.*/getVariableFromNodeA( null, evalNode.getFirstChild());
+ XDebugResponse response = s.getResponse(evalCommand);
+
+
+ Node evalNode = response.getParentNode();
+ XDebugVariable var = new XDebugVariable(null, evalNode);
XDebugVariable result[] = {var};
if (result.length == 0) {
listener.watchEvaluationFinished(x);
}
-
- private XDebugVariable getVariableFromNodeA(XDebugStackFrame frame, Node property) {
- String address = PHPDebugUtils.getAttributeValue(property, "address");
- String varName;
- String Name = PHPDebugUtils.getAttributeValue(property,"name");
- if ("".equals(Name)) {
- varName = address;
- } else {
- varName = Name;
- }
-
- String varEncoding=PHPDebugUtils.getAttributeValue(property,"encoding");
- int varNumChildren = 0;
- if (PHPDebugUtils.getAttributeValue(property,"numchildren").equals(""))
- varNumChildren = 0;
- else
- varNumChildren=Integer.parseInt(PHPDebugUtils.getAttributeValue(property,"numchildren"));
-
- String typeName=PHPDebugUtils.getAttributeValue(property,"type");
-
- XDebugVariable variable = new XDebugVariable(typeName, varName);
- variable.setEncoding(varEncoding);
- variable.setNumChildren(varNumChildren);
- XDebugAbstractValue val=null;
- try {
- val = (XDebugAbstractValue) variable.getValue();
- } catch (DebugException e1) {
- e1.printStackTrace();
- }
- if (val.getType()!= XDebugAbstractValue.VALUETYPE_UNINITIALIZED) {
- if (variable.hasChildren()) {
- NodeList varNodes = property.getChildNodes();
- val.renderValueString(""+varNodes.getLength());
- IVariable[] variables = new IVariable[varNodes.getLength()];
- for (int i = 0; i<varNodes.getLength(); i++) {
- Node propertyNode = varNodes.item(i);
- variables[i] = getVariableFromNodeA(frame, propertyNode);
- }
- val.setChildVariables(variables);
- }else {
- String str="";
- try {
- str=property.getFirstChild().getNodeValue();
- } catch (NullPointerException e) {
- str="";
- }
- if (variable.getEncoding().equals("base64")) {
- if (str.length()!=0)
- str=new String(Base64.decode(str));
- else
- str="";
- }
- val.renderValueString(str);
- }
-
- String className=PHPDebugUtils.getAttributeValue(property,"classname");
- if(!"".equals(className))
- val.renderValueString(className);
- }
- return variable;
-
- }
}
\ No newline at end of file