Skip to content

Commit

Permalink
Show frames as children of GroupedStackFrame
Browse files Browse the repository at this point in the history
  • Loading branch information
gzsombor committed Jul 15, 2022
1 parent 66d9d5e commit 543e52c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ public void start(BundleContext context) throws Exception {
manager.registerAdapters(monitorFactory, JavaOwningThread.class);
manager.registerAdapters(monitorFactory, JavaWaitingThread.class);
manager.registerAdapters(monitorFactory, IJavaStackFrame.class);
manager.registerAdapters(monitorFactory, GroupedStackFrame.class);

IAdapterFactory targetFactory = new TargetAdapterFactory();
manager.registerAdapters(targetFactory, IJavaDebugTarget.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public class JavaThreadContentProvider extends JavaElementContentProvider {
*/
@Override
protected int getChildCount(Object element, IPresentationContext context, IViewerUpdate monitor) throws CoreException {
if (element instanceof GroupedStackFrame) {
return ((GroupedStackFrame) element).getFrameCount();
}
IJavaThread thread = (IJavaThread)element;
if (!thread.isSuspended()) {
return 0;
Expand Down Expand Up @@ -80,13 +83,20 @@ private int getFrameCount(IJavaThread thread) throws DebugException {
*/
@Override
protected Object[] getChildren(Object parent, int index, int length, IPresentationContext context, IViewerUpdate monitor) throws CoreException {
if (parent instanceof GroupedStackFrame) {
return getChildren((GroupedStackFrame) parent, index, length);
}
IJavaThread thread = (IJavaThread)parent;
if (!thread.isSuspended()) {
return EMPTY;
}
return getElements(getChildren(thread), index, length);
}

private Object[] getChildren(GroupedStackFrame parent, int index, int length) {
return parent.getFramesAsArray(index, length);
}

protected Object[] getChildren(IJavaThread thread) {
try {
if (thread instanceof JDIThread) {
Expand Down Expand Up @@ -170,6 +180,9 @@ protected boolean hasChildren(Object element, IPresentationContext context, IVie
}
}
}
if (element instanceof GroupedStackFrame) {
return ((GroupedStackFrame) element).getFrameCount() > 0;
}
return ((IJavaThread)element).hasStackFrames() ||
(isDisplayMonitors() && ((IJavaThread)element).hasOwnedMonitors());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider;
import org.eclipse.jdt.debug.core.IJavaStackFrame;
import org.eclipse.jdt.debug.core.IJavaThread;
import org.eclipse.jdt.internal.debug.core.model.GroupedStackFrame;
import org.eclipse.jdt.internal.debug.ui.variables.JavaStackFrameContentProvider;

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

if (IElementContentProvider.class.equals(adapterType)) {
if (adaptableObject instanceof IJavaThread) {
if (adaptableObject instanceof IJavaThread || adaptableObject instanceof GroupedStackFrame) {
return (T) getThreadPresentation();
}
if (adaptableObject instanceof IJavaStackFrame) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ public Object[] getFramesAsArray() {
return stackFrames.toArray();
}

public Object[] getFramesAsArray(int index, int length) {
var subList = stackFrames.subList(index, index + length);
return subList.isEmpty() ? null : subList.toArray();
}

public IJavaStackFrame getTopMostFrame() {
return !stackFrames.isEmpty() ? stackFrames.get(0) : null;
}
Expand Down

0 comments on commit 543e52c

Please sign in to comment.