2 * Created on 23.11.2004
4 * TODO To change the template for this generated file go to
5 * Window - Preferences - Java - Code Style - Code Templates
7 package net.sourceforge.phpeclipse.xdebug.php.model;
9 //import java.net.MalformedURLException;
12 import org.eclipse.debug.core.DebugException;
13 import org.eclipse.debug.core.model.IRegisterGroup;
14 import org.eclipse.debug.core.model.IStackFrame;
15 import org.eclipse.debug.core.model.IThread;
16 import org.eclipse.debug.core.model.IVariable;
17 //import net.sourceforge.phpeclipse.xdebug.core.IDebugConnection;
18 import org.eclipse.core.runtime.IPath;
19 import org.eclipse.core.runtime.Path;
22 * @author PHPeclipse team
26 public class XDebugStackFrame extends XDebugElement implements IStackFrame {
27 private XDebugThread fThread;
31 //private IPath fName;
35 private int fLineNumber;
38 private String fWhere;
40 private IVariable[] fVariables;
42 private int fStepCount = 0;
43 //private int fCurrentStepCount = 0;
46 * Constructs a stack frame in the given thread with the given
50 * @param data frame data
51 * @param id stack frame id (0 is the bottom of the stack)
53 public XDebugStackFrame(XDebugThread thread, int id) {
54 super(thread == null ? null : (XDebugTarget) thread.getDebugTarget());
59 public void incrementStepCounter() {
64 * @see org.eclipse.debug.core.model.IStackFrame#getThread()
66 public IThread getThread() {
70 public IVariable[] getVariables() throws DebugException {
71 if (fVariables == null) {
72 fVariables = fTarget.getVariables(this, fLevel);
78 public void evaluateChange(IStackFrame OldStackFrame) throws DebugException {
79 IVariable[] OldVariable = ((XDebugStackFrame) OldStackFrame).getVariables();
80 for (int i = 0; i < fVariables.length; i++) {
81 ((XDebugVariable) fVariables[i]).setChange(OldVariable[i]);
86 * @see org.eclipse.debug.core.model.IStackFrame#hasVariables()
88 public boolean hasVariables() throws DebugException {
89 /*return fVariables.length > 0;*/
94 * @see org.eclipse.debug.core.model.IStackFrame#getLineNumber()
96 public int getLineNumber() throws DebugException {
101 * @see org.eclipse.debug.core.model.IStackFrame#getCharStart()
103 public int getCharStart() throws DebugException {
108 * @see org.eclipse.debug.core.model.IStackFrame#getCharEnd()
110 public int getCharEnd() throws DebugException {
114 /* (non-Javadoc)fName
115 * @see org.eclipse.debug.core.model.IStackFrame#getName()
117 public String getName() throws DebugException {
118 //String a = fName.getFile();
119 //return fName.lastSegment().toString()+"::"+fWhere+ " line: "+ fLineNumber;
120 return fName.toString()+"::"+fWhere+ " line: "+ fLineNumber;
124 * @see org.eclipse.debug.core.model.IStackFrame#getRegisterGroups()
126 public IRegisterGroup[] getRegisterGroups() throws DebugException {
131 * @see org.eclipse.debug.core.model.IStackFrame#hasRegisterGroups()
133 public boolean hasRegisterGroups() throws DebugException {
138 * @see org.eclipse.debug.core.model.IStep#canStepInto()
140 public boolean canStepInto() {
141 return fThread.canStepInto();
145 * @see org.eclipse.debug.core.model.IStep#canStepOver()
147 public boolean canStepOver() {
148 return fThread.canStepOver();
152 * @see org.eclipse.debug.core.model.IStep#canStepReturn()
154 public boolean canStepReturn() {
155 return fThread.canStepReturn();
159 * @see org.eclipse.debug.core.model.IStep#isStepping()
161 public boolean isStepping() {
162 return fThread.isStepping();
166 * @see org.eclipse.debug.core.model.IStep#stepInto()
168 public void stepInto() throws DebugException {
173 * @see org.eclipse.debug.core.model.IStep#stepOver()
175 public void stepOver() throws DebugException {
180 * @see org.eclipse.debug.core.model.IStep#stepReturn()
182 public void stepReturn() throws DebugException {
183 fThread.stepReturn();
187 * @see org.eclipse.debug.core.model.ISuspendResume#canResume()
189 public boolean canResume() {
190 return fThread.canResume();
194 * @see org.eclipse.debug.core.model.ISuspendResume#canSuspend()
196 public boolean canSuspend() {
197 return fThread.canSuspend();
201 * @see org.eclipse.debug.core.model.ISuspendResume#isSuspended()
203 public boolean isSuspended() {
204 return fThread.isSuspended();
208 * @see org.eclipse.debug.core.model.ISuspendResume#resume()
210 public void resume() throws DebugException {
215 * @see org.eclipse.debug.core.model.ISuspendResume#suspend()
217 public void suspend() throws DebugException {
222 * @see org.eclipse.debug.core.model.ITerminate#canTerminate()
224 public boolean canTerminate() {
225 return fThread.canTerminate();
229 * @see org.eclipse.debug.core.model.ITerminate#isTerminated()
231 public boolean isTerminated() {
232 return fThread.isTerminated();
236 * @see org.eclipse.debug.core.model.ITerminate#terminate()
238 public void terminate() throws DebugException {
243 * Returns the name of the source file this stack frame is associated
246 * @return the name of the source file this stack frame is associated
247 * with. If the file associated with this frame does not exists, it returns null.
249 public String getSourceName() {
253 IPath a = new Path(fName.getFile());
254 return a.lastSegment();
257 public boolean isSameStackFrame(Object obj) {
258 boolean isSameStackFrame = false;
260 if (obj instanceof XDebugStackFrame) {
261 XDebugStackFrame sf = (XDebugStackFrame)obj;
263 isSameStackFrame = sf.getSourceName().equals(getSourceName()) &&
264 /*sf.getLineNumber() == getLineNumber() &&*/
265 /*sf.getLevel() == getLevel() &&*/
266 sf.getType().equals(getType()) &&
267 sf.getWhere().equals(getWhere()); //&&
269 /*} catch (DebugException e) {
273 return isSameStackFrame;
277 * @see java.lang.Object#equals(java.lang.Object)
279 public boolean equals(Object obj) {
280 if (obj instanceof XDebugStackFrame) {
281 XDebugStackFrame sf = (XDebugStackFrame)obj;
283 return sf.getSourceName().equals(getSourceName()) &&
284 sf.getLineNumber() == getLineNumber() &&
285 sf.getLevel() == getLevel() &&
286 sf.getType().equals(getType()) &&
287 sf.getWhere().equals(getWhere());
288 /* sf.getType() == getType() &&
289 sf.getWhere() == getWhere() &&*/
291 } catch (DebugException e) {
299 * @see java.lang.Object#equals(java.lang.Object)
301 public boolean equalsOld(Object obj) {
302 if (obj instanceof XDebugStackFrame) {
303 XDebugStackFrame sf = (XDebugStackFrame)obj;
305 return sf.getSourceName().equals(getSourceName()) &&
306 sf.getLineNumber() == getLineNumber() &&
308 } catch (DebugException e) {
315 * @see java.lang.Object#hashCode()
317 public int hashCode() {
318 // return getSourceName().hashCode() + fId;
319 return getSourceName().hashCode() + fLevel;
324 * @return this stack frame's unique identifier within its thread
326 protected int getIdentifier() {
331 public void setFullName(URL name) {
336 public URL getFullName() {
341 public int getLevel() {
345 public void setLevel(int level) {
350 public String getType() {
354 public void setType(String type) {
358 public String getWhere() {
362 public void setWhere(String where) {
366 public void setLineNumber(int newlineNumber) {
367 fLineNumber = newlineNumber;