diff options
Diffstat (limited to 'src/cuchaz/enigma/mapping/MappingsWriter.java')
| -rw-r--r-- | src/cuchaz/enigma/mapping/MappingsWriter.java | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/cuchaz/enigma/mapping/MappingsWriter.java b/src/cuchaz/enigma/mapping/MappingsWriter.java index 2086368..a97052f 100644 --- a/src/cuchaz/enigma/mapping/MappingsWriter.java +++ b/src/cuchaz/enigma/mapping/MappingsWriter.java | |||
| @@ -13,6 +13,9 @@ package cuchaz.enigma.mapping; | |||
| 13 | import java.io.IOException; | 13 | import java.io.IOException; |
| 14 | import java.io.PrintWriter; | 14 | import java.io.PrintWriter; |
| 15 | import java.io.Writer; | 15 | import java.io.Writer; |
| 16 | import java.util.ArrayList; | ||
| 17 | import java.util.Collections; | ||
| 18 | import java.util.List; | ||
| 16 | 19 | ||
| 17 | public class MappingsWriter | 20 | public class MappingsWriter |
| 18 | { | 21 | { |
| @@ -25,7 +28,7 @@ public class MappingsWriter | |||
| 25 | public void write( PrintWriter out, Mappings mappings ) | 28 | public void write( PrintWriter out, Mappings mappings ) |
| 26 | throws IOException | 29 | throws IOException |
| 27 | { | 30 | { |
| 28 | for( ClassMapping classMapping : mappings.classes() ) | 31 | for( ClassMapping classMapping : sorted( mappings.classes() ) ) |
| 29 | { | 32 | { |
| 30 | write( out, classMapping ); | 33 | write( out, classMapping ); |
| 31 | } | 34 | } |
| @@ -36,12 +39,12 @@ public class MappingsWriter | |||
| 36 | { | 39 | { |
| 37 | out.format( "CLASS %s %s\n", classMapping.getObfName(), classMapping.getDeobfName() ); | 40 | out.format( "CLASS %s %s\n", classMapping.getObfName(), classMapping.getDeobfName() ); |
| 38 | 41 | ||
| 39 | for( FieldMapping fieldMapping : classMapping.fields() ) | 42 | for( FieldMapping fieldMapping : sorted( classMapping.fields() ) ) |
| 40 | { | 43 | { |
| 41 | write( out, fieldMapping ); | 44 | write( out, fieldMapping ); |
| 42 | } | 45 | } |
| 43 | 46 | ||
| 44 | for( MethodMapping methodMapping : classMapping.methods() ) | 47 | for( MethodMapping methodMapping : sorted( classMapping.methods() ) ) |
| 45 | { | 48 | { |
| 46 | write( out, methodMapping ); | 49 | write( out, methodMapping ); |
| 47 | } | 50 | } |
| @@ -61,7 +64,7 @@ public class MappingsWriter | |||
| 61 | methodMapping.getObfSignature(), methodMapping.getDeobfSignature() | 64 | methodMapping.getObfSignature(), methodMapping.getDeobfSignature() |
| 62 | ); | 65 | ); |
| 63 | 66 | ||
| 64 | for( ArgumentMapping argumentMapping : methodMapping.arguments() ) | 67 | for( ArgumentMapping argumentMapping : sorted( methodMapping.arguments() ) ) |
| 65 | { | 68 | { |
| 66 | write( out, argumentMapping ); | 69 | write( out, argumentMapping ); |
| 67 | } | 70 | } |
| @@ -72,4 +75,15 @@ public class MappingsWriter | |||
| 72 | { | 75 | { |
| 73 | out.format( "\t\tARG %d %s\n", argumentMapping.getIndex(), argumentMapping.getName() ); | 76 | out.format( "\t\tARG %d %s\n", argumentMapping.getIndex(), argumentMapping.getName() ); |
| 74 | } | 77 | } |
| 78 | |||
| 79 | private <T extends Comparable<T>> List<T> sorted( Iterable<T> classes ) | ||
| 80 | { | ||
| 81 | List<T> out = new ArrayList<T>(); | ||
| 82 | for( T t : classes ) | ||
| 83 | { | ||
| 84 | out.add( t ); | ||
| 85 | } | ||
| 86 | Collections.sort( out ); | ||
| 87 | return out; | ||
| 88 | } | ||
| 75 | } | 89 | } |