Skip to content

Commit 7a91818

Browse files
committed
Bug 574170 - Add coloring to the stack frames of the debug thread view
and add an action to enable/disable colorization from the context menu. All of the categorize can be switched on or off Use separate images for different stack frame categories. Update the labels to 'Your Source code', 'Your Test code', 'Highlighted ...'
1 parent cc699b9 commit 7a91818

File tree

20 files changed

+1320
-85
lines changed

20 files changed

+1320
-85
lines changed

org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/AutomatedSuite.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142
import org.eclipse.jdt.debug.tests.ui.DebugViewTests;
143143
import org.eclipse.jdt.debug.tests.ui.DetailPaneManagerTests;
144144
import org.eclipse.jdt.debug.tests.ui.OpenFromClipboardTests;
145+
import org.eclipse.jdt.debug.tests.ui.StackFramePresentationProviderTest;
145146
import org.eclipse.jdt.debug.tests.ui.ViewManagementTests;
146147
import org.eclipse.jdt.debug.tests.ui.presentation.ModelPresentationTests;
147148
import org.eclipse.jdt.debug.tests.ui.presentation.ModelPresentationTests18;
@@ -231,6 +232,7 @@ public AutomatedSuite() {
231232
addTest(new TestSuite(StepFilterTests.class));
232233
addTest(new TestSuite(StepIntoSelectionTests.class));
233234
addTest(new TestSuite(InstanceFilterTests.class));
235+
addTest(new TestSuite(StackFramePresentationProviderTest.class));
234236
if (JavaProjectHelper.isJava6Compatible()) {
235237
addTest(new TestSuite(ForceReturnTests.class));
236238
}
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2021 Zsombor Gegesy.
3+
*
4+
* This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License 2.0
6+
* which accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*
11+
* Contributors:
12+
* Zsombor Gegesy - initial API and implementation
13+
*******************************************************************************/
14+
package org.eclipse.jdt.debug.tests.ui;
15+
16+
import java.lang.reflect.InvocationHandler;
17+
import java.lang.reflect.Method;
18+
import java.lang.reflect.Proxy;
19+
20+
import org.eclipse.debug.core.DebugException;
21+
import org.eclipse.debug.core.ILaunch;
22+
import org.eclipse.jdt.debug.core.IJavaReferenceType;
23+
import org.eclipse.jdt.debug.core.IJavaStackFrame;
24+
import org.eclipse.jdt.debug.tests.AbstractDebugTest;
25+
import org.eclipse.jdt.internal.debug.ui.IJDIPreferencesConstants;
26+
import org.eclipse.jdt.internal.debug.ui.StackFramePresentationProvider;
27+
import org.eclipse.jface.preference.IPreferenceStore;
28+
import org.eclipse.jface.preference.PreferenceStore;
29+
30+
public class StackFramePresentationProviderTest extends AbstractDebugTest {
31+
32+
public StackFramePresentationProviderTest(String name) {
33+
super(name);
34+
}
35+
36+
private StackFramePresentationProvider provider;
37+
private IPreferenceStore preferenceStore;
38+
39+
private static class LaunchMock implements InvocationHandler {
40+
@Override
41+
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
42+
return null;
43+
}
44+
}
45+
private static class JavaStackFrameMock implements InvocationHandler {
46+
47+
final IJavaReferenceType referenceType;
48+
final boolean synthetic;
49+
50+
public JavaStackFrameMock(IJavaReferenceType referenceType, boolean synthetic) {
51+
this.referenceType = referenceType;
52+
this.synthetic = synthetic;
53+
}
54+
55+
@Override
56+
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
57+
var methodName = method.getName();
58+
if ("getReferenceType".equals(methodName)) {
59+
return referenceType;
60+
}
61+
if ("isSynthetic".equals(methodName)) {
62+
return synthetic;
63+
}
64+
if ("getLaunch".equals(methodName)) {
65+
return Proxy.newProxyInstance(StackFramePresentationProviderTest.class.getClassLoader(), new Class[] {
66+
ILaunch.class }, new LaunchMock());
67+
68+
}
69+
return null;
70+
}
71+
}
72+
73+
private static class JavaReferenceTypeMock implements InvocationHandler {
74+
75+
final String name;
76+
77+
public JavaReferenceTypeMock(String name) {
78+
this.name = name;
79+
}
80+
81+
@Override
82+
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
83+
if ("getName".equals(method.getName())) {
84+
return name;
85+
}
86+
return null;
87+
}
88+
}
89+
90+
@Override
91+
protected void setUp() throws Exception {
92+
super.setUp();
93+
preferenceStore = new PreferenceStore();
94+
preferenceStore.setValue(IJDIPreferencesConstants.PREF_ACTIVE_PLATFORM_FRAME_FILTER_LIST, "java.*,javax.*");
95+
preferenceStore.setValue(IJDIPreferencesConstants.PREF_COLORIZE_STACK_FRAMES, true);
96+
preferenceStore.setValue(IJDIPreferencesConstants.PREF_COLORIZE_PLATFORM_METHODS, true);
97+
preferenceStore.setValue(IJDIPreferencesConstants.PREF_COLORIZE_CUSTOM_METHODS, true);
98+
preferenceStore.setValue(IJDIPreferencesConstants.PREF_COLORIZE_SYNTHETIC_METHODS, true);
99+
provider = new StackFramePresentationProvider(preferenceStore);
100+
}
101+
102+
@Override
103+
protected void tearDown() throws Exception {
104+
super.tearDown();
105+
provider.close();
106+
}
107+
108+
private IJavaReferenceType createReference(String name) {
109+
return (IJavaReferenceType) Proxy.newProxyInstance(StackFramePresentationProviderTest.class.getClassLoader(), new Class[] {
110+
IJavaReferenceType.class }, new JavaReferenceTypeMock(name));
111+
}
112+
113+
private IJavaStackFrame createFrame(IJavaReferenceType refType, boolean syntetic) {
114+
return (IJavaStackFrame) Proxy.newProxyInstance(StackFramePresentationProviderTest.class.getClassLoader(), new Class[] {
115+
IJavaStackFrame.class }, new JavaStackFrameMock(refType, syntetic));
116+
}
117+
118+
private IJavaStackFrame.Category categorize(String refTypeName, boolean syntetic) throws DebugException {
119+
return categorize(createReference(refTypeName), syntetic);
120+
}
121+
122+
private IJavaStackFrame.Category categorize(IJavaReferenceType refType, boolean syntetic) throws DebugException {
123+
return provider.categorize(createFrame(refType, syntetic));
124+
}
125+
126+
public void testFiltering() throws DebugException {
127+
assertEquals(IJavaStackFrame.Category.SYNTHETIC, categorize("org.eclipse.Something", true));
128+
assertEquals(IJavaStackFrame.Category.PLATFORM, categorize("java.lang.String", false));
129+
assertEquals(IJavaStackFrame.Category.UNKNOWN, categorize("org.eclipse.Other", false));
130+
}
131+
132+
public void testUpdateWorks() throws DebugException {
133+
var something = createReference("org.eclipse.Something");
134+
var other = createReference("org.eclipse.Other");
135+
assertEquals(IJavaStackFrame.Category.UNKNOWN, categorize(something, false));
136+
assertEquals(IJavaStackFrame.Category.UNKNOWN, categorize(other, false));
137+
preferenceStore.setValue(IJDIPreferencesConstants.PREF_ACTIVE_CUSTOM_FRAME_FILTER_LIST, "org.eclipse.Something");
138+
139+
assertEquals(IJavaStackFrame.Category.CUSTOM_FILTERED, categorize(something, false));
140+
assertEquals(IJavaStackFrame.Category.UNKNOWN, categorize(other, false));
141+
}
142+
143+
public void testSwitchOffPlatform() throws DebugException {
144+
assertEquals(IJavaStackFrame.Category.PLATFORM, categorize("java.lang.String", false));
145+
preferenceStore.setValue(IJDIPreferencesConstants.PREF_COLORIZE_PLATFORM_METHODS, false);
146+
assertEquals(IJavaStackFrame.Category.UNKNOWN, categorize("java.lang.String", false));
147+
}
148+
149+
}

