Refactor and enabled value view in variable view.
authorincastrix <incastrix>
Wed, 24 Dec 2008 17:40:24 +0000 (17:40 +0000)
committerincastrix <incastrix>
Wed, 24 Dec 2008 17:40:24 +0000 (17:40 +0000)
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugAbstractValue.java
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugTarget.java
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugVariable.java
net.sourceforge.phpeclipse.xdebug.ui/src/net/sourceforge/phpeclipse/xdebug/ui/php/launching/PHPDebugModelPresentation.java

index 9a68c77..6e69d0b 100644 (file)
@@ -25,11 +25,11 @@ import org.w3c.dom.NodeList;
 public abstract class XDebugAbstractValue  extends XDebugElement implements IValue {
        private IVariable[] fVariables;
        protected String fValueString;
-       /*protected*/private String fTypeName;
+       private String fTypeName;
        private boolean fhasChanged;
 
        public XDebugAbstractValue(XDebugStackFrame frame, Node varNode) throws DebugException  {
-               super((XDebugTarget) frame.getDebugTarget());
+               super(frame == null ? null : (XDebugTarget) frame.getDebugTarget());
 
                fTypeName = PHPDebugUtils.getAttributeValue(varNode,"type");
 
index 0c9f1d3..def9a6f 100644 (file)
@@ -3,8 +3,14 @@
  */
 package net.sourceforge.phpeclipse.xdebug.php.model;
 
+//import java.io.ByteArrayInputStream;
+//import java.io.IOException;
 import java.util.List;
 
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
 import net.sourceforge.phpeclipse.xdebug.core.IPHPDebugEvent;
 import net.sourceforge.phpeclipse.xdebug.core.IProxyEventListener;
 import net.sourceforge.phpeclipse.xdebug.core.IXDebugPreferenceConstants;
@@ -30,8 +36,10 @@ import org.eclipse.debug.core.model.ILineBreakpoint;
 import org.eclipse.debug.core.model.IMemoryBlock;
 import org.eclipse.debug.core.model.IProcess;
 import org.eclipse.debug.core.model.IThread;
+import org.w3c.dom.Document;
 import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
+//import org.xml.sax.SAXException;
 
 import net.sourceforge.phpeclipse.xdebug.core.xdebug.ResponseListener;
 import net.sourceforge.phpeclipse.xdebug.core.xdebug.XDebugConnection;
@@ -478,12 +486,38 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, IDebugE
                }
        }
        
-       public Node eval(String expression) {
-               int id = fDebugConnection.eval(expression);
-               XDebugResponse response = getResponse(id);
-
-               Node evalResponse = response.getParentNode();
-               Node evalProperty = evalResponse.getFirstChild();
+       public Node eval(String expression) throws DebugException {
+               Node evalProperty = null;
+               if (fDebugConnection != null) {
+                       int id = fDebugConnection.eval(expression);
+                       //Node evalProperty = new Node("");
+                       //if (id > 0) {
+                               XDebugResponse response = getResponse(id);
+               
+                               Node evalResponse = response.getParentNode();
+                               /*Node*/ evalProperty = evalResponse.getFirstChild();
+                       //} /*else {
+                               
+                       //}*/
+               } else {
+                       DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+                       DocumentBuilder builder = null;
+                       Document doc = null;
+                       
+                       try {
+                               builder = factory.newDocumentBuilder();
+                       } catch (ParserConfigurationException e) {
+                               e.printStackTrace();
+                       }
+                       //try {
+                               doc =  builder.newDocument(); // .parse("");
+                               evalProperty = doc.createElement("value");
+                       /*} catch (SAXException e) {
+                               e.printStackTrace();
+                       } catch (IOException e) {
+                               e.printStackTrace();
+                       }*/
+               }
                
                return evalProperty;
        }
index c136e76..553a400 100644 (file)
@@ -33,8 +33,8 @@ public class XDebugVariable extends XDebugElement implements IVariable {
         * @param name variable name
         */
        public XDebugVariable(XDebugStackFrame frame, Node property) throws DebugException {
+               super((XDebugTarget) frame.getDebugTarget());
                if (frame != null ) {
-                       //super((XDebugTarget) frame.getDebugTarget());
                        fFrame = frame;
                }
 
@@ -139,9 +139,9 @@ public class XDebugVariable extends XDebugElement implements IVariable {
         * 
         * @return the stack frame owning this variable
         */
-       protected XDebugStackFrame getStackFrame() {
+       /*protected XDebugStackFrame getStackFrame() {
                return fFrame;
-       }
+       }*/
        
        public String getValueString() throws DebugException {
                return fValue.getValueString();
index 028eb2c..c68dafe 100644 (file)
@@ -36,6 +36,7 @@ import org.eclipse.core.resources.IMarker;
 import org.eclipse.core.resources.IStorage;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.debug.core.DebugException;
 import org.eclipse.debug.core.DebugPlugin;
 import org.eclipse.debug.core.model.IBreakpoint;
 import org.eclipse.debug.core.model.ILineBreakpoint;
@@ -165,7 +166,7 @@ public class PHPDebugModelPresentation extends LabelProvider implements
                                return getBreakpointText((IBreakpoint) element);
                        } else if (element instanceof XDebugVariable) {
                                XDebugVariable phpVar = (XDebugVariable) element;
-                               return phpVar.toString();
+                               return phpVar.getName() + "= " + phpVar.getValueString();//toString();
                        }
                } catch (CoreException e) {
                        //return PHPDebugUiMessages
@@ -178,7 +179,13 @@ public class PHPDebugModelPresentation extends LabelProvider implements
         * @see IDebugModelPresentation#computeDetail(IValue, IValueDetailListener)
         */
        public void computeDetail(IValue value, IValueDetailListener listener) {
-               return;
+               String detail = "";
+               try {
+                       detail = value.getValueString();
+               } catch (DebugException e) {
+               }
+               listener.detailComputed(value, detail);
+               //return;
        }
 
        protected IBreakpoint getBreakpoint(IMarker marker) {