diff --git a/.gitignore b/.gitignore index 0bacf76..a19a1bc 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,9 @@ *.class *.jar +# JD +debug* + # Eclipse .settings/ bin/ diff --git a/.project b/.project new file mode 100644 index 0000000..044654e --- /dev/null +++ b/.project @@ -0,0 +1,9 @@ + + + jd-eclipse + + + + + + diff --git a/LICENSE b/LICENSE index 21dbbc6..230579e 100644 --- a/LICENSE +++ b/LICENSE @@ -2,7 +2,7 @@ Version 3, 29 June 2007 - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (c) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -635,7 +635,7 @@ the "copyright" line and a pointer to where the full notice is found. JD-Eclipse is a plug-in for the Eclipse platform. It allows you to display all the Java sources during your debugging process, even if you do not have them all. - Copyright (C) 2008-2015 Emmanuel Dupuy + Copyright (c) 2008, 2019 Emmanuel Dupuy This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -655,7 +655,7 @@ Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: - JD-Eclipse Copyright (C) 2008-2015 Emmanuel Dupuy + JD-Eclipse Copyright (c) 2008, 2019 Emmanuel Dupuy This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. diff --git a/README.md b/README.md index 300e21f..024bdc9 100644 --- a/README.md +++ b/README.md @@ -1,52 +1,53 @@ -#JD-Eclipse +# JD-Eclipse JD-Eclipse, a Java decompiler plug-in for the Eclipse platform. -![](http://jd.benow.ca/img/screenshot8.png) +![](https://raw.githubusercontent.com/java-decompiler/jd-eclipse/master/src/website/img/jd-eclipse.png) -- Java Decompiler projects home page: [http://jd.benow.ca](http://jd.benow.ca) -- Java Decompiler Wikipedia page: [http://en.wikipedia.org/wiki/Java_Decompiler](http://en.wikipedia.org/wiki/Java_Decompiler) +- Java Decompiler projects home page: [http://java-decompiler.github.io](http://java-decompiler.github.io) - JD-Eclipse source code: [https://github.com/java-decompiler/jd-eclipse](https://github.com/java-decompiler/jd-eclipse) -##Description +## Description JD-Eclipse is a plug-in for the Eclipse platform. It allows you to display all the Java sources during your debugging process, even if you do not have them all. -##How to build JD-Eclipse ? -###With Gradle: +## How to build JD-Eclipse ? ``` -> ./gradlew installSiteDist +> git clone https://github.com/java-decompiler/jd-eclipse.git +> cd jd-eclipse +> ./gradlew build ``` -generate _"build/install/jd-eclipse-site"_ -###With Eclipse: -- Download dependencies -``` -> ./gradlew downloadDependencies -``` -- Launch _Eclipse_, -- Import the 3 _"Existing Projects into Workspace"_ by selecting the parent project folder, -- Export _"Deployable features"_, -- Copy _"site.xml"_ to the destination directory. +generate _"build/distributions/jd-eclipse-x.y.z.zip"_ -##How to install JD-Eclipse ? -1. Build or download & unzip _"jd-eclipse-site-x.y.z.zip"_, +## How to install JD-Eclipse ? +1. Build or download _"jd-eclipse-x.y.z.zip"_, 2. Launch _Eclipse_, 3. Click on _"Help > Install New Software..."_, -4. Click on button _"Add..."_ to add an new repository, -5. Enter _"JD-Eclipse Update Site"_ and select the local site directory, -6. Check _"Java Decompiler Eclipse Plug-in"_, -7. Next, next, next... and restart. +4. Drag and drop _"jd-eclipse-x.y.z.zip"_ on dialog windows, +5. Check _"Java Decompiler Eclipse Plug-in"_, +6. Click on "Next" and "Finish" buttons. +7. A warning dialog windows appear because _"org.jd.ide.eclipse.plugin_x.y.z.jar"_ is not signed. Click on "Install anyway" button. + +![](https://raw.githubusercontent.com/java-decompiler/jd-eclipse/master/src/website/img/install_anyway.png) -##How to check the file associations ? +## How to check the file associations ? Click on _"Window > Preferences > General > Editors > File Associations"_ - _"*.class"_ : _Eclipse_ _"Class File Viewer"_ is selected by default. - _"*.class without source"_ : _"JD Class File Viewer"_ is selected by default. -##How to configure JD-Eclipse ? +## How to configure JD-Eclipse ? Click on _"Window > Preferences > Java > Decompiler"_ -##How to uninstall JD-Eclipse ? +## How to uninstall JD-Eclipse ? 1. Click on _"Help > About Eclipse > Installation Details"_, 2. Select _"JD-Eclipse Plug-in"_, 3. Click on _"Uninstall..."_. + +## License +Released under the [GNU GPL v3](LICENSE). + +## Donations +Did JD-GUI help you to solve a critical situation? Do you use JD-Eclipse daily? What about making a donation? + +[![paypal](https://raw.githubusercontent.com/java-decompiler/jd-eclipse/master/src/website/img/btn_donate_euro.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=C88ZMVZ78RF22) [![paypal](https://raw.githubusercontent.com/java-decompiler/jd-eclipse/master/src/website/img/btn_donate_usd.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CRMXT4Y4QLQGU) diff --git a/build.gradle b/build.gradle index 22c7c6d..6bf9df5 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'distribution' // Common configuration // allprojects { - version='1.0.0' + version='2.0.0' } subprojects.each { subproject -> @@ -10,17 +10,29 @@ subprojects.each { subproject -> } distributions { - site { + distZip { + // Create JAR files before final ZIP file + dependsOn subprojects.tasks['jar'] + // For each file, remove root directory + eachFile { file -> + String path = file.relativePath + file.setPath(path.substring(path.indexOf('/')+1, path.length())) + } + } + + main { contents { into('features') { - from { fileTree('jd.ide.eclipse.feature/build/libs') { include '*.jar' } } + from { + fileTree 'org.jd.ide.eclipse.feature/build/libs' + } } into('plugins') { - from { fileTree('jd.ide.eclipse.plugin/build/libs') { include '*.jar' } } + from { + fileTree 'org.jd.ide.eclipse.plugin/build/libs' + } } - from 'jd.ide.eclipse.site/site.xml', 'LICENSE', 'NOTICE', 'README.md' + from 'org.jd.ide.eclipse.site/site.xml', 'LICENSE', 'NOTICE', 'README.md' } } } - -installSiteDist.dependsOn subprojects.tasks['jar'] diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 2322723..b5166da 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 5b79a30..1715e2b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Jul 06 16:38:55 CEST 2015 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip +#Sat Mar 02 11:11:32 CET 2019 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip diff --git a/jd.ide.eclipse.feature/.project b/jd.ide.eclipse.feature/.project deleted file mode 100644 index 9ba520b..0000000 --- a/jd.ide.eclipse.feature/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - jd.ide.eclipse.feature - - - - - - org.eclipse.pde.FeatureBuilder - - - - - - org.eclipse.pde.FeatureNature - - diff --git a/jd.ide.eclipse.plugin/META-INF/MANIFEST.MF b/jd.ide.eclipse.plugin/META-INF/MANIFEST.MF deleted file mode 100644 index aaea229..0000000 --- a/jd.ide.eclipse.plugin/META-INF/MANIFEST.MF +++ /dev/null @@ -1,21 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: JD-Eclipse Plug-in -Bundle-SymbolicName: jd.ide.eclipse.plugin;singleton:=true -Bundle-Version: 1.0.0 -Bundle-RequiredExecutionEnvironment: J2SE-1.5 -Require-Bundle: org.eclipse.ui, - org.eclipse.ui.editors, - org.eclipse.jdt.ui, - org.eclipse.jdt.core, - org.eclipse.core.runtime, - org.eclipse.core.resources, - org.eclipse.ui.ide, - org.eclipse.jface.text -Bundle-Vendor: Java Decompiler -Bundle-Activator: jd.ide.eclipse.JavaDecompilerPlugin -Bundle-ActivationPolicy: lazy -Bundle-ClassPath: lib/jd-common-0.7.1.jar, - lib/jd-common-ide-0.7.1.jar, - lib/jd-core-0.7.1.jar, - . diff --git a/jd.ide.eclipse.plugin/about.ini b/jd.ide.eclipse.plugin/about.ini deleted file mode 100644 index 1e3ca8b..0000000 --- a/jd.ide.eclipse.plugin/about.ini +++ /dev/null @@ -1,7 +0,0 @@ -featureImage=icons/jd_32.png -aboutText=Java Decompiler\n\ -\n\ -Wikipedia http://en.wikipedia.org/wiki/Java_Decompiler\n\ -Google+ https://plus.google.com/107508651694381167848\n\ -\n\ -Copyright © 2008-2015 Emmanuel Dupuy diff --git a/jd.ide.eclipse.plugin/build.gradle b/jd.ide.eclipse.plugin/build.gradle deleted file mode 100644 index 25c2ea9..0000000 --- a/jd.ide.eclipse.plugin/build.gradle +++ /dev/null @@ -1,45 +0,0 @@ -apply plugin: 'java' - -repositories { - maven { - url 'https://raw.github.com/java-decompiler/mvn-repo/master' - } -} - -configurations { - provided - compile.extendsFrom provided -} - -dependencies { - compile 'jd:jd-common-ide:0.7.1' - compile 'jd:jd-common:0.7.1' - compile 'jd:jd-core:0.7.1' - provided 'jd:eclipse-jee-juno-SR2-minimal:1.0.0' -} - -compileJava { - sourceCompatibility = '1.5' - targetCompatibility = '1.5' - source 'src' -} - -jar { - archiveName baseName + '_' + version + '.' + extension - manifest { - from 'META-INF/MANIFEST.MF' - } - from fileTree('.') { - include 'icons/**' - include 'about.ini' - include 'plugin.xml' - } - into('lib') { - from project.configurations.runtime - project.configurations.provided - } -} - -task downloadDependencies(type: Copy) { - from project.configurations.runtime - into 'lib' -} diff --git a/jd.ide.eclipse.plugin/src/jd/ide/eclipse/editors/JDSourceMapper.java b/jd.ide.eclipse.plugin/src/jd/ide/eclipse/editors/JDSourceMapper.java deleted file mode 100644 index b855a90..0000000 --- a/jd.ide.eclipse.plugin/src/jd/ide/eclipse/editors/JDSourceMapper.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2008-2015 Emmanuel Dupuy - * This program is made available under the terms of the GPLv3 License. - */ - -package jd.ide.eclipse.editors; - -import java.io.File; -import java.util.Iterator; -import java.util.Map; - -import jd.commonide.IdeDecompiler; -import jd.commonide.preferences.IdePreferences; -import jd.ide.eclipse.JavaDecompilerPlugin; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Status; -import org.eclipse.jdt.internal.core.SourceMapper; -import org.eclipse.jface.preference.IPreferenceStore; - - -/** - * JDSourceMapper - * - * @project Java Decompiler Eclipse Plugin - * @version 0.1.4 - * @see org.eclipse.jdt.internal.core.SourceMapper - */ -@SuppressWarnings("restriction") -public class JDSourceMapper extends SourceMapper -{ - private final static String JAVA_CLASS_SUFFIX = ".class"; - private final static String JAVA_SOURCE_SUFFIX = ".java"; - private final static int JAVA_SOURCE_SUFFIX_LENGTH = 5; - - private File basePath; - - @SuppressWarnings("rawtypes") - public JDSourceMapper( - File basePath, IPath sourcePath, String sourceRootPath, Map options) - { - super(sourcePath, sourceRootPath, options); - this.basePath = basePath; - } - - @SuppressWarnings("rawtypes") - public char[] findSource(String javaSourcePath) - { - char[] source = null; - - // Search source file - if (this.rootPaths == null) - { - source = super.findSource(javaSourcePath); - } - else - { - Iterator iterator = this.rootPaths.iterator(); - while (iterator.hasNext() && (source == null)) - { - String sourcesRootPath = (String)iterator.next(); - source = super.findSource( - sourcesRootPath + IPath.SEPARATOR + javaSourcePath); - } - } - - if ((source == null) && javaSourcePath.endsWith(JAVA_SOURCE_SUFFIX)) - { - String classPath = javaSourcePath.substring( - 0, javaSourcePath.length()-JAVA_SOURCE_SUFFIX_LENGTH) + JAVA_CLASS_SUFFIX; - - // Decompile class file - try - { - String result = decompile(this.basePath.getAbsolutePath(), classPath); - if (result != null) - source = result.toCharArray(); - } - catch (Exception e) - { - JavaDecompilerPlugin.getDefault().getLog().log(new Status( - Status.ERROR, JavaDecompilerPlugin.PLUGIN_ID, - 0, e.getMessage(), e)); - } - } - - return source; - } - - /** - * @param basePath Path to the root of the classpath, either a - * path to a directory or a path to a jar file. - * @param internalClassName internal name of the class. - * @return Decompiled class text. - */ - protected String decompile(String basePath, String classPath) { - // Load preferences - IPreferenceStore store = JavaDecompilerPlugin.getDefault().getPreferenceStore(); - - boolean showDefaultConstructor = store.getBoolean(JavaDecompilerPlugin.PREF_SHOW_DEFAULT_CONSTRUCTOR); - boolean realignmentLineNumber = store.getBoolean(JavaDecompilerPlugin.PREF_REALIGN_LINE_NUMBERS); - boolean showPrefixThis = store.getBoolean(JavaDecompilerPlugin.PREF_OMIT_PREFIX_THIS); - boolean mergeEmptyLines = false; - boolean unicodeEscape = store.getBoolean(JavaDecompilerPlugin.PREF_ESCAPE_UNICODE_CHARACTERS); - boolean showLineNumbers = store.getBoolean(JavaDecompilerPlugin.PREF_SHOW_LINE_NUMBERS); - boolean showMetadata = store.getBoolean(JavaDecompilerPlugin.PREF_SHOW_METADATA); - - // Create preferences - IdePreferences preferences = new IdePreferences( - showDefaultConstructor, realignmentLineNumber, showPrefixThis, - mergeEmptyLines, unicodeEscape, showLineNumbers, showMetadata); - - // Decompile - return IdeDecompiler.decompile(preferences, basePath, classPath); - } - - /** - * @return version of JD-Core - * @since JD-Core 0.7.0 - */ - public static String getVersion() { return "0.7.1"; } -} diff --git a/jd.ide.eclipse.plugin/src/jd/ide/eclipse/startup/JDStartupClass.java b/jd.ide.eclipse.plugin/src/jd/ide/eclipse/startup/JDStartupClass.java deleted file mode 100644 index 7d90e57..0000000 --- a/jd.ide.eclipse.plugin/src/jd/ide/eclipse/startup/JDStartupClass.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2008-2015 Emmanuel Dupuy - * This program is made available under the terms of the GPLv3 License. - */ - -package jd.ide.eclipse.startup; - -import org.eclipse.ui.IStartup; - -/** - * JDStartupClass - * - * @project Java Decompiler Eclipse Plugin - * @version 0.1.4 - */ -public class JDStartupClass implements IStartup -{ - public void earlyStartup() {} -} diff --git a/jd.ide.eclipse.site/site.xml b/jd.ide.eclipse.site/site.xml deleted file mode 100644 index e9f2bcc..0000000 --- a/jd.ide.eclipse.site/site.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - Eclipse Update Site for Java Decompiler Plug-in - - - - - - diff --git a/org.jd.ide.eclipse.feature/.classpath b/org.jd.ide.eclipse.feature/.classpath new file mode 100644 index 0000000..b7e2871 --- /dev/null +++ b/org.jd.ide.eclipse.feature/.classpath @@ -0,0 +1,5 @@ + + + + + diff --git a/org.jd.ide.eclipse.feature/.project b/org.jd.ide.eclipse.feature/.project new file mode 100644 index 0000000..2194f53 --- /dev/null +++ b/org.jd.ide.eclipse.feature/.project @@ -0,0 +1,21 @@ + + + org.jd.ide.eclipse.feature + + + + org.eclipse.pde.FeatureNature + org.eclipse.jdt.core.javanature + + + + org.eclipse.pde.FeatureBuilder + + + + org.eclipse.jdt.core.javabuilder + + + + + diff --git a/jd.ide.eclipse.feature/build.gradle b/org.jd.ide.eclipse.feature/build.gradle similarity index 100% rename from jd.ide.eclipse.feature/build.gradle rename to org.jd.ide.eclipse.feature/build.gradle diff --git a/jd.ide.eclipse.feature/build.properties b/org.jd.ide.eclipse.feature/build.properties similarity index 100% rename from jd.ide.eclipse.feature/build.properties rename to org.jd.ide.eclipse.feature/build.properties diff --git a/jd.ide.eclipse.feature/feature.xml b/org.jd.ide.eclipse.feature/feature.xml similarity index 72% rename from jd.ide.eclipse.feature/feature.xml rename to org.jd.ide.eclipse.feature/feature.xml index 86ce025..5680b88 100644 --- a/jd.ide.eclipse.feature/feature.xml +++ b/org.jd.ide.eclipse.feature/feature.xml @@ -1,20 +1,21 @@ + plugin="org.jd.ide.eclipse.plugin"> - JD-Eclipse is a plug-in for the Eclipse platform. It allows you to display all the Java sources during your debugging process, even if you do not have them all. + JD-Eclipse is a plug-in for the Eclipse platform. It allows you to display all the Java sources during your debugging process, even if you do not have them all. - Copyright (C) 2008-2015 Emmanuel Dupuy + Copyright (c) 2008, 2019 Emmanuel Dupuy - . + + . GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 @@ -32,12 +33,12 @@ free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. +the "copyright" line and a pointer to where the full notice is found. JD-Eclipse is a plug-in for the Eclipse platform. It allows you to display all the Java sources during your debugging process, even if you do not have them all. - Copyright (C) 2008-2015 Emmanuel Dupuy + Copyright (c) 2008, 2019 Emmanuel Dupuy This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -57,17 +58,17 @@ Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: - JD-Eclipse Copyright (C) 2008-2015 Emmanuel Dupuy - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + JD-Eclipse Copyright (c) 2008, 2019 Emmanuel Dupuy + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. + under certain conditions; type `show c' for details. -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. +if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <http://www.gnu.org/licenses/>. @@ -79,15 +80,11 @@ Public License instead of this License. But first, please read <http://www.gnu.org/philosophy/why-not-lgpl.html>. - - - - diff --git a/jd.ide.eclipse.plugin/.classpath b/org.jd.ide.eclipse.plugin/.classpath similarity index 58% rename from jd.ide.eclipse.plugin/.classpath rename to org.jd.ide.eclipse.plugin/.classpath index b0752f0..a6d508d 100644 --- a/jd.ide.eclipse.plugin/.classpath +++ b/org.jd.ide.eclipse.plugin/.classpath @@ -1,10 +1,8 @@ - - - - - - - - - - + + + + + + + + diff --git a/jd.ide.eclipse.plugin/.project b/org.jd.ide.eclipse.plugin/.project similarity index 73% rename from jd.ide.eclipse.plugin/.project rename to org.jd.ide.eclipse.plugin/.project index 1a5dd7c..e5dfac0 100644 --- a/jd.ide.eclipse.plugin/.project +++ b/org.jd.ide.eclipse.plugin/.project @@ -1,28 +1,25 @@ - - - jd.ide.eclipse.plugin - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - + + + org.jd.ide.eclipse.plugin + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + + + org.eclipse.jdt.core.javabuilder + + + + org.eclipse.pde.ManifestBuilder + + + + org.eclipse.pde.SchemaBuilder + + + + + diff --git a/org.jd.ide.eclipse.plugin/META-INF/MANIFEST.MF b/org.jd.ide.eclipse.plugin/META-INF/MANIFEST.MF new file mode 100644 index 0000000..9f14a20 --- /dev/null +++ b/org.jd.ide.eclipse.plugin/META-INF/MANIFEST.MF @@ -0,0 +1,25 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: JD-Eclipse Plug-in +Bundle-SymbolicName: org.jd.ide.eclipse.plugin;singleton:=true +Bundle-Version: 2.0.0 +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Require-Bundle: org.eclipse.ui, + org.eclipse.ui.editors, + org.eclipse.jdt.ui, + org.eclipse.jdt.core, + org.eclipse.core.runtime, + org.eclipse.core.resources, + org.eclipse.ui.ide, + org.eclipse.jface.text +Bundle-Vendor: Java Decompiler +Bundle-Activator: org.jd.ide.eclipse.JavaDecompilerPlugin +Bundle-ActivationPolicy: lazy +Bundle-ClassPath: /lib/jd-core-1.0.7.jar,. +Export-Package: org.jd.core.v1, + org.jd.ide.eclipse, + org.jd.ide.eclipse.editors, + org.jd.ide.eclipse.preferences, + org.jd.ide.eclipse.startup, + org.jd.ide.eclipse.util.loader, + org.jd.ide.eclipse.util.printer diff --git a/org.jd.ide.eclipse.plugin/about.ini b/org.jd.ide.eclipse.plugin/about.ini new file mode 100644 index 0000000..6892842 --- /dev/null +++ b/org.jd.ide.eclipse.plugin/about.ini @@ -0,0 +1,7 @@ +featureImage=icons/jd_32.png +aboutText=Java Decompiler\n\ +\n\ +Web site: http://java-decompiler.github.io\n\ +Issues: https://github.com/java-decompiler/jd-eclipse/issues\n\ +\n\ +Copyright (c) 2008, 2019 Emmanuel Dupuy diff --git a/org.jd.ide.eclipse.plugin/build.gradle b/org.jd.ide.eclipse.plugin/build.gradle new file mode 100644 index 0000000..5a48efc --- /dev/null +++ b/org.jd.ide.eclipse.plugin/build.gradle @@ -0,0 +1,81 @@ +apply plugin: 'java' + +repositories { + jcenter() +} + +configurations { + provided + compile.extendsFrom provided +} + +dependencies { + compile 'org.jd:jd-core:1.0.7' + + provided 'org.eclipse.core:org.eclipse.core.commands:3.6.0' + provided 'org.eclipse.core:org.eclipse.core.resources:3.7.100' + + provided('org.eclipse.jdt:org.eclipse.jdt.core:3.18.0') { + exclude group:'org.eclipse.platform' + } + provided('org.eclipse.jdt:org.eclipse.jdt.ui:3.18.0') { + exclude group:'org.eclipse.birt.runtime' + exclude group:'org.eclipse.emf' + exclude group:'org.eclipse.jdt' + exclude group:'org.eclipse.platform' + exclude group:'com.ibm.icu' + } + provided('org.eclipse.platform:org.eclipse.jface:3.15.0') { + exclude group:'org.eclipse.platform' + } + provided('org.eclipse.platform:org.eclipse.jface.text:3.15.0') { + exclude group:'org.eclipse.platform' + } + provided('org.eclipse.platform:org.eclipse.swt.win32.win32.x86_64:3.111.0') { + exclude group:'org.eclipse.platform' + } + provided('org.eclipse.platform:org.eclipse.ui.workbench:3.111.0') { + exclude group:'org.eclipse.emf' + exclude group:'org.eclipse.platform' + } + provided('org.eclipse.platform:org.eclipse.ui.workbench.texteditor:3.11.0') { + exclude group:'org.eclipse.platform' + } + provided('org.eclipse.platform:org.eclipse.ui.ide:3.15.0') { + exclude group:'org.eclipse.platform' + } + provided('org.eclipse.platform:org.eclipse.ui.editors:3.11.0') { + exclude group:'org.eclipse.platform' + } + provided('org.eclipse.platform:org.eclipse.ui.editors:3.11.0') { + exclude group:'org.eclipse.platform' + } +} + +compileJava { + sourceCompatibility = '1.8' + targetCompatibility = '1.8' + source 'src' +} + +jar { + archiveName baseName + '_' + version + '.' + extension + manifest { + from 'META-INF/MANIFEST.MF' + } + from fileTree('.') { + include 'icons/**' + include 'about.ini' + include 'plugin.xml' + } + into('lib') { + from project.configurations.runtime - project.configurations.provided + } +} + +task copyDependencies(type: Copy) { + from project.configurations.runtime - project.configurations.provided + into 'lib' +} + +build.finalizedBy copyDependencies diff --git a/jd.ide.eclipse.plugin/build.properties b/org.jd.ide.eclipse.plugin/build.properties similarity index 53% rename from jd.ide.eclipse.plugin/build.properties rename to org.jd.ide.eclipse.plugin/build.properties index f9889fd..290bd9f 100644 --- a/jd.ide.eclipse.plugin/build.properties +++ b/org.jd.ide.eclipse.plugin/build.properties @@ -2,9 +2,8 @@ bin.includes = META-INF/,\ plugin.xml,\ icons/,\ about.ini,\ - lib/jd-common-0.7.1.jar,\ - lib/jd-common-ide-0.7.1.jar,\ - lib/jd-core-0.7.1.jar,\ + lib/jd-core-1.0.7.jar,\ . source.. = src/ +jars.compile.order = . diff --git a/jd.ide.eclipse.plugin/icons/jd_16.png b/org.jd.ide.eclipse.plugin/icons/jd_16.png similarity index 100% rename from jd.ide.eclipse.plugin/icons/jd_16.png rename to org.jd.ide.eclipse.plugin/icons/jd_16.png diff --git a/jd.ide.eclipse.plugin/icons/jd_32.png b/org.jd.ide.eclipse.plugin/icons/jd_32.png similarity index 100% rename from jd.ide.eclipse.plugin/icons/jd_32.png rename to org.jd.ide.eclipse.plugin/icons/jd_32.png diff --git a/jd.ide.eclipse.plugin/plugin.xml b/org.jd.ide.eclipse.plugin/plugin.xml similarity index 65% rename from jd.ide.eclipse.plugin/plugin.xml rename to org.jd.ide.eclipse.plugin/plugin.xml index 52c4fdf..12b0d47 100644 --- a/jd.ide.eclipse.plugin/plugin.xml +++ b/org.jd.ide.eclipse.plugin/plugin.xml @@ -3,26 +3,26 @@ - + - + 0)) + if ((packageName != null) && (packageName.length() > 0)) { classPath = packageName.replace('.', '/') + '/' + classPath; + } // Location of the archive file containing source. IPath sourcePath = root.getSourceAttachmentPath(); - if (sourcePath == null) sourcePath = basePath; + if (sourcePath == null) { + sourcePath = basePath; + } // Location of the package fragment root within the zip // (empty specifies the default root). @@ -149,40 +141,30 @@ protected void setupSourceMapper(IClassFile classFile) // Options Map options = root.getJavaProject().getOptions(true); - root.setSourceMapper(new JDSourceMapper( - baseFile, sourcePath, sourceRootPath, options)); + root.setSourceMapper(new JDSourceMapper(baseFile, sourcePath, sourceRootPath, options)); } - } - catch (CoreException e) - { + } catch (CoreException e) { JavaDecompilerPlugin.getDefault().getLog().log(new Status( Status.ERROR, JavaDecompilerPlugin.PLUGIN_ID, 0, e.getMessage(), e)); } } - public boolean isEditable() { return false; } - - public boolean isDirty() { return false; } - - public boolean isEditorInputReadOnly() { return false; } + @Override public boolean isEditable() { return false; } + @Override public boolean isDirty() { return false; } + @Override public boolean isEditorInputReadOnly() { return false; } - public void dispose() - { - JavaDecompilerPlugin - .getDefault() - .getPreferenceStore() - .removePropertyChangeListener(this); + @Override + public void dispose() { + JavaDecompilerPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this); } /** * Refresh decompiled source code. * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) */ - public void propertyChange(PropertyChangeEvent event) - { - if (getSourceViewer() != null) - { + public void propertyChange(PropertyChangeEvent event) { + if (getSourceViewer() != null) { setInput(getEditorInput()); } } diff --git a/org.jd.ide.eclipse.plugin/src/org/jd/ide/eclipse/editors/JDSourceMapper.java b/org.jd.ide.eclipse.plugin/src/org/jd/ide/eclipse/editors/JDSourceMapper.java new file mode 100644 index 0000000..b3339ed --- /dev/null +++ b/org.jd.ide.eclipse.plugin/src/org/jd/ide/eclipse/editors/JDSourceMapper.java @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2008, 2019 Emmanuel Dupuy. + * This project is distributed under the GPLv3 license. + * This is a Copyleft license that gives the user the right to use, + * copy and modify the code freely for non-commercial purposes. + */ + +package org.jd.ide.eclipse.editors; + +import java.io.File; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import org.jd.core.v1.ClassFileToJavaSourceDecompiler; +import org.jd.core.v1.api.loader.Loader; +import org.jd.ide.eclipse.JavaDecompilerPlugin; +import org.jd.ide.eclipse.util.loader.DirectoryLoader; +import org.jd.ide.eclipse.util.loader.ZipLoader; +import org.jd.ide.eclipse.util.printer.LineNumberStringBuilderPrinter; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Status; +import org.eclipse.jdt.internal.core.SourceMapper; +import org.eclipse.jface.preference.IPreferenceStore; + + +/** + * JDSourceMapper + * + * @project Java Decompiler Eclipse Plugin + * @version 0.1.4 + * @see org.eclipse.jdt.internal.core.SourceMapper + */ +@SuppressWarnings("restriction") +public class JDSourceMapper extends SourceMapper { + private final static String JAVA_CLASS_SUFFIX = ".class"; + private final static String JAVA_SOURCE_SUFFIX = ".java"; + private final static int JAVA_SOURCE_SUFFIX_LENGTH = 5; + + private final static ClassFileToJavaSourceDecompiler DECOMPILER = new ClassFileToJavaSourceDecompiler(); + + private File basePath; + + private LineNumberStringBuilderPrinter printer = new LineNumberStringBuilderPrinter(); + + @SuppressWarnings("rawtypes") + public JDSourceMapper(File basePath, IPath sourcePath, String sourceRootPath, Map options) { + super(sourcePath, sourceRootPath, options); + this.basePath = basePath; + } + + @Override + @SuppressWarnings("rawtypes") + public char[] findSource(String javaSourcePath) { + char[] source = null; + + // Search source file + if (this.rootPaths == null) { + source = super.findSource(javaSourcePath); + } else { + Iterator iterator = this.rootPaths.iterator(); + + while (iterator.hasNext() && (source == null)) { + String sourcesRootPath = (String)iterator.next(); + source = super.findSource(sourcesRootPath + IPath.SEPARATOR + javaSourcePath); + } + } + + if ((source == null) && javaSourcePath.toLowerCase().endsWith(JAVA_SOURCE_SUFFIX)) { + String internalTypeName = javaSourcePath.substring(0, javaSourcePath.length()-JAVA_SOURCE_SUFFIX_LENGTH); + + // Decompile class file + try { + source = decompile(this.basePath.getAbsolutePath(), internalTypeName); + } catch (Exception e) { + JavaDecompilerPlugin.getDefault().getLog().log(new Status( + Status.ERROR, JavaDecompilerPlugin.PLUGIN_ID, + 0, e.getMessage(), e)); + } + } + + return source; + } + + /** + * @param basePath Path to the root of the classpath, either a + * path to a directory or a path to a jar file. + * @param internalClassName internal name of the class. + * @return Decompiled class text. + */ + protected char[] decompile(String basePath, String internalTypeName) throws Exception { + // Load preferences + IPreferenceStore store = JavaDecompilerPlugin.getDefault().getPreferenceStore(); + + boolean realignmentLineNumber = store.getBoolean(JavaDecompilerPlugin.PREF_REALIGN_LINE_NUMBERS); + boolean unicodeEscape = store.getBoolean(JavaDecompilerPlugin.PREF_ESCAPE_UNICODE_CHARACTERS); + boolean showLineNumbers = store.getBoolean(JavaDecompilerPlugin.PREF_SHOW_LINE_NUMBERS); + boolean showMetaData = store.getBoolean(JavaDecompilerPlugin.PREF_SHOW_METADATA); + + Map configuration = new HashMap<>(); + configuration.put("realignLineNumbers", realignmentLineNumber); + + // Initialize loader + Loader loader; + File base = new File(basePath); + + if (base.isFile()) { + if (basePath.toLowerCase().endsWith(".jar") || basePath.toLowerCase().endsWith(".zip")) { + loader = new ZipLoader(base); + } else { + JavaDecompilerPlugin.getDefault().getLog().log(new Status( + Status.ERROR, JavaDecompilerPlugin.PLUGIN_ID, + "Unexpected container type file: " + basePath)); + return null; + } + } else { + loader = new DirectoryLoader(base); + } + + // Initialize printer + printer.setRealignmentLineNumber(realignmentLineNumber); + printer.setUnicodeEscape(unicodeEscape); + printer.setShowLineNumbers(showLineNumbers); + + // Decompile class file + DECOMPILER.decompile(loader, printer, internalTypeName, configuration); + + StringBuilder stringBuffer = printer.getStringBuffer(); + + // Metadata + if (showMetaData) { + // Add location + stringBuffer.append("\n\n/* Location: "); + String classPath = internalTypeName + JAVA_CLASS_SUFFIX; + String location = base.isFile() ? base.getPath() + "!/" + classPath : new File(base, classPath).getPath(); + // Escape "\ u" sequence to prevent "Invalid unicode" errors + stringBuffer.append(location.replaceAll("(^|[^\\\\])\\\\u", "\\\\\\\\u")); + // Add Java compiler version + int majorVersion = printer.getMajorVersion(); + if (majorVersion >= 45) { + stringBuffer.append("\n * Java compiler version: "); + + if (majorVersion >= 49) { + stringBuffer.append(majorVersion - (49 - 5)); + } else { + stringBuffer.append(majorVersion - (45 - 1)); + } + + stringBuffer.append(" ("); + stringBuffer.append(majorVersion); + stringBuffer.append('.'); + stringBuffer.append(printer.getMinorVersion()); + stringBuffer.append(')'); + } + // Add JD-Core version + stringBuffer.append("\n * JD-Core Version: "); + stringBuffer.append(JavaDecompilerPlugin.VERSION_JD_CORE); + stringBuffer.append("\n */"); + } + + return stringBuffer.toString().toCharArray(); + } +} diff --git a/jd.ide.eclipse.plugin/src/jd/ide/eclipse/preferences/PreferenceInitializer.java b/org.jd.ide.eclipse.plugin/src/org/jd/ide/eclipse/preferences/PreferenceInitializer.java similarity index 67% rename from jd.ide.eclipse.plugin/src/jd/ide/eclipse/preferences/PreferenceInitializer.java rename to org.jd.ide.eclipse.plugin/src/org/jd/ide/eclipse/preferences/PreferenceInitializer.java index 20619af..2806c75 100644 --- a/jd.ide.eclipse.plugin/src/jd/ide/eclipse/preferences/PreferenceInitializer.java +++ b/org.jd.ide.eclipse.plugin/src/org/jd/ide/eclipse/preferences/PreferenceInitializer.java @@ -1,11 +1,13 @@ /* - * Copyright (c) 2008-2015 Emmanuel Dupuy - * This program is made available under the terms of the GPLv3 License. + * Copyright (c) 2008, 2019 Emmanuel Dupuy. + * This project is distributed under the GPLv3 license. + * This is a Copyleft license that gives the user the right to use, + * copy and modify the code freely for non-commercial purposes. */ -package jd.ide.eclipse.preferences; +package org.jd.ide.eclipse.preferences; -import jd.ide.eclipse.JavaDecompilerPlugin; +import org.jd.ide.eclipse.JavaDecompilerPlugin; import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; import org.eclipse.jface.preference.IPreferenceStore; @@ -16,19 +18,15 @@ * @project Java Decompiler Eclipse Plugin * @version 0.1.3 */ -public class PreferenceInitializer extends AbstractPreferenceInitializer -{ +public class PreferenceInitializer extends AbstractPreferenceInitializer { /** * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() */ - public void initializeDefaultPreferences() - { + public void initializeDefaultPreferences() { IPreferenceStore store = JavaDecompilerPlugin.getDefault().getPreferenceStore(); store.setDefault(JavaDecompilerPlugin.PREF_ESCAPE_UNICODE_CHARACTERS, false); - store.setDefault(JavaDecompilerPlugin.PREF_OMIT_PREFIX_THIS, false); store.setDefault(JavaDecompilerPlugin.PREF_REALIGN_LINE_NUMBERS, true); store.setDefault(JavaDecompilerPlugin.PREF_SHOW_LINE_NUMBERS, true); - store.setDefault(JavaDecompilerPlugin.PREF_SHOW_DEFAULT_CONSTRUCTOR, false); store.setDefault(JavaDecompilerPlugin.PREF_SHOW_METADATA, true); } } diff --git a/jd.ide.eclipse.plugin/src/jd/ide/eclipse/preferences/PreferencePage.java b/org.jd.ide.eclipse.plugin/src/org/jd/ide/eclipse/preferences/PreferencePage.java similarity index 68% rename from jd.ide.eclipse.plugin/src/jd/ide/eclipse/preferences/PreferencePage.java rename to org.jd.ide.eclipse.plugin/src/org/jd/ide/eclipse/preferences/PreferencePage.java index 8ce99d5..7a092a8 100644 --- a/jd.ide.eclipse.plugin/src/jd/ide/eclipse/preferences/PreferencePage.java +++ b/org.jd.ide.eclipse.plugin/src/org/jd/ide/eclipse/preferences/PreferencePage.java @@ -1,11 +1,13 @@ /* - * Copyright (c) 2008-2015 Emmanuel Dupuy - * This program is made available under the terms of the GPLv3 License. + * Copyright (c) 2008, 2019 Emmanuel Dupuy. + * This project is distributed under the GPLv3 license. + * This is a Copyleft license that gives the user the right to use, + * copy and modify the code freely for non-commercial purposes. */ -package jd.ide.eclipse.preferences; +package org.jd.ide.eclipse.preferences; -import jd.ide.eclipse.JavaDecompilerPlugin; +import org.jd.ide.eclipse.JavaDecompilerPlugin; import org.eclipse.jface.preference.BooleanFieldEditor; import org.eclipse.jface.preference.FieldEditorPreferencePage; @@ -21,11 +23,8 @@ * @project Java Decompiler Eclipse Plugin * @version 0.1.3 */ -public class PreferencePage - extends FieldEditorPreferencePage implements IWorkbenchPreferencePage -{ - public PreferencePage() - { +public class PreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { + public PreferencePage() { super(SWT.NONE); setDescription("JD-Eclipse preference page"); } @@ -36,8 +35,7 @@ public PreferencePage() * of preferences. Each field editor knows how to save and * restore itself. */ - public void createFieldEditors() - { + public void createFieldEditors() { Composite fieldEditorParent = getFieldEditorParent(); new Label(fieldEditorParent, SWT.NONE); @@ -45,18 +43,12 @@ public void createFieldEditors() addField(new BooleanFieldEditor( JavaDecompilerPlugin.PREF_ESCAPE_UNICODE_CHARACTERS, "Escape unicode characters", fieldEditorParent)); - addField(new BooleanFieldEditor( - JavaDecompilerPlugin.PREF_OMIT_PREFIX_THIS, - "Omit the prefix 'This' if possible", fieldEditorParent)); addField(new BooleanFieldEditor( JavaDecompilerPlugin.PREF_REALIGN_LINE_NUMBERS, "Realign line numbers", fieldEditorParent)); addField(new BooleanFieldEditor( JavaDecompilerPlugin.PREF_SHOW_LINE_NUMBERS, "Show original line numbers", fieldEditorParent)); - addField(new BooleanFieldEditor( - JavaDecompilerPlugin.PREF_SHOW_DEFAULT_CONSTRUCTOR, - "Show default constructor", fieldEditorParent)); addField(new BooleanFieldEditor( JavaDecompilerPlugin.PREF_SHOW_METADATA, "Show metadata", fieldEditorParent)); @@ -65,8 +57,7 @@ public void createFieldEditors() /** * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) */ - public void init(IWorkbench workbench) - { + public void init(IWorkbench workbench) { setPreferenceStore(JavaDecompilerPlugin.getDefault().getPreferenceStore()); } } \ No newline at end of file diff --git a/org.jd.ide.eclipse.plugin/src/org/jd/ide/eclipse/startup/JDStartupClass.java b/org.jd.ide.eclipse.plugin/src/org/jd/ide/eclipse/startup/JDStartupClass.java new file mode 100644 index 0000000..28b18bf --- /dev/null +++ b/org.jd.ide.eclipse.plugin/src/org/jd/ide/eclipse/startup/JDStartupClass.java @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2008, 2019 Emmanuel Dupuy. + * This project is distributed under the GPLv3 license. + * This is a Copyleft license that gives the user the right to use, + * copy and modify the code freely for non-commercial purposes. + */ + +package org.jd.ide.eclipse.startup; + +import org.eclipse.ui.IStartup; + +/** + * JDStartupClass + * + * @project Java Decompiler Eclipse Plugin + * @version 0.1.4 + */ +public class JDStartupClass implements IStartup { + public void earlyStartup() {} +} diff --git a/org.jd.ide.eclipse.plugin/src/org/jd/ide/eclipse/util/loader/DirectoryLoader.java b/org.jd.ide.eclipse.plugin/src/org/jd/ide/eclipse/util/loader/DirectoryLoader.java new file mode 100644 index 0000000..9f184cd --- /dev/null +++ b/org.jd.ide.eclipse.plugin/src/org/jd/ide/eclipse/util/loader/DirectoryLoader.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2008, 2019 Emmanuel Dupuy. + * This project is distributed under the GPLv3 license. + * This is a Copyleft license that gives the user the right to use, + * copy and modify the code freely for non-commercial purposes. + */ + +package org.jd.ide.eclipse.util.loader; + +import org.jd.core.v1.api.loader.Loader; +import org.jd.core.v1.api.loader.LoaderException; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; + +public class DirectoryLoader implements Loader { + protected File root; + + public DirectoryLoader(File root) throws LoaderException { + this.root = root; + } + + @Override + public byte[] load(String internalName) throws LoaderException { + File file = new File(root, internalName + ".class"); + + try (FileInputStream in=new FileInputStream(file); ByteArrayOutputStream out=new ByteArrayOutputStream()) { + byte[] buffer = new byte[1024]; + int read = in.read(buffer); + + while (read > 0) { + out.write(buffer, 0, read); + read = in.read(buffer); + } + + return out.toByteArray(); + } catch (IOException e) { + throw new LoaderException(e); + } + } + + @Override + public boolean canLoad(String internalName) { + return new File(root, internalName + ".class").exists(); + } +} diff --git a/org.jd.ide.eclipse.plugin/src/org/jd/ide/eclipse/util/loader/ZipLoader.java b/org.jd.ide.eclipse.plugin/src/org/jd/ide/eclipse/util/loader/ZipLoader.java new file mode 100644 index 0000000..dab834d --- /dev/null +++ b/org.jd.ide.eclipse.plugin/src/org/jd/ide/eclipse/util/loader/ZipLoader.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2008, 2019 Emmanuel Dupuy. + * This project is distributed under the GPLv3 license. + * This is a Copyleft license that gives the user the right to use, + * copy and modify the code freely for non-commercial purposes. + */ + +package org.jd.ide.eclipse.util.loader; + +import org.jd.core.v1.api.loader.Loader; +import org.jd.core.v1.api.loader.LoaderException; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.HashMap; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; + +public class ZipLoader implements Loader { + protected HashMap map = new HashMap<>(); + + public ZipLoader(File zip) throws LoaderException { + byte[] buffer = new byte[1024 * 2]; + + try (ZipInputStream zis = new ZipInputStream(new FileInputStream(zip))) { + ZipEntry ze = zis.getNextEntry(); + + while (ze != null) { + if (ze.isDirectory() == false) { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + int read = zis.read(buffer); + + while (read > 0) { + out.write(buffer, 0, read); + read = zis.read(buffer); + } + + map.put(ze.getName(), out.toByteArray()); + } + + ze = zis.getNextEntry(); + } + + zis.closeEntry(); + } catch (IOException e) { + throw new LoaderException(e); + } + } + + @Override + public byte[] load(String internalName) throws LoaderException { + return map.get(internalName + ".class"); + } + + @Override + public boolean canLoad(String internalName) { + return map.containsKey(internalName + ".class"); + } +} diff --git a/org.jd.ide.eclipse.plugin/src/org/jd/ide/eclipse/util/printer/LineNumberStringBuilderPrinter.java b/org.jd.ide.eclipse.plugin/src/org/jd/ide/eclipse/util/printer/LineNumberStringBuilderPrinter.java new file mode 100644 index 0000000..1930949 --- /dev/null +++ b/org.jd.ide.eclipse.plugin/src/org/jd/ide/eclipse/util/printer/LineNumberStringBuilderPrinter.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2008, 2019 Emmanuel Dupuy. + * This project is distributed under the GPLv3 license. + * This is a Copyleft license that gives the user the right to use, + * copy and modify the code freely for non-commercial purposes. + */ + +package org.jd.ide.eclipse.util.printer; + +public class LineNumberStringBuilderPrinter extends StringBuilderPrinter { + protected boolean showLineNumbers = false; + + protected int maxLineNumber = 0; + protected int digitCount = 0; + + protected String lineNumberBeginPrefix; + protected String lineNumberEndPrefix; + protected String unknownLineNumberPrefix; + + public void setShowLineNumbers(boolean showLineNumbers) { this.showLineNumbers = showLineNumbers; } + + protected int printDigit(int dcv, int lineNumber, int divisor, int left) { + if (digitCount >= dcv) { + if (lineNumber < divisor) { + stringBuffer.append(' '); + } else { + int e = (lineNumber-left) / divisor; + stringBuffer.append((char)('0' + e)); + left += e*divisor; + } + } + + return left; + } + + // --- Printer --- // + @Override + public void start(int maxLineNumber, int majorVersion, int minorVersion) { + super.start(maxLineNumber, majorVersion, minorVersion); + + if (showLineNumbers) { + this.maxLineNumber = maxLineNumber; + + if (maxLineNumber > 0) { + digitCount = 1; + unknownLineNumberPrefix = " "; + int maximum = 9; + + while (maximum < maxLineNumber) { + digitCount++; + unknownLineNumberPrefix += ' '; + maximum = maximum*10 + 9; + } + + lineNumberBeginPrefix = "/* "; + lineNumberEndPrefix = " */ "; + } else { + unknownLineNumberPrefix = ""; + lineNumberBeginPrefix = ""; + lineNumberEndPrefix = ""; + } + } else { + this.maxLineNumber = 0; + unknownLineNumberPrefix = ""; + lineNumberBeginPrefix = ""; + lineNumberEndPrefix = ""; + } + } + + @Override public void startLine(int lineNumber) { + if (maxLineNumber > 0) { + stringBuffer.append(lineNumberBeginPrefix); + + if (lineNumber == UNKNOWN_LINE_NUMBER) { + stringBuffer.append(unknownLineNumberPrefix); + } else { + int left = 0; + + left = printDigit(5, lineNumber, 10000, left); + left = printDigit(4, lineNumber, 1000, left); + left = printDigit(3, lineNumber, 100, left); + left = printDigit(2, lineNumber, 10, left); + stringBuffer.append((char)('0' + (lineNumber-left))); + } + + stringBuffer.append(lineNumberEndPrefix); + } + + for (int i=0; i 0) { + if (maxLineNumber > 0) { + stringBuffer.append(lineNumberBeginPrefix); + stringBuffer.append(unknownLineNumberPrefix); + stringBuffer.append(lineNumberEndPrefix); + } + + stringBuffer.append(NEWLINE); + } + } + } +} diff --git a/org.jd.ide.eclipse.plugin/src/org/jd/ide/eclipse/util/printer/StringBuilderPrinter.java b/org.jd.ide.eclipse.plugin/src/org/jd/ide/eclipse/util/printer/StringBuilderPrinter.java new file mode 100644 index 0000000..118720c --- /dev/null +++ b/org.jd.ide.eclipse.plugin/src/org/jd/ide/eclipse/util/printer/StringBuilderPrinter.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2008, 2019 Emmanuel Dupuy. + * This project is distributed under the GPLv3 license. + * This is a Copyleft license that gives the user the right to use, + * copy and modify the code freely for non-commercial purposes. + */ + +package org.jd.ide.eclipse.util.printer; + +import org.jd.core.v1.api.printer.Printer; + +public class StringBuilderPrinter implements Printer { + protected static final String TAB = " "; + protected static final String NEWLINE = "\n"; + + protected StringBuilder stringBuffer = new StringBuilder(10*1024); + + protected boolean unicodeEscape = true; + protected boolean realignmentLineNumber = false; + + protected int majorVersion = 0; + protected int minorVersion = 0; + protected int indentationCount; + + public void setUnicodeEscape(boolean unicodeEscape) { this.unicodeEscape = unicodeEscape; } + public void setRealignmentLineNumber(boolean realignmentLineNumber) { this.realignmentLineNumber = realignmentLineNumber; } + + public int getMajorVersion() { return majorVersion; } + public int getMinorVersion() { return minorVersion; } + public StringBuilder getStringBuffer() { return stringBuffer; } + + protected void escape(String s) { + if (unicodeEscape && (s != null)) { + int length = s.length(); + + for (int i=0; i> 3))); + stringBuffer.append((char) ('0' + (c & 0x7))); + } else if (c > 127) { + // Write octal format + stringBuffer.append("\\u"); + + int z = (c >> 12); + stringBuffer.append((char) ((z <= 9) ? ('0' + z) : (('A' - 10) + z))); + z = ((c >> 8) & 0xF); + stringBuffer.append((char) ((z <= 9) ? ('0' + z) : (('A' - 10) + z))); + z = ((c >> 4) & 0xF); + stringBuffer.append((char) ((z <= 9) ? ('0' + z) : (('A' - 10) + z))); + z = (c & 0xF); + stringBuffer.append((char) ((z <= 9) ? ('0' + z) : (('A' - 10) + z))); + } else { + stringBuffer.append(c); + } + } + } else { + stringBuffer.append(s); + } + } + + // --- Printer --- // + @Override + public void start(int maxLineNumber, int majorVersion, int minorVersion) { + this.stringBuffer.setLength(0); + this.majorVersion = majorVersion; + this.minorVersion = minorVersion; + this.indentationCount = 0; + } + + @Override public void end() {} + + @Override public void printText(String text) { escape(text); } + @Override public void printNumericConstant(String constant) { escape(constant); } + @Override public void printStringConstant(String constant, String ownerInternalName) { escape(constant); } + @Override public void printKeyword(String keyword) { stringBuffer.append(keyword); } + + @Override public void printDeclaration(int type, String internalTypeName, String name, String descriptor) { escape(name); } + @Override public void printReference(int type, String internalTypeName, String name, String descriptor, String ownerInternalName) { escape(name); } + + @Override public void indent() { indentationCount++; } + @Override public void unindent() { if (indentationCount > 0) indentationCount--; } + + @Override public void startLine(int lineNumber) { for (int i=0; i 0) stringBuffer.append(NEWLINE); } + + @Override public void startMarker(int type) {} + @Override public void endMarker(int type) {} +} diff --git a/jd.ide.eclipse.site/.project b/org.jd.ide.eclipse.site/.project similarity index 100% rename from jd.ide.eclipse.site/.project rename to org.jd.ide.eclipse.site/.project diff --git a/org.jd.ide.eclipse.site/site.xml b/org.jd.ide.eclipse.site/site.xml new file mode 100644 index 0000000..91c5031 --- /dev/null +++ b/org.jd.ide.eclipse.site/site.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/settings.gradle b/settings.gradle index ea0e698..65c50a0 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -include 'jd.ide.eclipse.plugin', 'jd.ide.eclipse.feature' +include 'org.jd.ide.eclipse.plugin', 'org.jd.ide.eclipse.feature' diff --git a/src/website/img/btn_donate_euro.gif b/src/website/img/btn_donate_euro.gif new file mode 100644 index 0000000..f317055 Binary files /dev/null and b/src/website/img/btn_donate_euro.gif differ diff --git a/src/website/img/btn_donate_usd.gif b/src/website/img/btn_donate_usd.gif new file mode 100644 index 0000000..3682dea Binary files /dev/null and b/src/website/img/btn_donate_usd.gif differ diff --git a/src/website/img/install_anyway.png b/src/website/img/install_anyway.png new file mode 100644 index 0000000..380eea2 Binary files /dev/null and b/src/website/img/install_anyway.png differ diff --git a/src/website/img/jd-eclipse.png b/src/website/img/jd-eclipse.png new file mode 100644 index 0000000..40f07c8 Binary files /dev/null and b/src/website/img/jd-eclipse.png differ