org.eclipse.jdt.debug.ui/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.5.0,4.0.0)",
4040
org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)",
4141
org.eclipse.jdt.core;bundle-version="[3.28.0,4.0.0)",
4242
org.eclipse.debug.ui;bundle-version="[3.13.400,4.0.0)",
43-
org.eclipse.jdt.debug;bundle-version="[3.19.0,4.0.0)",
43+
org.eclipse.jdt.debug;bundle-version="[3.20.0,4.0.0)",
4444
org.eclipse.jdt.launching;bundle-version="[3.19.0,4.0.0)",
4545
org.eclipse.jdt.ui;bundle-version="[3.26.0,4.0.0)",
4646
org.eclipse.core.runtime;bundle-version="[3.11.0,4.0.0)",

org.eclipse.jdt.debug.ui/plugin.properties

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ JavaSnippetEditor.label= Scrapbook
9898
javaStepFilterPrefName=Step Filtering
9999
javaDetailFormattersPrefName=Detail Formatters
100100

101+
javaStackFramePrefName=Stack Frames
102+
101103
javaVariableHoverLabel=Variable Values
102104
javaVariableHoverDescription=Shows the value of the selected variable when debugging.
103105

@@ -178,6 +180,9 @@ showMonitorThreadInfo.tooltip=Show the Thread & Monitor Information
178180
showNullEntriesAction.label=Show &Null Array Entries
179181
showNullEntriesAction.tooltip=Show Null Array Entries
180182

