IDEA-384931 [debugger]: Introduce canBeHidden property to filter out items in the dump

GitOrigin-RevId: 8875abcb6902ddc43f5373ef681dac133daad527
This commit is contained in:
Maria Sokolova
2026-02-16 23:07:47 +00:00
committed by intellij-monorepo-bot
parent c8f50ff68d
commit 49ee154be1
5 changed files with 25 additions and 12 deletions
@@ -53,6 +53,11 @@ interface DumpItem {
*/
val isContainer: Boolean
/**
* May be used in the UI to hide some items from the dump.
*/
val canBeHidden: Boolean
companion object {
@JvmField
val SLEEPING_ATTRIBUTES: SimpleTextAttributes = SimpleTextAttributes.GRAY_ATTRIBUTES
@@ -163,6 +168,9 @@ private class JavaThreadDumpItem(private val threadState: ThreadState) : Mergeab
override val parentId: Long?
get() = threadState.threadContainerUniqueId
override val canBeHidden: Boolean
get() = threadState.isVirtual
override val stateDesc: String
get() {
val trimmedState = (threadState.threadStateDetail ?: threadState.state).let {
@@ -296,6 +304,9 @@ private class JavaVirtualThreadContainerItem(private val containerName: String,
override val isContainer: Boolean
get() = true
override val canBeHidden: Boolean
get() = true
override val stateDesc: @NlsSafe String
get() = "" // todo we can add threadsCount to the state
@@ -362,8 +373,13 @@ class InfoDumpItem(private val title: @Nls String, private val details: @NlsSafe
get() = emptySet()
override val isContainer: Boolean
get() = false
override val canBeHidden: Boolean
get() = false
override val id: Long
get() = this.hashCode().toLong()
override val parentId: Long?
get() = null
}
@@ -200,7 +200,7 @@ public final class ThreadDumpPanel extends JPanel implements NoStackTraceFolding
toolbarActions.add(new SortThreadsAction());
toolbarActions.add(new ExportToTextFileToolbarAction(createDumpToFileExporter(project, myThreadDump)));
toolbarActions.add(new MergeStacktracesAction());
toolbarActions.add(new ShowHierarchyAction());
toolbarActions.add(new ShowDumpItemGroups());
toolbarActions.add(new ShowOnlyPlatformThreads());
ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("ThreadDump", toolbarActions, false);
@@ -282,14 +282,8 @@ public final class ThreadDumpPanel extends JPanel implements NoStackTraceFolding
for (DumpItem threadState : filteredThreadStates) {
if (threadState.isContainer()) continue;
if (showOnlyPlatformThreads) {
// todo define if an item corresponds to a platform thread
if (!Objects.equals(threadState.getIconToolTip(), JavaFrontbackBundle.message("dump.item.java.thread.icon.tooltip.virtual"))) {
treeRoot.add(new DefaultMutableTreeNode(threadState));
}
} else {
treeRoot.add(new DefaultMutableTreeNode(threadState));
}
if (showOnlyPlatformThreads && threadState.getCanBeHidden()) continue;
treeRoot.add(new DefaultMutableTreeNode(threadState));
}
}
}
@@ -490,8 +484,8 @@ public final class ThreadDumpPanel extends JPanel implements NoStackTraceFolding
}
}
private final class ShowHierarchyAction extends ToggleAction implements DumbAware {
private ShowHierarchyAction() {
private final class ShowDumpItemGroups extends ToggleAction implements DumbAware {
private ShowDumpItemGroups() {
super(JavaFrontbackBundle.lazyMessage("action.text.group.dump.items"), JavaFrontbackBundle.lazyMessage(
"action.description.group.dump.items"), AllIcons.Hierarchy.Subtypes);
}