More refactory.
[phpeclipse.git] / net.sourceforge.phpeclipse.xdebug.core / src / net / sourceforge / phpeclipse / xdebug / php / model / XDebugStackFrame.java
index 5fbece5..e7b1182 100644 (file)
@@ -6,13 +6,9 @@
  */
 package net.sourceforge.phpeclipse.xdebug.php.model;
 
+import java.net.MalformedURLException;
 import java.net.URL;
 
-//import net.sourceforge.phpeclipse.xdebug.core.Base64;
-//import net.sourceforge.phpeclipse.xdebug.core.PHPDebugUtils;
-//import net.sourceforge.phpeclipse.xdebug.core.xdebug.ResponseListener.DebugResponse;
-//import net.sourceforge.phpeclipse.xdebug.core.xdebug.ResponseListener.XDebugResponse;
-
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.debug.core.DebugException;
@@ -31,10 +27,7 @@ import org.w3c.dom.NodeList;
 public class XDebugStackFrame  extends XDebugElement implements IStackFrame {
        private XDebugThread fThread;
 
-       private int fId;
-       
        private URL fName;
-       
        private int fLineNumber;
        private int fLevel;
        private String fType;
@@ -52,10 +45,19 @@ public class XDebugStackFrame  extends XDebugElement implements IStackFrame {
         * @param data frame data
         * @param id stack frame id (0 is the bottom of the stack)
         */
-       public XDebugStackFrame(XDebugThread thread, int id) {
+       public XDebugStackFrame(XDebugThread thread, int level, String type, int lineNumber, String where, /*URL*/String filename) {
                super(thread == null ? null : (XDebugTarget) thread.getDebugTarget());
-               fId = id;
+               
+               fLevel = level;
                fThread = thread;
+               fType = type;
+               fLineNumber = lineNumber;
+               fWhere = where; 
+               try {
+               fName = new URL(filename);
+               } catch (MalformedURLException e) {
+                       e.printStackTrace();
+               }
        }
        
        public void incrementStepCounter() {
@@ -71,8 +73,8 @@ public class XDebugStackFrame  extends XDebugElement implements IStackFrame {
        
        public IVariable[] getVariables() throws DebugException {
                if (fVariables == null) {
-                       Node dfl = fTarget.getLocalVariables(fLevel);
-                       Node dfg = fTarget.getGlobalVariables(fLevel);
+                       Node dfl = ((XDebugTarget) getDebugTarget()).getLocalVariables(fLevel);
+                       Node dfg = ((XDebugTarget) getDebugTarget()).getGlobalVariables(fLevel);
                        parseVariable(dfl, dfg);
                }
 
@@ -139,8 +141,6 @@ public class XDebugStackFrame  extends XDebugElement implements IStackFrame {
         * @see org.eclipse.debug.core.model.IStackFrame#getName()
         */
        public String getName() throws DebugException {
-               //String a = fName.getFile();
-               //return fName.lastSegment().toString()+"::"+fWhere+ " line: "+ fLineNumber;
                return fName.toString()+"::"+fWhere+ " line: "+ fLineNumber;
        }
        
@@ -283,15 +283,9 @@ public class XDebugStackFrame  extends XDebugElement implements IStackFrame {
                
                if (obj instanceof XDebugStackFrame) {
                        XDebugStackFrame sf = (XDebugStackFrame)obj;
-                       //try {
-                               isSameStackFrame = sf.getSourceName().equals(getSourceName()) &&
-                                       /*sf.getLineNumber() == getLineNumber() &&*/
-                                       /*sf.getLevel() == getLevel() &&*/
-                                       sf.getType().equals(getType()) &&
-                                       sf.getWhere().equals(getWhere()); //&&
-                                       /*sf.fId == fId;*/
-                       /*} catch (DebugException e) {
-                       }*/
+                       isSameStackFrame = sf.getSourceName().equals(getSourceName()) &&
+                               sf.getType().equals(getType()) &&
+                               sf.getWhere().equals(getWhere()); //&&
                }
 
                return isSameStackFrame;
@@ -304,14 +298,11 @@ public class XDebugStackFrame  extends XDebugElement implements IStackFrame {
                if (obj instanceof XDebugStackFrame) {
                        XDebugStackFrame sf = (XDebugStackFrame)obj;
                        try {
-                               return sf.getSourceName().equals(getSourceName()) &&
-                                       sf.getLineNumber() == getLineNumber() &&
-                                       sf.getLevel() == getLevel() &&
-                                       sf.getType().equals(getType()) &&
-                                       sf.getWhere().equals(getWhere());
-/*                                     sf.getType() == getType() &&
-                                       sf.getWhere() == getWhere() &&*/
-                                       /*sf.fId == fId;*/
+                               return sf.getSourceName().equals(fName) &&
+                                       sf.getLineNumber() == fLineNumber &&
+                                       sf.getLevel() == fLevel &&
+                                       sf.getType().equals(fType) &&
+                                       sf.getWhere().equals(fWhere);
                        } catch (DebugException e) {
                        }
                }
@@ -320,74 +311,29 @@ public class XDebugStackFrame  extends XDebugElement implements IStackFrame {
        }
        
        /* (non-Javadoc)
-        * @see java.lang.Object#equals(java.lang.Object)
-        */
-       public boolean equalsOld(Object obj) {
-               if (obj instanceof XDebugStackFrame) {
-                       XDebugStackFrame sf = (XDebugStackFrame)obj;
-                       try {
-                               return sf.getSourceName().equals(getSourceName()) &&
-                                       sf.getLineNumber() == getLineNumber() &&
-                                       sf.fId == fId;
-                       } catch (DebugException e) {
-                       }
-               }
-               return false;
-       }
-       
-       /* (non-Javadoc)
         * @see java.lang.Object#hashCode()
         */
        public int hashCode() {
-//             return getSourceName().hashCode() + fId;
                return getSourceName().hashCode() + fLevel;
        }
        
-       /**
-        * 
-        * @return this stack frame's unique identifier within its thread
-        */
-       protected int getIdentifier() {
-               return fId;
-       }
-
-
-       public void setFullName(URL name) {
-               fName = name;
-       }
-
-
        public URL getFullName() {
                return fName;
        }
        
-
        public int getLevel() {
                return fLevel;
        }
 
-       public void setLevel(int level) {
-               fLevel = level;
-               fId = level;
-       }
-
        public String getType() {
                return fType;
        }
 
-       public void setType(String type) {
-               fType = type;
-       }
-
        public String getWhere() {
                return fWhere;
        }
 
-       public void setWhere(String where) {
-               fWhere = where;
-       }
-
-       public void setLineNumber(int newlineNumber) {
-               fLineNumber = newlineNumber;
+       public boolean setVariableValue(XDebugVariable variable, String expression)  throws DebugException {
+               return ((XDebugTarget) getDebugTarget()).setVarValue("$" + variable.getName(), expression);
        }
 }
\ No newline at end of file