183+
colorizeStackFrames.label=Mark Stack Frames with &Colors
184+
colorizeStackFrames.tooltip=Based on the function mark the stack frames with different colors
185+
181186
stepIntoSelectionHyperlinkDetector.label=Step Into Selection
182187
stepIntoSelectionHyperlinkDetector.description=Performs the step into selection command on demand via a hyperlink
183188

@@ -289,6 +294,36 @@ InDeadlockColorDefinition.description=The color used to render deadlocked thread
289294
LabeledObjectColorDefinition.label=Labeled objects
290295
LabeledObjectColorDefinition.description=The color used to render labeled objects in debug views.
291296

297+
CustomFilteredStackFrameFgColorDefinition.label=Highlighted methods
298+
CustomFilteredStackFrameBgColorDefinition.label=Highlighted methods background
299+
CustomFilteredStackFrameFgColorDefinition.description=The color used to render the Highlighted stack frames in the Debug view.
300+
CustomFilteredStackFrameBgColorDefinition.description=The background color used to render the Highlighted stack frames in the Debug view.
301+
302+
SyntheticStackFrameFgColorDefinition.label=Synthetic methods
303+
SyntheticStackFrameBgColorDefinition.label=Synthetic methods background
304+
SyntheticStackFrameFgColorDefinition.description=The color used to render stack frames for synthetic methods in the Debug view.
305+
SyntheticStackFrameBgColorDefinition.description=The background color used to render stack frames for synthetic methods in the Debug view.
306+
307+
PlatformStackFrameFgColorDefinition.label=Platform methods
308+
PlatformStackFrameBgColorDefinition.label=Platform methods background
309+
PlatformStackFrameFgColorDefinition.description=The color used to render stack frames for Platform methods in the Debug view.
310+
PlatformStackFrameBgColorDefinition.description=The background color used to render stack frame for Platform methods in the Debug view.
311+
312+
TestStackFrameFgColorDefinition.label=Your Test code
313+
TestStackFrameBgColorDefinition.label=Your Test code background
314+
TestStackFrameFgColorDefinition.description=The color used to render stack frames for Your Test code in the Debug view.
315+
TestStackFrameBgColorDefinition.description=The background color used to render stack frames for Your Test code in the Debug view.
316+
317+
LibraryStackFrameFgColorDefinition.label=Library code
318+
LibraryStackFrameBgColorDefinition.label=Library code background
319+
LibraryStackFrameFgColorDefinition.description=The color used to render stack frames for Library code in the Debug view.
320+
LibraryStackFrameBgColorDefinition.description=The background color used to render stack frames for Library code in the Debug view.
321+
322+
ProductionStackFrameFgColorDefinition.label=Your Source code
323+
ProductionStackFrameBgColorDefinition.label=Your Source code background
324+
ProductionStackFrameFgColorDefinition.description=The color used used to render stack frames for Your Source code in the Debug view.
325+
ProductionStackFrameBgColorDefinition.description=The background color used to render stack frames for Your Source code in the Debug view.
326+
292327
javaStackTraceConsole.label= Java Stack Trace Console
293328
FormatStackTraceActionDelegate.name= Format
294329
FormatStackTraceActionDelegate.tooltip= Format

