From c8d7fce938a4abd81bb680702c23a49e05a5e223 Mon Sep 17 00:00:00 2001 From: Skylot Date: Sun, 22 Aug 2021 18:53:12 +0100 Subject: [PATCH] fix(gui): use correct type formatter in class tree --- .../src/main/java/jadx/gui/ui/MainWindow.java | 1 + .../src/main/java/jadx/gui/utils/UiUtils.java | 36 +++++++++++++++---- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/jadx-gui/src/main/java/jadx/gui/ui/MainWindow.java b/jadx-gui/src/main/java/jadx/gui/ui/MainWindow.java index 785e4e3db..cc3c4a03d 100644 --- a/jadx-gui/src/main/java/jadx/gui/ui/MainWindow.java +++ b/jadx-gui/src/main/java/jadx/gui/ui/MainWindow.java @@ -1108,6 +1108,7 @@ public class MainWindow extends JFrame { Component c = super.getTreeCellRendererComponent(tree, value, selected, expanded, isLeaf, row, focused); if (value instanceof JNode) { JNode jNode = (JNode) value; + setText(jNode.makeStringHtml()); setIcon(jNode.getIcon()); setToolTipText(jNode.getTooltip()); } else { diff --git a/jadx-gui/src/main/java/jadx/gui/utils/UiUtils.java b/jadx-gui/src/main/java/jadx/gui/utils/UiUtils.java index df05cc489..35a89eba8 100644 --- a/jadx-gui/src/main/java/jadx/gui/utils/UiUtils.java +++ b/jadx-gui/src/main/java/jadx/gui/utils/UiUtils.java @@ -32,6 +32,7 @@ import com.formdev.flatlaf.extras.FlatSVGIcon; import jadx.core.dex.info.AccessInfo; import jadx.core.dex.instructions.args.ArgType; +import jadx.core.utils.Utils; import jadx.core.utils.exceptions.JadxRuntimeException; import jadx.gui.ui.codearea.AbstractCodeArea; @@ -117,13 +118,28 @@ public class UiUtils { return "null"; } if (type.isObject()) { - String cls = type.toString(); - int dot = cls.lastIndexOf('.'); - if (dot != -1) { - return cls.substring(dot + 1); - } else { - return cls; + if (type.isGenericType()) { + return type.getObject(); } + ArgType wt = type.getWildcardType(); + if (wt != null) { + ArgType.WildcardBound bound = type.getWildcardBound(); + if (bound == ArgType.WildcardBound.UNBOUND) { + return bound.getStr(); + } + return bound.getStr() + typeStr(wt); + } + String objName = objectShortName(type.getObject()); + ArgType outerType = type.getOuterType(); + if (outerType != null) { + return typeStr(outerType) + '.' + objName; + } + List genericTypes = type.getGenericTypes(); + if (genericTypes != null) { + String generics = Utils.listToString(genericTypes, ", ", UiUtils::typeStr); + return objName + '<' + generics + '>'; + } + return objName; } if (type.isArray()) { return typeStr(type.getArrayElement()) + "[]"; @@ -131,6 +147,14 @@ public class UiUtils { return type.toString(); } + private static String objectShortName(String obj) { + int dot = obj.lastIndexOf('.'); + if (dot != -1) { + return obj.substring(dot + 1); + } + return obj; + } + public static OverlayIcon makeIcon(AccessInfo af, Icon pub, Icon pri, Icon pro, Icon def) { Icon icon; if (af.isPublic()) {