-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement grouping of the stack frames
The rules how the frames are categorized are not editable as of now, just a single action is visible to switch on-off the behaviour, with enough javadocs. Category is a record, so it can be freely extended in the future.
- Loading branch information
Showing
21 changed files
with
781 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
...pse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/StackFramePresentationProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021, 2025 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 | ||
*******************************************************************************/ | ||
package org.eclipse.jdt.internal.debug.ui; | ||
|
||
import java.util.Set; | ||
|
||
import org.eclipse.jdt.debug.core.IJavaStackFrame; | ||
import org.eclipse.jdt.debug.core.JDIDebugModel; | ||
import org.eclipse.jdt.internal.ui.JavaPluginImages; | ||
import org.eclipse.jface.preference.IPreferenceStore; | ||
import org.eclipse.jface.resource.ImageDescriptor; | ||
import org.eclipse.jface.util.IPropertyChangeListener; | ||
import org.eclipse.jface.util.PropertyChangeEvent; | ||
|
||
/** | ||
* Provides foreground and background colors for stack frames in a debug view. After usage, it needs to be closed, so it could unregister itself from | ||
* preference storage. | ||
* | ||
*/ | ||
public final class StackFramePresentationProvider implements IPropertyChangeListener { | ||
|
||
private static final Set<String> JAR_ICON = Set.of(JDIDebugModel.CATEGORY_LIBRARY.name(), JDIDebugModel.CATEGORY_SYNTHETIC.name(), JDIDebugModel.CATEGORY_PLATFORM.name()); | ||
private final IPreferenceStore store; | ||
private boolean collapseStackFrames; | ||
|
||
public StackFramePresentationProvider(IPreferenceStore store) { | ||
this.store = store; | ||
store.addPropertyChangeListener(this); | ||
collapseStackFrames = store.getBoolean(IJDIPreferencesConstants.PREF_COLLAPSE_STACK_FRAMES); | ||
} | ||
|
||
public StackFramePresentationProvider() { | ||
this(JDIDebugUIPlugin.getDefault().getPreferenceStore()); | ||
} | ||
|
||
/** | ||
* @return the category specific image for the stack frame, or null, if there is no one defined. | ||
*/ | ||
public ImageDescriptor getStackFrameImage(IJavaStackFrame frame) { | ||
if (collapseStackFrames) { | ||
var category = frame.getCategory(); | ||
if (category != null) { | ||
if (JAR_ICON.contains(category.name())) { | ||
return JavaPluginImages.DESC_OBJS_JAR; | ||
} | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
/** | ||
* Unsubscribes from the {@link IPreferenceStore} to not receive notifications. | ||
*/ | ||
public void close() { | ||
store.removePropertyChangeListener(this); | ||
} | ||
|
||
@Override | ||
public void propertyChange(PropertyChangeEvent event) { | ||
String prop = event.getProperty(); | ||
if (IJDIPreferencesConstants.PREF_COLLAPSE_STACK_FRAMES.equals(prop)) { | ||
collapseStackFrames = (Boolean) event.getNewValue(); | ||
} | ||
} | ||
|
||
/** | ||
* @return if stack frames should be collapsed. | ||
*/ | ||
public boolean isCollapseStackFrames() { | ||
return collapseStackFrames; | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
....jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/CollapseStackFramesAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022, 2025 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 | ||
*******************************************************************************/ | ||
package org.eclipse.jdt.internal.debug.ui.actions; | ||
|
||
import org.eclipse.jdt.internal.debug.ui.IJDIPreferencesConstants; | ||
|
||
/** | ||
* Enable/disable collapsing of the non-relevant stack frames in debug views. | ||
* | ||
*/ | ||
public class CollapseStackFramesAction extends ToggleBooleanPreferenceAction { | ||
|
||
@Override | ||
protected String getPreferenceKey() { | ||
return IJDIPreferencesConstants.PREF_COLLAPSE_STACK_FRAMES; | ||
} | ||
|
||
@Override | ||
protected String getCompositeKey() { | ||
return getPreferenceKey(); | ||
} | ||
|
||
} |
Oops, something went wrong.