1) Although dbg will be dropped from being supported or bundled with PHPeclipse,...
[phpeclipse.git] / net.sourceforge.phpeclipse.debug.core / src / net / sourceforge / phpdt / internal / debug / core / model / PHPVariable.java
index 94d3c99..8bd7406 100644 (file)
@@ -32,11 +32,11 @@ 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 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;
 
        /**
         *
@@ -54,13 +54,13 @@ public class PHPVariable implements IVariable {
         * @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);
        }
 
        /**
@@ -69,7 +69,7 @@ public class PHPVariable implements IVariable {
         */
        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
 
@@ -77,20 +77,20 @@ public class PHPVariable implements IVariable {
                }
 
                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;
                }
        }
 
@@ -121,16 +121,18 @@ public class PHPVariable implements IVariable {
        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;
                }
        }
 
@@ -204,46 +206,50 @@ public class PHPVariable implements IVariable {
        /**
         * @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) });
+//*/
        }
 
        /**
@@ -262,7 +268,7 @@ public class PHPVariable implements IVariable {
 
        /**
         * Set whether this variable can be modified (default is true)
-        * 
+        *
         * for Global Variables root element only
         */
        public void setModifiable(boolean modifiable) {
@@ -340,12 +346,14 @@ public class PHPVariable implements IVariable {
         */
        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;
        }