未验证 提交 21e94d8d 编写于 作者: S Skylot

fix(gui): use alias for types in tooltips (#1487)

上级 7b1c7b96
......@@ -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;
}
ClassNode cls = root.resolveClass(type);
if (cls == null) {
return type;
}
ClassInfo clsInfo = cls.getClassInfo();
if (!clsInfo.hasAlias()) {
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());
}
String aliasFullName = clsInfo.getAliasFullName();
if (type.isGeneric()) {
if (type instanceof GenericObject) {
return new GenericObject(aliasFullName, type.getGenericTypes());
if (type.isObject()) {
ArgType wildcardType = type.getWildcardType();
if (wildcardType != null) {
return new WildcardType(tryToResolveClassAlias(root, wildcardType), type.getWildcardBound());
}
if (type instanceof WildcardType) {
return new WildcardType(ArgType.object(aliasFullName), 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 ArgType.object(aliasFullName);
return type;
}
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());
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册