1 package org.symbian.tools.tmw.debug.internal.launch; |
|
2 |
|
3 import org.chromium.debug.core.model.DebugTargetImpl; |
|
4 import org.chromium.debug.core.model.JavascriptThread; |
|
5 import org.chromium.debug.core.model.Messages; |
|
6 import org.chromium.debug.core.model.StackFrame; |
|
7 import org.chromium.debug.core.model.WorkspaceBridge.JsLabelProvider; |
|
8 import org.chromium.sdk.CallFrame; |
|
9 import org.chromium.sdk.DebugContext; |
|
10 import org.chromium.sdk.ExceptionData; |
|
11 import org.chromium.sdk.Script; |
|
12 import org.eclipse.core.filesystem.IFileStore; |
|
13 import org.eclipse.core.resources.IFile; |
|
14 import org.eclipse.debug.core.DebugException; |
|
15 import org.eclipse.osgi.util.NLS; |
|
16 |
|
17 public class WrtLabelProvider implements JsLabelProvider { |
|
18 |
|
19 public String getStackFrameLabel(StackFrame stackFrame) throws DebugException { |
|
20 CallFrame callFrame = stackFrame.getCallFrame(); |
|
21 String name = callFrame.getFunctionName(); |
|
22 Script script = callFrame.getScript(); |
|
23 if (script == null) { |
|
24 return "<unknown>"; |
|
25 } |
|
26 Object element = stackFrame.getLaunch().getSourceLocator().getSourceElement(stackFrame); |
|
27 if (element instanceof IFile) { |
|
28 IFile resource = (IFile) element; |
|
29 int line = script.getStartLine() + stackFrame.getLineNumber(); |
|
30 if (line != -1) { |
|
31 final String resourcePath = resource.getProjectRelativePath().toString(); |
|
32 name = NLS.bind("{0} [{1}:{2}]", new Object[] { name, resourcePath, line }); |
|
33 } |
|
34 } else if (element instanceof IFileStore) { |
|
35 return "(WRT System Library)"; |
|
36 } |
|
37 return name; |
|
38 } |
|
39 |
|
40 public String getTargetLabel(DebugTargetImpl debugTarget) throws DebugException { |
|
41 return "WRT Runtime"; |
|
42 } |
|
43 |
|
44 public String getThreadLabel(JavascriptThread thread) throws DebugException { |
|
45 return NLS.bind("JavaScript Thread ({0})", getThreadStateLabel(thread)); |
|
46 } |
|
47 |
|
48 private String getThreadStateLabel(JavascriptThread thread) { |
|
49 if (thread.isSuspended()) { |
|
50 DebugContext context = thread.getDebugTarget().getDebugContext(); |
|
51 ExceptionData exceptionData = context.getExceptionData(); |
|
52 if (exceptionData != null) { |
|
53 return NLS.bind(Messages.JsThread_ThreadLabelSuspendedExceptionFormat, |
|
54 exceptionData.getExceptionMessage()); |
|
55 } else { |
|
56 return Messages.JsThread_ThreadLabelSuspended; |
|
57 } |
|
58 } else { |
|
59 return Messages.JsThread_ThreadLabelRunning; |
|
60 } |
|
61 } |
|
62 |
|
63 } |
|