com.strobel.decompiler.languages.java.JavaFormattingOptions Java Examples
The following examples show how to use
com.strobel.decompiler.languages.java.JavaFormattingOptions.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProcyonDecompiler.java From Recaf with MIT License | 5 votes |
@Override public String decompile(String name) { ITypeLoader loader = new ComposedTypeLoader(Arrays.asList( new RecafTypeLoader(getController()), new InputTypeLoader() )); Map<String, Boolean> options = getOptions(); DecompilerSettings settings = new DecompilerSettings(); settings.setFlattenSwitchBlocks(options.get("flatten-switch-blocks")); settings.setForceExplicitImports(!options.get("collapse-imports")); settings.setForceExplicitTypeArguments(options.get("force-explicit-type-arguments")); settings.setRetainRedundantCasts(options.get("retain-redundant-casts")); settings.setShowSyntheticMembers(options.get("show-synthetic-members")); settings.setExcludeNestedTypes(options.get("exclude-nested-types")); settings.setRetainPointlessSwitches(options.get("retain-pointless-switches")); settings.setUnicodeOutputEnabled(options.get("unicode-output")); settings.setMergeVariables(options.get("merge-variables")); settings.setShowDebugLineNumbers(options.get("show-debug-line-numbers")); settings.setSimplifyMemberReferences(options.get("simplify-member-references")); settings.setForceFullyQualifiedReferences(options.get("force-fully-qualified-references")); settings.setDisableForEachTransforms(options.get("disable-for-each-transforms")); settings.setTypeLoader(loader); settings.setJavaFormattingOptions(JavaFormattingOptions.createDefault()); MetadataSystem system = new MetadataSystem(loader); system.setEagerMethodLoadingEnabled(options.get("eager-methods-loading")); TypeReference ref = system.lookupType(name); DecompilationOptions decompilationOptions = new DecompilationOptions(); decompilationOptions.setSettings(settings); decompilationOptions.setFullDecompilation(true); StringWriter writer = new StringWriter(); settings.getLanguage().decompileType(ref.resolve(), new PlainTextOutput(writer), decompilationOptions); return writer.toString(); }
Example #2
Source File: ProcyonDecompiler.java From bytecode-viewer with GNU General Public License v3.0 | 5 votes |
public DecompilerSettings getDecompilerSettings() { DecompilerSettings settings = new DecompilerSettings(); settings.setAlwaysGenerateExceptionVariableForCatchBlocks(BytecodeViewer.viewer.chckbxmntmNewCheckItem_6 .isSelected()); settings.setExcludeNestedTypes(BytecodeViewer.viewer.chckbxmntmNewCheckItem_11 .isSelected()); settings.setShowDebugLineNumbers(BytecodeViewer.viewer.chckbxmntmShowDebugLine .isSelected()); settings.setIncludeLineNumbersInBytecode(BytecodeViewer.viewer.chckbxmntmNewCheckItem_3 .isSelected()); settings.setIncludeErrorDiagnostics(BytecodeViewer.viewer.chckbxmntmNewCheckItem_4 .isSelected()); settings.setShowSyntheticMembers(BytecodeViewer.viewer.chckbxmntmNewCheckItem_7 .isSelected()); settings.setSimplifyMemberReferences(BytecodeViewer.viewer.chckbxmntmSimplifyMemberReferences .isSelected()); settings.setMergeVariables(BytecodeViewer.viewer.mnMergeVariables .isSelected()); settings.setForceExplicitTypeArguments(BytecodeViewer.viewer.chckbxmntmNewCheckItem_8 .isSelected()); settings.setForceExplicitImports(BytecodeViewer.viewer.chckbxmntmNewCheckItem_9 .isSelected()); settings.setFlattenSwitchBlocks(BytecodeViewer.viewer.chckbxmntmNewCheckItem_10 .isSelected()); settings.setRetainPointlessSwitches(BytecodeViewer.viewer.chckbxmntmNewCheckItem_2 .isSelected()); settings.setRetainRedundantCasts(BytecodeViewer.viewer.chckbxmntmNewCheckItem_5 .isSelected()); settings.setUnicodeOutputEnabled(BytecodeViewer.viewer.chckbxmntmNewCheckItem_1 .isSelected()); settings.setJavaFormattingOptions(JavaFormattingOptions.createDefault()); return settings; }
Example #3
Source File: ConfigSaver.java From Luyten with Apache License 2.0 | 5 votes |
/** * Do not load, get the loaded instance */ private void loadConfig() { decompilerSettings = new DecompilerSettings(); if (decompilerSettings.getJavaFormattingOptions() == null) { decompilerSettings.setJavaFormattingOptions(JavaFormattingOptions.createDefault()); } luytenPreferences = new LuytenPreferences(); mainWindowPosition = new WindowPosition(); findWindowPosition = new WindowPosition(); try { Preferences prefs = Preferences.userNodeForPackage(ConfigSaver.class); if (!prefs.get(LANGUAGE_NAME_ID, decompilerSettings.getLanguage().getName()) .equals(decompilerSettings.getLanguage().getName())) prefs.put(LANGUAGE_NAME_ID, decompilerSettings.getLanguage().getName()); decompilerSettings.setFlattenSwitchBlocks( prefs.getBoolean(FLATTEN_SWITCH_BLOCKS_ID, decompilerSettings.getFlattenSwitchBlocks())); decompilerSettings.setForceExplicitImports( prefs.getBoolean(FORCE_EXPLICIT_IMPORTS_ID, decompilerSettings.getForceExplicitImports())); decompilerSettings.setShowSyntheticMembers( prefs.getBoolean(SHOW_SYNTHETIC_MEMBERS_ID, decompilerSettings.getShowSyntheticMembers())); decompilerSettings.setExcludeNestedTypes( prefs.getBoolean(EXCLUDE_NESTED_TYPES_ID, decompilerSettings.getExcludeNestedTypes())); decompilerSettings.setForceExplicitTypeArguments(prefs.getBoolean(FORCE_EXPLICIT_TYPE_ARGUMENTS_ID, decompilerSettings.getForceExplicitTypeArguments())); decompilerSettings.setRetainRedundantCasts( prefs.getBoolean(RETAIN_REDUNDANT_CASTS_ID, decompilerSettings.getRetainRedundantCasts())); decompilerSettings.setIncludeErrorDiagnostics( prefs.getBoolean(INCLUDE_ERROR_DIAGNOSTICS_ID, decompilerSettings.getIncludeErrorDiagnostics())); decompilerSettings.setLanguage( findLanguageByName(prefs.get(LANGUAGE_NAME_ID, decompilerSettings.getLanguage().getName()))); decompilerSettings.setUnicodeOutputEnabled(prefs.getBoolean(UNICODE_REPLACE_ENABLED_ID, false)); mainWindowPosition = loadWindowPosition(prefs, MAIN_WINDOW_ID_PREFIX); findWindowPosition = loadWindowPosition(prefs, FIND_WINDOW_ID_PREFIX); luytenPreferences = loadLuytenPreferences(prefs); } catch (Exception e) { Luyten.showExceptionDialog("Exception!", e); } }
Example #4
Source File: FileSaver.java From Luyten with Apache License 2.0 | 5 votes |
private DecompilerSettings cloneSettings() { DecompilerSettings settings = ConfigSaver.getLoadedInstance().getDecompilerSettings(); DecompilerSettings newSettings = new DecompilerSettings(); if (newSettings.getJavaFormattingOptions() == null) { newSettings.setJavaFormattingOptions(JavaFormattingOptions.createDefault()); } // synchronized: against main menu changes synchronized (settings) { newSettings.setExcludeNestedTypes(settings.getExcludeNestedTypes()); newSettings.setFlattenSwitchBlocks(settings.getFlattenSwitchBlocks()); newSettings.setForceExplicitImports(settings.getForceExplicitImports()); newSettings.setForceExplicitTypeArguments(settings.getForceExplicitTypeArguments()); newSettings.setOutputFileHeaderText(settings.getOutputFileHeaderText()); newSettings.setLanguage(settings.getLanguage()); newSettings.setShowSyntheticMembers(settings.getShowSyntheticMembers()); newSettings.setAlwaysGenerateExceptionVariableForCatchBlocks( settings.getAlwaysGenerateExceptionVariableForCatchBlocks()); newSettings.setOutputDirectory(settings.getOutputDirectory()); newSettings.setRetainRedundantCasts(settings.getRetainRedundantCasts()); newSettings.setIncludeErrorDiagnostics(settings.getIncludeErrorDiagnostics()); newSettings.setIncludeLineNumbersInBytecode(settings.getIncludeLineNumbersInBytecode()); newSettings.setRetainPointlessSwitches(settings.getRetainPointlessSwitches()); newSettings.setUnicodeOutputEnabled(settings.isUnicodeOutputEnabled()); newSettings.setMergeVariables(settings.getMergeVariables()); newSettings.setShowDebugLineNumbers(settings.getShowDebugLineNumbers()); } return newSettings; }