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

Implement grouping of the stack frames #583

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gzsombor
Copy link
Contributor

@gzsombor gzsombor commented Jan 4, 2025

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

What it does

Groups - and hides - the supposedly not relevant stack frames from the debug views.
before
After
new_group1
Expanding the group:
new_group2

How to test

Start debugging, and notice that instead of having hundreds of frames only a couple are visible

Author checklist

@gzsombor
Copy link
Contributor Author

@jukzi : Could you please have a look on this when you have time and check what needs to be done to be merged?

@jukzi
Copy link
Contributor

jukzi commented Jan 14, 2025

unfortunately i am very limited in time. @SougandhS can you test/review this PR?

@SougandhS
Copy link
Contributor

unfortunately i am very limited in time. @SougandhS can you test/review this PR?

will check this

@@ -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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some additional space was added here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, sorry. Files with mixed tabs and spaces are very confusing and it is easy to mess up them even more!

store.setDefault(IJDIPreferencesConstants.PREF_ACTIVE_CUSTOM_FRAME_FILTER_LIST, ""); //$NON-NLS-1$
store.setDefault(IJDIPreferencesConstants.PREF_INACTIVE_CUSTOM_FRAME_FILTER_LIST, ""); //$NON-NLS-1$
store.setDefault(IJDIPreferencesConstants.PREF_COLLAPSE_STACK_FRAMES, true);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try using org.eclipse.jface.util.Util.ZERO_LENGTH_STRING for empty string declarations, so you can avoid NON-NLS comments

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I didn't know about this class!

@SougandhS
Copy link
Contributor

SougandhS commented Jan 14, 2025

Stack icons looks bit odd when code stops in .java files

image




Icons are same as of .Class files

image

reference . On master -
image

@SougandhS
Copy link
Contributor

SougandhS commented Jan 14, 2025

if the breakpoint is in .class file then original stack (master) icons are shown

image

both
image

Feature looks awsm!

Would be nice if the icons are consistent

@gzsombor
Copy link
Contributor Author

if the breakpoint is in .class file then original stack (master) icons are shown
image

both image

Feature looks awsm! Would be nice if the icons are consistent

I'm happy that you liked the feature!
It is a long time, since I've written most of the code - I even forgot, that I've modified that part which returns images for the stack frames. I've modified again a bit, so the icon will be the same old, for all the prod/test codes, and have the 'jar' icon for classes coming from the libraries and 'platform'.

@SougandhS
Copy link
Contributor

have the 'jar' icon for classes coming from the libraries and 'platform'.

image

Icons looks good now thanks!

org.eclipse.jdt.debug.ui/plugin.xml Outdated Show resolved Hide resolved
@SougandhS
Copy link
Contributor

SougandhS commented Jan 15, 2025

Hi @gzsombor , could pls take the latest pull and squash everything to one commit only and push, so we can get rid of the build errors

Copy link
Contributor

@SougandhS SougandhS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@jukzi
Copy link
Contributor

jukzi commented Jan 15, 2025

@gzsombor can you please update the pr description to include before/after screenshot to fatsly see what to expect?

@jukzi jukzi added the enhancement New feature or request label Jan 15, 2025
} catch (DebugException e) {
JDIDebugUIPlugin.log(e);
}
frame.setCategory(result);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does a getter getCategory set something? that is unexpected

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I add more description to the javadoc, but essentially, we don't want to always re-evaluate the rules, so we store the calculated category in that frame.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so if setCategory is only used as cache please move the caching implementation into the getter to avoid the setter. However it feels like the implementation is wrong in means of it will not update the cached value if the options change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The setter was there, because all the settings were managed by JDIDebugUIPlugin, not by JDIDebugPlugin, partially because managing class/package filter lists are a bit easier with org.eclipse.jface.preference.IPreferenceStore and org.eclipse.jdt.internal.ui.filtertable.FilterManager - those are UI classes, not reachable from the backend.
But I could rewrote it, the base functionality seems to be working - I still have to refactor the settings page and the couple of tests, but that will come in the other PR.

* @param category
* the new category of the stack frame.
*/
public void setCategory(Category category);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can it somehow avoided to have such setter? it is not obvious to me if such setter should fireChangeEvent(DebugEvent.STATE);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somehow we need to store the information how that frame was categorized - even if the process is not slow, it needs to lookup the source, and check which classpath entry contains that, etc.
In theory, we could have a map from IJavaStackFrame -> Category in some singleton, but it's unclear how we can detect, if that stack frame was not accessible anymore, so maybe a WeakHashMap could work, but it felt too complicated and error prone.
This setter is only called once - when we first want to display the frame, so firing a change event should not needed - at least it seems to work fine without it.

@gzsombor gzsombor force-pushed the single-change branch 3 times, most recently from 9eb4199 to 84bc37e Compare January 17, 2025 07:48
* @since 3.22
*
*/
enum Category {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels wrong to publish this enum as API as it may be subject to change. Especially "platform" may be usefull but has no clear definition. Also those categories may not be disjunct. code could be synthetic platform test and library at once. One could either use plain Strings as Category or have a CategoryRegistry where new Categories could be added at runtime.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the categories are not exact and there could be frames that could belong to multiple categories.
However, I don't think that adding new categories is a feasible - and useful feature ever. Main problem is that a single category needs to be handled in multiple places and going for a very general solution would be hard. For example, to have a foreground and background colors we have to declare them in the plugin.xml, otherwise it can't be set in the color editing preference page.
Maybe, we could have Category as a 'record' and have them declared as a fixed constant in the JDIDebugPlugin.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as the solution does not make the categories public API, it may be ok.

@gzsombor gzsombor force-pushed the single-change branch 2 times, most recently from 5154e9e to b62f599 Compare January 20, 2025 17:39
@SougandhS
Copy link
Contributor

Hi @gzsombor, pls squash all commits into one

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
@gzsombor
Copy link
Contributor Author

Hi @gzsombor, pls squash all commits into one

Done and also the build is green now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants