Commit 1bb53329 authored by Skylot's avatar Skylot

fix: use alias as a base for class rename if file system is case sensitive (#474)

parent e026345a
......@@ -50,19 +50,23 @@ public class RenameVisitor extends AbstractVisitor {
}
private void checkClasses(RootNode root, boolean caseSensitive) {
Set<String> clsNames = new HashSet<>();
for (ClassNode cls : root.getClasses(true)) {
List<ClassNode> classes = root.getClasses(true);
for (ClassNode cls : classes) {
checkClassName(cls);
checkFields(cls);
checkMethods(cls);
if (!caseSensitive) {
ClassInfo classInfo = cls.getClassInfo();
String clsFileName = classInfo.getAlias().getFullPath();
if (!clsNames.add(clsFileName.toLowerCase())) {
}
if (!caseSensitive) {
Set<String> clsFullPaths = new HashSet<>(classes.size());
for (ClassNode cls : classes) {
ClassInfo clsInfo = cls.getClassInfo();
ClassInfo aliasClsInfo = clsInfo.getAlias();
if (!clsFullPaths.add(aliasClsInfo.getFullPath().toLowerCase())) {
String newShortName = deobfuscator.getClsAlias(cls);
String newFullName = classInfo.makeFullClsName(newShortName, true);
classInfo.rename(cls.root(), newFullName);
clsNames.add(classInfo.getAlias().getFullPath().toLowerCase());
String newFullName = aliasClsInfo.makeFullClsName(newShortName, true);
clsInfo.rename(root, newFullName);
clsFullPaths.add(clsInfo.getAlias().getFullPath().toLowerCase());
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment