Skip to content

Commit 6a1d2bb

Browse files
committed
Add more javadoc, and adjust the used images for the stack frames.
1 parent a1db2c3 commit 6a1d2bb

5 files changed

Lines changed: 78 additions & 22 deletions

File tree

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,11 @@ protected Image getDebugElementImage(Object element) {
947947
return getDebugImage(image, flags);
948948
}
949949

950+
/**
951+
* Returns the image associated with the given {@link IJavaStackFrame}, decorated with overlays, if the stack frame is out of sync
952+
* ({@link IJavaStackFrame#isOutOfSynch()} or synchronized ({@link IJavaStackFrame#isSynchronized()}). The base image is acquired from the
953+
* {@link StackFramePresentationProvider}.
954+
*/
950955
private Image getStackFrameImage(IJavaStackFrame stackFrame) {
951956
var image = getStackFrameProvider().getStackFrameImage(stackFrame);
952957
if (image == null) {
@@ -988,9 +993,8 @@ protected Image getExpressionImage(Object expression) {
988993
}
989994

990995
/**
991-
* Returns the adornment flags for the given element.
992-
* These flags are used to render appropriate overlay
993-
* icons for the element.
996+
* Returns the adornment flags for the given element. These flags are used to render appropriate overlay icons for the element. It only supports
997+
* {@link IJavaThread} and {@link IJavaDebugTarget}, for other types it always returns 0.
994998
*/
995999
private int computeJDIAdornmentFlags(Object element) {
9961000
try {
@@ -2069,6 +2073,10 @@ protected JavaElementLabelProvider getJavaLabelProvider() {
20692073
return fJavaLabelProvider;
20702074
}
20712075

2076+
/**
2077+
* @return a {@link StackFramePresentationProvider} which responsible to classify stack frames into categories and could provide category specific
2078+
* visual representations.
2079+
*/
20722080
private StackFramePresentationProvider getStackFrameProvider() {
20732081
if (fStackFrameProvider == null) {
20742082
fStackFrameProvider = new StackFramePresentationProvider();

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

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2021 Zsombor Gegesy.
2+
* Copyright (c) 2021, 2025 Zsombor Gegesy and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -36,14 +36,17 @@ public final class StackFramePresentationProvider implements IPropertyChangeList
3636
public static final FilterManager PLATFORM_STACK_FRAMES = new FilterManager(IJDIPreferencesConstants.PREF_ACTIVE_PLATFORM_FRAME_FILTER_LIST, IJDIPreferencesConstants.PREF_INACTIVE_PLATFORM_FRAME_FILTER_LIST);
3737
public static final FilterManager CUSTOM_STACK_FRAMES = new FilterManager(IJDIPreferencesConstants.PREF_ACTIVE_CUSTOM_FRAME_FILTER_LIST, IJDIPreferencesConstants.PREF_INACTIVE_CUSTOM_FRAME_FILTER_LIST);
3838

39+
/**
40+
* Class to decide if a particular class name is part of a list of classes and list of packages.
41+
*/
3942
static class Filters {
4043
private final String[] filters;
4144

4245
Filters(String[] filters) {
4346
this.filters = filters;
4447
}
4548

46-
public boolean match(String fqcName) {
49+
boolean match(String fqcName) {
4750
for (String filter : filters) {
4851
if (filter.endsWith("*")) { //$NON-NLS-1$
4952
if (fqcName.startsWith(filter.substring(0, filter.length() - 1))) {
@@ -66,17 +69,26 @@ public boolean match(String fqcName) {
6669

6770
public StackFramePresentationProvider(IPreferenceStore store) {
6871
this.store = store;
69-
platform = getActivePlatformFilters(store);
70-
custom = getActiveCustomFilters(store);
72+
platform = createActivePlatformFilters(store);
73+
custom = createActiveCustomFilters(store);
7174
store.addPropertyChangeListener(this);
7275
collapseStackFrames = store.getBoolean(IJDIPreferencesConstants.PREF_COLLAPSE_STACK_FRAMES);
7376
}
7477

75-
private Filters getActivePlatformFilters(IPreferenceStore store) {
78+
/**
79+
* Create a {@link Filters} object to decide if a class is part of the 'platform'. The platform definition is stored in the
80+
* {@link IPreferenceStore}. By default, this is the classes provided by the JVM.
81+
*
82+
*/
83+
private Filters createActivePlatformFilters(IPreferenceStore store) {
7684
return new Filters(PLATFORM_STACK_FRAMES.getActiveList(store));
7785
}
7886

79-
private Filters getActiveCustomFilters(IPreferenceStore store) {
87+
/**
88+
* Create a {@link Filters} object to decide if a class is considered part of a custom, very important layer, which needs to be highlighted. This
89+
* definition is stored in the {@link IPreferenceStore}. By default, this is an empty list.
90+
*/
91+
private Filters createActiveCustomFilters(IPreferenceStore store) {
8092
return new Filters(CUSTOM_STACK_FRAMES.getActiveList(store));
8193
}
8294

@@ -92,11 +104,9 @@ public ImageDescriptor getStackFrameImage(IJavaStackFrame frame) {
92104
if (category != null) {
93105
switch (category) {
94106
case LIBRARY:
107+
case SYNTHETIC:
108+
case PLATFORM:
95109
return JavaPluginImages.DESC_OBJS_JAR;
96-
case TEST:
97-
return JavaPluginImages.DESC_OBJS_TEST_ATTRIB;
98-
case PRODUCTION:
99-
return JavaPluginImages.DESC_OBJS_CFILE;
100110
default:
101111
break;
102112
}
@@ -178,9 +188,9 @@ public void close() {
178188
public void propertyChange(PropertyChangeEvent event) {
179189
String prop = event.getProperty();
180190
if (IJDIPreferencesConstants.PREF_ACTIVE_PLATFORM_FRAME_FILTER_LIST.equals(prop)) {
181-
platform = getActivePlatformFilters(store);
191+
platform = createActivePlatformFilters(store);
182192
} else if (IJDIPreferencesConstants.PREF_ACTIVE_CUSTOM_FRAME_FILTER_LIST.equals(prop)) {
183-
custom = getActiveCustomFilters(store);
193+
custom = createActiveCustomFilters(store);
184194
} else if (IJDIPreferencesConstants.PREF_COLLAPSE_STACK_FRAMES.equals(prop)) {
185195
collapseStackFrames = (Boolean) event.getNewValue();
186196
}

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ private int getFrameCount(IJavaThread thread) throws DebugException {
8484
@Override
8585
protected Object[] getChildren(Object parent, int index, int length, IPresentationContext context, IViewerUpdate monitor) throws CoreException {
8686
if (parent instanceof GroupedStackFrame groupedFrame) {
87-
return getChildren(groupedFrame, index, length);
87+
return groupedFrame.getFramesAsArray(index, length);
8888
}
8989
IJavaThread thread = (IJavaThread)parent;
9090
if (!thread.isSuspended()) {
@@ -93,10 +93,6 @@ protected Object[] getChildren(Object parent, int index, int length, IPresentati
9393
return getElements(getChildren(thread), index, length);
9494
}
9595

96-
private Object[] getChildren(GroupedStackFrame parent, int index, int length) {
97-
return parent.getFramesAsArray(index, length);
98-
}
99-
10096
protected Object[] getChildren(IJavaThread thread) {
10197
try {
10298
if (thread instanceof JDIThread) {
@@ -131,6 +127,12 @@ protected Object[] getChildren(IJavaThread thread) {
131127
}
132128
}
133129

130+
/**
131+
* Return the stack frames for the given {@link IJavaThread}. If stack frames grouping is not switched on, it just returns all the stack frames
132+
* reported by the JVM. When stack frame grouping enabled, all frames that are not considered as {@link Category#PRODUCTION},
133+
* {@link Category#TEST} and {@link Category#CUSTOM_FILTERED} grouped into {@link GroupedStackFrame}s, those are folded by default, but can be
134+
* expanded on demand by the user.
135+
*/
134136
private List<Object> getStackFrames(IJavaThread thread) throws DebugException {
135137
var frames = thread.getStackFrames();
136138
var stackFrameProvider = getStackFrameProvider();
@@ -228,6 +230,9 @@ private ISchedulingRule getThreadRule(IViewerUpdate[] updates) {
228230
return null;
229231
}
230232

233+
/**
234+
* @return a {@link StackFramePresentationProvider} to provide classification of the stack frames.
235+
*/
231236
private synchronized StackFramePresentationProvider getStackFrameProvider() {
232237
if (stackFrameProvider == null) {
233238
stackFrameProvider = new StackFramePresentationProvider();

org.eclipse.jdt.debug/model/org/eclipse/jdt/debug/core/IJavaStackFrame.java

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,34 @@ public interface IJavaStackFrame extends IStackFrame, IJavaModifiers,
4242
*
4343
*/
4444
enum Category {
45-
CUSTOM_FILTERED, SYNTHETIC, PLATFORM, TEST, PRODUCTION, LIBRARY, UNKNOWN
45+
/**
46+
* The user specified a filter, can be used for highlighting specific, very important code layers.
47+
*/
48+
CUSTOM_FILTERED,
49+
/**
50+
* The stack frame represents a synthetic function call, which is not based on actual Java source code.
51+
*/
52+
SYNTHETIC,
53+
/**
54+
* Methods in classes that considered as platform, like code in 'java.*' packages.
55+
*/
56+
PLATFORM,
57+
/**
58+
* Classes found in a test source folder in the project.
59+
*/
60+
TEST,
61+
/**
62+
* Classes found in a non-test source folder in the project.
63+
*/
64+
PRODUCTION,
65+
/**
66+
* Classes coming from a library, not from the actual project.
67+
*/
68+
LIBRARY,
69+
/**
70+
* Classes with unknown origin.
71+
*/
72+
UNKNOWN
4673
}
4774

4875
/**

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2022 Zsombor Gegesy.
2+
* Copyright (c) 2022, 2025 Zsombor Gegesy and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -37,11 +37,17 @@ public int getFrameCount() {
3737
return stackFrames.size();
3838
}
3939

40+
/**
41+
* Return an array of child stack frames from the internally stored frames.
42+
*/
4043
public Object[] getFramesAsArray(int index, int length) {
4144
var subList = stackFrames.subList(index, Math.min(index + length, stackFrames.size()));
4245
return subList.isEmpty() ? null : subList.toArray();
4346
}
4447

48+
/**
49+
* @return the top most frame from the stack frames grouped inside.
50+
*/
4551
public IJavaStackFrame getTopMostFrame() {
4652
return !stackFrames.isEmpty() ? stackFrames.get(0) : null;
4753
}

0 commit comments

Comments
 (0)