Search in sources :

Example 1 with CommandLineOptions

use of com.strobel.decompiler.CommandLineOptions in project bytecode-viewer by Konloch.

the class ProcyonDecompiler method getDecompilerSettings.

public DecompilerSettings getDecompilerSettings() {
    CommandLineOptions options = new CommandLineOptions();
    JCommander jCommander = new JCommander(options);
    String[] args = new String[Settings.values().length * 2];
    int index = 0;
    for (the.bytecode.club.bytecodeviewer.DecompilerSettings.Setting setting : Settings.values()) {
        args[index++] = "--" + setting.getParam();
        args[index++] = String.valueOf(getSettings().isSelected(setting));
    }
    jCommander.parse(args);
    DecompilerSettings settings = new DecompilerSettings();
    settings.setFlattenSwitchBlocks(options.getFlattenSwitchBlocks());
    settings.setForceExplicitImports(!options.getCollapseImports());
    settings.setForceExplicitTypeArguments(options.getForceExplicitTypeArguments());
    settings.setRetainRedundantCasts(options.getRetainRedundantCasts());
    settings.setShowSyntheticMembers(options.getShowSyntheticMembers());
    settings.setExcludeNestedTypes(options.getExcludeNestedTypes());
    settings.setOutputDirectory(options.getOutputDirectory());
    settings.setIncludeLineNumbersInBytecode(options.getIncludeLineNumbers());
    settings.setRetainPointlessSwitches(options.getRetainPointlessSwitches());
    settings.setUnicodeOutputEnabled(options.isUnicodeOutputEnabled());
    settings.setMergeVariables(options.getMergeVariables());
    settings.setShowDebugLineNumbers(options.getShowDebugLineNumbers());
    settings.setSimplifyMemberReferences(options.getSimplifyMemberReferences());
    settings.setDisableForEachTransforms(options.getDisableForEachTransforms());
    settings.setTypeLoader(new InputTypeLoader());
    if (options.isRawBytecode()) {
        settings.setLanguage(Languages.bytecode());
    } else if (options.isBytecodeAst()) {
        settings.setLanguage(options.isUnoptimized() ? Languages.bytecodeAstUnoptimized() : Languages.bytecodeAst());
    }
    return settings;
}
Also used : InputTypeLoader(com.strobel.assembler.InputTypeLoader) CommandLineOptions(com.strobel.decompiler.CommandLineOptions) JCommander(com.beust.jcommander.JCommander) DecompilerSettings(com.strobel.decompiler.DecompilerSettings)

Aggregations

JCommander (com.beust.jcommander.JCommander)1 InputTypeLoader (com.strobel.assembler.InputTypeLoader)1 CommandLineOptions (com.strobel.decompiler.CommandLineOptions)1 DecompilerSettings (com.strobel.decompiler.DecompilerSettings)1