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 1 commit 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.

* @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.

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
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