Refactory: remove unused classes, imports, fields and methods.
[phpeclipse.git] / net.sourceforge.phpeclipse.debug.core / src / net / sourceforge / phpdt / internal / debug / core / model / PHPVariable.java
index 072e0b3..94d3c99 100644 (file)
@@ -36,6 +36,7 @@ public class PHPVariable implements IVariable {
        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;
 
        /**
         *
@@ -119,7 +120,18 @@ public class PHPVariable implements IVariable {
         */
        public void setParent(PHPVariable parent) {
                this.fParent = parent;
-               fLongName = parent.getLongName() + fName;
+
+               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;
+               }
        }
 
        /**
@@ -213,7 +225,21 @@ public class PHPVariable implements IVariable {
                        }
                }
 
-               setValue(vars[0].fValue);
+               fValue = vars[0].fValue;
+
+               // 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());
+                               }
+                       }
+               }
 
                DebugPlugin.getDefault().fireDebugEventSet(
                                new DebugEvent[] { new DebugEvent(this, DebugEvent.CHANGE,
@@ -231,7 +257,16 @@ public class PHPVariable implements IVariable {
         * @see org.eclipse.debug.core.model.IValueModification#supportsValueModification()
         */
        public boolean supportsValueModification() {
-               return true;
+               return fModifiable;
+       }
+
+       /**
+        * Set whether this variable can be modified (default is true)
+        * 
+        * for Global Variables root element only
+        */
+       public void setModifiable(boolean modifiable) {
+               fModifiable = modifiable;
        }
 
        /**
@@ -262,7 +297,6 @@ public class PHPVariable implements IVariable {
         * with a type specific explanation.
         */
        public String toString() {
-               int type = -1;
                String str = "";
 
                switch (getReferenceType()) {
@@ -300,4 +334,19 @@ public class PHPVariable implements IVariable {
 
                return str;
        }
+
+       /*
+        * ONLY FOR net.sourceforge.phpdt.internal.debug.core.model.PHPDBGEvalString#copyItems(PHPVariable, PHPValue)
+        */
+       protected Object clone() throws CloneNotSupportedException {
+               PHPVariable var = new PHPVariable();
+               var.fValue = fValue;
+               var.fName = fName;
+               var.fStackFrame = fStackFrame;
+               var.fParent = fParent;
+               var.fLongName = fLongName;
+               var.fModifiable = fModifiable;
+               return var;
+       }
+
 }