Skip to content

Commit 543e52c

Browse files
committed
Show frames as children of GroupedStackFrame
1 parent 66d9d5e commit 543e52c

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JDIDebugUIPlugin.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ public void start(BundleContext context) throws Exception {
385385
manager.registerAdapters(monitorFactory, JavaOwningThread.class);
386386
manager.registerAdapters(monitorFactory, JavaWaitingThread.class);
387387
manager.registerAdapters(monitorFactory, IJavaStackFrame.class);
388+
manager.registerAdapters(monitorFactory, GroupedStackFrame.class);
388389

389390
IAdapterFactory targetFactory = new TargetAdapterFactory();
390391
manager.registerAdapters(targetFactory, IJavaDebugTarget.class);

org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/monitors/JavaThreadContentProvider.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ public class JavaThreadContentProvider extends JavaElementContentProvider {
4949
*/
5050
@Override
5151
protected int getChildCount(Object element, IPresentationContext context, IViewerUpdate monitor) throws CoreException {
52+
if (element instanceof GroupedStackFrame) {
53+
return ((GroupedStackFrame) element).getFrameCount();
54+
}
5255
IJavaThread thread = (IJavaThread)element;
5356
if (!thread.isSuspended()) {
5457
return 0;
@@ -80,13 +83,20 @@ private int getFrameCount(IJavaThread thread) throws DebugException {
8083
*/
8184
@Override
8285
protected Object[] getChildren(Object parent, int index, int length, IPresentationContext context, IViewerUpdate monitor) throws CoreException {
86+
if (parent instanceof GroupedStackFrame) {
87+
return getChildren((GroupedStackFrame) parent, index, length);
88+
}
8389
IJavaThread thread = (IJavaThread)parent;
8490
if (!thread.isSuspended()) {
8591
return EMPTY;
8692
}
8793
return getElements(getChildren(thread), index, length);
8894
}
8995

96+
private Object[] getChildren(GroupedStackFrame parent, int index, int length) {
97+
return parent.getFramesAsArray(index, length);
98+
}
99+
90100
protected Object[] getChildren(IJavaThread thread) {
91101
try {
92102
if (thread instanceof JDIThread) {
@@ -170,6 +180,9 @@ protected boolean hasChildren(Object element, IPresentationContext context, IVie
170180
}
171181
}
172182
}
183+
if (element instanceof GroupedStackFrame) {
184+
return ((GroupedStackFrame) element).getFrameCount() > 0;
185+
}
173186
return ((IJavaThread)element).hasStackFrames() ||
174187
(isDisplayMonitors() && ((IJavaThread)element).hasOwnedMonitors());
175188
}

org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/monitors/MonitorsAdapterFactory.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider;
1818
import org.eclipse.jdt.debug.core.IJavaStackFrame;
1919
import org.eclipse.jdt.debug.core.IJavaThread;
20+
import org.eclipse.jdt.internal.debug.core.model.GroupedStackFrame;
2021
import org.eclipse.jdt.internal.debug.ui.variables.JavaStackFrameContentProvider;
2122

2223
/**
@@ -40,7 +41,7 @@ public class MonitorsAdapterFactory implements IAdapterFactory {
4041
public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
4142

4243
if (IElementContentProvider.class.equals(adapterType)) {
43-
if (adaptableObject instanceof IJavaThread) {
44+
if (adaptableObject instanceof IJavaThread || adaptableObject instanceof GroupedStackFrame) {
4445
return (T) getThreadPresentation();
4546
}
4647
if (adaptableObject instanceof IJavaStackFrame) {

org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/GroupedStackFrame.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ public Object[] getFramesAsArray() {
4141
return stackFrames.toArray();
4242
}
4343

44+
public Object[] getFramesAsArray(int index, int length) {
45+
var subList = stackFrames.subList(index, index + length);
46+
return subList.isEmpty() ? null : subList.toArray();
47+
}
48+
4449
public IJavaStackFrame getTopMostFrame() {
4550
return !stackFrames.isEmpty() ? stackFrames.get(0) : null;
4651
}

0 commit comments

Comments
 (0)