Modified: 1764120 - Variables View doesn't show global vars in class context
[phpeclipse.git] / net.sourceforge.phpeclipse.debug.core / src / net / sourceforge / phpdt / internal / debug / core / model / PHPVariable.java
index 072e0b3..e452669 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;
        }
 
        /**