From: toshihiro Date: Fri, 17 Aug 2007 03:12:56 +0000 (+0000) Subject: Fixed: 1775382 - Cannot change value in Expressions View X-Git-Url: http://secure.phpeclipse.com Fixed: 1775382 - Cannot change value in Expressions View --- diff --git a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPValue.java b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPValue.java index 4d511ee..e20be3d 100644 --- a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPValue.java +++ b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPValue.java @@ -41,16 +41,16 @@ public class PHPValue implements IValue { "reference", // 8 "soft reference" }; // 9 - final static int PEVT_UNKNOWN = 0; - final static int PEVT_LONG = 1; - final static int PEVT_DOUBLE = 2; - final static int PEVT_STRING = 3; - final static int PEVT_ARRAY = 4; - final static int PEVT_OBJECT = 5; - final static int PEVT_BOOLEAN = 6; - final static int PEVT_RESOURCE = 7; - final static int PEVT_REF = 8; - final static int PEVT_SOFTREF = 9; + public final static int PEVT_UNKNOWN = 0; + public final static int PEVT_LONG = 1; + public final static int PEVT_DOUBLE = 2; + public final static int PEVT_STRING = 3; + public final static int PEVT_ARRAY = 4; + public final static int PEVT_OBJECT = 5; + public final static int PEVT_BOOLEAN = 6; + public final static int PEVT_RESOURCE = 7; + public final static int PEVT_REF = 8; + public final static int PEVT_SOFTREF = 9; private int fValueType; // The type of this value (see the PEVT_... values) //private boolean hasChildren; // This value (variable) has children (more variables) diff --git a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/watch/PHPWatchExpressionDelegate.java b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/watch/PHPWatchExpressionDelegate.java index 1f38d53..3d2df36 100644 --- a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/watch/PHPWatchExpressionDelegate.java +++ b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/watch/PHPWatchExpressionDelegate.java @@ -1,8 +1,11 @@ package net.sourceforge.phpdt.internal.debug.core.watch; +import java.util.Vector; + import net.sourceforge.phpdt.internal.debug.core.PHPDBGProxy; import net.sourceforge.phpdt.internal.debug.core.model.PHPDebugTarget; import net.sourceforge.phpdt.internal.debug.core.model.PHPStackFrame; +import net.sourceforge.phpdt.internal.debug.core.model.PHPValue; import net.sourceforge.phpdt.internal.debug.core.model.PHPVariable; import org.eclipse.debug.core.model.IDebugElement; @@ -21,19 +24,28 @@ public class PHPWatchExpressionDelegate implements IWatchExpressionDelegate { PHPDBGProxy dbg; PHPStackFrame s; - dbg = ((PHPDebugTarget) context.getDebugTarget()).getPHPDBGProxy(); - s = null; - - if (context instanceof PHPStackFrame) { - s = (PHPStackFrame) context; + if (!(context instanceof PHPStackFrame)) { + x = new PHPWatchExpressionResult(expression, null, null); + listener.watchEvaluationFinished(x); + return; } + dbg = ((PHPDebugTarget) context.getDebugTarget()).getPHPDBGProxy(); + s = (PHPStackFrame) context; + try { PHPVariable result[] = dbg.eval(s, expression); if (result.length == 0) { x = new PHPWatchExpressionResult(expression, null, null); } else { + switch (result[0].getReferenceType()) { + case PHPValue.PEVT_ARRAY: + case PHPValue.PEVT_OBJECT: + result[0].setName(expression); + reset(result[0]); + break; + } x = new PHPWatchExpressionResult(expression, result[0] .getValue(), null); } @@ -47,4 +59,36 @@ public class PHPWatchExpressionDelegate implements IWatchExpressionDelegate { listener.watchEvaluationFinished(x); } + + private void reset(PHPVariable variable) { + PHPValue value; + Vector variables; + + switch (variable.getReferenceType()) { + case PHPValue.PEVT_ARRAY: + value = (PHPValue) variable.getValue(); + variables = value.getChildVariables(); + for (int i = 0; i < variables.size(); i++) { + PHPVariable var = (PHPVariable) variables.get(i); + String name = var.getName(); + if (var.getLongName().equals(name)) { + var.setName(name); + } else { + var.setParent(variable); + } + reset(var); + } + break; + case PHPValue.PEVT_OBJECT: + value = (PHPValue) variable.getValue(); + variables = value.getChildVariables(); + for (int i = 0; i < variables.size(); i++) { + PHPVariable var = (PHPVariable) variables.get(i); + var.setParent(variable); + reset(var); + } + break; + } + } + }