1) Added parameter 'parent' to XDebugVariable, so we can determine whether a variable...
authorrobekras <robekras>
Mon, 28 Mar 2011 16:05:30 +0000 (16:05 +0000)
committerrobekras <robekras>
Mon, 28 Mar 2011 16:05:30 +0000 (16:05 +0000)
2) Prepend a '$' to the php variable names, if it is a root node. This let us add the variable to watch expression window (and also no need for cutting of the '$' in PHPDebugHover.

net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugArrayValue.java
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugObjectValue.java
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugStackFrame.java
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugVariable.java
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugWatchExpressionDelegate.java

index 6174c3e..7680a89 100644 (file)
@@ -10,7 +10,7 @@ import org.w3c.dom.NodeList;
 public class XDebugArrayValue extends XDebugAbstractValue {
        private int NumChildren;
 
-       public XDebugArrayValue(XDebugStackFrame variable, Node value) throws DebugException {
+       public XDebugArrayValue(XDebugStackFrame variable, Node value, XDebugVariable parent) throws DebugException {
                super(variable, value);
 
                NumChildren = 0;
@@ -25,7 +25,7 @@ public class XDebugArrayValue extends XDebugAbstractValue {
                        
                        for (int i = 0; i<property.getLength(); i++) {
                                Node propertyNode = property.item(i);
-                               Variables[i] = new XDebugVariable(variable, propertyNode);
+                               Variables[i] = new XDebugVariable(variable, propertyNode, parent);
                        }
                        
                        setChildren(Variables);
index a94b869..4e7be86 100644 (file)
@@ -12,7 +12,7 @@ import org.w3c.dom.NodeList;
 public class XDebugObjectValue extends XDebugAbstractValue {
        private int NumChildren;
 
-       public XDebugObjectValue(XDebugStackFrame variable, Node value) throws DebugException {
+       public XDebugObjectValue(XDebugStackFrame variable, Node value, XDebugVariable parent) throws DebugException {
                super(variable, value);
 
                NumChildren = 0;
@@ -34,7 +34,7 @@ public class XDebugObjectValue extends XDebugAbstractValue {
                                String name     = PHPDebugUtils.getAttributeValue (propertyNode, "name");
 
                                if (!name.equals ("CLASSNAME")) {
-                                       a.add(new XDebugVariable(variable, propertyNode));
+                                       a.add(new XDebugVariable(variable, propertyNode, parent));
                                }
                        }
 
index a1c9ab4..0ff0e23 100644 (file)
@@ -287,13 +287,13 @@ public class XDebugStackFrame  extends XDebugElement implements IStackFrame, Com
 
                int length = property.getLength();
                for (int i = 0; i < length; i++) {
-                       XDebugVariable var = new XDebugVariable(this, property.item(i));
+                       XDebugVariable var = new XDebugVariable(this, property.item(i), null);
                        fVariables[i] = var;
                }
 
                int globalLength = propertyGlobal.getLength();
                for (int k = 0; k < globalLength; k++) {
-                       XDebugVariable var = new XDebugVariable(this, propertyGlobal.item(k));
+                       XDebugVariable var = new XDebugVariable(this, propertyGlobal.item(k), null);
                        fVariables[k + length] = var;
                }
        }
index 35b04a0..31b9b0d 100644 (file)
@@ -21,6 +21,7 @@ import org.w3c.dom.Node;
  */
 public class XDebugVariable extends XDebugElement implements IVariable {
        private String                          fName;
+       private String              fNameFull;
        private XDebugStackFrame        fFrame;
        private XDebugAbstractValue fValue;
        private String                          fFacet;
@@ -34,13 +35,26 @@ public class XDebugVariable extends XDebugElement implements IVariable {
         * @param frame owning stack frame
         * @param name variable name
         */
-       public XDebugVariable(XDebugStackFrame frame, Node property) throws DebugException {
+       public XDebugVariable(XDebugStackFrame frame, Node property, XDebugVariable parent) throws DebugException {
                super((XDebugTarget) frame.getDebugTarget());
+               
+               this.fParent = parent;
+               
                if (frame != null ) {
                        fFrame = frame;
                }
 
-               fName = PHPDebugUtils.getAttributeValue(property,"name");
+               if (parent == null) {
+                   fName = "$" + PHPDebugUtils.getAttributeValue(property,"name"); // Prepend the variable 'short' name with the php variable prefix '$'
+               }
+               else {
+                   fName = PHPDebugUtils.getAttributeValue(property,"name");       // If this is the root variable don't prepend prefix '$'
+               }
+                 
+               fNameFull = PHPDebugUtils.getAttributeValue(property,"fullname");   // The fullname has the '$' prepended, but it is the fully qualified name
+                                                                                   // e.g. $myvar->child->a_variable. The fullname would be suitable to take for
+                                                                                   // the setting a watch expression
+               
                if ("".equals(fName)) {
                        fName = PHPDebugUtils.getAttributeValue(property,"address");
                }
@@ -58,9 +72,9 @@ public class XDebugVariable extends XDebugElement implements IVariable {
                else if (typeName.equals("string") )
                        fValue = new XDebugStringValue(frame, property);
                else if (typeName.equals("array") )
-                       fValue = new XDebugArrayValue(frame, property);
+                       fValue = new XDebugArrayValue(frame, property, this);
                else if (typeName.equals("object") )
-                       fValue = new XDebugObjectValue(frame, property);
+                       fValue = new XDebugObjectValue(frame, property, this);
                else if (typeName.equals("resource") )
                        fValue = new XDebugResourceValue(frame, property);
                else
@@ -81,6 +95,13 @@ public class XDebugVariable extends XDebugElement implements IVariable {
                return fName;
        }
        
+       /*
+        * @return The fully qualified name of the variable
+        */
+    public String getNameFull () {
+        return fNameFull;
+    }
+
        /* (non-Javadoc)
         * @see org.eclipse.debug.core.model.IVariable#getReferenceTypeName()
         */
index e90aedd..d434a53 100644 (file)
@@ -28,7 +28,7 @@ public class XDebugWatchExpressionDelegate implements IWatchExpressionDelegate {
 
                        XDebugVariable variable = null;
                        try {
-                               variable = new XDebugVariable(frame, evalProperty);
+                               variable = new XDebugVariable(frame, evalProperty, null);
                                x = new XDebugWatchExpressionResult(expression, variable.getValue(), null);
                        } catch (DebugException e) {
                                // TODO Auto-generated catch block