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 { ...@@ -50,19 +50,23 @@ public class RenameVisitor extends AbstractVisitor {
} }
private void checkClasses(RootNode root, boolean caseSensitive) { private void checkClasses(RootNode root, boolean caseSensitive) {
Set<String> clsNames = new HashSet<>(); List<ClassNode> classes = root.getClasses(true);
for (ClassNode cls : root.getClasses(true)) { for (ClassNode cls : classes) {
checkClassName(cls); checkClassName(cls);
checkFields(cls); checkFields(cls);
checkMethods(cls); checkMethods(cls);
if (!caseSensitive) { }
ClassInfo classInfo = cls.getClassInfo(); if (!caseSensitive) {
String clsFileName = classInfo.getAlias().getFullPath(); Set<String> clsFullPaths = new HashSet<>(classes.size());
if (!clsNames.add(clsFileName.toLowerCase())) { for (ClassNode cls : classes) {
ClassInfo clsInfo = cls.getClassInfo();
ClassInfo aliasClsInfo = clsInfo.getAlias();
if (!clsFullPaths.add(aliasClsInfo.getFullPath().toLowerCase())) {
String newShortName = deobfuscator.getClsAlias(cls); String newShortName = deobfuscator.getClsAlias(cls);
String newFullName = classInfo.makeFullClsName(newShortName, true); String newFullName = aliasClsInfo.makeFullClsName(newShortName, true);
classInfo.rename(cls.root(), newFullName);
clsNames.add(classInfo.getAlias().getFullPath().toLowerCase()); 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