Skip to content

Commit

Permalink
Properly implement options for the renamer stuff.
Browse files Browse the repository at this point in the history
"JVN" argument enables JAD style variable naming (int i, j, k etc).
Can pass a "RENAMER_FACTORY" to the decompiler context: this is the name of a class implementing IVariableNamingFactory, that will be loaded and instantiated, overriding
other options.
  • Loading branch information
cpw committed Nov 6, 2015
1 parent 2ab59c1 commit da7239d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/org/jetbrains/java/decompiler/main/ClassWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.jetbrains.java.decompiler.code.CodeConstants;
import org.jetbrains.java.decompiler.main.ClassesProcessor.ClassNode;
import org.jetbrains.java.decompiler.main.collectors.BytecodeMappingTracer;
import org.jetbrains.java.decompiler.main.extern.IAbstractParameterRenamer;
import org.jetbrains.java.decompiler.main.extern.IFernflowerLogger;
import org.jetbrains.java.decompiler.main.extern.IFernflowerPreferences;
import org.jetbrains.java.decompiler.main.rels.ClassWrapper;
Expand Down
8 changes: 6 additions & 2 deletions src/org/jetbrains/java/decompiler/main/DecompilerContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,15 @@ public static void initContext(Map<String, Object> propertiesCustom) {
try {
currentContext.get().renamerFactory = Class.forName((String) DecompilerContext.getProperty(RENAMER_FACTORY)).asSubclass(IVariableNamingFactory.class).newInstance();
} catch (Exception e) {

getLogger().writeMessage("Error loading renamer factory class", e);
}
}
if (DecompilerContext.getNamingFactory() == null) {
currentContext.get().renamerFactory = new JADNameProvider.JADNameProviderFactory();
if (DecompilerContext.getOption(IFernflowerPreferences.USE_JAD_VARNAMING)) {
currentContext.get().renamerFactory = new JADNameProvider.JADNameProviderFactory();
} else {
currentContext.get().renamerFactory = new IdentityRenamerFactory();
}
}
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public interface IFernflowerPreferences {

String INCLUDE_ENTIRE_CLASSPATH = "iec";

String USE_JAD_VARNAMING = "jvn";

Map<String, Object> DEFAULTS = Collections.unmodifiableMap(new HashMap<String, Object>() {{
put(REMOVE_BRIDGE, "1");
put(REMOVE_SYNTHETIC, "0");
Expand Down Expand Up @@ -96,5 +98,6 @@ public interface IFernflowerPreferences {
put(UNIT_TEST_MODE, "0");
put(DUMP_ORIGINAL_LINES, "0");
put(INCLUDE_ENTIRE_CLASSPATH, "0");
put(USE_JAD_VARNAMING, "0");
}});
}

0 comments on commit da7239d

Please sign in to comment.