From dcc7952a65193b44a876ce63cfd3f632301e4757 Mon Sep 17 00:00:00 2001 From: Jamie Mansfield Date: Sun, 11 Sep 2016 20:42:58 +0100 Subject: [PATCH] Sort mappings alphabetically --- build.gradle | 2 +- .../nocturne/mapping/io/writer/SrgWriter.java | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index ca827d2..b9ce9d5 100644 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ defaultTasks 'clean', 'licenseFormat', 'build' // Project information allprojects { group = 'blue.lapis.nocturne' - version = '1.0.4' + version = '1.0.5' sourceCompatibility = '1.8' targetCompatibility = '1.8' diff --git a/src/main/java/blue/lapis/nocturne/mapping/io/writer/SrgWriter.java b/src/main/java/blue/lapis/nocturne/mapping/io/writer/SrgWriter.java index 4892a21..b8b2309 100644 --- a/src/main/java/blue/lapis/nocturne/mapping/io/writer/SrgWriter.java +++ b/src/main/java/blue/lapis/nocturne/mapping/io/writer/SrgWriter.java @@ -64,7 +64,9 @@ public SrgWriter(PrintWriter out) { @Override public void write(MappingContext mappingContext) { - mappingContext.getMappings().values().forEach(this::writeClassMapping); + mappingContext.getMappings().values().stream().sorted( + (o1, o2) -> o1.getFullObfuscatedName().compareToIgnoreCase(o2.getFullObfuscatedName()) + ).forEach(this::writeClassMapping); clWriter.close(); fdWriter.close(); mdWriter.close(); @@ -88,9 +90,15 @@ protected void writeClassMapping(ClassMapping classMapping) { classMapping.getFullObfuscatedName(), classMapping.getFullDeobfuscatedName()); } - classMapping.getInnerClassMappings().values().stream().filter(NOT_USELESS).forEach(this::writeClassMapping); - classMapping.getFieldMappings().values().stream().filter(NOT_USELESS).forEach(this::writeFieldMapping); - classMapping.getMethodMappings().values().stream().filter(NOT_USELESS).forEach(this::writeMethodMapping); + classMapping.getInnerClassMappings().values().stream().filter(NOT_USELESS).sorted( + (o1, o2) -> o1.getFullObfuscatedName().compareToIgnoreCase(o2.getFullObfuscatedName()) + ).forEach(this::writeClassMapping); + classMapping.getFieldMappings().values().stream().filter(NOT_USELESS).sorted( + (o1, o2) -> o1.getObfuscatedName().compareToIgnoreCase(o2.getObfuscatedName()) + ).forEach(this::writeFieldMapping); + classMapping.getMethodMappings().values().stream().filter(NOT_USELESS).sorted( + (o1, o2) -> o1.getObfuscatedName().compareToIgnoreCase(o2.getObfuscatedName()) + ).forEach(this::writeMethodMapping); } @Override