*/
package net.sourceforge.phpeclipse.xdebug.php.model;
-import net.sourceforge.phpeclipse.xdebug.core.PHPDebugUtils;
-import net.sourceforge.phpeclipse.xdebug.core.DebugConnection.DebugResponse;
+//import java.net.MalformedURLException;
+import java.net.URL;
-import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IRegisterGroup;
import org.eclipse.debug.core.model.IStackFrame;
import org.eclipse.debug.core.model.IThread;
import org.eclipse.debug.core.model.IVariable;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
+//import net.sourceforge.phpeclipse.xdebug.core.IDebugConnection;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
/**
+ * @author PHPeclipse team
* @author Axel
- *
- * TODO To change the template for this generated type comment go to Window -
- * Preferences - Java - Code Style - Code Templates
+ *
*/
-public class XDebugStackFrame extends XDebugElement implements IStackFrame {
-
+public class XDebugStackFrame extends XDebugElement implements IStackFrame {
private XDebugThread fThread;
- // private String fName;
- private int fLineNo;
-
- private String fFileName;
-
private int fId;
-
- private IVariable[] fVariables;
-
- private String fLevel;
-
+
+ //private IPath fName;
+
+ private URL fName;
+
+ private int fLineNumber;
+ private int fLevel;
private String fType;
-
private String fWhere;
+ private IVariable[] fVariables;
+
+ private int fStepCount = 0;
+ //private int fCurrentStepCount = 0;
+
/**
- * Constructs a stack frame in the given thread with the given frame data.
+ * Constructs a stack frame in the given thread with the given
+ * frame data.
*
* @param thread
- * @param data
- * frame data
- * @param id
- * stack frame id (0 is the bottom of the stack)
+ * @param data frame data
+ * @param id stack frame id (0 is the bottom of the stack)
*/
- public XDebugStackFrame(XDebugThread thread, Node stackNode, int id) {
- super((XDebugTarget) thread.getDebugTarget());
+ public XDebugStackFrame(XDebugThread thread, int id) {
+ super(thread == null ? null : (XDebugTarget) thread.getDebugTarget());
fId = id;
fThread = thread;
- init(stackNode);
}
-
- /**
- * Initializes this frame based on its data
- *
- * @param data
- */
- private void init(Node stackNode) {
-
- fLevel = PHPDebugUtils.getAttributeValue(stackNode, "level");
- fType = PHPDebugUtils.getAttributeValue(stackNode, "type");
- String fileName = PHPDebugUtils.unescapeString(PHPDebugUtils
- .getAttributeValue(stackNode, "filename"));
- String lineNo = PHPDebugUtils.getAttributeValue(stackNode, "lineno");
-
- if (lineNo != "")
- fLineNo = Integer.parseInt(lineNo);
-
- fWhere = PHPDebugUtils.getAttributeValue(stackNode, "where");
-
- fFileName = (new Path(fileName)).lastSegment();
- int id = -1;
- try {
- id = ((XDebugTarget) getDebugTarget()).sendRequest("context_get",
- "-d " + fLevel);
- } catch (DebugException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- DebugResponse response = ((XDebugTarget) getDebugTarget())
- .getResponse(id);
- Node responseNode = response.getParentNode();
- NodeList property = responseNode.getChildNodes();
- fVariables = new IVariable[property.getLength()];
- for (int i = 0; i < property.getLength(); i++) {
- Node propertyNode = property.item(i);
- fVariables[i] = new XDebugVariable(this, propertyNode);
- }
-
- // int numVars = strings.length - 3;
- // fVariables = new IVariable[numVars];
- // for (int i = 0; i < numVars; i++) {
- // fVariables[i] = new XDebugVariable(this, strings[i + 3]);
- // }
+
+ public void incrementStepCounter() {
+ fStepCount++;
}
-
- /*
- * (non-Javadoc)
- *
+
+ /* (non-Javadoc)
* @see org.eclipse.debug.core.model.IStackFrame#getThread()
*/
public IThread getThread() {
return fThread;
}
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.debug.core.model.IStackFrame#getVariables()
- */
+
public IVariable[] getVariables() throws DebugException {
+ if (fVariables == null) {
+ fVariables = fTarget.getVariables(this, fLevel);
+ }
+
return fVariables;
}
-
- /*
- * (non-Javadoc)
- *
+
+ public void evaluateChange(IStackFrame OldStackFrame) throws DebugException {
+ IVariable[] OldVariable = ((XDebugStackFrame) OldStackFrame).getVariables();
+ for (int i = 0; i < fVariables.length; i++) {
+ ((XDebugVariable) fVariables[i]).setChange(OldVariable[i]);
+ }
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.debug.core.model.IStackFrame#hasVariables()
*/
public boolean hasVariables() throws DebugException {
- return fVariables.length > 0;
+ /*return fVariables.length > 0;*/
+ return true;
}
-
- /*
- * (non-Javadoc)
- *
+
+ /* (non-Javadoc)
* @see org.eclipse.debug.core.model.IStackFrame#getLineNumber()
*/
public int getLineNumber() throws DebugException {
- return fLineNo;
+ return fLineNumber;
}
-
- /*
- * (non-Javadoc)
- *
+
+ /* (non-Javadoc)
* @see org.eclipse.debug.core.model.IStackFrame#getCharStart()
*/
public int getCharStart() throws DebugException {
return -1;
}
-
- /*
- * (non-Javadoc)
- *
+
+ /* (non-Javadoc)
* @see org.eclipse.debug.core.model.IStackFrame#getCharEnd()
*/
public int getCharEnd() throws DebugException {
return -1;
}
-
- /*
- * (non-Javadoc)
- *
+
+ /* (non-Javadoc)fName
* @see org.eclipse.debug.core.model.IStackFrame#getName()
*/
public String getName() throws DebugException {
- return fFileName + "::" + fWhere + " : lineno " + fLineNo;
+ //String a = fName.getFile();
+ //return fName.lastSegment().toString()+"::"+fWhere+ " line: "+ fLineNumber;
+ return fName.toString()+"::"+fWhere+ " line: "+ fLineNumber;
}
-
- /*
- * (non-Javadoc)
- *
+
+ /* (non-Javadoc)
* @see org.eclipse.debug.core.model.IStackFrame#getRegisterGroups()
*/
public IRegisterGroup[] getRegisterGroups() throws DebugException {
return null;
}
-
- /*
- * (non-Javadoc)
- *
+
+ /* (non-Javadoc)
* @see org.eclipse.debug.core.model.IStackFrame#hasRegisterGroups()
*/
public boolean hasRegisterGroups() throws DebugException {
return false;
}
-
- /*
- * (non-Javadoc)
- *
+
+ /* (non-Javadoc)
* @see org.eclipse.debug.core.model.IStep#canStepInto()
*/
public boolean canStepInto() {
- return getThread().canStepInto();
+ return fThread.canStepInto();
}
-
- /*
- * (non-Javadoc)
- *
+
+ /* (non-Javadoc)
* @see org.eclipse.debug.core.model.IStep#canStepOver()
*/
public boolean canStepOver() {
- return getThread().canStepOver();
+ return fThread.canStepOver();
}
-
- /*
- * (non-Javadoc)
- *
+
+ /* (non-Javadoc)
* @see org.eclipse.debug.core.model.IStep#canStepReturn()
*/
public boolean canStepReturn() {
- return getThread().canStepReturn();
+ return fThread.canStepReturn();
}
-
- /*
- * (non-Javadoc)
- *
+
+ /* (non-Javadoc)
* @see org.eclipse.debug.core.model.IStep#isStepping()
*/
public boolean isStepping() {
- return getThread().isStepping();
+ return fThread.isStepping();
}
-
- /*
- * (non-Javadoc)
- *
+
+ /* (non-Javadoc)
* @see org.eclipse.debug.core.model.IStep#stepInto()
*/
public void stepInto() throws DebugException {
- getThread().stepInto();
+ fThread.stepInto();
}
-
- /*
- * (non-Javadoc)
- *
+
+ /* (non-Javadoc)
* @see org.eclipse.debug.core.model.IStep#stepOver()
*/
public void stepOver() throws DebugException {
- getThread().stepOver();
+ fThread.stepOver();
}
-
- /*
- * (non-Javadoc)
- *
+
+ /* (non-Javadoc)
* @see org.eclipse.debug.core.model.IStep#stepReturn()
*/
public void stepReturn() throws DebugException {
- getThread().stepReturn();
+ fThread.stepReturn();
}
-
- /*
- * (non-Javadoc)
- *
+
+ /* (non-Javadoc)
* @see org.eclipse.debug.core.model.ISuspendResume#canResume()
*/
public boolean canResume() {
- return getThread().canResume();
+ return fThread.canResume();
}
-
- /*
- * (non-Javadoc)
- *
+
+ /* (non-Javadoc)
* @see org.eclipse.debug.core.model.ISuspendResume#canSuspend()
*/
public boolean canSuspend() {
- return getThread().canSuspend();
+ return fThread.canSuspend();
}
-
- /*
- * (non-Javadoc)
- *
+
+ /* (non-Javadoc)
* @see org.eclipse.debug.core.model.ISuspendResume#isSuspended()
*/
public boolean isSuspended() {
- return getThread().isSuspended();
+ return fThread.isSuspended();
}
-
- /*
- * (non-Javadoc)
- *
+
+ /* (non-Javadoc)
* @see org.eclipse.debug.core.model.ISuspendResume#resume()
*/
public void resume() throws DebugException {
- getThread().resume();
+ fThread.resume();
}
-
- /*
- * (non-Javadoc)
- *
+
+ /* (non-Javadoc)
* @see org.eclipse.debug.core.model.ISuspendResume#suspend()
*/
public void suspend() throws DebugException {
- getThread().suspend();
+ fThread.suspend();
}
-
- /*
- * (non-Javadoc)
- *
+
+ /* (non-Javadoc)
* @see org.eclipse.debug.core.model.ITerminate#canTerminate()
*/
public boolean canTerminate() {
- return getThread().canTerminate();
+ return fThread.canTerminate();
}
-
- /*
- * (non-Javadoc)
- *
+
+ /* (non-Javadoc)
* @see org.eclipse.debug.core.model.ITerminate#isTerminated()
*/
public boolean isTerminated() {
- return getThread().isTerminated();
+ return fThread.isTerminated();
}
-
- /*
- * (non-Javadoc)
- *
+
+ /* (non-Javadoc)
* @see org.eclipse.debug.core.model.ITerminate#terminate()
*/
public void terminate() throws DebugException {
- getThread().terminate();
+ fThread.terminate();
}
-
+
/**
- * Returns the name of the source file this stack frame is associated with.
+ * Returns the name of the source file this stack frame is associated
+ * with.
*
- * @return the name of the source file this stack frame is associated with
+ * @return the name of the source file this stack frame is associated
+ * with. If the file associated with this frame does not exists, it returns null.
*/
public String getSourceName() {
- return fFileName;
+ if (fName == null) {
+ return null;
+ }
+ IPath a = new Path(fName.getFile());
+ return a.lastSegment();
}
- /*
- * (non-Javadoc)
- *
+ public boolean isSameStackFrame(Object obj) {
+ boolean isSameStackFrame = false;
+
+ 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) {
+ }*/
+ }
+
+ return isSameStackFrame;
+ }
+
+ /* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(Object obj) {
if (obj instanceof XDebugStackFrame) {
- XDebugStackFrame sf = (XDebugStackFrame) obj;
+ XDebugStackFrame sf = (XDebugStackFrame)obj;
try {
- return sf.getSourceName().equals(getSourceName())
- && sf.getLineNumber() == getLineNumber()
- && sf.fId == fId;
+ 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;*/
} catch (DebugException e) {
}
}
+
return false;
}
-
- /*
- * (non-Javadoc)
- *
+
+ /* (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() + fId;
+ return getSourceName().hashCode() + fLevel;
}
-
+
/**
- * Returns this stack frame's unique identifier within its thread
*
* @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;
+ }
+}
\ No newline at end of file