fix(gui): use alias for types in tooltips (#1487)
This commit is contained in:
@@ -12,9 +12,9 @@ import org.jetbrains.annotations.TestOnly;
|
||||
|
||||
import jadx.core.Consts;
|
||||
import jadx.core.dex.info.ClassInfo;
|
||||
import jadx.core.dex.nodes.ClassNode;
|
||||
import jadx.core.dex.nodes.RootNode;
|
||||
import jadx.core.dex.visitors.typeinference.TypeCompareEnum;
|
||||
import jadx.core.utils.ListUtils;
|
||||
import jadx.core.utils.Utils;
|
||||
import jadx.core.utils.exceptions.JadxRuntimeException;
|
||||
|
||||
@@ -874,28 +874,37 @@ public abstract class ArgType {
|
||||
}
|
||||
|
||||
public static ArgType tryToResolveClassAlias(RootNode root, ArgType type) {
|
||||
if (!type.isObject() || type.isGenericType()) {
|
||||
if (type.isGenericType()) {
|
||||
return type;
|
||||
}
|
||||
if (type.isArray()) {
|
||||
ArgType rootType = type.getArrayRootElement();
|
||||
ArgType aliasType = tryToResolveClassAlias(root, rootType);
|
||||
if (aliasType == rootType) {
|
||||
return type;
|
||||
}
|
||||
return ArgType.array(aliasType, type.getArrayDimension());
|
||||
}
|
||||
if (type.isObject()) {
|
||||
ArgType wildcardType = type.getWildcardType();
|
||||
if (wildcardType != null) {
|
||||
return new WildcardType(tryToResolveClassAlias(root, wildcardType), type.getWildcardBound());
|
||||
}
|
||||
ClassInfo clsInfo = ClassInfo.fromName(root, type.getObject());
|
||||
ArgType baseType = clsInfo.hasAlias() ? ArgType.object(clsInfo.getAliasFullName()) : type;
|
||||
if (!type.isGeneric()) {
|
||||
return baseType;
|
||||
}
|
||||
List<ArgType> genericTypes = type.getGenericTypes();
|
||||
if (genericTypes != null) {
|
||||
return new GenericObject(baseType.getObject(), tryToResolveClassAlias(root, genericTypes));
|
||||
}
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
ClassNode cls = root.resolveClass(type);
|
||||
if (cls == null) {
|
||||
return type;
|
||||
}
|
||||
ClassInfo clsInfo = cls.getClassInfo();
|
||||
if (!clsInfo.hasAlias()) {
|
||||
return type;
|
||||
}
|
||||
String aliasFullName = clsInfo.getAliasFullName();
|
||||
if (type.isGeneric()) {
|
||||
if (type instanceof GenericObject) {
|
||||
return new GenericObject(aliasFullName, type.getGenericTypes());
|
||||
}
|
||||
if (type instanceof WildcardType) {
|
||||
return new WildcardType(ArgType.object(aliasFullName), type.getWildcardBound());
|
||||
}
|
||||
}
|
||||
return ArgType.object(aliasFullName);
|
||||
public static List<ArgType> tryToResolveClassAlias(RootNode root, List<ArgType> types) {
|
||||
return ListUtils.map(types, t -> tryToResolveClassAlias(root, t));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -90,7 +90,7 @@ public abstract class JNode extends DefaultMutableTreeNode implements Comparable
|
||||
}
|
||||
|
||||
public String getTooltip() {
|
||||
return null;
|
||||
return makeLongStringHtml();
|
||||
}
|
||||
|
||||
private static final Comparator<JNode> COMPARATOR = Comparator
|
||||
|
||||
@@ -83,6 +83,6 @@ class MouseHoverHighlighter extends MouseMotionAdapter {
|
||||
}
|
||||
JNodeCache nodeCache = codeArea.getMainWindow().getCacheObject().getNodeCache();
|
||||
JNode jNode = nodeCache.makeFrom(node);
|
||||
codeArea.setToolTipText(jNode.makeLongString());
|
||||
codeArea.setToolTipText(jNode.getTooltip());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user