From 6d35272a3f5dac8dad5ad7aec087cc70f23818c9 Mon Sep 17 00:00:00 2001 From: toshihiro Date: Wed, 1 Aug 2007 03:34:14 +0000 Subject: [PATCH] Fixed: 1765073 - Value column of Variables View is not updated immediately --- .../internal/debug/core/model/PHPVariable.java | 229 ++++++++++---------- 1 files changed, 115 insertions(+), 114 deletions(-) diff --git a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPVariable.java b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPVariable.java index 40519a2..072e0b3 100644 --- a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPVariable.java +++ b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPVariable.java @@ -18,29 +18,30 @@ import net.sourceforge.phpdt.internal.debug.core.PHPDebugCorePlugin; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; +import org.eclipse.debug.core.DebugEvent; import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.model.IDebugTarget; import org.eclipse.debug.core.model.IValue; import org.eclipse.debug.core.model.IVariable; - /** * */ public class PHPVariable implements IVariable { - private PHPValue fValue; // The value of this variable - private String fName; // The name of the variable - private PHPStackFrame fStackFrame; // The stackframe this variable belongs to - private PHPVariable fParent; // The parent variable (a back link) - private String fLongName; // ??? + private PHPValue fValue; // The value of this variable + private String fName; // The name of the variable + private PHPStackFrame fStackFrame; // The stackframe this variable belongs to + private PHPVariable fParent; // The parent variable (a back link) + private String fLongName; // The qualified name /** * */ - PHPVariable () { - this (null, "", null, "", PHPValue.PEVT_UNKNOWN, null); // create an empty variable (a simple dummy node?) + PHPVariable() { + this(null, "", null, "", PHPValue.PEVT_UNKNOWN, null); // create an empty variable (a simple dummy node?) } /** @@ -52,43 +53,43 @@ public class PHPVariable implements IVariable { * @param valueType The type of the value (e.g. int, double, string etc.) @see PHPValue * @param subitems */ - PHPVariable (PHPStackFrame frame, String name, PHPVariable parent, String value, int valueType, Vector subitems) - { + public PHPVariable(PHPStackFrame frame, String name, PHPVariable parent, + String value, int valueType, Vector subitems) { this.fStackFrame = frame; - this.fValue = new PHPValue (frame, value, valueType, subitems); - this.fParent = parent; + this.fValue = new PHPValue(frame, value, valueType, subitems); + this.fParent = parent; - setName (name); + setName(name); } /** * * @param name */ - public void setName (String name) { - if ((fParent == null) || // If we have no parent for this variable - (fParent.getName () == "")) { // or we have a parent which is just a simple node ??? - fLongName = name; // Set the long name - fName = name; // and set the name + public void setName(String name) { + if ((fParent == null) || // If we have no parent for this variable + (fParent.getName() == "")) { // or we have a parent which is just a simple node ??? + fLongName = name; // Set the long name + fName = name; // and set the name return; } - switch (fParent.getReferenceType ()) { // Get the type of the parent variable - case PHPValue.PEVT_ARRAY : // It's an array - fName = "['" + name + "']"; // So set the variable name as [name] - fLongName = fParent.getLongName () + fName; // Set the longname to parentVariableLongname[name] - break; - - case PHPValue.PEVT_OBJECT : // It's an object - fName = name; // Set the name to name - fLongName = fParent.getLongName () + "." + fName; // Set the longname to parentVariableLongname.name - break; - - default : - fName = name; // Set the name to name - fLongName = name; // Set the Longname to name - break; + switch (fParent.getReferenceType()) { // Get the type of the parent variable + case PHPValue.PEVT_ARRAY: // It's an array + fName = "['" + name + "']"; // So set the variable name as [name] + fLongName = fParent.getLongName() + fName; // Set the longname to parentVariableLongname[name] + break; + + case PHPValue.PEVT_OBJECT: // It's an object + fName = name; // Set the name to name + fLongName = fParent.getLongName() + "->" + fName; // Set the longname to parentVariableLongname.name + break; + + default: + fName = name; // Set the name to name + fLongName = name; // Set the Longname to name + break; } } @@ -102,25 +103,23 @@ public class PHPVariable implements IVariable { /** * @see org.eclipse.debug.core.model.IVariable#getfName() */ - public String getName() { + public String getName() { return fName; } /** * */ - public PHPVariable getParent() - { + public PHPVariable getParent() { return fParent; } /** * */ - public void setParent(PHPVariable parent) - { - this.fParent=parent; - fLongName=parent.getLongName()+fName; + public void setParent(PHPVariable parent) { + this.fParent = parent; + fLongName = parent.getLongName() + fName; } /** @@ -155,7 +154,7 @@ public class PHPVariable implements IVariable { * @see org.eclipse.debug.core.model.IVariable#hasValueChanged() */ public boolean hasValueChanged() throws DebugException { - return fValue.hasValueChanged (); + return fValue.hasValueChanged(); } /** @@ -165,48 +164,48 @@ public class PHPVariable implements IVariable { * value. The variable view will show this variable in * a different color. */ - public void setValueChanged (boolean changed) { - fValue.setValueChanged (changed); + public void setValueChanged(boolean changed) { + fValue.setValueChanged(changed); } - /** - * @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier() - */ - public String getModelIdentifier() { - return getDebugTarget().getModelIdentifier(); - } - - /** - * @see org.eclipse.debug.core.model.IDebugElement#getDebugTarget() - */ - public IDebugTarget getDebugTarget() { - return fStackFrame.getDebugTarget(); - } - - /** - * @see org.eclipse.debug.core.model.IDebugElement#getLaunch() - */ - public ILaunch getLaunch() { - return getDebugTarget().getLaunch(); - } + /** + * @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier() + */ + public String getModelIdentifier() { + return getDebugTarget().getModelIdentifier(); + } + + /** + * @see org.eclipse.debug.core.model.IDebugElement#getDebugTarget() + */ + public IDebugTarget getDebugTarget() { + return fStackFrame.getDebugTarget(); + } + + /** + * @see org.eclipse.debug.core.model.IDebugElement#getLaunch() + */ + public ILaunch getLaunch() { + return getDebugTarget().getLaunch(); + } /** * @see org.eclipse.debug.core.model.IValueModification#setValue(java.lang.String) */ public void setValue(String expression) throws DebugException { String evalString; - if(fValue.getReferenceType()==PHPValue.PEVT_STRING) - evalString=fLongName+"=\""+expression+"\""; + if (fValue.getReferenceType() == PHPValue.PEVT_STRING) + evalString = fLongName + "=\"" + expression + "\""; else - evalString=fLongName+"="+expression; - PHPVariable[] vars=fStackFrame.getPHPDBGProxy().eval(fStackFrame,evalString); + evalString = fLongName + "=" + expression; + PHPVariable[] vars = fStackFrame.getPHPDBGProxy().eval(fStackFrame, + evalString); if (vars == null || vars.length == 0) { vars = fStackFrame.getPHPDBGProxy().eval(fStackFrame, fLongName); if (vars == null || vars.length == 0) { - // TODO code and message int code = 0; - String msg = "Could not assign and get variable"; + String msg = "Could not set " + expression + " to " + fLongName; Status status = new Status(Status.ERROR, PHPDebugCorePlugin.PLUGIN_ID, code, msg, null); PHPDebugCorePlugin.log(status); @@ -215,14 +214,17 @@ public class PHPVariable implements IVariable { } setValue(vars[0].fValue); + + DebugPlugin.getDefault().fireDebugEventSet( + new DebugEvent[] { new DebugEvent(this, DebugEvent.CHANGE, + DebugEvent.CONTENT) }); } /** * @see org.eclipse.debug.core.model.IValueModification#setValue(org.eclipse.debug.core.model.IValue) */ public void setValue(IValue value) throws DebugException { - // TODO Auto-generated method stub - this.fValue=(PHPValue)value; + this.fValue = (PHPValue) value; } /** @@ -248,55 +250,54 @@ public class PHPVariable implements IVariable { return false; } - /** - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class) - */ - public Object getAdapter(Class adapter) { - return Platform.getAdapterManager().getAdapter(this, adapter); - } + /** + * @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class) + */ + public Object getAdapter(Class adapter) { + return Platform.getAdapterManager().getAdapter(this, adapter); + } /** - * This method is called from variable view and denominates the variables with - * a type specific explanation. - * + * This method is called from variable view and denominates the variables + * with a type specific explanation. */ - public String toString () { - int type = -1; - String str = ""; - - switch (getReferenceType ()) { - case PHPValue.PEVT_ARRAY : // Variable is an array - int elements = fValue.getVariables ().length; // Get the number of child elements - - switch (elements) { // Switch for the number of child elements - case 0: // We have no child element - str = this.getName () + " [no elements]"; // string => 'varname [no elements]' - break; - - case 1: // We have exactly one child element - str = this.getName () + " [1 element]"; // string => 'varname [1 element]' - break; - - default: // We have more than one element - str = this.getName () + " [" + elements + " elements]"; // string => 'varname [x elements]' - break; - } - break; - - case PHPValue.PEVT_OBJECT : // Variable is an object - str = this.getName () + " [class: " + fValue.getValueString() + "]"; // string => 'varname [class: varvalue]' - break; - - case PHPValue.PEVT_STRING : // Variable is a string - str = this.getName () + " = \"" + fValue.getValueString() +"\"" ; // string => 'varname = "varvalue"' + public String toString() { + int type = -1; + String str = ""; + + switch (getReferenceType()) { + case PHPValue.PEVT_ARRAY: // Variable is an array + int elements = fValue.getVariables().length; // Get the number of child elements + + switch (elements) { // Switch for the number of child elements + case 0: // We have no child element + str = this.getName() + " [no elements]"; // string => 'varname [no elements]' break; - case PHPValue.PEVT_SOFTREF : // Variable is a soft reference - default : // or anything else - str = this.getName () + " = " + fValue.getValueString(); // string => 'varname = varvalue' - break; + case 1: // We have exactly one child element + str = this.getName() + " [1 element]"; // string => 'varname [1 element]' + break; + + default: // We have more than one element + str = this.getName() + " [" + elements + " elements]"; // string => 'varname [x elements]' + break; + } + break; + + case PHPValue.PEVT_OBJECT: // Variable is an object + str = this.getName() + " [class: " + fValue.getValueString() + "]"; // string => 'varname [class: varvalue]' + break; + + case PHPValue.PEVT_STRING: // Variable is a string + str = this.getName() + " = \"" + fValue.getValueString() + "\""; // string => 'varname = "varvalue"' + break; + + case PHPValue.PEVT_SOFTREF: // Variable is a soft reference + default: // or anything else + str = this.getName() + " = " + fValue.getValueString(); // string => 'varname = varvalue' + break; } return str; - } + } } -- 1.7.1