From 6e464ea251cab63c776ece0b2a356f1498ffa294 Mon Sep 17 00:00:00 2001 From: Thog Date: Wed, 8 Mar 2017 08:17:04 +0100 Subject: Follow Fabric guidelines --- .../cuchaz/enigma/mapping/MappingsSRGWriter.java | 112 ++++++++++----------- 1 file changed, 55 insertions(+), 57 deletions(-) (limited to 'src/main/java/cuchaz/enigma/mapping/MappingsSRGWriter.java') diff --git a/src/main/java/cuchaz/enigma/mapping/MappingsSRGWriter.java b/src/main/java/cuchaz/enigma/mapping/MappingsSRGWriter.java index a3f0cc8..b0eb826 100644 --- a/src/main/java/cuchaz/enigma/mapping/MappingsSRGWriter.java +++ b/src/main/java/cuchaz/enigma/mapping/MappingsSRGWriter.java @@ -13,69 +13,67 @@ import java.util.List; */ public class MappingsSRGWriter { - public void write(File file, Mappings mappings) throws IOException { - if(file.exists()){ - file.delete(); - } - file.createNewFile(); + public void write(File file, Mappings mappings) throws IOException { + if (file.exists()) { + file.delete(); + } + file.createNewFile(); - TranslationIndex index = new TranslationIndex(); + TranslationIndex index = new TranslationIndex(); - PrintWriter writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), Charsets.UTF_8)); - List fieldMappings = new ArrayList<>(); - List methodMappings = new ArrayList<>(); - for (ClassMapping classMapping : sorted(mappings.classes())) { - if(classMapping.getDeobfName() == null || classMapping.getObfSimpleName() == null || classMapping.getDeobfName() == null){ - continue; - } - writer.write("CL: " + classMapping.getObfSimpleName() + " " + classMapping.getDeobfName()); - writer.write(System.lineSeparator()); - for (ClassMapping innerClassMapping : sorted(classMapping.innerClasses())) { - if(innerClassMapping.getDeobfName() == null || innerClassMapping.getObfSimpleName() == null || innerClassMapping.getDeobfName() == null){ - continue; - } - String innerClassName = classMapping.getObfSimpleName() + "$" + innerClassMapping.getObfSimpleName(); - String innerDeobfClassName = classMapping.getDeobfName() + "$" + innerClassMapping.getDeobfName(); - writer.write("CL: " + innerClassName + " " + classMapping.getDeobfName() + "$" + innerClassMapping.getDeobfName()); - writer.write(System.lineSeparator()); - for (FieldMapping fieldMapping : sorted(innerClassMapping.fields())) { - fieldMappings.add("FD: " + innerClassName + "/" + fieldMapping.getObfName() + " " + innerDeobfClassName + "/" + fieldMapping.getDeobfName()); - } + PrintWriter writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), Charsets.UTF_8)); + List fieldMappings = new ArrayList<>(); + List methodMappings = new ArrayList<>(); + for (ClassMapping classMapping : sorted(mappings.classes())) { + if (classMapping.getDeobfName() == null || classMapping.getObfSimpleName() == null || classMapping.getDeobfName() == null) { + continue; + } + writer.write("CL: " + classMapping.getObfSimpleName() + " " + classMapping.getDeobfName()); + writer.write(System.lineSeparator()); + for (ClassMapping innerClassMapping : sorted(classMapping.innerClasses())) { + if (innerClassMapping.getDeobfName() == null || innerClassMapping.getObfSimpleName() == null || innerClassMapping.getDeobfName() == null) { + continue; + } + String innerClassName = classMapping.getObfSimpleName() + "$" + innerClassMapping.getObfSimpleName(); + String innerDeobfClassName = classMapping.getDeobfName() + "$" + innerClassMapping.getDeobfName(); + writer.write("CL: " + innerClassName + " " + classMapping.getDeobfName() + "$" + innerClassMapping.getDeobfName()); + writer.write(System.lineSeparator()); + for (FieldMapping fieldMapping : sorted(innerClassMapping.fields())) { + fieldMappings.add("FD: " + innerClassName + "/" + fieldMapping.getObfName() + " " + innerDeobfClassName + "/" + fieldMapping.getDeobfName()); + } - for (MethodMapping methodMapping : sorted(innerClassMapping.methods())) { - methodMappings.add("MD: " + innerClassName + "/" + methodMapping.getObfName() + " " + methodMapping.getObfSignature().toString() + " " + innerDeobfClassName + "/" + methodMapping.getDeobfName() + " " + mappings.getTranslator(TranslationDirection.Deobfuscating, index).translateSignature(methodMapping.getObfSignature())); - } - } + for (MethodMapping methodMapping : sorted(innerClassMapping.methods())) { + methodMappings.add("MD: " + innerClassName + "/" + methodMapping.getObfName() + " " + methodMapping.getObfSignature() + " " + innerDeobfClassName + "/" + methodMapping.getDeobfName() + " " + mappings.getTranslator(TranslationDirection.Deobfuscating, index).translateSignature(methodMapping.getObfSignature())); + } + } - for (FieldMapping fieldMapping : sorted(classMapping.fields())) { - fieldMappings.add("FD: " + classMapping.getObfFullName() + "/" + fieldMapping.getObfName() + " " + classMapping.getDeobfName() + "/" + fieldMapping.getDeobfName()); - } + for (FieldMapping fieldMapping : sorted(classMapping.fields())) { + fieldMappings.add("FD: " + classMapping.getObfFullName() + "/" + fieldMapping.getObfName() + " " + classMapping.getDeobfName() + "/" + fieldMapping.getDeobfName()); + } - for (MethodMapping methodMapping : sorted(classMapping.methods())) { - methodMappings.add("MD: " + classMapping.getObfFullName() + "/" + methodMapping.getObfName() + " " + methodMapping.getObfSignature().toString() + " " + classMapping.getDeobfName() + "/" + methodMapping.getDeobfName() + " " + mappings.getTranslator(TranslationDirection.Deobfuscating, index).translateSignature(methodMapping.getObfSignature())); - } - } - for(String fd : fieldMappings){ - writer.write(fd); - writer.write(System.lineSeparator()); - } + for (MethodMapping methodMapping : sorted(classMapping.methods())) { + methodMappings.add("MD: " + classMapping.getObfFullName() + "/" + methodMapping.getObfName() + " " + methodMapping.getObfSignature() + " " + classMapping.getDeobfName() + "/" + methodMapping.getDeobfName() + " " + mappings.getTranslator(TranslationDirection.Deobfuscating, index).translateSignature(methodMapping.getObfSignature())); + } + } + for (String fd : fieldMappings) { + writer.write(fd); + writer.write(System.lineSeparator()); + } - for(String md : methodMappings){ - writer.write(md); - writer.write(System.lineSeparator()); - } + for (String md : methodMappings) { + writer.write(md); + writer.write(System.lineSeparator()); + } + writer.close(); + } - writer.close(); - } - - - private > List sorted(Iterable classes) { - List out = new ArrayList<>(); - for (T t : classes) { - out.add(t); - } - Collections.sort(out); - return out; - } + private > List sorted(Iterable classes) { + List out = new ArrayList<>(); + for (T t : classes) { + out.add(t); + } + Collections.sort(out); + return out; + } } -- cgit v1.2.3