summaryrefslogtreecommitdiff
path: root/src/cuchaz/enigma/mapping/MappingsWriter.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/cuchaz/enigma/mapping/MappingsWriter.java')
-rw-r--r--src/cuchaz/enigma/mapping/MappingsWriter.java40
1 files changed, 28 insertions, 12 deletions
diff --git a/src/cuchaz/enigma/mapping/MappingsWriter.java b/src/cuchaz/enigma/mapping/MappingsWriter.java
index a97052f..6203571 100644
--- a/src/cuchaz/enigma/mapping/MappingsWriter.java
+++ b/src/cuchaz/enigma/mapping/MappingsWriter.java
@@ -30,50 +30,56 @@ public class MappingsWriter
30 { 30 {
31 for( ClassMapping classMapping : sorted( mappings.classes() ) ) 31 for( ClassMapping classMapping : sorted( mappings.classes() ) )
32 { 32 {
33 write( out, classMapping ); 33 write( out, classMapping, 0 );
34 } 34 }
35 } 35 }
36 36
37 public void write( PrintWriter out, ClassMapping classMapping ) 37 private void write( PrintWriter out, ClassMapping classMapping, int depth )
38 throws IOException 38 throws IOException
39 { 39 {
40 out.format( "CLASS %s %s\n", classMapping.getObfName(), classMapping.getDeobfName() ); 40 out.format( "%sCLASS %s %s\n", getIndent( depth ), classMapping.getObfName(), classMapping.getDeobfName() );
41
42 for( ClassMapping innerClassMapping : sorted( classMapping.innerClasses() ) )
43 {
44 write( out, innerClassMapping, depth + 1 );
45 }
41 46
42 for( FieldMapping fieldMapping : sorted( classMapping.fields() ) ) 47 for( FieldMapping fieldMapping : sorted( classMapping.fields() ) )
43 { 48 {
44 write( out, fieldMapping ); 49 write( out, fieldMapping, depth + 1 );
45 } 50 }
46 51
47 for( MethodMapping methodMapping : sorted( classMapping.methods() ) ) 52 for( MethodMapping methodMapping : sorted( classMapping.methods() ) )
48 { 53 {
49 write( out, methodMapping ); 54 write( out, methodMapping, depth + 1 );
50 } 55 }
51 } 56 }
52 57
53 public void write( PrintWriter out, FieldMapping fieldMapping ) 58 private void write( PrintWriter out, FieldMapping fieldMapping, int depth )
54 throws IOException 59 throws IOException
55 { 60 {
56 out.format( "\tFIELD %s %s\n", fieldMapping.getObfName(), fieldMapping.getDeobfName() ); 61 out.format( "%sFIELD %s %s\n", getIndent( depth ), fieldMapping.getObfName(), fieldMapping.getDeobfName() );
57 } 62 }
58 63
59 public void write( PrintWriter out, MethodMapping methodMapping ) 64 private void write( PrintWriter out, MethodMapping methodMapping, int depth )
60 throws IOException 65 throws IOException
61 { 66 {
62 out.format( "\tMETHOD %s %s %s %s\n", 67 out.format( "%sMETHOD %s %s %s %s\n",
68 getIndent( depth ),
63 methodMapping.getObfName(), methodMapping.getDeobfName(), 69 methodMapping.getObfName(), methodMapping.getDeobfName(),
64 methodMapping.getObfSignature(), methodMapping.getDeobfSignature() 70 methodMapping.getObfSignature(), methodMapping.getDeobfSignature()
65 ); 71 );
66 72
67 for( ArgumentMapping argumentMapping : sorted( methodMapping.arguments() ) ) 73 for( ArgumentMapping argumentMapping : sorted( methodMapping.arguments() ) )
68 { 74 {
69 write( out, argumentMapping ); 75 write( out, argumentMapping, depth + 1 );
70 } 76 }
71 } 77 }
72 78
73 public void write( PrintWriter out, ArgumentMapping argumentMapping ) 79 private void write( PrintWriter out, ArgumentMapping argumentMapping, int depth )
74 throws IOException 80 throws IOException
75 { 81 {
76 out.format( "\t\tARG %d %s\n", argumentMapping.getIndex(), argumentMapping.getName() ); 82 out.format( "%sARG %d %s\n", getIndent( depth ), argumentMapping.getIndex(), argumentMapping.getName() );
77 } 83 }
78 84
79 private <T extends Comparable<T>> List<T> sorted( Iterable<T> classes ) 85 private <T extends Comparable<T>> List<T> sorted( Iterable<T> classes )
@@ -86,4 +92,14 @@ public class MappingsWriter
86 Collections.sort( out ); 92 Collections.sort( out );
87 return out; 93 return out;
88 } 94 }
95
96 private String getIndent( int depth )
97 {
98 StringBuilder buf = new StringBuilder();
99 for( int i=0; i<depth; i++ )
100 {
101 buf.append( "\t" );
102 }
103 return buf.toString();
104 }
89} 105}