From ba640984e3ba590ab267864ce6cd8ce90a4e3099 Mon Sep 17 00:00:00 2001 From: "Jan S." Date: Mon, 18 Mar 2024 18:20:09 +0100 Subject: [PATCH] Fixed: missing Fernflower in update site; Ignore out outdated decompiler plugins (remains of older ECD versions) --- .gitignore | 1 + .../cfr/decompiler/CfrDecompiler.java | 6 +- .../decompiler/FernFlowerDecompiler.java | 3 +- .../ide/eclipse/editors/JDSourceMapper.java | 9 +- .../procyon/decompiler/ProcyonDecompiler.java | 3 +- .../decompiler/VineflowerDecompiler.java | 3 +- .../decompiler/JavaDecompilerConstants.java | 50 ++++++ .../decompiler/JavaDecompilerPlugin.java | 152 ++++++++---------- .../sf/feeling/decompiler/SetupRunnable.java | 6 +- .../actions/BaseDecompilerHandler.java | 4 +- .../decompiler/actions/ByteCodeAction.java | 5 +- .../actions/ByteCodeActionDelegate.java | 5 +- .../actions/ByteCodeMenuItemAction.java | 3 +- .../decompiler/actions/DecompileHandler.java | 5 +- .../actions/DecompilerPeferenceAction.java | 7 +- .../actions/DisassemblerAction.java | 5 +- .../actions/DisassemblerActionDelegate.java | 5 +- .../actions/DisassemblerMenuItemAction.java | 3 +- .../actions/ExportSourceAction.java | 25 +-- .../OpenClassWithContributionFactory.java | 5 +- .../decompiler/actions/SourceCodeAction.java | 5 +- .../actions/SourceCodeActionDelegate.java | 5 +- .../actions/SourceCodeMenuItemAction.java | 3 +- .../editor/BaseDecompilerSourceMapper.java | 17 +- .../editor/ByteCodeSourceViewer.java | 3 +- .../editor/DecompilerSourceMapper.java | 3 +- .../editor/DisassemblerSourceViewer.java | 9 +- .../editor/JavaDecompilerClassFileEditor.java | 79 ++++----- .../editor/RenderedBytecodeScanner.java | 6 +- .../DisassemblerPreferencePage.java | 31 ++-- .../JavaDecompilerPreferencePage.java | 27 ++-- .../sf/feeling/decompiler/util/UIUtil.java | 5 +- update_site/category.xml | 3 + 33 files changed, 279 insertions(+), 222 deletions(-) create mode 100644 org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/JavaDecompilerConstants.java diff --git a/.gitignore b/.gitignore index 393c2144..527b2a4b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .project **/bin/ **/target +**/.tycho-consumer-pom.xml diff --git a/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/decompiler/CfrDecompiler.java b/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/decompiler/CfrDecompiler.java index 3611310f..243682b7 100644 --- a/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/decompiler/CfrDecompiler.java +++ b/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/decompiler/CfrDecompiler.java @@ -29,6 +29,7 @@ import org.benf.cfr.reader.util.output.IllegalIdentifierDump; import org.benf.cfr.reader.util.output.MethodErrorCollector; import org.benf.cfr.reader.util.output.StringStreamDumper; +import org.sf.feeling.decompiler.JavaDecompilerConstants; import org.sf.feeling.decompiler.JavaDecompilerPlugin; import org.sf.feeling.decompiler.cfr.CfrDecompilerPlugin; import org.sf.feeling.decompiler.editor.BaseDecompiler; @@ -140,7 +141,7 @@ public void decompileFromArchive(String archivePath, String packege, String clas StopWatch stopWatch = new StopWatch(); stopWatch.start(); String tempDir = JavaDecompilerPlugin.getDefault().getPreferenceStore() - .getString(JavaDecompilerPlugin.TEMP_DIR); + .getString(JavaDecompilerConstants.TEMP_DIR); File workingDir = new File(tempDir + "/ecd_cfr_" + System.currentTimeMillis()); //$NON-NLS-1$ try { workingDir.mkdirs(); @@ -194,7 +195,8 @@ public boolean supportLevel(int level) { @Override public boolean supportDebugLevel(int level) { - return false; // CFR is not usable when debugging? + return false; // CFR does not seem to have an option to create code that matche sthe original + // line numbers } @Override diff --git a/org.sf.feeling.decompiler.fernflower/src/org/sf/feeling/decompiler/fernflower/decompiler/FernFlowerDecompiler.java b/org.sf.feeling.decompiler.fernflower/src/org/sf/feeling/decompiler/fernflower/decompiler/FernFlowerDecompiler.java index 5561f11e..78ff1234 100644 --- a/org.sf.feeling.decompiler.fernflower/src/org/sf/feeling/decompiler/fernflower/decompiler/FernFlowerDecompiler.java +++ b/org.sf.feeling.decompiler.fernflower/src/org/sf/feeling/decompiler/fernflower/decompiler/FernFlowerDecompiler.java @@ -22,6 +22,7 @@ import org.jetbrains.java.decompiler.main.decompiler.PrintStreamLogger; import org.jetbrains.java.decompiler.main.extern.IFernflowerLogger; import org.jetbrains.java.decompiler.main.extern.IFernflowerPreferences; +import org.sf.feeling.decompiler.JavaDecompilerConstants; import org.sf.feeling.decompiler.JavaDecompilerPlugin; import org.sf.feeling.decompiler.editor.BaseDecompiler; import org.sf.feeling.decompiler.editor.IDecompiler; @@ -158,7 +159,7 @@ public void decompileFromArchive(String archivePath, String packege, String clas StopWatch stopWatch = new StopWatch(); stopWatch.start(); File workingDir = new File( - JavaDecompilerPlugin.getDefault().getPreferenceStore().getString(JavaDecompilerPlugin.TEMP_DIR) + "/" //$NON-NLS-1$ + JavaDecompilerPlugin.getDefault().getPreferenceStore().getString(JavaDecompilerConstants.TEMP_DIR) + "/" //$NON-NLS-1$ + System.currentTimeMillis()); try { diff --git a/org.sf.feeling.decompiler.jd/src/jd/ide/eclipse/editors/JDSourceMapper.java b/org.sf.feeling.decompiler.jd/src/jd/ide/eclipse/editors/JDSourceMapper.java index b7374e6a..03836a65 100644 --- a/org.sf.feeling.decompiler.jd/src/jd/ide/eclipse/editors/JDSourceMapper.java +++ b/org.sf.feeling.decompiler.jd/src/jd/ide/eclipse/editors/JDSourceMapper.java @@ -16,6 +16,7 @@ import org.eclipse.core.runtime.Status; import org.eclipse.jface.preference.IPreferenceStore; import org.jd.core.v1.ClassFileToJavaSourceDecompiler; +import org.sf.feeling.decompiler.JavaDecompilerConstants; import org.sf.feeling.decompiler.JavaDecompilerPlugin; import org.sf.feeling.decompiler.editor.BaseDecompilerSourceMapper; import org.sf.feeling.decompiler.jd.decompiler.JDCorePrinter; @@ -73,12 +74,12 @@ public char[] findSource(String javaSourcePath) { } } else { JavaDecompilerPlugin.getDefault().getLog() - .log(new Status(Status.ERROR, JavaDecompilerPlugin.PLUGIN_ID, 0, + .log(new Status(Status.ERROR, JavaDecompilerConstants.PLUGIN_ID, 0, "Unable to decompile: " + decompilePath + " is not a valid file.", null)); } } catch (Exception e) { JavaDecompilerPlugin.getDefault().getLog() - .log(new Status(Status.ERROR, JavaDecompilerPlugin.PLUGIN_ID, 0, e.getMessage(), e)); + .log(new Status(Status.ERROR, JavaDecompilerConstants.PLUGIN_ID, 0, e.getMessage(), e)); } } @@ -96,10 +97,10 @@ public String decompile(String basePath, String classPath) throws Exception { // Load preferences IPreferenceStore store = JavaDecompilerPlugin.getDefault().getPreferenceStore(); - boolean realignmentLineNumber = store.getBoolean(JavaDecompilerPlugin.ALIGN); + boolean realignmentLineNumber = store.getBoolean(JavaDecompilerConstants.ALIGN); boolean unicodeEscape = false; // currently unused : // store.getBoolean(JavaDecompilerPlugin.PREF_ESCAPE_UNICODE_CHARACTERS); - boolean showLineNumbers = store.getBoolean(JavaDecompilerPlugin.PREF_DISPLAY_LINE_NUMBERS); + boolean showLineNumbers = store.getBoolean(JavaDecompilerConstants.PREF_DISPLAY_LINE_NUMBERS); // boolean showMetadata = // store.getBoolean(JavaDecompilerPlugin.PREF_DISPLAY_METADATA); diff --git a/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/decompiler/ProcyonDecompiler.java b/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/decompiler/ProcyonDecompiler.java index d8f8f89f..bccb9e77 100644 --- a/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/decompiler/ProcyonDecompiler.java +++ b/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/decompiler/ProcyonDecompiler.java @@ -20,6 +20,7 @@ import java.util.regex.Pattern; import org.apache.commons.lang3.time.StopWatch; +import org.sf.feeling.decompiler.JavaDecompilerConstants; import org.sf.feeling.decompiler.JavaDecompilerPlugin; import org.sf.feeling.decompiler.editor.BaseDecompiler; import org.sf.feeling.decompiler.editor.IDecompiler; @@ -169,7 +170,7 @@ public void decompileFromArchive(String archivePath, String packege, String clas StopWatch stopWatch = new StopWatch(); stopWatch.start(); File workingDir = new File( - JavaDecompilerPlugin.getDefault().getPreferenceStore().getString(JavaDecompilerPlugin.TEMP_DIR) + "/" //$NON-NLS-1$ + JavaDecompilerPlugin.getDefault().getPreferenceStore().getString(JavaDecompilerConstants.TEMP_DIR) + "/" //$NON-NLS-1$ + System.currentTimeMillis()); try { diff --git a/org.sf.feeling.decompiler.vineflower/src/org/sf/feeling/decompiler/vineflower/decompiler/VineflowerDecompiler.java b/org.sf.feeling.decompiler.vineflower/src/org/sf/feeling/decompiler/vineflower/decompiler/VineflowerDecompiler.java index 1e5921f6..fb252984 100644 --- a/org.sf.feeling.decompiler.vineflower/src/org/sf/feeling/decompiler/vineflower/decompiler/VineflowerDecompiler.java +++ b/org.sf.feeling.decompiler.vineflower/src/org/sf/feeling/decompiler/vineflower/decompiler/VineflowerDecompiler.java @@ -23,6 +23,7 @@ import org.jetbrains.java.decompiler.main.decompiler.PrintStreamLogger; import org.jetbrains.java.decompiler.main.extern.IFernflowerLogger; import org.jetbrains.java.decompiler.main.extern.IFernflowerPreferences; +import org.sf.feeling.decompiler.JavaDecompilerConstants; import org.sf.feeling.decompiler.JavaDecompilerPlugin; import org.sf.feeling.decompiler.editor.BaseDecompiler; import org.sf.feeling.decompiler.editor.IDecompiler; @@ -157,7 +158,7 @@ public boolean accept(File dir, String name) { public void decompileFromArchive(String archivePath, String packege, String className) { start = System.currentTimeMillis(); File workingDir = new File( - JavaDecompilerPlugin.getDefault().getPreferenceStore().getString(JavaDecompilerPlugin.TEMP_DIR) + "/" //$NON-NLS-1$ + JavaDecompilerPlugin.getDefault().getPreferenceStore().getString(JavaDecompilerConstants.TEMP_DIR) + "/" //$NON-NLS-1$ + System.currentTimeMillis()); try { diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/JavaDecompilerConstants.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/JavaDecompilerConstants.java new file mode 100644 index 00000000..13466ce9 --- /dev/null +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/JavaDecompilerConstants.java @@ -0,0 +1,50 @@ +package org.sf.feeling.decompiler; + +public class JavaDecompilerConstants { + + public static final String EDITOR_ID = "org.sf.feeling.decompiler.ClassFileEditor"; //$NON-NLS-1$ + public static final String PLUGIN_ID = "org.sf.feeling.decompiler"; //$NON-NLS-1$ + public static final String TEMP_DIR = "org.sf.feeling.decompiler.tempd"; //$NON-NLS-1$ + + public static final String REUSE_BUFFER = "org.sf.feeling.decompiler.reusebuff"; //$NON-NLS-1$ + public static final String IGNORE_EXISTING = "org.sf.feeling.decompiler.alwaysuse"; //$NON-NLS-1$ + public static final String USE_ECLIPSE_FORMATTER = "org.sf.feeling.decompiler.use_eclipse_formatter"; //$NON-NLS-1$ + public static final String USE_ECLIPSE_SORTER = "org.sf.feeling.decompiler.use_eclipse_sorter"; //$NON-NLS-1$ + public static final String DECOMPILER_TYPE = "org.sf.feeling.decompiler.type"; //$NON-NLS-1$ + public static final String PREF_DISPLAY_LINE_NUMBERS = "jd.ide.eclipse.prefs.DisplayLineNumbers"; //$NON-NLS-1$ + public static final String PREF_DISPLAY_METADATA = "jd.ide.eclipse.prefs.DisplayMetadata"; //$NON-NLS-1$ + public static final String ALIGN = "jd.ide.eclipse.prefs.RealignLineNumbers"; //$NON-NLS-1$ + public static final String DEFAULT_EDITOR = "org.sf.feeling.decompiler.default_editor"; //$NON-NLS-1$ ; + public static final String EXPORT_ENCODING = "org.sf.feeling.decompiler.export.encoding"; //$NON-NLS-1$ ; + @Deprecated + public static final String ATTACH_SOURCE = "org.sf.feeling.decompiler.attach_source"; //$NON-NLS-1$ ; + public static final String bytecodeMnemonicPreferencesPrefix = "BYTECODEMNEMONIC_"; //$NON-NLS-1$ + public static final String BYTECODE_MNEMONIC = bytecodeMnemonicPreferencesPrefix + "bytecodeMnemonic"; //$NON-NLS-1$ + public static final String BYTECODE_MNEMONIC_BOLD = bytecodeMnemonicPreferencesPrefix + "bytecodeMnemonic_bold"; //$NON-NLS-1$ + public static final String BYTECODE_MNEMONIC_ITALIC = bytecodeMnemonicPreferencesPrefix + "bytecodeMnemonic_italic"; //$NON-NLS-1$ + public static final String BYTECODE_MNEMONIC_STRIKETHROUGH = bytecodeMnemonicPreferencesPrefix + + "bytecodeMnemonic_strikethrough"; //$NON-NLS-1$ + public static final String BYTECODE_MNEMONIC_UNDERLINE = bytecodeMnemonicPreferencesPrefix + + "bytecodeMnemonic_underline"; //$NON-NLS-1$ + public static final String classFileAttributePreferencesPrefix = "CLASS_FILE_ATTR_"; //$NON-NLS-1$ + public static final String CLASS_FILE_ATTR_SHOW_CONSTANT_POOL = classFileAttributePreferencesPrefix + + "show_constantPool"; //$NON-NLS-1$ + public static final String CLASS_FILE_ATTR_SHOW_LINE_NUMBER_TABLE = classFileAttributePreferencesPrefix + + "show_lineNumberTable"; //$NON-NLS-1$ + public static final String CLASS_FILE_ATTR_SHOW_VARIABLE_TABLE = classFileAttributePreferencesPrefix + + "show_localVariableTable"; //$NON-NLS-1$ + public static final String CLASS_FILE_ATTR_SHOW_EXCEPTION_TABLE = classFileAttributePreferencesPrefix + + "show_exceptionTable"; //$NON-NLS-1$ + public static final String CLASS_FILE_ATTR_SHOW_MAXS = classFileAttributePreferencesPrefix + "show_maxs"; //$NON-NLS-1$ + public static final String CLASS_FILE_ATTR_RENDER_TRYCATCH_BLOCKS = classFileAttributePreferencesPrefix + + "render_tryCatchBlocks"; //$NON-NLS-1$ + public static final String CLASS_FILE_ATTR_SHOW_SOURCE_LINE_NUMBERS = classFileAttributePreferencesPrefix + + "render_sourceLineNumbers"; //$NON-NLS-1$ + public static final String BRANCH_TARGET_ADDRESS_RENDERING = "BRANCH_TARGET_ADDRESS_RENDERING"; //$NON-NLS-1$ + public static final String BRANCH_TARGET_ADDRESS_ABSOLUTE = BRANCH_TARGET_ADDRESS_RENDERING + "_ABSOLUTE"; //$NON-NLS-1$ + public static final String BRANCH_TARGET_ADDRESS_RELATIVE = BRANCH_TARGET_ADDRESS_RENDERING + "_RELATIVE"; //$NON-NLS-1$ + public static final int SOURCE_MODE = 0; + public static final int BYTE_CODE_MODE = 1; + public static final int DISASSEMBLER_MODE = 2; + +} diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/JavaDecompilerPlugin.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/JavaDecompilerPlugin.java index c5ef3b46..4ad7ca09 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/JavaDecompilerPlugin.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/JavaDecompilerPlugin.java @@ -12,6 +12,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.nio.charset.StandardCharsets; +import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.Map; @@ -43,48 +44,10 @@ public class JavaDecompilerPlugin extends AbstractUIPlugin implements IPropertyChangeListener { - public static final String EDITOR_ID = "org.sf.feeling.decompiler.ClassFileEditor"; //$NON-NLS-1$ - public static final String PLUGIN_ID = "org.sf.feeling.decompiler"; //$NON-NLS-1$ - public static final String TEMP_DIR = "org.sf.feeling.decompiler.tempd"; //$NON-NLS-1$ - - public static final String REUSE_BUFFER = "org.sf.feeling.decompiler.reusebuff"; //$NON-NLS-1$ - public static final String IGNORE_EXISTING = "org.sf.feeling.decompiler.alwaysuse"; //$NON-NLS-1$ - public static final String USE_ECLIPSE_FORMATTER = "org.sf.feeling.decompiler.use_eclipse_formatter"; //$NON-NLS-1$ - public static final String USE_ECLIPSE_SORTER = "org.sf.feeling.decompiler.use_eclipse_sorter"; //$NON-NLS-1$ - public static final String DECOMPILER_TYPE = "org.sf.feeling.decompiler.type"; //$NON-NLS-1$ - public static final String PREF_DISPLAY_LINE_NUMBERS = "jd.ide.eclipse.prefs.DisplayLineNumbers"; //$NON-NLS-1$ - public static final String PREF_DISPLAY_METADATA = "jd.ide.eclipse.prefs.DisplayMetadata"; //$NON-NLS-1$ - public static final String ALIGN = "jd.ide.eclipse.prefs.RealignLineNumbers"; //$NON-NLS-1$ - public static final String DEFAULT_EDITOR = "org.sf.feeling.decompiler.default_editor"; //$NON-NLS-1$ ; - public static final String EXPORT_ENCODING = "org.sf.feeling.decompiler.export.encoding"; //$NON-NLS-1$ ; - public static final String ATTACH_SOURCE = "org.sf.feeling.decompiler.attach_source"; //$NON-NLS-1$ ; - - public static final String bytecodeMnemonicPreferencesPrefix = "BYTECODEMNEMONIC_"; //$NON-NLS-1$ - public static final String BYTECODE_MNEMONIC = bytecodeMnemonicPreferencesPrefix + "bytecodeMnemonic"; //$NON-NLS-1$ - public static final String BYTECODE_MNEMONIC_BOLD = bytecodeMnemonicPreferencesPrefix + "bytecodeMnemonic_bold"; //$NON-NLS-1$ - public static final String BYTECODE_MNEMONIC_ITALIC = bytecodeMnemonicPreferencesPrefix + "bytecodeMnemonic_italic"; //$NON-NLS-1$ - public static final String BYTECODE_MNEMONIC_STRIKETHROUGH = bytecodeMnemonicPreferencesPrefix - + "bytecodeMnemonic_strikethrough"; //$NON-NLS-1$ - public static final String BYTECODE_MNEMONIC_UNDERLINE = bytecodeMnemonicPreferencesPrefix - + "bytecodeMnemonic_underline"; //$NON-NLS-1$ - - public static final String classFileAttributePreferencesPrefix = "CLASS_FILE_ATTR_"; //$NON-NLS-1$ - public static final String CLASS_FILE_ATTR_SHOW_CONSTANT_POOL = classFileAttributePreferencesPrefix - + "show_constantPool"; //$NON-NLS-1$ - public static final String CLASS_FILE_ATTR_SHOW_LINE_NUMBER_TABLE = classFileAttributePreferencesPrefix - + "show_lineNumberTable"; //$NON-NLS-1$ - public static final String CLASS_FILE_ATTR_SHOW_VARIABLE_TABLE = classFileAttributePreferencesPrefix - + "show_localVariableTable"; //$NON-NLS-1$ - public static final String CLASS_FILE_ATTR_SHOW_EXCEPTION_TABLE = classFileAttributePreferencesPrefix - + "show_exceptionTable"; //$NON-NLS-1$ - public static final String CLASS_FILE_ATTR_SHOW_MAXS = classFileAttributePreferencesPrefix + "show_maxs"; //$NON-NLS-1$ - public static final String CLASS_FILE_ATTR_RENDER_TRYCATCH_BLOCKS = classFileAttributePreferencesPrefix - + "render_tryCatchBlocks"; //$NON-NLS-1$ - public static final String CLASS_FILE_ATTR_SHOW_SOURCE_LINE_NUMBERS = classFileAttributePreferencesPrefix - + "render_sourceLineNumbers"; //$NON-NLS-1$ - public static final String BRANCH_TARGET_ADDRESS_RENDERING = "BRANCH_TARGET_ADDRESS_RENDERING"; //$NON-NLS-1$ - public static final String BRANCH_TARGET_ADDRESS_ABSOLUTE = BRANCH_TARGET_ADDRESS_RENDERING + "_ABSOLUTE"; //$NON-NLS-1$ - public static final String BRANCH_TARGET_ADDRESS_RELATIVE = BRANCH_TARGET_ADDRESS_RENDERING + "_RELATIVE"; //$NON-NLS-1$ + private static final String ECD_DECOMPILER_CLASS_NAME_PREFIX = "org.sf.feeling.decompiler"; + + private static final List ALLOWED_PLUGINS = Arrays.asList("cfr", "fernflower", "jd", "procyon", + "vineflower"); private static JavaDecompilerPlugin plugin; @@ -93,10 +56,6 @@ public class JavaDecompilerPlugin extends AbstractUIPlugin implements IPropertyC private boolean isDebugMode = false; - public static final int SOURCE_MODE = 0; - public static final int BYTE_CODE_MODE = 1; - public static final int DISASSEMBLER_MODE = 2; - private int sourceMode = 0; public Map getDecompilerDescriptorMap() { @@ -116,15 +75,15 @@ public static JavaDecompilerPlugin getDefault() { } public static void logError(Throwable t, String message) { - JavaDecompilerPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, 0, message, t)); + JavaDecompilerPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, JavaDecompilerConstants.PLUGIN_ID, 0, message, t)); } public static void logInfo(String message) { - JavaDecompilerPlugin.getDefault().getLog().log(new Status(IStatus.INFO, PLUGIN_ID, 0, message, null)); + JavaDecompilerPlugin.getDefault().getLog().log(new Status(IStatus.INFO, JavaDecompilerConstants.PLUGIN_ID, 0, message, null)); } public static void log(int severity, Throwable t, String message) { - JavaDecompilerPlugin.getDefault().getLog().log(new Status(severity, PLUGIN_ID, 0, message, t)); + JavaDecompilerPlugin.getDefault().getLog().log(new Status(severity, JavaDecompilerConstants.PLUGIN_ID, 0, message, t)); } public static ImageDescriptor getImageDescriptor(String path) { @@ -148,33 +107,33 @@ public JavaDecompilerPlugin() { @Override protected void initializeDefaultPreferences(IPreferenceStore store) { - store.setDefault(TEMP_DIR, System.getProperty("java.io.tmpdir") //$NON-NLS-1$ + store.setDefault(JavaDecompilerConstants.TEMP_DIR, System.getProperty("java.io.tmpdir") //$NON-NLS-1$ + File.separator + ".org.sf.feeling.decompiler" //$NON-NLS-1$ + System.currentTimeMillis()); - store.setDefault(REUSE_BUFFER, true); - store.setDefault(IGNORE_EXISTING, false); - store.setDefault(USE_ECLIPSE_FORMATTER, true); - store.setDefault(USE_ECLIPSE_SORTER, false); - store.setDefault(PREF_DISPLAY_METADATA, false); - store.setDefault(DEFAULT_EDITOR, true); - store.setDefault(ATTACH_SOURCE, false); - store.setDefault(EXPORT_ENCODING, StandardCharsets.UTF_8.name()); - - PreferenceConverter.setDefault(store, BYTECODE_MNEMONIC, new RGB(0, 0, 0)); - store.setDefault(BYTECODE_MNEMONIC_BOLD, true); - store.setDefault(BYTECODE_MNEMONIC_ITALIC, false); - store.setDefault(BYTECODE_MNEMONIC_STRIKETHROUGH, false); - store.setDefault(BYTECODE_MNEMONIC_UNDERLINE, false); - - store.setDefault(CLASS_FILE_ATTR_SHOW_CONSTANT_POOL, false); - store.setDefault(CLASS_FILE_ATTR_SHOW_LINE_NUMBER_TABLE, false); - store.setDefault(CLASS_FILE_ATTR_SHOW_VARIABLE_TABLE, false); - store.setDefault(CLASS_FILE_ATTR_SHOW_EXCEPTION_TABLE, false); - store.setDefault(CLASS_FILE_ATTR_SHOW_MAXS, false); - store.setDefault(BRANCH_TARGET_ADDRESS_RENDERING, BRANCH_TARGET_ADDRESS_RELATIVE); - store.setDefault(CLASS_FILE_ATTR_RENDER_TRYCATCH_BLOCKS, true); - store.setDefault(CLASS_FILE_ATTR_SHOW_SOURCE_LINE_NUMBERS, true); - store.setDefault(CLASS_FILE_ATTR_SHOW_MAXS, false); + store.setDefault(JavaDecompilerConstants.REUSE_BUFFER, true); + store.setDefault(JavaDecompilerConstants.IGNORE_EXISTING, false); + store.setDefault(JavaDecompilerConstants.USE_ECLIPSE_FORMATTER, true); + store.setDefault(JavaDecompilerConstants.USE_ECLIPSE_SORTER, false); + store.setDefault(JavaDecompilerConstants.PREF_DISPLAY_METADATA, false); + store.setDefault(JavaDecompilerConstants.DEFAULT_EDITOR, true); + store.setDefault(JavaDecompilerConstants.ATTACH_SOURCE, false); + store.setDefault(JavaDecompilerConstants.EXPORT_ENCODING, StandardCharsets.UTF_8.name()); + + PreferenceConverter.setDefault(store, JavaDecompilerConstants.BYTECODE_MNEMONIC, new RGB(0, 0, 0)); + store.setDefault(JavaDecompilerConstants.BYTECODE_MNEMONIC_BOLD, true); + store.setDefault(JavaDecompilerConstants.BYTECODE_MNEMONIC_ITALIC, false); + store.setDefault(JavaDecompilerConstants.BYTECODE_MNEMONIC_STRIKETHROUGH, false); + store.setDefault(JavaDecompilerConstants.BYTECODE_MNEMONIC_UNDERLINE, false); + + store.setDefault(JavaDecompilerConstants.CLASS_FILE_ATTR_SHOW_CONSTANT_POOL, false); + store.setDefault(JavaDecompilerConstants.CLASS_FILE_ATTR_SHOW_LINE_NUMBER_TABLE, false); + store.setDefault(JavaDecompilerConstants.CLASS_FILE_ATTR_SHOW_VARIABLE_TABLE, false); + store.setDefault(JavaDecompilerConstants.CLASS_FILE_ATTR_SHOW_EXCEPTION_TABLE, false); + store.setDefault(JavaDecompilerConstants.CLASS_FILE_ATTR_SHOW_MAXS, false); + store.setDefault(JavaDecompilerConstants.BRANCH_TARGET_ADDRESS_RENDERING, JavaDecompilerConstants.BRANCH_TARGET_ADDRESS_RELATIVE); + store.setDefault(JavaDecompilerConstants.CLASS_FILE_ATTR_RENDER_TRYCATCH_BLOCKS, true); + store.setDefault(JavaDecompilerConstants.CLASS_FILE_ATTR_SHOW_SOURCE_LINE_NUMBERS, true); + store.setDefault(JavaDecompilerConstants.CLASS_FILE_ATTR_SHOW_MAXS, false); } private void initializeDecompilerDescriptorMap(IPreferenceStore store) { @@ -182,7 +141,24 @@ private void initializeDecompilerDescriptorMap(IPreferenceStore store) { IDecompilerDescriptor.class); if (decompilerAdapters != null) { + for (IDecompilerDescriptor descriptor : decompilerAdapters) { + // Filter out plugins/features of outdated ECD plugins (e.g. plugins that + // belong to an older ECD version) + String className = descriptor.getClass().getName(); + if (className.startsWith(ECD_DECOMPILER_CLASS_NAME_PREFIX)) { + String name = className.substring(ECD_DECOMPILER_CLASS_NAME_PREFIX.length() + 1); + int idx = name.indexOf('.'); + if (idx > 0) { + name = name.substring(0, idx); + boolean allowed = (ALLOWED_PLUGINS.indexOf(name) >= 0); + if (!allowed) { + Logger.error("Disabling unknown decompiler plugin: " + className); + continue; + } + } + } + if (descriptor.isEnabled()) { decompilerDescriptorMap.put(descriptor.getDecompilerType(), descriptor); } @@ -192,7 +168,7 @@ private void initializeDecompilerDescriptorMap(IPreferenceStore store) { @Override public void propertyChange(PropertyChangeEvent event) { - if (event.getProperty().equals(IGNORE_EXISTING)) { + if (event.getProperty().equals(JavaDecompilerConstants.IGNORE_EXISTING)) { JavaDecompilerBufferManager.closeDecompilerBuffers(false); } } @@ -212,12 +188,12 @@ public IPreferenceStore getPreferenceStore() { if (preferenceStore == null) { preferenceStore = super.getPreferenceStore(); - String decompilerType = preferenceStore.getString(DECOMPILER_TYPE); + String decompilerType = preferenceStore.getString(JavaDecompilerConstants.DECOMPILER_TYPE); IDecompilerDescriptor descriptor = getDecompilerDescriptor(decompilerType); if (descriptor == null) { String defaultDecompiler = getDefaultDecompilerType(); if (defaultDecompiler != null) { - preferenceStore.setDefault(DECOMPILER_TYPE, defaultDecompiler); + preferenceStore.setDefault(JavaDecompilerConstants.DECOMPILER_TYPE, defaultDecompiler); } } } @@ -225,7 +201,7 @@ public IPreferenceStore getPreferenceStore() { } public void initializeDefaultDecompilerType() { - String decompilerType = preferenceStore.getString(DECOMPILER_TYPE); + String decompilerType = preferenceStore.getString(JavaDecompilerConstants.DECOMPILER_TYPE); IDecompilerDescriptor descriptor = getDecompilerDescriptor(decompilerType); if (descriptor != null) { return; @@ -235,14 +211,14 @@ public void initializeDefaultDecompilerType() { if (!descriptorColl.isEmpty()) { String defaultDecompiler = getDefaultDecompilerType(); if (defaultDecompiler != null) { - preferenceStore.setDefault(DECOMPILER_TYPE, defaultDecompiler); + preferenceStore.setDefault(JavaDecompilerConstants.DECOMPILER_TYPE, defaultDecompiler); } } } @Override public void stop(BundleContext context) throws Exception { - FileUtil.deltree(new File(getPreferenceStore().getString(JavaDecompilerPlugin.TEMP_DIR))); + FileUtil.deltree(new File(getPreferenceStore().getString(JavaDecompilerConstants.TEMP_DIR))); super.stop(context); @@ -252,23 +228,23 @@ public void stop(BundleContext context) throws Exception { } public Boolean isDisplayLineNumber() { - return Boolean.valueOf(getPreferenceStore().getBoolean(PREF_DISPLAY_LINE_NUMBERS)); + return Boolean.valueOf(getPreferenceStore().getBoolean(JavaDecompilerConstants.PREF_DISPLAY_LINE_NUMBERS)); } public Boolean isDebug() { - return Boolean.valueOf(getPreferenceStore().getBoolean(ALIGN)); + return Boolean.valueOf(getPreferenceStore().getBoolean(JavaDecompilerConstants.ALIGN)); } public void displayLineNumber(Boolean display) { - getPreferenceStore().setValue(PREF_DISPLAY_LINE_NUMBERS, display.booleanValue()); + getPreferenceStore().setValue(JavaDecompilerConstants.PREF_DISPLAY_LINE_NUMBERS, display.booleanValue()); } public void setExportEncoding(String encoding) { - getPreferenceStore().setValue(EXPORT_ENCODING, encoding); + getPreferenceStore().setValue(JavaDecompilerConstants.EXPORT_ENCODING, encoding); } public String getExportEncoding() { - return getPreferenceStore().getString(EXPORT_ENCODING); + return getPreferenceStore().getString(JavaDecompilerConstants.EXPORT_ENCODING); } public boolean enableAttachSourceSetting() { @@ -297,7 +273,7 @@ public void syncLibrarySource(IPackageFragmentRoot library) { if (library.getPath() != null && library.getSourceAttachmentPath() != null && !libraries.contains(library.getPath().toOSString())) { final IPreferenceStore prefs = JavaDecompilerPlugin.getDefault().getPreferenceStore(); - if (prefs.getBoolean(JavaDecompilerPlugin.DEFAULT_EDITOR)) { + if (prefs.getBoolean(JavaDecompilerConstants.DEFAULT_EDITOR)) { final Object attachSourceAdapter = DecompilerAdapterManager .getAdapter(JavaDecompilerPlugin.getDefault(), IAttachSourceHandler.class); if (attachSourceAdapter instanceof IAttachSourceHandler) { @@ -318,7 +294,7 @@ public boolean isAutoAttachSource() { return false; } - return getPreferenceStore().getBoolean(ATTACH_SOURCE); + return getPreferenceStore().getBoolean(JavaDecompilerConstants.ATTACH_SOURCE); } public String getDefaultDecompilerType() { @@ -349,7 +325,7 @@ public void setSourceMode(int sourceMode) { } public String getDefaultExportEncoding() { - return getPreferenceStore().getDefaultString(JavaDecompilerPlugin.EXPORT_ENCODING); + return getPreferenceStore().getDefaultString(JavaDecompilerConstants.EXPORT_ENCODING); } } \ No newline at end of file diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/SetupRunnable.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/SetupRunnable.java index 5cb4059c..071ff66a 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/SetupRunnable.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/SetupRunnable.java @@ -198,7 +198,7 @@ public void windowActivated(IWorkbenchWindow window) { private void checkClassFileAssociation() { IPreferenceStore prefs = JavaDecompilerPlugin.getDefault().getPreferenceStore(); - if (prefs.getBoolean(JavaDecompilerPlugin.DEFAULT_EDITOR)) { + if (prefs.getBoolean(JavaDecompilerConstants.DEFAULT_EDITOR)) { updateClassDefaultEditor(); IPreferenceStore store = WorkbenchPlugin.getDefault().getPreferenceStore(); @@ -241,7 +241,7 @@ protected void updateClassDefaultEditor() { IFileEditorMapping mapping = classMappings[i]; for (int j = 0; j < mapping.getEditors().length; j++) { IEditorDescriptor editor = mapping.getEditors()[j]; - if (editor.getId().equals(JavaDecompilerPlugin.EDITOR_ID)) { + if (editor.getId().equals(JavaDecompilerConstants.EDITOR_ID)) { try { ReflectionUtils.invokeMethod(mapping, "setDefaultEditor", //$NON-NLS-1$ new Class[] { Class.forName("org.eclipse.ui.IEditorDescriptor") //$NON-NLS-1$ @@ -268,7 +268,7 @@ protected boolean checkDefaultEditor(IFileEditorMapping[] classMappings) { for (int i = 0; i < classMappings.length; i++) { IFileEditorMapping mapping = classMappings[i]; if (mapping.getDefaultEditor() != null - && !mapping.getDefaultEditor().getId().equals(JavaDecompilerPlugin.EDITOR_ID)) { + && !mapping.getDefaultEditor().getId().equals(JavaDecompilerConstants.EDITOR_ID)) { return true; } } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/BaseDecompilerHandler.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/BaseDecompilerHandler.java index eddb0395..4a0abe50 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/BaseDecompilerHandler.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/BaseDecompilerHandler.java @@ -13,7 +13,7 @@ import org.eclipse.ui.IEditorDescriptor; import org.eclipse.ui.IEditorRegistry; import org.eclipse.ui.PlatformUI; -import org.sf.feeling.decompiler.JavaDecompilerPlugin; +import org.sf.feeling.decompiler.JavaDecompilerConstants; import org.sf.feeling.decompiler.actions.OpenClassWithContributionFactory.OpenClassesAction; import org.sf.feeling.decompiler.editor.JavaDecompilerClassFileEditor; import org.sf.feeling.decompiler.util.UIUtil; @@ -24,7 +24,7 @@ protected Object handleDecompile(String decompilerType) { final List classes = UIUtil.getActiveSelection(); if (classes != null && !classes.isEmpty()) { IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry(); - IEditorDescriptor editorDescriptor = registry.findEditor(JavaDecompilerPlugin.EDITOR_ID); + IEditorDescriptor editorDescriptor = registry.findEditor(JavaDecompilerConstants.EDITOR_ID); if (editorDescriptor == null) { JavaDecompilerClassFileEditor editor = UIUtil.getActiveEditor(); if (editor != null) { diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/ByteCodeAction.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/ByteCodeAction.java index cf2e9334..77db6f74 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/ByteCodeAction.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/ByteCodeAction.java @@ -11,6 +11,7 @@ import org.eclipse.jface.action.Action; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.texteditor.IUpdate; +import org.sf.feeling.decompiler.JavaDecompilerConstants; import org.sf.feeling.decompiler.JavaDecompilerPlugin; import org.sf.feeling.decompiler.editor.JavaDecompilerClassFileEditor; import org.sf.feeling.decompiler.i18n.Messages; @@ -26,7 +27,7 @@ public ByteCodeAction() { @Override public void run() { - JavaDecompilerPlugin.getDefault().setSourceMode(JavaDecompilerPlugin.BYTE_CODE_MODE); + JavaDecompilerPlugin.getDefault().setSourceMode(JavaDecompilerConstants.BYTE_CODE_MODE); setChecked(true); final JavaDecompilerClassFileEditor editor = UIUtil.getActiveEditor(); if (editor != null) { @@ -48,7 +49,7 @@ public boolean isEnabled() { } public boolean isChecked() { - return JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.BYTE_CODE_MODE; + return JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.BYTE_CODE_MODE; } @Override diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/ByteCodeActionDelegate.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/ByteCodeActionDelegate.java index 176e3e51..bf63dcde 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/ByteCodeActionDelegate.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/ByteCodeActionDelegate.java @@ -13,6 +13,7 @@ import org.eclipse.ui.IEditorActionDelegate; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.actions.ActionDelegate; +import org.sf.feeling.decompiler.JavaDecompilerConstants; import org.sf.feeling.decompiler.JavaDecompilerPlugin; import org.sf.feeling.decompiler.editor.JavaDecompilerClassFileEditor; @@ -24,7 +25,7 @@ public class ByteCodeActionDelegate extends ActionDelegate implements IEditorAct public void setActiveEditor(IAction action, IEditorPart targetEditor) { if (targetEditor instanceof JavaDecompilerClassFileEditor) { editor = (JavaDecompilerClassFileEditor) targetEditor; - action.setChecked(JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.BYTE_CODE_MODE); + action.setChecked(JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.BYTE_CODE_MODE); } } @@ -35,6 +36,6 @@ public void run(IAction action) { @Override public void selectionChanged(IAction action, ISelection selection) { - action.setChecked(JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.BYTE_CODE_MODE); + action.setChecked(JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.BYTE_CODE_MODE); } } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/ByteCodeMenuItemAction.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/ByteCodeMenuItemAction.java index af0e7e18..e9b61e8b 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/ByteCodeMenuItemAction.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/ByteCodeMenuItemAction.java @@ -15,6 +15,7 @@ import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowPulldownDelegate; import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2; +import org.sf.feeling.decompiler.JavaDecompilerConstants; import org.sf.feeling.decompiler.JavaDecompilerPlugin; public class ByteCodeMenuItemAction implements IWorkbenchWindowPulldownDelegate, IWorkbenchWindowPulldownDelegate2 { @@ -48,6 +49,6 @@ public void run(IAction action) { @Override public void selectionChanged(IAction action, ISelection selection) { - action.setChecked(JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.BYTE_CODE_MODE); + action.setChecked(JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.BYTE_CODE_MODE); } } \ No newline at end of file diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DecompileHandler.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DecompileHandler.java index 97c3fd0f..f702106f 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DecompileHandler.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DecompileHandler.java @@ -17,6 +17,7 @@ import org.eclipse.ui.IEditorDescriptor; import org.eclipse.ui.IEditorRegistry; import org.eclipse.ui.PlatformUI; +import org.sf.feeling.decompiler.JavaDecompilerConstants; import org.sf.feeling.decompiler.JavaDecompilerPlugin; import org.sf.feeling.decompiler.actions.OpenClassWithContributionFactory.OpenClassesAction; import org.sf.feeling.decompiler.editor.JavaDecompilerClassFileEditor; @@ -29,9 +30,9 @@ public Object execute(ExecutionEvent event) throws ExecutionException { final List classes = UIUtil.getActiveSelection(); if (classes != null && !classes.isEmpty() && PlatformUI.getWorkbench() != null) { IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry(); - IEditorDescriptor editor = registry.findEditor(JavaDecompilerPlugin.EDITOR_ID); + IEditorDescriptor editor = registry.findEditor(JavaDecompilerConstants.EDITOR_ID); IPreferenceStore prefs = JavaDecompilerPlugin.getDefault().getPreferenceStore(); - String decompilerType = prefs.getString(JavaDecompilerPlugin.DECOMPILER_TYPE); + String decompilerType = prefs.getString(JavaDecompilerConstants.DECOMPILER_TYPE); new OpenClassesAction(editor, classes, decompilerType).run(); } else { JavaDecompilerClassFileEditor editor = UIUtil.getActiveEditor(); diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DecompilerPeferenceAction.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DecompilerPeferenceAction.java index 1bbc5030..0c74bc00 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DecompilerPeferenceAction.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DecompilerPeferenceAction.java @@ -11,6 +11,7 @@ import org.eclipse.jface.action.Action; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.dialogs.PreferencesUtil; +import org.sf.feeling.decompiler.JavaDecompilerConstants; import org.sf.feeling.decompiler.JavaDecompilerPlugin; import org.sf.feeling.decompiler.editor.JavaDecompilerClassFileEditor; import org.sf.feeling.decompiler.i18n.Messages; @@ -27,11 +28,11 @@ public void run() { JavaDecompilerClassFileEditor editor = UIUtil.getActiveDecompilerEditor(); String showId = "org.sf.feeling.decompiler.Main"; //$NON-NLS-1$ - if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.SOURCE_MODE) { + if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.SOURCE_MODE) { showId = "org.sf.feeling.decompiler.Main"; //$NON-NLS-1$ - } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.DISASSEMBLER_MODE) { + } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.DISASSEMBLER_MODE) { showId = "org.sf.feeling.decompiler.Disassembler"; //$NON-NLS-1$ - } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.BYTE_CODE_MODE) { + } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.BYTE_CODE_MODE) { showId = "org.eclipse.ui.preferencePages.ColorsAndFonts"; //$NON-NLS-1$ } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DisassemblerAction.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DisassemblerAction.java index 794df3fe..20f9e141 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DisassemblerAction.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DisassemblerAction.java @@ -11,6 +11,7 @@ import org.eclipse.jface.action.Action; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.texteditor.IUpdate; +import org.sf.feeling.decompiler.JavaDecompilerConstants; import org.sf.feeling.decompiler.JavaDecompilerPlugin; import org.sf.feeling.decompiler.editor.JavaDecompilerClassFileEditor; import org.sf.feeling.decompiler.i18n.Messages; @@ -26,7 +27,7 @@ public DisassemblerAction() { @Override public void run() { - JavaDecompilerPlugin.getDefault().setSourceMode(JavaDecompilerPlugin.DISASSEMBLER_MODE); + JavaDecompilerPlugin.getDefault().setSourceMode(JavaDecompilerConstants.DISASSEMBLER_MODE); setChecked(true); final JavaDecompilerClassFileEditor editor = UIUtil.getActiveEditor(); if (editor != null) { @@ -48,7 +49,7 @@ public boolean isEnabled() { } public boolean isChecked() { - return JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.DISASSEMBLER_MODE; + return JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.DISASSEMBLER_MODE; } public void update() { diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DisassemblerActionDelegate.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DisassemblerActionDelegate.java index 4a546943..f6d26357 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DisassemblerActionDelegate.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DisassemblerActionDelegate.java @@ -13,6 +13,7 @@ import org.eclipse.ui.IEditorActionDelegate; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.actions.ActionDelegate; +import org.sf.feeling.decompiler.JavaDecompilerConstants; import org.sf.feeling.decompiler.JavaDecompilerPlugin; import org.sf.feeling.decompiler.editor.JavaDecompilerClassFileEditor; @@ -25,7 +26,7 @@ public void setActiveEditor(IAction action, IEditorPart targetEditor) { if (targetEditor instanceof JavaDecompilerClassFileEditor) { editor = (JavaDecompilerClassFileEditor) targetEditor; action.setChecked( - JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.DISASSEMBLER_MODE); + JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.DISASSEMBLER_MODE); } } @@ -36,6 +37,6 @@ public void run(IAction action) { @Override public void selectionChanged(IAction action, ISelection selection) { - action.setChecked(JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.DISASSEMBLER_MODE); + action.setChecked(JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.DISASSEMBLER_MODE); } } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DisassemblerMenuItemAction.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DisassemblerMenuItemAction.java index 385b656d..30ddb8a9 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DisassemblerMenuItemAction.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DisassemblerMenuItemAction.java @@ -15,6 +15,7 @@ import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowPulldownDelegate; import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2; +import org.sf.feeling.decompiler.JavaDecompilerConstants; import org.sf.feeling.decompiler.JavaDecompilerPlugin; public class DisassemblerMenuItemAction implements IWorkbenchWindowPulldownDelegate, IWorkbenchWindowPulldownDelegate2 { @@ -48,6 +49,6 @@ public void run(IAction action) { @Override public void selectionChanged(IAction action, ISelection selection) { - action.setChecked(JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.DISASSEMBLER_MODE); + action.setChecked(JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.DISASSEMBLER_MODE); } } \ No newline at end of file diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/ExportSourceAction.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/ExportSourceAction.java index 0c135e2b..eb8b0818 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/ExportSourceAction.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/ExportSourceAction.java @@ -40,6 +40,7 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.FileDialog; +import org.sf.feeling.decompiler.JavaDecompilerConstants; import org.sf.feeling.decompiler.JavaDecompilerPlugin; import org.sf.feeling.decompiler.i18n.Messages; import org.sf.feeling.decompiler.util.DecompileUtil; @@ -66,9 +67,9 @@ public void run() { return; IPreferenceStore prefs = JavaDecompilerPlugin.getDefault().getPreferenceStore(); - final String decompilerType = prefs.getString(JavaDecompilerPlugin.DECOMPILER_TYPE); - final boolean reuseBuf = prefs.getBoolean(JavaDecompilerPlugin.REUSE_BUFFER); - final boolean always = prefs.getBoolean(JavaDecompilerPlugin.IGNORE_EXISTING); + final String decompilerType = prefs.getString(JavaDecompilerConstants.DECOMPILER_TYPE); + final boolean reuseBuf = prefs.getBoolean(JavaDecompilerConstants.REUSE_BUFFER); + final boolean always = prefs.getBoolean(JavaDecompilerConstants.IGNORE_EXISTING); Object firstElement = selection.get(0); if (selection.size() == 1 && firstElement instanceof IClassFile) { @@ -140,7 +141,7 @@ public void run(final IProgressMonitor monitor) throws InvocationTargetException exportPackageSources(monitor, decompilerType, reuseBuf, always, projectFile, children, exceptions); final File workingDir = new File(JavaDecompilerPlugin.getDefault().getPreferenceStore() - .getString(JavaDecompilerPlugin.TEMP_DIR));// $NON-NLS-1$ + .getString(JavaDecompilerConstants.TEMP_DIR));// $NON-NLS-1$ if (workingDir != null && workingDir.exists()) { try { @@ -157,7 +158,7 @@ public void run(final IProgressMonitor monitor) throws InvocationTargetException Messages.getString("ExportSourceAction.InfoDialog.Title"), //$NON-NLS-1$ Messages.getString("ExportSourceAction.InfoDialog.Message.Canceled")); //$NON-NLS-1$ } else if (!exceptions.isEmpty()) { - final MultiStatus status = new MultiStatus(JavaDecompilerPlugin.PLUGIN_ID, IStatus.WARNING, + final MultiStatus status = new MultiStatus(JavaDecompilerConstants.PLUGIN_ID, IStatus.WARNING, (exceptions.size() <= 1 ? Messages.getFormattedString("ExportSourceAction.WarningDialog.Message.Failed", //$NON-NLS-1$ new String[] { "" + exceptions.size() //$NON-NLS-1$ @@ -189,7 +190,7 @@ public void add(IStatus status) { Messages.getString("ExportSourceAction.InfoDialog.Message.Success")); //$NON-NLS-1$ } } catch (Exception e) { - IStatus status = new Status(IStatus.ERROR, JavaDecompilerPlugin.PLUGIN_ID, + IStatus status = new Status(IStatus.ERROR, JavaDecompilerConstants.PLUGIN_ID, Messages.getString("ExportSourceAction.Status.Error.DecompileAndExport"), //$NON-NLS-1$ e); ExceptionHandler.handle(status, Messages.getString("ExportSourceAction.ErrorDialog.Title"), //$NON-NLS-1$ @@ -204,7 +205,7 @@ private void exportPackageSources(IProgressMonitor monitor, final String decompi 1000000); final File workingDir = new File( - JavaDecompilerPlugin.getDefault().getPreferenceStore().getString(JavaDecompilerPlugin.TEMP_DIR) + JavaDecompilerPlugin.getDefault().getPreferenceStore().getString(JavaDecompilerConstants.TEMP_DIR) + "/export/" //$NON-NLS-1$ + System.currentTimeMillis()); @@ -216,7 +217,7 @@ private void exportPackageSources(IProgressMonitor monitor, final String decompi try { collectClasses(child, classes, monitor); } catch (JavaModelException e) { - IStatus status = new Status(IStatus.ERROR, JavaDecompilerPlugin.PLUGIN_ID, + IStatus status = new Status(IStatus.ERROR, JavaDecompilerConstants.PLUGIN_ID, Messages.getString("ExportSourceAction.Status.Error.CollectPackage"), //$NON-NLS-1$ e); exceptions.add(status); @@ -262,13 +263,13 @@ private void exportPackageSources(IProgressMonitor monitor, final String decompi + ".java"), //$NON-NLS-1$ result); } else { - IStatus status = new Status(IStatus.ERROR, JavaDecompilerPlugin.PLUGIN_ID, + IStatus status = new Status(IStatus.ERROR, JavaDecompilerConstants.PLUGIN_ID, Messages.getFormattedString("ExportSourceAction.Status.Error.DecompileFailed", //$NON-NLS-1$ new String[] { className })); throw new CoreException(status); } } catch (Exception e) { - IStatus status = new Status(IStatus.ERROR, JavaDecompilerPlugin.PLUGIN_ID, + IStatus status = new Status(IStatus.ERROR, JavaDecompilerConstants.PLUGIN_ID, Messages.getFormattedString("ExportSourceAction.Status.Error.DecompileFailed", //$NON-NLS-1$ new String[] { className })); exceptions.add(status); @@ -308,7 +309,7 @@ private void exportPackageSources(IProgressMonitor monitor, final String decompi monitor.worked(20000 - total); } } catch (Exception e) { - final IStatus status = new Status(IStatus.ERROR, JavaDecompilerPlugin.PLUGIN_ID, + final IStatus status = new Status(IStatus.ERROR, JavaDecompilerConstants.PLUGIN_ID, Messages.getString("ExportSourceAction.Status.Error.ExportFailed"), //$NON-NLS-1$ e); exceptions.add(status); @@ -370,7 +371,7 @@ private void exportClass(String decompilerType, boolean reuseBuf, boolean always if (result != null) FileUtil.writeToFile(new File(projectFile), result); else { - IStatus status = new Status(IStatus.ERROR, JavaDecompilerPlugin.PLUGIN_ID, + IStatus status = new Status(IStatus.ERROR, JavaDecompilerConstants.PLUGIN_ID, Messages.getFormattedString("ExportSourceAction.Status.Error.DecompileFailed", //$NON-NLS-1$ new String[] { className })); throw new CoreException(status); diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/OpenClassWithContributionFactory.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/OpenClassWithContributionFactory.java index 89fbbd3d..8534a610 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/OpenClassWithContributionFactory.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/OpenClassWithContributionFactory.java @@ -44,6 +44,7 @@ import org.eclipse.ui.menus.ExtensionContributionFactory; import org.eclipse.ui.menus.IContributionRoot; import org.eclipse.ui.services.IServiceLocator; +import org.sf.feeling.decompiler.JavaDecompilerConstants; import org.sf.feeling.decompiler.JavaDecompilerPlugin; import org.sf.feeling.decompiler.editor.DecompilerType; import org.sf.feeling.decompiler.editor.IDecompilerDescriptor; @@ -115,7 +116,7 @@ public void run() { } } catch (PartInitException e) { JavaDecompilerPlugin.getDefault().getLog() - .log(new Status(IStatus.ERROR, JavaDecompilerPlugin.PLUGIN_ID, 0, e.getMessage(), e)); + .log(new Status(IStatus.ERROR, JavaDecompilerConstants.PLUGIN_ID, 0, e.getMessage(), e)); } } } @@ -148,7 +149,7 @@ protected IContributionItem[] getContributionItems() { List list = new ArrayList<>(); if (classes.size() == 1) { - IEditorDescriptor editor = registry.findEditor(JavaDecompilerPlugin.EDITOR_ID); + IEditorDescriptor editor = registry.findEditor(JavaDecompilerConstants.EDITOR_ID); TreeSet decompilerTypes = new TreeSet<>(); Collections.addAll(decompilerTypes, DecompilerType.getDecompilerTypes()); diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/SourceCodeAction.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/SourceCodeAction.java index d6be3d61..cdcf8dbb 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/SourceCodeAction.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/SourceCodeAction.java @@ -11,6 +11,7 @@ import org.eclipse.jface.action.Action; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.texteditor.IUpdate; +import org.sf.feeling.decompiler.JavaDecompilerConstants; import org.sf.feeling.decompiler.JavaDecompilerPlugin; import org.sf.feeling.decompiler.editor.JavaDecompilerClassFileEditor; import org.sf.feeling.decompiler.i18n.Messages; @@ -26,7 +27,7 @@ public SourceCodeAction() { @Override public void run() { - JavaDecompilerPlugin.getDefault().setSourceMode(JavaDecompilerPlugin.SOURCE_MODE); + JavaDecompilerPlugin.getDefault().setSourceMode(JavaDecompilerConstants.SOURCE_MODE); setChecked(true); final JavaDecompilerClassFileEditor editor = UIUtil.getActiveEditor(); if (editor != null) { @@ -48,7 +49,7 @@ public boolean isEnabled() { } public boolean isChecked() { - return JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.SOURCE_MODE; + return JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.SOURCE_MODE; } @Override diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/SourceCodeActionDelegate.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/SourceCodeActionDelegate.java index 4593cfa7..9b68716a 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/SourceCodeActionDelegate.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/SourceCodeActionDelegate.java @@ -13,6 +13,7 @@ import org.eclipse.ui.IEditorActionDelegate; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.actions.ActionDelegate; +import org.sf.feeling.decompiler.JavaDecompilerConstants; import org.sf.feeling.decompiler.JavaDecompilerPlugin; import org.sf.feeling.decompiler.editor.JavaDecompilerClassFileEditor; @@ -24,7 +25,7 @@ public class SourceCodeActionDelegate extends ActionDelegate implements IEditorA public void setActiveEditor(IAction action, IEditorPart targetEditor) { if (targetEditor instanceof JavaDecompilerClassFileEditor) { editor = (JavaDecompilerClassFileEditor) targetEditor; - action.setChecked(JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.SOURCE_MODE); + action.setChecked(JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.SOURCE_MODE); } } @@ -35,6 +36,6 @@ public void run(IAction action) { @Override public void selectionChanged(IAction action, ISelection selection) { - action.setChecked(JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.SOURCE_MODE); + action.setChecked(JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.SOURCE_MODE); } } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/SourceCodeMenuItemAction.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/SourceCodeMenuItemAction.java index 2e1eed7e..923da797 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/SourceCodeMenuItemAction.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/SourceCodeMenuItemAction.java @@ -15,6 +15,7 @@ import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowPulldownDelegate; import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2; +import org.sf.feeling.decompiler.JavaDecompilerConstants; import org.sf.feeling.decompiler.JavaDecompilerPlugin; public class SourceCodeMenuItemAction implements IWorkbenchWindowPulldownDelegate, IWorkbenchWindowPulldownDelegate2 { @@ -48,6 +49,6 @@ public void run(IAction action) { @Override public void selectionChanged(IAction action, ISelection selection) { - action.setChecked(JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.SOURCE_MODE); + action.setChecked(JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.SOURCE_MODE); } } \ No newline at end of file diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/BaseDecompilerSourceMapper.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/BaseDecompilerSourceMapper.java index 21a19a3a..fb48fb89 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/BaseDecompilerSourceMapper.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/BaseDecompilerSourceMapper.java @@ -33,6 +33,7 @@ import org.eclipse.jdt.internal.core.SourceMapper; import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput; import org.eclipse.jface.preference.IPreferenceStore; +import org.sf.feeling.decompiler.JavaDecompilerConstants; import org.sf.feeling.decompiler.JavaDecompilerPlugin; import org.sf.feeling.decompiler.util.ClassUtil; import org.sf.feeling.decompiler.util.DecompileUtil; @@ -69,7 +70,7 @@ public BaseDecompilerSourceMapper(IPath sourcePath, String rootPath, Map exceptions = new LinkedList<>(); IPackageFragment pkgFrag = type.getPackageFragment(); @@ -169,13 +170,13 @@ public char[] findSource(IType type, IBinaryType info) { String code = usedDecompiler.getSource(); - boolean showReport = prefs.getBoolean(JavaDecompilerPlugin.PREF_DISPLAY_METADATA); + boolean showReport = prefs.getBoolean(JavaDecompilerConstants.PREF_DISPLAY_METADATA); if (!showReport) { code = usedDecompiler.removeComment(code); } - boolean showLineNumber = prefs.getBoolean(JavaDecompilerPlugin.PREF_DISPLAY_LINE_NUMBERS); - boolean align = prefs.getBoolean(JavaDecompilerPlugin.ALIGN); + boolean showLineNumber = prefs.getBoolean(JavaDecompilerConstants.PREF_DISPLAY_LINE_NUMBERS); + boolean align = prefs.getBoolean(JavaDecompilerConstants.ALIGN); if ((showLineNumber && align) || UIUtil.isDebugPerspective() || JavaDecompilerPlugin.getDefault().isDebugMode()) { if (showReport) { @@ -189,7 +190,7 @@ public char[] findSource(IType type, IBinaryType info) { StringBuffer source = new StringBuffer(); if (!(UIUtil.isDebugPerspective() || JavaDecompilerPlugin.getDefault().isDebugMode())) { - boolean useSorter = prefs.getBoolean(JavaDecompilerPlugin.USE_ECLIPSE_SORTER); + boolean useSorter = prefs.getBoolean(JavaDecompilerConstants.USE_ECLIPSE_SORTER); if (useSorter) { className = new String(info.getName()); fullName = new String(info.getFileName()); @@ -348,13 +349,13 @@ public String decompile(String decompilerType, File file) { String code = currentDecompiler.getSource(); - boolean showReport = prefs.getBoolean(JavaDecompilerPlugin.PREF_DISPLAY_METADATA); + boolean showReport = prefs.getBoolean(JavaDecompilerConstants.PREF_DISPLAY_METADATA); if (!showReport) { code = currentDecompiler.removeComment(code); } - boolean showLineNumber = prefs.getBoolean(JavaDecompilerPlugin.PREF_DISPLAY_LINE_NUMBERS); - boolean align = prefs.getBoolean(JavaDecompilerPlugin.ALIGN); + boolean showLineNumber = prefs.getBoolean(JavaDecompilerConstants.PREF_DISPLAY_LINE_NUMBERS); + boolean align = prefs.getBoolean(JavaDecompilerConstants.ALIGN); if ((showLineNumber && align) || UIUtil.isDebugPerspective() || JavaDecompilerPlugin.getDefault().isDebugMode()) { if (showReport) { diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/ByteCodeSourceViewer.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/ByteCodeSourceViewer.java index 75e206e1..8d4314b5 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/ByteCodeSourceViewer.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/ByteCodeSourceViewer.java @@ -68,6 +68,7 @@ import org.eclipse.ui.texteditor.rulers.IColumnSupport; import org.eclipse.ui.texteditor.rulers.RulerColumnDescriptor; import org.eclipse.ui.texteditor.rulers.RulerColumnRegistry; +import org.sf.feeling.decompiler.JavaDecompilerConstants; import org.sf.feeling.decompiler.JavaDecompilerPlugin; import org.sf.feeling.decompiler.actions.ByteCodeAction; import org.sf.feeling.decompiler.actions.DisassemblerAction; @@ -606,7 +607,7 @@ public void setSelectionElement(ISourceReference selectedElement) { public void setSelectionElement(ISourceReference selectedElement, boolean force) { final StyledText byteCodeText = getSourceViewer().getTextWidget(); - if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.BYTE_CODE_MODE + if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.BYTE_CODE_MODE && byteCodeText != null && !byteCodeText.isDisposed()) { if (!force) { if (UIUtil.requestFromDisassemblerSelection()) diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/DecompilerSourceMapper.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/DecompilerSourceMapper.java index 1f967de4..94c59558 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/DecompilerSourceMapper.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/DecompilerSourceMapper.java @@ -32,6 +32,7 @@ import org.eclipse.jface.text.Document; import org.eclipse.jface.text.IDocument; import org.eclipse.text.edits.TextEdit; +import org.sf.feeling.decompiler.JavaDecompilerConstants; import org.sf.feeling.decompiler.JavaDecompilerPlugin; import org.sf.feeling.decompiler.util.DecompilerOutputUtil; import org.sf.feeling.decompiler.util.EclipseCompatibilityHelper; @@ -96,7 +97,7 @@ protected String formatSource(String source) { String result = null; IPreferenceStore prefs = JavaDecompilerPlugin.getDefault().getPreferenceStore(); - boolean useFormatter = prefs.getBoolean(JavaDecompilerPlugin.USE_ECLIPSE_FORMATTER); + boolean useFormatter = prefs.getBoolean(JavaDecompilerConstants.USE_ECLIPSE_FORMATTER); if (source != null && useFormatter) { CompilerOptions option = new CompilerOptions(); diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/DisassemblerSourceViewer.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/DisassemblerSourceViewer.java index e3e923f4..061f3d6c 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/DisassemblerSourceViewer.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/DisassemblerSourceViewer.java @@ -69,6 +69,7 @@ import org.eclipse.ui.texteditor.rulers.IColumnSupport; import org.eclipse.ui.texteditor.rulers.RulerColumnDescriptor; import org.eclipse.ui.texteditor.rulers.RulerColumnRegistry; +import org.sf.feeling.decompiler.JavaDecompilerConstants; import org.sf.feeling.decompiler.JavaDecompilerPlugin; import org.sf.feeling.decompiler.actions.ByteCodeAction; import org.sf.feeling.decompiler.actions.DisassemblerAction; @@ -502,7 +503,7 @@ public void setSelectionElement(ISourceReference selectedElement, boolean force) final StyledText disassemblerText = getSourceViewer().getTextWidget(); OutlineElement disassemblerRootElement = (OutlineElement) ((DisassemblerDocumentProvider) getDocumentProvider()) .getClassFileOutlineElement(); - if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.DISASSEMBLER_MODE + if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.DISASSEMBLER_MODE && disassemblerText != null && !disassemblerText.isDisposed() && disassemblerRootElement != null) { if (!force) { if (UIUtil.requestFromDisassemblerSelection()) { @@ -722,7 +723,7 @@ protected IConfigurationElement getConfigurationElement() { @Override public void propertyChange(PropertyChangeEvent event) { - if (event.getProperty().startsWith(JavaDecompilerPlugin.bytecodeMnemonicPreferencesPrefix)) { + if (event.getProperty().startsWith(JavaDecompilerConstants.bytecodeMnemonicPreferencesPrefix)) { ((DisassemblerConfiguration) getSourceViewerConfiguration()).adaptToPreferenceChange(event); if (styleChanged == false) { styleChanged = true; @@ -734,8 +735,8 @@ public void run() { } }); } - } else if (event.getProperty().startsWith(JavaDecompilerPlugin.classFileAttributePreferencesPrefix) - || event.getProperty().equals(JavaDecompilerPlugin.BRANCH_TARGET_ADDRESS_RENDERING)) { + } else if (event.getProperty().startsWith(JavaDecompilerConstants.classFileAttributePreferencesPrefix) + || event.getProperty().equals(JavaDecompilerConstants.BRANCH_TARGET_ADDRESS_RENDERING)) { if (docChanged == false) { docChanged = true; Display.getDefault().timerExec(10, new Runnable() { diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/JavaDecompilerClassFileEditor.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/JavaDecompilerClassFileEditor.java index fef3fc9d..72a6bf9a 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/JavaDecompilerClassFileEditor.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/JavaDecompilerClassFileEditor.java @@ -80,6 +80,7 @@ import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds; import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds; import org.eclipse.ui.texteditor.IncrementalFindAction; +import org.sf.feeling.decompiler.JavaDecompilerConstants; import org.sf.feeling.decompiler.JavaDecompilerPlugin; import org.sf.feeling.decompiler.actions.DecompileActionGroup; import org.sf.feeling.decompiler.util.ClassUtil; @@ -116,10 +117,10 @@ public JavaDecompilerClassFileEditor() { @Override public ISelectionProvider getSelectionProvider() { if (UIUtil.requestFromCopyOperation()) { - if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.DISASSEMBLER_MODE + if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.DISASSEMBLER_MODE && fDisassemblerSourceViewer != null) { return fDisassemblerSourceViewer.getSelectionProvider(); - } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.BYTE_CODE_MODE + } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.BYTE_CODE_MODE && fByteCodeSourceViewer != null) { return fByteCodeSourceViewer.getSelectionProvider(); } @@ -129,14 +130,14 @@ public ISelectionProvider getSelectionProvider() { private boolean doOpenBuffer(IEditorInput input, boolean force) throws JavaModelException { IPreferenceStore prefs = JavaDecompilerPlugin.getDefault().getPreferenceStore(); - String decompilerType = prefs.getString(JavaDecompilerPlugin.DECOMPILER_TYPE); + String decompilerType = prefs.getString(JavaDecompilerConstants.DECOMPILER_TYPE); return doOpenBuffer(input, decompilerType, force); } private boolean doOpenBuffer(IEditorInput input, String type, boolean force) throws JavaModelException { IPreferenceStore prefs = JavaDecompilerPlugin.getDefault().getPreferenceStore(); - boolean reuseBuf = prefs.getBoolean(JavaDecompilerPlugin.REUSE_BUFFER); - boolean always = prefs.getBoolean(JavaDecompilerPlugin.IGNORE_EXISTING); + boolean reuseBuf = prefs.getBoolean(JavaDecompilerConstants.REUSE_BUFFER); + boolean always = prefs.getBoolean(JavaDecompilerConstants.IGNORE_EXISTING); return doOpenBuffer(input, type, force, reuseBuf, always); } @@ -322,7 +323,7 @@ protected void doSetInput(IEditorInput input) throws CoreException { FileStoreEditorInput storeInput = (FileStoreEditorInput) input; IPreferenceStore prefs = JavaDecompilerPlugin.getDefault().getPreferenceStore(); - String decompilerType = prefs.getString(JavaDecompilerPlugin.DECOMPILER_TYPE); + String decompilerType = prefs.getString(JavaDecompilerConstants.DECOMPILER_TYPE); String source = DecompileUtil.decompiler(storeInput, decompilerType); if (source != null) { @@ -371,7 +372,7 @@ public void run() { } }); - throw new CoreException(new Status(8, JavaDecompilerPlugin.PLUGIN_ID, 1, "", //$NON-NLS-1$ + throw new CoreException(new Status(8, JavaDecompilerConstants.PLUGIN_ID, 1, "", //$NON-NLS-1$ null)); } else { if (input instanceof InternalClassFileEditorInput) { @@ -405,7 +406,7 @@ public void run() { if (file.getSourceRange() == null && file.getBytes() != null) { if (ClassUtil.isClassFile(file.getBytes())) { File classFile = new File(JavaDecompilerPlugin.getDefault().getPreferenceStore() - .getString(JavaDecompilerPlugin.TEMP_DIR), file.getElementName()); + .getString(JavaDecompilerConstants.TEMP_DIR), file.getElementName()); try { try (FileOutputStream fos = new FileOutputStream(classFile)) { fos.write(file.getBytes()); @@ -644,11 +645,11 @@ public String[] collectContextMenuPreferencePages() { String[] inheritedPages = super.collectContextMenuPreferencePages(); int length = 1; String[] result = new String[inheritedPages.length + length]; - if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.SOURCE_MODE) { + if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.SOURCE_MODE) { result[0] = "org.sf.feeling.decompiler.Main"; //$NON-NLS-1$ - } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.DISASSEMBLER_MODE) { + } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.DISASSEMBLER_MODE) { result[0] = "org.sf.feeling.decompiler.Disassembler"; //$NON-NLS-1$ - } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.BYTE_CODE_MODE) { + } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.BYTE_CODE_MODE) { result[0] = "org.eclipse.ui.preferencePages.ColorsAndFonts"; //$NON-NLS-1$ } System.arraycopy(inheritedPages, 0, result, length, inheritedPages.length); @@ -667,12 +668,12 @@ protected void createActions() { @Override public void run() { - if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.SOURCE_MODE) { + if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.SOURCE_MODE) { ((SourceViewer) JavaDecompilerClassFileEditor.this.getSourceViewer()).getTextWidget().copy(); - } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.DISASSEMBLER_MODE + } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.DISASSEMBLER_MODE && fDisassemblerSourceViewer != null && fDisassemblerSourceViewer.getTextWidget() != null) { JavaDecompilerClassFileEditor.this.fDisassemblerSourceViewer.getTextWidget().copy(); - } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.BYTE_CODE_MODE + } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.BYTE_CODE_MODE && fByteCodeSourceViewer != null && fByteCodeSourceViewer.getTextWidget() != null) { JavaDecompilerClassFileEditor.this.fByteCodeSourceViewer.getTextWidget().copy(); } @@ -686,12 +687,12 @@ public void run() { @Override public void run() { - if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.SOURCE_MODE) { + if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.SOURCE_MODE) { ((SourceViewer) JavaDecompilerClassFileEditor.this.getSourceViewer()).getTextWidget().selectAll(); - } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.DISASSEMBLER_MODE + } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.DISASSEMBLER_MODE && fDisassemblerSourceViewer != null && fDisassemblerSourceViewer.getTextWidget() != null) { JavaDecompilerClassFileEditor.this.fDisassemblerSourceViewer.getTextWidget().selectAll(); - } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.BYTE_CODE_MODE + } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.BYTE_CODE_MODE && fByteCodeSourceViewer != null && fByteCodeSourceViewer.getTextWidget() != null) { JavaDecompilerClassFileEditor.this.fByteCodeSourceViewer.getTextWidget().selectAll(); } @@ -705,16 +706,16 @@ public void run() { this) { public void run() { - if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.SOURCE_MODE) { + if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.SOURCE_MODE) { ReflectionUtils.setFieldValue(this, "fTarget", //$NON-NLS-1$ (IFindReplaceTarget) JavaDecompilerClassFileEditor.this .getAdapter(IFindReplaceTarget.class)); - } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.DISASSEMBLER_MODE + } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.DISASSEMBLER_MODE && fDisassemblerSourceViewer != null) { ReflectionUtils.setFieldValue(this, "fTarget", //$NON-NLS-1$ (IFindReplaceTarget) fDisassemblerSourceViewer.getAdapter(IFindReplaceTarget.class)); - } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.BYTE_CODE_MODE + } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.BYTE_CODE_MODE && fByteCodeSourceViewer != null) { ReflectionUtils.setFieldValue(this, "fTarget", //$NON-NLS-1$ (IFindReplaceTarget) fByteCodeSourceViewer.getAdapter(IFindReplaceTarget.class)); @@ -732,16 +733,16 @@ public void run() { this, true) { public void run() { - if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.SOURCE_MODE) { + if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.SOURCE_MODE) { ReflectionUtils.setFieldValue(this, "fTarget", //$NON-NLS-1$ (IFindReplaceTarget) JavaDecompilerClassFileEditor.this .getAdapter(IFindReplaceTarget.class)); - } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.DISASSEMBLER_MODE + } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.DISASSEMBLER_MODE && fDisassemblerSourceViewer != null) { ReflectionUtils.setFieldValue(this, "fTarget", //$NON-NLS-1$ (IFindReplaceTarget) fDisassemblerSourceViewer.getAdapter(IFindReplaceTarget.class)); - } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.BYTE_CODE_MODE + } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.BYTE_CODE_MODE && fByteCodeSourceViewer != null) { ReflectionUtils.setFieldValue(this, "fTarget", //$NON-NLS-1$ (IFindReplaceTarget) fByteCodeSourceViewer.getAdapter(IFindReplaceTarget.class)); @@ -759,16 +760,16 @@ public void run() { this, false) { public void run() { - if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.SOURCE_MODE) { + if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.SOURCE_MODE) { ReflectionUtils.setFieldValue(this, "fTarget", //$NON-NLS-1$ (IFindReplaceTarget) JavaDecompilerClassFileEditor.this .getAdapter(IFindReplaceTarget.class)); - } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.DISASSEMBLER_MODE + } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.DISASSEMBLER_MODE && fDisassemblerSourceViewer != null) { ReflectionUtils.setFieldValue(this, "fTarget", //$NON-NLS-1$ (IFindReplaceTarget) fDisassemblerSourceViewer.getAdapter(IFindReplaceTarget.class)); - } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.BYTE_CODE_MODE + } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.BYTE_CODE_MODE && fByteCodeSourceViewer != null) { ReflectionUtils.setFieldValue(this, "fTarget", //$NON-NLS-1$ (IFindReplaceTarget) fByteCodeSourceViewer.getAdapter(IFindReplaceTarget.class)); @@ -789,15 +790,15 @@ public void run() { public void run() { try { Class clazz = Class.forName("org.eclipse.ui.texteditor.IncrementalFindTarget"); //$NON-NLS-1$ - if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.SOURCE_MODE) { + if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.SOURCE_MODE) { ReflectionUtils.setFieldValue(this, "fTarget", //$NON-NLS-1$ JavaDecompilerClassFileEditor.this.getAdapter(clazz)); } else if (JavaDecompilerPlugin.getDefault() - .getSourceMode() == JavaDecompilerPlugin.DISASSEMBLER_MODE + .getSourceMode() == JavaDecompilerConstants.DISASSEMBLER_MODE && fDisassemblerSourceViewer != null) { ReflectionUtils.setFieldValue(this, "fTarget", fDisassemblerSourceViewer.getAdapter(clazz)); //$NON-NLS-1$ - } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.BYTE_CODE_MODE + } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.BYTE_CODE_MODE && fByteCodeSourceViewer != null) { ReflectionUtils.setFieldValue(this, "fTarget", fByteCodeSourceViewer.getAdapter(clazz)); //$NON-NLS-1$ } @@ -820,15 +821,15 @@ public void run() { public void run() { try { Class clazz = Class.forName("org.eclipse.ui.texteditor.IncrementalFindTarget"); //$NON-NLS-1$ - if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.SOURCE_MODE) { + if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.SOURCE_MODE) { ReflectionUtils.setFieldValue(this, "fTarget", //$NON-NLS-1$ JavaDecompilerClassFileEditor.this.getAdapter(clazz)); } else if (JavaDecompilerPlugin.getDefault() - .getSourceMode() == JavaDecompilerPlugin.DISASSEMBLER_MODE + .getSourceMode() == JavaDecompilerConstants.DISASSEMBLER_MODE && fDisassemblerSourceViewer != null) { ReflectionUtils.setFieldValue(this, "fTarget", fDisassemblerSourceViewer.getAdapter(clazz)); //$NON-NLS-1$ - } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.BYTE_CODE_MODE + } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.BYTE_CODE_MODE && fByteCodeSourceViewer != null) { ReflectionUtils.setFieldValue(this, "fTarget", fByteCodeSourceViewer.getAdapter(clazz)); //$NON-NLS-1$ } @@ -848,9 +849,9 @@ public void run() { GotoLineAction gotoAction = new GotoLineAction(fgBundleForConstructedKeys, "Editor.GotoLine.", this) { //$NON-NLS-1$ protected ITextEditor getTextEditor() { - if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.DISASSEMBLER_MODE) { + if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.DISASSEMBLER_MODE) { return fDisassemblerSourceViewer; - } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.BYTE_CODE_MODE) { + } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.BYTE_CODE_MODE) { return fByteCodeSourceViewer; } return JavaDecompilerClassFileEditor.this; @@ -884,12 +885,12 @@ protected void showSource(IClassFileEditorInput classFileEditorInput) { StackLayout fStackLayout = (StackLayout) ReflectionUtils.getFieldValue(this, "fStackLayout"); //$NON-NLS-1$ Composite fParent = (Composite) ReflectionUtils.getFieldValue(this, "fParent"); //$NON-NLS-1$ Composite fViewerComposite = (Composite) ReflectionUtils.getFieldValue(this, "fViewerComposite"); //$NON-NLS-1$ - if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.SOURCE_MODE) { + if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.SOURCE_MODE) { if (fStackLayout != null && fViewerComposite != null && fParent != null) { fStackLayout.topControl = fViewerComposite; fParent.layout(); } - } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.DISASSEMBLER_MODE) { + } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.DISASSEMBLER_MODE) { if (fStackLayout != null && fParent != null) { if (fDisassemblerSourceViewer == null) { fDisassemblerSourceViewer = new DisassemblerSourceViewer(this); @@ -900,7 +901,7 @@ protected void showSource(IClassFileEditorInput classFileEditorInput) { fStackLayout.topControl = fDisassemblerSourceViewer.getControl(); fParent.layout(); } - } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.BYTE_CODE_MODE) { + } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.BYTE_CODE_MODE) { if (fStackLayout != null && fParent != null) { if (fByteCodeSourceViewer == null) { fByteCodeSourceViewer = new ByteCodeSourceViewer(this); @@ -919,7 +920,7 @@ protected void showSource(IClassFileEditorInput classFileEditorInput) { } protected String getCursorPosition() { - if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.DISASSEMBLER_MODE) { + if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.DISASSEMBLER_MODE) { if (fDisassemblerSourceViewer != null && fDisassemblerSourceViewer.getTextWidget() != null) { int line = fDisassemblerSourceViewer.getTextWidget() .getLineAtOffset(fDisassemblerSourceViewer.getTextWidget().getCaretOffset()); @@ -927,7 +928,7 @@ protected String getCursorPosition() { - fDisassemblerSourceViewer.getTextWidget().getOffsetAtLine(line); return (line + 1) + " : " + (column + 1); //$NON-NLS-1$ } - } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerPlugin.BYTE_CODE_MODE) { + } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.BYTE_CODE_MODE) { if (fByteCodeSourceViewer != null && fByteCodeSourceViewer.getTextWidget().getSelection() != null) { int line = fByteCodeSourceViewer.getTextWidget() .getLineAtOffset(fByteCodeSourceViewer.getTextWidget().getCaretOffset()); diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/RenderedBytecodeScanner.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/RenderedBytecodeScanner.java index 2453da0f..dba57bcb 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/RenderedBytecodeScanner.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/RenderedBytecodeScanner.java @@ -24,7 +24,7 @@ import org.eclipse.jface.text.rules.Token; import org.eclipse.jface.text.rules.WhitespaceRule; import org.eclipse.jface.text.rules.WordRule; -import org.sf.feeling.decompiler.JavaDecompilerPlugin; +import org.sf.feeling.decompiler.JavaDecompilerConstants; import com.drgarbage.bytecode.ByteCodeConstants; import com.drgarbage.javasrc.JavaKeywords; @@ -181,7 +181,7 @@ public IToken evaluate(ICharacterScanner scanner) { private static String[] tokenProperties = { IJavaColorConstants.JAVA_KEYWORD, IJavaColorConstants.JAVA_STRING, IJavaColorConstants.JAVA_DEFAULT, IJavaColorConstants.JAVA_OPERATOR, - JavaDecompilerPlugin.BYTECODE_MNEMONIC }; + JavaDecompilerConstants.BYTECODE_MNEMONIC }; /** * Creates a Java code scanner @@ -226,7 +226,7 @@ protected List createRules() { wordRule.addWord(RENDERED_BYTECODE_KEYWORDS[i], token); } - token = getToken(JavaDecompilerPlugin.BYTECODE_MNEMONIC); + token = getToken(JavaDecompilerConstants.BYTECODE_MNEMONIC); for (int i = 0; i < ByteCodeConstants.OPCODE_MNEMONICS.length; i++) { String word = ByteCodeConstants.OPCODE_MNEMONICS[i]; if (word != null) { diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/preferences/DisassemblerPreferencePage.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/preferences/DisassemblerPreferencePage.java index ac3b51fe..5554ffea 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/preferences/DisassemblerPreferencePage.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/preferences/DisassemblerPreferencePage.java @@ -21,6 +21,7 @@ import org.eclipse.swt.widgets.Group; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; +import org.sf.feeling.decompiler.JavaDecompilerConstants; import org.sf.feeling.decompiler.JavaDecompilerPlugin; import org.sf.feeling.decompiler.i18n.Messages; @@ -76,36 +77,36 @@ protected void createFieldEditors() { basicGroup.setLayoutData(gd); BooleanFieldEditor showConstantPool = new BooleanFieldEditor( - JavaDecompilerPlugin.CLASS_FILE_ATTR_SHOW_CONSTANT_POOL, + JavaDecompilerConstants.CLASS_FILE_ATTR_SHOW_CONSTANT_POOL, Messages.getString("DisassemblerPreferencePage.Label.ShowConstant"), //$NON-NLS-1$ basicGroup); BooleanFieldEditor showSourceLineNumber = new BooleanFieldEditor( - JavaDecompilerPlugin.CLASS_FILE_ATTR_SHOW_SOURCE_LINE_NUMBERS, + JavaDecompilerConstants.CLASS_FILE_ATTR_SHOW_SOURCE_LINE_NUMBERS, Messages.getString("DisassemblerPreferencePage.Label.ShowSourceLineNumber"), //$NON-NLS-1$ basicGroup); BooleanFieldEditor showLineNumberTable = new BooleanFieldEditor( - JavaDecompilerPlugin.CLASS_FILE_ATTR_SHOW_LINE_NUMBER_TABLE, + JavaDecompilerConstants.CLASS_FILE_ATTR_SHOW_LINE_NUMBER_TABLE, Messages.getString("DisassemblerPreferencePage.Label.ShowLineNumberTable"), //$NON-NLS-1$ basicGroup); BooleanFieldEditor showVariableTable = new BooleanFieldEditor( - JavaDecompilerPlugin.CLASS_FILE_ATTR_SHOW_VARIABLE_TABLE, + JavaDecompilerConstants.CLASS_FILE_ATTR_SHOW_VARIABLE_TABLE, Messages.getString("DisassemblerPreferencePage.Label.ShowVariableTable"), //$NON-NLS-1$ basicGroup); BooleanFieldEditor showExceptionTable = new BooleanFieldEditor( - JavaDecompilerPlugin.CLASS_FILE_ATTR_SHOW_EXCEPTION_TABLE, + JavaDecompilerConstants.CLASS_FILE_ATTR_SHOW_EXCEPTION_TABLE, Messages.getString("DisassemblerPreferencePage.Label.ShowExceptionTable"), //$NON-NLS-1$ basicGroup); - BooleanFieldEditor showMaxs = new BooleanFieldEditor(JavaDecompilerPlugin.CLASS_FILE_ATTR_SHOW_MAXS, + BooleanFieldEditor showMaxs = new BooleanFieldEditor(JavaDecompilerConstants.CLASS_FILE_ATTR_SHOW_MAXS, Messages.getString("DisassemblerPreferencePage.Label.ShowMaxs"), //$NON-NLS-1$ basicGroup); BooleanFieldEditor showTryCatch = new BooleanFieldEditor( - JavaDecompilerPlugin.CLASS_FILE_ATTR_RENDER_TRYCATCH_BLOCKS, + JavaDecompilerConstants.CLASS_FILE_ATTR_RENDER_TRYCATCH_BLOCKS, Messages.getString("DisassemblerPreferencePage.Label.ShowTryCatch"), //$NON-NLS-1$ basicGroup); @@ -121,12 +122,12 @@ protected void createFieldEditors() { layout.marginWidth = layout.marginHeight = 5; basicGroup.layout(); - RadioGroupFieldEditor red = new RadioGroupFieldEditor(JavaDecompilerPlugin.BRANCH_TARGET_ADDRESS_RENDERING, + RadioGroupFieldEditor red = new RadioGroupFieldEditor(JavaDecompilerConstants.BRANCH_TARGET_ADDRESS_RENDERING, Messages.getString("DisassemblerPreferencePage.Label.BranchTargetAddressSettings"), //$NON-NLS-1$ 1, new String[][] { { Messages.getString("DisassemblerPreferencePage.Label.AbsoluteAddress"), //$NON-NLS-1$ - JavaDecompilerPlugin.BRANCH_TARGET_ADDRESS_RELATIVE }, + JavaDecompilerConstants.BRANCH_TARGET_ADDRESS_RELATIVE }, { Messages.getString("DisassemblerPreferencePage.Label.RelativeAddress"), //$NON-NLS-1$ - JavaDecompilerPlugin.BRANCH_TARGET_ADDRESS_ABSOLUTE } }, + JavaDecompilerConstants.BRANCH_TARGET_ADDRESS_ABSOLUTE } }, getFieldEditorParent(), true); addField(red); @@ -135,24 +136,24 @@ protected void createFieldEditors() { gd = new GridData(GridData.FILL_HORIZONTAL); styleGroup.setLayoutData(gd); - ColorFieldEditor opcodeColor = new ColorFieldEditor(JavaDecompilerPlugin.BYTECODE_MNEMONIC, + ColorFieldEditor opcodeColor = new ColorFieldEditor(JavaDecompilerConstants.BYTECODE_MNEMONIC, Messages.getString("DisassemblerPreferencePage.Label.StyleColor"), //$NON-NLS-1$ styleGroup); - BooleanFieldEditor opcodeFontBold = new BooleanFieldEditor(JavaDecompilerPlugin.BYTECODE_MNEMONIC_BOLD, + BooleanFieldEditor opcodeFontBold = new BooleanFieldEditor(JavaDecompilerConstants.BYTECODE_MNEMONIC_BOLD, Messages.getString("DisassemblerPreferencePage.Label.StyleBold"), //$NON-NLS-1$ styleGroup); - BooleanFieldEditor opcodeFontItalic = new BooleanFieldEditor(JavaDecompilerPlugin.BYTECODE_MNEMONIC_ITALIC, + BooleanFieldEditor opcodeFontItalic = new BooleanFieldEditor(JavaDecompilerConstants.BYTECODE_MNEMONIC_ITALIC, Messages.getString("DisassemblerPreferencePage.Label.StyleItalic"), //$NON-NLS-1$ styleGroup); BooleanFieldEditor opcodeFontStrikethrough = new BooleanFieldEditor( - JavaDecompilerPlugin.BYTECODE_MNEMONIC_STRIKETHROUGH, + JavaDecompilerConstants.BYTECODE_MNEMONIC_STRIKETHROUGH, Messages.getString("DisassemblerPreferencePage.Label.StyleStrikethrough"), //$NON-NLS-1$ styleGroup); - BooleanFieldEditor showFontUnderline = new BooleanFieldEditor(JavaDecompilerPlugin.BYTECODE_MNEMONIC_UNDERLINE, + BooleanFieldEditor showFontUnderline = new BooleanFieldEditor(JavaDecompilerConstants.BYTECODE_MNEMONIC_UNDERLINE, Messages.getString("DisassemblerPreferencePage.Label.StyleUnderline"), //$NON-NLS-1$ styleGroup); diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/preferences/JavaDecompilerPreferencePage.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/preferences/JavaDecompilerPreferencePage.java index 5c13dd77..c8603b41 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/preferences/JavaDecompilerPreferencePage.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/preferences/JavaDecompilerPreferencePage.java @@ -19,6 +19,7 @@ import org.eclipse.swt.widgets.Group; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; +import org.sf.feeling.decompiler.JavaDecompilerConstants; import org.sf.feeling.decompiler.JavaDecompilerPlugin; import org.sf.feeling.decompiler.editor.DecompilerType; import org.sf.feeling.decompiler.editor.IDecompilerDescriptor; @@ -79,7 +80,7 @@ public void createControl(Composite parent) { @Override protected void createFieldEditors() { - defaultDecompiler = new StringChoiceFieldEditor(JavaDecompilerPlugin.DECOMPILER_TYPE, + defaultDecompiler = new StringChoiceFieldEditor(JavaDecompilerConstants.DECOMPILER_TYPE, Messages.getString("JavaDecompilerPreferencePage.Label.DefaultClassDecompiler"), //$NON-NLS-1$ getFieldEditorParent()) { @@ -109,7 +110,7 @@ protected void doFillIntoGrid(Composite parent, int numColumns) { gd.horizontalSpan = defaultDecompiler.getNumberOfControls(); basicGroup.setLayoutData(gd); - BooleanFieldEditor reusebuf = new BooleanFieldEditor(JavaDecompilerPlugin.REUSE_BUFFER, + BooleanFieldEditor reusebuf = new BooleanFieldEditor(JavaDecompilerConstants.REUSE_BUFFER, Messages.getString("JavaDecompilerPreferencePage.Label.ReuseCodeBuffer"), //$NON-NLS-1$ basicGroup); addField(reusebuf); @@ -118,12 +119,12 @@ protected void doFillIntoGrid(Composite parent, int numColumns) { createAttachSourceFieldEditor(basicGroup); } - BooleanFieldEditor alwaysUse = new BooleanFieldEditor(JavaDecompilerPlugin.IGNORE_EXISTING, + BooleanFieldEditor alwaysUse = new BooleanFieldEditor(JavaDecompilerConstants.IGNORE_EXISTING, Messages.getString("JavaDecompilerPreferencePage.Label.IgnoreExistSource"), //$NON-NLS-1$ basicGroup); addField(alwaysUse); - showReport = new CheckFieldEditor(JavaDecompilerPlugin.PREF_DISPLAY_METADATA, + showReport = new CheckFieldEditor(JavaDecompilerConstants.PREF_DISPLAY_METADATA, Messages.getString("JavaDecompilerPreferencePage.Label.ShowDecompilerReport"), //$NON-NLS-1$ basicGroup); addField(showReport); @@ -138,12 +139,12 @@ protected void doFillIntoGrid(Composite parent, int numColumns) { gd.horizontalSpan = defaultDecompiler.getNumberOfControls(); formatGroup.setLayoutData(gd); - eclipseFormatter = new CheckFieldEditor(JavaDecompilerPlugin.USE_ECLIPSE_FORMATTER, + eclipseFormatter = new CheckFieldEditor(JavaDecompilerConstants.USE_ECLIPSE_FORMATTER, Messages.getString("JavaDecompilerPreferencePage.Label.UseEclipseFormat"), //$NON-NLS-1$ formatGroup); addField(eclipseFormatter); - eclipseSorter = new CheckFieldEditor(JavaDecompilerPlugin.USE_ECLIPSE_SORTER, + eclipseSorter = new CheckFieldEditor(JavaDecompilerConstants.USE_ECLIPSE_SORTER, Messages.getString("JavaDecompilerPreferencePage.Lable.UseEclipseSorter"), //$NON-NLS-1$ formatGroup); addField(eclipseSorter); @@ -158,12 +159,12 @@ protected void doFillIntoGrid(Composite parent, int numColumns) { gd.horizontalSpan = defaultDecompiler.getNumberOfControls(); debugGroup.setLayoutData(gd); - optionLncEditor = new CheckFieldEditor(JavaDecompilerPlugin.PREF_DISPLAY_LINE_NUMBERS, + optionLncEditor = new CheckFieldEditor(JavaDecompilerConstants.PREF_DISPLAY_LINE_NUMBERS, Messages.getString("JavaDecompilerPreferencePage.Label.OutputLineNumber"), //$NON-NLS-1$ debugGroup); addField(optionLncEditor); - alignEditor = new CheckFieldEditor(JavaDecompilerPlugin.ALIGN, + alignEditor = new CheckFieldEditor(JavaDecompilerConstants.ALIGN, Messages.getString("JavaDecompilerPreferencePage.Label.AlignCode"), //$NON-NLS-1$ debugGroup); addField(alignEditor); @@ -180,7 +181,7 @@ protected void doFillIntoGrid(Composite parent, int numColumns) { gd.horizontalSpan = defaultDecompiler.getNumberOfControls(); startupGroup.setLayoutData(gd); - CheckFieldEditor defaultViewerEditor = new CheckFieldEditor(JavaDecompilerPlugin.DEFAULT_EDITOR, + CheckFieldEditor defaultViewerEditor = new CheckFieldEditor(JavaDecompilerConstants.DEFAULT_EDITOR, Messages.getString("JavaDecompilerPreferencePage.Label.DefaultEditor"), //$NON-NLS-1$ startupGroup); addField(defaultViewerEditor); @@ -193,7 +194,7 @@ protected void doFillIntoGrid(Composite parent, int numColumns) { } private void createAttachSourceFieldEditor(Group group) { - CheckFieldEditor attachSource = new CheckFieldEditor(JavaDecompilerPlugin.ATTACH_SOURCE, + CheckFieldEditor attachSource = new CheckFieldEditor(JavaDecompilerConstants.ATTACH_SOURCE, Messages.getString("JavaDecompilerPreferencePage.Label.Attach.Source"), //$NON-NLS-1$ group); addField(attachSource); @@ -206,7 +207,7 @@ private void createEncodingFieldEditor(Composite composite) { gd.horizontalSpan = defaultDecompiler.getNumberOfControls(); encodingGroup.setLayoutData(gd); - encodingEditor = new EncodingFieldEditor(JavaDecompilerPlugin.EXPORT_ENCODING, // $NON-NLS-1$ + encodingEditor = new EncodingFieldEditor(JavaDecompilerConstants.EXPORT_ENCODING, // $NON-NLS-1$ "", //$NON-NLS-1$ null, encodingGroup); addField(encodingEditor); @@ -224,11 +225,11 @@ public void init(IWorkbench arg0) { @Override protected void initialize() { super.initialize(); - boolean enabled = getPreferenceStore().getBoolean(JavaDecompilerPlugin.PREF_DISPLAY_LINE_NUMBERS); + boolean enabled = getPreferenceStore().getBoolean(JavaDecompilerConstants.PREF_DISPLAY_LINE_NUMBERS); alignEditor.setEnabled(enabled, debugGroup); String defaultEncoding = JavaDecompilerPlugin.getDefault().getDefaultExportEncoding(); - String encoding = getPreferenceStore().getString(JavaDecompilerPlugin.EXPORT_ENCODING); + String encoding = getPreferenceStore().getString(JavaDecompilerConstants.EXPORT_ENCODING); encodingEditor.setPreferenceStore(getPreferenceStore()); encodingEditor.load(); diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/UIUtil.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/UIUtil.java index 32a9b776..b1412138 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/UIUtil.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/UIUtil.java @@ -45,6 +45,7 @@ import org.eclipse.ui.navigator.IExtensionStateModel; import org.eclipse.ui.navigator.INavigatorContentService; import org.eclipse.ui.views.contentoutline.ContentOutline; +import org.sf.feeling.decompiler.JavaDecompilerConstants; import org.sf.feeling.decompiler.JavaDecompilerPlugin; import org.sf.feeling.decompiler.editor.JavaDecompilerClassFileEditor; @@ -151,8 +152,8 @@ public void run() { public static boolean isDebug() { IPreferenceStore prefs = JavaDecompilerPlugin.getDefault().getPreferenceStore(); - boolean showLineNumber = prefs.getBoolean(JavaDecompilerPlugin.PREF_DISPLAY_LINE_NUMBERS); - boolean align = prefs.getBoolean(JavaDecompilerPlugin.ALIGN); + boolean showLineNumber = prefs.getBoolean(JavaDecompilerConstants.PREF_DISPLAY_LINE_NUMBERS); + boolean align = prefs.getBoolean(JavaDecompilerConstants.ALIGN); boolean debug = (showLineNumber && align) || UIUtil.isDebugPerspective() || JavaDecompilerPlugin.getDefault().isDebugMode(); return debug; diff --git a/update_site/category.xml b/update_site/category.xml index 31a5d9b6..4b2aa672 100644 --- a/update_site/category.xml +++ b/update_site/category.xml @@ -4,6 +4,9 @@ + + +