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

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

上级 7b1c7b96
...@@ -12,9 +12,9 @@ import org.jetbrains.annotations.TestOnly; ...@@ -12,9 +12,9 @@ import org.jetbrains.annotations.TestOnly;
import jadx.core.Consts; import jadx.core.Consts;
import jadx.core.dex.info.ClassInfo; import jadx.core.dex.info.ClassInfo;
import jadx.core.dex.nodes.ClassNode;
import jadx.core.dex.nodes.RootNode; import jadx.core.dex.nodes.RootNode;
import jadx.core.dex.visitors.typeinference.TypeCompareEnum; import jadx.core.dex.visitors.typeinference.TypeCompareEnum;
import jadx.core.utils.ListUtils;
import jadx.core.utils.Utils; import jadx.core.utils.Utils;
import jadx.core.utils.exceptions.JadxRuntimeException; import jadx.core.utils.exceptions.JadxRuntimeException;
...@@ -874,28 +874,37 @@ public abstract class ArgType { ...@@ -874,28 +874,37 @@ public abstract class ArgType {
} }
public static ArgType tryToResolveClassAlias(RootNode root, ArgType type) { public static ArgType tryToResolveClassAlias(RootNode root, ArgType type) {
if (!type.isObject() || type.isGenericType()) { if (type.isGenericType()) {
return type; return type;
} }
if (type.isArray()) {
ClassNode cls = root.resolveClass(type); ArgType rootType = type.getArrayRootElement();
if (cls == null) { ArgType aliasType = tryToResolveClassAlias(root, rootType);
return type; if (aliasType == rootType) {
} return type;
ClassInfo clsInfo = cls.getClassInfo(); }
if (!clsInfo.hasAlias()) { return ArgType.array(aliasType, type.getArrayDimension());
return type;
} }
String aliasFullName = clsInfo.getAliasFullName(); if (type.isObject()) {
if (type.isGeneric()) { ArgType wildcardType = type.getWildcardType();
if (type instanceof GenericObject) { if (wildcardType != null) {
return new GenericObject(aliasFullName, type.getGenericTypes()); return new WildcardType(tryToResolveClassAlias(root, wildcardType), type.getWildcardBound());
} }
if (type instanceof WildcardType) { ClassInfo clsInfo = ClassInfo.fromName(root, type.getObject());
return new WildcardType(ArgType.object(aliasFullName), type.getWildcardBound()); 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 @Override
......
...@@ -90,7 +90,7 @@ public abstract class JNode extends DefaultMutableTreeNode implements Comparable ...@@ -90,7 +90,7 @@ public abstract class JNode extends DefaultMutableTreeNode implements Comparable
} }
public String getTooltip() { public String getTooltip() {
return null; return makeLongStringHtml();
} }
private static final Comparator<JNode> COMPARATOR = Comparator private static final Comparator<JNode> COMPARATOR = Comparator
......
...@@ -83,6 +83,6 @@ class MouseHoverHighlighter extends MouseMotionAdapter { ...@@ -83,6 +83,6 @@ class MouseHoverHighlighter extends MouseMotionAdapter {
} }
JNodeCache nodeCache = codeArea.getMainWindow().getCacheObject().getNodeCache(); JNodeCache nodeCache = codeArea.getMainWindow().getCacheObject().getNodeCache();
JNode jNode = nodeCache.makeFrom(node); 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.
先完成此消息的编辑!
想要评论请 注册