Skip to main content
summaryrefslogtreecommitdiffstats
blob: e92f16e36eddab6c65fd5e6d4027e7dfb29dec1e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/*******************************************************************************
 * Copyright (c) 2007 Chase Technology Ltd - http://www.chasetechnology.co.uk
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Doug Satchwell (Chase Technology Ltd) - initial API and implementation
 *******************************************************************************/
package org.eclipse.wst.xsl.launching.model;

import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.debug.core.model.IStackFrame;
import org.eclipse.debug.core.model.IThread;

public class XSLThread extends XSLDebugElement implements IThread
{

	/**
	 * Breakpoints this thread is suspended at or <code>null</code> if none.
	 */
	private IBreakpoint[] fBreakpoints;

	/**
	 * Whether this thread is stepping
	 */
	private boolean fStepping = false;

	/**
	 * Constructs a new thread for the given target
	 */
	public XSLThread(IDebugTarget target)
	{
		super(target);
	}

	public IStackFrame[] getStackFrames() throws DebugException
	{
		if (isSuspended())
		{
			return ((IXSLDebugTarget) getDebugTarget()).getStackFrames();
		}
		else
		{
			return new IStackFrame[0];
		}
	}

	public boolean hasStackFrames() throws DebugException
	{
		return isSuspended();
	}

	public int getPriority() throws DebugException
	{
		return 0;
	}

	public IStackFrame getTopStackFrame() throws DebugException
	{
		IStackFrame[] frames = getStackFrames();
		if (frames.length > 0)
		{
			return frames[0];
		}
		return null;
	}

	public String getName() throws DebugException
	{
		return "Thread[1]"; //$NON-NLS-1$
	}

	public IBreakpoint[] getBreakpoints()
	{
		if (fBreakpoints == null)
		{
			return new IBreakpoint[0];
		}
		return fBreakpoints;
	}

	/**
	 * Sets the breakpoints this thread is suspended at, or <code>null</code>
	 * if none.
	 * 
	 * @param breakpoints
	 *            the breakpoints this thread is suspended at, or
	 *            <code>null</code> if none
	 * @since 1.0
	 */
	public void setBreakpoints(IBreakpoint[] breakpoints)
	{
		fBreakpoints = breakpoints;
	}

	public boolean canResume()
	{
		return isSuspended();
	}

	public boolean canSuspend()
	{
		return !isSuspended();
	}

	public boolean isSuspended()
	{
		return getDebugTarget().isSuspended();
	}

	public void resume() throws DebugException
	{
		getDebugTarget().resume();
	}

	public void suspend() throws DebugException
	{
		getDebugTarget().suspend();
	}

	public boolean canStepInto()
	{
		return isSuspended();
	}

	public boolean canStepOver()
	{
		return isSuspended();
	}

	public boolean canStepReturn()
	{
		return isSuspended();
	}

	public boolean isStepping()
	{
		return fStepping;
	}

	public void stepInto() throws DebugException
	{
		((IXSLDebugTarget) getDebugTarget()).stepInto();
	}

	public void stepOver() throws DebugException
	{
		((IXSLDebugTarget) getDebugTarget()).stepOver();
	}

	public void stepReturn() throws DebugException
	{
		((IXSLDebugTarget) getDebugTarget()).stepReturn();
	}

	public boolean canTerminate()
	{
		return !isTerminated();
	}

	public boolean isTerminated()
	{
		return getDebugTarget().isTerminated();
	}

	public void terminate() throws DebugException
	{
		getDebugTarget().terminate();
	}

	/**
	 * @since 1.0
	 */
	public void setStepping(boolean stepping)
	{
		fStepping = stepping;
	}
}

Back to the top