Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add coloring to the stack frames of the debug thread view #81

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion org.eclipse.jdt.debug.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jdt.debug.tests; singleton:=true
Bundle-Version: 3.12.600.qualifier
Bundle-Version: 3.12.700.qualifier
Bundle-ClassPath: javadebugtests.jar
Bundle-Activator: org.eclipse.jdt.debug.testplugin.JavaTestPlugin
Bundle-Vendor: %providerName
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.jdt.debug.tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</parent>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.debug.tests</artifactId>
<version>3.12.600-SNAPSHOT</version>
<version>3.12.700-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<properties>
<testSuite>${project.artifactId}</testSuite>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
import org.eclipse.jdt.debug.tests.ui.DetailPaneManagerTests;
import org.eclipse.jdt.debug.tests.ui.JavaSnippetEditorTest;
import org.eclipse.jdt.debug.tests.ui.OpenFromClipboardTests;
import org.eclipse.jdt.debug.tests.ui.StackFramePresentationProviderTest;
import org.eclipse.jdt.debug.tests.ui.ViewManagementTests;
import org.eclipse.jdt.debug.tests.ui.VirtualThreadsDebugViewTests;
import org.eclipse.jdt.debug.tests.ui.presentation.ModelPresentationTests;
Expand Down Expand Up @@ -243,6 +244,7 @@ public AutomatedSuite() {
addTest(new TestSuite(StepFilterTests.class));
addTest(new TestSuite(StepIntoSelectionTests.class));
addTest(new TestSuite(InstanceFilterTests.class));
addTest(new TestSuite(StackFramePresentationProviderTest.class));
if (JavaProjectHelper.isJava6Compatible()) {
addTest(new TestSuite(ForceReturnTests.class));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
/*******************************************************************************
* Copyright (c) 2021 Zsombor Gegesy.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Zsombor Gegesy - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.debug.tests.ui;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.jdt.debug.core.IJavaReferenceType;
import org.eclipse.jdt.debug.core.IJavaStackFrame;
import org.eclipse.jdt.debug.tests.AbstractDebugTest;
import org.eclipse.jdt.internal.debug.ui.IJDIPreferencesConstants;
import org.eclipse.jdt.internal.debug.ui.StackFramePresentationProvider;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceStore;

public class StackFramePresentationProviderTest extends AbstractDebugTest {

public StackFramePresentationProviderTest(String name) {
super(name);
}

private StackFramePresentationProvider provider;
private IPreferenceStore preferenceStore;

private static class LaunchMock implements InvocationHandler {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
return null;
}
}
private static class JavaStackFrameMock implements InvocationHandler {

final IJavaReferenceType referenceType;
final boolean synthetic;

public JavaStackFrameMock(IJavaReferenceType referenceType, boolean synthetic) {
this.referenceType = referenceType;
this.synthetic = synthetic;
}

@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
var methodName = method.getName();
if ("getReferenceType".equals(methodName)) {
return referenceType;
}
if ("isSynthetic".equals(methodName)) {
return synthetic;
}
if ("getLaunch".equals(methodName)) {
return Proxy.newProxyInstance(StackFramePresentationProviderTest.class.getClassLoader(), new Class[] {
ILaunch.class }, new LaunchMock());

}
return null;
}
}

private static class JavaReferenceTypeMock implements InvocationHandler {

final String name;

public JavaReferenceTypeMock(String name) {
this.name = name;
}

@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if ("getName".equals(method.getName())) {
return name;
}
return null;
}
}

@Override
protected void setUp() throws Exception {
super.setUp();
preferenceStore = new PreferenceStore();
preferenceStore.setValue(IJDIPreferencesConstants.PREF_ACTIVE_PLATFORM_FRAME_FILTER_LIST, "java.*,javax.*");
preferenceStore.setValue(IJDIPreferencesConstants.PREF_COLORIZE_STACK_FRAMES, true);
preferenceStore.setValue(IJDIPreferencesConstants.PREF_COLORIZE_PLATFORM_METHODS, true);
preferenceStore.setValue(IJDIPreferencesConstants.PREF_COLORIZE_CUSTOM_METHODS, true);
preferenceStore.setValue(IJDIPreferencesConstants.PREF_COLORIZE_SYNTHETIC_METHODS, true);
provider = new StackFramePresentationProvider(preferenceStore);
}

@Override
protected void tearDown() throws Exception {
super.tearDown();
provider.close();
}

private IJavaReferenceType createReference(String name) {
return (IJavaReferenceType) Proxy.newProxyInstance(StackFramePresentationProviderTest.class.getClassLoader(), new Class[] {
IJavaReferenceType.class }, new JavaReferenceTypeMock(name));
}

private IJavaStackFrame createFrame(IJavaReferenceType refType, boolean syntetic) {
return (IJavaStackFrame) Proxy.newProxyInstance(StackFramePresentationProviderTest.class.getClassLoader(), new Class[] {
IJavaStackFrame.class }, new JavaStackFrameMock(refType, syntetic));
}

private IJavaStackFrame.Category categorize(String refTypeName, boolean syntetic) throws DebugException {
return categorize(createReference(refTypeName), syntetic);
}

private IJavaStackFrame.Category categorize(IJavaReferenceType refType, boolean syntetic) throws DebugException {
return provider.categorize(createFrame(refType, syntetic));
}

public void testFiltering() throws DebugException {
assertEquals(IJavaStackFrame.Category.SYNTHETIC, categorize("org.eclipse.Something", true));
assertEquals(IJavaStackFrame.Category.PLATFORM, categorize("java.lang.String", false));
assertEquals(IJavaStackFrame.Category.UNKNOWN, categorize("org.eclipse.Other", false));
}

public void testUpdateWorks() throws DebugException {
var something = createReference("org.eclipse.Something");
var other = createReference("org.eclipse.Other");
assertEquals(IJavaStackFrame.Category.UNKNOWN, categorize(something, false));
assertEquals(IJavaStackFrame.Category.UNKNOWN, categorize(other, false));
preferenceStore.setValue(IJDIPreferencesConstants.PREF_ACTIVE_CUSTOM_FRAME_FILTER_LIST, "org.eclipse.Something");

assertEquals(IJavaStackFrame.Category.CUSTOM_FILTERED, categorize(something, false));
assertEquals(IJavaStackFrame.Category.UNKNOWN, categorize(other, false));
}

public void testSwitchOffPlatform() throws DebugException {
assertEquals(IJavaStackFrame.Category.PLATFORM, categorize("java.lang.String", false));
preferenceStore.setValue(IJDIPreferencesConstants.PREF_COLORIZE_PLATFORM_METHODS, false);
assertEquals(IJavaStackFrame.Category.UNKNOWN, categorize("java.lang.String", false));
}

}
31 changes: 31 additions & 0 deletions org.eclipse.jdt.debug.ui/css/e4-dark_jdi_debug_prefstyle.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*******************************************************************************
* Copyright (c) 2024 Zsombor Gegesy and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Zsombor Gegesy - initial API and implementation
*******************************************************************************/

/* ############################## Debug preferences ############################## */

IEclipsePreferences#org-eclipse-ui-workbench:org-eclipse-jdt-debug-ui {
preferences:
'org.eclipse.jdt.debug.ui.CustomFilteredStackFrameFgColor=252,226,186'
'org.eclipse.jdt.debug.ui.CustomFilteredStackFrameBgColor=53,53,53'
'org.eclipse.jdt.debug.ui.ProductionStackFrameFgColor=238,238,255'
'org.eclipse.jdt.debug.ui.ProductionStackFrameBgColor=53,53,53'
'org.eclipse.jdt.debug.ui.TestStackFrameFgColor=238,255,238'
'org.eclipse.jdt.debug.ui.TestStackFrameBgColor=53,53,53'
'org.eclipse.jdt.debug.ui.SyntheticStackFrameFgColor=101,101,65'
'org.eclipse.jdt.debug.ui.SyntheticStackFrameBgColor=53,53,53'
'org.eclipse.jdt.debug.ui.LibraryStackFrameFgColor=182,164,206'
'org.eclipse.jdt.debug.ui.LibraryStackFrameBgColor=53,53,53'
'org.eclipse.jdt.debug.ui.PlatformStackFrameFgColor=108,132,108'
'org.eclipse.jdt.debug.ui.PlatformStackFrameBgColor=53,53,53'
}
41 changes: 41 additions & 0 deletions org.eclipse.jdt.debug.ui/plugin.properties
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ JavaSnippetEditor.label= Scrapbook
javaStepFilterPrefName=Step Filtering
javaDetailFormattersPrefName=Detail Formatters

javaStackFramePrefName=Stack Frames

javaVariableHoverLabel=Variable Values
javaVariableHoverDescription=Shows the value of the selected variable when debugging.

Expand Down Expand Up @@ -178,6 +180,15 @@ showMonitorThreadInfo.tooltip=Show the Thread & Monitor Information
showNullEntriesAction.label=Show &Null Array Entries
showNullEntriesAction.tooltip=Show Null Array Entries

colorizeStackFrames.label=Mark Stack Frames with &Colors
colorizeStackFrames.tooltip=Based on the function mark the stack frames with different colors

collapseStackFrames.label=Collapse Stack Frames
collapseStackFrames.tooltip=Hide less relevant stack frames

highlightStackFrame.label=Highlight Stack Frame
highlightStackFrame.tooltip=Always mark this stack frame distinctly

stepIntoSelectionHyperlinkDetector.label=Step Into Selection
stepIntoSelectionHyperlinkDetector.description=Performs the step into selection command on demand via a hyperlink

Expand Down Expand Up @@ -289,6 +300,36 @@ InDeadlockColorDefinition.description=The color used to render deadlocked thread
LabeledObjectColorDefinition.label=Labeled objects
LabeledObjectColorDefinition.description=The color used to render labeled objects in debug views.

CustomFilteredStackFrameFgColorDefinition.label=Highlighted methods
CustomFilteredStackFrameBgColorDefinition.label=Highlighted methods background
CustomFilteredStackFrameFgColorDefinition.description=The color used to render the Highlighted stack frames in the Debug view.
CustomFilteredStackFrameBgColorDefinition.description=The background color used to render the Highlighted stack frames in the Debug view.

SyntheticStackFrameFgColorDefinition.label=Synthetic methods
SyntheticStackFrameBgColorDefinition.label=Synthetic methods background
SyntheticStackFrameFgColorDefinition.description=The color used to render stack frames for synthetic methods in the Debug view.
SyntheticStackFrameBgColorDefinition.description=The background color used to render stack frames for synthetic methods in the Debug view.

PlatformStackFrameFgColorDefinition.label=Platform methods
PlatformStackFrameBgColorDefinition.label=Platform methods background
PlatformStackFrameFgColorDefinition.description=The color used to render stack frames for Platform methods in the Debug view.
PlatformStackFrameBgColorDefinition.description=The background color used to render stack frame for Platform methods in the Debug view.

TestStackFrameFgColorDefinition.label=Your Test code
TestStackFrameBgColorDefinition.label=Your Test code background
TestStackFrameFgColorDefinition.description=The color used to render stack frames for Your Test code in the Debug view.
TestStackFrameBgColorDefinition.description=The background color used to render stack frames for Your Test code in the Debug view.

LibraryStackFrameFgColorDefinition.label=Library code
LibraryStackFrameBgColorDefinition.label=Library code background
LibraryStackFrameFgColorDefinition.description=The color used to render stack frames for Library code in the Debug view.
LibraryStackFrameBgColorDefinition.description=The background color used to render stack frames for Library code in the Debug view.

ProductionStackFrameFgColorDefinition.label=Your Source code
ProductionStackFrameBgColorDefinition.label=Your Source code background
ProductionStackFrameFgColorDefinition.description=The color used used to render stack frames for Your Source code in the Debug view.
ProductionStackFrameBgColorDefinition.description=The background color used to render stack frames for Your Source code in the Debug view.

javaStackTraceConsole.label= Java Stack Trace Console
FormatStackTraceActionDelegate.name= Format
FormatStackTraceActionDelegate.tooltip= Format
Expand Down
Loading
Loading