public class PHPVariable implements IVariable {
private PHPValue fValue; // The value of this variable
- private String fName; // The name of the 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
- private boolean fModifiable = true;
+ private String fLongName; // The qualified name
+ private boolean fModifiable = true;
/**
*
* @param valueType The type of the value (e.g. int, double, string etc.) @see PHPValue
* @param subitems
*/
- public 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);
}
/**
*/
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 ???
+ (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
}
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_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;
+ 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;
+ default:
+ fName = name; // Set the name to name
+ fLongName = name; // Set the Longname to name
+ break;
}
}
public void setParent(PHPVariable parent) {
this.fParent = parent;
- switch (fParent.getReferenceType()) {
- case PHPValue.PEVT_ARRAY:
- fLongName = fParent.getLongName() + fName;
- break;
- case PHPValue.PEVT_OBJECT:
- fLongName = fParent.getLongName() + "->" + fName;
- break;
- default:
- fLongName = fName;
- break;
+ switch (fParent.getReferenceType ()) {
+ case PHPValue.PEVT_ARRAY:
+ fLongName = fParent.getLongName() + fName;
+ break;
+
+ case PHPValue.PEVT_OBJECT:
+ fLongName = fParent.getLongName() + "->" + fName;
+ break;
+
+ default:
+ fLongName = fName;
+ break;
}
}
/**
* @see org.eclipse.debug.core.model.IValueModification#setValue(java.lang.String)
*/
- public void setValue(String expression) throws DebugException {
+ public void setValue (String expression) throws DebugException {
String evalString;
- if (fValue.getReferenceType() == PHPValue.PEVT_STRING)
+
+ if (fValue.getReferenceType () == PHPValue.PEVT_STRING) {
evalString = fLongName + "=\"" + expression + "\"";
- else
+ }
+ else {
evalString = fLongName + "=" + expression;
- PHPVariable[] vars = fStackFrame.getPHPDBGProxy().eval(fStackFrame,
- evalString);
+ }
+ PHPVariable[] vars = fStackFrame.getPHPDBGProxy ().eval (fStackFrame, evalString);
+///*
if (vars == null || vars.length == 0) {
- vars = fStackFrame.getPHPDBGProxy().eval(fStackFrame, fLongName);
+ vars = fStackFrame.getPHPDBGProxy ().eval (fStackFrame, fLongName);
+
if (vars == null || vars.length == 0) {
- int code = 0;
- String msg = "Could not set " + expression + " to " + fLongName;
- Status status = new Status(Status.ERROR,
- PHPDebugCorePlugin.PLUGIN_ID, code, msg, null);
- PHPDebugCorePlugin.log(status);
- throw new DebugException(status);
+ int code = 0;
+ String msg = "Could not set " + expression + " to " + fLongName;
+ Status status = new Status (Status.ERROR, PHPDebugCorePlugin.PLUGIN_ID, code, msg, null);
+ PHPDebugCorePlugin.log (status);
+
+ throw new DebugException (status);
}
}
-
+//*/
fValue = vars[0].fValue;
+///*
+ if (fValue.hasVariables ()) { // set parent if new value has children
+ Vector variables = fValue.getChildVariables ();
+
+ for (int i = 0; i < variables.size (); i++) {
+ PHPVariable var = (PHPVariable) variables.get (i);
+
+ var.setParent (this);
- // set parent if new value has children
- if (fValue.hasVariables()) {
- Vector variables = fValue.getChildVariables();
- for (int i = 0; i < variables.size(); i++) {
- PHPVariable var = (PHPVariable) variables.get(i);
- var.setParent(this);
- // adjust name if value type is array
- // (still bare name. make "['name']")
- if (fValue.getReferenceType() == PHPValue.PEVT_ARRAY) {
- var.setName(var.getName());
+ if (fValue.getReferenceType() == PHPValue.PEVT_ARRAY) { // adjust name if value type is array
+ var.setName (var.getName ()); // (still bare name. make "['name']")
}
}
}
- DebugPlugin.getDefault().fireDebugEventSet(
- new DebugEvent[] { new DebugEvent(this, DebugEvent.CHANGE,
- DebugEvent.CONTENT) });
+ DebugPlugin.getDefault().fireDebugEventSet (new DebugEvent[] {
+ new DebugEvent (this, DebugEvent.CHANGE, DebugEvent.CONTENT) });
+//*/
}
/**
/**
* Set whether this variable can be modified (default is true)
- *
+ *
* for Global Variables root element only
*/
public void setModifiable(boolean modifiable) {
*/
protected Object clone() throws CloneNotSupportedException {
PHPVariable var = new PHPVariable();
- var.fValue = fValue;
- var.fName = fName;
+
+ var.fValue = fValue;
+ var.fName = fName;
var.fStackFrame = fStackFrame;
- var.fParent = fParent;
- var.fLongName = fLongName;
+ var.fParent = fParent;
+ var.fLongName = fLongName;
var.fModifiable = fModifiable;
+
return var;
}