@@ -41,7 +41,7 @@ public String getName() {
4141 @ Override
4242 public String decompileClassNode (String containerName , final ClassNode cn ) {
4343 try {
44- Map <String , Object > options = main ( generateMainMethod () );
44+ Map <String , Object > options = generateFernflowerArgs ( );
4545
4646 final AtomicReference <String > result = new AtomicReference <>();
4747 result .set (null );
@@ -120,7 +120,7 @@ public void decompileToZip(String zipName) {
120120 Path tempJar = Files .createTempFile ("fernflower_input" , ".jar" );
121121 File output = new File (zipName );
122122 JarUtils .saveAsJar (JDA .getLoadedBytes (), tempJar .toAbsolutePath ().toString ());
123- ConsoleDecompiler decompiler = new ConsoleDecompiler (outputDir .toFile (), main ( generateMainMethod () ));
123+ ConsoleDecompiler decompiler = new ConsoleDecompiler (outputDir .toFile (), generateFernflowerArgs ( ));
124124 decompiler .addSpace (tempJar .toFile (), true );
125125 decompiler .decompileContext ();
126126 Files .move (outputDir .toFile ().listFiles ()[0 ].toPath (), output .toPath ());
@@ -131,87 +131,72 @@ public void decompileToZip(String zipName) {
131131 }
132132 }
133133
134- public Map <String , Object > main (String [] args ) {
135- HashMap mapOptions = new HashMap ();
136- boolean isOption = true ;
137-
138- for (int destination = 0 ; destination < args .length - 1 ; ++destination ) {
139- String logger = args [destination ];
140- if (isOption && logger .length () > 5 && logger .charAt (0 ) == 45 && logger .charAt (4 ) == 61 ) {
141- String decompiler = logger .substring (5 );
142- if ("true" .equalsIgnoreCase (decompiler )) {
143- decompiler = "1" ;
144- } else if ("false" .equalsIgnoreCase (decompiler )) {
145- decompiler = "0" ;
146- }
147-
148- mapOptions .put (logger .substring (1 , 4 ), decompiler );
149- } else {
150- isOption = false ;
151- }
152- }
153-
154- return mapOptions ;
155- }
156-
157- private String [] generateMainMethod () {
158- String [] result = new String [getSettings ().size ()];
159- int index = 0 ;
134+ private Map <String , Object > generateFernflowerArgs () {
135+ Map <String , Object > options = new HashMap <>();
160136 for (Settings setting : Settings .values ()) {
161- result [index ++] = String .format ("-%s=%s" , setting .getParam (),
162- getSettings ().isSelected (setting ) ? "1" : "0" );
137+ options .put (setting .getParam (), getSettings ().getValue (setting ));
163138 }
164- return result ;
139+ return options ;
165140 }
166141
167142 public enum Settings implements DecompilerSettings .SettingsEntry {
168- HIDE_BRIDGE_METHODS ("rbr" , "Hide Bridge Methods" , true ),
169- HIDE_SYNTHETIC_CLASS_MEMBERS ("rsy" , "Hide Synthetic Class Members" ),
170- DECOMPILE_INNER_CLASSES ("din" , "Decompile Inner Classes" , true ),
171- COLLAPSE_14_CLASS_REFERENCES ("dc4" , "Collapse 1.4 Class References" , true ),
172- DECOMPILE_ASSERTIONS ("das" , "Decompile Assertions" , true ),
173- HIDE_EMPTY_SUPER_INVOCATION ("hes" , "Hide Empty Super Invocation" , true ),
174- HIDE_EMPTY_DEFAULT_CONSTRUCTOR ("hec" , "Hide Empty Default Constructor" , true ),
175- DECOMPILE_GENERIC_SIGNATURES ("dgs" , "Decompile Generic Signatures" ),
176- ASSUME_RETURN_NOT_THROWING_EXCEPTIONS ("ner" , "Assume return not throwing exceptions" , true ),
177- DECOMPILE_ENUMS ("den" , "Decompile enumerations" , true ),
178- REMOVE_GETCLASS ("rgn" , "Remove getClass()" , true ),
179- OUTPUT_NUMBERIC_LITERALS ("lit" , "Output numeric literals 'as-is'" ),
180- ENCODE_UNICODE ("asc" , "Encode non-ASCII as unicode escapes" ),
181- INT_1_AS_BOOLEAN_TRUE ("bto" , "Assume int 1 is boolean true" , true ),
182- ALLOW_NOT_SET_SYNTHETIC ("nns" , "Allow not set synthetic attribute" , true ),
183- NAMELESS_TYPES_AS_OBJECT ("uto" , "Consider nameless types as java.lang.Object" , true ),
184- RECOVER_VARIABLE_NAMES ("udv" , "Recover variable names" , true ),
185- REMOVE_EMPTY_EXCEPTIONS ("rer" , "Remove empty exceptions" , true ),
186- DEINLINE_FINALLY ("fdi" , "De-inline finally" , true ),
187- RENAME_AMBIGIOUS_MEMBERS ("ren" , "Rename ambigious members" ),
188- REMOVE_INTELLIJ_NOTNULL ("inn" , "Remove IntelliJ @NotNull" , true ),
189- DECOMPILE_LAMBDA_TO_ANONYMOUS ("lac" , "Decompile lambdas to anonymous classes" );
190-
191- private String name ;
192- private String param ;
193- private boolean on ;
194-
195- Settings (String param , String name ) {
196- this (param , name , false );
143+ HIDE_BRIDGE_METHODS ("rbr" , "Hide Bridge Methods" , "true" ),
144+ HIDE_SYNTHETIC_CLASS_MEMBERS ("rsy" , "Hide Synthetic Class Members" , "false" ),
145+ DECOMPILE_INNER_CLASSES ("din" , "Decompile Inner Classes" , "true" ),
146+ COLLAPSE_14_CLASS_REFERENCES ("dc4" , "Collapse 1.4 Class References" , "true" ),
147+ DECOMPILE_ASSERTIONS ("das" , "Decompile Assertions" , "true" ),
148+ HIDE_EMPTY_SUPER_INVOCATION ("hes" , "Hide Empty Super Invocation" , "true" ),
149+ HIDE_EMPTY_DEFAULT_CONSTRUCTOR ("hec" , "Hide Empty Default Constructor" , "true" ),
150+ DECOMPILE_GENERIC_SIGNATURES ("dgs" , "Decompile Generic Signatures" , "false" ),
151+ ASSUME_RETURN_NOT_THROWING_EXCEPTIONS ("ner" , "Assume return not throwing exceptions" , "true" ),
152+ DECOMPILE_ENUMS ("den" , "Decompile enumerations" , "true" ),
153+ REMOVE_GETCLASS ("rgn" , "Remove getClass()" , "true" ),
154+ OUTPUT_NUMBERIC_LITERALS ("lit" , "Output numeric literals 'as-is'" , "false" ),
155+ ENCODE_UNICODE ("asc" , "Encode non-ASCII as unicode escapes" , "true" ),
156+ INT_1_AS_BOOLEAN_TRUE ("bto" , "Assume int 1 is boolean true" , "true" ),
157+ ALLOW_NOT_SET_SYNTHETIC ("nns" , "Allow not set synthetic attribute" , "true" ),
158+ NAMELESS_TYPES_AS_OBJECT ("uto" , "Consider nameless types as java.lang.Object" , "true" ),
159+ RECOVER_VARIABLE_NAMES ("udv" , "Recover variable names" , "true" ),
160+ REMOVE_EMPTY_EXCEPTIONS ("rer" , "Remove empty exceptions" , "true" ),
161+ DEINLINE_FINALLY ("fdi" , "De-inline finally" , "true" ),
162+ TIME_LIMIT ("mpm" , "Maximum processing time" , "0" , SettingType .INT ), // this is a numeric setting!
163+ RENAME_AMBIGIOUS_MEMBERS ("ren" , "Rename ambigious members" , "false" ),
164+ // urc: IIDentifierRenamer
165+ REMOVE_INTELLIJ_NOTNULL ("inn" , "Remove IntelliJ @NotNull" , "true" ),
166+ DECOMPILE_LAMBDA_TO_ANONYMOUS ("lac" , "Decompile lambdas to anonymous classes" , "false" ),
167+ // NEWLINE_TYPE("nls", "Newline character"); // this is an optional argument!
168+ INDENTATION ("ind" , "Indentation string" , " " , SettingType .STRING );
169+
170+ private final String name ;
171+ private final String param ;
172+ private final String defaultValue ;
173+ private final SettingType type ;
174+
175+ Settings (String param , String name , String defaultValue ) {
176+ this (param , name , defaultValue , SettingType .BOOLEAN );
197177 }
198178
199- Settings (String param , String name , boolean on ) {
179+ Settings (String param , String name , String defaultValue , SettingType type ) {
200180 this .name = name ;
201181 this .param = param ;
202- this .on = on ;
182+ this .defaultValue = defaultValue ;
183+ this .type = type ;
203184 }
204185
205186 public String getText () {
206187 return name ;
207188 }
208189
209- public boolean isDefaultOn () {
210- return on ;
211- }
212-
213190 public String getParam () {
214191 return param ;
215192 }
193+
194+ public String getDefaultValue () {
195+ return defaultValue ;
196+ }
197+
198+ public SettingType getType () {
199+ return type ;
200+ }
216201 }
217202}
0 commit comments