org.eclipse.jdt.debug.ui/plugin.xml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2208,6 +2208,15 @@
22082208
style="toggle"
22092209
menubarPath="org.eclipse.jdt.debug.ui.LaunchView.javaSubmenu/javaPart"
22102210
id="org.eclipse.jdt.debug.ui.launchViewActions.ShowMonitorThreadInfo"/>
2211+
<action
2212+
helpContextId="colorize_stack_frames_action_context"
2213+
label="%colorizeStackFrames.label"
2214+
tooltip="%colorizeStackFrames.tooltip"
2215+
class="org.eclipse.jdt.internal.debug.ui.actions.ColorizeStackFramesAction"
2216+
style="toggle"
2217+
menubarPath="org.eclipse.jdt.debug.ui.LaunchView.javaSubmenu/javaPart"
2218+
id="org.eclipse.jdt.debug.ui.launchViewActions.ColorizeStackFrames"/>
2219+
22112220
<menu
22122221
id="org.eclipse.jdt.debug.ui.LaunchView.javaSubmenu"
22132222
label="%LaunchViewJavaSubmenu.label"
@@ -2484,6 +2493,13 @@
24842493
id="org.eclipse.jdt.debug.ui.JavaDebugPreferencePage">
24852494
<keywordReference id="org.eclipse.jdt.debug.ui.general"/>
24862495
</page>
2496+
<page
2497+
name="%javaStackFramePrefName"
2498+
category="org.eclipse.jdt.debug.ui.JavaDebugPreferencePage"
2499+
class="org.eclipse.jdt.internal.debug.ui.JavaStackFramePreferencePage"
2500+
id="org.eclipse.jdt.debug.ui.JavaStackFramePreferencePage">
2501+
<keywordReference id="org.eclipse.jdt.debug.ui.stepFilters"/>
2502+
</page>
24872503
<page
24882504
name="%javaStepFilterPrefName"
24892505
category="org.eclipse.jdt.debug.ui.JavaDebugPreferencePage"
@@ -3595,6 +3611,108 @@ M4 = Platform-specific fourth key
35953611
value="COLOR_RED">
35963612
<description>%LabeledObjectColorDefinition.description</description>
35973613
</colorDefinition>
3614+
3615+
<colorDefinition
3616+
categoryId="org.eclipse.debug.ui.presentation"
3617+
id="org.eclipse.jdt.debug.ui.CustomFilteredStackFrameFgColor"
3618+
isEditable="true"
3619+
label="%CustomFilteredStackFrameFgColorDefinition.label"
3620+
value="COLOR_LIST_FOREGROUND">
3621+
<description>%CustomFilteredStackFrameFgColorDefinition.description</description>
3622+
</colorDefinition>
3623+
<colorDefinition
3624+
categoryId="org.eclipse.debug.ui.presentation"
3625+
id="org.eclipse.jdt.debug.ui.CustomFilteredStackFrameBgColor"
3626+
isEditable="true"
3627+
label="%CustomFilteredStackFrameBgColorDefinition.label"
3628+
value="252,226,186">
3629+
<description>%CustomFilteredStackFrameBgColorDefinition.description</description>
3630+
</colorDefinition>
3631+
3632+
<colorDefinition
3633+
categoryId="org.eclipse.debug.ui.presentation"
3634+
id="org.eclipse.jdt.debug.ui.SyntheticStackFrameFgColor"
3635+
isEditable="true"
3636+
label="%SyntheticStackFrameFgColorDefinition.label"
3637+
value="202,130,130">
3638+
<description>%SyntheticStackFrameFgColorDefinition.description</description>
3639+
</colorDefinition>
3640+
<colorDefinition
3641+
categoryId="org.eclipse.debug.ui.presentation"
3642+
id="org.eclipse.jdt.debug.ui.SyntheticStackFrameBgColor"
3643+
isEditable="true"
3644+
label="%SyntheticStackFrameBgColorDefinition.label"
3645+
value="COLOR_LIST_BACKGROUND">
3646+
<description>%SyntheticStackFrameBgColorDefinition.description</description>
3647+
</colorDefinition>
3648+
3649+
<colorDefinition
3650+
categoryId="org.eclipse.debug.ui.presentation"
3651+
id="org.eclipse.jdt.debug.ui.PlatformStackFrameFgColor"
3652+
isEditable="true"
3653+
label="%PlatformStackFrameFgColorDefinition.label"
3654+
value="151,203,155">
3655+
<description>%PlatformStackFrameFgColorDefinition.description</description>
3656+
</colorDefinition>
3657+
<colorDefinition
3658+
categoryId="org.eclipse.debug.ui.presentation"
3659+
id="org.eclipse.jdt.debug.ui.PlatformStackFrameBgColor"
3660+
isEditable="true"
3661+
label="%PlatformStackFrameBgColorDefinition.label"
3662+
value="COLOR_LIST_BACKGROUND">
3663+
<description>%PlatformStackFrameBgColorDefinition.description</description>
3664+
</colorDefinition>
3665+
3666+
<colorDefinition
3667+
categoryId="org.eclipse.debug.ui.presentation"
3668+
id="org.eclipse.jdt.debug.ui.TestStackFrameFgColor"
3669+
isEditable="true"
3670+
label="%TestStackFrameFgColorDefinition.label"
3671+
value="COLOR_LIST_FOREGROUND">
3672+
<description>%TestStackFrameFgColorDefinition.description</description>
3673+
</colorDefinition>
3674+
<colorDefinition
3675+
categoryId="org.eclipse.debug.ui.presentation"
3676+
id="org.eclipse.jdt.debug.ui.TestStackFrameBgColor"
3677+
isEditable="true"
3678+
label="%TestStackFrameBgColorDefinition.label"
3679+
value="229,253,204">
3680+
<description>%TestStackFrameBgColorDefinition.description</description>
3681+
</colorDefinition>
3682+
3683+
<colorDefinition
3684+
categoryId="org.eclipse.debug.ui.presentation"
3685+
id="org.eclipse.jdt.debug.ui.ProductionStackFrameFgColor"
3686+
isEditable="true"
3687+
label="%ProductionStackFrameFgColorDefinition.label"
3688+
value="52,101,164">
3689+
<description>%ProductionStackFrameFgColorDefinition.description</description>
3690+
</colorDefinition>
3691+
<colorDefinition
3692+
categoryId="org.eclipse.debug.ui.presentation"
3693+
id="org.eclipse.jdt.debug.ui.ProductionStackFrameBgColor"
3694+
isEditable="true"
3695+
label="%ProductionStackFrameBgColorDefinition.label"
3696+
value="COLOR_LIST_BACKGROUND">
3697+
<description>%ProductionStackFrameBgColorDefinition.description</description>
3698+
</colorDefinition>
3699+
3700+
<colorDefinition
3701+
categoryId="org.eclipse.debug.ui.presentation"
3702+
id="org.eclipse.jdt.debug.ui.LibraryStackFrameFgColor"
3703+
isEditable="true"
3704+
label="%LibraryStackFrameFgColorDefinition.label"
3705+
value="205,167,251">
3706+
<description>%LibraryStackFrameFgColorDefinition.description</description>
3707+
</colorDefinition>
3708+
<colorDefinition
3709+
categoryId="org.eclipse.debug.ui.presentation"
3710+
id="org.eclipse.jdt.debug.ui.LibraryStackFrameBgColor"
3711+
isEditable="true"
3712+
label="%LibraryStackFrameBgColorDefinition.label"
3713+
value="COLOR_LIST_BACKGROUND">
3714+
<description>%LibraryStackFrameBgColorDefinition.description</description>
3715+
</colorDefinition>
35983716
</extension>
35993717
<extension
36003718
point="org.eclipse.debug.ui.variableValueEditors">

0 commit comments

Comments
 (0)