diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..4a8dca2e --- /dev/null +++ b/.gitattributes @@ -0,0 +1,6 @@ +# Handle line endings automatically for files detected as text +# and leave all files detected as binary untouched. +* text=auto + +# Never modify line endings of our bash scripts +*.sh -crlf \ No newline at end of file diff --git a/.gitignore b/.gitignore index 9425ec19..527b2a4b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,4 @@ -/**/bin/**/* -/./**/bin/**/* -./**/bin/**/* -**/bin/**/* -*/bin/**/* -bin/**/* -/**/bin/* -/bin/ +.project +**/bin/ +**/target +**/.tycho-consumer-pom.xml diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000..99f26c02 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 00000000..f897a7f1 --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/AUDIT.md b/AUDIT.md new file mode 100644 index 00000000..3b5ab482 --- /dev/null +++ b/AUDIT.md @@ -0,0 +1,124 @@ +# Audit results + +## Binary File Verification + +### Dr. Garbage Tools + +_Primary Source: https://sourceforge.net/projects/drgarbagetools/files/eclipse/4.4/stable/plugins/_ -> com.drgarbage.asm_5.0.3.201408050542.jar contains both files + +* `./org.sf.feeling.decompiler/lib/com.drgarbage.asm.util_5.0.3.jar` + * SHA-256: 06096adf6144ee613a9cc6d55325f6b1f04b03c52ca1841e9b3d7ae9dcadd2f2 + * Equal to the file of the same name in https://downloads.sourceforge.net/project/drgarbagetools/eclipse/4.4/stable/plugins/com.drgarbage.asm_5.0.3.201408050542.jar +* `./org.sf.feeling.decompiler/lib/com.drgarbage.asm_5.0.3.jar` + * SHA-256: d14546c965fea4a8fef3f7c267788d9748058957b84ae11a9fb22d5e386921d1 + * Equal to the file of the same name in https://downloads.sourceforge.net/project/drgarbagetools/eclipse/4.4/stable/plugins/com.drgarbage.asm_5.0.3.201408050542.jar + +### ASM - org.ow2.asm + +_Primary Source: https://mvnrepository.com/artifact/org.ow2.asm/asm_ + +* `./org.sf.feeling.decompiler/lib/asm-9.1.jar` + * SHA-256: cda4de455fab48ff0bcb7c48b4639447d4de859a7afc30a094a986f0936beba2 + * https://repo1.maven.org/maven2/org/ow2/asm/asm/9.1/asm-9.1.jar + +### Fernflower +* `./org.sf.feeling.decompiler.fernflower/lib/fernflower.jar` + * Not included in ECD repository, downloaded automatically via Maven + * SHA-256: 97b3579a221a3edf9651fca278257307441cb6dfdcfe1a1c6579f11002ff5d27 + * Version from https://www.jetbrains.com/intellij-repository/releases/com/jetbrains/intellij/java/java-decompiler-engine/232.10203.10/java-decompiler-engine-232.10203.10.jar + +### Vineflower +_Primary Source: https://github.com/Vineflower/vineflower/releases_ +_Build Source: https://github.com/Vineflower/vineflower_ +* `./org.sf.feeling.decompiler.vineflower/lib/vineflower.jar` + * Not included in ECD repository, downloaded automatically via Maven + * SHA-256: 2e563300af223b04772195709539fba69237e61eba14090ee3a44e2992c41cdb + * version from: https://repo1.maven.org/maven2/org/vineflower/vineflower/1.9.3/vineflower-1.9.3.jar + +### Minimal JSON + +### CFR +_Project homepage: https://www.benf.org/other/cfr/_ +_Primary Source: https://repo1.maven.org/maven2/org/benf/cfr/_ + +* `./org.sf.feeling.decompiler.cfr/lib/cfr-0.152.jar` + * Not included in ECD repository, downloaded automatically via Maven + * SHA-256: f686e8f3ded377d7bc87d216a90e9e9512df4156e75b06c655a16648ae8765b2 + * Equal to https://repo1.maven.org/maven2/org/benf/cfr/0.152/cfr-0.152.jar + * Signed with GPG key 0x01066A5BDD7A425BDE0BB3ED101B4F4D25952FC7 + +### Procyon +_Primary Source: https://repo1.maven.org/maven2/org/bitbucket/mstrobel/_ + +* `./org.sf.feeling.decompiler.procyon/lib/procyon-core.jar` + * Not included in ECD repository, downloaded automatically via Maven + * SHA-256: e52096fde7ce4c84db7a943298ae6cad4ea9e33824fe6ccb99c308a7ad7e594c + * Version from https://repo1.maven.org/maven2/org/bitbucket/mstrobel/procyon-core/0.6.0/procyon-core-0.6.0.jar + +* `./org.sf.feeling.decompiler.procyon/lib/procyon-compilertools.jar` + * Not included in ECD repository, downloaded automatically via Maven + * SHA-256: 5b5b40d4bae758a823210c5c1513f2027bd7fe2e9421cd2b004c5d91b0676956 + * Version from https://repo1.maven.org/maven2/org/bitbucket/mstrobel/procyon-compilertools/0.6.0/procyon-compilertools-0.6.0.jar + +### Netbeans CVSClient +_Primary Source: https://versioncontrol.netbeans.org/javacvs/library/_ +* `./org.sf.feeling.decompiler.source.attach/lib/cvsclient-20060125.jar` + +### Maven SCM +_Primary Source: https://maven.apache.org/scm/_ +* `./org.sf.feeling.decompiler.source.attach/lib/maven-scm-api-1.9.4.jar` +* `./org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-accurev-1.9.4.jar` +* `./org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-bazaar-1.9.4.jar` +* `./org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-clearcase-1.9.4.jar` +* `./org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-cvs-commons-1.9.4.jar` +* `./org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-cvsexe-1.9.4.jar` +* `./org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-cvsjava-1.9.4.jar` +* `./org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-git-commons-1.9.4.jar` +* `./org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-gitexe-1.9.4.jar` +* `./org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-hg-1.9.4.jar` +* `./org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-integrity-1.9.4.jar` +* `./org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-jazz-1.9.4.jar` +* `./org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-local-1.9.4.jar` +* `./org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-perforce-1.9.4.jar` +* `./org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-starteam-1.9.4.jar` +* `./org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-svn-commons-1.9.4.jar` +* `./org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-svnexe-1.9.4.jar` +* `./org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-synergy-1.9.4.jar` +* `./org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-tfs-1.9.4.jar` +* `./org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-vss-1.9.4.jar` + +### Nexus + +https://repo1.maven.org/maven2/org/sonatype/nexus/plugins/nexus-indexer-lucene-model/2.14.20-02/nexus-indexer-lucene-model-2.14.20-02.jar +* `./org.sf.feeling.decompiler.source.attach/lib/nexus-indexer-lucene-model-2.14.20-02.jar` + * SHA-256: 74465BC0D1BBECEF4173522CFBAA3D07E4F5EEC6CF16E2E25268182D1350CB7A + * https://repo1.maven.org/maven2/org/sonatype/nexus/plugins/nexus-indexer-lucene-model/2.14.20-02/nexus-indexer-lucene-model-2.14.20-02.jar +* `./org.sf.feeling.decompiler.source.attach/lib/nexus-restlet1x-model-2.9.2-01.jar` + +### Plexus Utils +Primary Source: _https://github.com/codehaus-plexus/plexus-utils_ +* `./org.sf.feeling.decompiler.source.attach/lib/plexus-utils-3.0.15.jar` + * SHA-256: D0BE76C5CE910134A7E07FD2AA48D9B677800AB0E95873F314B445C6F177C973 + +## JD-Core +_Primary Source: https://github.com/java-decompiler/jd-core/releases_ + +* `./org.sf.feeling.decompiler.jd/lib/jd-core-1.1.3.jar` + * SHA-256: 33F60FF75C77DC08905E767694A38F7B6AB792BD2E5831F41E2B56354BB806FB + +## JAXB +_Primary Source: https://repo1.maven.org/maven2/_ + +* `org.sf.feeling.decompiler.source.attach/lib/activation-1.1.1.jar` + * SHA-256: ae475120e9fcd99b4b00b38329bd61cdc5eb754eee03fe66c01f50e137724f99 + * https://repo1.maven.org/maven2/javax/activation/activation/1.1.1/activation-1.1.1.jar +* `org.sf.feeling.decompiler.source.attach/lib/jaxb-api-2.3.1.jar` + * SHA-256: 88b955a0df57880a26a74708bc34f74dcaf8ebf4e78843a28b50eae945732b06 + * https://repo1.maven.org/maven2/javax/xml/bind/jaxb-api/2.3.1/jaxb-api-2.3.1.jar +* `org.sf.feeling.decompiler.source.attach/lib/jaxb-impl-2.3.3.jar` + * SHA-256: e5178d0c7948247f75a13c689bf36f4d5d4910a121f712aa3b20ae94377069d8 + * https://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-impl/2.3.3/jaxb-impl-2.3.3.jar +* `org.sf.feeling.decompiler.source.attach/lib/jaxb-runtime-2.3.3.jar` + * SHA-256: 3fcbf9247b08303ecaef2b8b91b47e220b6eced843e02837a5379d011c2c623d + * https://repo1.maven.org/maven2/org/glassfish/jaxb/jaxb-runtime/2.3.3/jaxb-runtime-2.3.3.jar + diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..45980db8 --- /dev/null +++ b/LICENSE @@ -0,0 +1,212 @@ +Eclipse Public License - v 1.0 + +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC +LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM +CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + + a) in the case of the initial Contributor, the initial code and + documentation distributed under this Agreement, and + b) in the case of each subsequent Contributor: + + i) changes to the Program, and + + ii) additions to the Program; + + where such changes and/or additions to the Program originate from and are +distributed by that particular Contributor. A Contribution 'originates' from a +Contributor if it was added to the Program by such Contributor itself or anyone +acting on such Contributor's behalf. Contributions do not include additions to +the Program which: (i) are separate modules of software distributed in +conjunction with the Program under their own license agreement, and (ii) are +not derivative works of the Program. + +"Contributor" means any person or entity that distributes the Program. + +"Licensed Patents " mean patent claims licensable by a Contributor which are +necessarily infringed by the use or sale of its Contribution alone or when +combined with the Program. + +"Program" means the Contributions distributed in accordance with this Agreement. + +"Recipient" means anyone who receives the Program under this Agreement, +including all Contributors. + +2. GRANT OF RIGHTS + + a) Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide, royalty-free copyright license to +reproduce, prepare derivative works of, publicly display, publicly perform, +distribute and sublicense the Contribution of such Contributor, if any, and +such derivative works, in source code and object code form. + + b) Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide, royalty-free patent license under +Licensed Patents to make, use, sell, offer to sell, import and otherwise +transfer the Contribution of such Contributor, if any, in source code and +object code form. This patent license shall apply to the combination of the +Contribution and the Program if, at the time the Contribution is added by the +Contributor, such addition of the Contribution causes such combination to be +covered by the Licensed Patents. The patent license shall not apply to any +other combinations which include the Contribution. No hardware per se is +licensed hereunder. + + c) Recipient understands that although each Contributor grants the +licenses to its Contributions set forth herein, no assurances are provided by +any Contributor that the Program does not infringe the patent or other +intellectual property rights of any other entity. Each Contributor disclaims +any liability to Recipient for claims brought by any other entity based on +infringement of intellectual property rights or otherwise. As a condition to +exercising the rights and licenses granted hereunder, each Recipient hereby +assumes sole responsibility to secure any other intellectual property rights +needed, if any. For example, if a third party patent license is required to +allow Recipient to distribute the Program, it is Recipient's responsibility to +acquire that license before distributing the Program. + + d) Each Contributor represents that to its knowledge it has sufficient +copyright rights in its Contribution, if any, to grant the copyright license +set forth in this Agreement. + +3. REQUIREMENTS + +A Contributor may choose to distribute the Program in object code form under +its own license agreement, provided that: + + a) it complies with the terms and conditions of this Agreement; and + + b) its license agreement: + + i) effectively disclaims on behalf of all Contributors all warranties and +conditions, express and implied, including warranties or conditions of title +and non-infringement, and implied warranties or conditions of merchantability +and fitness for a particular purpose; + + ii) effectively excludes on behalf of all Contributors all liability for +damages, including direct, indirect, special, incidental and consequential +damages, such as lost profits; + + iii) states that any provisions which differ from this Agreement are +offered by that Contributor alone and not by any other party; and + + iv) states that source code for the Program is available from such +Contributor, and informs licensees how to obtain it in a reasonable manner on +or through a medium customarily used for software exchange. + +When the Program is made available in source code form: + + a) it must be made available under this Agreement; and + + b) a copy of this Agreement must be included with each copy of the +Program. + +Contributors may not remove or alter any copyright notices contained within the +Program. + +Each Contributor must identify itself as the originator of its Contribution, if +any, in a manner that reasonably allows subsequent Recipients to identify the +originator of the Contribution. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain responsibilities with +respect to end users, business partners and the like. While this license is +intended to facilitate the commercial use of the Program, the Contributor who +includes the Program in a commercial product offering should do so in a manner +which does not create potential liability for other Contributors. Therefore, if +a Contributor includes the Program in a commercial product offering, such +Contributor ("Commercial Contributor") hereby agrees to defend and indemnify +every other Contributor ("Indemnified Contributor") against any losses, damages +and costs (collectively "Losses") arising from claims, lawsuits and other legal +actions brought by a third party against the Indemnified Contributor to the +extent caused by the acts or omissions of such Commercial Contributor in +connection with its distribution of the Program in a commercial product +offering. The obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. In order +to qualify, an Indemnified Contributor must: a) promptly notify the Commercial +Contributor in writing of such claim, and b) allow the Commercial Contributor +to control, and cooperate with the Commercial Contributor in, the defense and +any related settlement negotiations. The Indemnified Contributor may +participate in any such claim at its own expense. + +For example, a Contributor might include the Program in a commercial product +offering, Product X. That Contributor is then a Commercial Contributor. If that +Commercial Contributor then makes performance claims, or offers warranties +related to Product X, those performance claims and warranties are such +Commercial Contributor's responsibility alone. Under this section, the +Commercial Contributor would have to defend claims against the other +Contributors related to those performance claims and warranties, and if a court +requires any other Contributor to pay any damages as a result, the Commercial +Contributor must pay those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR +IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, +NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each +Recipient is solely responsible for determining the appropriateness of using +and distributing the Program and assumes all risks associated with its exercise +of rights under this Agreement, including but not limited to the risks and +costs of program errors, compliance with applicable laws, damage to or loss of +data, programs or equipment, and unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY +CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST +PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY +WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS +GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under applicable +law, it shall not affect the validity or enforceability of the remainder of the +terms of this Agreement, and without further action by the parties hereto, such +provision shall be reformed to the minimum extent necessary to make such +provision valid and enforceable. + +If Recipient institutes patent litigation against any +entity (including a cross-claim or counterclaim in a lawsuit) alleging that the +Program itself (excluding combinations of the Program with other software or +hardware) infringes such Recipient's patent(s), then such Recipient's rights +granted under Section 2(b) shall terminate as of the date such litigation is +filed. + +All Recipient's rights under this Agreement shall terminate if it fails to +comply with any of the material terms or conditions of this Agreement and does +not cure such failure in a reasonable period of time after becoming aware of +such noncompliance. If all Recipient's rights under this Agreement terminate, +Recipient agrees to cease use and distribution of the Program as soon as +reasonably practicable. However, Recipient's obligations under this Agreement +and any licenses granted by Recipient relating to the Program shall continue +and survive. + +Everyone is permitted to copy and distribute copies of this Agreement, but in +order to avoid inconsistency the Agreement is copyrighted and may only be +modified in the following manner. The Agreement Steward reserves the right to +publish new versions (including revisions) of this Agreement from time to time. +No one other than the Agreement Steward has the right to modify this Agreement. +The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to +serve as the Agreement Steward to a suitable separate entity. Each new version +of the Agreement will be given a distinguishing version number. The Program +(including Contributions) may always be distributed subject to the version of +the Agreement under which it was received. In addition, after a new version of +the Agreement is published, Contributor may elect to distribute the Program +(including its Contributions) under the new version. Except as expressly stated +in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to +the intellectual property of any Contributor under this Agreement, whether +expressly, by implication, estoppel or otherwise. All rights in the Program not +expressly granted under this Agreement are reserved. + +This Agreement is governed by the laws of the State of New York and the +intellectual property laws of the United States of America. No party to this +Agreement will bring a legal action under this Agreement more than one year +after the cause of action arose. Each party waives its rights to a jury trial +in any resulting litigation. + diff --git a/README.md b/README.md index 4c588684..4a694886 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,162 @@ -# ecd -nothing +# Enhanced Class Decompiler +Enhanced Class Decompiler integrates **JD**, **FernFlower**, **Vineflower**, **CFR**, **Procyon** seamlessly with Eclipse and allows Java developers to **debug class files without source code directly**. It also integrates with the eclipse class editor, m2e plugin, supports **Javadoc**, **reference search**, **library source attaching**, **byte code view** and the syntax of JDK8 **lambda** expression. + +

+ +## Description +Enhanced Class Decompiler is a plug-in for the Eclipse platform. It integrates JD, FernFlower, Vineflower, CFR, Procyon seamlessly with Eclipse, allows you to display all the Java sources during your debugging process, even if you do not have them all, and you can debug these class files without source code directly. + +## Why is this plug-in "enhanced"? +This is an ad-free fork of the Eclipse Decompiler Plugin. So we enhanced it by removing all code which might compromise your privacy or security (to the best of our knowledge). + +## Supported Eclipse Versions + +Enhanced Class Decompiler requires at least Eclipse 4.8 (Photon) or newer. + +## How to install Enhanced Class Decompiler? + +Drag and Drop installation: [![Drag to your running Eclipse workspace.](https://marketplace.eclipse.org/modules/custom/eclipsefdn/eclipsefdn_marketplace/images/btn-install.svg)](https://marketplace.eclipse.org/marketplace-client-intro?mpc_install=3644319 "Drag to your running Eclipse workspace.") + + +_If you have currently the "Eclipse" Class Decompiler installed, it is recommended to uninstall that plug-in first and remove the corresponding update site from your Eclipse installation._ + 1. Launch _Eclipse_, + 2. Click on _"Help > Install New Software..."_, + 3. Click on button _"Add..."_ to add an new repository, + 4. Enter name as _"Enhanced Class Decompiler Update Site"_ and enter location as _"[https://ecd-plugin.github.io/update](https://ecd-plugin.github.io/update)"_, then click on button _"OK"_, + 5. Check _"Enhanced Class Decompiler"_, + 6. Next, next, next... and restart. + +## How to check the file associations? + 1. Click on _"Window > Preferences > General > Editors > File Associations"_ + 2. _"*.class"_ : _"Class Decompiler Viewer"_ is selected by default. + 3. _"*.class without source"_ : _"Class Decompiler Viewer"_ is selected by default. + +## How to configure Enhanced Class Decompiler? + 1. Click on _"Window > Preferences > Java > Decompiler"_ + +## How to uninstall Enhanced Class Decompiler? + 1. Click on _"Help > About Eclipse > Installation Details > Installation Software"_, + 2. Select _"Enhanced Class Decompiler"_, + 3. Click on _"Uninstall..."_. + +## How to build from source? + + Requiremnent: JDK 17 (make sure `JAVA_HOME` environment variable points to an JDK 17) + + If you want to test the latest features of this plugin, you have to build it from source. For this, proceed as following: + + 1. `git clone https://github.com/ecd-plugin/ecd` + 2. Run `cd ecd` + 3. Run `mvn clean package` + + If you want to use Eclipse and help developing, continue like this: + + 4. Install _Eclipse for RCP and RAP Developers_ + 3. Import all projects into Eclipse by selecting _File_ > _Import_ > _General_ > _Existing Projects into Workspace_ > _Next_ and enter the parent of the cloned directory as "root directory". + 4. Open the _org.sf.feeling.decompiler.updatesite_ project in the Package Explorer + 5. Open the file _site.xml_ within the project + 6. Press "Build All" + 7. Copy the jar files generated in the _build/features_ and _build/plugins_ folder of the project into the correspondent folders of your normal Eclipse installation. + +## Plugin Signature + +Since version 3.3.0 ECD is signed by a self-signed 4096 bit RSA key: + +* Subject: `CN=ECD Software Distribution,OU=ECD,O=ECD` +* SHA-1 fingerprint: 2D DB EE 7E 07 32 EB 0D 7C F2 FF C6 68 A0 C4 B8 B9 58 40 29 +* SHA-256 fingerprint: 8A 68 55 D3 91 B7 6F 95 DA D1 1E DF 1C 38 8D 38 F1 8A 0C A2 97 E5 12 85 DD 5B 05 9C C3 21 1B D4 +* Certificate file: [ecd.cer](ecd.cer) + +## Eclipse Photon to Eclipse 2021-03 + +Due to a signature bug in all Eclipse versions up to (including) Eclipse 2021-03, the signed releases of Enhanced Class Decompiler (ECD) 3.4.1 and newer can no longer be used. Please download the latest unsigned repository from the [ECD releases](https://github.com/ecd-plugin/ecd/releases) and install it manually in Eclipse. + +This affects the release version published on https://ecd-plugin.github.io/update/ and also the version installable via Eclipse Marketplace as it uses this update site. + +## Changelog +* Version 3.5.1 + * Use AST to remove block comments + * For newer Eclipse versions use methods to get the latest supported Java version (required for Eclipse 2024-06) + +* Version 3.5.0 + * Moved FernFlower into own plugin/feature + * Quiltflower plugin and feature removed + * Vineflower plugin and feature added (replaces Quiltflower) + * Removed "Source" (source.attach) plugin and feature + * Updated build environment to use Java 17 + +* Version 3.4.0 + * Updated Embedded Decompilers + * Fernflower updated to 232.10203.10 + +* Version 3.3.0 + * ECD releases are now signed with a self-signed certificate + * Removed Jad decompiler (decompiler was released 2001) + * Quiltflower plugin and feature added + * Updated Embedded Decompilers + * CFR to version 0.152 (JDK 14 support) + * Procyon to version 0.6.0 + +* Version 3.2.2 + * Fixed some inconsistencies regarding version numbers and the update site + * Upgraded some service URL to HTTPS + +* Version 3.2.1 + * Updated Embedded Decompilers + * CFR to version 0.15.1 (JDK 14 support) + * Procyon to version 0.5.36 + +* Version 3.2.0 + * Updated Embedded Decompilers + * JD-Core to version 1.1.3 (JDK 12 support) + +* Version 3.1.1 + * #44 Fixed that setting breakpoints might not work. + * #52 Fixed that hyperlinks might have oddly. + +* Version 3.1.0 + * Updated Embedded Decompilers + * CFR to version 0_130 + * Verified and updated embedded decompilers + * Fixed that activating a tab with a decompiled source would reset the selected line location + * Fixed and tested compatibility with Eclipse Photon + * Tested compatibility with JDK11. + +* Version 3.0.0 + * Removed adware code fragments + * Removed self-update feature (Eclipse handles updates fine) + * Removed extra-header in code (Issue [upstream#2](https://github.com/cnfree/Eclipse-Class-Decompiler/issues/28)) + * Display information about class being decompiled in editor title (Issue #3) + * Made plug-in work with Java9 BETA JDT core + +## Licenses + +The main plugin and the _org.sf.feeling.decompiler.jd_ project are licensed under [GPL 3](https://www.gnu.org/licenses/gpl-3.0-standalone.html), the other feature plugins are licensed under the [Eclipse Public License v1.0](https://www.eclipse.org/legal/epl-v10.html) + +Code partially based on: + * JD-Eclipse: Copyright Emmanuel Dupuy, [GPL 3](https://www.gnu.org/licenses/gpl-3.0-standalone.html) + * Java Source Attacher: Copyright Thai Ha, [Apache License V2.0](https://www.apache.org/licenses/LICENSE-2.0.html) + +Used libraries: + * Dr. Garbage Tools: Copyright (c) Dr. Garbage Ltd. & Co KG, [Apache License V2.0](https://www.apache.org/licenses/LICENSE-2.0.html) + * Apache commons: Copyright (c) Apache Software Foundation, [Apache License V2.0](https://www.apache.org/licenses/LICENSE-2.0.html) + * Fernflower: Copyright (c) JetBrains, [Apache License V2.0](https://www.apache.org/licenses/LICENSE-2.0.html) + * Minimal JSON: Copyright (c) 2013, 2014 EclipseSource, [MIT License](https://opensource.org/licenses/MIT) + * CFR: Copyright Leee Benfield, [MIT License](https://opensource.org/licenses/MIT) + * Procyon: Copyright Mike Strobel, [Apache License V2.0](https://www.apache.org/licenses/LICENSE-2.0.html) + * Netbeans CVSClient: Copyright (c) NetBeans Community, [Eclipse Public License v1.0](https://www.eclipse.org/legal/epl-v10.html) and [Apache License V2.0](https://www.apache.org/licenses/LICENSE-2.0.html) + * Maven SCM: Copyright (c) Apache Software Foundation, [Apache License V2.0](https://www.apache.org/licenses/LICENSE-2.0.html) + * Nexus Indexer: [Apache License V2.0](https://www.apache.org/licenses/LICENSE-2.0.html) + * Nexus Restlet1x Model: [Eclipse Public License v1.0](https://www.eclipse.org/legal/epl-v10.html) + * Plexus Utils: Copyright The Codehaus Foundation, [Apache License V2.0](https://www.apache.org/licenses/LICENSE-2.0.html) + * JD-Core: Copyright Emmanuel Dupuy, [GPL 3](https://www.gnu.org/licenses/gpl-3.0-standalone.html) + * Vineflower: [Apache License V2.0](https://www.apache.org/licenses/LICENSE-2.0.html) + +## Contributors + +* Chen Chao (cnfree2000@hotmail.com) - initial API and implementation +* Robert Zenz +* Pascal Bihler +* Nick Lombard +* Jan Peter Stotz +* Nicolas Baumann (@nbauma109) diff --git a/RELEASE.md b/RELEASE.md new file mode 100644 index 00000000..fd1d7c07 --- /dev/null +++ b/RELEASE.md @@ -0,0 +1,42 @@ +# Update versio in pom.xml files + + update-version.sh + +# Creating release files + +## Unsigned release + + mvn clean package + +This command will create the release repository ZIP file in `update_site/target/com.github.ecd-plugin.update-.zip` + +* Rename created zip to `com.github.ecd-plugin.update-.unsigned.zip` +* Move zip file to different folder (next build process will delete it otherwise) + +# Creating a release with signed JAR files + +(For ECD maintainers): + + mvn clean package -Dsigning.disabled=false -Dsigning.password= -Dsigning.keystore= + +This command will create the release repository ZIP file in `update_site/target/com.github.ecd-plugin.update-.zip` + +* Move zip file to different folder (next build process will delete it otherwise) + +# Update site + +1. Delete existing plugins and features directory in update site project. +2. Copy `update_site/target/category.xml` to update site project +3. Extract the content of `com.github.ecd-plugin.update-.zip` (signed version) to the update site project directory. +4. Update `site.xml` file + +# Github release + +1. Create Release with new Git tag. The tag is ECD `.` - example: v3.5.0.20240613 +2. Copy new changelog enries of the version from `Readme.md` to release description +3. Attach the two generated files `com.github.ecd-plugin.update-.zip` `com.github.ecd-plugin.update-.unsigned.zip` + +# Eclipse Marketplace + +Update the latest version number and the supported Eclipse versions and update the features list if features has been added/removed. +https://marketplace.eclipse.org/content/enhanced-class-decompiler/edit \ No newline at end of file diff --git a/_config.yml b/_config.yml new file mode 100644 index 00000000..fc24e7a6 --- /dev/null +++ b/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-hacker \ No newline at end of file diff --git a/doc/o_debug_class.png b/doc/o_debug_class.png new file mode 100644 index 00000000..9f94b73e Binary files /dev/null and b/doc/o_debug_class.png differ diff --git a/ecd.cer b/ecd.cer new file mode 100644 index 00000000..2864bd5e --- /dev/null +++ b/ecd.cer @@ -0,0 +1,29 @@ +-----BEGIN CERTIFICATE----- +MIIE/DCCAuSgAwIBAgIEZE6LsDANBgkqhkiG9w0BAQsFADBAMQwwCgYDVQQKDANF +Q0QxDDAKBgNVBAsMA0VDRDEiMCAGA1UEAwwZRUNEIFNvZnR3YXJlIERpc3RyaWJ1 +dGlvbjAeFw0yMzA0MzAxNTM5MjhaFw00MzA0MzAxNTM5MjhaMEAxDDAKBgNVBAoM +A0VDRDEMMAoGA1UECwwDRUNEMSIwIAYDVQQDDBlFQ0QgU29mdHdhcmUgRGlzdHJp +YnV0aW9uMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAxsFruVI40LBv +OvwivSYhFB+Vc9fp16Vkcy8lyHwH59AR2KHMce0GPvYnfy0pVkPWfmyO+zt58moS +ahwKL+bsJtYXF/SCFZTyQUG0NMZQcv3Rguef9/wVpfLW4m3QaRP/qXB4cjXUP0+o +sYWDmvgQEm3RHeicOk+HiDWkFFg0IaFO4DJ/4zbXEitNuBZq6odTGB7ffQLXHeU9 +xr3aW/EJ6Ik5EQfhAa7oKl5yNeMfOHHM0gc6NcbWWB3qkRNTIPpwKapYYqr6lTQ2 ++CQ0bYMcUwnMGZqX4p3RQy+nomvJOqBlPpLn00PIyA+NYIWcRwP2jhXWABRuTcpz +qXAtL7QseDZGfiXkhP5kl/W9GkdVUlnjwHhdP2kq/O93nZi413UzLNdJx7cHIQHg +RiBllHOD2E0nPxPNZTb8zZz1H3D1zWSysW+/KSAPPmiwOKbMvpJB65uMQHEnaObz +y9U50k3UdqqtXLjiO76JUZq2TmZyJy7fm46MZYrxnMzQLq0c+66dtrtF5vk5EDzn +Q2ApgDuDOALwix6olX57KoKMkMNfJPk0olslDM8ZgTiwbu9CYkKunus88BXvYJGJ ++iNL/36cyBsNBeHwH5wksh93EQskx5qGm1eO/4IpnyewLksXa25/QqiYdwgCzNGo +M6UG8ylQvR2SffdkpnD9HwW9uVwIfjECAwEAATANBgkqhkiG9w0BAQsFAAOCAgEA +ZTkIW7frYmRPsAiUkPWDKgKVCs9DCSrdXfjA+QyIIadRWGeIgzcV1UX7GiCKkpBv +ZeWAomAa69Esnw1itOqkxWwgsXi9jbFT7tWYr3xr04mcSNkzlw2zCAlol1z2B5NE +RJbiO0+tUbROeba+ZLkK27Z68Jf0WuQ0jcZqKLy5Tban3Dvucx0NK/EM+VNSp+xu +kJ+zFQPRQFyvQUhDN90CKLMSc8zLkeEfbP9WPe4WEnuVdNOYQ7+VeHxxuBUOQStU +uv1lx3CtHIhR9pnssEwvHznnNWoJY7dfqlUNJVKavynuKcIL9ifzlqSYk9OoLH9f +4O/zuzToRRHrJ8iqxtYu63GSBj1NXsyNLO0BWentgyZwm0Vl29lcQDT1Yn2o071e +LTDA9Y4nV+L57mqIlcXf8z5RVQEydfItl4nZegkgtMA4mA3t54GtW6tJyqEVkNTs +zZxBjDO/mPh4ific7X2CH8ktZetflA3xfLqBCpcUdkzhfWeESwnbnc/yIFdB0Di0 +6LhmV7g9ZjDTzThdpeocEcla29gNJQnF3NUvJI0N6Vj6KbU+A/1HkytPwJf8CRiA +plv4LUR+8+EnKiSTJRtGImv/AztgZMjJJxnUy596NCEkDtflAn8matVrTh0UggXM +xf6G9CCQJ8kE4puNsuEHDgfOsy75AdBWBB+nsHUUc2I= +-----END CERTIFICATE----- diff --git a/org.sf.feeling.decompiler.cfr.feature/.settings/org.eclipse.core.resources.prefs b/org.sf.feeling.decompiler.cfr.feature/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000..99f26c02 --- /dev/null +++ b/org.sf.feeling.decompiler.cfr.feature/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/org.sf.feeling.decompiler.cfr.feature/.settings/org.eclipse.core.runtime.prefs b/org.sf.feeling.decompiler.cfr.feature/.settings/org.eclipse.core.runtime.prefs new file mode 100644 index 00000000..deae05a9 --- /dev/null +++ b/org.sf.feeling.decompiler.cfr.feature/.settings/org.eclipse.core.runtime.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +line.separator=\r\n diff --git a/org.sf.feeling.decompiler.cfr.feature/build.properties b/org.sf.feeling.decompiler.cfr.feature/build.properties index 2ed3f033..40b08e1e 100644 --- a/org.sf.feeling.decompiler.cfr.feature/build.properties +++ b/org.sf.feeling.decompiler.cfr.feature/build.properties @@ -1,6 +1,5 @@ -bin.includes = feature.xml,\ - eclipse_update_120.jpg,\ - epl-v10.html,\ - feature.properties,\ - license.html -qualifier = 20170815 \ No newline at end of file +bin.includes = feature.xml,\ + eclipse_update_120.jpg,\ + epl-v10.html,\ + feature.properties,\ + license.html \ No newline at end of file diff --git a/org.sf.feeling.decompiler.cfr.feature/feature.properties b/org.sf.feeling.decompiler.cfr.feature/feature.properties index 4da5a65e..b81a365a 100644 --- a/org.sf.feeling.decompiler.cfr.feature/feature.properties +++ b/org.sf.feeling.decompiler.cfr.feature/feature.properties @@ -1,12 +1,9 @@ ############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). +# Copyright (c) 2017 Chen Chao and other ECD project contributors. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation +# https://www.eclipse.org/legal/epl-v10.html ############################################################################### # feature.properties @@ -16,21 +13,21 @@ # This file should be translated. # "featureName" property - name of the feature -featureName=Eclipse Class Decompiler CFR Extension (Optional) +featureName=Enhanced Class Decompiler CFR Extension (Optional) # "providerName" property - name of the company that provides the feature -providerName=Chen Chao +providerName=ECD project contributors # "updateSiteName" property - label for the update site -updateSiteName=Eclipse Class Decompiler Updates +updateSiteName=Enhanced Class Decompiler Updates # "description" property - description of the feature -description=Eclipse Class Decompiler integrates JD, Jad, FernFlower, CFR, Procyon with Eclipse seamlessly. \ +description=Enhanced Class Decompiler integrates JD, FernFlower, Vineflower, CFR, Procyon with Eclipse seamlessly. \ It allows Java developers to debug class files without source code directly. -copyrightURL=http://www.cpupk.com/decompiler/update +copyrightURL=https://ecd-plugin.github.io -copyright=(c) Copyright 2017 Chen Chao(cnfree2000@hotmail.com). All rights reserved.\n +copyright=(c) Copyright 2017 Chen Chao and other ECD project contributors. All rights reserved.\n # "licenseURL" property - URL of the "Feature License" # do not translate value - just change to point to a locale-specific HTML page @@ -65,7 +62,7 @@ Applicable Licenses\n\ Unless otherwise indicated, all Content made available by the Eclipse Foundation\n\ is provided to you under the terms and conditions of the Eclipse Public\n\ License Version 1.0 ("EPL"). A copy of the EPL is provided with this\n\ -Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\ +Content and is also available at https://www.eclipse.org/legal/epl-v10.html.\n\ For purposes of the EPL, "Program" will mean the Content.\n\ \n\ Content includes, but is not limited to, source code, object code,\n\ @@ -112,9 +109,9 @@ THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER\n\ TO THE CPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\ SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\ \n\ - - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\ - - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\ - - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\ + - Common Public License Version 1.0 (available at https://www.eclipse.org/legal/cpl-v10.html)\n\ + - Apache Software License 1.1 (available at https://www.apache.org/licenses/LICENSE.txt)\n\ + - Apache Software License 2.0 (available at https://www.apache.org/licenses/LICENSE-2.0.html)\n\ - IBM Public License 1.0 (available at http://oss.software.ibm.com/developerworks/opensource/license10.html)\n\ - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\ - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\ @@ -132,4 +129,4 @@ and/or re-export to another country, of encryption software. BEFORE\n\ using any encryption software, please check the country's laws,\n\ regulations and policies concerning the import, possession, or use,\n\ and re-export of encryption software, to see if this is permitted.\n -########### end of license property ########################################## \ No newline at end of file +########### end of license property ########################################## diff --git a/org.sf.feeling.decompiler.cfr.feature/feature.xml b/org.sf.feeling.decompiler.cfr.feature/feature.xml index eefbb091..efc6fe4f 100644 --- a/org.sf.feeling.decompiler.cfr.feature/feature.xml +++ b/org.sf.feeling.decompiler.cfr.feature/feature.xml @@ -2,7 +2,7 @@ @@ -19,13 +19,12 @@ - - + + - @@ -40,13 +39,15 @@ + + diff --git a/org.sf.feeling.decompiler.cfr.feature/license.html b/org.sf.feeling.decompiler.cfr.feature/license.html index e2323dfc..db78f42e 100644 --- a/org.sf.feeling.decompiler.cfr.feature/license.html +++ b/org.sf.feeling.decompiler.cfr.feature/license.html @@ -21,7 +21,7 @@

Usage Of Content

Applicable Licenses

Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0 - ("EPL"). A copy of the EPL is provided with this Content and is also available at http://www.eclipse.org/legal/epl-v10.html. + ("EPL"). A copy of the EPL is provided with this Content and is also available at https://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, "Program" will mean the Content.

Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse.org CVS repository ("Repository") in CVS @@ -53,9 +53,9 @@

Applicable Licenses

OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):

    -
  • Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)
  • -
  • Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)
  • -
  • Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)
  • +
  • Common Public License Version 1.0 (available at https://www.eclipse.org/legal/cpl-v10.html)
  • +
  • Apache Software License 1.1 (available at https://www.apache.org/licenses/LICENSE.txt)
  • +
  • Apache Software License 2.0 (available at https://www.apache.org/licenses/LICENSE-2.0.html)
  • IBM Public License 1.0 (available at http://oss.software.ibm.com/developerworks/opensource/license10.html)
  • Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)
  • Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)
  • diff --git a/org.sf.feeling.decompiler.cfr.feature/pom.xml b/org.sf.feeling.decompiler.cfr.feature/pom.xml new file mode 100644 index 00000000..714c1ea2 --- /dev/null +++ b/org.sf.feeling.decompiler.cfr.feature/pom.xml @@ -0,0 +1,15 @@ + + 4.0.0 + + + com.github.ecd-plugin + com.github.ecd-plugin.ecd + 3.5.1 + ../pom.xml + + + com.github.ecd-plugin.features + org.sf.feeling.decompiler.cfr + eclipse-feature + diff --git a/org.sf.feeling.decompiler.cfr/.classpath b/org.sf.feeling.decompiler.cfr/.classpath index 60564cd0..f57b4d1d 100644 --- a/org.sf.feeling.decompiler.cfr/.classpath +++ b/org.sf.feeling.decompiler.cfr/.classpath @@ -1,8 +1,12 @@ - - - - - - - - + + + + + + + + + + + + diff --git a/org.sf.feeling.decompiler.cfr/.gitignore b/org.sf.feeling.decompiler.cfr/.gitignore deleted file mode 100644 index ae3c1726..00000000 --- a/org.sf.feeling.decompiler.cfr/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin/ diff --git a/org.sf.feeling.decompiler.cfr/.project b/org.sf.feeling.decompiler.cfr/.project index 043fda44..fba26d92 100644 --- a/org.sf.feeling.decompiler.cfr/.project +++ b/org.sf.feeling.decompiler.cfr/.project @@ -20,8 +20,14 @@ + + org.eclipse.m2e.core.maven2Builder + + + + org.eclipse.m2e.core.maven2Nature org.eclipse.pde.PluginNature org.eclipse.jdt.core.javanature diff --git a/org.sf.feeling.decompiler.cfr/.settings/org.eclipse.core.resources.prefs b/org.sf.feeling.decompiler.cfr/.settings/org.eclipse.core.resources.prefs index e291fe31..4824b802 100644 --- a/org.sf.feeling.decompiler.cfr/.settings/org.eclipse.core.resources.prefs +++ b/org.sf.feeling.decompiler.cfr/.settings/org.eclipse.core.resources.prefs @@ -1,4 +1,2 @@ eclipse.preferences.version=1 -encoding//src/org/sf/feeling/decompiler/cfr/i18n/messages_zh_CN.properties=UTF-8 -encoding//src/org/sf/feeling/decompiler/cfr/i18n/messages_zh_HK.properties=UTF-8 -encoding//src/org/sf/feeling/decompiler/cfr/i18n/messages_zh_TW.properties=UTF-8 +encoding/=UTF-8 diff --git a/org.sf.feeling.decompiler.cfr/.settings/org.eclipse.core.runtime.prefs b/org.sf.feeling.decompiler.cfr/.settings/org.eclipse.core.runtime.prefs new file mode 100644 index 00000000..f8a67de1 --- /dev/null +++ b/org.sf.feeling.decompiler.cfr/.settings/org.eclipse.core.runtime.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +line.separator=\r\n diff --git a/org.sf.feeling.decompiler.cfr/.settings/org.eclipse.jdt.core.prefs b/org.sf.feeling.decompiler.cfr/.settings/org.eclipse.jdt.core.prefs index 72c4a7e3..dd8b8ec2 100644 --- a/org.sf.feeling.decompiler.cfr/.settings/org.eclipse.jdt.core.prefs +++ b/org.sf.feeling.decompiler.cfr/.settings/org.eclipse.jdt.core.prefs @@ -1,7 +1,7 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.autoboxing=ignore @@ -74,4 +74,391 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false +org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false +org.eclipse.jdt.core.formatter.align_with_spaces=false +org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_enum_constant=49 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field=49 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable=49 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_method=49 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package=49 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter=0 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type=49 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assertion_message=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain=0 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0 +org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_module_statements=16 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_record_components=16 +org.eclipse.jdt.core.formatter.alignment_for_relational_operator=0 +org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_shift_operator=0 +org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_record_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_type_annotations=0 +org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0 +org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0 +org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_last_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_abstract_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_statement_group_in_switch=0 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_record_constructor=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_record_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped=true +org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false +org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=true +org.eclipse.jdt.core.formatter.comment.format_block_comments=true +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true +org.eclipse.jdt.core.formatter.comment.format_line_comments=true +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=false +org.eclipse.jdt.core.formatter.comment.indent_root_tags=false +org.eclipse.jdt.core.formatter.comment.indent_tag_description=false +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_between_different_tags=do not insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert +org.eclipse.jdt.core.formatter.comment.line_length=80 +org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true +org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true +org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false +org.eclipse.jdt.core.formatter.compact_else_if=true +org.eclipse.jdt.core.formatter.continuation_indentation=2 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 +org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=false +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_record_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false +org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_default=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_record_components=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_switch_case_expressions=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_not_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_record_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert +org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_case=insert +org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_default=insert +org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_record_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_record_components=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_switch_case_expressions=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_constructor=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_record_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=true +org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_code_block_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_method_body_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_record_constructor_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_record_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line=false +org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.lineSplit=120 +org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false +org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false +org.eclipse.jdt.core.formatter.number_of_blank_lines_after_code_block=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_code_block=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_code_block=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_before_code_block=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 +org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_record_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true +org.eclipse.jdt.core.formatter.tabulation.char=tab +org.eclipse.jdt.core.formatter.tabulation.size=4 +org.eclipse.jdt.core.formatter.text_block_indentation=0 +org.eclipse.jdt.core.formatter.use_on_off_tags=true +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true +org.eclipse.jdt.core.formatter.wrap_before_assertion_message_operator=true +org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false +org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true +org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true +org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true +org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true +org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_before_relational_operator=true +org.eclipse.jdt.core.formatter.wrap_before_shift_operator=true +org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true +org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter diff --git a/org.sf.feeling.decompiler.cfr/.settings/org.eclipse.jdt.ui.prefs b/org.sf.feeling.decompiler.cfr/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 00000000..9a4e91e5 --- /dev/null +++ b/org.sf.feeling.decompiler.cfr/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,106 @@ +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +formatter_profile=org.eclipse.jdt.ui.default.eclipse_profile +formatter_settings_version=20 +sp_cleanup.add_all=false +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.arrays_fill=false +sp_cleanup.bitwise_conditional_expression=false +sp_cleanup.boolean_literal=false +sp_cleanup.break_loop=false +sp_cleanup.collection_cloning=false +sp_cleanup.comparison_statement=false +sp_cleanup.convert_functional_interfaces=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.convert_to_enhanced_for_loop_if_loop_var_used=false +sp_cleanup.convert_to_switch_expressions=false +sp_cleanup.correct_indentation=false +sp_cleanup.double_negation=false +sp_cleanup.else_if=false +sp_cleanup.embedded_if=false +sp_cleanup.evaluate_nullable=false +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=false +sp_cleanup.hash=false +sp_cleanup.if_condition=false +sp_cleanup.insert_inferred_type_arguments=false +sp_cleanup.instanceof=false +sp_cleanup.join=false +sp_cleanup.lazy_logical_operator=false +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=true +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=false +sp_cleanup.map_cloning=false +sp_cleanup.merge_conditional_blocks=false +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.no_string_creation=false +sp_cleanup.no_super=false +sp_cleanup.number_suffix=false +sp_cleanup.objects_equals=false +sp_cleanup.on_save_use_additional_actions=false +sp_cleanup.organize_imports=true +sp_cleanup.overridden_assignment=false +sp_cleanup.precompile_regex=false +sp_cleanup.primitive_serialization=false +sp_cleanup.pull_up_assignment=false +sp_cleanup.push_down_negation=false +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=false +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.redundant_falling_through_block_end=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_redundant_modifiers=false +sp_cleanup.remove_redundant_semicolons=false +sp_cleanup.remove_redundant_type_arguments=false +sp_cleanup.remove_trailing_whitespaces=false +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_array_creation=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=false +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.simplify_lambda_expression_and_method_ref=false +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.strictly_equal_or_different=false +sp_cleanup.stringbuilder=false +sp_cleanup.switch=false +sp_cleanup.ternary_operator=false +sp_cleanup.try_with_resource=false +sp_cleanup.use_anonymous_class_creation=false +sp_cleanup.use_autoboxing=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_directly_map_method=false +sp_cleanup.use_lambda=true +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=false +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true +sp_cleanup.use_unboxing=false +sp_cleanup.use_var=false +sp_cleanup.useless_continue=false +sp_cleanup.useless_return=false diff --git a/org.sf.feeling.decompiler.cfr/.settings/org.eclipse.m2e.core.prefs b/org.sf.feeling.decompiler.cfr/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 00000000..f897a7f1 --- /dev/null +++ b/org.sf.feeling.decompiler.cfr/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/org.sf.feeling.decompiler.cfr/META-INF/MANIFEST.MF b/org.sf.feeling.decompiler.cfr/META-INF/MANIFEST.MF index 9899a67d..41ce5d89 100644 --- a/org.sf.feeling.decompiler.cfr/META-INF/MANIFEST.MF +++ b/org.sf.feeling.decompiler.cfr/META-INF/MANIFEST.MF @@ -1,11 +1,11 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 -Bundle-Name: Eclipse Class Decompiler CFR Extension +Bundle-Name: Enhanced Class Decompiler CFR Extension Bundle-SymbolicName: org.sf.feeling.decompiler.cfr;singleton:=true -Bundle-Version: 2.10.0.qualifier +Bundle-Version: 3.5.1 Bundle-Activator: org.sf.feeling.decompiler.cfr.CfrDecompilerPlugin Require-Bundle: org.eclipse.core.runtime, - org.sf.feeling.decompiler, + org.sf.feeling.decompiler;bundle-version="3.2.2", org.eclipse.core.resources, org.eclipse.jface, org.eclipse.jface.text, @@ -21,10 +21,11 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.ui.navigator, org.eclipse.ui.ide;resolution:=optional, org.eclipse.core.filesystem -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ActivationPolicy: lazy -Bundle-Vendor: Chen Chao +Bundle-Vendor: ECD Project Team Export-Package: org.sf.feeling.decompiler.cfr.actions, org.sf.feeling.decompiler.cfr.decompiler -Bundle-ClassPath: lib/cfr_0_122.jar, +Bundle-ClassPath: lib/cfr.jar, . +Import-Package: org.apache.commons.lang3.time diff --git a/org.sf.feeling.decompiler.cfr/build.properties b/org.sf.feeling.decompiler.cfr/build.properties index 59fb8910..70f010cd 100644 --- a/org.sf.feeling.decompiler.cfr/build.properties +++ b/org.sf.feeling.decompiler.cfr/build.properties @@ -4,5 +4,4 @@ bin.includes = META-INF/,\ .,\ plugin.xml,\ icons/,\ - lib/ -qualifier = 20170815 + lib/cfr.jar diff --git a/org.sf.feeling.decompiler.cfr/lib/.gitignore b/org.sf.feeling.decompiler.cfr/lib/.gitignore new file mode 100644 index 00000000..ef5920e2 --- /dev/null +++ b/org.sf.feeling.decompiler.cfr/lib/.gitignore @@ -0,0 +1 @@ +/cfr.jar diff --git a/org.sf.feeling.decompiler.cfr/lib/cfr_0_122.jar b/org.sf.feeling.decompiler.cfr/lib/cfr_0_122.jar deleted file mode 100644 index fda5c9ef..00000000 Binary files a/org.sf.feeling.decompiler.cfr/lib/cfr_0_122.jar and /dev/null differ diff --git a/org.sf.feeling.decompiler.cfr/plugin.xml b/org.sf.feeling.decompiler.cfr/plugin.xml index 3cfc6dbc..67419419 100644 --- a/org.sf.feeling.decompiler.cfr/plugin.xml +++ b/org.sf.feeling.decompiler.cfr/plugin.xml @@ -1,14 +1,11 @@ diff --git a/org.sf.feeling.decompiler.cfr/pom.xml b/org.sf.feeling.decompiler.cfr/pom.xml new file mode 100644 index 00000000..b6e80545 --- /dev/null +++ b/org.sf.feeling.decompiler.cfr/pom.xml @@ -0,0 +1,48 @@ + + 4.0.0 + + + com.github.ecd-plugin + com.github.ecd-plugin.ecd + 3.5.1 + ../pom.xml + + + org.sf.feeling.decompiler.cfr + eclipse-plugin + + + + + org.apache.maven.plugins + maven-dependency-plugin + ${maven.dependency.plugin.version} + + + copy-libraries + validate + + copy + + + + + org.benf + cfr + 0.152 + cfr.jar + + + lib + true + true + + + + + + + + diff --git a/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/CfrDecompilerPlugin.java b/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/CfrDecompilerPlugin.java index e1fdae3c..a9202b43 100644 --- a/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/CfrDecompilerPlugin.java +++ b/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/CfrDecompilerPlugin.java @@ -4,6 +4,7 @@ import java.net.MalformedURLException; import java.net.URL; +import org.benf.cfr.reader.util.CfrVersionInfo; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.util.IPropertyChangeListener; @@ -12,13 +13,14 @@ import org.osgi.framework.BundleContext; import org.sf.feeling.decompiler.JavaDecompilerPlugin; -public class CfrDecompilerPlugin extends AbstractUIPlugin implements IPropertyChangeListener -{ +public class CfrDecompilerPlugin extends AbstractUIPlugin implements IPropertyChangeListener { public static final String PLUGIN_ID = "org.sf.feeling.decompiler.cfr"; //$NON-NLS-1$ public static final String decompilerType = "CFR"; //$NON-NLS-1$ + public static final String decompilerVersion = CfrVersionInfo.VERSION; + private static CfrDecompilerPlugin plugin; private IPreferenceStore preferenceStore; @@ -27,14 +29,12 @@ public class CfrDecompilerPlugin extends AbstractUIPlugin implements IPropertyCh * (non-Javadoc) * * @see - * org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext - * ) + * org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext ) */ @Override - public void start( BundleContext context ) throws Exception - { - super.start( context ); - getPreferenceStore( ).addPropertyChangeListener( this ); + public void start(BundleContext context) throws Exception { + super.start(context); + getPreferenceStore().addPropertyChangeListener(this); } /* @@ -44,54 +44,45 @@ public void start( BundleContext context ) throws Exception * org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) */ @Override - public void stop( BundleContext context ) throws Exception - { - super.stop( context ); - getPreferenceStore( ).removePropertyChangeListener( this ); + public void stop(BundleContext context) throws Exception { + super.stop(context); + getPreferenceStore().removePropertyChangeListener(this); plugin = null; } @Override - public void propertyChange( PropertyChangeEvent event ) - { + public void propertyChange(PropertyChangeEvent event) { } @Override - public IPreferenceStore getPreferenceStore( ) - { - if ( preferenceStore == null ) - { - preferenceStore = JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ); + public IPreferenceStore getPreferenceStore() { + if (preferenceStore == null) { + preferenceStore = JavaDecompilerPlugin.getDefault().getPreferenceStore(); } return preferenceStore; } - public static CfrDecompilerPlugin getDefault( ) - { + public static CfrDecompilerPlugin getDefault() { return plugin; } - public CfrDecompilerPlugin( ) - { + public CfrDecompilerPlugin() { plugin = this; } - public static ImageDescriptor getImageDescriptor( String path ) - { - URL base = CfrDecompilerPlugin.getDefault( ).getBundle( ).getEntry( "/" ); //$NON-NLS-1$ + public static ImageDescriptor getImageDescriptor(String path) { + URL base = CfrDecompilerPlugin.getDefault().getBundle().getEntry("/"); //$NON-NLS-1$ URL url = null; - try - { - url = new URL( base, path ); // $NON-NLS-1$ - } - catch ( MalformedURLException e ) - { - e.printStackTrace( ); + try { + url = new URL(base, path); // $NON-NLS-1$ + } catch (MalformedURLException e) { + e.printStackTrace(); } ImageDescriptor actionIcon = null; - if ( url != null ) - actionIcon = ImageDescriptor.createFromURL( url ); + if (url != null) { + actionIcon = ImageDescriptor.createFromURL(url); + } return actionIcon; } diff --git a/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/actions/DecompileWithCfrAction.java b/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/actions/DecompileWithCfrAction.java index 28856adb..123dc46d 100644 --- a/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/actions/DecompileWithCfrAction.java +++ b/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/actions/DecompileWithCfrAction.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.cfr.actions; @@ -17,30 +14,23 @@ import org.sf.feeling.decompiler.cfr.i18n.Messages; import org.sf.feeling.decompiler.util.UIUtil; -public class DecompileWithCfrAction extends Action -{ +public class DecompileWithCfrAction extends Action { - public DecompileWithCfrAction( ) - { - super( Messages.getString( "JavaDecompilerActionBarContributor.Action.DecompileWithCfr" ) ); //$NON-NLS-1$ - this.setImageDescriptor( CfrDecompilerPlugin.getImageDescriptor( "icons/cfr_16.gif" ) ); //$NON-NLS-1$ + public DecompileWithCfrAction() { + super(Messages.getString("JavaDecompilerActionBarContributor.Action.DecompileWithCfr")); //$NON-NLS-1$ + this.setImageDescriptor(CfrDecompilerPlugin.getImageDescriptor("icons/cfr_16.gif")); //$NON-NLS-1$ } @Override - public void run( ) - { - try - { - new DecompileWithCfrHandler( ).execute( null ); - } - catch ( ExecutionException e ) - { + public void run() { + try { + new DecompileWithCfrHandler().execute(null); + } catch (ExecutionException e) { } } @Override - public boolean isEnabled( ) - { - return UIUtil.getActiveEditor( ) != null || UIUtil.getActiveSelection( ) != null; + public boolean isEnabled() { + return UIUtil.getActiveEditor() != null || UIUtil.getActiveSelection() != null; } -} \ No newline at end of file +} diff --git a/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/actions/DecompileWithCfrHandler.java b/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/actions/DecompileWithCfrHandler.java index 31950f3d..a3759b4d 100644 --- a/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/actions/DecompileWithCfrHandler.java +++ b/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/actions/DecompileWithCfrHandler.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.cfr.actions; @@ -16,12 +13,10 @@ import org.sf.feeling.decompiler.actions.BaseDecompilerHandler; import org.sf.feeling.decompiler.cfr.CfrDecompilerPlugin; -public class DecompileWithCfrHandler extends BaseDecompilerHandler -{ +public class DecompileWithCfrHandler extends BaseDecompilerHandler { @Override - public Object execute( ExecutionEvent event ) throws ExecutionException - { - return handleDecompile( CfrDecompilerPlugin.decompilerType ); + public Object execute(ExecutionEvent event) throws ExecutionException { + return handleDecompile(CfrDecompilerPlugin.decompilerType); } } 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 549acea1..04e3111a 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 @@ -1,216 +1,193 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.cfr.decompiler; - -import java.io.File; -import java.util.Collections; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.benf.cfr.reader.api.ClassFileSource; -import org.benf.cfr.reader.entities.ClassFile; -import org.benf.cfr.reader.state.ClassFileSourceImpl; -import org.benf.cfr.reader.state.DCCommonState; -import org.benf.cfr.reader.state.TypeUsageCollector; -import org.benf.cfr.reader.util.CannotLoadClassException; -import org.benf.cfr.reader.util.getopt.GetOptParser; -import org.benf.cfr.reader.util.getopt.Options; -import org.benf.cfr.reader.util.getopt.OptionsImpl; -import org.benf.cfr.reader.util.output.IllegalIdentifierDump; -import org.sf.feeling.decompiler.JavaDecompilerPlugin; -import org.sf.feeling.decompiler.cfr.CfrDecompilerPlugin; -import org.sf.feeling.decompiler.editor.IDecompiler; -import org.sf.feeling.decompiler.util.FileUtil; -import org.sf.feeling.decompiler.util.JarClassExtractor; -import org.sf.feeling.decompiler.util.UnicodeUtil; - -public class CfrDecompiler implements IDecompiler -{ - - private String source = ""; //$NON-NLS-1$ - private long time, start; - private String log = ""; //$NON-NLS-1$ - - /** - * Performs a Runtime.exec() on jad executable with selected - * options. - * - * @see IDecompiler#decompile(String, String, String) - */ - @Override - public void decompile( String root, String packege, String className ) - { - start = System.currentTimeMillis( ); - log = ""; //$NON-NLS-1$ - source = ""; //$NON-NLS-1$ - File workingDir = new File( root + "/" + packege ); //$NON-NLS-1$ - - String classPathStr = new File( workingDir, className ).getAbsolutePath( ); - - GetOptParser getOptParser = new GetOptParser( ); - - try - { - Options options = getOptParser.parse( new String[]{ - classPathStr - }, OptionsImpl.getFactory( ) ); - ClassFileSource classFileSource = new ClassFileSourceImpl( options ); - DCCommonState dcCommonState = new DCCommonState( options, classFileSource ); - - IllegalIdentifierDump illegalIdentifierDump = IllegalIdentifierDump.Factory.get( options ); - - ClassFile c = dcCommonState.getClassFileMaybePath( options.getOption( OptionsImpl.FILENAME ) ); - dcCommonState.configureWith( c ); - try - { - c = dcCommonState.getClassFile( c.getClassType( ) ); - } - catch ( CannotLoadClassException e ) - { - } - if ( options.getOption( OptionsImpl.DECOMPILE_INNER_CLASSES ).booleanValue( ) ) - { - c.loadInnerClasses( dcCommonState ); - } - - c.analyseTop( dcCommonState ); - - TypeUsageCollector collectingDumper = new TypeUsageCollector( c ); - c.collectTypeUsages( collectingDumper ); - - StringDumper dumper = new StringDumper( collectingDumper.getTypeUsageInformation( ), - options, - illegalIdentifierDump ); - c.dump( dumper ); - - source = UnicodeUtil.decode( dumper.toString( ).trim( ) ); - - Pattern wp = Pattern.compile( "/\\*.+?\\*/", Pattern.DOTALL ); //$NON-NLS-1$ - Matcher m = wp.matcher( source ); - while ( m.find( ) ) - { - if ( m.group( ).matches( "/\\*\\s+\\d*\\s+\\*/" ) ) //$NON-NLS-1$ - continue; - String group = m.group( ); - group = group.replace( "/*", "" ); //$NON-NLS-1$ //$NON-NLS-2$ - group = group.replace( "*/", "" ); //$NON-NLS-1$ //$NON-NLS-2$ - group = group.replace( "*", "" ); //$NON-NLS-1$ //$NON-NLS-2$ - if ( log.length( ) > 0 ) - log += "\n"; //$NON-NLS-1$ - log += group; - - source = source.replace( m.group( ), "" ).trim( ); //$NON-NLS-1$ - } - dumper.close( ); - } - catch ( Exception e ) - { - JavaDecompilerPlugin.logError( e, e.getMessage( ) ); - } - - time = System.currentTimeMillis( ) - start; - } - - /** - * Jad doesn't support decompilation from archives. This methods extracts - * request class file from the specified archive into temp directory and - * then calls decompile. - * - * @see IDecompiler#decompileFromArchive(String, String, String) - */ - @Override - 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$ - + System.currentTimeMillis( ) ); - - try - { - workingDir.mkdirs( ); - JarClassExtractor.extract( archivePath, packege, className, true, workingDir.getAbsolutePath( ) ); - decompile( workingDir.getAbsolutePath( ), "", className ); //$NON-NLS-1$ - } - catch ( Exception e ) - { - JavaDecompilerPlugin.logError( e, e.getMessage( ) ); - return; - } - finally - { - FileUtil.deltree( workingDir ); - } - } - - @Override - public long getDecompilationTime( ) - { - return time; - } - - @Override - public List getExceptions( ) - { - return Collections.EMPTY_LIST; - } - - /** - * @see IDecompiler#getLog() - */ - @Override - public String getLog( ) - { - return log; - } - - /** - * @see IDecompiler#getSource() - */ - @Override - public String getSource( ) - { - return source; - } - - @Override - public String getDecompilerType( ) - { - return CfrDecompilerPlugin.decompilerType; - } - - @Override - public String removeComment( String source ) - { - return source; - } - - @Override - public boolean supportLevel( int level ) - { - return true; - } - - @Override - public boolean supportDebugLevel( int level ) - { - return false; - } - - @Override - public boolean supportDebug( ) - { - return false; - } +/******************************************************************************* + * Copyright (c) 2017 Chen Chao and other ECD project contributors. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.sf.feeling.decompiler.cfr.decompiler; + +import java.io.File; +import java.util.List; + +import org.apache.commons.lang3.time.StopWatch; +import org.benf.cfr.reader.apiunreleased.ClassFileSource2; +import org.benf.cfr.reader.bytecode.analysis.parse.utils.Pair; +import org.benf.cfr.reader.entities.ClassFile; +import org.benf.cfr.reader.entities.Method; +import org.benf.cfr.reader.state.ClassFileSourceImpl; +import org.benf.cfr.reader.state.DCCommonState; +import org.benf.cfr.reader.state.TypeUsageCollectingDumper; +import org.benf.cfr.reader.state.TypeUsageInformation; +import org.benf.cfr.reader.util.CannotLoadClassException; +import org.benf.cfr.reader.util.getopt.GetOptParser; +import org.benf.cfr.reader.util.getopt.Options; +import org.benf.cfr.reader.util.getopt.OptionsImpl; +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; +import org.sf.feeling.decompiler.editor.IDecompiler; +import org.sf.feeling.decompiler.util.CommentUtil; +import org.sf.feeling.decompiler.util.FileUtil; +import org.sf.feeling.decompiler.util.JarClassExtractor; +import org.sf.feeling.decompiler.util.UnicodeUtil; + +public class CfrDecompiler extends BaseDecompiler { + + private String source = ""; //$NON-NLS-1$ + private long time; + private String log = ""; //$NON-NLS-1$ + + /** + * Performs a Runtime.exec() on CFR with selected options. + * + * @see IDecompiler#decompile(String, String, String) + */ + @Override + public void decompile(String root, String packege, String className) { + StopWatch stopWatch = new StopWatch(); + stopWatch.start(); + log = ""; //$NON-NLS-1$ + source = ""; //$NON-NLS-1$ + File workingDir = new File(root + "/" + packege); //$NON-NLS-1$ + + String classPathStr = new File(workingDir, className).getAbsolutePath(); + + GetOptParser getOptParser = new GetOptParser(); + + try { + Pair, Options> options = getOptParser.parse(new String[] { classPathStr }, + OptionsImpl.getFactory()); + Options namedOptions = options.getSecond(); + ClassFileSource2 classFileSource = new ClassFileSourceImpl(namedOptions); + classFileSource.informAnalysisRelativePathDetail(null, null); + DCCommonState dcCommonState = new DCCommonState(namedOptions, classFileSource); + + IllegalIdentifierDump illegalIdentifierDump = IllegalIdentifierDump.Factory.get(namedOptions); + + ClassFile classFile = dcCommonState.getClassFileMaybePath(classPathStr); + dcCommonState.configureWith(classFile); + try { + classFile = dcCommonState.getClassFile(classFile.getClassType()); + } catch (CannotLoadClassException e) { + throw new RuntimeException(e); + } + if (namedOptions.getOption(OptionsImpl.DECOMPILE_INNER_CLASSES).booleanValue()) { + classFile.loadInnerClasses(dcCommonState); + } + TypeUsageCollectingDumper typeUsageCollectingDumper = new TypeUsageCollectingDumper(namedOptions, + classFile); + + classFile.analyseTop(dcCommonState, typeUsageCollectingDumper); + + TypeUsageInformation typeUsageInfo = typeUsageCollectingDumper.getRealTypeUsageInformation(); + + MethodErrorCollector methodErrorCollector = new MethodErrorCollector() { + + @Override + public void addSummaryError(Method paramMethod, String msg) { + log += String.format("\n%s: %s", paramMethod.toString(), msg); + } + + }; + + StringBuilder stringBuilder = new StringBuilder(4096); + StringStreamDumper dumper = new StringStreamDumper(methodErrorCollector, stringBuilder, typeUsageInfo, + namedOptions, illegalIdentifierDump); + classFile.dump(dumper); + source = UnicodeUtil.decode(stringBuilder.toString().trim()); + + source = CommentUtil.clearComments(source); + } catch (Exception e) { + exceptions.add(e); + JavaDecompilerPlugin.logError(e, e.getMessage()); + } + + time = stopWatch.getTime(); + } + + /** + * Cfr doesn't support decompilation from archives. This methods extracts + * request class file from the specified archive into temp directory and then + * calls decompile. + * + * @see IDecompiler#decompileFromArchive(String, String, String) + */ + @Override + public void decompileFromArchive(String archivePath, String packege, String className) { + StopWatch stopWatch = new StopWatch(); + stopWatch.start(); + String tempDir = JavaDecompilerPlugin.getDefault().getPreferenceStore() + .getString(JavaDecompilerConstants.TEMP_DIR); + File workingDir = new File(tempDir + "/ecd_cfr_" + System.currentTimeMillis()); //$NON-NLS-1$ + try { + workingDir.mkdirs(); + JarClassExtractor.extract(archivePath, packege, className, true, workingDir.getAbsolutePath()); + decompile(workingDir.getAbsolutePath(), "", className); //$NON-NLS-1$ + time = stopWatch.getTime(); + } catch (Exception e) { + exceptions.add(e); + JavaDecompilerPlugin.logError(e, e.getMessage()); + return; + } finally { + FileUtil.deltree(workingDir); + } + } + + @Override + public long getDecompilationTime() { + return time; + } + + /** + * @see IDecompiler#getLog() + */ + @Override + public String getLog() { + return log; + } + + /** + * @see IDecompiler#getSource() + */ + @Override + public String getSource() { + return source; + } + + @Override + public String getDecompilerType() { + return CfrDecompilerPlugin.decompilerType; + } + + @Override + public String removeComment(String source) { + return source; + } + + @Override + public boolean supportLevel(int level) { + return true; + } + + @Override + public boolean supportDebugLevel(int level) { + return false; // CFR does not seem to have an option to create code that matches the original + // line numbers + } + + @Override + public String getDecompilerName() { + return CfrDecompilerPlugin.decompilerType; + } + + @Override + public String getDecompilerVersion() { + return CfrDecompilerPlugin.decompilerVersion; + } } \ No newline at end of file diff --git a/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/decompiler/CfrDecompilerDescriptor.java b/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/decompiler/CfrDecompilerDescriptor.java index 4692257a..b89304d6 100644 --- a/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/decompiler/CfrDecompilerDescriptor.java +++ b/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/decompiler/CfrDecompilerDescriptor.java @@ -10,8 +10,7 @@ import org.sf.feeling.decompiler.editor.IDecompiler; import org.sf.feeling.decompiler.editor.IDecompilerDescriptor; -public class CfrDecompilerDescriptor implements IDecompilerDescriptor -{ +public class CfrDecompilerDescriptor implements IDecompilerDescriptor { private CfrDecompiler decompiler = null; @@ -20,61 +19,52 @@ public class CfrDecompilerDescriptor implements IDecompilerDescriptor private Action decompileAction = null; @Override - public String getDecompilerType( ) - { + public String getDecompilerType() { return CfrDecompilerPlugin.decompilerType; } @Override - public String getDecompilerPreferenceLabel( ) - { - return Messages.getString( "CfrDecompilerDescriptor.PreferenceLabel" ); //$NON-NLS-1$ + public String getDecompilerPreferenceLabel() { + return Messages.getString("CfrDecompilerDescriptor.PreferenceLabel"); //$NON-NLS-1$ } @Override - public IDecompiler getDecompiler( ) - { - if ( decompiler == null ) - decompiler = new CfrDecompiler( ); + public IDecompiler getDecompiler() { + if (decompiler == null) { + decompiler = new CfrDecompiler(); + } return decompiler; } @Override - public BaseDecompilerSourceMapper getDecompilerSourceMapper( ) - { - if ( sourceMapper == null ) - { - sourceMapper = new CfrSourceMapper( ); + public BaseDecompilerSourceMapper getDecompilerSourceMapper() { + if (sourceMapper == null) { + sourceMapper = new CfrSourceMapper(); } return sourceMapper; } @Override - public Action getDecompileAction( ) - { - if ( decompileAction == null ) - { - decompileAction = new DecompileWithCfrAction( ); + public Action getDecompileAction() { + if (decompileAction == null) { + decompileAction = new DecompileWithCfrAction(); } return decompileAction; } @Override - public boolean isEnabled( ) - { - return !( System.getProperty( "java.version" ).compareTo( "1.6" ) < 0 ); //$NON-NLS-1$ //$NON-NLS-2$ + public boolean isEnabled() { + return true; } @Override - public boolean isDefault( ) - { - return false; + public int getDefaultPriority() { + return 0; } @Override - public ImageDescriptor getDecompilerIcon( ) - { - return CfrDecompilerPlugin.getImageDescriptor( "icons/cfr_16.gif" ); //$NON-NLS-1$ ; + public ImageDescriptor getDecompilerIcon() { + return CfrDecompilerPlugin.getImageDescriptor("icons/cfr_16.gif"); //$NON-NLS-1$ ; } } diff --git a/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/decompiler/CfrSourceMapper.java b/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/decompiler/CfrSourceMapper.java index 5cd50d4f..ed64a118 100644 --- a/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/decompiler/CfrSourceMapper.java +++ b/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/decompiler/CfrSourceMapper.java @@ -1,75 +1,32 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.cfr.decompiler; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Collection; -import java.util.Iterator; - import org.eclipse.core.runtime.Path; +import org.sf.feeling.decompiler.cfr.CfrDecompilerPlugin; import org.sf.feeling.decompiler.editor.BaseDecompilerSourceMapper; -public class CfrSourceMapper extends BaseDecompilerSourceMapper -{ +public class CfrSourceMapper extends BaseDecompilerSourceMapper { - public CfrSourceMapper( ) - { - super( new Path( "." ), "" ); //$NON-NLS-1$ //$NON-NLS-2$ - origionalDecompiler = new CfrDecompiler( ); + public CfrSourceMapper() { + super(new Path("."), ""); //$NON-NLS-1$ //$NON-NLS-2$ + originalDecompiler = new CfrDecompiler(); } @Override - protected void printDecompileReport( StringBuffer source, String fileLocation, Collection exceptions, - long decompilationTime ) - { - String location = "\tDecompiled from: " //$NON-NLS-1$ - + fileLocation; - source.append( "\n\n/*" ); //$NON-NLS-1$ - source.append( "\n\tDECOMPILATION REPORT\n\n" ); //$NON-NLS-1$ - source.append( location ).append( "\n" ); //$NON-NLS-1$ - source.append( "\tTotal time: " ) //$NON-NLS-1$ - .append( decompilationTime ) - .append( " ms\n" ); //$NON-NLS-1$ - source.append( "\t" //$NON-NLS-1$ - + origionalDecompiler.getLog( ) - .replaceAll( "\t", "" ) //$NON-NLS-1$ //$NON-NLS-2$ - .replaceAll( "\n\\s*", "\n\t" ) ); //$NON-NLS-1$ //$NON-NLS-2$ - exceptions.addAll( origionalDecompiler.getExceptions( ) ); - logExceptions( exceptions, source ); - source.append( "\n*/" ); //$NON-NLS-1$ + protected String getDecompilerName() { + return CfrDecompilerPlugin.decompilerType; } - protected void logExceptions( Collection exceptions, StringBuffer buffer ) - { - if ( !exceptions.isEmpty( ) ) - { - buffer.append( "\n\tCaught exceptions:" ); //$NON-NLS-1$ - if ( exceptions == null || exceptions.size( ) == 0 ) - return; // nothing to do - buffer.append( "\n" ); //$NON-NLS-1$ - StringWriter stackTraces = new StringWriter( ); - PrintWriter stackTracesP = new PrintWriter( stackTraces ); - - Iterator i = exceptions.iterator( ); - while ( i.hasNext( ) ) - { - ( (Exception) i.next( ) ).printStackTrace( stackTracesP ); - stackTracesP.println( "" ); //$NON-NLS-1$ - } - - stackTracesP.flush( ); - stackTracesP.close( ); - buffer.append( stackTraces.toString( ) ); - } + @Override + protected String getDecompilerVersion() { + return CfrDecompilerPlugin.decompilerVersion; } + } \ No newline at end of file diff --git a/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/decompiler/StringDumper.java b/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/decompiler/StringDumper.java deleted file mode 100644 index aa6611a7..00000000 --- a/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/decompiler/StringDumper.java +++ /dev/null @@ -1,54 +0,0 @@ - -package org.sf.feeling.decompiler.cfr.decompiler; - -import java.io.IOException; -import java.io.StringWriter; - -import org.benf.cfr.reader.entities.Method; -import org.benf.cfr.reader.state.TypeUsageInformation; -import org.benf.cfr.reader.util.getopt.Options; -import org.benf.cfr.reader.util.output.IllegalIdentifierDump; -import org.benf.cfr.reader.util.output.StreamDumper; - -public class StringDumper extends StreamDumper -{ - - private StringWriter sw = new StringWriter( ); - - public StringDumper( TypeUsageInformation typeUsageInformation, Options options, - IllegalIdentifierDump illegalIdentifierDump ) - { - super( typeUsageInformation, options, illegalIdentifierDump ); - } - - @Override - public void addSummaryError( Method paramMethod, String paramString ) - { - - } - - @Override - public void close( ) - { - try - { - sw.close( ); - } - catch ( IOException e ) - { - throw new RuntimeException( e ); - } - } - - @Override - protected void write( String source ) - { - sw.write( source ); - } - - @Override - public String toString( ) - { - return sw.toString( ); - } -} diff --git a/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/i18n/Messages.java b/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/i18n/Messages.java index 8663770f..78cd64cb 100644 --- a/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/i18n/Messages.java +++ b/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/i18n/Messages.java @@ -1,53 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2017 Chen Chao and other ECD project contributors. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ package org.sf.feeling.decompiler.cfr.i18n; -import java.io.UnsupportedEncodingException; -import java.text.MessageFormat; -import java.util.MissingResourceException; -import java.util.ResourceBundle; +import org.sf.feeling.decompiler.i18n.EcdResouceBundle; -public class Messages -{ +public class Messages { - private static final String BUNDLE_NAME = "org.sf.feeling.decompiler.cfr.i18n.messages"; //$NON-NLS-1$ + private static final EcdResouceBundle RESOURCE_BUNDLE = new EcdResouceBundle(Messages.class); - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); - - private Messages( ) - { + private Messages() { } - public static String getString( String key ) - { - - try - { - String result = RESOURCE_BUNDLE.getString( key ); - try - { - result = new String( result.getBytes( "ISO-8859-1" ), "utf-8" ); //$NON-NLS-1$ //$NON-NLS-2$ - } - catch ( UnsupportedEncodingException e ) - { - return '!' + key + '!'; - } - return result; - } - catch ( MissingResourceException e ) - { - return '!' + key + '!'; - } + public static String getString(String key) { + return RESOURCE_BUNDLE.getString(key); } /** * Gets formatted translation for current local * - * @param key - * the key + * @param key the key * @return translated value string */ - public static String getFormattedString( String key, Object[] arguments ) - { - return MessageFormat.format( getString( key ), arguments ); + public static String getFormattedString(String key, Object[] arguments) { + return RESOURCE_BUNDLE.getFormattedString(key, arguments); } + } diff --git a/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/i18n/messages.properties b/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/i18n/messages.properties index 78454506..9bddb9ff 100644 --- a/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/i18n/messages.properties +++ b/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/i18n/messages.properties @@ -1,13 +1,10 @@ ############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). +# Copyright (c) 2017 Chen Chao and other ECD project contributors. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation +# https://www.eclipse.org/legal/epl-v10.html ############################################################################### -CfrDecompilerDescriptor.PreferenceLabel=CFR (Support JDK8) +CfrDecompilerDescriptor.PreferenceLabel=CFR (Support JDK14) JavaDecompilerActionBarContributor.Action.DecompileWithCfr=C&FR \ No newline at end of file diff --git a/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/i18n/messages_zh_CN.properties b/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/i18n/messages_zh_CN.properties deleted file mode 100644 index af2182ae..00000000 --- a/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/i18n/messages_zh_CN.properties +++ /dev/null @@ -1,13 +0,0 @@ -############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation -############################################################################### - -CfrDecompilerDescriptor.PreferenceLabel=CFR (支æŒJDK8) -JavaDecompilerActionBarContributor.Action.DecompileWithCfr=C&FR diff --git a/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/i18n/messages_zh_HK.properties b/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/i18n/messages_zh_HK.properties deleted file mode 100644 index af2182ae..00000000 --- a/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/i18n/messages_zh_HK.properties +++ /dev/null @@ -1,13 +0,0 @@ -############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation -############################################################################### - -CfrDecompilerDescriptor.PreferenceLabel=CFR (支æŒJDK8) -JavaDecompilerActionBarContributor.Action.DecompileWithCfr=C&FR diff --git a/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/i18n/messages_zh_TW.properties b/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/i18n/messages_zh_TW.properties deleted file mode 100644 index af2182ae..00000000 --- a/org.sf.feeling.decompiler.cfr/src/org/sf/feeling/decompiler/cfr/i18n/messages_zh_TW.properties +++ /dev/null @@ -1,13 +0,0 @@ -############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation -############################################################################### - -CfrDecompilerDescriptor.PreferenceLabel=CFR (支æŒJDK8) -JavaDecompilerActionBarContributor.Action.DecompileWithCfr=C&FR diff --git a/org.sf.feeling.decompiler.feature/.settings/org.eclipse.core.resources.prefs b/org.sf.feeling.decompiler.feature/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000..4824b802 --- /dev/null +++ b/org.sf.feeling.decompiler.feature/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/org.sf.feeling.decompiler.feature/.settings/org.eclipse.core.runtime.prefs b/org.sf.feeling.decompiler.feature/.settings/org.eclipse.core.runtime.prefs new file mode 100644 index 00000000..f8a67de1 --- /dev/null +++ b/org.sf.feeling.decompiler.feature/.settings/org.eclipse.core.runtime.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +line.separator=\r\n diff --git a/org.sf.feeling.decompiler.feature/build.properties b/org.sf.feeling.decompiler.feature/build.properties index 2ed3f033..40b08e1e 100644 --- a/org.sf.feeling.decompiler.feature/build.properties +++ b/org.sf.feeling.decompiler.feature/build.properties @@ -1,6 +1,5 @@ -bin.includes = feature.xml,\ - eclipse_update_120.jpg,\ - epl-v10.html,\ - feature.properties,\ - license.html -qualifier = 20170815 \ No newline at end of file +bin.includes = feature.xml,\ + eclipse_update_120.jpg,\ + epl-v10.html,\ + feature.properties,\ + license.html \ No newline at end of file diff --git a/org.sf.feeling.decompiler.feature/feature.properties b/org.sf.feeling.decompiler.feature/feature.properties index 0749a12a..3c2be1c5 100644 --- a/org.sf.feeling.decompiler.feature/feature.properties +++ b/org.sf.feeling.decompiler.feature/feature.properties @@ -1,12 +1,9 @@ ############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). +# Copyright (c) 2017 Chen Chao and other ECD project contributors. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation +# https://www.eclipse.org/legal/epl-v10.html ############################################################################### # feature.properties @@ -16,21 +13,21 @@ # This file should be translated. # "featureName" property - name of the feature -featureName=Eclipse Class Decompiler (Core) +featureName=Enhanced Class Decompiler (Core) # "providerName" property - name of the company that provides the feature -providerName=Chen Chao +providerName=ECD project contributors # "updateSiteName" property - label for the update site -updateSiteName=Eclipse Class Decompiler Updates +updateSiteName=Enhanced Class Decompiler Updates # "description" property - description of the feature -description=Eclipse Class Decompiler integrates JD, Jad, FernFlower, CFR, Procyon with Eclipse seamlessly. \ +description=Enhanced Class Decompiler integrates JD, FernFlower, Vineflower, CFR, Procyon with Eclipse seamlessly. \ It allows Java developers to debug class files without source code directly. -copyrightURL=http://www.cpupk.com/decompiler/update +copyrightURL=https://ecd-plugin.github.io -copyright=(c) Copyright 2017 Chen Chao(cnfree2000@hotmail.com). All rights reserved.\n +copyright=(c) Copyright 2017 Chen Chao and other ECD project contributors. All rights reserved.\n # "licenseURL" property - URL of the "Feature License" # do not translate value - just change to point to a locale-specific HTML page @@ -43,93 +40,681 @@ aboutURL=about.html # "license" property - text of the "Feature Update License" # should be plain text version of license agreement pointed to be "licenseURL" license=\ -ECLIPSE FOUNDATION SOFTWARE USER AGREEMENT\n\ -January 28, 2004\n\ -\n\ -Usage Of Content\n\ -\n\ -THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\ -OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\ -USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\ -AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\ -NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU\n\ -AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\ -AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\ -OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\ -TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\ -OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\ -BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\ -\n\ -Applicable Licenses\n\ -\n\ -Unless otherwise indicated, all Content made available by the Eclipse Foundation\n\ -is provided to you under the terms and conditions of the Eclipse Public\n\ -License Version 1.0 ("EPL"). A copy of the EPL is provided with this\n\ -Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\ -For purposes of the EPL, "Program" will mean the Content.\n\ -\n\ -Content includes, but is not limited to, source code, object code,\n\ -documentation and other files maintained in the Eclipse.org CVS\n\ -repository ("Repository") in CVS modules ("Modules") and made available\n\ -as downloadable archives ("Downloads").\n\ -\n\ -Content may be apportioned into plug-ins ("Plug-ins"), plug-in fragments\n\ -("Fragments"), and features ("Features"). A Feature is a bundle of one or\n\ -more Plug-ins and/or Fragments and associated material. Files named\n\ -"feature.xml" may contain a list of the names and version numbers of the\n\ -Plug-ins and/or Fragments associated with a Feature. Plug-ins and Fragments\n\ -are located in directories named "plugins" and Features are located in\n\ -directories named "features".\n\ -\n\ -Features may also include other Features ("Included Features"). Files named\n\ -"feature.xml" may contain a list of the names and version numbers of\n\ -Included Features.\n\ -\n\ -The terms and conditions governing Plug-ins and Fragments should be\n\ -contained in files named "about.html" ("Abouts"). The terms and\n\ -conditions governing Features and Included Features should be contained\n\ -in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\ -Licenses may be located in any directory of a Download or Module\n\ -including, but not limited to the following locations:\n\ -\n\ - - The top-level (root) directory\n\ - - Plug-in and Fragment directories\n\ - - Subdirectories of the directory named "src" of certain Plug-ins\n\ - - Feature directories\n\ -\n\ -Note: if a Feature made available by the Eclipse Foundation is installed using the\n\ -Eclipse Update Manager, you must agree to a license ("Feature Update\n\ -License") during the installation process. If the Feature contains\n\ -Included Features, the Feature Update License should either provide you\n\ -with the terms and conditions governing the Included Features or inform\n\ -you where you can locate them. Feature Update Licenses may be found in\n\ -the "license" property of files named "feature.properties". Such Abouts,\n\ -Feature Licenses and Feature Update Licenses contain the terms and\n\ -conditions (or references to such terms and conditions) that govern your\n\ -use of the associated Content in that directory.\n\ -\n\ -THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER\n\ -TO THE CPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\ -SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\ -\n\ - - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\ - - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\ - - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\ - - IBM Public License 1.0 (available at http://oss.software.ibm.com/developerworks/opensource/license10.html)\n\ - - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\ - - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\ -\n\ -IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\ -TO USE OF THE CONTENT. If no About, Feature License or Feature Update License\n\ -is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\ -govern that particular Content.\n\ -\n\ -Cryptography\n\ -\n\ -Content may contain encryption software. The country in which you are\n\ -currently may have restrictions on the import, possession, and use,\n\ -and/or re-export to another country, of encryption software. BEFORE\n\ -using any encryption software, please check the country's laws,\n\ -regulations and policies concerning the import, possession, or use,\n\ -and re-export of encryption software, to see if this is permitted.\n -########### end of license property ########################################## \ No newline at end of file + GNU GENERAL PUBLIC LICENSE\n\ +\n\ + Version 3, 29 June 2007\n\ +\n\ + Copyright (C) 2007 Free Software Foundation, Inc. \n\ + Everyone is permitted to copy and distribute verbatim copies\n\ + of this license document, but changing it is not allowed.\n\ +\n\ + Preamble\n\ +\n\ + The GNU General Public License is a free, copyleft license for\n\ +software and other kinds of works.\n\ +\n\ + The licenses for most software and other practical works are designed\n\ +to take away your freedom to share and change the works. By contrast,\n\ +the GNU General Public License is intended to guarantee your freedom to\n\ +share and change all versions of a program--to make sure it remains free\n\ +software for all its users. We, the Free Software Foundation, use the\n\ +GNU General Public License for most of our software; it applies also to\n\ +any other work released this way by its authors. You can apply it to\n\ +your programs, too.\n\ +\n\ + When we speak of free software, we are referring to freedom, not\n\ +price. Our General Public Licenses are designed to make sure that you\n\ +have the freedom to distribute copies of free software (and charge for\n\ +them if you wish), that you receive source code or can get it if you\n\ +want it, that you can change the software or use pieces of it in new\n\ +free programs, and that you know you can do these things.\n\ +\n\ + To protect your rights, we need to prevent others from denying you\n\ +these rights or asking you to surrender the rights. Therefore, you have\n\ +certain responsibilities if you distribute copies of the software, or if\n\ +you modify it: responsibilities to respect the freedom of others.\n\ +\n\ + For example, if you distribute copies of such a program, whether\n\ +gratis or for a fee, you must pass on to the recipients the same\n\ +freedoms that you received. You must make sure that they, too, receive\n\ +or can get the source code. And you must show them these terms so they\n\ +know their rights.\n\ +\n\ + Developers that use the GNU GPL protect your rights with two steps:\n\ +(1) assert copyright on the software, and (2) offer you this License\n\ +giving you legal permission to copy, distribute and/or modify it.\n\ +\n\ + For the developers' and authors' protection, the GPL clearly explains\n\ +that there is no warranty for this free software. For both users' and\n\ +authors' sake, the GPL requires that modified versions be marked as\n\ +changed, so that their problems will not be attributed erroneously to\n\ +authors of previous versions.\n\ +\n\ + Some devices are designed to deny users access to install or run\n\ +modified versions of the software inside them, although the manufacturer\n\ +can do so. This is fundamentally incompatible with the aim of\n\ +protecting users' freedom to change the software. The systematic\n\ +pattern of such abuse occurs in the area of products for individuals to\n\ +use, which is precisely where it is most unacceptable. Therefore, we\n\ +have designed this version of the GPL to prohibit the practice for those\n\ +products. If such problems arise substantially in other domains, we\n\ +stand ready to extend this provision to those domains in future versions\n\ +of the GPL, as needed to protect the freedom of users.\n\ +\n\ + Finally, every program is threatened constantly by software patents.\n\ +States should not allow patents to restrict development and use of\n\ +software on general-purpose computers, but in those that do, we wish to\n\ +avoid the special danger that patents applied to a free program could\n\ +make it effectively proprietary. To prevent this, the GPL assures that\n\ +patents cannot be used to render the program non-free.\n\ +\n\ + The precise terms and conditions for copying, distribution and\n\ +modification follow.\n\ +\n\ + TERMS AND CONDITIONS\n\ +\n\ + 0. Definitions.\n\ +\n\ + "This License" refers to version 3 of the GNU General Public License.\n\ +\n\ + "Copyright" also means copyright-like laws that apply to other kinds of\n\ +works, such as semiconductor masks.\n\ +\n\ + "The Program" refers to any copyrightable work licensed under this\n\ +License. Each licensee is addressed as "you". "Licensees" and\n\ +"recipients" may be individuals or organizations.\n\ +\n\ + To "modify" a work means to copy from or adapt all or part of the work\n\ +in a fashion requiring copyright permission, other than the making of an\n\ +exact copy. The resulting work is called a "modified version" of the\n\ +earlier work or a work "based on" the earlier work.\n\ +\n\ + A "covered work" means either the unmodified Program or a work based\n\ +on the Program.\n\ +\n\ + To "propagate" a work means to do anything with it that, without\n\ +permission, would make you directly or secondarily liable for\n\ +infringement under applicable copyright law, except executing it on a\n\ +computer or modifying a private copy. Propagation includes copying,\n\ +distribution (with or without modification), making available to the\n\ +public, and in some countries other activities as well.\n\ +\n\ + To "convey" a work means any kind of propagation that enables other\n\ +parties to make or receive copies. Mere interaction with a user through\n\ +a computer network, with no transfer of a copy, is not conveying.\n\ +\n\ + An interactive user interface displays "Appropriate Legal Notices"\n\ +to the extent that it includes a convenient and prominently visible\n\ +feature that (1) displays an appropriate copyright notice, and (2)\n\ +tells the user that there is no warranty for the work (except to the\n\ +extent that warranties are provided), that licensees may convey the\n\ +work under this License, and how to view a copy of this License. If\n\ +the interface presents a list of user commands or options, such as a\n\ +menu, a prominent item in the list meets this criterion.\n\ +\n\ + 1. Source Code.\n\ +\n\ + The "source code" for a work means the preferred form of the work\n\ +for making modifications to it. "Object code" means any non-source\n\ +form of a work.\n\ +\n\ + A "Standard Interface" means an interface that either is an official\n\ +standard defined by a recognized standards body, or, in the case of\n\ +interfaces specified for a particular programming language, one that\n\ +is widely used among developers working in that language.\n\ +\n\ + The "System Libraries" of an executable work include anything, other\n\ +than the work as a whole, that (a) is included in the normal form of\n\ +packaging a Major Component, but which is not part of that Major\n\ +Component, and (b) serves only to enable use of the work with that\n\ +Major Component, or to implement a Standard Interface for which an\n\ +implementation is available to the public in source code form. A\n\ +"Major Component", in this context, means a major essential component\n\ +(kernel, window system, and so on) of the specific operating system\n\ +(if any) on which the executable work runs, or a compiler used to\n\ +produce the work, or an object code interpreter used to run it.\n\ +\n\ + The "Corresponding Source" for a work in object code form means all\n\ +the source code needed to generate, install, and (for an executable\n\ +work) run the object code and to modify the work, including scripts to\n\ +control those activities. However, it does not include the work's\n\ +System Libraries, or general-purpose tools or generally available free\n\ +programs which are used unmodified in performing those activities but\n\ +which are not part of the work. For example, Corresponding Source\n\ +includes interface definition files associated with source files for\n\ +the work, and the source code for shared libraries and dynamically\n\ +linked subprograms that the work is specifically designed to require,\n\ +such as by intimate data communication or control flow between those\n\ +subprograms and other parts of the work.\n\ +\n\ + The Corresponding Source need not include anything that users\n\ +can regenerate automatically from other parts of the Corresponding\n\ +Source.\n\ +\n\ + The Corresponding Source for a work in source code form is that\n\ +same work.\n\ +\n\ + 2. Basic Permissions.\n\ +\n\ + All rights granted under this License are granted for the term of\n\ +copyright on the Program, and are irrevocable provided the stated\n\ +conditions are met. This License explicitly affirms your unlimited\n\ +permission to run the unmodified Program. The output from running a\n\ +covered work is covered by this License only if the output, given its\n\ +content, constitutes a covered work. This License acknowledges your\n\ +rights of fair use or other equivalent, as provided by copyright law.\n\ +\n\ + You may make, run and propagate covered works that you do not\n\ +convey, without conditions so long as your license otherwise remains\n\ +in force. You may convey covered works to others for the sole purpose\n\ +of having them make modifications exclusively for you, or provide you\n\ +with facilities for running those works, provided that you comply with\n\ +the terms of this License in conveying all material for which you do\n\ +not control copyright. Those thus making or running the covered works\n\ +for you must do so exclusively on your behalf, under your direction\n\ +and control, on terms that prohibit them from making any copies of\n\ +your copyrighted material outside their relationship with you.\n\ +\n\ + Conveying under any other circumstances is permitted solely under\n\ +the conditions stated below. Sublicensing is not allowed; section 10\n\ +makes it unnecessary.\n\ +\n\ + 3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\ +\n\ + No covered work shall be deemed part of an effective technological\n\ +measure under any applicable law fulfilling obligations under article\n\ +11 of the WIPO copyright treaty adopted on 20 December 1996, or\n\ +similar laws prohibiting or restricting circumvention of such\n\ +measures.\n\ +\n\ + When you convey a covered work, you waive any legal power to forbid\n\ +circumvention of technological measures to the extent such circumvention\n\ +is effected by exercising rights under this License with respect to\n\ +the covered work, and you disclaim any intention to limit operation or\n\ +modification of the work as a means of enforcing, against the work's\n\ +users, your or third parties' legal rights to forbid circumvention of\n\ +technological measures.\n\ +\n\ + 4. Conveying Verbatim Copies.\n\ +\n\ + You may convey verbatim copies of the Program's source code as you\n\ +receive it, in any medium, provided that you conspicuously and\n\ +appropriately publish on each copy an appropriate copyright notice;\n\ +keep intact all notices stating that this License and any\n\ +non-permissive terms added in accord with section 7 apply to the code;\n\ +keep intact all notices of the absence of any warranty; and give all\n\ +recipients a copy of this License along with the Program.\n\ +\n\ + You may charge any price or no price for each copy that you convey,\n\ +and you may offer support or warranty protection for a fee.\n\ +\n\ + 5. Conveying Modified Source Versions.\n\ +\n\ + You may convey a work based on the Program, or the modifications to\n\ +produce it from the Program, in the form of source code under the\n\ +terms of section 4, provided that you also meet all of these conditions:\n\ +\n\ + a) The work must carry prominent notices stating that you modified\n\ + it, and giving a relevant date.\n\ +\n\ + b) The work must carry prominent notices stating that it is\n\ + released under this License and any conditions added under section\n\ + 7. This requirement modifies the requirement in section 4 to\n\ + "keep intact all notices".\n\ +\n\ + c) You must license the entire work, as a whole, under this\n\ + License to anyone who comes into possession of a copy. This\n\ + License will therefore apply, along with any applicable section 7\n\ + additional terms, to the whole of the work, and all its parts,\n\ + regardless of how they are packaged. This License gives no\n\ + permission to license the work in any other way, but it does not\n\ + invalidate such permission if you have separately received it.\n\ +\n\ + d) If the work has interactive user interfaces, each must display\n\ + Appropriate Legal Notices; however, if the Program has interactive\n\ + interfaces that do not display Appropriate Legal Notices, your\n\ + work need not make them do so.\n\ +\n\ + A compilation of a covered work with other separate and independent\n\ +works, which are not by their nature extensions of the covered work,\n\ +and which are not combined with it such as to form a larger program,\n\ +in or on a volume of a storage or distribution medium, is called an\n\ +"aggregate" if the compilation and its resulting copyright are not\n\ +used to limit the access or legal rights of the compilation's users\n\ +beyond what the individual works permit. Inclusion of a covered work\n\ +in an aggregate does not cause this License to apply to the other\n\ +parts of the aggregate.\n\ +\n\ + 6. Conveying Non-Source Forms.\n\ +\n\ + You may convey a covered work in object code form under the terms\n\ +of sections 4 and 5, provided that you also convey the\n\ +machine-readable Corresponding Source under the terms of this License,\n\ +in one of these ways:\n\ +\n\ + a) Convey the object code in, or embodied in, a physical product\n\ + (including a physical distribution medium), accompanied by the\n\ + Corresponding Source fixed on a durable physical medium\n\ + customarily used for software interchange.\n\ +\n\ + b) Convey the object code in, or embodied in, a physical product\n\ + (including a physical distribution medium), accompanied by a\n\ + written offer, valid for at least three years and valid for as\n\ + long as you offer spare parts or customer support for that product\n\ + model, to give anyone who possesses the object code either (1) a\n\ + copy of the Corresponding Source for all the software in the\n\ + product that is covered by this License, on a durable physical\n\ + medium customarily used for software interchange, for a price no\n\ + more than your reasonable cost of physically performing this\n\ + conveying of source, or (2) access to copy the\n\ + Corresponding Source from a network server at no charge.\n\ +\n\ + c) Convey individual copies of the object code with a copy of the\n\ + written offer to provide the Corresponding Source. This\n\ + alternative is allowed only occasionally and noncommercially, and\n\ + only if you received the object code with such an offer, in accord\n\ + with subsection 6b.\n\ +\n\ + d) Convey the object code by offering access from a designated\n\ + place (gratis or for a charge), and offer equivalent access to the\n\ + Corresponding Source in the same way through the same place at no\n\ + further charge. You need not require recipients to copy the\n\ + Corresponding Source along with the object code. If the place to\n\ + copy the object code is a network server, the Corresponding Source\n\ + may be on a different server (operated by you or a third party)\n\ + that supports equivalent copying facilities, provided you maintain\n\ + clear directions next to the object code saying where to find the\n\ + Corresponding Source. Regardless of what server hosts the\n\ + Corresponding Source, you remain obligated to ensure that it is\n\ + available for as long as needed to satisfy these requirements.\n\ +\n\ + e) Convey the object code using peer-to-peer transmission, provided\n\ + you inform other peers where the object code and Corresponding\n\ + Source of the work are being offered to the general public at no\n\ + charge under subsection 6d.\n\ +\n\ + A separable portion of the object code, whose source code is excluded\n\ +from the Corresponding Source as a System Library, need not be\n\ +included in conveying the object code work.\n\ +\n\ + A "User Product" is either (1) a "consumer product", which means any\n\ +tangible personal property which is normally used for personal, family,\n\ +or household purposes, or (2) anything designed or sold for incorporation\n\ +into a dwelling. In determining whether a product is a consumer product,\n\ +doubtful cases shall be resolved in favor of coverage. For a particular\n\ +product received by a particular user, "normally used" refers to a\n\ +typical or common use of that class of product, regardless of the status\n\ +of the particular user or of the way in which the particular user\n\ +actually uses, or expects or is expected to use, the product. A product\n\ +is a consumer product regardless of whether the product has substantial\n\ +commercial, industrial or non-consumer uses, unless such uses represent\n\ +the only significant mode of use of the product.\n\ +\n\ + "Installation Information" for a User Product means any methods,\n\ +procedures, authorization keys, or other information required to install\n\ +and execute modified versions of a covered work in that User Product from\n\ +a modified version of its Corresponding Source. The information must\n\ +suffice to ensure that the continued functioning of the modified object\n\ +code is in no case prevented or interfered with solely because\n\ +modification has been made.\n\ +\n\ + If you convey an object code work under this section in, or with, or\n\ +specifically for use in, a User Product, and the conveying occurs as\n\ +part of a transaction in which the right of possession and use of the\n\ +User Product is transferred to the recipient in perpetuity or for a\n\ +fixed term (regardless of how the transaction is characterized), the\n\ +Corresponding Source conveyed under this section must be accompanied\n\ +by the Installation Information. But this requirement does not apply\n\ +if neither you nor any third party retains the ability to install\n\ +modified object code on the User Product (for example, the work has\n\ +been installed in ROM).\n\ +\n\ + The requirement to provide Installation Information does not include a\n\ +requirement to continue to provide support service, warranty, or updates\n\ +for a work that has been modified or installed by the recipient, or for\n\ +the User Product in which it has been modified or installed. Access to a\n\ +network may be denied when the modification itself materially and\n\ +adversely affects the operation of the network or violates the rules and\n\ +protocols for communication across the network.\n\ +\n\ + Corresponding Source conveyed, and Installation Information provided,\n\ +in accord with this section must be in a format that is publicly\n\ +documented (and with an implementation available to the public in\n\ +source code form), and must require no special password or key for\n\ +unpacking, reading or copying.\n\ +\n\ + 7. Additional Terms.\n\ +\n\ + "Additional permissions" are terms that supplement the terms of this\n\ +License by making exceptions from one or more of its conditions.\n\ +Additional permissions that are applicable to the entire Program shall\n\ +be treated as though they were included in this License, to the extent\n\ +that they are valid under applicable law. If additional permissions\n\ +apply only to part of the Program, that part may be used separately\n\ +under those permissions, but the entire Program remains governed by\n\ +this License without regard to the additional permissions.\n\ +\n\ + When you convey a copy of a covered work, you may at your option\n\ +remove any additional permissions from that copy, or from any part of\n\ +it. (Additional permissions may be written to require their own\n\ +removal in certain cases when you modify the work.) You may place\n\ +additional permissions on material, added by you to a covered work,\n\ +for which you have or can give appropriate copyright permission.\n\ +\n\ + Notwithstanding any other provision of this License, for material you\n\ +add to a covered work, you may (if authorized by the copyright holders of\n\ +that material) supplement the terms of this License with terms:\n\ +\n\ + a) Disclaiming warranty or limiting liability differently from the\n\ + terms of sections 15 and 16 of this License; or\n\ +\n\ + b) Requiring preservation of specified reasonable legal notices or\n\ + author attributions in that material or in the Appropriate Legal\n\ + Notices displayed by works containing it; or\n\ +\n\ + c) Prohibiting misrepresentation of the origin of that material, or\n\ + requiring that modified versions of such material be marked in\n\ + reasonable ways as different from the original version; or\n\ +\n\ + d) Limiting the use for publicity purposes of names of licensors or\n\ + authors of the material; or\n\ +\n\ + e) Declining to grant rights under trademark law for use of some\n\ + trade names, trademarks, or service marks; or\n\ +\n\ + f) Requiring indemnification of licensors and authors of that\n\ + material by anyone who conveys the material (or modified versions of\n\ + it) with contractual assumptions of liability to the recipient, for\n\ + any liability that these contractual assumptions directly impose on\n\ + those licensors and authors.\n\ +\n\ + All other non-permissive additional terms are considered "further\n\ +restrictions" within the meaning of section 10. If the Program as you\n\ +received it, or any part of it, contains a notice stating that it is\n\ +governed by this License along with a term that is a further\n\ +restriction, you may remove that term. If a license document contains\n\ +a further restriction but permits relicensing or conveying under this\n\ +License, you may add to a covered work material governed by the terms\n\ +of that license document, provided that the further restriction does\n\ +not survive such relicensing or conveying.\n\ +\n\ + If you add terms to a covered work in accord with this section, you\n\ +must place, in the relevant source files, a statement of the\n\ +additional terms that apply to those files, or a notice indicating\n\ +where to find the applicable terms.\n\ +\n\ + Additional terms, permissive or non-permissive, may be stated in the\n\ +form of a separately written license, or stated as exceptions;\n\ +the above requirements apply either way.\n\ +\n\ + 8. Termination.\n\ +\n\ + You may not propagate or modify a covered work except as expressly\n\ +provided under this License. Any attempt otherwise to propagate or\n\ +modify it is void, and will automatically terminate your rights under\n\ +this License (including any patent licenses granted under the third\n\ +paragraph of section 11).\n\ +\n\ + However, if you cease all violation of this License, then your\n\ +license from a particular copyright holder is reinstated (a)\n\ +provisionally, unless and until the copyright holder explicitly and\n\ +finally terminates your license, and (b) permanently, if the copyright\n\ +holder fails to notify you of the violation by some reasonable means\n\ +prior to 60 days after the cessation.\n\ +\n\ + Moreover, your license from a particular copyright holder is\n\ +reinstated permanently if the copyright holder notifies you of the\n\ +violation by some reasonable means, this is the first time you have\n\ +received notice of violation of this License (for any work) from that\n\ +copyright holder, and you cure the violation prior to 30 days after\n\ +your receipt of the notice.\n\ +\n\ + Termination of your rights under this section does not terminate the\n\ +licenses of parties who have received copies or rights from you under\n\ +this License. If your rights have been terminated and not permanently\n\ +reinstated, you do not qualify to receive new licenses for the same\n\ +material under section 10.\n\ +\n\ + 9. Acceptance Not Required for Having Copies.\n\ +\n\ + You are not required to accept this License in order to receive or\n\ +run a copy of the Program. Ancillary propagation of a covered work\n\ +occurring solely as a consequence of using peer-to-peer transmission\n\ +to receive a copy likewise does not require acceptance. However,\n\ +nothing other than this License grants you permission to propagate or\n\ +modify any covered work. These actions infringe copyright if you do\n\ +not accept this License. Therefore, by modifying or propagating a\n\ +covered work, you indicate your acceptance of this License to do so.\n\ +\n\ + 10. Automatic Licensing of Downstream Recipients.\n\ +\n\ + Each time you convey a covered work, the recipient automatically\n\ +receives a license from the original licensors, to run, modify and\n\ +propagate that work, subject to this License. You are not responsible\n\ +for enforcing compliance by third parties with this License.\n\ +\n\ + An "entity transaction" is a transaction transferring control of an\n\ +organization, or substantially all assets of one, or subdividing an\n\ +organization, or merging organizations. If propagation of a covered\n\ +work results from an entity transaction, each party to that\n\ +transaction who receives a copy of the work also receives whatever\n\ +licenses to the work the party's predecessor in interest had or could\n\ +give under the previous paragraph, plus a right to possession of the\n\ +Corresponding Source of the work from the predecessor in interest, if\n\ +the predecessor has it or can get it with reasonable efforts.\n\ +\n\ + You may not impose any further restrictions on the exercise of the\n\ +rights granted or affirmed under this License. For example, you may\n\ +not impose a license fee, royalty, or other charge for exercise of\n\ +rights granted under this License, and you may not initiate litigation\n\ +(including a cross-claim or counterclaim in a lawsuit) alleging that\n\ +any patent claim is infringed by making, using, selling, offering for\n\ +sale, or importing the Program or any portion of it.\n\ +\n\ + 11. Patents.\n\ +\n\ + A "contributor" is a copyright holder who authorizes use under this\n\ +License of the Program or a work on which the Program is based. The\n\ +work thus licensed is called the contributor's "contributor version".\n\ +\n\ + A contributor's "essential patent claims" are all patent claims\n\ +owned or controlled by the contributor, whether already acquired or\n\ +hereafter acquired, that would be infringed by some manner, permitted\n\ +by this License, of making, using, or selling its contributor version,\n\ +but do not include claims that would be infringed only as a\n\ +consequence of further modification of the contributor version. For\n\ +purposes of this definition, "control" includes the right to grant\n\ +patent sublicenses in a manner consistent with the requirements of\n\ +this License.\n\ +\n\ + Each contributor grants you a non-exclusive, worldwide, royalty-free\n\ +patent license under the contributor's essential patent claims, to\n\ +make, use, sell, offer for sale, import and otherwise run, modify and\n\ +propagate the contents of its contributor version.\n\ +\n\ + In the following three paragraphs, a "patent license" is any express\n\ +agreement or commitment, however denominated, not to enforce a patent\n\ +(such as an express permission to practice a patent or covenant not to\n\ +sue for patent infringement). To "grant" such a patent license to a\n\ +party means to make such an agreement or commitment not to enforce a\n\ +patent against the party.\n\ +\n\ + If you convey a covered work, knowingly relying on a patent license,\n\ +and the Corresponding Source of the work is not available for anyone\n\ +to copy, free of charge and under the terms of this License, through a\n\ +publicly available network server or other readily accessible means,\n\ +then you must either (1) cause the Corresponding Source to be so\n\ +available, or (2) arrange to deprive yourself of the benefit of the\n\ +patent license for this particular work, or (3) arrange, in a manner\n\ +consistent with the requirements of this License, to extend the patent\n\ +license to downstream recipients. "Knowingly relying" means you have\n\ +actual knowledge that, but for the patent license, your conveying the\n\ +covered work in a country, or your recipient's use of the covered work\n\ +in a country, would infringe one or more identifiable patents in that\n\ +country that you have reason to believe are valid.\n\ +\n\ + If, pursuant to or in connection with a single transaction or\n\ +arrangement, you convey, or propagate by procuring conveyance of, a\n\ +covered work, and grant a patent license to some of the parties\n\ +receiving the covered work authorizing them to use, propagate, modify\n\ +or convey a specific copy of the covered work, then the patent license\n\ +you grant is automatically extended to all recipients of the covered\n\ +work and works based on it.\n\ +\n\ + A patent license is "discriminatory" if it does not include within\n\ +the scope of its coverage, prohibits the exercise of, or is\n\ +conditioned on the non-exercise of one or more of the rights that are\n\ +specifically granted under this License. You may not convey a covered\n\ +work if you are a party to an arrangement with a third party that is\n\ +in the business of distributing software, under which you make payment\n\ +to the third party based on the extent of your activity of conveying\n\ +the work, and under which the third party grants, to any of the\n\ +parties who would receive the covered work from you, a discriminatory\n\ +patent license (a) in connection with copies of the covered work\n\ +conveyed by you (or copies made from those copies), or (b) primarily\n\ +for and in connection with specific products or compilations that\n\ +contain the covered work, unless you entered into that arrangement,\n\ +or that patent license was granted, prior to 28 March 2007.\n\ +\n\ + Nothing in this License shall be construed as excluding or limiting\n\ +any implied license or other defenses to infringement that may\n\ +otherwise be available to you under applicable patent law.\n\ +\n\ + 12. No Surrender of Others' Freedom.\n\ +\n\ + If conditions are imposed on you (whether by court order, agreement or\n\ +otherwise) that contradict the conditions of this License, they do not\n\ +excuse you from the conditions of this License. If you cannot convey a\n\ +covered work so as to satisfy simultaneously your obligations under this\n\ +License and any other pertinent obligations, then as a consequence you may\n\ +not convey it at all. For example, if you agree to terms that obligate you\n\ +to collect a royalty for further conveying from those to whom you convey\n\ +the Program, the only way you could satisfy both those terms and this\n\ +License would be to refrain entirely from conveying the Program.\n\ +\n\ + 13. Use with the GNU Affero General Public License.\n\ +\n\ + Notwithstanding any other provision of this License, you have\n\ +permission to link or combine any covered work with a work licensed\n\ +under version 3 of the GNU Affero General Public License into a single\n\ +combined work, and to convey the resulting work. The terms of this\n\ +License will continue to apply to the part which is the covered work,\n\ +but the special requirements of the GNU Affero General Public License,\n\ +section 13, concerning interaction through a network will apply to the\n\ +combination as such.\n\ +\n\ + 14. Revised Versions of this License.\n\ +\n\ + The Free Software Foundation may publish revised and/or new versions of\n\ +the GNU General Public License from time to time. Such new versions will\n\ +be similar in spirit to the present version, but may differ in detail to\n\ +address new problems or concerns.\n\ +\n\ + Each version is given a distinguishing version number. If the\n\ +Program specifies that a certain numbered version of the GNU General\n\ +Public License "or any later version" applies to it, you have the\n\ +option of following the terms and conditions either of that numbered\n\ +version or of any later version published by the Free Software\n\ +Foundation. If the Program does not specify a version number of the\n\ +GNU General Public License, you may choose any version ever published\n\ +by the Free Software Foundation.\n\ +\n\ + If the Program specifies that a proxy can decide which future\n\ +versions of the GNU General Public License can be used, that proxy's\n\ +public statement of acceptance of a version permanently authorizes you\n\ +to choose that version for the Program.\n\ +\n\ + Later license versions may give you additional or different\n\ +permissions. However, no additional obligations are imposed on any\n\ +author or copyright holder as a result of your choosing to follow a\n\ +later version.\n\ +\n\ + 15. Disclaimer of Warranty.\n\ +\n\ + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\n\ +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\n\ +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY\n\ +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\n\ +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n\ +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\n\ +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\n\ +ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\ +\n\ + 16. Limitation of Liability.\n\ +\n\ + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\n\ +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\n\ +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\n\ +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\n\ +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\n\ +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\n\ +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\n\ +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\n\ +SUCH DAMAGES.\n\ +\n\ + 17. Interpretation of Sections 15 and 16.\n\ +\n\ + If the disclaimer of warranty and limitation of liability provided\n\ +above cannot be given local legal effect according to their terms,\n\ +reviewing courts shall apply local law that most closely approximates\n\ +an absolute waiver of all civil liability in connection with the\n\ +Program, unless a warranty or assumption of liability accompanies a\n\ +copy of the Program in return for a fee.\n\ +\n\ + END OF TERMS AND CONDITIONS\n\ +\n\ + How to Apply These Terms to Your New Programs\n\ +\n\ + If you develop a new program, and you want it to be of the greatest\n\ +possible use to the public, the best way to achieve this is to make it\n\ +free software which everyone can redistribute and change under these terms.\n\ +\n\ + To do so, attach the following notices to the program. It is safest\n\ +to attach them to the start of each source file to most effectively\n\ +state the exclusion of warranty; and each file should have at least\n\ +the "copyright" line and a pointer to where the full notice is found.\n\ +\n\ + JD-Eclipse is a plug-in for the Eclipse platform. It allows you to \n\ + display all the Java sources during your debugging process, even if \n\ + you do not have them all.\n\ + Copyright (C) 2008-2015 Emmanuel Dupuy\n\ +\n\ + This program is free software: you can redistribute it and/or modify\n\ + it under the terms of the GNU General Public License as published by\n\ + the Free Software Foundation, either version 3 of the License, or\n\ + (at your option) any later version.\n\ +\n\ + This program is distributed in the hope that it will be useful,\n\ + but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ + GNU General Public License for more details.\n\ +\n\ + You should have received a copy of the GNU General Public License\n\ + along with this program. If not, see .\n\ +\n\ +Also add information on how to contact you by electronic and paper mail.\n\ +\n\ + If the program does terminal interaction, make it output a short\n\ +notice like this when it starts in an interactive mode:\n\ +\n\ + JD-Eclipse Copyright (C) 2008-2015 Emmanuel Dupuy\n\ + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n\ + This is free software, and you are welcome to redistribute it\n\ + under certain conditions; type `show c' for details.\n\ +\n\ +The hypothetical commands `show w' and `show c' should show the appropriate\n\ +parts of the General Public License. Of course, your program's commands\n\ +might be different; for a GUI interface, you would use an "about box".\n\ +\n\ + You should also get your employer (if you work as a programmer) or school,\n\ +if any, to sign a "copyright disclaimer" for the program, if necessary.\n\ +For more information on this, and how to apply and follow the GNU GPL, see\n\ +.\n\ +\n\ + The GNU General Public License does not permit incorporating your program\n\ +into proprietary programs. If your program is a subroutine library, you\n\ +may consider it more useful to permit linking proprietary applications with\n\ +the library. If this is what you want to do, use the GNU Lesser General\n\ +Public License instead of this License. But first, please read\n\ +.\n +########### end of license property ########################################## diff --git a/org.sf.feeling.decompiler.feature/feature.xml b/org.sf.feeling.decompiler.feature/feature.xml index 5ddec8d8..bdd796bb 100644 --- a/org.sf.feeling.decompiler.feature/feature.xml +++ b/org.sf.feeling.decompiler.feature/feature.xml @@ -2,7 +2,7 @@ @@ -19,59 +19,38 @@ - - + + - - - - - - - - - - - - - - - + + + + + + + + - - - - diff --git a/org.sf.feeling.decompiler.feature/license.html b/org.sf.feeling.decompiler.feature/license.html index e2323dfc..87eb9824 100644 --- a/org.sf.feeling.decompiler.feature/license.html +++ b/org.sf.feeling.decompiler.feature/license.html @@ -1,73 +1,696 @@ - - - - -Eclipse.org Software User Agreement - - - -

    Eclipse Foundation Software User Agreement

    -

    January 28, 2005

    - -

    Usage Of Content

    - -

    THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS - (COLLECTIVELY "CONTENT"). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND - CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE - OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR - NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND - CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.

    - -

    Applicable Licenses

    - -

    Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0 - ("EPL"). A copy of the EPL is provided with this Content and is also available at http://www.eclipse.org/legal/epl-v10.html. - For purposes of the EPL, "Program" will mean the Content.

    - -

    Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse.org CVS repository ("Repository") in CVS - modules ("Modules") and made available as downloadable archives ("Downloads").

    - -

    Content may be apportioned into plug-ins ("Plug-ins"), plug-in fragments ("Fragments"), and features ("Features"). A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material. Files named "feature.xml" may contain a list of the names and version numbers of the Plug-ins and/or Fragments associated with a Feature. Plug-ins and Fragments are located in directories - named "plugins" and Features are located in directories named "features".

    - -

    Features may also include other Features ("Included Features"). Files named "feature.xml" may contain a list of the names and version numbers of Included Features.

    - -

    The terms and conditions governing Plug-ins and Fragments should be contained in files named "about.html" ("Abouts"). The terms and conditions governing Features and -Included Features should be contained in files named "license.html" ("Feature Licenses"). Abouts and Feature Licenses may be located in any directory of a Download or Module -including, but not limited to the following locations:

    - -
      -
    • The top-level (root) directory
    • -
    • Plug-in and Fragment directories
    • -
    • Subdirectories of the directory named "src" of certain Plug-ins
    • -
    • Feature directories
    • -
    - -

    Note: if a Feature made available by the Eclipse Foundation is installed using the Eclipse Update Manager, you must agree to a license ("Feature Update License") during the -installation process. If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or -inform you where you can locate them. Feature Update Licenses may be found in the "license" property of files named "feature.properties". -Such Abouts, Feature Licenses and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in -that directory.

    - -

    THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE -OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):

    - - - -

    IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License or Feature Update License is provided, please -contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.

    - -

    Cryptography

    - -

    Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to - another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import, - possession, or use, and re-export of encryption software, to see if this is permitted.

    - - + + + + + + GNU General Public License v3.0 - GNU Project - Free Software Foundation (FSF) + + + +

    GNU GENERAL PUBLIC LICENSE

    +

    Version 3, 29 June 2007

    + +

    Copyright © 2007 Free Software Foundation, Inc. + <https://fsf.org/>

    + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed.

    + +

    Preamble

    + +

    The GNU General Public License is a free, copyleft license for +software and other kinds of works.

    + +

    The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too.

    + +

    When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things.

    + +

    To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others.

    + +

    For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights.

    + +

    Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it.

    + +

    For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions.

    + +

    Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users.

    + +

    Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free.

    + +

    The precise terms and conditions for copying, distribution and +modification follow.

    + +

    TERMS AND CONDITIONS

    + +

    0. Definitions.

    + +

    “This License” refers to version 3 of the GNU General Public License.

    + +

    “Copyright” also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks.

    + +

    “The Program” refers to any copyrightable work licensed under this +License. Each licensee is addressed as “you”. “Licensees” and +“recipients” may be individuals or organizations.

    + +

    To “modify” a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a “modified version” of the +earlier work or a work “based on” the earlier work.

    + +

    A “covered work” means either the unmodified Program or a work based +on the Program.

    + +

    To “propagate” a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well.

    + +

    To “convey” a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying.

    + +

    An interactive user interface displays “Appropriate Legal Notices” +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion.

    + +

    1. Source Code.

    + +

    The “source code” for a work means the preferred form of the work +for making modifications to it. “Object code” means any non-source +form of a work.

    + +

    A “Standard Interface” means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language.

    + +

    The “System Libraries” of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +“Major Component”, in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it.

    + +

    The “Corresponding Source” for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work.

    + +

    The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source.

    + +

    The Corresponding Source for a work in source code form is that +same work.

    + +

    2. Basic Permissions.

    + +

    All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law.

    + +

    You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you.

    + +

    Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary.

    + +

    3. Protecting Users' Legal Rights From Anti-Circumvention Law.

    + +

    No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures.

    + +

    When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures.

    + +

    4. Conveying Verbatim Copies.

    + +

    You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program.

    + +

    You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee.

    + +

    5. Conveying Modified Source Versions.

    + +

    You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions:

    + +
      +
    • a) The work must carry prominent notices stating that you modified + it, and giving a relevant date.
    • + +
    • b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + “keep intact all notices”.
    • + +
    • c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it.
    • + +
    • d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so.
    • +
    + +

    A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +“aggregate” if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate.

    + +

    6. Conveying Non-Source Forms.

    + +

    You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways:

    + +
      +
    • a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange.
    • + +
    • b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge.
    • + +
    • c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b.
    • + +
    • d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements.
    • + +
    • e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d.
    • +
    + +

    A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work.

    + +

    A “User Product” is either (1) a “consumer product”, which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, “normally used” refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product.

    + +

    “Installation Information” for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made.

    + +

    If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM).

    + +

    The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network.

    + +

    Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying.

    + +

    7. Additional Terms.

    + +

    “Additional permissions” are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions.

    + +

    When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission.

    + +

    Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms:

    + +
      +
    • a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or
    • + +
    • b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or
    • + +
    • c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or
    • + +
    • d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or
    • + +
    • e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or
    • + +
    • f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors.
    • +
    + +

    All other non-permissive additional terms are considered “further +restrictions” within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying.

    + +

    If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms.

    + +

    Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way.

    + +

    8. Termination.

    + +

    You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11).

    + +

    However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation.

    + +

    Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice.

    + +

    Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10.

    + +

    9. Acceptance Not Required for Having Copies.

    + +

    You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so.

    + +

    10. Automatic Licensing of Downstream Recipients.

    + +

    Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License.

    + +

    An “entity transaction” is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts.

    + +

    You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it.

    + +

    11. Patents.

    + +

    A “contributor” is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's “contributor version”.

    + +

    A contributor's “essential patent claims” are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, “control” includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License.

    + +

    Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version.

    + +

    In the following three paragraphs, a “patent license” is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To “grant” such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party.

    + +

    If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. “Knowingly relying” means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid.

    + +

    If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it.

    + +

    A patent license is “discriminatory” if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007.

    + +

    Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law.

    + +

    12. No Surrender of Others' Freedom.

    + +

    If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program.

    + +

    13. Use with the GNU Affero General Public License.

    + +

    Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such.

    + +

    14. Revised Versions of this License.

    + +

    The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns.

    + +

    Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License “or any later version” applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation.

    + +

    If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program.

    + +

    Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version.

    + +

    15. Disclaimer of Warranty.

    + +

    THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

    + +

    16. Limitation of Liability.

    + +

    IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES.

    + +

    17. Interpretation of Sections 15 and 16.

    + +

    If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee.

    + +

    END OF TERMS AND CONDITIONS

    + +

    How to Apply These Terms to Your New Programs

    + +

    If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +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.

    + +
        <one line to give the program's name and a brief idea of what it does.>
    +    Copyright (C) <year>  <name of author>
    +
    +    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
    +    the Free Software Foundation, either version 3 of the License, or
    +    (at your option) any later version.
    +
    +    This program is distributed in the hope that it will be useful,
    +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    +    GNU General Public License for more details.
    +
    +    You should have received a copy of the GNU General Public License
    +    along with this program.  If not, see <https://www.gnu.org/licenses/>.
    +
    + +

    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:

    + +
        <program>  Copyright (C) <year>  <name of author>
    +    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.
    +
    + +

    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. +For more information on this, and how to apply and follow the GNU GPL, see +<https://www.gnu.org/licenses/>.

    + +

    The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<https://www.gnu.org/licenses/why-not-lgpl.html>.

    + + diff --git a/org.sf.feeling.decompiler.feature/pom.xml b/org.sf.feeling.decompiler.feature/pom.xml new file mode 100644 index 00000000..9fb8c282 --- /dev/null +++ b/org.sf.feeling.decompiler.feature/pom.xml @@ -0,0 +1,15 @@ + + 4.0.0 + + + com.github.ecd-plugin + com.github.ecd-plugin.ecd + 3.5.1 + ../pom.xml + + + com.github.ecd-plugin.features + org.sf.feeling.decompiler + eclipse-feature + diff --git a/org.sf.feeling.decompiler.jad.feature/.project b/org.sf.feeling.decompiler.fernflower.feature/.project similarity index 83% rename from org.sf.feeling.decompiler.jad.feature/.project rename to org.sf.feeling.decompiler.fernflower.feature/.project index 75a86a2f..1951cddb 100644 --- a/org.sf.feeling.decompiler.jad.feature/.project +++ b/org.sf.feeling.decompiler.fernflower.feature/.project @@ -1,17 +1,17 @@ - - - org.sf.feeling.decompiler.jad.feature - - - - - - org.eclipse.pde.FeatureBuilder - - - - - - org.eclipse.pde.FeatureNature - - + + + org.sf.feeling.decompiler.fernflower.feature + + + + + + org.eclipse.pde.FeatureBuilder + + + + + + org.eclipse.pde.FeatureNature + + diff --git a/org.sf.feeling.decompiler.fernflower.feature/.settings/org.eclipse.core.resources.prefs b/org.sf.feeling.decompiler.fernflower.feature/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000..99f26c02 --- /dev/null +++ b/org.sf.feeling.decompiler.fernflower.feature/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/org.sf.feeling.decompiler.fernflower.feature/.settings/org.eclipse.core.runtime.prefs b/org.sf.feeling.decompiler.fernflower.feature/.settings/org.eclipse.core.runtime.prefs new file mode 100644 index 00000000..deae05a9 --- /dev/null +++ b/org.sf.feeling.decompiler.fernflower.feature/.settings/org.eclipse.core.runtime.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +line.separator=\r\n diff --git a/org.sf.feeling.decompiler.jad.feature/build.properties b/org.sf.feeling.decompiler.fernflower.feature/build.properties similarity index 71% rename from org.sf.feeling.decompiler.jad.feature/build.properties rename to org.sf.feeling.decompiler.fernflower.feature/build.properties index 2ed3f033..40b08e1e 100644 --- a/org.sf.feeling.decompiler.jad.feature/build.properties +++ b/org.sf.feeling.decompiler.fernflower.feature/build.properties @@ -1,6 +1,5 @@ -bin.includes = feature.xml,\ - eclipse_update_120.jpg,\ - epl-v10.html,\ - feature.properties,\ - license.html -qualifier = 20170815 \ No newline at end of file +bin.includes = feature.xml,\ + eclipse_update_120.jpg,\ + epl-v10.html,\ + feature.properties,\ + license.html \ No newline at end of file diff --git a/org.sf.feeling.decompiler.jad.feature/eclipse_update_120.jpg b/org.sf.feeling.decompiler.fernflower.feature/eclipse_update_120.jpg similarity index 100% rename from org.sf.feeling.decompiler.jad.feature/eclipse_update_120.jpg rename to org.sf.feeling.decompiler.fernflower.feature/eclipse_update_120.jpg diff --git a/org.sf.feeling.decompiler.jad.feature/epl-v10.html b/org.sf.feeling.decompiler.fernflower.feature/epl-v10.html similarity index 98% rename from org.sf.feeling.decompiler.jad.feature/epl-v10.html rename to org.sf.feeling.decompiler.fernflower.feature/epl-v10.html index 90f2d5ea..ed4b1966 100644 --- a/org.sf.feeling.decompiler.jad.feature/epl-v10.html +++ b/org.sf.feeling.decompiler.fernflower.feature/epl-v10.html @@ -1,328 +1,328 @@ - - - - - - - - -Eclipse Public License - Version 1.0 - - - - - - -
    - -

    Eclipse Public License - v 1.0 -

    - -

    THE ACCOMPANYING PROGRAM IS PROVIDED UNDER -THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, -REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE -OF THIS AGREEMENT.

    - -

    1. DEFINITIONS

    - -

    "Contribution" means:

    - -

    a) -in the case of the initial Contributor, the initial code and documentation -distributed under this Agreement, and
    -b) in the case of each subsequent Contributor:

    - -

    i) -changes to the Program, and

    - -

    ii) -additions to the Program;

    - -

    where -such changes and/or additions to the Program originate from and are distributed -by that particular Contributor. A Contribution 'originates' from a Contributor -if it was added to the Program by such Contributor itself or anyone acting on -such Contributor's behalf. Contributions do not include additions to the -Program which: (i) are separate modules of software distributed in conjunction -with the Program under their own license agreement, and (ii) are not derivative -works of the Program.

    - -

    "Contributor" means any person or -entity that distributes the Program.

    - -

    "Licensed Patents " mean patent -claims licensable by a Contributor which are necessarily infringed by the use -or sale of its Contribution alone or when combined with the Program.

    - -

    "Program" means the Contributions -distributed in accordance with this Agreement.

    - -

    "Recipient" means anyone who -receives the Program under this Agreement, including all Contributors.

    - -

    2. GRANT OF RIGHTS

    - -

    a) -Subject to the terms of this Agreement, each Contributor hereby grants Recipient -a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly -display, publicly perform, distribute and sublicense the Contribution of such -Contributor, if any, and such derivative works, in source code and object code -form.

    - -

    b) -Subject to the terms of this Agreement, each Contributor hereby grants -Recipient a non-exclusive, worldwide, royalty-free -patent license under Licensed Patents to make, use, sell, offer to sell, import -and otherwise transfer the Contribution of such Contributor, if any, in source -code and object code form. This patent license shall apply to the combination -of the Contribution and the Program if, at the time the Contribution is added -by the Contributor, such addition of the Contribution causes such combination -to be covered by the Licensed Patents. The patent license shall not apply to -any other combinations which include the Contribution. No hardware per se is -licensed hereunder.

    - -

    c) -Recipient understands that although each Contributor grants the licenses to its -Contributions set forth herein, no assurances are provided by any Contributor -that the Program does not infringe the patent or other intellectual property -rights of any other entity. Each Contributor disclaims any liability to Recipient -for claims brought by any other entity based on infringement of intellectual -property rights or otherwise. As a condition to exercising the rights and -licenses granted hereunder, each Recipient hereby assumes sole responsibility -to secure any other intellectual property rights needed, if any. For example, -if a third party patent license is required to allow Recipient to distribute -the Program, it is Recipient's responsibility to acquire that license before -distributing the Program.

    - -

    d) -Each Contributor represents that to its knowledge it has sufficient copyright -rights in its Contribution, if any, to grant the copyright license set forth in -this Agreement.

    - -

    3. REQUIREMENTS

    - -

    A Contributor may choose to distribute the -Program in object code form under its own license agreement, provided that: -

    - -

    a) -it complies with the terms and conditions of this Agreement; and

    - -

    b) -its license agreement:

    - -

    i) -effectively disclaims on behalf of all Contributors all warranties and -conditions, express and implied, including warranties or conditions of title -and non-infringement, and implied warranties or conditions of merchantability -and fitness for a particular purpose;

    - -

    ii) -effectively excludes on behalf of all Contributors all liability for damages, -including direct, indirect, special, incidental and consequential damages, such -as lost profits;

    - -

    iii) -states that any provisions which differ from this Agreement are offered by that -Contributor alone and not by any other party; and

    - -

    iv) -states that source code for the Program is available from such Contributor, and -informs licensees how to obtain it in a reasonable manner on or through a -medium customarily used for software exchange.

    - -

    When the Program is made available in source -code form:

    - -

    a) -it must be made available under this Agreement; and

    - -

    b) a -copy of this Agreement must be included with each copy of the Program.

    - -

    Contributors may not remove or alter any -copyright notices contained within the Program.

    - -

    Each Contributor must identify itself as the -originator of its Contribution, if any, in a manner that reasonably allows -subsequent Recipients to identify the originator of the Contribution.

    - -

    4. COMMERCIAL DISTRIBUTION

    - -

    Commercial distributors of software may -accept certain responsibilities with respect to end users, business partners -and the like. While this license is intended to facilitate the commercial use -of the Program, the Contributor who includes the Program in a commercial -product offering should do so in a manner which does not create potential -liability for other Contributors. Therefore, if a Contributor includes the -Program in a commercial product offering, such Contributor ("Commercial -Contributor") hereby agrees to defend and indemnify every other -Contributor ("Indemnified Contributor") against any losses, damages and -costs (collectively "Losses") arising from claims, lawsuits and other -legal actions brought by a third party against the Indemnified Contributor to -the extent caused by the acts or omissions of such Commercial Contributor in -connection with its distribution of the Program in a commercial product -offering. The obligations in this section do not apply to any claims or Losses -relating to any actual or alleged intellectual property infringement. In order -to qualify, an Indemnified Contributor must: a) promptly notify the Commercial -Contributor in writing of such claim, and b) allow the Commercial Contributor -to control, and cooperate with the Commercial Contributor in, the defense and -any related settlement negotiations. The Indemnified Contributor may participate -in any such claim at its own expense.

    - -

    For example, a Contributor might include the -Program in a commercial product offering, Product X. That Contributor is then a -Commercial Contributor. If that Commercial Contributor then makes performance -claims, or offers warranties related to Product X, those performance claims and -warranties are such Commercial Contributor's responsibility alone. Under this -section, the Commercial Contributor would have to defend claims against the -other Contributors related to those performance claims and warranties, and if a -court requires any other Contributor to pay any damages as a result, the -Commercial Contributor must pay those damages.

    - -

    5. NO WARRANTY

    - -

    EXCEPT AS EXPRESSLY SET FORTH IN THIS -AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, -WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, -MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely -responsible for determining the appropriateness of using and distributing the -Program and assumes all risks associated with its exercise of rights under this -Agreement , including but not limited to the risks and costs of program errors, -compliance with applicable laws, damage to or loss of data, programs or -equipment, and unavailability or interruption of operations.

    - -

    6. DISCLAIMER OF LIABILITY

    - -

    EXCEPT AS EXPRESSLY SET FORTH IN THIS -AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY -OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF -THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF -THE POSSIBILITY OF SUCH DAMAGES.

    - -

    7. GENERAL

    - -

    If any provision of this Agreement is invalid -or unenforceable under applicable law, it shall not affect the validity or -enforceability of the remainder of the terms of this Agreement, and without -further action by the parties hereto, such provision shall be reformed to the -minimum extent necessary to make such provision valid and enforceable.

    - -

    If Recipient institutes patent litigation -against any entity (including a cross-claim or counterclaim in a lawsuit) -alleging that the Program itself (excluding combinations of the Program with -other software or hardware) infringes such Recipient's patent(s), then such -Recipient's rights granted under Section 2(b) shall terminate as of the date -such litigation is filed.

    - -

    All Recipient's rights under this Agreement -shall terminate if it fails to comply with any of the material terms or -conditions of this Agreement and does not cure such failure in a reasonable -period of time after becoming aware of such noncompliance. If all Recipient's -rights under this Agreement terminate, Recipient agrees to cease use and -distribution of the Program as soon as reasonably practicable. However, -Recipient's obligations under this Agreement and any licenses granted by -Recipient relating to the Program shall continue and survive.

    - -

    Everyone is permitted to copy and distribute -copies of this Agreement, but in order to avoid inconsistency the Agreement is -copyrighted and may only be modified in the following manner. The Agreement -Steward reserves the right to publish new versions (including revisions) of -this Agreement from time to time. No one other than the Agreement Steward has -the right to modify this Agreement. The Eclipse Foundation is the initial -Agreement Steward. The Eclipse Foundation may assign the responsibility to -serve as the Agreement Steward to a suitable separate entity. Each new version -of the Agreement will be given a distinguishing version number. The Program -(including Contributions) may always be distributed subject to the version of -the Agreement under which it was received. In addition, after a new version of -the Agreement is published, Contributor may elect to distribute the Program -(including its Contributions) under the new version. Except as expressly stated -in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to -the intellectual property of any Contributor under this Agreement, whether -expressly, by implication, estoppel or otherwise. All rights in the Program not -expressly granted under this Agreement are reserved.

    - -

    This Agreement is governed by the laws of the -State of New York and the intellectual property laws of the United States of -America. No party to this Agreement will bring a legal action under this -Agreement more than one year after the cause of action arose. Each party waives -its rights to a jury trial in any resulting litigation.

    - -

     

    - -
    - - - + + + + + + + + +Eclipse Public License - Version 1.0 + + + + + + +
    + +

    Eclipse Public License - v 1.0 +

    + +

    THE ACCOMPANYING PROGRAM IS PROVIDED UNDER +THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, +REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE +OF THIS AGREEMENT.

    + +

    1. DEFINITIONS

    + +

    "Contribution" means:

    + +

    a) +in the case of the initial Contributor, the initial code and documentation +distributed under this Agreement, and
    +b) in the case of each subsequent Contributor:

    + +

    i) +changes to the Program, and

    + +

    ii) +additions to the Program;

    + +

    where +such changes and/or additions to the Program originate from and are distributed +by that particular Contributor. A Contribution 'originates' from a Contributor +if it was added to the Program by such Contributor itself or anyone acting on +such Contributor's behalf. Contributions do not include additions to the +Program which: (i) are separate modules of software distributed in conjunction +with the Program under their own license agreement, and (ii) are not derivative +works of the Program.

    + +

    "Contributor" means any person or +entity that distributes the Program.

    + +

    "Licensed Patents " mean patent +claims licensable by a Contributor which are necessarily infringed by the use +or sale of its Contribution alone or when combined with the Program.

    + +

    "Program" means the Contributions +distributed in accordance with this Agreement.

    + +

    "Recipient" means anyone who +receives the Program under this Agreement, including all Contributors.

    + +

    2. GRANT OF RIGHTS

    + +

    a) +Subject to the terms of this Agreement, each Contributor hereby grants Recipient +a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly +display, publicly perform, distribute and sublicense the Contribution of such +Contributor, if any, and such derivative works, in source code and object code +form.

    + +

    b) +Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide, royalty-free +patent license under Licensed Patents to make, use, sell, offer to sell, import +and otherwise transfer the Contribution of such Contributor, if any, in source +code and object code form. This patent license shall apply to the combination +of the Contribution and the Program if, at the time the Contribution is added +by the Contributor, such addition of the Contribution causes such combination +to be covered by the Licensed Patents. The patent license shall not apply to +any other combinations which include the Contribution. No hardware per se is +licensed hereunder.

    + +

    c) +Recipient understands that although each Contributor grants the licenses to its +Contributions set forth herein, no assurances are provided by any Contributor +that the Program does not infringe the patent or other intellectual property +rights of any other entity. Each Contributor disclaims any liability to Recipient +for claims brought by any other entity based on infringement of intellectual +property rights or otherwise. As a condition to exercising the rights and +licenses granted hereunder, each Recipient hereby assumes sole responsibility +to secure any other intellectual property rights needed, if any. For example, +if a third party patent license is required to allow Recipient to distribute +the Program, it is Recipient's responsibility to acquire that license before +distributing the Program.

    + +

    d) +Each Contributor represents that to its knowledge it has sufficient copyright +rights in its Contribution, if any, to grant the copyright license set forth in +this Agreement.

    + +

    3. REQUIREMENTS

    + +

    A Contributor may choose to distribute the +Program in object code form under its own license agreement, provided that: +

    + +

    a) +it complies with the terms and conditions of this Agreement; and

    + +

    b) +its license agreement:

    + +

    i) +effectively disclaims on behalf of all Contributors all warranties and +conditions, express and implied, including warranties or conditions of title +and non-infringement, and implied warranties or conditions of merchantability +and fitness for a particular purpose;

    + +

    ii) +effectively excludes on behalf of all Contributors all liability for damages, +including direct, indirect, special, incidental and consequential damages, such +as lost profits;

    + +

    iii) +states that any provisions which differ from this Agreement are offered by that +Contributor alone and not by any other party; and

    + +

    iv) +states that source code for the Program is available from such Contributor, and +informs licensees how to obtain it in a reasonable manner on or through a +medium customarily used for software exchange.

    + +

    When the Program is made available in source +code form:

    + +

    a) +it must be made available under this Agreement; and

    + +

    b) a +copy of this Agreement must be included with each copy of the Program.

    + +

    Contributors may not remove or alter any +copyright notices contained within the Program.

    + +

    Each Contributor must identify itself as the +originator of its Contribution, if any, in a manner that reasonably allows +subsequent Recipients to identify the originator of the Contribution.

    + +

    4. COMMERCIAL DISTRIBUTION

    + +

    Commercial distributors of software may +accept certain responsibilities with respect to end users, business partners +and the like. While this license is intended to facilitate the commercial use +of the Program, the Contributor who includes the Program in a commercial +product offering should do so in a manner which does not create potential +liability for other Contributors. Therefore, if a Contributor includes the +Program in a commercial product offering, such Contributor ("Commercial +Contributor") hereby agrees to defend and indemnify every other +Contributor ("Indemnified Contributor") against any losses, damages and +costs (collectively "Losses") arising from claims, lawsuits and other +legal actions brought by a third party against the Indemnified Contributor to +the extent caused by the acts or omissions of such Commercial Contributor in +connection with its distribution of the Program in a commercial product +offering. The obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. In order +to qualify, an Indemnified Contributor must: a) promptly notify the Commercial +Contributor in writing of such claim, and b) allow the Commercial Contributor +to control, and cooperate with the Commercial Contributor in, the defense and +any related settlement negotiations. The Indemnified Contributor may participate +in any such claim at its own expense.

    + +

    For example, a Contributor might include the +Program in a commercial product offering, Product X. That Contributor is then a +Commercial Contributor. If that Commercial Contributor then makes performance +claims, or offers warranties related to Product X, those performance claims and +warranties are such Commercial Contributor's responsibility alone. Under this +section, the Commercial Contributor would have to defend claims against the +other Contributors related to those performance claims and warranties, and if a +court requires any other Contributor to pay any damages as a result, the +Commercial Contributor must pay those damages.

    + +

    5. NO WARRANTY

    + +

    EXCEPT AS EXPRESSLY SET FORTH IN THIS +AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, +WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, +MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely +responsible for determining the appropriateness of using and distributing the +Program and assumes all risks associated with its exercise of rights under this +Agreement , including but not limited to the risks and costs of program errors, +compliance with applicable laws, damage to or loss of data, programs or +equipment, and unavailability or interruption of operations.

    + +

    6. DISCLAIMER OF LIABILITY

    + +

    EXCEPT AS EXPRESSLY SET FORTH IN THIS +AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF +THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGES.

    + +

    7. GENERAL

    + +

    If any provision of this Agreement is invalid +or unenforceable under applicable law, it shall not affect the validity or +enforceability of the remainder of the terms of this Agreement, and without +further action by the parties hereto, such provision shall be reformed to the +minimum extent necessary to make such provision valid and enforceable.

    + +

    If Recipient institutes patent litigation +against any entity (including a cross-claim or counterclaim in a lawsuit) +alleging that the Program itself (excluding combinations of the Program with +other software or hardware) infringes such Recipient's patent(s), then such +Recipient's rights granted under Section 2(b) shall terminate as of the date +such litigation is filed.

    + +

    All Recipient's rights under this Agreement +shall terminate if it fails to comply with any of the material terms or +conditions of this Agreement and does not cure such failure in a reasonable +period of time after becoming aware of such noncompliance. If all Recipient's +rights under this Agreement terminate, Recipient agrees to cease use and +distribution of the Program as soon as reasonably practicable. However, +Recipient's obligations under this Agreement and any licenses granted by +Recipient relating to the Program shall continue and survive.

    + +

    Everyone is permitted to copy and distribute +copies of this Agreement, but in order to avoid inconsistency the Agreement is +copyrighted and may only be modified in the following manner. The Agreement +Steward reserves the right to publish new versions (including revisions) of +this Agreement from time to time. No one other than the Agreement Steward has +the right to modify this Agreement. The Eclipse Foundation is the initial +Agreement Steward. The Eclipse Foundation may assign the responsibility to +serve as the Agreement Steward to a suitable separate entity. Each new version +of the Agreement will be given a distinguishing version number. The Program +(including Contributions) may always be distributed subject to the version of +the Agreement under which it was received. In addition, after a new version of +the Agreement is published, Contributor may elect to distribute the Program +(including its Contributions) under the new version. Except as expressly stated +in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to +the intellectual property of any Contributor under this Agreement, whether +expressly, by implication, estoppel or otherwise. All rights in the Program not +expressly granted under this Agreement are reserved.

    + +

    This Agreement is governed by the laws of the +State of New York and the intellectual property laws of the United States of +America. No party to this Agreement will bring a legal action under this +Agreement more than one year after the cause of action arose. Each party waives +its rights to a jury trial in any resulting litigation.

    + +

     

    + +
    + + + \ No newline at end of file diff --git a/org.sf.feeling.decompiler.fernflower.feature/feature.properties b/org.sf.feeling.decompiler.fernflower.feature/feature.properties new file mode 100644 index 00000000..bcec5f0f --- /dev/null +++ b/org.sf.feeling.decompiler.fernflower.feature/feature.properties @@ -0,0 +1,720 @@ +############################################################################### +# Copyright (c) 2017 Chen Chao and other ECD project contributors. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# https://www.eclipse.org/legal/epl-v10.html +############################################################################### + +# feature.properties +# contains externalized strings for feature.xml +# "%foo" in feature.xml corresponds to the key "foo" in this file +# java.io.Properties file (ISO 8859-1 with "\" escapes) +# This file should be translated. + +# "featureName" property - name of the feature +featureName=Enhanced Class Decompiler Fernflower Extension (Optional) + +# "providerName" property - name of the company that provides the feature +providerName=ECD project contributors + +# "updateSiteName" property - label for the update site +updateSiteName=Enhanced Class Decompiler Updates + +# "description" property - description of the feature +description=Enhanced Class Decompiler integrates JD, FernFlower, Vineflower, CFR, Procyon with Eclipse seamlessly. \ +It allows Java developers to debug class files without source code directly. + +copyrightURL=https://ecd-plugin.github.io + +copyright=(c) Copyright 2023 Chen Chao and other ECD project contributors. All rights reserved.\n + +# "licenseURL" property - URL of the "Feature License" +# do not translate value - just change to point to a locale-specific HTML page +licenseURL=license.html + +# "aboutURL" property - URL of the "About and Change log" +# do not translate value - just change to point to a locale-specific HTML page +aboutURL=about.html + +# "license" property - text of the "Feature Update License" +# should be plain text version of license agreement pointed to be "licenseURL" +license=\ + GNU GENERAL PUBLIC LICENSE\n\ +\n\ + Version 3, 29 June 2007\n\ +\n\ + Copyright (C) 2007 Free Software Foundation, Inc. \n\ + Everyone is permitted to copy and distribute verbatim copies\n\ + of this license document, but changing it is not allowed.\n\ +\n\ + Preamble\n\ +\n\ + The GNU General Public License is a free, copyleft license for\n\ +software and other kinds of works.\n\ +\n\ + The licenses for most software and other practical works are designed\n\ +to take away your freedom to share and change the works. By contrast,\n\ +the GNU General Public License is intended to guarantee your freedom to\n\ +share and change all versions of a program--to make sure it remains free\n\ +software for all its users. We, the Free Software Foundation, use the\n\ +GNU General Public License for most of our software; it applies also to\n\ +any other work released this way by its authors. You can apply it to\n\ +your programs, too.\n\ +\n\ + When we speak of free software, we are referring to freedom, not\n\ +price. Our General Public Licenses are designed to make sure that you\n\ +have the freedom to distribute copies of free software (and charge for\n\ +them if you wish), that you receive source code or can get it if you\n\ +want it, that you can change the software or use pieces of it in new\n\ +free programs, and that you know you can do these things.\n\ +\n\ + To protect your rights, we need to prevent others from denying you\n\ +these rights or asking you to surrender the rights. Therefore, you have\n\ +certain responsibilities if you distribute copies of the software, or if\n\ +you modify it: responsibilities to respect the freedom of others.\n\ +\n\ + For example, if you distribute copies of such a program, whether\n\ +gratis or for a fee, you must pass on to the recipients the same\n\ +freedoms that you received. You must make sure that they, too, receive\n\ +or can get the source code. And you must show them these terms so they\n\ +know their rights.\n\ +\n\ + Developers that use the GNU GPL protect your rights with two steps:\n\ +(1) assert copyright on the software, and (2) offer you this License\n\ +giving you legal permission to copy, distribute and/or modify it.\n\ +\n\ + For the developers' and authors' protection, the GPL clearly explains\n\ +that there is no warranty for this free software. For both users' and\n\ +authors' sake, the GPL requires that modified versions be marked as\n\ +changed, so that their problems will not be attributed erroneously to\n\ +authors of previous versions.\n\ +\n\ + Some devices are designed to deny users access to install or run\n\ +modified versions of the software inside them, although the manufacturer\n\ +can do so. This is fundamentally incompatible with the aim of\n\ +protecting users' freedom to change the software. The systematic\n\ +pattern of such abuse occurs in the area of products for individuals to\n\ +use, which is precisely where it is most unacceptable. Therefore, we\n\ +have designed this version of the GPL to prohibit the practice for those\n\ +products. If such problems arise substantially in other domains, we\n\ +stand ready to extend this provision to those domains in future versions\n\ +of the GPL, as needed to protect the freedom of users.\n\ +\n\ + Finally, every program is threatened constantly by software patents.\n\ +States should not allow patents to restrict development and use of\n\ +software on general-purpose computers, but in those that do, we wish to\n\ +avoid the special danger that patents applied to a free program could\n\ +make it effectively proprietary. To prevent this, the GPL assures that\n\ +patents cannot be used to render the program non-free.\n\ +\n\ + The precise terms and conditions for copying, distribution and\n\ +modification follow.\n\ +\n\ + TERMS AND CONDITIONS\n\ +\n\ + 0. Definitions.\n\ +\n\ + "This License" refers to version 3 of the GNU General Public License.\n\ +\n\ + "Copyright" also means copyright-like laws that apply to other kinds of\n\ +works, such as semiconductor masks.\n\ +\n\ + "The Program" refers to any copyrightable work licensed under this\n\ +License. Each licensee is addressed as "you". "Licensees" and\n\ +"recipients" may be individuals or organizations.\n\ +\n\ + To "modify" a work means to copy from or adapt all or part of the work\n\ +in a fashion requiring copyright permission, other than the making of an\n\ +exact copy. The resulting work is called a "modified version" of the\n\ +earlier work or a work "based on" the earlier work.\n\ +\n\ + A "covered work" means either the unmodified Program or a work based\n\ +on the Program.\n\ +\n\ + To "propagate" a work means to do anything with it that, without\n\ +permission, would make you directly or secondarily liable for\n\ +infringement under applicable copyright law, except executing it on a\n\ +computer or modifying a private copy. Propagation includes copying,\n\ +distribution (with or without modification), making available to the\n\ +public, and in some countries other activities as well.\n\ +\n\ + To "convey" a work means any kind of propagation that enables other\n\ +parties to make or receive copies. Mere interaction with a user through\n\ +a computer network, with no transfer of a copy, is not conveying.\n\ +\n\ + An interactive user interface displays "Appropriate Legal Notices"\n\ +to the extent that it includes a convenient and prominently visible\n\ +feature that (1) displays an appropriate copyright notice, and (2)\n\ +tells the user that there is no warranty for the work (except to the\n\ +extent that warranties are provided), that licensees may convey the\n\ +work under this License, and how to view a copy of this License. If\n\ +the interface presents a list of user commands or options, such as a\n\ +menu, a prominent item in the list meets this criterion.\n\ +\n\ + 1. Source Code.\n\ +\n\ + The "source code" for a work means the preferred form of the work\n\ +for making modifications to it. "Object code" means any non-source\n\ +form of a work.\n\ +\n\ + A "Standard Interface" means an interface that either is an official\n\ +standard defined by a recognized standards body, or, in the case of\n\ +interfaces specified for a particular programming language, one that\n\ +is widely used among developers working in that language.\n\ +\n\ + The "System Libraries" of an executable work include anything, other\n\ +than the work as a whole, that (a) is included in the normal form of\n\ +packaging a Major Component, but which is not part of that Major\n\ +Component, and (b) serves only to enable use of the work with that\n\ +Major Component, or to implement a Standard Interface for which an\n\ +implementation is available to the public in source code form. A\n\ +"Major Component", in this context, means a major essential component\n\ +(kernel, window system, and so on) of the specific operating system\n\ +(if any) on which the executable work runs, or a compiler used to\n\ +produce the work, or an object code interpreter used to run it.\n\ +\n\ + The "Corresponding Source" for a work in object code form means all\n\ +the source code needed to generate, install, and (for an executable\n\ +work) run the object code and to modify the work, including scripts to\n\ +control those activities. However, it does not include the work's\n\ +System Libraries, or general-purpose tools or generally available free\n\ +programs which are used unmodified in performing those activities but\n\ +which are not part of the work. For example, Corresponding Source\n\ +includes interface definition files associated with source files for\n\ +the work, and the source code for shared libraries and dynamically\n\ +linked subprograms that the work is specifically designed to require,\n\ +such as by intimate data communication or control flow between those\n\ +subprograms and other parts of the work.\n\ +\n\ + The Corresponding Source need not include anything that users\n\ +can regenerate automatically from other parts of the Corresponding\n\ +Source.\n\ +\n\ + The Corresponding Source for a work in source code form is that\n\ +same work.\n\ +\n\ + 2. Basic Permissions.\n\ +\n\ + All rights granted under this License are granted for the term of\n\ +copyright on the Program, and are irrevocable provided the stated\n\ +conditions are met. This License explicitly affirms your unlimited\n\ +permission to run the unmodified Program. The output from running a\n\ +covered work is covered by this License only if the output, given its\n\ +content, constitutes a covered work. This License acknowledges your\n\ +rights of fair use or other equivalent, as provided by copyright law.\n\ +\n\ + You may make, run and propagate covered works that you do not\n\ +convey, without conditions so long as your license otherwise remains\n\ +in force. You may convey covered works to others for the sole purpose\n\ +of having them make modifications exclusively for you, or provide you\n\ +with facilities for running those works, provided that you comply with\n\ +the terms of this License in conveying all material for which you do\n\ +not control copyright. Those thus making or running the covered works\n\ +for you must do so exclusively on your behalf, under your direction\n\ +and control, on terms that prohibit them from making any copies of\n\ +your copyrighted material outside their relationship with you.\n\ +\n\ + Conveying under any other circumstances is permitted solely under\n\ +the conditions stated below. Sublicensing is not allowed; section 10\n\ +makes it unnecessary.\n\ +\n\ + 3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\ +\n\ + No covered work shall be deemed part of an effective technological\n\ +measure under any applicable law fulfilling obligations under article\n\ +11 of the WIPO copyright treaty adopted on 20 December 1996, or\n\ +similar laws prohibiting or restricting circumvention of such\n\ +measures.\n\ +\n\ + When you convey a covered work, you waive any legal power to forbid\n\ +circumvention of technological measures to the extent such circumvention\n\ +is effected by exercising rights under this License with respect to\n\ +the covered work, and you disclaim any intention to limit operation or\n\ +modification of the work as a means of enforcing, against the work's\n\ +users, your or third parties' legal rights to forbid circumvention of\n\ +technological measures.\n\ +\n\ + 4. Conveying Verbatim Copies.\n\ +\n\ + You may convey verbatim copies of the Program's source code as you\n\ +receive it, in any medium, provided that you conspicuously and\n\ +appropriately publish on each copy an appropriate copyright notice;\n\ +keep intact all notices stating that this License and any\n\ +non-permissive terms added in accord with section 7 apply to the code;\n\ +keep intact all notices of the absence of any warranty; and give all\n\ +recipients a copy of this License along with the Program.\n\ +\n\ + You may charge any price or no price for each copy that you convey,\n\ +and you may offer support or warranty protection for a fee.\n\ +\n\ + 5. Conveying Modified Source Versions.\n\ +\n\ + You may convey a work based on the Program, or the modifications to\n\ +produce it from the Program, in the form of source code under the\n\ +terms of section 4, provided that you also meet all of these conditions:\n\ +\n\ + a) The work must carry prominent notices stating that you modified\n\ + it, and giving a relevant date.\n\ +\n\ + b) The work must carry prominent notices stating that it is\n\ + released under this License and any conditions added under section\n\ + 7. This requirement modifies the requirement in section 4 to\n\ + "keep intact all notices".\n\ +\n\ + c) You must license the entire work, as a whole, under this\n\ + License to anyone who comes into possession of a copy. This\n\ + License will therefore apply, along with any applicable section 7\n\ + additional terms, to the whole of the work, and all its parts,\n\ + regardless of how they are packaged. This License gives no\n\ + permission to license the work in any other way, but it does not\n\ + invalidate such permission if you have separately received it.\n\ +\n\ + d) If the work has interactive user interfaces, each must display\n\ + Appropriate Legal Notices; however, if the Program has interactive\n\ + interfaces that do not display Appropriate Legal Notices, your\n\ + work need not make them do so.\n\ +\n\ + A compilation of a covered work with other separate and independent\n\ +works, which are not by their nature extensions of the covered work,\n\ +and which are not combined with it such as to form a larger program,\n\ +in or on a volume of a storage or distribution medium, is called an\n\ +"aggregate" if the compilation and its resulting copyright are not\n\ +used to limit the access or legal rights of the compilation's users\n\ +beyond what the individual works permit. Inclusion of a covered work\n\ +in an aggregate does not cause this License to apply to the other\n\ +parts of the aggregate.\n\ +\n\ + 6. Conveying Non-Source Forms.\n\ +\n\ + You may convey a covered work in object code form under the terms\n\ +of sections 4 and 5, provided that you also convey the\n\ +machine-readable Corresponding Source under the terms of this License,\n\ +in one of these ways:\n\ +\n\ + a) Convey the object code in, or embodied in, a physical product\n\ + (including a physical distribution medium), accompanied by the\n\ + Corresponding Source fixed on a durable physical medium\n\ + customarily used for software interchange.\n\ +\n\ + b) Convey the object code in, or embodied in, a physical product\n\ + (including a physical distribution medium), accompanied by a\n\ + written offer, valid for at least three years and valid for as\n\ + long as you offer spare parts or customer support for that product\n\ + model, to give anyone who possesses the object code either (1) a\n\ + copy of the Corresponding Source for all the software in the\n\ + product that is covered by this License, on a durable physical\n\ + medium customarily used for software interchange, for a price no\n\ + more than your reasonable cost of physically performing this\n\ + conveying of source, or (2) access to copy the\n\ + Corresponding Source from a network server at no charge.\n\ +\n\ + c) Convey individual copies of the object code with a copy of the\n\ + written offer to provide the Corresponding Source. This\n\ + alternative is allowed only occasionally and noncommercially, and\n\ + only if you received the object code with such an offer, in accord\n\ + with subsection 6b.\n\ +\n\ + d) Convey the object code by offering access from a designated\n\ + place (gratis or for a charge), and offer equivalent access to the\n\ + Corresponding Source in the same way through the same place at no\n\ + further charge. You need not require recipients to copy the\n\ + Corresponding Source along with the object code. If the place to\n\ + copy the object code is a network server, the Corresponding Source\n\ + may be on a different server (operated by you or a third party)\n\ + that supports equivalent copying facilities, provided you maintain\n\ + clear directions next to the object code saying where to find the\n\ + Corresponding Source. Regardless of what server hosts the\n\ + Corresponding Source, you remain obligated to ensure that it is\n\ + available for as long as needed to satisfy these requirements.\n\ +\n\ + e) Convey the object code using peer-to-peer transmission, provided\n\ + you inform other peers where the object code and Corresponding\n\ + Source of the work are being offered to the general public at no\n\ + charge under subsection 6d.\n\ +\n\ + A separable portion of the object code, whose source code is excluded\n\ +from the Corresponding Source as a System Library, need not be\n\ +included in conveying the object code work.\n\ +\n\ + A "User Product" is either (1) a "consumer product", which means any\n\ +tangible personal property which is normally used for personal, family,\n\ +or household purposes, or (2) anything designed or sold for incorporation\n\ +into a dwelling. In determining whether a product is a consumer product,\n\ +doubtful cases shall be resolved in favor of coverage. For a particular\n\ +product received by a particular user, "normally used" refers to a\n\ +typical or common use of that class of product, regardless of the status\n\ +of the particular user or of the way in which the particular user\n\ +actually uses, or expects or is expected to use, the product. A product\n\ +is a consumer product regardless of whether the product has substantial\n\ +commercial, industrial or non-consumer uses, unless such uses represent\n\ +the only significant mode of use of the product.\n\ +\n\ + "Installation Information" for a User Product means any methods,\n\ +procedures, authorization keys, or other information required to install\n\ +and execute modified versions of a covered work in that User Product from\n\ +a modified version of its Corresponding Source. The information must\n\ +suffice to ensure that the continued functioning of the modified object\n\ +code is in no case prevented or interfered with solely because\n\ +modification has been made.\n\ +\n\ + If you convey an object code work under this section in, or with, or\n\ +specifically for use in, a User Product, and the conveying occurs as\n\ +part of a transaction in which the right of possession and use of the\n\ +User Product is transferred to the recipient in perpetuity or for a\n\ +fixed term (regardless of how the transaction is characterized), the\n\ +Corresponding Source conveyed under this section must be accompanied\n\ +by the Installation Information. But this requirement does not apply\n\ +if neither you nor any third party retains the ability to install\n\ +modified object code on the User Product (for example, the work has\n\ +been installed in ROM).\n\ +\n\ + The requirement to provide Installation Information does not include a\n\ +requirement to continue to provide support service, warranty, or updates\n\ +for a work that has been modified or installed by the recipient, or for\n\ +the User Product in which it has been modified or installed. Access to a\n\ +network may be denied when the modification itself materially and\n\ +adversely affects the operation of the network or violates the rules and\n\ +protocols for communication across the network.\n\ +\n\ + Corresponding Source conveyed, and Installation Information provided,\n\ +in accord with this section must be in a format that is publicly\n\ +documented (and with an implementation available to the public in\n\ +source code form), and must require no special password or key for\n\ +unpacking, reading or copying.\n\ +\n\ + 7. Additional Terms.\n\ +\n\ + "Additional permissions" are terms that supplement the terms of this\n\ +License by making exceptions from one or more of its conditions.\n\ +Additional permissions that are applicable to the entire Program shall\n\ +be treated as though they were included in this License, to the extent\n\ +that they are valid under applicable law. If additional permissions\n\ +apply only to part of the Program, that part may be used separately\n\ +under those permissions, but the entire Program remains governed by\n\ +this License without regard to the additional permissions.\n\ +\n\ + When you convey a copy of a covered work, you may at your option\n\ +remove any additional permissions from that copy, or from any part of\n\ +it. (Additional permissions may be written to require their own\n\ +removal in certain cases when you modify the work.) You may place\n\ +additional permissions on material, added by you to a covered work,\n\ +for which you have or can give appropriate copyright permission.\n\ +\n\ + Notwithstanding any other provision of this License, for material you\n\ +add to a covered work, you may (if authorized by the copyright holders of\n\ +that material) supplement the terms of this License with terms:\n\ +\n\ + a) Disclaiming warranty or limiting liability differently from the\n\ + terms of sections 15 and 16 of this License; or\n\ +\n\ + b) Requiring preservation of specified reasonable legal notices or\n\ + author attributions in that material or in the Appropriate Legal\n\ + Notices displayed by works containing it; or\n\ +\n\ + c) Prohibiting misrepresentation of the origin of that material, or\n\ + requiring that modified versions of such material be marked in\n\ + reasonable ways as different from the original version; or\n\ +\n\ + d) Limiting the use for publicity purposes of names of licensors or\n\ + authors of the material; or\n\ +\n\ + e) Declining to grant rights under trademark law for use of some\n\ + trade names, trademarks, or service marks; or\n\ +\n\ + f) Requiring indemnification of licensors and authors of that\n\ + material by anyone who conveys the material (or modified versions of\n\ + it) with contractual assumptions of liability to the recipient, for\n\ + any liability that these contractual assumptions directly impose on\n\ + those licensors and authors.\n\ +\n\ + All other non-permissive additional terms are considered "further\n\ +restrictions" within the meaning of section 10. If the Program as you\n\ +received it, or any part of it, contains a notice stating that it is\n\ +governed by this License along with a term that is a further\n\ +restriction, you may remove that term. If a license document contains\n\ +a further restriction but permits relicensing or conveying under this\n\ +License, you may add to a covered work material governed by the terms\n\ +of that license document, provided that the further restriction does\n\ +not survive such relicensing or conveying.\n\ +\n\ + If you add terms to a covered work in accord with this section, you\n\ +must place, in the relevant source files, a statement of the\n\ +additional terms that apply to those files, or a notice indicating\n\ +where to find the applicable terms.\n\ +\n\ + Additional terms, permissive or non-permissive, may be stated in the\n\ +form of a separately written license, or stated as exceptions;\n\ +the above requirements apply either way.\n\ +\n\ + 8. Termination.\n\ +\n\ + You may not propagate or modify a covered work except as expressly\n\ +provided under this License. Any attempt otherwise to propagate or\n\ +modify it is void, and will automatically terminate your rights under\n\ +this License (including any patent licenses granted under the third\n\ +paragraph of section 11).\n\ +\n\ + However, if you cease all violation of this License, then your\n\ +license from a particular copyright holder is reinstated (a)\n\ +provisionally, unless and until the copyright holder explicitly and\n\ +finally terminates your license, and (b) permanently, if the copyright\n\ +holder fails to notify you of the violation by some reasonable means\n\ +prior to 60 days after the cessation.\n\ +\n\ + Moreover, your license from a particular copyright holder is\n\ +reinstated permanently if the copyright holder notifies you of the\n\ +violation by some reasonable means, this is the first time you have\n\ +received notice of violation of this License (for any work) from that\n\ +copyright holder, and you cure the violation prior to 30 days after\n\ +your receipt of the notice.\n\ +\n\ + Termination of your rights under this section does not terminate the\n\ +licenses of parties who have received copies or rights from you under\n\ +this License. If your rights have been terminated and not permanently\n\ +reinstated, you do not qualify to receive new licenses for the same\n\ +material under section 10.\n\ +\n\ + 9. Acceptance Not Required for Having Copies.\n\ +\n\ + You are not required to accept this License in order to receive or\n\ +run a copy of the Program. Ancillary propagation of a covered work\n\ +occurring solely as a consequence of using peer-to-peer transmission\n\ +to receive a copy likewise does not require acceptance. However,\n\ +nothing other than this License grants you permission to propagate or\n\ +modify any covered work. These actions infringe copyright if you do\n\ +not accept this License. Therefore, by modifying or propagating a\n\ +covered work, you indicate your acceptance of this License to do so.\n\ +\n\ + 10. Automatic Licensing of Downstream Recipients.\n\ +\n\ + Each time you convey a covered work, the recipient automatically\n\ +receives a license from the original licensors, to run, modify and\n\ +propagate that work, subject to this License. You are not responsible\n\ +for enforcing compliance by third parties with this License.\n\ +\n\ + An "entity transaction" is a transaction transferring control of an\n\ +organization, or substantially all assets of one, or subdividing an\n\ +organization, or merging organizations. If propagation of a covered\n\ +work results from an entity transaction, each party to that\n\ +transaction who receives a copy of the work also receives whatever\n\ +licenses to the work the party's predecessor in interest had or could\n\ +give under the previous paragraph, plus a right to possession of the\n\ +Corresponding Source of the work from the predecessor in interest, if\n\ +the predecessor has it or can get it with reasonable efforts.\n\ +\n\ + You may not impose any further restrictions on the exercise of the\n\ +rights granted or affirmed under this License. For example, you may\n\ +not impose a license fee, royalty, or other charge for exercise of\n\ +rights granted under this License, and you may not initiate litigation\n\ +(including a cross-claim or counterclaim in a lawsuit) alleging that\n\ +any patent claim is infringed by making, using, selling, offering for\n\ +sale, or importing the Program or any portion of it.\n\ +\n\ + 11. Patents.\n\ +\n\ + A "contributor" is a copyright holder who authorizes use under this\n\ +License of the Program or a work on which the Program is based. The\n\ +work thus licensed is called the contributor's "contributor version".\n\ +\n\ + A contributor's "essential patent claims" are all patent claims\n\ +owned or controlled by the contributor, whether already acquired or\n\ +hereafter acquired, that would be infringed by some manner, permitted\n\ +by this License, of making, using, or selling its contributor version,\n\ +but do not include claims that would be infringed only as a\n\ +consequence of further modification of the contributor version. For\n\ +purposes of this definition, "control" includes the right to grant\n\ +patent sublicenses in a manner consistent with the requirements of\n\ +this License.\n\ +\n\ + Each contributor grants you a non-exclusive, worldwide, royalty-free\n\ +patent license under the contributor's essential patent claims, to\n\ +make, use, sell, offer for sale, import and otherwise run, modify and\n\ +propagate the contents of its contributor version.\n\ +\n\ + In the following three paragraphs, a "patent license" is any express\n\ +agreement or commitment, however denominated, not to enforce a patent\n\ +(such as an express permission to practice a patent or covenant not to\n\ +sue for patent infringement). To "grant" such a patent license to a\n\ +party means to make such an agreement or commitment not to enforce a\n\ +patent against the party.\n\ +\n\ + If you convey a covered work, knowingly relying on a patent license,\n\ +and the Corresponding Source of the work is not available for anyone\n\ +to copy, free of charge and under the terms of this License, through a\n\ +publicly available network server or other readily accessible means,\n\ +then you must either (1) cause the Corresponding Source to be so\n\ +available, or (2) arrange to deprive yourself of the benefit of the\n\ +patent license for this particular work, or (3) arrange, in a manner\n\ +consistent with the requirements of this License, to extend the patent\n\ +license to downstream recipients. "Knowingly relying" means you have\n\ +actual knowledge that, but for the patent license, your conveying the\n\ +covered work in a country, or your recipient's use of the covered work\n\ +in a country, would infringe one or more identifiable patents in that\n\ +country that you have reason to believe are valid.\n\ +\n\ + If, pursuant to or in connection with a single transaction or\n\ +arrangement, you convey, or propagate by procuring conveyance of, a\n\ +covered work, and grant a patent license to some of the parties\n\ +receiving the covered work authorizing them to use, propagate, modify\n\ +or convey a specific copy of the covered work, then the patent license\n\ +you grant is automatically extended to all recipients of the covered\n\ +work and works based on it.\n\ +\n\ + A patent license is "discriminatory" if it does not include within\n\ +the scope of its coverage, prohibits the exercise of, or is\n\ +conditioned on the non-exercise of one or more of the rights that are\n\ +specifically granted under this License. You may not convey a covered\n\ +work if you are a party to an arrangement with a third party that is\n\ +in the business of distributing software, under which you make payment\n\ +to the third party based on the extent of your activity of conveying\n\ +the work, and under which the third party grants, to any of the\n\ +parties who would receive the covered work from you, a discriminatory\n\ +patent license (a) in connection with copies of the covered work\n\ +conveyed by you (or copies made from those copies), or (b) primarily\n\ +for and in connection with specific products or compilations that\n\ +contain the covered work, unless you entered into that arrangement,\n\ +or that patent license was granted, prior to 28 March 2007.\n\ +\n\ + Nothing in this License shall be construed as excluding or limiting\n\ +any implied license or other defenses to infringement that may\n\ +otherwise be available to you under applicable patent law.\n\ +\n\ + 12. No Surrender of Others' Freedom.\n\ +\n\ + If conditions are imposed on you (whether by court order, agreement or\n\ +otherwise) that contradict the conditions of this License, they do not\n\ +excuse you from the conditions of this License. If you cannot convey a\n\ +covered work so as to satisfy simultaneously your obligations under this\n\ +License and any other pertinent obligations, then as a consequence you may\n\ +not convey it at all. For example, if you agree to terms that obligate you\n\ +to collect a royalty for further conveying from those to whom you convey\n\ +the Program, the only way you could satisfy both those terms and this\n\ +License would be to refrain entirely from conveying the Program.\n\ +\n\ + 13. Use with the GNU Affero General Public License.\n\ +\n\ + Notwithstanding any other provision of this License, you have\n\ +permission to link or combine any covered work with a work licensed\n\ +under version 3 of the GNU Affero General Public License into a single\n\ +combined work, and to convey the resulting work. The terms of this\n\ +License will continue to apply to the part which is the covered work,\n\ +but the special requirements of the GNU Affero General Public License,\n\ +section 13, concerning interaction through a network will apply to the\n\ +combination as such.\n\ +\n\ + 14. Revised Versions of this License.\n\ +\n\ + The Free Software Foundation may publish revised and/or new versions of\n\ +the GNU General Public License from time to time. Such new versions will\n\ +be similar in spirit to the present version, but may differ in detail to\n\ +address new problems or concerns.\n\ +\n\ + Each version is given a distinguishing version number. If the\n\ +Program specifies that a certain numbered version of the GNU General\n\ +Public License "or any later version" applies to it, you have the\n\ +option of following the terms and conditions either of that numbered\n\ +version or of any later version published by the Free Software\n\ +Foundation. If the Program does not specify a version number of the\n\ +GNU General Public License, you may choose any version ever published\n\ +by the Free Software Foundation.\n\ +\n\ + If the Program specifies that a proxy can decide which future\n\ +versions of the GNU General Public License can be used, that proxy's\n\ +public statement of acceptance of a version permanently authorizes you\n\ +to choose that version for the Program.\n\ +\n\ + Later license versions may give you additional or different\n\ +permissions. However, no additional obligations are imposed on any\n\ +author or copyright holder as a result of your choosing to follow a\n\ +later version.\n\ +\n\ + 15. Disclaimer of Warranty.\n\ +\n\ + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\n\ +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\n\ +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY\n\ +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\n\ +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n\ +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\n\ +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\n\ +ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\ +\n\ + 16. Limitation of Liability.\n\ +\n\ + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\n\ +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\n\ +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\n\ +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\n\ +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\n\ +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\n\ +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\n\ +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\n\ +SUCH DAMAGES.\n\ +\n\ + 17. Interpretation of Sections 15 and 16.\n\ +\n\ + If the disclaimer of warranty and limitation of liability provided\n\ +above cannot be given local legal effect according to their terms,\n\ +reviewing courts shall apply local law that most closely approximates\n\ +an absolute waiver of all civil liability in connection with the\n\ +Program, unless a warranty or assumption of liability accompanies a\n\ +copy of the Program in return for a fee.\n\ +\n\ + END OF TERMS AND CONDITIONS\n\ +\n\ + How to Apply These Terms to Your New Programs\n\ +\n\ + If you develop a new program, and you want it to be of the greatest\n\ +possible use to the public, the best way to achieve this is to make it\n\ +free software which everyone can redistribute and change under these terms.\n\ +\n\ + To do so, attach the following notices to the program. It is safest\n\ +to attach them to the start of each source file to most effectively\n\ +state the exclusion of warranty; and each file should have at least\n\ +the "copyright" line and a pointer to where the full notice is found.\n\ +\n\ + JD-Eclipse is a plug-in for the Eclipse platform. It allows you to \n\ + display all the Java sources during your debugging process, even if \n\ + you do not have them all.\n\ + Copyright (C) 2008-2015 Emmanuel Dupuy\n\ +\n\ + This program is free software: you can redistribute it and/or modify\n\ + it under the terms of the GNU General Public License as published by\n\ + the Free Software Foundation, either version 3 of the License, or\n\ + (at your option) any later version.\n\ +\n\ + This program is distributed in the hope that it will be useful,\n\ + but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ + GNU General Public License for more details.\n\ +\n\ + You should have received a copy of the GNU General Public License\n\ + along with this program. If not, see .\n\ +\n\ +Also add information on how to contact you by electronic and paper mail.\n\ +\n\ + If the program does terminal interaction, make it output a short\n\ +notice like this when it starts in an interactive mode:\n\ +\n\ + JD-Eclipse Copyright (C) 2008-2015 Emmanuel Dupuy\n\ + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n\ + This is free software, and you are welcome to redistribute it\n\ + under certain conditions; type `show c' for details.\n\ +\n\ +The hypothetical commands `show w' and `show c' should show the appropriate\n\ +parts of the General Public License. Of course, your program's commands\n\ +might be different; for a GUI interface, you would use an "about box".\n\ +\n\ + You should also get your employer (if you work as a programmer) or school,\n\ +if any, to sign a "copyright disclaimer" for the program, if necessary.\n\ +For more information on this, and how to apply and follow the GNU GPL, see\n\ +.\n\ +\n\ + The GNU General Public License does not permit incorporating your program\n\ +into proprietary programs. If your program is a subroutine library, you\n\ +may consider it more useful to permit linking proprietary applications with\n\ +the library. If this is what you want to do, use the GNU Lesser General\n\ +Public License instead of this License. But first, please read\n\ +.\n +########### end of license property ########################################## diff --git a/org.sf.feeling.decompiler.jad.feature/feature.xml b/org.sf.feeling.decompiler.fernflower.feature/feature.xml similarity index 66% rename from org.sf.feeling.decompiler.jad.feature/feature.xml rename to org.sf.feeling.decompiler.fernflower.feature/feature.xml index d8852f13..df1cdee3 100644 --- a/org.sf.feeling.decompiler.jad.feature/feature.xml +++ b/org.sf.feeling.decompiler.fernflower.feature/feature.xml @@ -1,56 +1,53 @@ - - - - - %description - - - - %copyright - - - - %license - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + %description + + + + %copyright + + + + %license + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/org.sf.feeling.decompiler.fernflower.feature/license.html b/org.sf.feeling.decompiler.fernflower.feature/license.html new file mode 100644 index 00000000..87eb9824 --- /dev/null +++ b/org.sf.feeling.decompiler.fernflower.feature/license.html @@ -0,0 +1,696 @@ + + + + + + GNU General Public License v3.0 - GNU Project - Free Software Foundation (FSF) + + + +

    GNU GENERAL PUBLIC LICENSE

    +

    Version 3, 29 June 2007

    + +

    Copyright © 2007 Free Software Foundation, Inc. + <https://fsf.org/>

    + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed.

    + +

    Preamble

    + +

    The GNU General Public License is a free, copyleft license for +software and other kinds of works.

    + +

    The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too.

    + +

    When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things.

    + +

    To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others.

    + +

    For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights.

    + +

    Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it.

    + +

    For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions.

    + +

    Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users.

    + +

    Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free.

    + +

    The precise terms and conditions for copying, distribution and +modification follow.

    + +

    TERMS AND CONDITIONS

    + +

    0. Definitions.

    + +

    “This License” refers to version 3 of the GNU General Public License.

    + +

    “Copyright” also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks.

    + +

    “The Program” refers to any copyrightable work licensed under this +License. Each licensee is addressed as “you”. “Licensees” and +“recipients” may be individuals or organizations.

    + +

    To “modify” a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a “modified version” of the +earlier work or a work “based on” the earlier work.

    + +

    A “covered work” means either the unmodified Program or a work based +on the Program.

    + +

    To “propagate” a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well.

    + +

    To “convey” a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying.

    + +

    An interactive user interface displays “Appropriate Legal Notices” +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion.

    + +

    1. Source Code.

    + +

    The “source code” for a work means the preferred form of the work +for making modifications to it. “Object code” means any non-source +form of a work.

    + +

    A “Standard Interface” means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language.

    + +

    The “System Libraries” of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +“Major Component”, in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it.

    + +

    The “Corresponding Source” for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work.

    + +

    The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source.

    + +

    The Corresponding Source for a work in source code form is that +same work.

    + +

    2. Basic Permissions.

    + +

    All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law.

    + +

    You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you.

    + +

    Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary.

    + +

    3. Protecting Users' Legal Rights From Anti-Circumvention Law.

    + +

    No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures.

    + +

    When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures.

    + +

    4. Conveying Verbatim Copies.

    + +

    You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program.

    + +

    You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee.

    + +

    5. Conveying Modified Source Versions.

    + +

    You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions:

    + +
      +
    • a) The work must carry prominent notices stating that you modified + it, and giving a relevant date.
    • + +
    • b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + “keep intact all notices”.
    • + +
    • c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it.
    • + +
    • d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so.
    • +
    + +

    A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +“aggregate” if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate.

    + +

    6. Conveying Non-Source Forms.

    + +

    You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways:

    + +
      +
    • a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange.
    • + +
    • b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge.
    • + +
    • c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b.
    • + +
    • d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements.
    • + +
    • e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d.
    • +
    + +

    A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work.

    + +

    A “User Product” is either (1) a “consumer product”, which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, “normally used” refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product.

    + +

    “Installation Information” for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made.

    + +

    If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM).

    + +

    The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network.

    + +

    Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying.

    + +

    7. Additional Terms.

    + +

    “Additional permissions” are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions.

    + +

    When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission.

    + +

    Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms:

    + +
      +
    • a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or
    • + +
    • b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or
    • + +
    • c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or
    • + +
    • d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or
    • + +
    • e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or
    • + +
    • f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors.
    • +
    + +

    All other non-permissive additional terms are considered “further +restrictions” within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying.

    + +

    If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms.

    + +

    Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way.

    + +

    8. Termination.

    + +

    You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11).

    + +

    However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation.

    + +

    Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice.

    + +

    Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10.

    + +

    9. Acceptance Not Required for Having Copies.

    + +

    You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so.

    + +

    10. Automatic Licensing of Downstream Recipients.

    + +

    Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License.

    + +

    An “entity transaction” is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts.

    + +

    You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it.

    + +

    11. Patents.

    + +

    A “contributor” is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's “contributor version”.

    + +

    A contributor's “essential patent claims” are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, “control” includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License.

    + +

    Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version.

    + +

    In the following three paragraphs, a “patent license” is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To “grant” such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party.

    + +

    If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. “Knowingly relying” means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid.

    + +

    If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it.

    + +

    A patent license is “discriminatory” if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007.

    + +

    Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law.

    + +

    12. No Surrender of Others' Freedom.

    + +

    If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program.

    + +

    13. Use with the GNU Affero General Public License.

    + +

    Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such.

    + +

    14. Revised Versions of this License.

    + +

    The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns.

    + +

    Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License “or any later version” applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation.

    + +

    If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program.

    + +

    Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version.

    + +

    15. Disclaimer of Warranty.

    + +

    THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

    + +

    16. Limitation of Liability.

    + +

    IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES.

    + +

    17. Interpretation of Sections 15 and 16.

    + +

    If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee.

    + +

    END OF TERMS AND CONDITIONS

    + +

    How to Apply These Terms to Your New Programs

    + +

    If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +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.

    + +
        <one line to give the program's name and a brief idea of what it does.>
    +    Copyright (C) <year>  <name of author>
    +
    +    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
    +    the Free Software Foundation, either version 3 of the License, or
    +    (at your option) any later version.
    +
    +    This program is distributed in the hope that it will be useful,
    +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    +    GNU General Public License for more details.
    +
    +    You should have received a copy of the GNU General Public License
    +    along with this program.  If not, see <https://www.gnu.org/licenses/>.
    +
    + +

    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:

    + +
        <program>  Copyright (C) <year>  <name of author>
    +    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.
    +
    + +

    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. +For more information on this, and how to apply and follow the GNU GPL, see +<https://www.gnu.org/licenses/>.

    + +

    The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<https://www.gnu.org/licenses/why-not-lgpl.html>.

    + + diff --git a/org.sf.feeling.decompiler.fernflower.feature/pom.xml b/org.sf.feeling.decompiler.fernflower.feature/pom.xml new file mode 100644 index 00000000..110d5cf5 --- /dev/null +++ b/org.sf.feeling.decompiler.fernflower.feature/pom.xml @@ -0,0 +1,15 @@ + + 4.0.0 + + + com.github.ecd-plugin + com.github.ecd-plugin.ecd + 3.5.1 + ../pom.xml + + + com.github.ecd-plugin.features + org.sf.feeling.decompiler.fernflower + eclipse-feature + diff --git a/org.sf.feeling.decompiler.update/.classpath b/org.sf.feeling.decompiler.fernflower/.classpath similarity index 57% rename from org.sf.feeling.decompiler.update/.classpath rename to org.sf.feeling.decompiler.fernflower/.classpath index c129c036..3f4f8c3d 100644 --- a/org.sf.feeling.decompiler.update/.classpath +++ b/org.sf.feeling.decompiler.fernflower/.classpath @@ -1,8 +1,12 @@ - - - - - - - - + + + + + + + + + + + + diff --git a/org.sf.feeling.decompiler.update/.project b/org.sf.feeling.decompiler.fernflower/.project similarity index 78% rename from org.sf.feeling.decompiler.update/.project rename to org.sf.feeling.decompiler.fernflower/.project index 78604a44..ca5c4bec 100644 --- a/org.sf.feeling.decompiler.update/.project +++ b/org.sf.feeling.decompiler.fernflower/.project @@ -1,34 +1,34 @@ - - - org.sf.feeling.decompiler.update - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.UpdateSiteBuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.UpdateSiteNature - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - + + + org.sf.feeling.decompiler.fernflower + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.m2e.core.maven2Nature + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/org.sf.feeling.decompiler.fernflower/.settings/org.eclipse.core.resources.prefs b/org.sf.feeling.decompiler.fernflower/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000..99f26c02 --- /dev/null +++ b/org.sf.feeling.decompiler.fernflower/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/org.sf.feeling.decompiler.fernflower/.settings/org.eclipse.core.runtime.prefs b/org.sf.feeling.decompiler.fernflower/.settings/org.eclipse.core.runtime.prefs new file mode 100644 index 00000000..deae05a9 --- /dev/null +++ b/org.sf.feeling.decompiler.fernflower/.settings/org.eclipse.core.runtime.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +line.separator=\r\n diff --git a/org.sf.feeling.decompiler.fernflower/.settings/org.eclipse.jdt.core.prefs b/org.sf.feeling.decompiler.fernflower/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..57a09535 --- /dev/null +++ b/org.sf.feeling.decompiler.fernflower/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,466 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=ignore +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore +org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=ignore +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 +org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false +org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false +org.eclipse.jdt.core.formatter.align_with_spaces=false +org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_enum_constant=49 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field=49 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable=49 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_method=49 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package=49 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter=0 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type=49 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assertion_message=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain=0 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0 +org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_module_statements=16 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_record_components=16 +org.eclipse.jdt.core.formatter.alignment_for_relational_operator=0 +org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_shift_operator=0 +org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_record_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_type_annotations=0 +org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0 +org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0 +org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_last_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_abstract_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_statement_group_in_switch=0 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_record_constructor=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_record_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped=true +org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false +org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=true +org.eclipse.jdt.core.formatter.comment.format_block_comments=true +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true +org.eclipse.jdt.core.formatter.comment.format_line_comments=true +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=false +org.eclipse.jdt.core.formatter.comment.indent_root_tags=false +org.eclipse.jdt.core.formatter.comment.indent_tag_description=false +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_between_different_tags=do not insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert +org.eclipse.jdt.core.formatter.comment.line_length=80 +org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true +org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true +org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false +org.eclipse.jdt.core.formatter.compact_else_if=true +org.eclipse.jdt.core.formatter.continuation_indentation=2 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 +org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=false +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_record_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false +org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_default=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_record_components=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_switch_case_expressions=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_not_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_record_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert +org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_case=insert +org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_default=insert +org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_record_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_record_components=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_switch_case_expressions=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_constructor=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_record_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=true +org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_code_block_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_method_body_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_record_constructor_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_record_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line=false +org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.lineSplit=120 +org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false +org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false +org.eclipse.jdt.core.formatter.number_of_blank_lines_after_code_block=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_code_block=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_code_block=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_before_code_block=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 +org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_record_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true +org.eclipse.jdt.core.formatter.tabulation.char=tab +org.eclipse.jdt.core.formatter.tabulation.size=4 +org.eclipse.jdt.core.formatter.text_block_indentation=0 +org.eclipse.jdt.core.formatter.use_on_off_tags=true +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true +org.eclipse.jdt.core.formatter.wrap_before_assertion_message_operator=true +org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false +org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true +org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true +org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true +org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true +org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_before_relational_operator=true +org.eclipse.jdt.core.formatter.wrap_before_shift_operator=true +org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true +org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter diff --git a/org.sf.feeling.decompiler.fernflower/.settings/org.eclipse.jdt.ui.prefs b/org.sf.feeling.decompiler.fernflower/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 00000000..9a4e91e5 --- /dev/null +++ b/org.sf.feeling.decompiler.fernflower/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,106 @@ +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +formatter_profile=org.eclipse.jdt.ui.default.eclipse_profile +formatter_settings_version=20 +sp_cleanup.add_all=false +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.arrays_fill=false +sp_cleanup.bitwise_conditional_expression=false +sp_cleanup.boolean_literal=false +sp_cleanup.break_loop=false +sp_cleanup.collection_cloning=false +sp_cleanup.comparison_statement=false +sp_cleanup.convert_functional_interfaces=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.convert_to_enhanced_for_loop_if_loop_var_used=false +sp_cleanup.convert_to_switch_expressions=false +sp_cleanup.correct_indentation=false +sp_cleanup.double_negation=false +sp_cleanup.else_if=false +sp_cleanup.embedded_if=false +sp_cleanup.evaluate_nullable=false +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=false +sp_cleanup.hash=false +sp_cleanup.if_condition=false +sp_cleanup.insert_inferred_type_arguments=false +sp_cleanup.instanceof=false +sp_cleanup.join=false +sp_cleanup.lazy_logical_operator=false +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=true +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=false +sp_cleanup.map_cloning=false +sp_cleanup.merge_conditional_blocks=false +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.no_string_creation=false +sp_cleanup.no_super=false +sp_cleanup.number_suffix=false +sp_cleanup.objects_equals=false +sp_cleanup.on_save_use_additional_actions=false +sp_cleanup.organize_imports=true +sp_cleanup.overridden_assignment=false +sp_cleanup.precompile_regex=false +sp_cleanup.primitive_serialization=false +sp_cleanup.pull_up_assignment=false +sp_cleanup.push_down_negation=false +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=false +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.redundant_falling_through_block_end=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_redundant_modifiers=false +sp_cleanup.remove_redundant_semicolons=false +sp_cleanup.remove_redundant_type_arguments=false +sp_cleanup.remove_trailing_whitespaces=false +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_array_creation=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=false +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.simplify_lambda_expression_and_method_ref=false +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.strictly_equal_or_different=false +sp_cleanup.stringbuilder=false +sp_cleanup.switch=false +sp_cleanup.ternary_operator=false +sp_cleanup.try_with_resource=false +sp_cleanup.use_anonymous_class_creation=false +sp_cleanup.use_autoboxing=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_directly_map_method=false +sp_cleanup.use_lambda=true +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=false +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true +sp_cleanup.use_unboxing=false +sp_cleanup.use_var=false +sp_cleanup.useless_continue=false +sp_cleanup.useless_return=false diff --git a/org.sf.feeling.decompiler.fernflower/.settings/org.eclipse.m2e.core.prefs b/org.sf.feeling.decompiler.fernflower/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 00000000..f897a7f1 --- /dev/null +++ b/org.sf.feeling.decompiler.fernflower/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/org.sf.feeling.decompiler.fernflower/META-INF/MANIFEST.MF b/org.sf.feeling.decompiler.fernflower/META-INF/MANIFEST.MF new file mode 100644 index 00000000..ee67d188 --- /dev/null +++ b/org.sf.feeling.decompiler.fernflower/META-INF/MANIFEST.MF @@ -0,0 +1,31 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Enhanced Class Decompiler FernFlower Extension +Bundle-SymbolicName: org.sf.feeling.decompiler.fernflower;singleton:=true +Bundle-Version: 3.5.1 +Bundle-Activator: org.sf.feeling.decompiler.fernflower.FernFlowerDecompilerPlugin +Require-Bundle: org.eclipse.core.runtime, + org.sf.feeling.decompiler;bundle-version="3.2.2", + org.eclipse.core.resources, + org.eclipse.jface, + org.eclipse.jface.text, + org.eclipse.ui.editors, + org.eclipse.ui.workbench, + org.eclipse.ui.workbench.texteditor, + org.eclipse.jdt.core, + org.eclipse.jdt.ui, + org.eclipse.jdt.debug.ui, + org.eclipse.debug.ui, + org.eclipse.jdt.launching, + org.eclipse.core.expressions, + org.eclipse.ui.navigator, + org.eclipse.ui.ide;resolution:=optional, + org.eclipse.core.filesystem, + org.apache.commons.lang3;bundle-version="3.1.0" +Bundle-RequiredExecutionEnvironment: JavaSE-17 +Bundle-ActivationPolicy: lazy +Bundle-Vendor: ECD Project Team +Export-Package: org.sf.feeling.decompiler.fernflower.actions, + org.sf.feeling.decompiler.fernflower.decompiler +Bundle-ClassPath: ., + lib/fernflower.jar diff --git a/org.sf.feeling.decompiler.jad/build.properties b/org.sf.feeling.decompiler.fernflower/build.properties similarity index 65% rename from org.sf.feeling.decompiler.jad/build.properties rename to org.sf.feeling.decompiler.fernflower/build.properties index 7cb575b9..a5f7a5e7 100644 --- a/org.sf.feeling.decompiler.jad/build.properties +++ b/org.sf.feeling.decompiler.fernflower/build.properties @@ -1,7 +1,7 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - plugin.xml,\ - icons/ -qualifier = 20170815 \ No newline at end of file +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + icons/,\ + lib/fernflower.jar \ No newline at end of file diff --git a/org.sf.feeling.decompiler/icons/fernflower_16.png b/org.sf.feeling.decompiler.fernflower/icons/fernflower_16.png similarity index 100% rename from org.sf.feeling.decompiler/icons/fernflower_16.png rename to org.sf.feeling.decompiler.fernflower/icons/fernflower_16.png diff --git a/org.sf.feeling.decompiler.fernflower/lib/.gitignore b/org.sf.feeling.decompiler.fernflower/lib/.gitignore new file mode 100644 index 00000000..d3f05e7a --- /dev/null +++ b/org.sf.feeling.decompiler.fernflower/lib/.gitignore @@ -0,0 +1 @@ +/fernflower.jar diff --git a/org.sf.feeling.decompiler.jad/plugin.xml b/org.sf.feeling.decompiler.fernflower/plugin.xml similarity index 62% rename from org.sf.feeling.decompiler.jad/plugin.xml rename to org.sf.feeling.decompiler.fernflower/plugin.xml index 7360af12..05c7a1f4 100644 --- a/org.sf.feeling.decompiler.jad/plugin.xml +++ b/org.sf.feeling.decompiler.fernflower/plugin.xml @@ -1,41 +1,38 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/org.sf.feeling.decompiler.fernflower/pom.xml b/org.sf.feeling.decompiler.fernflower/pom.xml new file mode 100644 index 00000000..df625359 --- /dev/null +++ b/org.sf.feeling.decompiler.fernflower/pom.xml @@ -0,0 +1,54 @@ + + 4.0.0 + + + com.github.ecd-plugin + com.github.ecd-plugin.ecd + 3.5.1 + ../pom.xml + + + org.sf.feeling.decompiler.fernflower + eclipse-plugin + + + 17 + 17 + + + + + + org.apache.maven.plugins + maven-dependency-plugin + ${maven.dependency.plugin.version} + + + copy-libraries + validate + + copy + + + + + + + com.jetbrains.intellij.java + java-decompiler-engine + 232.10203.10 + fernflower.jar + + + lib + true + true + + + + + + + diff --git a/org.sf.feeling.decompiler.fernflower/src/org/sf/feeling/decompiler/fernflower/FernFlowerDecompilerPlugin.java b/org.sf.feeling.decompiler.fernflower/src/org/sf/feeling/decompiler/fernflower/FernFlowerDecompilerPlugin.java new file mode 100644 index 00000000..bd8b6e95 --- /dev/null +++ b/org.sf.feeling.decompiler.fernflower/src/org/sf/feeling/decompiler/fernflower/FernFlowerDecompilerPlugin.java @@ -0,0 +1,90 @@ + +package org.sf.feeling.decompiler.fernflower; + +import java.net.MalformedURLException; +import java.net.URL; + +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; +import org.sf.feeling.decompiler.JavaDecompilerPlugin; + +public class FernFlowerDecompilerPlugin extends AbstractUIPlugin implements IPropertyChangeListener { + + public static final String PLUGIN_ID = "org.sf.feeling.decompiler.fernflower"; //$NON-NLS-1$ + + public static final String CMD = "org.sf.feeling.decompiler.fernflower.cmd"; //$NON-NLS-1$ + + public static final String decompilerType = "Fernflower"; //$NON-NLS-1$ + + public static final String decompilerVersion = "1.9.3"; //$NON-NLS-1$ + + private static FernFlowerDecompilerPlugin plugin; + + private IPreferenceStore preferenceStore; + + /* + * (non-Javadoc) + * + * @see + * org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext ) + */ + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + getPreferenceStore().addPropertyChangeListener(this); + } + + /* + * (non-Javadoc) + * + * @see + * org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) + */ + @Override + public void stop(BundleContext context) throws Exception { + super.stop(context); + getPreferenceStore().removePropertyChangeListener(this); + plugin = null; + } + + @Override + public void propertyChange(PropertyChangeEvent event) { + + } + + @Override + public IPreferenceStore getPreferenceStore() { + if (preferenceStore == null) { + preferenceStore = JavaDecompilerPlugin.getDefault().getPreferenceStore(); + } + return preferenceStore; + } + + public static FernFlowerDecompilerPlugin getDefault() { + return plugin; + } + + public FernFlowerDecompilerPlugin() { + plugin = this; + } + + public static ImageDescriptor getImageDescriptor(String path) { + URL base = FernFlowerDecompilerPlugin.getDefault().getBundle().getEntry("/"); //$NON-NLS-1$ + URL url = null; + try { + url = new URL(base, path); // $NON-NLS-1$ + } catch (MalformedURLException e) { + throw new RuntimeException(e); + } + ImageDescriptor actionIcon = null; + if (url != null) { + actionIcon = ImageDescriptor.createFromURL(url); + } + return actionIcon; + } + +} diff --git a/org.sf.feeling.decompiler.fernflower/src/org/sf/feeling/decompiler/fernflower/actions/DecompileWithFernFlowerAction.java b/org.sf.feeling.decompiler.fernflower/src/org/sf/feeling/decompiler/fernflower/actions/DecompileWithFernFlowerAction.java new file mode 100644 index 00000000..af7f26ac --- /dev/null +++ b/org.sf.feeling.decompiler.fernflower/src/org/sf/feeling/decompiler/fernflower/actions/DecompileWithFernFlowerAction.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2017 Chen Chao and other ECD project contributors. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.sf.feeling.decompiler.fernflower.actions; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.jface.action.Action; +import org.sf.feeling.decompiler.fernflower.FernFlowerDecompilerPlugin; +import org.sf.feeling.decompiler.fernflower.i18n.Messages; +import org.sf.feeling.decompiler.util.UIUtil; + +public class DecompileWithFernFlowerAction extends Action { + + public DecompileWithFernFlowerAction() { + super(Messages.getString("JavaDecompilerActionBarContributor.Action.DecompileWithFernFlower")); //$NON-NLS-1$ + this.setImageDescriptor(FernFlowerDecompilerPlugin.getImageDescriptor("icons/fernflower_16.png")); //$NON-NLS-1$ + } + + @Override + public void run() { + try { + new DecompileWithFernFlowerHandler().execute(null); + } catch (ExecutionException e) { + } + } + + @Override + public boolean isEnabled() { + return UIUtil.getActiveEditor() != null || UIUtil.getActiveSelection() != null; + } +} \ No newline at end of file diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DecompileWithFernFlowerHandler.java b/org.sf.feeling.decompiler.fernflower/src/org/sf/feeling/decompiler/fernflower/actions/DecompileWithFernFlowerHandler.java similarity index 54% rename from org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DecompileWithFernFlowerHandler.java rename to org.sf.feeling.decompiler.fernflower/src/org/sf/feeling/decompiler/fernflower/actions/DecompileWithFernFlowerHandler.java index a37d0a74..c4a33d5f 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DecompileWithFernFlowerHandler.java +++ b/org.sf.feeling.decompiler.fernflower/src/org/sf/feeling/decompiler/fernflower/actions/DecompileWithFernFlowerHandler.java @@ -1,26 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.actions; - -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.sf.feeling.decompiler.editor.DecompilerType; - -public class DecompileWithFernFlowerHandler extends BaseDecompilerHandler -{ - - @Override - public Object execute( ExecutionEvent event ) throws ExecutionException - { - return handleDecompile( DecompilerType.FernFlower ); - } -} +/******************************************************************************* + * Copyright (c) 2017 Chen Chao and other ECD project contributors. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.sf.feeling.decompiler.fernflower.actions; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.sf.feeling.decompiler.actions.BaseDecompilerHandler; +import org.sf.feeling.decompiler.fernflower.FernFlowerDecompilerPlugin; + +public class DecompileWithFernFlowerHandler extends BaseDecompilerHandler { + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + return handleDecompile(FernFlowerDecompilerPlugin.decompilerType); + } + +} \ No newline at end of file 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 new file mode 100644 index 00000000..3d4c58d1 --- /dev/null +++ b/org.sf.feeling.decompiler.fernflower/src/org/sf/feeling/decompiler/fernflower/decompiler/FernFlowerDecompiler.java @@ -0,0 +1,224 @@ +/******************************************************************************* + * Copyright (c) 2017 Chen Chao and other ECD project contributors. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.sf.feeling.decompiler.fernflower.decompiler; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FilenameFilter; +import java.io.PrintStream; +import java.util.HashMap; +import java.util.Map; + +import org.apache.commons.lang3.time.StopWatch; +import org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler; +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; +import org.sf.feeling.decompiler.editor.LineNumberOutputType; +import org.sf.feeling.decompiler.util.CommentUtil; +import org.sf.feeling.decompiler.util.FileUtil; +import org.sf.feeling.decompiler.util.JarClassExtractor; +import org.sf.feeling.decompiler.util.UIUtil; +import org.sf.feeling.decompiler.util.UnicodeUtil; + +public class FernFlowerDecompiler extends BaseDecompiler { + + public static final String decompilerType = "FernFlower"; //$NON-NLS-1$ \r\n" + public static final String decompilerVersion = "232.10203.10"; //$NON-NLS-1$ \r\n" + + private long time = 0; + private String source = ""; // $NON-NLS-1$ //$NON-NLS-1$ + private String log = ""; //$NON-NLS-1$ + + ByteArrayOutputStream loggerStream; + + /** + * Performs a Runtime.exec() on FernFlower executable with selected + * options. + * + * @see IDecompiler#decompile(String, String, String) + */ + @Override + public void decompile(String root, String packege, final String className) { + if (root == null || packege == null || className == null) { + return; + } + + StopWatch stopWatch = new StopWatch(); + stopWatch.start(); + + exceptions.clear(); + log = ""; //$NON-NLS-1$ + source = ""; //$NON-NLS-1$ + + loggerStream = new ByteArrayOutputStream(); + + File workingDir = new File(root + "/" + packege); //$NON-NLS-1$ + + final Map mapOptions = new HashMap<>(); + + mapOptions.put(IFernflowerPreferences.REMOVE_SYNTHETIC, "1"); //$NON-NLS-1$ + mapOptions.put(IFernflowerPreferences.DECOMPILE_GENERIC_SIGNATURES, "1"); //$NON-NLS-1$ + mapOptions.put(IFernflowerPreferences.DECOMPILE_INNER, "1"); //$NON-NLS-1$ + mapOptions.put(IFernflowerPreferences.DECOMPILE_ENUM, "1"); //$NON-NLS-1$ + mapOptions.put(IFernflowerPreferences.LOG_LEVEL, IFernflowerLogger.Severity.ERROR.name()); + mapOptions.put(IFernflowerPreferences.ASCII_STRING_CHARACTERS, "1"); //$NON-NLS-1$ + + if (UIUtil.isDebug()) { + mapOptions.put(IFernflowerPreferences.DUMP_ORIGINAL_LINES, "1"); //$NON-NLS-1$ + mapOptions.put(IFernflowerPreferences.BYTECODE_SOURCE_MAPPING, "1"); //$NON-NLS-1$ + } + + final File tmpDir = new File(System.getProperty("java.io.tmpdir"), //$NON-NLS-1$ + String.valueOf(System.currentTimeMillis())); + + if (!tmpDir.exists()) { + tmpDir.mkdirs(); + } + + String classNameFilterTmp = className.toLowerCase(); + if (classNameFilterTmp.endsWith(".class")) { + classNameFilterTmp = classNameFilterTmp.substring(0, classNameFilterTmp.length() - 6); + } + final String classNameFilter = classNameFilterTmp; + + // Work around to get access to protected constructor + class EmbeddedConsoleDecompiler extends ConsoleDecompiler { + + protected EmbeddedConsoleDecompiler() { + super(tmpDir, mapOptions, new PrintStreamLogger(new PrintStream(loggerStream))); + } + + } + ConsoleDecompiler decompiler = new EmbeddedConsoleDecompiler(); + + File[] files = workingDir.listFiles(new FilenameFilter() { + + @Override + public boolean accept(File dir, String name) { + name = name.toLowerCase(); + if (name.startsWith(classNameFilter) && name.endsWith(".class")) { + return true; + } + return false; + } + }); + + for (File f : files) { + decompiler.addSource(f); + } + + decompiler.decompileContext(); + + File classFile = new File(tmpDir, className.replaceAll("(?i)\\.class", ".java")); //$NON-NLS-1$ //$NON-NLS-2$ + + source = UnicodeUtil.decode(FileUtil.getContent(classFile)); + + classFile.delete(); + + FileUtil.deltree(tmpDir); + + source = CommentUtil.clearComments(source); + + time = stopWatch.getTime(); + } + + /** + * Jad doesn't support decompilation from archives. This methods extracts + * request class file from the specified archive into temp directory and then + * calls decompile. + * + * @see IDecompiler#decompileFromArchive(String, String, String) + */ + @Override + public void decompileFromArchive(String archivePath, String packege, String className) { + StopWatch stopWatch = new StopWatch(); + stopWatch.start(); + File workingDir = new File( + JavaDecompilerPlugin.getDefault().getPreferenceStore().getString(JavaDecompilerConstants.TEMP_DIR) + "/" //$NON-NLS-1$ + + System.currentTimeMillis()); + + try { + workingDir.mkdirs(); + JarClassExtractor.extract(archivePath, packege, className, true, workingDir.getAbsolutePath()); + decompile(workingDir.getAbsolutePath(), "", className); //$NON-NLS-1$ + } catch (Exception e) { + exceptions.add(e); + JavaDecompilerPlugin.logError(e, e.getMessage()); + return; + } finally { + FileUtil.deltree(workingDir); + } + time = stopWatch.getTime(); + } + + @Override + public long getDecompilationTime() { + return time; + } + + /** + * @see IDecompiler#getLog() + */ + @Override + public String getLog() { + if (loggerStream != null) { + return log + loggerStream.toString(); + } + return log; + } + + /** + * @see IDecompiler#getSource() + */ + @Override + public String getSource() { + return source; + } + + @Override + public String getDecompilerType() { + return decompilerType; + } + + @Override + public String removeComment(String source) { + return source; + } + + @Override + public boolean supportLevel(int level) { + return true; + } + + @Override + public boolean supportDebugLevel(int level) { + return true; + } + + @Override + public LineNumberOutputType getLineNumberOutputType() { + return LineNumberOutputType.SINGLE_LINE_COMMENT_END_OF_LINE; + } + + @Override + public String getDecompilerName() { + return FernFlowerDecompiler.decompilerType; + } + + @Override + public String getDecompilerVersion() { + return FernFlowerDecompiler.decompilerVersion; + } + +} \ No newline at end of file diff --git a/org.sf.feeling.decompiler.fernflower/src/org/sf/feeling/decompiler/fernflower/decompiler/FernFlowerDecompilerDescriptor.java b/org.sf.feeling.decompiler.fernflower/src/org/sf/feeling/decompiler/fernflower/decompiler/FernFlowerDecompilerDescriptor.java new file mode 100644 index 00000000..07cb26e0 --- /dev/null +++ b/org.sf.feeling.decompiler.fernflower/src/org/sf/feeling/decompiler/fernflower/decompiler/FernFlowerDecompilerDescriptor.java @@ -0,0 +1,67 @@ +package org.sf.feeling.decompiler.fernflower.decompiler; + +import org.eclipse.jface.action.Action; +import org.eclipse.jface.resource.ImageDescriptor; +import org.sf.feeling.decompiler.editor.BaseDecompilerSourceMapper; +import org.sf.feeling.decompiler.editor.IDecompiler; +import org.sf.feeling.decompiler.editor.IDecompilerDescriptor; +import org.sf.feeling.decompiler.fernflower.FernFlowerDecompilerPlugin; +import org.sf.feeling.decompiler.fernflower.actions.DecompileWithFernFlowerAction; +import org.sf.feeling.decompiler.fernflower.i18n.Messages; + +public class FernFlowerDecompilerDescriptor implements IDecompilerDescriptor { + private FernFlowerDecompiler decompiler = null; + private FernFlowerSourceMapper sourceMapper = null; + private Action decompileAction; + + @Override + public String getDecompilerType() { + return FernFlowerDecompilerPlugin.decompilerType; + } + + @Override + public String getDecompilerPreferenceLabel() { + return Messages.getString("FernFlowerDecompilerDescriptor.PreferenceLabel"); //$NON-NLS-1$ + } + + @Override + public IDecompiler getDecompiler() { + if (decompiler == null) { + decompiler = new FernFlowerDecompiler(); + } + return decompiler; + + } + + @Override + public BaseDecompilerSourceMapper getDecompilerSourceMapper() { + if (sourceMapper == null) { + sourceMapper = new FernFlowerSourceMapper(); + } + return sourceMapper; + } + + @Override + public Action getDecompileAction() { + if (decompileAction == null) { + decompileAction = new DecompileWithFernFlowerAction(); + } + return decompileAction; + } + + @Override + public boolean isEnabled() { + return true; + } + + @Override + public int getDefaultPriority() { + return 100; + } + + @Override + public ImageDescriptor getDecompilerIcon() { + return FernFlowerDecompilerPlugin.getImageDescriptor("icons/fernflower_16.png"); //$NON-NLS-1$ + } + +} diff --git a/org.sf.feeling.decompiler.fernflower/src/org/sf/feeling/decompiler/fernflower/decompiler/FernFlowerSourceMapper.java b/org.sf.feeling.decompiler.fernflower/src/org/sf/feeling/decompiler/fernflower/decompiler/FernFlowerSourceMapper.java new file mode 100644 index 00000000..c0215c25 --- /dev/null +++ b/org.sf.feeling.decompiler.fernflower/src/org/sf/feeling/decompiler/fernflower/decompiler/FernFlowerSourceMapper.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2017 Chen Chao and other ECD project contributors. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.sf.feeling.decompiler.fernflower.decompiler; + +import org.eclipse.core.runtime.Path; +import org.sf.feeling.decompiler.editor.BaseDecompilerSourceMapper; + +public class FernFlowerSourceMapper extends BaseDecompilerSourceMapper { + + public FernFlowerSourceMapper() { + super(new Path("."), ""); //$NON-NLS-1$ //$NON-NLS-2$ + originalDecompiler = new FernFlowerDecompiler(); + } + + @Override + protected String getDecompilerName() { + return FernFlowerDecompiler.decompilerType; + } + + @Override + protected String getDecompilerVersion() { + return FernFlowerDecompiler.decompilerVersion; + } + +} \ No newline at end of file diff --git a/org.sf.feeling.decompiler.fernflower/src/org/sf/feeling/decompiler/fernflower/i18n/Messages.java b/org.sf.feeling.decompiler.fernflower/src/org/sf/feeling/decompiler/fernflower/i18n/Messages.java new file mode 100644 index 00000000..519e3a59 --- /dev/null +++ b/org.sf.feeling.decompiler.fernflower/src/org/sf/feeling/decompiler/fernflower/i18n/Messages.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2017 Chen Chao and other ECD project contributors. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.sf.feeling.decompiler.fernflower.i18n; + +import org.sf.feeling.decompiler.i18n.EcdResouceBundle; + +public class Messages { + + private static final EcdResouceBundle RESOURCE_BUNDLE = new EcdResouceBundle(Messages.class); + + private Messages() { + } + + public static String getString(String key) { + return RESOURCE_BUNDLE.getString(key); + } + + /** + * Gets formatted translation for current local + * + * @param key the key + * @return translated value string + */ + public static String getFormattedString(String key, Object[] arguments) { + return RESOURCE_BUNDLE.getFormattedString(key, arguments); + } + +} diff --git a/org.sf.feeling.decompiler.source.attach/plugin.properties b/org.sf.feeling.decompiler.fernflower/src/org/sf/feeling/decompiler/fernflower/i18n/messages.properties similarity index 59% rename from org.sf.feeling.decompiler.source.attach/plugin.properties rename to org.sf.feeling.decompiler.fernflower/src/org/sf/feeling/decompiler/fernflower/i18n/messages.properties index 96a4c23a..af197c02 100644 --- a/org.sf.feeling.decompiler.source.attach/plugin.properties +++ b/org.sf.feeling.decompiler.fernflower/src/org/sf/feeling/decompiler/fernflower/i18n/messages.properties @@ -1,12 +1,10 @@ -############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation -############################################################################### - -action.label=Download Source \ No newline at end of file +############################################################################### +# Copyright (c) 2017 Chen Chao and other ECD project contributors. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# https://www.eclipse.org/legal/epl-v10.html +############################################################################### + +FernFlowerDecompilerDescriptor.PreferenceLabel=FernFlower +JavaDecompilerActionBarContributor.Action.DecompileWithFernFlower=&FernFlower \ No newline at end of file diff --git a/org.sf.feeling.decompiler.jad.feature/feature.properties b/org.sf.feeling.decompiler.jad.feature/feature.properties deleted file mode 100644 index a9ead388..00000000 --- a/org.sf.feeling.decompiler.jad.feature/feature.properties +++ /dev/null @@ -1,135 +0,0 @@ -############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation -############################################################################### - -# feature.properties -# contains externalized strings for feature.xml -# "%foo" in feature.xml corresponds to the key "foo" in this file -# java.io.Properties file (ISO 8859-1 with "\" escapes) -# This file should be translated. - -# "featureName" property - name of the feature -featureName=Eclipse Class Decompiler Jad Extension (Optional) - -# "providerName" property - name of the company that provides the feature -providerName=Chen Chao - -# "updateSiteName" property - label for the update site -updateSiteName=Eclipse Class Decompiler Updates - -# "description" property - description of the feature -description=Eclipse Class Decompiler integrates JD, Jad, FernFlower, CFR, Procyon with Eclipse seamlessly. \ -It allows Java developers to debug class files without source code directly. - -copyrightURL=http://www.cpupk.com/decompiler/update - -copyright=(c) Copyright 2017 Chen Chao(cnfree2000@hotmail.com). All rights reserved.\n - -# "licenseURL" property - URL of the "Feature License" -# do not translate value - just change to point to a locale-specific HTML page -licenseURL=license.html - -# "aboutURL" property - URL of the "About and Change log" -# do not translate value - just change to point to a locale-specific HTML page -aboutURL=about.html - -# "license" property - text of the "Feature Update License" -# should be plain text version of license agreement pointed to be "licenseURL" -license=\ -ECLIPSE FOUNDATION SOFTWARE USER AGREEMENT\n\ -January 28, 2004\n\ -\n\ -Usage Of Content\n\ -\n\ -THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\ -OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\ -USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\ -AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\ -NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU\n\ -AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\ -AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\ -OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\ -TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\ -OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\ -BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\ -\n\ -Applicable Licenses\n\ -\n\ -Unless otherwise indicated, all Content made available by the Eclipse Foundation\n\ -is provided to you under the terms and conditions of the Eclipse Public\n\ -License Version 1.0 ("EPL"). A copy of the EPL is provided with this\n\ -Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\ -For purposes of the EPL, "Program" will mean the Content.\n\ -\n\ -Content includes, but is not limited to, source code, object code,\n\ -documentation and other files maintained in the Eclipse.org CVS\n\ -repository ("Repository") in CVS modules ("Modules") and made available\n\ -as downloadable archives ("Downloads").\n\ -\n\ -Content may be apportioned into plug-ins ("Plug-ins"), plug-in fragments\n\ -("Fragments"), and features ("Features"). A Feature is a bundle of one or\n\ -more Plug-ins and/or Fragments and associated material. Files named\n\ -"feature.xml" may contain a list of the names and version numbers of the\n\ -Plug-ins and/or Fragments associated with a Feature. Plug-ins and Fragments\n\ -are located in directories named "plugins" and Features are located in\n\ -directories named "features".\n\ -\n\ -Features may also include other Features ("Included Features"). Files named\n\ -"feature.xml" may contain a list of the names and version numbers of\n\ -Included Features.\n\ -\n\ -The terms and conditions governing Plug-ins and Fragments should be\n\ -contained in files named "about.html" ("Abouts"). The terms and\n\ -conditions governing Features and Included Features should be contained\n\ -in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\ -Licenses may be located in any directory of a Download or Module\n\ -including, but not limited to the following locations:\n\ -\n\ - - The top-level (root) directory\n\ - - Plug-in and Fragment directories\n\ - - Subdirectories of the directory named "src" of certain Plug-ins\n\ - - Feature directories\n\ -\n\ -Note: if a Feature made available by the Eclipse Foundation is installed using the\n\ -Eclipse Update Manager, you must agree to a license ("Feature Update\n\ -License") during the installation process. If the Feature contains\n\ -Included Features, the Feature Update License should either provide you\n\ -with the terms and conditions governing the Included Features or inform\n\ -you where you can locate them. Feature Update Licenses may be found in\n\ -the "license" property of files named "feature.properties". Such Abouts,\n\ -Feature Licenses and Feature Update Licenses contain the terms and\n\ -conditions (or references to such terms and conditions) that govern your\n\ -use of the associated Content in that directory.\n\ -\n\ -THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER\n\ -TO THE CPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\ -SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\ -\n\ - - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\ - - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\ - - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\ - - IBM Public License 1.0 (available at http://oss.software.ibm.com/developerworks/opensource/license10.html)\n\ - - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\ - - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\ -\n\ -IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\ -TO USE OF THE CONTENT. If no About, Feature License or Feature Update License\n\ -is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\ -govern that particular Content.\n\ -\n\ -Cryptography\n\ -\n\ -Content may contain encryption software. The country in which you are\n\ -currently may have restrictions on the import, possession, and use,\n\ -and/or re-export to another country, of encryption software. BEFORE\n\ -using any encryption software, please check the country's laws,\n\ -regulations and policies concerning the import, possession, or use,\n\ -and re-export of encryption software, to see if this is permitted.\n -########### end of license property ########################################## \ No newline at end of file diff --git a/org.sf.feeling.decompiler.jad.feature/license.html b/org.sf.feeling.decompiler.jad.feature/license.html deleted file mode 100644 index e2323dfc..00000000 --- a/org.sf.feeling.decompiler.jad.feature/license.html +++ /dev/null @@ -1,73 +0,0 @@ - - - - -Eclipse.org Software User Agreement - - - -

    Eclipse Foundation Software User Agreement

    -

    January 28, 2005

    - -

    Usage Of Content

    - -

    THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS - (COLLECTIVELY "CONTENT"). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND - CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE - OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR - NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND - CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.

    - -

    Applicable Licenses

    - -

    Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0 - ("EPL"). A copy of the EPL is provided with this Content and is also available at http://www.eclipse.org/legal/epl-v10.html. - For purposes of the EPL, "Program" will mean the Content.

    - -

    Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse.org CVS repository ("Repository") in CVS - modules ("Modules") and made available as downloadable archives ("Downloads").

    - -

    Content may be apportioned into plug-ins ("Plug-ins"), plug-in fragments ("Fragments"), and features ("Features"). A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material. Files named "feature.xml" may contain a list of the names and version numbers of the Plug-ins and/or Fragments associated with a Feature. Plug-ins and Fragments are located in directories - named "plugins" and Features are located in directories named "features".

    - -

    Features may also include other Features ("Included Features"). Files named "feature.xml" may contain a list of the names and version numbers of Included Features.

    - -

    The terms and conditions governing Plug-ins and Fragments should be contained in files named "about.html" ("Abouts"). The terms and conditions governing Features and -Included Features should be contained in files named "license.html" ("Feature Licenses"). Abouts and Feature Licenses may be located in any directory of a Download or Module -including, but not limited to the following locations:

    - -
      -
    • The top-level (root) directory
    • -
    • Plug-in and Fragment directories
    • -
    • Subdirectories of the directory named "src" of certain Plug-ins
    • -
    • Feature directories
    • -
    - -

    Note: if a Feature made available by the Eclipse Foundation is installed using the Eclipse Update Manager, you must agree to a license ("Feature Update License") during the -installation process. If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or -inform you where you can locate them. Feature Update Licenses may be found in the "license" property of files named "feature.properties". -Such Abouts, Feature Licenses and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in -that directory.

    - -

    THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE -OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):

    - - - -

    IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License or Feature Update License is provided, please -contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.

    - -

    Cryptography

    - -

    Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to - another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import, - possession, or use, and re-export of encryption software, to see if this is permitted.

    - - diff --git a/org.sf.feeling.decompiler.jad/.gitignore b/org.sf.feeling.decompiler.jad/.gitignore deleted file mode 100644 index ae3c1726..00000000 --- a/org.sf.feeling.decompiler.jad/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin/ diff --git a/org.sf.feeling.decompiler.jad/.settings/org.eclipse.core.resources.prefs b/org.sf.feeling.decompiler.jad/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index d74f05b5..00000000 --- a/org.sf.feeling.decompiler.jad/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,4 +0,0 @@ -eclipse.preferences.version=1 -encoding//src/org/sf/feeling/decompiler/jad/i18n/messages_zh_CN.properties=UTF-8 -encoding//src/org/sf/feeling/decompiler/jad/i18n/messages_zh_HK.properties=UTF-8 -encoding//src/org/sf/feeling/decompiler/jad/i18n/messages_zh_TW.properties=UTF-8 diff --git a/org.sf.feeling.decompiler.jad/.settings/org.eclipse.jdt.core.prefs b/org.sf.feeling.decompiler.jad/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 36413b06..00000000 --- a/org.sf.feeling.decompiler.jad/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,81 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.autoboxing=ignore -org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning -org.eclipse.jdt.core.compiler.problem.deadCode=warning -org.eclipse.jdt.core.compiler.problem.deprecation=ignore -org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled -org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled -org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore -org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore -org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled -org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore -org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore -org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning -org.eclipse.jdt.core.compiler.problem.forbiddenReference=ignore -org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning -org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled -org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning -org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore -org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore -org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore -org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore -org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled -org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning -org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore -org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning -org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning -org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore -org.eclipse.jdt.core.compiler.problem.nullReference=warning -org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning -org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore -org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore -org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore -org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore -org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore -org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore -org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore -org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore -org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore -org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled -org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning -org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled -org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled -org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore -org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning -org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled -org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore -org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore -org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning -org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore -org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore -org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled -org.eclipse.jdt.core.compiler.problem.unusedImport=warning -org.eclipse.jdt.core.compiler.problem.unusedLabel=warning -org.eclipse.jdt.core.compiler.problem.unusedLocal=warning -org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled -org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning -org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning -org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/org.sf.feeling.decompiler.jad/META-INF/MANIFEST.MF b/org.sf.feeling.decompiler.jad/META-INF/MANIFEST.MF deleted file mode 100644 index 2e5b47ea..00000000 --- a/org.sf.feeling.decompiler.jad/META-INF/MANIFEST.MF +++ /dev/null @@ -1,28 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Eclipse Class Decompiler Jad Extension -Bundle-SymbolicName: org.sf.feeling.decompiler.jad;singleton:=true -Bundle-Version: 2.10.0.qualifier -Bundle-Activator: org.sf.feeling.decompiler.jad.JadDecompilerPlugin -Require-Bundle: org.eclipse.core.runtime, - org.sf.feeling.decompiler, - org.eclipse.core.resources, - org.eclipse.jface, - org.eclipse.jface.text, - org.eclipse.ui.editors, - org.eclipse.ui.workbench, - org.eclipse.ui.workbench.texteditor, - org.eclipse.jdt.core, - org.eclipse.jdt.ui, - org.eclipse.jdt.debug.ui, - org.eclipse.debug.ui, - org.eclipse.jdt.launching, - org.eclipse.core.expressions, - org.eclipse.ui.navigator, - org.eclipse.ui.ide;resolution:=optional, - org.eclipse.core.filesystem -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Bundle-ActivationPolicy: lazy -Bundle-Vendor: Chen Chao -Export-Package: org.sf.feeling.decompiler.jad.actions, - org.sf.feeling.decompiler.jad.decompiler diff --git a/org.sf.feeling.decompiler.jad/icons/jad_16.gif b/org.sf.feeling.decompiler.jad/icons/jad_16.gif deleted file mode 100644 index b44ac377..00000000 Binary files a/org.sf.feeling.decompiler.jad/icons/jad_16.gif and /dev/null differ diff --git a/org.sf.feeling.decompiler.jad/src/native/jad/linux/jad b/org.sf.feeling.decompiler.jad/src/native/jad/linux/jad deleted file mode 100644 index 981fa277..00000000 Binary files a/org.sf.feeling.decompiler.jad/src/native/jad/linux/jad and /dev/null differ diff --git a/org.sf.feeling.decompiler.jad/src/native/jad/macosx/jad b/org.sf.feeling.decompiler.jad/src/native/jad/macosx/jad deleted file mode 100644 index 3034bacf..00000000 Binary files a/org.sf.feeling.decompiler.jad/src/native/jad/macosx/jad and /dev/null differ diff --git a/org.sf.feeling.decompiler.jad/src/native/jad/win32/jad.exe b/org.sf.feeling.decompiler.jad/src/native/jad/win32/jad.exe deleted file mode 100644 index 983e2a93..00000000 Binary files a/org.sf.feeling.decompiler.jad/src/native/jad/win32/jad.exe and /dev/null differ diff --git a/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/JadDecompilerPlugin.java b/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/JadDecompilerPlugin.java deleted file mode 100644 index 51c1b78b..00000000 --- a/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/JadDecompilerPlugin.java +++ /dev/null @@ -1,118 +0,0 @@ - -package org.sf.feeling.decompiler.jad; - -import java.net.MalformedURLException; -import java.net.URL; - -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; -import org.sf.feeling.decompiler.JavaDecompilerPlugin; -import org.sf.feeling.decompiler.jad.decompiler.JadDecompiler; -import org.sf.feeling.decompiler.jad.decompiler.JadLoader; - -public class JadDecompilerPlugin extends AbstractUIPlugin implements IPropertyChangeListener -{ - - public static final String PLUGIN_ID = "org.sf.feeling.decompiler.jad"; //$NON-NLS-1$ - - public static final String CMD = "org.sf.feeling.decompiler.jad.cmd"; //$NON-NLS-1$ - - public static final String decompilerType = "Jad"; //$NON-NLS-1$ - - private static JadDecompilerPlugin plugin; - - private IPreferenceStore preferenceStore; - - /* - * (non-Javadoc) - * - * @see - * org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext - * ) - */ - @Override - public void start( BundleContext context ) throws Exception - { - super.start( context ); - getPreferenceStore( ).addPropertyChangeListener( this ); - } - - /* - * (non-Javadoc) - * - * @see - * org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) - */ - @Override - public void stop( BundleContext context ) throws Exception - { - super.stop( context ); - getPreferenceStore( ).removePropertyChangeListener( this ); - plugin = null; - } - - @Override - public void propertyChange( PropertyChangeEvent event ) - { - - } - - @Override - public IPreferenceStore getPreferenceStore( ) - { - if ( preferenceStore == null ) - { - preferenceStore = JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ); - - IPreferenceStore decompilerStore = preferenceStore; - String jad = JadLoader.loadJad( ); - if ( jad != null ) - decompilerStore.setDefault( CMD, jad ); - - decompilerStore.setDefault( JadDecompiler.OPTION_INDENT_SPACE, 4 ); - decompilerStore.setDefault( JadDecompiler.OPTION_IRADIX, 10 ); - decompilerStore.setDefault( JadDecompiler.OPTION_LRADIX, 10 ); - decompilerStore.setDefault( JadDecompiler.OPTION_SPLITSTR_MAX, 0 ); - decompilerStore.setDefault( JadDecompiler.OPTION_PI, 0 ); - decompilerStore.setDefault( JadDecompiler.OPTION_PV, 0 ); - decompilerStore.setDefault( JadDecompiler.OPTION_FIELDSFIRST, true ); - decompilerStore.setDefault( JadDecompiler.OPTION_NOCTOR, true ); - decompilerStore.setDefault( JadDecompiler.OPTION_ANSI, false ); - - } - return preferenceStore; - } - - public static JadDecompilerPlugin getDefault( ) - { - return plugin; - } - - public JadDecompilerPlugin( ) - { - plugin = this; - } - - public static ImageDescriptor getImageDescriptor( String path ) - { - URL base = JadDecompilerPlugin.getDefault( ).getBundle( ).getEntry( "/" ); //$NON-NLS-1$ - URL url = null; - try - { - url = new URL( base, path ); // $NON-NLS-1$ - } - catch ( MalformedURLException e ) - { - e.printStackTrace( ); - } - ImageDescriptor actionIcon = null; - if ( url != null ) - actionIcon = ImageDescriptor.createFromURL( url ); - return actionIcon; - } - -} diff --git a/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/actions/DecompileWithJadAction.java b/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/actions/DecompileWithJadAction.java deleted file mode 100644 index e9424fb6..00000000 --- a/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/actions/DecompileWithJadAction.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.jad.actions; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.jface.action.Action; -import org.sf.feeling.decompiler.jad.JadDecompilerPlugin; -import org.sf.feeling.decompiler.jad.i18n.Messages; -import org.sf.feeling.decompiler.util.UIUtil; - -public class DecompileWithJadAction extends Action -{ - - public DecompileWithJadAction( ) - { - super( Messages.getString( "JavaDecompilerActionBarContributor.Action.DecompileWithJad" ) ); //$NON-NLS-1$ - this.setImageDescriptor( JadDecompilerPlugin.getImageDescriptor( "icons/jad_16.gif" ) ); //$NON-NLS-1$ - } - - @Override - public void run( ) - { - try - { - new DecompileWithJadHandler( ).execute( null ); - } - catch ( ExecutionException e ) - { - } - } - - @Override - public boolean isEnabled( ) - { - return UIUtil.getActiveEditor( ) != null || UIUtil.getActiveSelection( ) != null; - } -} \ No newline at end of file diff --git a/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/decompiler/JadDecompiler.java b/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/decompiler/JadDecompiler.java deleted file mode 100644 index 7bfed870..00000000 --- a/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/decompiler/JadDecompiler.java +++ /dev/null @@ -1,497 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.jad.decompiler; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.eclipse.jface.preference.IPreferenceStore; -import org.sf.feeling.decompiler.JavaDecompilerPlugin; -import org.sf.feeling.decompiler.editor.IDecompiler; -import org.sf.feeling.decompiler.jad.JadDecompilerPlugin; -import org.sf.feeling.decompiler.util.ClassUtil; -import org.sf.feeling.decompiler.util.FileUtil; -import org.sf.feeling.decompiler.util.JarClassExtractor; -import org.sf.feeling.decompiler.util.UnicodeUtil; - -/** - * This implementation of IDecompiler uses Jad as the underlying - * decompler. - */ -public class JadDecompiler implements IDecompiler -{ - - public static final String OPTION_ANNOTATE = "-a"; // format //$NON-NLS-1$ - public static final String OPTION_ANNOTATE_FQ = "-af"; // format //$NON-NLS-1$ - public static final String OPTION_BRACES = "-b"; // format //$NON-NLS-1$ - public static final String OPTION_CLEAR = "-clear"; // format //$NON-NLS-1$ - public static final String OPTION_DIR = "-d"; // ? //$NON-NLS-1$ - public static final String OPTION_DEAD = "-dead"; // directives //$NON-NLS-1$ - public static final String OPTION_DISASSEMBLER = "-dis"; // directives //$NON-NLS-1$ - public static final String OPTION_FULLNAMES = "-f"; // format //$NON-NLS-1$ - public static final String OPTION_FIELDSFIRST = "-ff"; // format //$NON-NLS-1$ - public static final String OPTION_DEFINITS = "-i"; // format //$NON-NLS-1$ - public static final String OPTION_SPLITSTR_MAX = "-l"; // format //$NON-NLS-1$ - public static final String OPTION_LNC = JavaDecompilerPlugin.PREF_DISPLAY_LINE_NUMBERS;// "-lnc"; - // // - // debug - public static final String OPTION_LRADIX = "-lradix"; // format //$NON-NLS-1$ - public static final String OPTION_SPLITSTR_NL = "-nl"; // format //$NON-NLS-1$ - public static final String OPTION_NOCONV = "-noconv"; // directives //$NON-NLS-1$ - public static final String OPTION_NOCAST = "-nocast"; // directives //$NON-NLS-1$ - public static final String OPTION_NOCLASS = "-noclass"; // directives //$NON-NLS-1$ - public static final String OPTION_NOCODE = "-nocode"; // directives //$NON-NLS-1$ - public static final String OPTION_NOCTOR = "-noctor"; // directives //$NON-NLS-1$ - public static final String OPTION_NODOS = "-nodos"; // directives //$NON-NLS-1$ - public static final String OPTION_NOFLDIS = "-nofd"; // directives //$NON-NLS-1$ - public static final String OPTION_NOINNER = "-noinner"; // directives //$NON-NLS-1$ - public static final String OPTION_NOLVT = "-nolvt"; // directives //$NON-NLS-1$ - public static final String OPTION_NONLB = "-nonlb"; // format //$NON-NLS-1$ - public static final String OPTION_OVERWRITE = "-o"; // ? //$NON-NLS-1$ - public static final String OPTION_SENDSTDOUT = "-p"; // ? //$NON-NLS-1$ - public static final String OPTION_PA = "-pa"; // directives //$NON-NLS-1$ - public static final String OPTION_PC = "-pc"; // directives //$NON-NLS-1$ - public static final String OPTION_PE = "-pe"; // directives //$NON-NLS-1$ - public static final String OPTION_PF = "-pf"; // directives //$NON-NLS-1$ - public static final String OPTION_PI = "-pi"; // format //$NON-NLS-1$ - public static final String OPTION_PL = "-pl"; // directives //$NON-NLS-1$ - public static final String OPTION_PM = "-pm"; // directives //$NON-NLS-1$ - public static final String OPTION_PP = "-pp"; // directives //$NON-NLS-1$ - public static final String OPTION_PV = "-pv"; // format //$NON-NLS-1$ - public static final String OPTION_RESTORE = "-r"; // ? //$NON-NLS-1$ - public static final String OPTION_IRADIX = "-radix"; // format //$NON-NLS-1$ - public static final String OPTION_EXT = "-s"; // ? //$NON-NLS-1$ - public static final String OPTION_SAFE = "-safe"; // directives //$NON-NLS-1$ - public static final String OPTION_SPACE = "-space"; // format //$NON-NLS-1$ - public static final String OPTION_STAT = "-stat"; // misc //$NON-NLS-1$ - public static final String OPTION_INDENT_SPACE = "-t"; // format //$NON-NLS-1$ - public static final String OPTION_INDENT_TAB = "-t"; // ? //$NON-NLS-1$ - public static final String OPTION_VERBOSE = "-v"; // misc //$NON-NLS-1$ - public static final String OPTION_ANSI = "-8"; // misc //$NON-NLS-1$ - public static final String OPTION_REDSTDERR = "-&"; // ? //$NON-NLS-1$ - - public static final String USE_TAB = "use tab"; //$NON-NLS-1$ - - public static final String[] TOGGLE_OPTION = { - OPTION_ANNOTATE, - OPTION_ANNOTATE_FQ, - OPTION_BRACES, - OPTION_CLEAR, - OPTION_DEAD, - OPTION_DISASSEMBLER, - OPTION_FULLNAMES, - OPTION_FIELDSFIRST, - OPTION_DEFINITS, - OPTION_LNC, - OPTION_SPLITSTR_NL, - OPTION_NOCONV, - OPTION_NOCAST, - OPTION_NOCLASS, - OPTION_NOCODE, - OPTION_NOCTOR, - OPTION_NODOS, - OPTION_NOFLDIS, - OPTION_NOINNER, - OPTION_NOLVT, - OPTION_NONLB, - /* OPTION_OVERWRITE, */ - /* OPTION_SENDSTDOUT, */ - /* OPTION_RESTORE, */ - OPTION_SAFE, - OPTION_SPACE, - OPTION_STAT, - OPTION_INDENT_TAB, - OPTION_VERBOSE, - OPTION_ANSI, - /* OPTION_REDSTDERR */ - }; - - public static final String[] VALUE_OPTION_STRING = { - /* OPTION_DIR, */ - OPTION_PA, OPTION_PC, OPTION_PE, OPTION_PF, OPTION_PL, OPTION_PM, OPTION_PP, - /* OPTION_EXT, */ - }; - - public static final String[] VALUE_OPTION_INT = { - /* OPTION_INDENT_SPACE, */ - OPTION_SPLITSTR_MAX, OPTION_LRADIX, OPTION_PI, OPTION_PV, OPTION_IRADIX, - }; - - private String source = "/* ERROR? */"; //$NON-NLS-1$ - private StringBuffer log; - private List excList = new ArrayList( ); - private long time, start; - - private String[] buildCmdLine( String classFileName ) - { - ArrayList cmdLine = new ArrayList( ); - IPreferenceStore settings = JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ); - - // command and special options - cmdLine.add( settings.getString( JadDecompilerPlugin.CMD ) ); - cmdLine.add( OPTION_SENDSTDOUT ); - - String indent = settings.getString( OPTION_INDENT_SPACE ); - if ( indent.equals( USE_TAB ) ) - cmdLine.add( OPTION_INDENT_TAB ); - else - { - try - { - Integer.parseInt( indent ); - cmdLine.add( OPTION_INDENT_SPACE + indent ); - } - catch ( Exception e ) - { - } - } - - // toggles - for ( int i = 0; i < TOGGLE_OPTION.length; i++ ) - { - if ( settings.getBoolean( TOGGLE_OPTION[i] ) ) - { - if ( OPTION_LNC.equals( TOGGLE_OPTION[i] ) ) - { - // cmdLine.add( "-lnc" ); //$NON-NLS-1$ - } - else - cmdLine.add( TOGGLE_OPTION[i] ); - } - } - - if ( ClassUtil.isDebug( ) ) - { - cmdLine.add( "-lnc" ); //$NON-NLS-1$ - } - - // integers, 0 means disabled - int iValue; - for ( int i = 0; i < VALUE_OPTION_INT.length; i++ ) - { - iValue = settings.getInt( VALUE_OPTION_INT[i] ); - if ( iValue > 0 ) - cmdLine.add( VALUE_OPTION_INT[i] + iValue ); - } - - // strings, "" means disabled - String sValue; - for ( int i = 0; i < VALUE_OPTION_STRING.length; i++ ) - { - sValue = settings.getString( VALUE_OPTION_STRING[i] ); - if ( sValue != null && sValue.length( ) > 0 ) - cmdLine.add( VALUE_OPTION_STRING[i] + " " + sValue ); //$NON-NLS-1$ - - } - - cmdLine.add( classFileName ); - // debugCmdLine(cmdLine); - return (String[]) cmdLine.toArray( new String[cmdLine.size( )] ); - - } - - void debugCmdLine( List segments ) - { - StringBuffer cmdline = new StringBuffer( ); - for ( int i = 0; i < segments.size( ); i++ ) - cmdline.append( segments.get( i ) ).append( " " ); //$NON-NLS-1$ - System.err.println( "-> " + cmdline.toString( ) ); //$NON-NLS-1$ - } - - /** - * Performs a Runtime.exec() on jad executable with selected - * options. - * - * @see IDecompiler#decompile(String, String, String) - */ - @Override - public void decompile( String root, String packege, String className ) - { - log = new StringBuffer( ); - source = ""; //$NON-NLS-1$ - File workingDir = new File( root + "/" + packege ); //$NON-NLS-1$ - ByteArrayOutputStream bos = new ByteArrayOutputStream( ); - ByteArrayOutputStream errors = new ByteArrayOutputStream( ); - PrintWriter errorsP = new PrintWriter( new OutputStreamWriter( errors ) ); - // errorsP.println("\n\n\n/***** DECOMPILE LOG *****\n"); - int status = 0; - - try - { - start = System.currentTimeMillis( ); - errorsP.println( "\tJad reported messages/errors:" ); //$NON-NLS-1$ - Process p = Runtime.getRuntime( ).exec( buildCmdLine( className ), new String[]{}, workingDir ); - StreamRedirectThread outRedirect = new StreamRedirectThread( "output_reader", //$NON-NLS-1$ - p.getInputStream( ), - bos ); - StreamRedirectThread errRedirect = new StreamRedirectThread( "error_reader", //$NON-NLS-1$ - p.getErrorStream( ), - errors ); - outRedirect.start( ); - errRedirect.start( ); - status = p.waitFor( ); // wait for jad to finish - outRedirect.join( ); // wait until output stream content is fully - // copied - errRedirect.join( ); // wait until error stream content is fully - // copied - if ( outRedirect.getException( ) != null ) - excList.add( outRedirect.getException( ) ); - if ( errRedirect.getException( ) != null ) - excList.add( errRedirect.getException( ) ); - } - catch ( Exception e ) - { - excList.add( e ); - } - finally - { - try - { - bos.flush( ); - bos.close( ); - errorsP.println( "\tExit status: " + status ); //$NON-NLS-1$ - // errorsP.print(" *************************/"); - errors.flush( ); - errorsP.close( ); - } - catch ( Exception e ) - { - excList.add( e ); // will never get here... - } - time = System.currentTimeMillis( ) - start; - } - - source = UnicodeUtil.decode( bos.toString( ) ); - - log = new StringBuffer( errors.toString( ) ); - // logExceptions(); - // result = new DecompiledClassFile(classFile, source.toString()); - } - - /** - * Jad doesn't support decompilation from archives. This methods extracts - * request class file from the specified archive into temp directory and - * then calls decompile. - * - * @see IDecompiler#decompileFromArchive(String, String, String) - */ - @Override - 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$ - + System.currentTimeMillis( ) ); - - try - { - workingDir.mkdirs( ); - JarClassExtractor.extract( archivePath, packege, className, true, workingDir.getAbsolutePath( ) ); - decompile( workingDir.getAbsolutePath( ), "", className ); //$NON-NLS-1$ - } - catch ( Exception e ) - { - excList.add( e ); - // logExceptions(); - return; - } - finally - { - FileUtil.deltree( workingDir ); - } - } - - @Override - public long getDecompilationTime( ) - { - return time; - } - - @Override - public List getExceptions( ) - { - return excList; - } - - /** - * @see IDecompiler#getLog() - */ - @Override - public String getLog( ) - { - return log == null ? "" : log.toString( ); //$NON-NLS-1$ - } - - // private void logExceptions() - // { - // if (log == null) log = new StringBuffer(); - // log.append("\n\tCAUGHT EXCEPTIONS:\n"); - // if (excList.size() == 0) return; - // StringWriter stackTraces = new StringWriter(); - // PrintWriter stackTracesP = new PrintWriter(stackTraces); - // - // for (int i = 0; i < excList.size(); i++) - // { - // ((Exception) excList.get(i)).printStackTrace(stackTracesP); - // stackTracesP.println(""); - // } - // - // stackTracesP.flush(); - // stackTracesP.close(); - // log.append(stackTraces.toString()); - // } - - /** - * @see IDecompiler#getSource() - */ - @Override - public String getSource( ) - { - return source; - } - - @Override - public String getDecompilerType( ) - { - return JadDecompilerPlugin.decompilerType; - } - - @Override - public String removeComment( String source ) - { - - String[] spilts = source.replaceAll( "\r\n", "\n" ).split( "\n" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - StringBuffer buffer = new StringBuffer( ); - for ( int i = 0; i < spilts.length; i++ ) - { - if ( i > 0 && i < 5 ) - continue; - String string = spilts[i]; - Pattern pattern = Pattern.compile( "\\s*/\\*\\s*\\S*\\*/", //$NON-NLS-1$ - Pattern.CASE_INSENSITIVE ); - Matcher matcher = pattern.matcher( string ); - if ( matcher.find( ) ) - { - if ( matcher.start( ) == 0 ) - { - buffer.append( string ).append( "\r\n" ); //$NON-NLS-1$ - continue; - } - } - - boolean refer = false; - - pattern = Pattern.compile( "\\s*// Referenced", //$NON-NLS-1$ - Pattern.CASE_INSENSITIVE ); - matcher = pattern.matcher( string ); - if ( matcher.find( ) ) - { - refer = true; - - while ( true ) - { - i++; - if ( spilts[i].trim( ).startsWith( "//" ) ) //$NON-NLS-1$ - { - continue; - } - else if ( i >= spilts.length ) - { - break; - } - else - { - i--; - break; - } - } - } - - if ( !refer ) - buffer.append( string + "\r\n" ); //$NON-NLS-1$ - } - return buffer.toString( ); - - } - - @Override - public boolean supportLevel( int level ) - { - return level < 8; - } - - @Override - public boolean supportDebugLevel( int level ) - { - return level < 8; - } - - @Override - public boolean supportDebug( ) - { - return true; - } -} - -// OPTION_ANNOTATE, -// OPTION_ANNOTATE_FQ, -// OPTION_BRACES, -// OPTION_CLEAR, -// OPTION_DIR, -// OPTION_DEAD, -// OPTION_DISASSEMBLER, -// OPTION_FULLNAMES, -// OPTION_FIELDSFIRST, -// OPTION_DEFINITS, -// OPTION_SPLITSTR_MAX, -// OPTION_LNC, -// OPTION_LRADIX, -// OPTION_SPLITSTR_NL, -// OPTION_NOCONV, -// OPTION_NOCAST, -// OPTION_NOCLASS, -// OPTION_NOCODE, -// OPTION_NOCTOR, -// OPTION_NODOS, -// OPTION_NOFLDIS, -// OPTION_NOINNER, -// OPTION_NOLVT, -// OPTION_NOLB, -// OPTION_OVERWRITE, -// OPTION_SENDSTDOUT, -// OPTION_PA, -// OPTION_PC, -// OPTION_PE, -// OPTION_PF, -// OPTION_PI, -// OPTION_PL, -// OPTION_PM, -// OPTION_PP, -// OPTION_PV, -// OPTION_RESTORE, -// OPTION_IRADIX, -// OPTION_EXT, -// OPTION_SAFE, -// OPTION_SPACE, -// OPTION_STAT, -// OPTION_INDENT_SPACE, -// OPTION_INDENT_TAB, -// OPTION_VERBOSE, -// OPTION_ANSI, -// OPTION_REDSTDERR \ No newline at end of file diff --git a/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/decompiler/JadDecompilerDescriptor.java b/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/decompiler/JadDecompilerDescriptor.java deleted file mode 100644 index 5f8502d7..00000000 --- a/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/decompiler/JadDecompilerDescriptor.java +++ /dev/null @@ -1,80 +0,0 @@ - -package org.sf.feeling.decompiler.jad.decompiler; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.resource.ImageDescriptor; -import org.sf.feeling.decompiler.editor.BaseDecompilerSourceMapper; -import org.sf.feeling.decompiler.editor.IDecompiler; -import org.sf.feeling.decompiler.editor.IDecompilerDescriptor; -import org.sf.feeling.decompiler.jad.JadDecompilerPlugin; -import org.sf.feeling.decompiler.jad.actions.DecompileWithJadAction; -import org.sf.feeling.decompiler.jad.i18n.Messages; - -public class JadDecompilerDescriptor implements IDecompilerDescriptor -{ - - private JadDecompiler decompiler = null; - - private BaseDecompilerSourceMapper sourceMapper = null; - - private Action decompileAction = null; - - @Override - public String getDecompilerType( ) - { - return JadDecompilerPlugin.decompilerType; - } - - @Override - public String getDecompilerPreferenceLabel( ) - { - return Messages.getString( "JadDecompilerDescriptor.PreferenceLabel" ); //$NON-NLS-1$ - } - - @Override - public IDecompiler getDecompiler( ) - { - if ( decompiler == null ) - decompiler = new JadDecompiler( ); - return decompiler; - } - - @Override - public BaseDecompilerSourceMapper getDecompilerSourceMapper( ) - { - if ( sourceMapper == null ) - { - sourceMapper = new JadSourceMapper( ); - } - return sourceMapper; - } - - @Override - public Action getDecompileAction( ) - { - if ( decompileAction == null ) - { - decompileAction = new DecompileWithJadAction( ); - } - return decompileAction; - } - - @Override - public boolean isEnabled( ) - { - return true; - } - - @Override - public boolean isDefault( ) - { - return false; - } - - @Override - public ImageDescriptor getDecompilerIcon( ) - { - return JadDecompilerPlugin.getImageDescriptor( "icons/jad_16.gif" ); //$NON-NLS-1$ ; - } - -} diff --git a/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/decompiler/JadLoader.java b/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/decompiler/JadLoader.java deleted file mode 100644 index c7e5d724..00000000 --- a/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/decompiler/JadLoader.java +++ /dev/null @@ -1,127 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.jad.decompiler; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; - -import org.eclipse.core.runtime.Platform; -import org.sf.feeling.decompiler.JavaDecompilerPlugin; - -public final class JadLoader -{ - - public static String loadJad( ) - { - String jadFileName = null; - String jadFilePath = null; - - if ( Platform.OS_WIN32.equalsIgnoreCase( Platform.getOS( ) ) ) - { - jadFileName = "jad" + System.currentTimeMillis( ) + ".exe"; //$NON-NLS-1$ //$NON-NLS-2$ - jadFilePath = "/native/jad/win32/jad.exe"; //$NON-NLS-1$ - } - else if ( Platform.OS_LINUX.equalsIgnoreCase( Platform.getOS( ) ) ) - { - jadFileName = "jad" + System.currentTimeMillis( ); //$NON-NLS-1$ - jadFilePath = "/native/jad/linux/jad"; //$NON-NLS-1$ - } - else if ( Platform.OS_MACOSX.equalsIgnoreCase( Platform.getOS( ) ) ) - { - jadFileName = "jad" + System.currentTimeMillis( ); //$NON-NLS-1$ - jadFilePath = "/native/jad/macosx/jad"; //$NON-NLS-1$ - } - else - { - throw new Error( "Can't obtain jad executable file." ); //$NON-NLS-1$ - } - - InputStream is = JadLoader.class.getResourceAsStream( jadFilePath ); // $NON-NLS-1$ - if ( is == null ) - { - throw new Error( "Can't obtain jad executable file." ); //$NON-NLS-1$ - } - - FileOutputStream fos = null; - try - { - File tempDir = new File(JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ).getString( JavaDecompilerPlugin.TEMP_DIR )); - if(!tempDir.exists( )) { - tempDir.mkdirs( ); - } - File jad = new File( tempDir, jadFileName ); - jad.createNewFile( ); - jad.deleteOnExit( ); - fos = new FileOutputStream( jad ); - int count; - byte[] buf = new byte[1024]; - while ( ( count = is.read( buf, 0, buf.length ) ) > 0 ) - { - fos.write( buf, 0, count ); - } - fos.close( ); - fos = null; - - try - { - if ( Platform.OS_LINUX.equalsIgnoreCase( Platform.getOS( ) ) ) - { - Runtime.getRuntime( ) - .exec( "chmod a+x " //$NON-NLS-1$ - + jad.getAbsolutePath( ) ) - .waitFor( ); - } - else if ( Platform.OS_MACOSX.equalsIgnoreCase( Platform.getOS( ) ) ) - { - Runtime.getRuntime( ) - .exec( "chmod a+x " //$NON-NLS-1$ - + jad.getAbsolutePath( ) ) - .waitFor( ); - } - } - catch ( InterruptedException e ) - { - e.printStackTrace( ); - } - - // jad.setExecutable( true ); - return jad.getAbsolutePath( ); - } - catch ( IOException e ) - { - throw new Error( "Failed to create temporary file for jad.exe: " //$NON-NLS-1$ - + e ); - } - finally - { - try - { - is.close( ); - } - catch ( IOException e ) - { - } - if ( fos != null ) - { - try - { - fos.close( ); - } - catch ( IOException e ) - { - } - } - } - } -} diff --git a/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/decompiler/JadSourceMapper.java b/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/decompiler/JadSourceMapper.java deleted file mode 100644 index a64a4307..00000000 --- a/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/decompiler/JadSourceMapper.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.jad.decompiler; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Collection; -import java.util.Iterator; - -import org.eclipse.core.runtime.Path; -import org.sf.feeling.decompiler.editor.BaseDecompilerSourceMapper; - -public class JadSourceMapper extends BaseDecompilerSourceMapper -{ - - public JadSourceMapper( ) - { - super( new Path( "." ), "" ); //$NON-NLS-1$ //$NON-NLS-2$ - origionalDecompiler = new JadDecompiler( ); - } - - protected void logExceptions( Collection exceptions, StringBuffer buffer ) - { - if ( !exceptions.isEmpty( ) ) - { - buffer.append( "\n\tCaught exceptions:" ); //$NON-NLS-1$ - if ( exceptions == null || exceptions.size( ) == 0 ) - return; // nothing to do - buffer.append( "\n" ); //$NON-NLS-1$ - StringWriter stackTraces = new StringWriter( ); - PrintWriter stackTracesP = new PrintWriter( stackTraces ); - - Iterator i = exceptions.iterator( ); - while ( i.hasNext( ) ) - { - ( (Exception) i.next( ) ).printStackTrace( stackTracesP ); - stackTracesP.println( "" ); //$NON-NLS-1$ - } - - stackTracesP.flush( ); - stackTracesP.close( ); - buffer.append( stackTraces.toString( ) ); - } - } - - @Override - protected void printDecompileReport( StringBuffer source, String fileLocation, Collection exceptions, - long decompilationTime ) - { - String location = "\tDecompiled from: " //$NON-NLS-1$ - + fileLocation; - source.append( "\n\n/*" ); //$NON-NLS-1$ - source.append( "\n\tDECOMPILATION REPORT\n\n" ); //$NON-NLS-1$ - source.append( location ).append( "\n" ); //$NON-NLS-1$ - source.append( "\tTotal time: " ) //$NON-NLS-1$ - .append( decompilationTime ) - .append( " ms\n" ); //$NON-NLS-1$ - source.append( "\t" //$NON-NLS-1$ - + origionalDecompiler.getLog( ).replaceAll( "\t", "" ).replaceAll( "\n", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - "\n\t" ) ); //$NON-NLS-1$ - logExceptions( exceptions, source ); - source.append( "\n*/" ); //$NON-NLS-1$ - } - -} \ No newline at end of file diff --git a/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/decompiler/StreamRedirectThread.java b/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/decompiler/StreamRedirectThread.java deleted file mode 100644 index aebe8c5c..00000000 --- a/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/decompiler/StreamRedirectThread.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.jad.decompiler; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -class StreamRedirectThread extends Thread -{ - - private final InputStream in; - private final OutputStream out; - private Exception ex; - - private static final int BUFFER_SIZE = 2048; - - StreamRedirectThread( String name, InputStream in, OutputStream out ) - { - super( name ); - this.in = in; - this.out = out; - setPriority( Thread.MAX_PRIORITY - 1 ); - } - - public Exception getException( ) - { - return ex; - } - - /** - * Copy. - */ - @Override - public void run( ) - { - try - { - byte[] cbuf = new byte[BUFFER_SIZE]; - int count; - while ( ( count = in.read( cbuf, 0, BUFFER_SIZE ) ) >= 0 ) - { - out.write( cbuf, 0, count ); - out.flush( ); - } - } - catch ( IOException exc ) - { - // System.err.println("Child I/O Transfer - " + exc); - ex = exc; - } - } -} \ No newline at end of file diff --git a/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/i18n/Messages.java b/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/i18n/Messages.java deleted file mode 100644 index 1d415603..00000000 --- a/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/i18n/Messages.java +++ /dev/null @@ -1,53 +0,0 @@ - -package org.sf.feeling.decompiler.jad.i18n; - -import java.io.UnsupportedEncodingException; -import java.text.MessageFormat; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -public class Messages -{ - - private static final String BUNDLE_NAME = "org.sf.feeling.decompiler.jad.i18n.messages"; //$NON-NLS-1$ - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); - - private Messages( ) - { - } - - public static String getString( String key ) - { - - try - { - String result = RESOURCE_BUNDLE.getString( key ); - try - { - result = new String( result.getBytes( "ISO-8859-1" ), "utf-8" ); //$NON-NLS-1$ //$NON-NLS-2$ - } - catch ( UnsupportedEncodingException e ) - { - return '!' + key + '!'; - } - return result; - } - catch ( MissingResourceException e ) - { - return '!' + key + '!'; - } - } - - /** - * Gets formatted translation for current local - * - * @param key - * the key - * @return translated value string - */ - public static String getFormattedString( String key, Object[] arguments ) - { - return MessageFormat.format( getString( key ), arguments ); - } -} diff --git a/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/i18n/messages.properties b/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/i18n/messages.properties deleted file mode 100644 index f92fbc57..00000000 --- a/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/i18n/messages.properties +++ /dev/null @@ -1,13 +0,0 @@ -############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation -############################################################################### - -JadDecompilerDescriptor.PreferenceLabel=Jad -JavaDecompilerActionBarContributor.Action.DecompileWithJad=&Jad \ No newline at end of file diff --git a/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/i18n/messages_zh_CN.properties b/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/i18n/messages_zh_CN.properties deleted file mode 100644 index f92fbc57..00000000 --- a/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/i18n/messages_zh_CN.properties +++ /dev/null @@ -1,13 +0,0 @@ -############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation -############################################################################### - -JadDecompilerDescriptor.PreferenceLabel=Jad -JavaDecompilerActionBarContributor.Action.DecompileWithJad=&Jad \ No newline at end of file diff --git a/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/i18n/messages_zh_HK.properties b/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/i18n/messages_zh_HK.properties deleted file mode 100644 index f92fbc57..00000000 --- a/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/i18n/messages_zh_HK.properties +++ /dev/null @@ -1,13 +0,0 @@ -############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation -############################################################################### - -JadDecompilerDescriptor.PreferenceLabel=Jad -JavaDecompilerActionBarContributor.Action.DecompileWithJad=&Jad \ No newline at end of file diff --git a/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/i18n/messages_zh_TW.properties b/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/i18n/messages_zh_TW.properties deleted file mode 100644 index f92fbc57..00000000 --- a/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/i18n/messages_zh_TW.properties +++ /dev/null @@ -1,13 +0,0 @@ -############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation -############################################################################### - -JadDecompilerDescriptor.PreferenceLabel=Jad -JavaDecompilerActionBarContributor.Action.DecompileWithJad=&Jad \ No newline at end of file diff --git a/org.sf.feeling.decompiler.jd.feature/.settings/org.eclipse.core.resources.prefs b/org.sf.feeling.decompiler.jd.feature/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000..4824b802 --- /dev/null +++ b/org.sf.feeling.decompiler.jd.feature/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/org.sf.feeling.decompiler.jd.feature/.settings/org.eclipse.core.runtime.prefs b/org.sf.feeling.decompiler.jd.feature/.settings/org.eclipse.core.runtime.prefs new file mode 100644 index 00000000..f8a67de1 --- /dev/null +++ b/org.sf.feeling.decompiler.jd.feature/.settings/org.eclipse.core.runtime.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +line.separator=\r\n diff --git a/org.sf.feeling.decompiler.jd.feature/build.properties b/org.sf.feeling.decompiler.jd.feature/build.properties index 2ed3f033..40b08e1e 100644 --- a/org.sf.feeling.decompiler.jd.feature/build.properties +++ b/org.sf.feeling.decompiler.jd.feature/build.properties @@ -1,6 +1,5 @@ -bin.includes = feature.xml,\ - eclipse_update_120.jpg,\ - epl-v10.html,\ - feature.properties,\ - license.html -qualifier = 20170815 \ No newline at end of file +bin.includes = feature.xml,\ + eclipse_update_120.jpg,\ + epl-v10.html,\ + feature.properties,\ + license.html \ No newline at end of file diff --git a/org.sf.feeling.decompiler.jd.feature/feature.properties b/org.sf.feeling.decompiler.jd.feature/feature.properties index 7a2493b8..7556b1e3 100644 --- a/org.sf.feeling.decompiler.jd.feature/feature.properties +++ b/org.sf.feeling.decompiler.jd.feature/feature.properties @@ -1,12 +1,9 @@ ############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). +# Copyright (c) 2017 Chen Chao and other ECD project contributors. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation +# https://www.eclipse.org/legal/epl-v10.html ############################################################################### # feature.properties @@ -16,21 +13,21 @@ # This file should be translated. # "featureName" property - name of the feature -featureName=Eclipse Class Decompiler JD-Core Extension (Optional) +featureName=Enhanced Class Decompiler JD-Core Extension (Optional) # "providerName" property - name of the company that provides the feature -providerName=Chen Chao +providerName=ECD project contributors # "updateSiteName" property - label for the update site -updateSiteName=Eclipse Class Decompiler Updates +updateSiteName=Enhanced Class Decompiler Updates # "description" property - description of the feature -description=Eclipse Class Decompiler integrates JD, Jad, FernFlower, CFR, Procyon with Eclipse seamlessly. \ +description=Enhanced Class Decompiler integrates JD, FernFlower, Vineflower, CFR, Procyon with Eclipse seamlessly. \ It allows Java developers to debug class files without source code directly. -copyrightURL=http://www.cpupk.com/decompiler/update +copyrightURL=https://ecd-plugin.github.io -copyright=(c) Copyright 2017 Chen Chao(cnfree2000@hotmail.com). All rights reserved.\n +copyright=(c) Copyright 2017 Chen Chao and other ECD project contributors. All rights reserved.\n # "licenseURL" property - URL of the "Feature License" # do not translate value - just change to point to a locale-specific HTML page @@ -43,93 +40,681 @@ aboutURL=about.html # "license" property - text of the "Feature Update License" # should be plain text version of license agreement pointed to be "licenseURL" license=\ -ECLIPSE FOUNDATION SOFTWARE USER AGREEMENT\n\ -January 28, 2004\n\ -\n\ -Usage Of Content\n\ -\n\ -THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\ -OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\ -USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\ -AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\ -NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU\n\ -AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\ -AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\ -OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\ -TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\ -OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\ -BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\ -\n\ -Applicable Licenses\n\ -\n\ -Unless otherwise indicated, all Content made available by the Eclipse Foundation\n\ -is provided to you under the terms and conditions of the Eclipse Public\n\ -License Version 1.0 ("EPL"). A copy of the EPL is provided with this\n\ -Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\ -For purposes of the EPL, "Program" will mean the Content.\n\ -\n\ -Content includes, but is not limited to, source code, object code,\n\ -documentation and other files maintained in the Eclipse.org CVS\n\ -repository ("Repository") in CVS modules ("Modules") and made available\n\ -as downloadable archives ("Downloads").\n\ -\n\ -Content may be apportioned into plug-ins ("Plug-ins"), plug-in fragments\n\ -("Fragments"), and features ("Features"). A Feature is a bundle of one or\n\ -more Plug-ins and/or Fragments and associated material. Files named\n\ -"feature.xml" may contain a list of the names and version numbers of the\n\ -Plug-ins and/or Fragments associated with a Feature. Plug-ins and Fragments\n\ -are located in directories named "plugins" and Features are located in\n\ -directories named "features".\n\ -\n\ -Features may also include other Features ("Included Features"). Files named\n\ -"feature.xml" may contain a list of the names and version numbers of\n\ -Included Features.\n\ -\n\ -The terms and conditions governing Plug-ins and Fragments should be\n\ -contained in files named "about.html" ("Abouts"). The terms and\n\ -conditions governing Features and Included Features should be contained\n\ -in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\ -Licenses may be located in any directory of a Download or Module\n\ -including, but not limited to the following locations:\n\ -\n\ - - The top-level (root) directory\n\ - - Plug-in and Fragment directories\n\ - - Subdirectories of the directory named "src" of certain Plug-ins\n\ - - Feature directories\n\ -\n\ -Note: if a Feature made available by the Eclipse Foundation is installed using the\n\ -Eclipse Update Manager, you must agree to a license ("Feature Update\n\ -License") during the installation process. If the Feature contains\n\ -Included Features, the Feature Update License should either provide you\n\ -with the terms and conditions governing the Included Features or inform\n\ -you where you can locate them. Feature Update Licenses may be found in\n\ -the "license" property of files named "feature.properties". Such Abouts,\n\ -Feature Licenses and Feature Update Licenses contain the terms and\n\ -conditions (or references to such terms and conditions) that govern your\n\ -use of the associated Content in that directory.\n\ -\n\ -THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER\n\ -TO THE CPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\ -SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\ -\n\ - - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\ - - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\ - - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\ - - IBM Public License 1.0 (available at http://oss.software.ibm.com/developerworks/opensource/license10.html)\n\ - - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\ - - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\ -\n\ -IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\ -TO USE OF THE CONTENT. If no About, Feature License or Feature Update License\n\ -is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\ -govern that particular Content.\n\ -\n\ -Cryptography\n\ -\n\ -Content may contain encryption software. The country in which you are\n\ -currently may have restrictions on the import, possession, and use,\n\ -and/or re-export to another country, of encryption software. BEFORE\n\ -using any encryption software, please check the country's laws,\n\ -regulations and policies concerning the import, possession, or use,\n\ -and re-export of encryption software, to see if this is permitted.\n -########### end of license property ########################################## \ No newline at end of file + GNU GENERAL PUBLIC LICENSE\n\ +\n\ + Version 3, 29 June 2007\n\ +\n\ + Copyright (C) 2007 Free Software Foundation, Inc. \n\ + Everyone is permitted to copy and distribute verbatim copies\n\ + of this license document, but changing it is not allowed.\n\ +\n\ + Preamble\n\ +\n\ + The GNU General Public License is a free, copyleft license for\n\ +software and other kinds of works.\n\ +\n\ + The licenses for most software and other practical works are designed\n\ +to take away your freedom to share and change the works. By contrast,\n\ +the GNU General Public License is intended to guarantee your freedom to\n\ +share and change all versions of a program--to make sure it remains free\n\ +software for all its users. We, the Free Software Foundation, use the\n\ +GNU General Public License for most of our software; it applies also to\n\ +any other work released this way by its authors. You can apply it to\n\ +your programs, too.\n\ +\n\ + When we speak of free software, we are referring to freedom, not\n\ +price. Our General Public Licenses are designed to make sure that you\n\ +have the freedom to distribute copies of free software (and charge for\n\ +them if you wish), that you receive source code or can get it if you\n\ +want it, that you can change the software or use pieces of it in new\n\ +free programs, and that you know you can do these things.\n\ +\n\ + To protect your rights, we need to prevent others from denying you\n\ +these rights or asking you to surrender the rights. Therefore, you have\n\ +certain responsibilities if you distribute copies of the software, or if\n\ +you modify it: responsibilities to respect the freedom of others.\n\ +\n\ + For example, if you distribute copies of such a program, whether\n\ +gratis or for a fee, you must pass on to the recipients the same\n\ +freedoms that you received. You must make sure that they, too, receive\n\ +or can get the source code. And you must show them these terms so they\n\ +know their rights.\n\ +\n\ + Developers that use the GNU GPL protect your rights with two steps:\n\ +(1) assert copyright on the software, and (2) offer you this License\n\ +giving you legal permission to copy, distribute and/or modify it.\n\ +\n\ + For the developers' and authors' protection, the GPL clearly explains\n\ +that there is no warranty for this free software. For both users' and\n\ +authors' sake, the GPL requires that modified versions be marked as\n\ +changed, so that their problems will not be attributed erroneously to\n\ +authors of previous versions.\n\ +\n\ + Some devices are designed to deny users access to install or run\n\ +modified versions of the software inside them, although the manufacturer\n\ +can do so. This is fundamentally incompatible with the aim of\n\ +protecting users' freedom to change the software. The systematic\n\ +pattern of such abuse occurs in the area of products for individuals to\n\ +use, which is precisely where it is most unacceptable. Therefore, we\n\ +have designed this version of the GPL to prohibit the practice for those\n\ +products. If such problems arise substantially in other domains, we\n\ +stand ready to extend this provision to those domains in future versions\n\ +of the GPL, as needed to protect the freedom of users.\n\ +\n\ + Finally, every program is threatened constantly by software patents.\n\ +States should not allow patents to restrict development and use of\n\ +software on general-purpose computers, but in those that do, we wish to\n\ +avoid the special danger that patents applied to a free program could\n\ +make it effectively proprietary. To prevent this, the GPL assures that\n\ +patents cannot be used to render the program non-free.\n\ +\n\ + The precise terms and conditions for copying, distribution and\n\ +modification follow.\n\ +\n\ + TERMS AND CONDITIONS\n\ +\n\ + 0. Definitions.\n\ +\n\ + "This License" refers to version 3 of the GNU General Public License.\n\ +\n\ + "Copyright" also means copyright-like laws that apply to other kinds of\n\ +works, such as semiconductor masks.\n\ +\n\ + "The Program" refers to any copyrightable work licensed under this\n\ +License. Each licensee is addressed as "you". "Licensees" and\n\ +"recipients" may be individuals or organizations.\n\ +\n\ + To "modify" a work means to copy from or adapt all or part of the work\n\ +in a fashion requiring copyright permission, other than the making of an\n\ +exact copy. The resulting work is called a "modified version" of the\n\ +earlier work or a work "based on" the earlier work.\n\ +\n\ + A "covered work" means either the unmodified Program or a work based\n\ +on the Program.\n\ +\n\ + To "propagate" a work means to do anything with it that, without\n\ +permission, would make you directly or secondarily liable for\n\ +infringement under applicable copyright law, except executing it on a\n\ +computer or modifying a private copy. Propagation includes copying,\n\ +distribution (with or without modification), making available to the\n\ +public, and in some countries other activities as well.\n\ +\n\ + To "convey" a work means any kind of propagation that enables other\n\ +parties to make or receive copies. Mere interaction with a user through\n\ +a computer network, with no transfer of a copy, is not conveying.\n\ +\n\ + An interactive user interface displays "Appropriate Legal Notices"\n\ +to the extent that it includes a convenient and prominently visible\n\ +feature that (1) displays an appropriate copyright notice, and (2)\n\ +tells the user that there is no warranty for the work (except to the\n\ +extent that warranties are provided), that licensees may convey the\n\ +work under this License, and how to view a copy of this License. If\n\ +the interface presents a list of user commands or options, such as a\n\ +menu, a prominent item in the list meets this criterion.\n\ +\n\ + 1. Source Code.\n\ +\n\ + The "source code" for a work means the preferred form of the work\n\ +for making modifications to it. "Object code" means any non-source\n\ +form of a work.\n\ +\n\ + A "Standard Interface" means an interface that either is an official\n\ +standard defined by a recognized standards body, or, in the case of\n\ +interfaces specified for a particular programming language, one that\n\ +is widely used among developers working in that language.\n\ +\n\ + The "System Libraries" of an executable work include anything, other\n\ +than the work as a whole, that (a) is included in the normal form of\n\ +packaging a Major Component, but which is not part of that Major\n\ +Component, and (b) serves only to enable use of the work with that\n\ +Major Component, or to implement a Standard Interface for which an\n\ +implementation is available to the public in source code form. A\n\ +"Major Component", in this context, means a major essential component\n\ +(kernel, window system, and so on) of the specific operating system\n\ +(if any) on which the executable work runs, or a compiler used to\n\ +produce the work, or an object code interpreter used to run it.\n\ +\n\ + The "Corresponding Source" for a work in object code form means all\n\ +the source code needed to generate, install, and (for an executable\n\ +work) run the object code and to modify the work, including scripts to\n\ +control those activities. However, it does not include the work's\n\ +System Libraries, or general-purpose tools or generally available free\n\ +programs which are used unmodified in performing those activities but\n\ +which are not part of the work. For example, Corresponding Source\n\ +includes interface definition files associated with source files for\n\ +the work, and the source code for shared libraries and dynamically\n\ +linked subprograms that the work is specifically designed to require,\n\ +such as by intimate data communication or control flow between those\n\ +subprograms and other parts of the work.\n\ +\n\ + The Corresponding Source need not include anything that users\n\ +can regenerate automatically from other parts of the Corresponding\n\ +Source.\n\ +\n\ + The Corresponding Source for a work in source code form is that\n\ +same work.\n\ +\n\ + 2. Basic Permissions.\n\ +\n\ + All rights granted under this License are granted for the term of\n\ +copyright on the Program, and are irrevocable provided the stated\n\ +conditions are met. This License explicitly affirms your unlimited\n\ +permission to run the unmodified Program. The output from running a\n\ +covered work is covered by this License only if the output, given its\n\ +content, constitutes a covered work. This License acknowledges your\n\ +rights of fair use or other equivalent, as provided by copyright law.\n\ +\n\ + You may make, run and propagate covered works that you do not\n\ +convey, without conditions so long as your license otherwise remains\n\ +in force. You may convey covered works to others for the sole purpose\n\ +of having them make modifications exclusively for you, or provide you\n\ +with facilities for running those works, provided that you comply with\n\ +the terms of this License in conveying all material for which you do\n\ +not control copyright. Those thus making or running the covered works\n\ +for you must do so exclusively on your behalf, under your direction\n\ +and control, on terms that prohibit them from making any copies of\n\ +your copyrighted material outside their relationship with you.\n\ +\n\ + Conveying under any other circumstances is permitted solely under\n\ +the conditions stated below. Sublicensing is not allowed; section 10\n\ +makes it unnecessary.\n\ +\n\ + 3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\ +\n\ + No covered work shall be deemed part of an effective technological\n\ +measure under any applicable law fulfilling obligations under article\n\ +11 of the WIPO copyright treaty adopted on 20 December 1996, or\n\ +similar laws prohibiting or restricting circumvention of such\n\ +measures.\n\ +\n\ + When you convey a covered work, you waive any legal power to forbid\n\ +circumvention of technological measures to the extent such circumvention\n\ +is effected by exercising rights under this License with respect to\n\ +the covered work, and you disclaim any intention to limit operation or\n\ +modification of the work as a means of enforcing, against the work's\n\ +users, your or third parties' legal rights to forbid circumvention of\n\ +technological measures.\n\ +\n\ + 4. Conveying Verbatim Copies.\n\ +\n\ + You may convey verbatim copies of the Program's source code as you\n\ +receive it, in any medium, provided that you conspicuously and\n\ +appropriately publish on each copy an appropriate copyright notice;\n\ +keep intact all notices stating that this License and any\n\ +non-permissive terms added in accord with section 7 apply to the code;\n\ +keep intact all notices of the absence of any warranty; and give all\n\ +recipients a copy of this License along with the Program.\n\ +\n\ + You may charge any price or no price for each copy that you convey,\n\ +and you may offer support or warranty protection for a fee.\n\ +\n\ + 5. Conveying Modified Source Versions.\n\ +\n\ + You may convey a work based on the Program, or the modifications to\n\ +produce it from the Program, in the form of source code under the\n\ +terms of section 4, provided that you also meet all of these conditions:\n\ +\n\ + a) The work must carry prominent notices stating that you modified\n\ + it, and giving a relevant date.\n\ +\n\ + b) The work must carry prominent notices stating that it is\n\ + released under this License and any conditions added under section\n\ + 7. This requirement modifies the requirement in section 4 to\n\ + "keep intact all notices".\n\ +\n\ + c) You must license the entire work, as a whole, under this\n\ + License to anyone who comes into possession of a copy. This\n\ + License will therefore apply, along with any applicable section 7\n\ + additional terms, to the whole of the work, and all its parts,\n\ + regardless of how they are packaged. This License gives no\n\ + permission to license the work in any other way, but it does not\n\ + invalidate such permission if you have separately received it.\n\ +\n\ + d) If the work has interactive user interfaces, each must display\n\ + Appropriate Legal Notices; however, if the Program has interactive\n\ + interfaces that do not display Appropriate Legal Notices, your\n\ + work need not make them do so.\n\ +\n\ + A compilation of a covered work with other separate and independent\n\ +works, which are not by their nature extensions of the covered work,\n\ +and which are not combined with it such as to form a larger program,\n\ +in or on a volume of a storage or distribution medium, is called an\n\ +"aggregate" if the compilation and its resulting copyright are not\n\ +used to limit the access or legal rights of the compilation's users\n\ +beyond what the individual works permit. Inclusion of a covered work\n\ +in an aggregate does not cause this License to apply to the other\n\ +parts of the aggregate.\n\ +\n\ + 6. Conveying Non-Source Forms.\n\ +\n\ + You may convey a covered work in object code form under the terms\n\ +of sections 4 and 5, provided that you also convey the\n\ +machine-readable Corresponding Source under the terms of this License,\n\ +in one of these ways:\n\ +\n\ + a) Convey the object code in, or embodied in, a physical product\n\ + (including a physical distribution medium), accompanied by the\n\ + Corresponding Source fixed on a durable physical medium\n\ + customarily used for software interchange.\n\ +\n\ + b) Convey the object code in, or embodied in, a physical product\n\ + (including a physical distribution medium), accompanied by a\n\ + written offer, valid for at least three years and valid for as\n\ + long as you offer spare parts or customer support for that product\n\ + model, to give anyone who possesses the object code either (1) a\n\ + copy of the Corresponding Source for all the software in the\n\ + product that is covered by this License, on a durable physical\n\ + medium customarily used for software interchange, for a price no\n\ + more than your reasonable cost of physically performing this\n\ + conveying of source, or (2) access to copy the\n\ + Corresponding Source from a network server at no charge.\n\ +\n\ + c) Convey individual copies of the object code with a copy of the\n\ + written offer to provide the Corresponding Source. This\n\ + alternative is allowed only occasionally and noncommercially, and\n\ + only if you received the object code with such an offer, in accord\n\ + with subsection 6b.\n\ +\n\ + d) Convey the object code by offering access from a designated\n\ + place (gratis or for a charge), and offer equivalent access to the\n\ + Corresponding Source in the same way through the same place at no\n\ + further charge. You need not require recipients to copy the\n\ + Corresponding Source along with the object code. If the place to\n\ + copy the object code is a network server, the Corresponding Source\n\ + may be on a different server (operated by you or a third party)\n\ + that supports equivalent copying facilities, provided you maintain\n\ + clear directions next to the object code saying where to find the\n\ + Corresponding Source. Regardless of what server hosts the\n\ + Corresponding Source, you remain obligated to ensure that it is\n\ + available for as long as needed to satisfy these requirements.\n\ +\n\ + e) Convey the object code using peer-to-peer transmission, provided\n\ + you inform other peers where the object code and Corresponding\n\ + Source of the work are being offered to the general public at no\n\ + charge under subsection 6d.\n\ +\n\ + A separable portion of the object code, whose source code is excluded\n\ +from the Corresponding Source as a System Library, need not be\n\ +included in conveying the object code work.\n\ +\n\ + A "User Product" is either (1) a "consumer product", which means any\n\ +tangible personal property which is normally used for personal, family,\n\ +or household purposes, or (2) anything designed or sold for incorporation\n\ +into a dwelling. In determining whether a product is a consumer product,\n\ +doubtful cases shall be resolved in favor of coverage. For a particular\n\ +product received by a particular user, "normally used" refers to a\n\ +typical or common use of that class of product, regardless of the status\n\ +of the particular user or of the way in which the particular user\n\ +actually uses, or expects or is expected to use, the product. A product\n\ +is a consumer product regardless of whether the product has substantial\n\ +commercial, industrial or non-consumer uses, unless such uses represent\n\ +the only significant mode of use of the product.\n\ +\n\ + "Installation Information" for a User Product means any methods,\n\ +procedures, authorization keys, or other information required to install\n\ +and execute modified versions of a covered work in that User Product from\n\ +a modified version of its Corresponding Source. The information must\n\ +suffice to ensure that the continued functioning of the modified object\n\ +code is in no case prevented or interfered with solely because\n\ +modification has been made.\n\ +\n\ + If you convey an object code work under this section in, or with, or\n\ +specifically for use in, a User Product, and the conveying occurs as\n\ +part of a transaction in which the right of possession and use of the\n\ +User Product is transferred to the recipient in perpetuity or for a\n\ +fixed term (regardless of how the transaction is characterized), the\n\ +Corresponding Source conveyed under this section must be accompanied\n\ +by the Installation Information. But this requirement does not apply\n\ +if neither you nor any third party retains the ability to install\n\ +modified object code on the User Product (for example, the work has\n\ +been installed in ROM).\n\ +\n\ + The requirement to provide Installation Information does not include a\n\ +requirement to continue to provide support service, warranty, or updates\n\ +for a work that has been modified or installed by the recipient, or for\n\ +the User Product in which it has been modified or installed. Access to a\n\ +network may be denied when the modification itself materially and\n\ +adversely affects the operation of the network or violates the rules and\n\ +protocols for communication across the network.\n\ +\n\ + Corresponding Source conveyed, and Installation Information provided,\n\ +in accord with this section must be in a format that is publicly\n\ +documented (and with an implementation available to the public in\n\ +source code form), and must require no special password or key for\n\ +unpacking, reading or copying.\n\ +\n\ + 7. Additional Terms.\n\ +\n\ + "Additional permissions" are terms that supplement the terms of this\n\ +License by making exceptions from one or more of its conditions.\n\ +Additional permissions that are applicable to the entire Program shall\n\ +be treated as though they were included in this License, to the extent\n\ +that they are valid under applicable law. If additional permissions\n\ +apply only to part of the Program, that part may be used separately\n\ +under those permissions, but the entire Program remains governed by\n\ +this License without regard to the additional permissions.\n\ +\n\ + When you convey a copy of a covered work, you may at your option\n\ +remove any additional permissions from that copy, or from any part of\n\ +it. (Additional permissions may be written to require their own\n\ +removal in certain cases when you modify the work.) You may place\n\ +additional permissions on material, added by you to a covered work,\n\ +for which you have or can give appropriate copyright permission.\n\ +\n\ + Notwithstanding any other provision of this License, for material you\n\ +add to a covered work, you may (if authorized by the copyright holders of\n\ +that material) supplement the terms of this License with terms:\n\ +\n\ + a) Disclaiming warranty or limiting liability differently from the\n\ + terms of sections 15 and 16 of this License; or\n\ +\n\ + b) Requiring preservation of specified reasonable legal notices or\n\ + author attributions in that material or in the Appropriate Legal\n\ + Notices displayed by works containing it; or\n\ +\n\ + c) Prohibiting misrepresentation of the origin of that material, or\n\ + requiring that modified versions of such material be marked in\n\ + reasonable ways as different from the original version; or\n\ +\n\ + d) Limiting the use for publicity purposes of names of licensors or\n\ + authors of the material; or\n\ +\n\ + e) Declining to grant rights under trademark law for use of some\n\ + trade names, trademarks, or service marks; or\n\ +\n\ + f) Requiring indemnification of licensors and authors of that\n\ + material by anyone who conveys the material (or modified versions of\n\ + it) with contractual assumptions of liability to the recipient, for\n\ + any liability that these contractual assumptions directly impose on\n\ + those licensors and authors.\n\ +\n\ + All other non-permissive additional terms are considered "further\n\ +restrictions" within the meaning of section 10. If the Program as you\n\ +received it, or any part of it, contains a notice stating that it is\n\ +governed by this License along with a term that is a further\n\ +restriction, you may remove that term. If a license document contains\n\ +a further restriction but permits relicensing or conveying under this\n\ +License, you may add to a covered work material governed by the terms\n\ +of that license document, provided that the further restriction does\n\ +not survive such relicensing or conveying.\n\ +\n\ + If you add terms to a covered work in accord with this section, you\n\ +must place, in the relevant source files, a statement of the\n\ +additional terms that apply to those files, or a notice indicating\n\ +where to find the applicable terms.\n\ +\n\ + Additional terms, permissive or non-permissive, may be stated in the\n\ +form of a separately written license, or stated as exceptions;\n\ +the above requirements apply either way.\n\ +\n\ + 8. Termination.\n\ +\n\ + You may not propagate or modify a covered work except as expressly\n\ +provided under this License. Any attempt otherwise to propagate or\n\ +modify it is void, and will automatically terminate your rights under\n\ +this License (including any patent licenses granted under the third\n\ +paragraph of section 11).\n\ +\n\ + However, if you cease all violation of this License, then your\n\ +license from a particular copyright holder is reinstated (a)\n\ +provisionally, unless and until the copyright holder explicitly and\n\ +finally terminates your license, and (b) permanently, if the copyright\n\ +holder fails to notify you of the violation by some reasonable means\n\ +prior to 60 days after the cessation.\n\ +\n\ + Moreover, your license from a particular copyright holder is\n\ +reinstated permanently if the copyright holder notifies you of the\n\ +violation by some reasonable means, this is the first time you have\n\ +received notice of violation of this License (for any work) from that\n\ +copyright holder, and you cure the violation prior to 30 days after\n\ +your receipt of the notice.\n\ +\n\ + Termination of your rights under this section does not terminate the\n\ +licenses of parties who have received copies or rights from you under\n\ +this License. If your rights have been terminated and not permanently\n\ +reinstated, you do not qualify to receive new licenses for the same\n\ +material under section 10.\n\ +\n\ + 9. Acceptance Not Required for Having Copies.\n\ +\n\ + You are not required to accept this License in order to receive or\n\ +run a copy of the Program. Ancillary propagation of a covered work\n\ +occurring solely as a consequence of using peer-to-peer transmission\n\ +to receive a copy likewise does not require acceptance. However,\n\ +nothing other than this License grants you permission to propagate or\n\ +modify any covered work. These actions infringe copyright if you do\n\ +not accept this License. Therefore, by modifying or propagating a\n\ +covered work, you indicate your acceptance of this License to do so.\n\ +\n\ + 10. Automatic Licensing of Downstream Recipients.\n\ +\n\ + Each time you convey a covered work, the recipient automatically\n\ +receives a license from the original licensors, to run, modify and\n\ +propagate that work, subject to this License. You are not responsible\n\ +for enforcing compliance by third parties with this License.\n\ +\n\ + An "entity transaction" is a transaction transferring control of an\n\ +organization, or substantially all assets of one, or subdividing an\n\ +organization, or merging organizations. If propagation of a covered\n\ +work results from an entity transaction, each party to that\n\ +transaction who receives a copy of the work also receives whatever\n\ +licenses to the work the party's predecessor in interest had or could\n\ +give under the previous paragraph, plus a right to possession of the\n\ +Corresponding Source of the work from the predecessor in interest, if\n\ +the predecessor has it or can get it with reasonable efforts.\n\ +\n\ + You may not impose any further restrictions on the exercise of the\n\ +rights granted or affirmed under this License. For example, you may\n\ +not impose a license fee, royalty, or other charge for exercise of\n\ +rights granted under this License, and you may not initiate litigation\n\ +(including a cross-claim or counterclaim in a lawsuit) alleging that\n\ +any patent claim is infringed by making, using, selling, offering for\n\ +sale, or importing the Program or any portion of it.\n\ +\n\ + 11. Patents.\n\ +\n\ + A "contributor" is a copyright holder who authorizes use under this\n\ +License of the Program or a work on which the Program is based. The\n\ +work thus licensed is called the contributor's "contributor version".\n\ +\n\ + A contributor's "essential patent claims" are all patent claims\n\ +owned or controlled by the contributor, whether already acquired or\n\ +hereafter acquired, that would be infringed by some manner, permitted\n\ +by this License, of making, using, or selling its contributor version,\n\ +but do not include claims that would be infringed only as a\n\ +consequence of further modification of the contributor version. For\n\ +purposes of this definition, "control" includes the right to grant\n\ +patent sublicenses in a manner consistent with the requirements of\n\ +this License.\n\ +\n\ + Each contributor grants you a non-exclusive, worldwide, royalty-free\n\ +patent license under the contributor's essential patent claims, to\n\ +make, use, sell, offer for sale, import and otherwise run, modify and\n\ +propagate the contents of its contributor version.\n\ +\n\ + In the following three paragraphs, a "patent license" is any express\n\ +agreement or commitment, however denominated, not to enforce a patent\n\ +(such as an express permission to practice a patent or covenant not to\n\ +sue for patent infringement). To "grant" such a patent license to a\n\ +party means to make such an agreement or commitment not to enforce a\n\ +patent against the party.\n\ +\n\ + If you convey a covered work, knowingly relying on a patent license,\n\ +and the Corresponding Source of the work is not available for anyone\n\ +to copy, free of charge and under the terms of this License, through a\n\ +publicly available network server or other readily accessible means,\n\ +then you must either (1) cause the Corresponding Source to be so\n\ +available, or (2) arrange to deprive yourself of the benefit of the\n\ +patent license for this particular work, or (3) arrange, in a manner\n\ +consistent with the requirements of this License, to extend the patent\n\ +license to downstream recipients. "Knowingly relying" means you have\n\ +actual knowledge that, but for the patent license, your conveying the\n\ +covered work in a country, or your recipient's use of the covered work\n\ +in a country, would infringe one or more identifiable patents in that\n\ +country that you have reason to believe are valid.\n\ +\n\ + If, pursuant to or in connection with a single transaction or\n\ +arrangement, you convey, or propagate by procuring conveyance of, a\n\ +covered work, and grant a patent license to some of the parties\n\ +receiving the covered work authorizing them to use, propagate, modify\n\ +or convey a specific copy of the covered work, then the patent license\n\ +you grant is automatically extended to all recipients of the covered\n\ +work and works based on it.\n\ +\n\ + A patent license is "discriminatory" if it does not include within\n\ +the scope of its coverage, prohibits the exercise of, or is\n\ +conditioned on the non-exercise of one or more of the rights that are\n\ +specifically granted under this License. You may not convey a covered\n\ +work if you are a party to an arrangement with a third party that is\n\ +in the business of distributing software, under which you make payment\n\ +to the third party based on the extent of your activity of conveying\n\ +the work, and under which the third party grants, to any of the\n\ +parties who would receive the covered work from you, a discriminatory\n\ +patent license (a) in connection with copies of the covered work\n\ +conveyed by you (or copies made from those copies), or (b) primarily\n\ +for and in connection with specific products or compilations that\n\ +contain the covered work, unless you entered into that arrangement,\n\ +or that patent license was granted, prior to 28 March 2007.\n\ +\n\ + Nothing in this License shall be construed as excluding or limiting\n\ +any implied license or other defenses to infringement that may\n\ +otherwise be available to you under applicable patent law.\n\ +\n\ + 12. No Surrender of Others' Freedom.\n\ +\n\ + If conditions are imposed on you (whether by court order, agreement or\n\ +otherwise) that contradict the conditions of this License, they do not\n\ +excuse you from the conditions of this License. If you cannot convey a\n\ +covered work so as to satisfy simultaneously your obligations under this\n\ +License and any other pertinent obligations, then as a consequence you may\n\ +not convey it at all. For example, if you agree to terms that obligate you\n\ +to collect a royalty for further conveying from those to whom you convey\n\ +the Program, the only way you could satisfy both those terms and this\n\ +License would be to refrain entirely from conveying the Program.\n\ +\n\ + 13. Use with the GNU Affero General Public License.\n\ +\n\ + Notwithstanding any other provision of this License, you have\n\ +permission to link or combine any covered work with a work licensed\n\ +under version 3 of the GNU Affero General Public License into a single\n\ +combined work, and to convey the resulting work. The terms of this\n\ +License will continue to apply to the part which is the covered work,\n\ +but the special requirements of the GNU Affero General Public License,\n\ +section 13, concerning interaction through a network will apply to the\n\ +combination as such.\n\ +\n\ + 14. Revised Versions of this License.\n\ +\n\ + The Free Software Foundation may publish revised and/or new versions of\n\ +the GNU General Public License from time to time. Such new versions will\n\ +be similar in spirit to the present version, but may differ in detail to\n\ +address new problems or concerns.\n\ +\n\ + Each version is given a distinguishing version number. If the\n\ +Program specifies that a certain numbered version of the GNU General\n\ +Public License "or any later version" applies to it, you have the\n\ +option of following the terms and conditions either of that numbered\n\ +version or of any later version published by the Free Software\n\ +Foundation. If the Program does not specify a version number of the\n\ +GNU General Public License, you may choose any version ever published\n\ +by the Free Software Foundation.\n\ +\n\ + If the Program specifies that a proxy can decide which future\n\ +versions of the GNU General Public License can be used, that proxy's\n\ +public statement of acceptance of a version permanently authorizes you\n\ +to choose that version for the Program.\n\ +\n\ + Later license versions may give you additional or different\n\ +permissions. However, no additional obligations are imposed on any\n\ +author or copyright holder as a result of your choosing to follow a\n\ +later version.\n\ +\n\ + 15. Disclaimer of Warranty.\n\ +\n\ + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\n\ +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\n\ +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY\n\ +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\n\ +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n\ +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\n\ +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\n\ +ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\ +\n\ + 16. Limitation of Liability.\n\ +\n\ + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\n\ +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\n\ +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\n\ +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\n\ +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\n\ +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\n\ +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\n\ +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\n\ +SUCH DAMAGES.\n\ +\n\ + 17. Interpretation of Sections 15 and 16.\n\ +\n\ + If the disclaimer of warranty and limitation of liability provided\n\ +above cannot be given local legal effect according to their terms,\n\ +reviewing courts shall apply local law that most closely approximates\n\ +an absolute waiver of all civil liability in connection with the\n\ +Program, unless a warranty or assumption of liability accompanies a\n\ +copy of the Program in return for a fee.\n\ +\n\ + END OF TERMS AND CONDITIONS\n\ +\n\ + How to Apply These Terms to Your New Programs\n\ +\n\ + If you develop a new program, and you want it to be of the greatest\n\ +possible use to the public, the best way to achieve this is to make it\n\ +free software which everyone can redistribute and change under these terms.\n\ +\n\ + To do so, attach the following notices to the program. It is safest\n\ +to attach them to the start of each source file to most effectively\n\ +state the exclusion of warranty; and each file should have at least\n\ +the "copyright" line and a pointer to where the full notice is found.\n\ +\n\ + JD-Eclipse is a plug-in for the Eclipse platform. It allows you to \n\ + display all the Java sources during your debugging process, even if \n\ + you do not have them all.\n\ + Copyright (C) 2008-2015 Emmanuel Dupuy\n\ +\n\ + This program is free software: you can redistribute it and/or modify\n\ + it under the terms of the GNU General Public License as published by\n\ + the Free Software Foundation, either version 3 of the License, or\n\ + (at your option) any later version.\n\ +\n\ + This program is distributed in the hope that it will be useful,\n\ + but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ + GNU General Public License for more details.\n\ +\n\ + You should have received a copy of the GNU General Public License\n\ + along with this program. If not, see .\n\ +\n\ +Also add information on how to contact you by electronic and paper mail.\n\ +\n\ + If the program does terminal interaction, make it output a short\n\ +notice like this when it starts in an interactive mode:\n\ +\n\ + JD-Eclipse Copyright (C) 2008-2015 Emmanuel Dupuy\n\ + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n\ + This is free software, and you are welcome to redistribute it\n\ + under certain conditions; type `show c' for details.\n\ +\n\ +The hypothetical commands `show w' and `show c' should show the appropriate\n\ +parts of the General Public License. Of course, your program's commands\n\ +might be different; for a GUI interface, you would use an "about box".\n\ +\n\ + You should also get your employer (if you work as a programmer) or school,\n\ +if any, to sign a "copyright disclaimer" for the program, if necessary.\n\ +For more information on this, and how to apply and follow the GNU GPL, see\n\ +.\n\ +\n\ + The GNU General Public License does not permit incorporating your program\n\ +into proprietary programs. If your program is a subroutine library, you\n\ +may consider it more useful to permit linking proprietary applications with\n\ +the library. If this is what you want to do, use the GNU Lesser General\n\ +Public License instead of this License. But first, please read\n\ +.\n +########### end of license property ########################################## diff --git a/org.sf.feeling.decompiler.jd.feature/feature.xml b/org.sf.feeling.decompiler.jd.feature/feature.xml index 815f78c6..38edbdd5 100644 --- a/org.sf.feeling.decompiler.jd.feature/feature.xml +++ b/org.sf.feeling.decompiler.jd.feature/feature.xml @@ -2,11 +2,9 @@ + plugin="org.sf.feeling.decompiler.jd"> %description @@ -21,8 +19,8 @@ - - + + @@ -41,16 +39,15 @@ - + + diff --git a/org.sf.feeling.decompiler.jd.feature/license.html b/org.sf.feeling.decompiler.jd.feature/license.html index e2323dfc..87eb9824 100644 --- a/org.sf.feeling.decompiler.jd.feature/license.html +++ b/org.sf.feeling.decompiler.jd.feature/license.html @@ -1,73 +1,696 @@ - - - - -Eclipse.org Software User Agreement - - - -

    Eclipse Foundation Software User Agreement

    -

    January 28, 2005

    - -

    Usage Of Content

    - -

    THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS - (COLLECTIVELY "CONTENT"). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND - CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE - OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR - NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND - CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.

    - -

    Applicable Licenses

    - -

    Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0 - ("EPL"). A copy of the EPL is provided with this Content and is also available at http://www.eclipse.org/legal/epl-v10.html. - For purposes of the EPL, "Program" will mean the Content.

    - -

    Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse.org CVS repository ("Repository") in CVS - modules ("Modules") and made available as downloadable archives ("Downloads").

    - -

    Content may be apportioned into plug-ins ("Plug-ins"), plug-in fragments ("Fragments"), and features ("Features"). A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material. Files named "feature.xml" may contain a list of the names and version numbers of the Plug-ins and/or Fragments associated with a Feature. Plug-ins and Fragments are located in directories - named "plugins" and Features are located in directories named "features".

    - -

    Features may also include other Features ("Included Features"). Files named "feature.xml" may contain a list of the names and version numbers of Included Features.

    - -

    The terms and conditions governing Plug-ins and Fragments should be contained in files named "about.html" ("Abouts"). The terms and conditions governing Features and -Included Features should be contained in files named "license.html" ("Feature Licenses"). Abouts and Feature Licenses may be located in any directory of a Download or Module -including, but not limited to the following locations:

    - -
      -
    • The top-level (root) directory
    • -
    • Plug-in and Fragment directories
    • -
    • Subdirectories of the directory named "src" of certain Plug-ins
    • -
    • Feature directories
    • -
    - -

    Note: if a Feature made available by the Eclipse Foundation is installed using the Eclipse Update Manager, you must agree to a license ("Feature Update License") during the -installation process. If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or -inform you where you can locate them. Feature Update Licenses may be found in the "license" property of files named "feature.properties". -Such Abouts, Feature Licenses and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in -that directory.

    - -

    THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE -OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):

    - - - -

    IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License or Feature Update License is provided, please -contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.

    - -

    Cryptography

    - -

    Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to - another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import, - possession, or use, and re-export of encryption software, to see if this is permitted.

    - - + + + + + + GNU General Public License v3.0 - GNU Project - Free Software Foundation (FSF) + + + +

    GNU GENERAL PUBLIC LICENSE

    +

    Version 3, 29 June 2007

    + +

    Copyright © 2007 Free Software Foundation, Inc. + <https://fsf.org/>

    + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed.

    + +

    Preamble

    + +

    The GNU General Public License is a free, copyleft license for +software and other kinds of works.

    + +

    The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too.

    + +

    When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things.

    + +

    To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others.

    + +

    For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights.

    + +

    Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it.

    + +

    For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions.

    + +

    Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users.

    + +

    Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free.

    + +

    The precise terms and conditions for copying, distribution and +modification follow.

    + +

    TERMS AND CONDITIONS

    + +

    0. Definitions.

    + +

    “This License” refers to version 3 of the GNU General Public License.

    + +

    “Copyright” also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks.

    + +

    “The Program” refers to any copyrightable work licensed under this +License. Each licensee is addressed as “you”. “Licensees” and +“recipients” may be individuals or organizations.

    + +

    To “modify” a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a “modified version” of the +earlier work or a work “based on” the earlier work.

    + +

    A “covered work” means either the unmodified Program or a work based +on the Program.

    + +

    To “propagate” a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well.

    + +

    To “convey” a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying.

    + +

    An interactive user interface displays “Appropriate Legal Notices” +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion.

    + +

    1. Source Code.

    + +

    The “source code” for a work means the preferred form of the work +for making modifications to it. “Object code” means any non-source +form of a work.

    + +

    A “Standard Interface” means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language.

    + +

    The “System Libraries” of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +“Major Component”, in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it.

    + +

    The “Corresponding Source” for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work.

    + +

    The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source.

    + +

    The Corresponding Source for a work in source code form is that +same work.

    + +

    2. Basic Permissions.

    + +

    All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law.

    + +

    You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you.

    + +

    Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary.

    + +

    3. Protecting Users' Legal Rights From Anti-Circumvention Law.

    + +

    No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures.

    + +

    When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures.

    + +

    4. Conveying Verbatim Copies.

    + +

    You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program.

    + +

    You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee.

    + +

    5. Conveying Modified Source Versions.

    + +

    You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions:

    + +
      +
    • a) The work must carry prominent notices stating that you modified + it, and giving a relevant date.
    • + +
    • b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + “keep intact all notices”.
    • + +
    • c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it.
    • + +
    • d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so.
    • +
    + +

    A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +“aggregate” if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate.

    + +

    6. Conveying Non-Source Forms.

    + +

    You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways:

    + +
      +
    • a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange.
    • + +
    • b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge.
    • + +
    • c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b.
    • + +
    • d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements.
    • + +
    • e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d.
    • +
    + +

    A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work.

    + +

    A “User Product” is either (1) a “consumer product”, which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, “normally used” refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product.

    + +

    “Installation Information” for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made.

    + +

    If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM).

    + +

    The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network.

    + +

    Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying.

    + +

    7. Additional Terms.

    + +

    “Additional permissions” are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions.

    + +

    When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission.

    + +

    Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms:

    + +
      +
    • a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or
    • + +
    • b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or
    • + +
    • c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or
    • + +
    • d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or
    • + +
    • e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or
    • + +
    • f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors.
    • +
    + +

    All other non-permissive additional terms are considered “further +restrictions” within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying.

    + +

    If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms.

    + +

    Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way.

    + +

    8. Termination.

    + +

    You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11).

    + +

    However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation.

    + +

    Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice.

    + +

    Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10.

    + +

    9. Acceptance Not Required for Having Copies.

    + +

    You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so.

    + +

    10. Automatic Licensing of Downstream Recipients.

    + +

    Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License.

    + +

    An “entity transaction” is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts.

    + +

    You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it.

    + +

    11. Patents.

    + +

    A “contributor” is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's “contributor version”.

    + +

    A contributor's “essential patent claims” are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, “control” includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License.

    + +

    Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version.

    + +

    In the following three paragraphs, a “patent license” is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To “grant” such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party.

    + +

    If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. “Knowingly relying” means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid.

    + +

    If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it.

    + +

    A patent license is “discriminatory” if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007.

    + +

    Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law.

    + +

    12. No Surrender of Others' Freedom.

    + +

    If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program.

    + +

    13. Use with the GNU Affero General Public License.

    + +

    Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such.

    + +

    14. Revised Versions of this License.

    + +

    The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns.

    + +

    Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License “or any later version” applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation.

    + +

    If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program.

    + +

    Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version.

    + +

    15. Disclaimer of Warranty.

    + +

    THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

    + +

    16. Limitation of Liability.

    + +

    IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES.

    + +

    17. Interpretation of Sections 15 and 16.

    + +

    If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee.

    + +

    END OF TERMS AND CONDITIONS

    + +

    How to Apply These Terms to Your New Programs

    + +

    If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +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.

    + +
        <one line to give the program's name and a brief idea of what it does.>
    +    Copyright (C) <year>  <name of author>
    +
    +    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
    +    the Free Software Foundation, either version 3 of the License, or
    +    (at your option) any later version.
    +
    +    This program is distributed in the hope that it will be useful,
    +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    +    GNU General Public License for more details.
    +
    +    You should have received a copy of the GNU General Public License
    +    along with this program.  If not, see <https://www.gnu.org/licenses/>.
    +
    + +

    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:

    + +
        <program>  Copyright (C) <year>  <name of author>
    +    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.
    +
    + +

    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. +For more information on this, and how to apply and follow the GNU GPL, see +<https://www.gnu.org/licenses/>.

    + +

    The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<https://www.gnu.org/licenses/why-not-lgpl.html>.

    + + diff --git a/org.sf.feeling.decompiler.jd.feature/pom.xml b/org.sf.feeling.decompiler.jd.feature/pom.xml new file mode 100644 index 00000000..73643694 --- /dev/null +++ b/org.sf.feeling.decompiler.jd.feature/pom.xml @@ -0,0 +1,15 @@ + + 4.0.0 + + + com.github.ecd-plugin + com.github.ecd-plugin.ecd + 3.5.1 + ../pom.xml + + + com.github.ecd-plugin.features + org.sf.feeling.decompiler.jd + eclipse-feature + diff --git a/org.sf.feeling.decompiler.jd/.classpath b/org.sf.feeling.decompiler.jd/.classpath index 8a8f1668..96721aee 100644 --- a/org.sf.feeling.decompiler.jd/.classpath +++ b/org.sf.feeling.decompiler.jd/.classpath @@ -1,7 +1,12 @@ - + + + + + - + + diff --git a/org.sf.feeling.decompiler.jd/.gitignore b/org.sf.feeling.decompiler.jd/.gitignore deleted file mode 100644 index ae3c1726..00000000 --- a/org.sf.feeling.decompiler.jd/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin/ diff --git a/org.sf.feeling.decompiler.jd/.project b/org.sf.feeling.decompiler.jd/.project index c0431c21..90ec0f27 100644 --- a/org.sf.feeling.decompiler.jd/.project +++ b/org.sf.feeling.decompiler.jd/.project @@ -20,8 +20,14 @@ + + org.eclipse.m2e.core.maven2Builder + + + + org.eclipse.m2e.core.maven2Nature org.eclipse.pde.PluginNature org.eclipse.jdt.core.javanature diff --git a/org.sf.feeling.decompiler.jd/.settings/org.eclipse.core.resources.prefs b/org.sf.feeling.decompiler.jd/.settings/org.eclipse.core.resources.prefs index 713acf91..4824b802 100644 --- a/org.sf.feeling.decompiler.jd/.settings/org.eclipse.core.resources.prefs +++ b/org.sf.feeling.decompiler.jd/.settings/org.eclipse.core.resources.prefs @@ -1,4 +1,2 @@ eclipse.preferences.version=1 -encoding//src/org/sf/feeling/decompiler/jd/i18n/messages_zh_CN.properties=UTF-8 -encoding//src/org/sf/feeling/decompiler/jd/i18n/messages_zh_HK.properties=UTF-8 -encoding//src/org/sf/feeling/decompiler/jd/i18n/messages_zh_TW.properties=UTF-8 +encoding/=UTF-8 diff --git a/org.sf.feeling.decompiler.jd/.settings/org.eclipse.core.runtime.prefs b/org.sf.feeling.decompiler.jd/.settings/org.eclipse.core.runtime.prefs new file mode 100644 index 00000000..f8a67de1 --- /dev/null +++ b/org.sf.feeling.decompiler.jd/.settings/org.eclipse.core.runtime.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +line.separator=\r\n diff --git a/org.sf.feeling.decompiler.jd/.settings/org.eclipse.jdt.core.prefs b/org.sf.feeling.decompiler.jd/.settings/org.eclipse.jdt.core.prefs index 36413b06..dd8b8ec2 100644 --- a/org.sf.feeling.decompiler.jd/.settings/org.eclipse.jdt.core.prefs +++ b/org.sf.feeling.decompiler.jd/.settings/org.eclipse.jdt.core.prefs @@ -1,11 +1,7 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.autoboxing=ignore @@ -78,4 +74,391 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false +org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false +org.eclipse.jdt.core.formatter.align_with_spaces=false +org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_enum_constant=49 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field=49 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable=49 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_method=49 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package=49 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter=0 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type=49 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assertion_message=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain=0 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0 +org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_module_statements=16 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_record_components=16 +org.eclipse.jdt.core.formatter.alignment_for_relational_operator=0 +org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_shift_operator=0 +org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_record_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_type_annotations=0 +org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0 +org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0 +org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_last_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_abstract_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_statement_group_in_switch=0 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_record_constructor=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_record_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped=true +org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false +org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=true +org.eclipse.jdt.core.formatter.comment.format_block_comments=true +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true +org.eclipse.jdt.core.formatter.comment.format_line_comments=true +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=false +org.eclipse.jdt.core.formatter.comment.indent_root_tags=false +org.eclipse.jdt.core.formatter.comment.indent_tag_description=false +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_between_different_tags=do not insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert +org.eclipse.jdt.core.formatter.comment.line_length=80 +org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true +org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true +org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false +org.eclipse.jdt.core.formatter.compact_else_if=true +org.eclipse.jdt.core.formatter.continuation_indentation=2 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 +org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=false +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_record_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false +org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_default=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_record_components=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_switch_case_expressions=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_not_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_record_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert +org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_case=insert +org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_default=insert +org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_record_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_record_components=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_switch_case_expressions=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_constructor=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_record_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=true +org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_code_block_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_method_body_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_record_constructor_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_record_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line=false +org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.lineSplit=120 +org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false +org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false +org.eclipse.jdt.core.formatter.number_of_blank_lines_after_code_block=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_code_block=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_code_block=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_before_code_block=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 +org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_record_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true +org.eclipse.jdt.core.formatter.tabulation.char=tab +org.eclipse.jdt.core.formatter.tabulation.size=4 +org.eclipse.jdt.core.formatter.text_block_indentation=0 +org.eclipse.jdt.core.formatter.use_on_off_tags=true +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true +org.eclipse.jdt.core.formatter.wrap_before_assertion_message_operator=true +org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false +org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true +org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true +org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true +org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true +org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_before_relational_operator=true +org.eclipse.jdt.core.formatter.wrap_before_shift_operator=true +org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true +org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter diff --git a/org.sf.feeling.decompiler.jd/.settings/org.eclipse.jdt.ui.prefs b/org.sf.feeling.decompiler.jd/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 00000000..9a4e91e5 --- /dev/null +++ b/org.sf.feeling.decompiler.jd/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,106 @@ +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +formatter_profile=org.eclipse.jdt.ui.default.eclipse_profile +formatter_settings_version=20 +sp_cleanup.add_all=false +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.arrays_fill=false +sp_cleanup.bitwise_conditional_expression=false +sp_cleanup.boolean_literal=false +sp_cleanup.break_loop=false +sp_cleanup.collection_cloning=false +sp_cleanup.comparison_statement=false +sp_cleanup.convert_functional_interfaces=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.convert_to_enhanced_for_loop_if_loop_var_used=false +sp_cleanup.convert_to_switch_expressions=false +sp_cleanup.correct_indentation=false +sp_cleanup.double_negation=false +sp_cleanup.else_if=false +sp_cleanup.embedded_if=false +sp_cleanup.evaluate_nullable=false +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=false +sp_cleanup.hash=false +sp_cleanup.if_condition=false +sp_cleanup.insert_inferred_type_arguments=false +sp_cleanup.instanceof=false +sp_cleanup.join=false +sp_cleanup.lazy_logical_operator=false +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=true +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=false +sp_cleanup.map_cloning=false +sp_cleanup.merge_conditional_blocks=false +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.no_string_creation=false +sp_cleanup.no_super=false +sp_cleanup.number_suffix=false +sp_cleanup.objects_equals=false +sp_cleanup.on_save_use_additional_actions=false +sp_cleanup.organize_imports=true +sp_cleanup.overridden_assignment=false +sp_cleanup.precompile_regex=false +sp_cleanup.primitive_serialization=false +sp_cleanup.pull_up_assignment=false +sp_cleanup.push_down_negation=false +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=false +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.redundant_falling_through_block_end=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_redundant_modifiers=false +sp_cleanup.remove_redundant_semicolons=false +sp_cleanup.remove_redundant_type_arguments=false +sp_cleanup.remove_trailing_whitespaces=false +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_array_creation=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=false +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.simplify_lambda_expression_and_method_ref=false +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.strictly_equal_or_different=false +sp_cleanup.stringbuilder=false +sp_cleanup.switch=false +sp_cleanup.ternary_operator=false +sp_cleanup.try_with_resource=false +sp_cleanup.use_anonymous_class_creation=false +sp_cleanup.use_autoboxing=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_directly_map_method=false +sp_cleanup.use_lambda=true +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=false +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true +sp_cleanup.use_unboxing=false +sp_cleanup.use_var=false +sp_cleanup.useless_continue=false +sp_cleanup.useless_return=false diff --git a/org.sf.feeling.decompiler.jd/.settings/org.eclipse.m2e.core.prefs b/org.sf.feeling.decompiler.jd/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 00000000..f897a7f1 --- /dev/null +++ b/org.sf.feeling.decompiler.jd/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/org.sf.feeling.decompiler.jd/META-INF/MANIFEST.MF b/org.sf.feeling.decompiler.jd/META-INF/MANIFEST.MF index c42dd949..07c9255b 100644 --- a/org.sf.feeling.decompiler.jd/META-INF/MANIFEST.MF +++ b/org.sf.feeling.decompiler.jd/META-INF/MANIFEST.MF @@ -1,11 +1,11 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 -Bundle-Name: Eclipse Class Decompiler JD-Core Extension +Bundle-Name: Enhanced Class Decompiler JD-Core Extension Bundle-SymbolicName: org.sf.feeling.decompiler.jd;singleton:=true -Bundle-Version: 2.10.0.qualifier +Bundle-Version: 3.5.1 Bundle-Activator: org.sf.feeling.decompiler.jd.JDCoreDecompilerPlugin Require-Bundle: org.eclipse.core.runtime, - org.sf.feeling.decompiler, + org.sf.feeling.decompiler;bundle-version="3.2.2", org.eclipse.core.resources, org.eclipse.jface, org.eclipse.jface.text, @@ -20,9 +20,12 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.core.expressions, org.eclipse.ui.navigator, org.eclipse.ui.ide;resolution:=optional, - org.eclipse.core.filesystem -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 + org.eclipse.core.filesystem, + org.apache.commons.lang3;bundle-version="3.1.0" +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ActivationPolicy: lazy -Bundle-Vendor: Chen Chao +Bundle-Vendor: ECD Project Team Export-Package: org.sf.feeling.decompiler.jd.actions, org.sf.feeling.decompiler.jd.decompiler +Bundle-ClassPath: ., + lib/jd-core-1.1.3.jar diff --git a/org.sf.feeling.decompiler.jd/build.properties b/org.sf.feeling.decompiler.jd/build.properties index 7cb575b9..42366b0c 100644 --- a/org.sf.feeling.decompiler.jd/build.properties +++ b/org.sf.feeling.decompiler.jd/build.properties @@ -3,5 +3,7 @@ output.. = bin/ bin.includes = META-INF/,\ .,\ plugin.xml,\ - icons/ -qualifier = 20170815 \ No newline at end of file + icons/,\ + lib/,\ + lib/jd-core-1.1.3.jar + diff --git a/org.sf.feeling.decompiler.jd/lib/jd-core-1.1.3.jar b/org.sf.feeling.decompiler.jd/lib/jd-core-1.1.3.jar new file mode 100644 index 00000000..ec8c3ad2 Binary files /dev/null and b/org.sf.feeling.decompiler.jd/lib/jd-core-1.1.3.jar differ diff --git a/org.sf.feeling.decompiler.jd/plugin.xml b/org.sf.feeling.decompiler.jd/plugin.xml index 870f3b31..cd9693a7 100644 --- a/org.sf.feeling.decompiler.jd/plugin.xml +++ b/org.sf.feeling.decompiler.jd/plugin.xml @@ -1,14 +1,11 @@ diff --git a/org.sf.feeling.decompiler.jd/pom.xml b/org.sf.feeling.decompiler.jd/pom.xml new file mode 100644 index 00000000..2d935982 --- /dev/null +++ b/org.sf.feeling.decompiler.jd/pom.xml @@ -0,0 +1,14 @@ + + 4.0.0 + + + com.github.ecd-plugin + com.github.ecd-plugin.ecd + 3.5.1 + ../pom.xml + + + org.sf.feeling.decompiler.jd + eclipse-plugin + diff --git a/org.sf.feeling.decompiler.jd/src/jd/ide/eclipse/JavaDecompilerPlugin.java b/org.sf.feeling.decompiler.jd/src/jd/ide/eclipse/JavaDecompilerPlugin.java deleted file mode 100644 index 947b52b3..00000000 --- a/org.sf.feeling.decompiler.jd/src/jd/ide/eclipse/JavaDecompilerPlugin.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package jd.ide.eclipse; - -import java.lang.reflect.Field; - -import org.eclipse.core.runtime.Plugin; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.ui.plugin.AbstractUIPlugin; - -public class JavaDecompilerPlugin extends AbstractUIPlugin -{ - - public static final String PLUGIN_ID = "jd.ide.eclipse"; //$NON-NLS-1$ - - private static JavaDecompilerPlugin plugin; - - public static JavaDecompilerPlugin getDefault( ) - { - if ( plugin == null ) - plugin = new JavaDecompilerPlugin( ); - - IPreferenceStore store = plugin.getPreferenceStore( ); - store.setDefault( org.sf.feeling.decompiler.JavaDecompilerPlugin.PREF_DISPLAY_LINE_NUMBERS, false ); - store.setDefault( org.sf.feeling.decompiler.JavaDecompilerPlugin.PREF_DISPLAY_METADATA, false ); - - return plugin; - } - - @Override - public IPreferenceStore getPreferenceStore( ) - { - IPreferenceStore store = org.sf.feeling.decompiler.JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ); - - try - { - Field field = Plugin.class.getDeclaredField( "preferences" ); //$NON-NLS-1$ - if ( field != null ) - { - field.setAccessible( true ); - field.set( this, org.sf.feeling.decompiler.JavaDecompilerPlugin.getDefault( ).getPluginPreferences( ) ); - } - } - - catch ( Exception e ) - { - e.printStackTrace( ); - } - - return store; - } -} \ No newline at end of file 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 3c34e5fd..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 @@ -1,91 +1,144 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package jd.ide.eclipse.editors; - -import java.io.IOException; -import java.net.URL; - -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Platform; -import org.sf.feeling.decompiler.editor.BaseDecompilerSourceMapper; -import org.sf.feeling.decompiler.util.UIUtil; - -public abstract class JDSourceMapper extends BaseDecompilerSourceMapper -{ - - protected final static String JAR_SUFFIX = ".jar"; //$NON-NLS-1$ - protected final static String ZIP_SUFFIX = ".zip"; //$NON-NLS-1$ - protected final static String JAVA_CLASS_SUFFIX = ".class"; //$NON-NLS-1$ - protected final static String JAVA_SOURCE_SUFFIX = ".java"; //$NON-NLS-1$ - protected final static int JAVA_SOURCE_SUFFIX_LENGTH = 5; - protected static boolean loaded = false; - - public JDSourceMapper( IPath sourcePath, String rootPath ) - { - super( sourcePath, rootPath ); - } - - public native String decompile( String baseName, String qualifiedName ); - - protected void loadLibrary( ) throws IOException - { - if ( loaded == false ) - { - System.load( getLibraryPath( ) ); - loaded = true; - } - } - - protected String getLibraryPath( ) throws IOException - { - URL pluginUrl = null; - if ( Platform.OS_WIN32.equalsIgnoreCase( Platform.getOS( ) ) ) - { - if ( Platform.ARCH_X86_64.equalsIgnoreCase( Platform.getOSArch( ) ) ) - { - pluginUrl = this.getClass( ).getResource( "/native/jd-core/win32/x86_64/jd-eclipse.dll" ); //$NON-NLS-1$ - } - else - { - pluginUrl = this.getClass( ).getResource( "/native/jd-core/win32/x86/jd-eclipse.dll" ); //$NON-NLS-1$ - } - } - else if ( Platform.OS_LINUX.equalsIgnoreCase( Platform.getOS( ) ) ) - { - if ( Platform.ARCH_X86_64.equalsIgnoreCase( Platform.getOSArch( ) ) ) - { - pluginUrl = this.getClass( ).getResource( "/native/jd-core/linux/x86_64/libjd-eclipse.so" ); //$NON-NLS-1$ - } - else - { - pluginUrl = this.getClass( ).getResource( "/native/jd-core/linux/x86/libjd-eclipse.so" ); //$NON-NLS-1$ - } - } - else if ( Platform.OS_MACOSX.equalsIgnoreCase( Platform.getOS( ) ) ) - { - if ( Platform.ARCH_X86_64.equalsIgnoreCase( Platform.getOSArch( ) ) ) - { - pluginUrl = this.getClass( ).getResource( "/native/jd-core/macosx/x86_64/libjd-eclipse.jnilib" ); //$NON-NLS-1$ - } - else - { - pluginUrl = this.getClass( ).getResource( "/native/jd-core/macosx/x86/libjd-eclipse.jnilib" ); //$NON-NLS-1$ - } - } - String path = FileLocator.toFileURL( pluginUrl ).getFile( ); - if ( UIUtil.isWin32( ) && path != null && ( path.length( ) > 0 ) && ( path.charAt( 0 ) == '/' ) ) - path = path.substring( 1 ); - - return path; - } -} +/* + * 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.nio.file.Path; +import java.nio.file.Paths; +import java.util.Iterator; +import java.util.Map; +import java.util.TreeMap; + +import org.eclipse.core.runtime.IPath; +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; +import org.sf.feeling.decompiler.jd.decompiler.JDCoreZipLoader; +import org.sf.feeling.decompiler.jd.decompiler.JDCoreZipLoader.EntriesCache; + +/** + * JDSourceMapper + * + * @project Java Decompiler Eclipse Plugin + * @version 0.1.5 + * @see org.eclipse.jdt.internal.core.SourceMapper + */ +public abstract class JDSourceMapper extends BaseDecompilerSourceMapper { + + 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 static EntriesCache entriesCache = null; + + private File basePath; + + public JDSourceMapper(File basePath, IPath sourcePath, String sourceRootPath, Map options) { + super(sourcePath, sourceRootPath, options); + this.basePath = basePath; + } + + @Override + 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 = 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 { + File decompilePath = this.basePath.getAbsoluteFile(); + if (decompilePath.isFile()) { + String result = decompile(decompilePath.toString(), classPath); + if (result != null) { + source = result.toCharArray(); + } + } else { + JavaDecompilerPlugin.getDefault().getLog() + .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, JavaDecompilerConstants.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. + * @throws Exception + */ + public String decompile(String basePath, String classPath) throws Exception { + // Load preferences + IPreferenceStore store = JavaDecompilerPlugin.getDefault().getPreferenceStore(); + + boolean realignmentLineNumber = store.getBoolean(JavaDecompilerConstants.ALIGN); + boolean unicodeEscape = false; // currently unused : + // store.getBoolean(JavaDecompilerPlugin.PREF_ESCAPE_UNICODE_CHARACTERS); + boolean showLineNumbers = store.getBoolean(JavaDecompilerConstants.PREF_DISPLAY_LINE_NUMBERS); + // boolean showMetadata = + // store.getBoolean(JavaDecompilerPlugin.PREF_DISPLAY_METADATA); + + Map configuration = new TreeMap<>(); + configuration.put("realignLineNumbers", realignmentLineNumber); + + if (classPath.endsWith(JAVA_CLASS_SUFFIX)) { + classPath = classPath.substring(0, classPath.length() - 6); + } + + Path jarPath = Paths.get(basePath); + + EntriesCache cache = null; + if (entriesCache != null && entriesCache.isForTheSameFile(jarPath)) { + // The saved cache is for the same file and the file has not changed + // => we can just re-use it + cache = entriesCache; + } + + try (JDCoreZipLoader loader = new JDCoreZipLoader(jarPath, cache)) { + JDCorePrinter printer = new JDCorePrinter(unicodeEscape, showLineNumbers); + + ClassFileToJavaSourceDecompiler decompiler = new ClassFileToJavaSourceDecompiler(); + decompiler.decompile(loader, printer, classPath, configuration); + + // Save the cache so we don't have to re-load the class names + // in case we decompile another class from the same JAR file + entriesCache = loader.getEntriesCache(); + + return printer.toString(); + } + } + + /** + * @return version of JD-Core + * @since JD-Core 1.1.3 + */ + public static String getVersion() { + return "1.1.3"; + } +} diff --git a/org.sf.feeling.decompiler.jd/src/native/jd-core/linux/x86/libjd-eclipse.so b/org.sf.feeling.decompiler.jd/src/native/jd-core/linux/x86/libjd-eclipse.so deleted file mode 100644 index c22ce39a..00000000 Binary files a/org.sf.feeling.decompiler.jd/src/native/jd-core/linux/x86/libjd-eclipse.so and /dev/null differ diff --git a/org.sf.feeling.decompiler.jd/src/native/jd-core/linux/x86_64/libjd-eclipse.so b/org.sf.feeling.decompiler.jd/src/native/jd-core/linux/x86_64/libjd-eclipse.so deleted file mode 100644 index e18c5610..00000000 Binary files a/org.sf.feeling.decompiler.jd/src/native/jd-core/linux/x86_64/libjd-eclipse.so and /dev/null differ diff --git a/org.sf.feeling.decompiler.jd/src/native/jd-core/macosx/x86/libjd-eclipse.jnilib b/org.sf.feeling.decompiler.jd/src/native/jd-core/macosx/x86/libjd-eclipse.jnilib deleted file mode 100644 index 7de4d5dd..00000000 Binary files a/org.sf.feeling.decompiler.jd/src/native/jd-core/macosx/x86/libjd-eclipse.jnilib and /dev/null differ diff --git a/org.sf.feeling.decompiler.jd/src/native/jd-core/macosx/x86_64/libjd-eclipse.jnilib b/org.sf.feeling.decompiler.jd/src/native/jd-core/macosx/x86_64/libjd-eclipse.jnilib deleted file mode 100644 index f949e74c..00000000 Binary files a/org.sf.feeling.decompiler.jd/src/native/jd-core/macosx/x86_64/libjd-eclipse.jnilib and /dev/null differ diff --git a/org.sf.feeling.decompiler.jd/src/native/jd-core/win32/x86/jd-eclipse.dll b/org.sf.feeling.decompiler.jd/src/native/jd-core/win32/x86/jd-eclipse.dll deleted file mode 100644 index d7b2249f..00000000 Binary files a/org.sf.feeling.decompiler.jd/src/native/jd-core/win32/x86/jd-eclipse.dll and /dev/null differ diff --git a/org.sf.feeling.decompiler.jd/src/native/jd-core/win32/x86_64/jd-eclipse.dll b/org.sf.feeling.decompiler.jd/src/native/jd-core/win32/x86_64/jd-eclipse.dll deleted file mode 100644 index 3acceaa8..00000000 Binary files a/org.sf.feeling.decompiler.jd/src/native/jd-core/win32/x86_64/jd-eclipse.dll and /dev/null differ diff --git a/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/JDCoreDecompilerPlugin.java b/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/JDCoreDecompilerPlugin.java index 029bbeed..4e664602 100644 --- a/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/JDCoreDecompilerPlugin.java +++ b/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/JDCoreDecompilerPlugin.java @@ -11,9 +11,9 @@ import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; import org.sf.feeling.decompiler.JavaDecompilerPlugin; +import org.sf.feeling.decompiler.jd.decompiler.JDCoreSourceMapper; -public class JDCoreDecompilerPlugin extends AbstractUIPlugin implements IPropertyChangeListener -{ +public class JDCoreDecompilerPlugin extends AbstractUIPlugin implements IPropertyChangeListener { public static final String PLUGIN_ID = "org.sf.feeling.decompiler.jd"; //$NON-NLS-1$ @@ -21,6 +21,8 @@ public class JDCoreDecompilerPlugin extends AbstractUIPlugin implements IPropert public static final String decompilerType = "JD-Core"; //$NON-NLS-1$ + public static final String decompilerVersion = JDCoreSourceMapper.getVersion(); + private static JDCoreDecompilerPlugin plugin; private IPreferenceStore preferenceStore; @@ -29,14 +31,12 @@ public class JDCoreDecompilerPlugin extends AbstractUIPlugin implements IPropert * (non-Javadoc) * * @see - * org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext - * ) + * org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext ) */ @Override - public void start( BundleContext context ) throws Exception - { - super.start( context ); - getPreferenceStore( ).addPropertyChangeListener( this ); + public void start(BundleContext context) throws Exception { + super.start(context); + getPreferenceStore().addPropertyChangeListener(this); } /* @@ -46,55 +46,45 @@ public void start( BundleContext context ) throws Exception * org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) */ @Override - public void stop( BundleContext context ) throws Exception - { - super.stop( context ); - getPreferenceStore( ).removePropertyChangeListener( this ); + public void stop(BundleContext context) throws Exception { + super.stop(context); + getPreferenceStore().removePropertyChangeListener(this); plugin = null; } @Override - public void propertyChange( PropertyChangeEvent event ) - { + public void propertyChange(PropertyChangeEvent event) { } @Override - public IPreferenceStore getPreferenceStore( ) - { - if ( preferenceStore == null ) - { - preferenceStore = JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ); + public IPreferenceStore getPreferenceStore() { + if (preferenceStore == null) { + preferenceStore = JavaDecompilerPlugin.getDefault().getPreferenceStore(); } return preferenceStore; } - public static JDCoreDecompilerPlugin getDefault( ) - { + public static JDCoreDecompilerPlugin getDefault() { return plugin; } - public JDCoreDecompilerPlugin( ) - { + public JDCoreDecompilerPlugin() { plugin = this; } - public static ImageDescriptor getImageDescriptor( String path ) - { - URL base = JDCoreDecompilerPlugin.getDefault( ).getBundle( ).getEntry( "/" ); //$NON-NLS-1$ + public static ImageDescriptor getImageDescriptor(String path) { + URL base = JDCoreDecompilerPlugin.getDefault().getBundle().getEntry("/"); //$NON-NLS-1$ URL url = null; - try - { - url = new URL( base, path ); // $NON-NLS-1$ - } - catch ( MalformedURLException e ) - { - e.printStackTrace( ); + try { + url = new URL(base, path); // $NON-NLS-1$ + } catch (MalformedURLException e) { + e.printStackTrace(); } ImageDescriptor actionIcon = null; - if ( url != null ) - actionIcon = ImageDescriptor.createFromURL( url ); + if (url != null) + actionIcon = ImageDescriptor.createFromURL(url); return actionIcon; } diff --git a/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/actions/DecompileWithJDCoreAction.java b/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/actions/DecompileWithJDCoreAction.java index 2a880dee..af7e7adf 100644 --- a/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/actions/DecompileWithJDCoreAction.java +++ b/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/actions/DecompileWithJDCoreAction.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.jd.actions; @@ -17,30 +14,23 @@ import org.sf.feeling.decompiler.jd.i18n.Messages; import org.sf.feeling.decompiler.util.UIUtil; -public class DecompileWithJDCoreAction extends Action -{ +public class DecompileWithJDCoreAction extends Action { - public DecompileWithJDCoreAction( ) - { - super( Messages.getString( "JavaDecompilerActionBarContributor.Action.DecompileWithJDCore" ) ); //$NON-NLS-1$ - this.setImageDescriptor( JDCoreDecompilerPlugin.getImageDescriptor( "icons/jd_16.png" ) ); //$NON-NLS-1$ + public DecompileWithJDCoreAction() { + super(Messages.getString("JavaDecompilerActionBarContributor.Action.DecompileWithJDCore")); //$NON-NLS-1$ + this.setImageDescriptor(JDCoreDecompilerPlugin.getImageDescriptor("icons/jd_16.png")); //$NON-NLS-1$ } @Override - public void run( ) - { - try - { - new DecompileWithJDCoreHandler( ).execute( null ); - } - catch ( ExecutionException e ) - { + public void run() { + try { + new DecompileWithJDCoreHandler().execute(null); + } catch (ExecutionException e) { } } @Override - public boolean isEnabled( ) - { - return UIUtil.getActiveEditor( ) != null || UIUtil.getActiveSelection( ) != null; + public boolean isEnabled() { + return UIUtil.getActiveEditor() != null || UIUtil.getActiveSelection() != null; } } \ No newline at end of file diff --git a/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/actions/DecompileWithJDCoreHandler.java b/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/actions/DecompileWithJDCoreHandler.java index 0d776ac8..b3cbc41c 100644 --- a/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/actions/DecompileWithJDCoreHandler.java +++ b/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/actions/DecompileWithJDCoreHandler.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.jd.actions; @@ -16,13 +13,11 @@ import org.sf.feeling.decompiler.actions.BaseDecompilerHandler; import org.sf.feeling.decompiler.jd.JDCoreDecompilerPlugin; -public class DecompileWithJDCoreHandler extends BaseDecompilerHandler -{ +public class DecompileWithJDCoreHandler extends BaseDecompilerHandler { @Override - public Object execute( ExecutionEvent event ) throws ExecutionException - { - return handleDecompile( JDCoreDecompilerPlugin.decompilerType ); + public Object execute(ExecutionEvent event) throws ExecutionException { + return handleDecompile(JDCoreDecompilerPlugin.decompilerType); } } \ No newline at end of file diff --git a/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/decompiler/JDCoreDecompiler.java b/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/decompiler/JDCoreDecompiler.java index 72e36628..1eea8809 100644 --- a/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/decompiler/JDCoreDecompiler.java +++ b/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/decompiler/JDCoreDecompiler.java @@ -1,47 +1,37 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.jd.decompiler; import java.io.File; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.jetbrains.java.decompiler.main.DecompilerContext; -import org.jetbrains.java.decompiler.main.collectors.CounterContainer; -import org.jetbrains.java.decompiler.struct.StructClass; -import org.jetbrains.java.decompiler.struct.lazy.LazyLoader; +import java.nio.file.Files; + +import org.apache.commons.lang3.time.StopWatch; import org.sf.feeling.decompiler.JavaDecompilerPlugin; +import org.sf.feeling.decompiler.editor.BaseDecompiler; import org.sf.feeling.decompiler.editor.IDecompiler; +import org.sf.feeling.decompiler.editor.LineNumberOutputType; import org.sf.feeling.decompiler.jd.JDCoreDecompilerPlugin; +import org.sf.feeling.decompiler.util.ClassUtil; import org.sf.feeling.decompiler.util.FileUtil; -import org.sf.feeling.decompiler.util.JarClassExtractor; import org.sf.feeling.decompiler.util.UIUtil; import jd.ide.eclipse.editors.JDSourceMapper; -public class JDCoreDecompiler implements IDecompiler -{ +public class JDCoreDecompiler extends BaseDecompiler { private String source = ""; // $NON-NLS-1$ //$NON-NLS-1$ - private long time, start; + private long time; private String log = ""; //$NON-NLS-1$ private JDSourceMapper mapper; - public JDCoreDecompiler( JDSourceMapper mapper ) - { + public JDCoreDecompiler(JDSourceMapper mapper) { this.mapper = mapper; } @@ -52,137 +42,92 @@ public JDCoreDecompiler( JDSourceMapper mapper ) * @see IDecompiler#decompile(String, String, String) */ @Override - public void decompile( String root, String classPackage, String className ) - { - start = System.currentTimeMillis( ); + public void decompile(String root, String classPackage, String className) { + StopWatch stopWatch = new StopWatch(); + stopWatch.start(); log = ""; //$NON-NLS-1$ source = ""; //$NON-NLS-1$ Boolean displayNumber = null; - File workingDir = new File( root ); // $NON-NLS-1$ - - File zipFile = new File( System.getProperty( "java.io.tmpdir" ), //$NON-NLS-1$ - className.replaceAll( "(?i)\\.class", System.currentTimeMillis( ) + ".jar" ) ); //$NON-NLS-1$ //$NON-NLS-2$ - String zipFileName = zipFile.getAbsolutePath( ); - - try - { - if ( classPackage.length( ) == 0 ) - { - DecompilerContext.initContext( new HashMap( ) ); - DecompilerContext.setCounterContainer( new CounterContainer( ) ); - StructClass structClass = new StructClass( FileUtil.getBytes( new File( root, className ) ), - true, - new LazyLoader( null ) ); - structClass.releaseResources( ); - classPackage = structClass.qualifiedName.replace( "/" //$NON-NLS-1$ - + className.replaceAll( "(?i)\\.class", "" ), "" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } + File workingDir = new File(root); // $NON-NLS-1$ - FileUtil.zipDir( workingDir, classPackage, zipFileName ); + File zipFile = new File(System.getProperty("java.io.tmpdir"), //$NON-NLS-1$ + className.replaceAll("(?i)\\.class", System.currentTimeMillis() + ".jar")); //$NON-NLS-1$ //$NON-NLS-2$ + String zipFileName = zipFile.getAbsolutePath(); - if ( UIUtil.isDebugPerspective( ) || JavaDecompilerPlugin.getDefault( ).isDebugMode( ) ) - { - displayNumber = JavaDecompilerPlugin.getDefault( ).isDisplayLineNumber( ); - JavaDecompilerPlugin.getDefault( ).displayLineNumber( Boolean.TRUE ); + try { + if (classPackage.length() == 0) { + File classFile = new File(root, className); + String qualifiedName = ClassUtil.getClassQualifiedName(Files.readAllBytes(classFile.toPath())); + classPackage = qualifiedName.replace("/" //$NON-NLS-1$ + + className.replaceAll("(?i)\\.class", ""), ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } - source = mapper.decompile( zipFileName, - ( classPackage.length( ) > 0 ? ( classPackage + "/" ) : "" ) //$NON-NLS-1$ //$NON-NLS-2$ - + className ); + FileUtil.zipDir(workingDir, classPackage, zipFileName); - if ( !zipFile.delete( ) ) - { - zipFile.deleteOnExit( ); + if (UIUtil.isDebugPerspective() || JavaDecompilerPlugin.getDefault().isDebugMode()) { + displayNumber = JavaDecompilerPlugin.getDefault().isDisplayLineNumber(); + JavaDecompilerPlugin.getDefault().displayLineNumber(Boolean.TRUE); } - } - catch ( Exception e ) - { - JavaDecompilerPlugin.logError( e, e.getMessage( ) ); - } - - if ( displayNumber != null ) - { - JavaDecompilerPlugin.getDefault( ).displayLineNumber( displayNumber ); - } - - if ( source != null ) - { - Pattern wp = Pattern.compile( "/\\*.+?\\*/", Pattern.DOTALL ); //$NON-NLS-1$ - Matcher m = wp.matcher( source ); - while ( m.find( ) ) - { - if ( m.group( ).matches( "/\\*\\s+\\d*\\s+\\*/" ) ) //$NON-NLS-1$ - continue; - - String group = m.group( ); - group = group.replace( "/* ", "\t" ); //$NON-NLS-1$ //$NON-NLS-2$ - group = group.replace( " */", "" ); //$NON-NLS-1$ //$NON-NLS-2$ - group = group.replace( " * ", "\t" ); //$NON-NLS-1$ //$NON-NLS-2$ - - if ( log.length( ) > 0 ) - log += "\n"; //$NON-NLS-1$ - log += group; - source = source.replace( m.group( ), "" ); //$NON-NLS-1$ + source = mapper.decompile(zipFileName, (classPackage.length() > 0 ? (classPackage + "/") : "") //$NON-NLS-1$ //$NON-NLS-2$ + + className); + if (!zipFile.delete()) { + zipFile.deleteOnExit(); } + } catch (Exception e) { + JavaDecompilerPlugin.logError(e, e.getMessage()); } - time = System.currentTimeMillis( ) - start; + if (displayNumber != null) { + JavaDecompilerPlugin.getDefault().displayLineNumber(displayNumber); + } + + time = stopWatch.getTime(); } /** - * Jad doesn't support decompilation from archives. This methods extracts - * request class file from the specified archive into temp directory and - * then calls decompile. + * Our {@link JDCoreZipLoader} supports direct decompilation from within a JAR + * archive * * @see IDecompiler#decompileFromArchive(String, String, String) */ @Override - 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$ - + System.currentTimeMillis( ) ); - - try - { - workingDir.mkdirs( ); - JarClassExtractor.extract( archivePath, packege, className, true, workingDir.getAbsolutePath( ) ); - decompile( workingDir.getAbsolutePath( ), packege, className ); // $NON-NLS-1$ - } - catch ( Exception e ) - { - JavaDecompilerPlugin.logError( e, e.getMessage( ) ); - return; + public void decompileFromArchive(String archivePath, String packege, String className) { + long start = System.nanoTime(); + Boolean displayNumber = null; + + try { + if (UIUtil.isDebugPerspective() || JavaDecompilerPlugin.getDefault().isDebugMode()) { + displayNumber = JavaDecompilerPlugin.getDefault().isDisplayLineNumber(); + JavaDecompilerPlugin.getDefault().displayLineNumber(Boolean.TRUE); + } + + String decompileClassName = packege + "/" + className.replaceAll("(?i)\\.class$", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + + source = mapper.decompile(archivePath, decompileClassName); + } catch (Exception e) { + JavaDecompilerPlugin.logError(e, e.getMessage()); } - finally - { - FileUtil.deltree( workingDir ); + + if (displayNumber != null) { + JavaDecompilerPlugin.getDefault().displayLineNumber(displayNumber); } - } - @Override - public long getDecompilationTime( ) - { - return time; + time = (System.nanoTime() - start) / 1000000; } @Override - public List getExceptions( ) - { - return Collections.EMPTY_LIST; + public long getDecompilationTime() { + return time; } /** * @see IDecompiler#getLog() */ @Override - public String getLog( ) - { + public String getLog() { return log; } @@ -190,38 +135,43 @@ public String getLog( ) * @see IDecompiler#getSource() */ @Override - public String getSource( ) - { + public String getSource() { return source; } @Override - public String getDecompilerType( ) - { + public String getDecompilerType() { return JDCoreDecompilerPlugin.decompilerType; } @Override - public String removeComment( String source ) - { + public String removeComment(String source) { return source; } @Override - public boolean supportLevel( int level ) - { - return level < 8; + public boolean supportLevel(int level) { + return true; } @Override - public boolean supportDebugLevel( int level ) - { - return level < 8; + public boolean supportDebugLevel(int level) { + return true; } @Override - public boolean supportDebug( ) - { - return true; + public String getDecompilerName() { + return JDCoreDecompilerPlugin.decompilerType; + } + + @Override + public String getDecompilerVersion() { + return JDCoreDecompilerPlugin.decompilerVersion; } + + @Override + public LineNumberOutputType getLineNumberOutputType() { + return LineNumberOutputType.BLOCK_COMMENT_BEGIN_OF_LINE; + } + } \ No newline at end of file diff --git a/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/decompiler/JDCoreDecompilerDescriptor.java b/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/decompiler/JDCoreDecompilerDescriptor.java index 19a454c7..43a1254a 100644 --- a/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/decompiler/JDCoreDecompilerDescriptor.java +++ b/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/decompiler/JDCoreDecompilerDescriptor.java @@ -3,7 +3,6 @@ import org.eclipse.jface.action.Action; import org.eclipse.jface.resource.ImageDescriptor; -import org.sf.feeling.decompiler.editor.BaseDecompilerSourceMapper; import org.sf.feeling.decompiler.editor.IDecompiler; import org.sf.feeling.decompiler.editor.IDecompilerDescriptor; import org.sf.feeling.decompiler.jd.JDCoreDecompilerPlugin; @@ -12,70 +11,60 @@ import jd.ide.eclipse.editors.JDSourceMapper; -public class JDCoreDecompilerDescriptor implements IDecompilerDescriptor -{ +public class JDCoreDecompilerDescriptor implements IDecompilerDescriptor { private JDCoreDecompiler decompiler = null; - private BaseDecompilerSourceMapper sourceMapper = null; + private JDSourceMapper sourceMapper = null; private Action decompileAction = null; @Override - public String getDecompilerType( ) - { + public String getDecompilerType() { return JDCoreDecompilerPlugin.decompilerType; } @Override - public String getDecompilerPreferenceLabel( ) - { - return Messages.getString( "JDCoreDecompilerDescriptor.PreferenceLabel" ); //$NON-NLS-1$ + public String getDecompilerPreferenceLabel() { + return Messages.getString("JDCoreDecompilerDescriptor.PreferenceLabel"); //$NON-NLS-1$ } @Override - public IDecompiler getDecompiler( ) - { - if ( decompiler == null ) - decompiler = new JDCoreDecompiler( (JDSourceMapper) getDecompilerSourceMapper( ) ); + public IDecompiler getDecompiler() { + if (decompiler == null) { + decompiler = new JDCoreDecompiler(getDecompilerSourceMapper()); + } return decompiler; } @Override - public BaseDecompilerSourceMapper getDecompilerSourceMapper( ) - { - if ( sourceMapper == null ) - { - sourceMapper = new JDCoreSourceMapper( ); + public JDSourceMapper getDecompilerSourceMapper() { + if (sourceMapper == null) { + sourceMapper = new JDCoreSourceMapper(); } return sourceMapper; } @Override - public Action getDecompileAction( ) - { - if ( decompileAction == null ) - { - decompileAction = new DecompileWithJDCoreAction( ); + public Action getDecompileAction() { + if (decompileAction == null) { + decompileAction = new DecompileWithJDCoreAction(); } return decompileAction; } @Override - public boolean isEnabled( ) - { + public boolean isEnabled() { return true; } @Override - public boolean isDefault( ) - { - return true; + public int getDefaultPriority() { + return 0; } @Override - public ImageDescriptor getDecompilerIcon( ) - { - return JDCoreDecompilerPlugin.getImageDescriptor( "icons/jd_16.png" ); //$NON-NLS-1$ + public ImageDescriptor getDecompilerIcon() { + return JDCoreDecompilerPlugin.getImageDescriptor("icons/jd_16.png"); //$NON-NLS-1$ } } diff --git a/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/decompiler/JDCorePrinter.java b/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/decompiler/JDCorePrinter.java new file mode 100644 index 00000000..824eab3b --- /dev/null +++ b/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/decompiler/JDCorePrinter.java @@ -0,0 +1,160 @@ +/* + * 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.sf.feeling.decompiler.jd.decompiler; + +import org.jd.core.v1.api.printer.Printer; + +public class JDCorePrinter implements Printer { + + protected static final String TAB = " "; + protected static final String NEWLINE = "\n"; + + protected final StringBuilder sb = new StringBuilder(4096); + + protected int indentationCount; + protected int realLineNumber = 0; + protected String lineNumberFormat; + protected int lineNumberWidth; + + protected final boolean escapeUnicodeCharacters; + protected final boolean printLineNumbers; + + public JDCorePrinter(boolean escapeUnicodeCharacters, boolean printLineNumbers) { + super(); + this.escapeUnicodeCharacters = escapeUnicodeCharacters; + this.printLineNumbers = printLineNumbers; + } + + public void init() { + sb.setLength(0); + realLineNumber = 0; + indentationCount = 0; + } + + public String toString() { + return sb.toString(); + } + + // --- Printer --- // + public void start(int maxLineNumber, int majorVersion, int minorVersion) { + this.indentationCount = 0; + + if (printLineNumbers) { + if (maxLineNumber == Printer.UNKNOWN_LINE_NUMBER) { + lineNumberFormat = "%4d"; + } else { + int width = 1; + + while (maxLineNumber >= 10) { + width++; + maxLineNumber /= 10; + } + + lineNumberFormat = "%" + width + "d"; + lineNumberWidth = width; + } + } + } + + public void end() { + } + + public void printText(String text) { + if (escapeUnicodeCharacters) { + for (int i = 0, len = text.length(); i < len; i++) { + char c = text.charAt(i); + + if (c < 127) { + sb.append(c); + } else { + int h = (c >> 12); + + sb.append("\\u"); + sb.append((char) ((h <= 9) ? (h + '0') : (h + ('A' - 10)))); + h = (c >> 8) & 15; + sb.append((char) ((h <= 9) ? (h + '0') : (h + ('A' - 10)))); + h = (c >> 4) & 15; + sb.append((char) ((h <= 9) ? (h + '0') : (h + ('A' - 10)))); + h = (c) & 15; + sb.append((char) ((h <= 9) ? (h + '0') : (h + ('A' - 10)))); + } + } + } else { + sb.append(text); + } + } + + public void printNumericConstant(String constant) { + sb.append(constant); + } + + public void printStringConstant(String constant, String ownerInternalName) { + printText(constant); + } + + public void printKeyword(String keyword) { + sb.append(keyword); + } + + public void printDeclaration(int type, String internalTypeName, String name, String descriptor) { + printText(name); + } + + public void printReference(int type, String internalTypeName, String name, String descriptor, + String ownerInternalName) { + printText(name); + } + + public void indent() { + this.indentationCount++; + } + + public void unindent() { + if (this.indentationCount > 0) + this.indentationCount--; + } + + public void startLine(int lineNumber) { + printLineNumber(lineNumber); + + for (int i = 0; i < indentationCount; i++) + sb.append(TAB); + } + + public void endLine() { + sb.append(NEWLINE); + } + + public void extraLine(int count) { + while (count-- > 0) { + printLineNumber(0); + sb.append(NEWLINE); + } + } + + public void startMarker(int type) { + } + + public void endMarker(int type) { + } + + protected void printLineNumber(int lineNumber) { + if (!printLineNumbers) { + return; + } + sb.append("/* "); + if (lineNumber > 0) { + sb.append(String.format(lineNumberFormat, lineNumber)); + } else { + for (int i = 0; i < lineNumberWidth; i++) { + sb.append(' '); + } + } + sb.append(" */ "); + } +} \ No newline at end of file diff --git a/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/decompiler/JDCoreSourceMapper.java b/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/decompiler/JDCoreSourceMapper.java index 98224860..51d2c845 100644 --- a/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/decompiler/JDCoreSourceMapper.java +++ b/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/decompiler/JDCoreSourceMapper.java @@ -1,86 +1,36 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.jd.decompiler; -import java.io.IOException; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Collection; -import java.util.Iterator; +import java.io.File; +import java.util.Collections; import org.eclipse.core.runtime.Path; -import org.sf.feeling.decompiler.JavaDecompilerPlugin; +import org.sf.feeling.decompiler.jd.JDCoreDecompilerPlugin; import jd.ide.eclipse.editors.JDSourceMapper; -public class JDCoreSourceMapper extends JDSourceMapper -{ +public class JDCoreSourceMapper extends JDSourceMapper { - public JDCoreSourceMapper( ) - { - super( new Path( "." ), "" ); //$NON-NLS-1$ //$NON-NLS-2$ - try - { - loadLibrary( ); - } - catch ( IOException e ) - { - JavaDecompilerPlugin.logError( e, e.getMessage( ) ); - } - origionalDecompiler = new JDCoreDecompiler( this ); + public JDCoreSourceMapper() { + super(new File("."), new Path("."), "", Collections.emptyMap()); //$NON-NLS-1$ //$NON-NLS-2$ + originalDecompiler = new JDCoreDecompiler(this); } @Override - protected void printDecompileReport( StringBuffer source, String fileLocation, Collection exceptions, - long decompilationTime ) - { - String location = "\tDecompiled from: " //$NON-NLS-1$ - + fileLocation; - source.append( "\n\n/*" ); //$NON-NLS-1$ - source.append( "\n\tDECOMPILATION REPORT\n\n" ); //$NON-NLS-1$ - source.append( location ).append( "\n" ); //$NON-NLS-1$ - source.append( "\tTotal time: " ) //$NON-NLS-1$ - .append( decompilationTime ) - .append( " ms\n" ); //$NON-NLS-1$ - source.append( "\t" //$NON-NLS-1$ - + origionalDecompiler.getLog( ) - .replaceAll( "\t", "" ) //$NON-NLS-1$ //$NON-NLS-2$ - .replaceAll( "\n\\s*", "\n\t" ) ); //$NON-NLS-1$ //$NON-NLS-2$ - exceptions.addAll( origionalDecompiler.getExceptions( ) ); - logExceptions( exceptions, source ); - source.append( "\n*/" ); //$NON-NLS-1$ + protected String getDecompilerName() { + return JDCoreDecompilerPlugin.decompilerType; } - protected void logExceptions( Collection exceptions, StringBuffer buffer ) - { - if ( !exceptions.isEmpty( ) ) - { - buffer.append( "\n\tCaught exceptions:" ); //$NON-NLS-1$ - if ( exceptions == null || exceptions.size( ) == 0 ) - return; // nothing to do - buffer.append( "\n" ); //$NON-NLS-1$ - StringWriter stackTraces = new StringWriter( ); - PrintWriter stackTracesP = new PrintWriter( stackTraces ); - - Iterator i = exceptions.iterator( ); - while ( i.hasNext( ) ) - { - ( (Exception) i.next( ) ).printStackTrace( stackTracesP ); - stackTracesP.println( "" ); //$NON-NLS-1$ - } - - stackTracesP.flush( ); - stackTracesP.close( ); - buffer.append( stackTraces.toString( ) ); - } + @Override + protected String getDecompilerVersion() { + return JDCoreDecompilerPlugin.decompilerVersion; } + } diff --git a/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/decompiler/JDCoreZipLoader.java b/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/decompiler/JDCoreZipLoader.java new file mode 100644 index 00000000..6f9eaa9a --- /dev/null +++ b/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/decompiler/JDCoreZipLoader.java @@ -0,0 +1,186 @@ +/******************************************************************************* + * Copyright (c) 2020 Chen Chao and other ECD project contributors. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.sf.feeling.decompiler.jd.decompiler; + +import java.io.ByteArrayOutputStream; +import java.io.Closeable; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.attribute.FileTime; +import java.util.Enumeration; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; +import java.util.TreeSet; +import java.util.zip.ZipEntry; +import java.util.zip.ZipException; +import java.util.zip.ZipFile; + +import org.jd.core.v1.api.loader.Loader; +import org.jd.core.v1.api.loader.LoaderException; +import org.objectweb.asm.ClassReader; +import org.sf.feeling.decompiler.util.IOUtils; +import org.sf.feeling.decompiler.util.Logger; + +/** + * + * JD-Core Loader implementation for decompiling classes directly from within a + * ZIP/JAR archive + * + * @author Jan Peter Stotz + * + */ +public class JDCoreZipLoader implements Loader, Closeable { + + private final ZipFile zipFile; + + private final EntriesCache entriesCache; + + private final Set loadedEntries = new TreeSet<>(); + + public JDCoreZipLoader(Path zipFilePath, EntriesCache entriesCache) throws ZipException, IOException { + super(); + if (entriesCache != null && !entriesCache.zipFilePath.equals(zipFilePath)) { + throw new IllegalArgumentException("entriesCache is for the wrong zipFilePath"); + } + zipFile = new ZipFile(zipFilePath.toFile()); + + if (entriesCache == null) { + entriesCache = new EntriesCache(zipFilePath); + Enumeration entries = zipFile.entries(); + while (entries.hasMoreElements()) { + ZipEntry entry = entries.nextElement(); + String name = entry.getName(); + + if (name.startsWith("/")) { + name = name.substring(1); + } + if (name.endsWith(".class")) { + try { + // Extract class name from class file + ClassReader cr = new ClassReader(zipFile.getInputStream(entry)); + String className = cr.getClassName(); + + if (className != null && !className.isEmpty()) { + String oldEntry = entriesCache.entriesMap.put(className, entry.getName()); + if (oldEntry != null) { + Logger.info("Duplicate class " + className + " found in JAR " + zipFilePath + ": " + + entry.getName() + "/" + oldEntry); + } + } + } catch (Exception e) { + Logger.error("Failed to read entry " + name + ": " + e.toString()); + } + } + } + } + this.entriesCache = entriesCache; + } + + @Override + public boolean canLoad(String internalName) { + boolean result = entriesCache.entriesMap.containsKey(internalName); + return result; + } + + @Override + public byte[] load(String internalName) throws LoaderException { + String entryName = entriesCache.entriesMap.get(internalName); + if (entryName == null) { + Logger.error("Class not found: " + internalName); + return new byte[0]; + } + ZipEntry entry = zipFile.getEntry(entryName); + if (entry == null) { + // Should never happen + Logger.error("Entry - missing for class file: " + entryName); + return new byte[0]; + } + int initialSize = entry.getSize() > 0 ? (int) entry.getSize() : 4096; + try (ByteArrayOutputStream out = new ByteArrayOutputStream(initialSize)) { + try (InputStream in = zipFile.getInputStream(entry)) { + IOUtils.copy(in, out, 8 * 1024); + loadedEntries.add(internalName); + return out.toByteArray(); + } + } catch (IOException e) { + throw new LoaderException(e); + } + } + + public Set getLoadedEntries() { + return loadedEntries; + } + + public EntriesCache getEntriesCache() { + return entriesCache; + } + + @Override + public void close() throws IOException { + zipFile.close(); + } + + public static class EntriesCache { + private final Path zipFilePath; + private final FileTime zipFileLastModified; + + /** + * maps class name to file name in the JAR file + */ + private final Map entriesMap = new TreeMap<>(); + + public EntriesCache(Path zipFilePath) throws IOException { + super(); + this.zipFilePath = zipFilePath; + this.zipFileLastModified = Files.getLastModifiedTime(zipFilePath); + } + + public Path getZipFilePath() { + return zipFilePath; + } + + public boolean isForTheSameFile(Path fileToTest) throws IOException { + boolean equal = zipFilePath.equals(fileToTest); + if (equal) { + FileTime lastMod = Files.getLastModifiedTime(fileToTest); + return (zipFileLastModified.equals(lastMod)); + } + return false; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((zipFilePath == null) ? 0 : zipFilePath.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + EntriesCache other = (EntriesCache) obj; + if (zipFilePath == null) { + if (other.zipFilePath != null) + return false; + } else if (!zipFilePath.equals(other.zipFilePath)) + return false; + return true; + } + + } +} diff --git a/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/i18n/Messages.java b/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/i18n/Messages.java index b6ef6a1c..1731c058 100644 --- a/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/i18n/Messages.java +++ b/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/i18n/Messages.java @@ -1,53 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2017 Chen Chao and other ECD project contributors. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ package org.sf.feeling.decompiler.jd.i18n; -import java.io.UnsupportedEncodingException; -import java.text.MessageFormat; -import java.util.MissingResourceException; -import java.util.ResourceBundle; +import org.sf.feeling.decompiler.i18n.EcdResouceBundle; -public class Messages -{ +public class Messages { - private static final String BUNDLE_NAME = "org.sf.feeling.decompiler.jd.i18n.messages"; //$NON-NLS-1$ + private static final EcdResouceBundle RESOURCE_BUNDLE = new EcdResouceBundle(Messages.class); - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); - - private Messages( ) - { + private Messages() { } - public static String getString( String key ) - { - - try - { - String result = RESOURCE_BUNDLE.getString( key ); - try - { - result = new String( result.getBytes( "ISO-8859-1" ), "utf-8" ); //$NON-NLS-1$ //$NON-NLS-2$ - } - catch ( UnsupportedEncodingException e ) - { - return '!' + key + '!'; - } - return result; - } - catch ( MissingResourceException e ) - { - return '!' + key + '!'; - } + public static String getString(String key) { + return RESOURCE_BUNDLE.getString(key); } /** * Gets formatted translation for current local * - * @param key - * the key + * @param key the key * @return translated value string */ - public static String getFormattedString( String key, Object[] arguments ) - { - return MessageFormat.format( getString( key ), arguments ); + public static String getFormattedString(String key, Object[] arguments) { + return RESOURCE_BUNDLE.getFormattedString(key, arguments); } + } diff --git a/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/i18n/messages.properties b/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/i18n/messages.properties index 2c9b0906..e341b3c6 100644 --- a/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/i18n/messages.properties +++ b/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/i18n/messages.properties @@ -1,13 +1,10 @@ ############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). +# Copyright (c) 2017 Chen Chao and other ECD project contributors. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation +# https://www.eclipse.org/legal/epl-v10.html ############################################################################### -JDCoreDecompilerDescriptor.PreferenceLabel=JD-Core +JDCoreDecompilerDescriptor.PreferenceLabel=JD-Core (Support JDK12) JavaDecompilerActionBarContributor.Action.DecompileWithJDCore=JD-&Core \ No newline at end of file diff --git a/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/i18n/messages_zh_CN.properties b/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/i18n/messages_zh_CN.properties deleted file mode 100644 index 2c9b0906..00000000 --- a/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/i18n/messages_zh_CN.properties +++ /dev/null @@ -1,13 +0,0 @@ -############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation -############################################################################### - -JDCoreDecompilerDescriptor.PreferenceLabel=JD-Core -JavaDecompilerActionBarContributor.Action.DecompileWithJDCore=JD-&Core \ No newline at end of file diff --git a/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/i18n/messages_zh_HK.properties b/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/i18n/messages_zh_HK.properties deleted file mode 100644 index 2c9b0906..00000000 --- a/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/i18n/messages_zh_HK.properties +++ /dev/null @@ -1,13 +0,0 @@ -############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation -############################################################################### - -JDCoreDecompilerDescriptor.PreferenceLabel=JD-Core -JavaDecompilerActionBarContributor.Action.DecompileWithJDCore=JD-&Core \ No newline at end of file diff --git a/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/i18n/messages_zh_TW.properties b/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/i18n/messages_zh_TW.properties deleted file mode 100644 index 2c9b0906..00000000 --- a/org.sf.feeling.decompiler.jd/src/org/sf/feeling/decompiler/jd/i18n/messages_zh_TW.properties +++ /dev/null @@ -1,13 +0,0 @@ -############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation -############################################################################### - -JDCoreDecompilerDescriptor.PreferenceLabel=JD-Core -JavaDecompilerActionBarContributor.Action.DecompileWithJDCore=JD-&Core \ No newline at end of file diff --git a/org.sf.feeling.decompiler.procyon.feature/.settings/org.eclipse.core.resources.prefs b/org.sf.feeling.decompiler.procyon.feature/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000..4824b802 --- /dev/null +++ b/org.sf.feeling.decompiler.procyon.feature/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/org.sf.feeling.decompiler.procyon.feature/.settings/org.eclipse.core.runtime.prefs b/org.sf.feeling.decompiler.procyon.feature/.settings/org.eclipse.core.runtime.prefs new file mode 100644 index 00000000..f8a67de1 --- /dev/null +++ b/org.sf.feeling.decompiler.procyon.feature/.settings/org.eclipse.core.runtime.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +line.separator=\r\n diff --git a/org.sf.feeling.decompiler.procyon.feature/build.properties b/org.sf.feeling.decompiler.procyon.feature/build.properties index 2ed3f033..40b08e1e 100644 --- a/org.sf.feeling.decompiler.procyon.feature/build.properties +++ b/org.sf.feeling.decompiler.procyon.feature/build.properties @@ -1,6 +1,5 @@ -bin.includes = feature.xml,\ - eclipse_update_120.jpg,\ - epl-v10.html,\ - feature.properties,\ - license.html -qualifier = 20170815 \ No newline at end of file +bin.includes = feature.xml,\ + eclipse_update_120.jpg,\ + epl-v10.html,\ + feature.properties,\ + license.html \ No newline at end of file diff --git a/org.sf.feeling.decompiler.procyon.feature/feature.properties b/org.sf.feeling.decompiler.procyon.feature/feature.properties index f183f59d..c85044c5 100644 --- a/org.sf.feeling.decompiler.procyon.feature/feature.properties +++ b/org.sf.feeling.decompiler.procyon.feature/feature.properties @@ -1,12 +1,9 @@ ############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). +# Copyright (c) 2017 Chen Chao and other ECD project contributors. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation +# https://www.eclipse.org/legal/epl-v10.html ############################################################################### # feature.properties @@ -16,21 +13,21 @@ # This file should be translated. # "featureName" property - name of the feature -featureName=Eclipse Class Decompiler Procyon Extension (Optional) +featureName=Enhanced Class Decompiler Procyon Extension (Optional) # "providerName" property - name of the company that provides the feature -providerName=Chen Chao +providerName=ECD project contributors # "updateSiteName" property - label for the update site -updateSiteName=Eclipse Class Decompiler Updates +updateSiteName=Enhanced Class Decompiler Updates # "description" property - description of the feature -description=Eclipse Class Decompiler integrates JD, Jad, FernFlower, CFR, Procyon with Eclipse seamlessly. \ +description=Enhanced Class Decompiler integrates JD, FernFlower, Vineflower, CFR, Procyon with Eclipse seamlessly. \ It allows Java developers to debug class files without source code directly. -copyrightURL=http://www.cpupk.com/decompiler/update +copyrightURL=https://ecd-plugin.github.io -copyright=(c) Copyright 2017 Chen Chao(cnfree2000@hotmail.com). All rights reserved.\n +copyright=(c) Copyright 2017 Chen Chao and other ECD project contributors. All rights reserved.\n # "licenseURL" property - URL of the "Feature License" # do not translate value - just change to point to a locale-specific HTML page @@ -65,7 +62,7 @@ Applicable Licenses\n\ Unless otherwise indicated, all Content made available by the Eclipse Foundation\n\ is provided to you under the terms and conditions of the Eclipse Public\n\ License Version 1.0 ("EPL"). A copy of the EPL is provided with this\n\ -Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\ +Content and is also available at https://www.eclipse.org/legal/epl-v10.html.\n\ For purposes of the EPL, "Program" will mean the Content.\n\ \n\ Content includes, but is not limited to, source code, object code,\n\ @@ -112,9 +109,9 @@ THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER\n\ TO THE CPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\ SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\ \n\ - - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\ - - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\ - - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\ + - Common Public License Version 1.0 (available at https://www.eclipse.org/legal/cpl-v10.html)\n\ + - Apache Software License 1.1 (available at https://www.apache.org/licenses/LICENSE.txt)\n\ + - Apache Software License 2.0 (available at https://www.apache.org/licenses/LICENSE-2.0.html)\n\ - IBM Public License 1.0 (available at http://oss.software.ibm.com/developerworks/opensource/license10.html)\n\ - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\ - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\ @@ -132,4 +129,4 @@ and/or re-export to another country, of encryption software. BEFORE\n\ using any encryption software, please check the country's laws,\n\ regulations and policies concerning the import, possession, or use,\n\ and re-export of encryption software, to see if this is permitted.\n -########### end of license property ########################################## \ No newline at end of file +########### end of license property ########################################## diff --git a/org.sf.feeling.decompiler.procyon.feature/feature.xml b/org.sf.feeling.decompiler.procyon.feature/feature.xml index 851e59e0..5e34dd14 100644 --- a/org.sf.feeling.decompiler.procyon.feature/feature.xml +++ b/org.sf.feeling.decompiler.procyon.feature/feature.xml @@ -2,7 +2,7 @@ @@ -19,8 +19,8 @@ - - + + @@ -39,14 +39,15 @@ - + + diff --git a/org.sf.feeling.decompiler.procyon.feature/license.html b/org.sf.feeling.decompiler.procyon.feature/license.html index e2323dfc..db78f42e 100644 --- a/org.sf.feeling.decompiler.procyon.feature/license.html +++ b/org.sf.feeling.decompiler.procyon.feature/license.html @@ -21,7 +21,7 @@

    Usage Of Content

    Applicable Licenses

    Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0 - ("EPL"). A copy of the EPL is provided with this Content and is also available at http://www.eclipse.org/legal/epl-v10.html. + ("EPL"). A copy of the EPL is provided with this Content and is also available at https://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, "Program" will mean the Content.

    Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse.org CVS repository ("Repository") in CVS @@ -53,9 +53,9 @@

    Applicable Licenses

    OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):

      -
    • Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)
    • -
    • Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)
    • -
    • Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)
    • +
    • Common Public License Version 1.0 (available at https://www.eclipse.org/legal/cpl-v10.html)
    • +
    • Apache Software License 1.1 (available at https://www.apache.org/licenses/LICENSE.txt)
    • +
    • Apache Software License 2.0 (available at https://www.apache.org/licenses/LICENSE-2.0.html)
    • IBM Public License 1.0 (available at http://oss.software.ibm.com/developerworks/opensource/license10.html)
    • Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)
    • Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)
    • diff --git a/org.sf.feeling.decompiler.procyon.feature/pom.xml b/org.sf.feeling.decompiler.procyon.feature/pom.xml new file mode 100644 index 00000000..40d5af81 --- /dev/null +++ b/org.sf.feeling.decompiler.procyon.feature/pom.xml @@ -0,0 +1,15 @@ + + 4.0.0 + + + com.github.ecd-plugin + com.github.ecd-plugin.ecd + 3.5.1 + ../pom.xml + + + com.github.ecd-plugin.features + org.sf.feeling.decompiler.procyon + eclipse-feature + diff --git a/org.sf.feeling.decompiler.procyon/.classpath b/org.sf.feeling.decompiler.procyon/.classpath index 51f9410b..3933ccb4 100644 --- a/org.sf.feeling.decompiler.procyon/.classpath +++ b/org.sf.feeling.decompiler.procyon/.classpath @@ -1,8 +1,13 @@ - - - - - - - - + + + + + + + + + + + + + diff --git a/org.sf.feeling.decompiler.procyon/.gitignore b/org.sf.feeling.decompiler.procyon/.gitignore deleted file mode 100644 index ae3c1726..00000000 --- a/org.sf.feeling.decompiler.procyon/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin/ diff --git a/org.sf.feeling.decompiler.procyon/.project b/org.sf.feeling.decompiler.procyon/.project index ba47c6af..c90dee6d 100644 --- a/org.sf.feeling.decompiler.procyon/.project +++ b/org.sf.feeling.decompiler.procyon/.project @@ -20,8 +20,14 @@ + + org.eclipse.m2e.core.maven2Builder + + + + org.eclipse.m2e.core.maven2Nature org.eclipse.pde.PluginNature org.eclipse.jdt.core.javanature diff --git a/org.sf.feeling.decompiler.procyon/.settings/org.eclipse.core.resources.prefs b/org.sf.feeling.decompiler.procyon/.settings/org.eclipse.core.resources.prefs index f6a920c1..4824b802 100644 --- a/org.sf.feeling.decompiler.procyon/.settings/org.eclipse.core.resources.prefs +++ b/org.sf.feeling.decompiler.procyon/.settings/org.eclipse.core.resources.prefs @@ -1,4 +1,2 @@ eclipse.preferences.version=1 -encoding//src/org/sf/feeling/decompiler/procyon/i18n/messages_zh_CN.properties=UTF-8 -encoding//src/org/sf/feeling/decompiler/procyon/i18n/messages_zh_HK.properties=UTF-8 -encoding//src/org/sf/feeling/decompiler/procyon/i18n/messages_zh_TW.properties=UTF-8 +encoding/=UTF-8 diff --git a/org.sf.feeling.decompiler.procyon/.settings/org.eclipse.core.runtime.prefs b/org.sf.feeling.decompiler.procyon/.settings/org.eclipse.core.runtime.prefs new file mode 100644 index 00000000..f8a67de1 --- /dev/null +++ b/org.sf.feeling.decompiler.procyon/.settings/org.eclipse.core.runtime.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +line.separator=\r\n diff --git a/org.sf.feeling.decompiler.procyon/.settings/org.eclipse.jdt.core.prefs b/org.sf.feeling.decompiler.procyon/.settings/org.eclipse.jdt.core.prefs index 36413b06..dd8b8ec2 100644 --- a/org.sf.feeling.decompiler.procyon/.settings/org.eclipse.jdt.core.prefs +++ b/org.sf.feeling.decompiler.procyon/.settings/org.eclipse.jdt.core.prefs @@ -1,11 +1,7 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.autoboxing=ignore @@ -78,4 +74,391 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false +org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false +org.eclipse.jdt.core.formatter.align_with_spaces=false +org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_enum_constant=49 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field=49 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable=49 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_method=49 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package=49 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter=0 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type=49 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assertion_message=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain=0 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0 +org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_module_statements=16 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_record_components=16 +org.eclipse.jdt.core.formatter.alignment_for_relational_operator=0 +org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_shift_operator=0 +org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_record_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_type_annotations=0 +org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0 +org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0 +org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_last_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_abstract_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_statement_group_in_switch=0 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_record_constructor=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_record_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped=true +org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false +org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=true +org.eclipse.jdt.core.formatter.comment.format_block_comments=true +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true +org.eclipse.jdt.core.formatter.comment.format_line_comments=true +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=false +org.eclipse.jdt.core.formatter.comment.indent_root_tags=false +org.eclipse.jdt.core.formatter.comment.indent_tag_description=false +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_between_different_tags=do not insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert +org.eclipse.jdt.core.formatter.comment.line_length=80 +org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true +org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true +org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false +org.eclipse.jdt.core.formatter.compact_else_if=true +org.eclipse.jdt.core.formatter.continuation_indentation=2 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 +org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=false +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_record_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false +org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_default=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_record_components=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_switch_case_expressions=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_not_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_record_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert +org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_case=insert +org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_default=insert +org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_record_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_record_components=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_switch_case_expressions=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_constructor=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_record_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=true +org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_code_block_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_method_body_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_record_constructor_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_record_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line=false +org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.lineSplit=120 +org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false +org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false +org.eclipse.jdt.core.formatter.number_of_blank_lines_after_code_block=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_code_block=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_code_block=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_before_code_block=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 +org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_record_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true +org.eclipse.jdt.core.formatter.tabulation.char=tab +org.eclipse.jdt.core.formatter.tabulation.size=4 +org.eclipse.jdt.core.formatter.text_block_indentation=0 +org.eclipse.jdt.core.formatter.use_on_off_tags=true +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true +org.eclipse.jdt.core.formatter.wrap_before_assertion_message_operator=true +org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false +org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true +org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true +org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true +org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true +org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_before_relational_operator=true +org.eclipse.jdt.core.formatter.wrap_before_shift_operator=true +org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true +org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter diff --git a/org.sf.feeling.decompiler.procyon/.settings/org.eclipse.jdt.ui.prefs b/org.sf.feeling.decompiler.procyon/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 00000000..9a4e91e5 --- /dev/null +++ b/org.sf.feeling.decompiler.procyon/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,106 @@ +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +formatter_profile=org.eclipse.jdt.ui.default.eclipse_profile +formatter_settings_version=20 +sp_cleanup.add_all=false +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.arrays_fill=false +sp_cleanup.bitwise_conditional_expression=false +sp_cleanup.boolean_literal=false +sp_cleanup.break_loop=false +sp_cleanup.collection_cloning=false +sp_cleanup.comparison_statement=false +sp_cleanup.convert_functional_interfaces=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.convert_to_enhanced_for_loop_if_loop_var_used=false +sp_cleanup.convert_to_switch_expressions=false +sp_cleanup.correct_indentation=false +sp_cleanup.double_negation=false +sp_cleanup.else_if=false +sp_cleanup.embedded_if=false +sp_cleanup.evaluate_nullable=false +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=false +sp_cleanup.hash=false +sp_cleanup.if_condition=false +sp_cleanup.insert_inferred_type_arguments=false +sp_cleanup.instanceof=false +sp_cleanup.join=false +sp_cleanup.lazy_logical_operator=false +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=true +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=false +sp_cleanup.map_cloning=false +sp_cleanup.merge_conditional_blocks=false +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.no_string_creation=false +sp_cleanup.no_super=false +sp_cleanup.number_suffix=false +sp_cleanup.objects_equals=false +sp_cleanup.on_save_use_additional_actions=false +sp_cleanup.organize_imports=true +sp_cleanup.overridden_assignment=false +sp_cleanup.precompile_regex=false +sp_cleanup.primitive_serialization=false +sp_cleanup.pull_up_assignment=false +sp_cleanup.push_down_negation=false +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=false +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.redundant_falling_through_block_end=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_redundant_modifiers=false +sp_cleanup.remove_redundant_semicolons=false +sp_cleanup.remove_redundant_type_arguments=false +sp_cleanup.remove_trailing_whitespaces=false +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_array_creation=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=false +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.simplify_lambda_expression_and_method_ref=false +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.strictly_equal_or_different=false +sp_cleanup.stringbuilder=false +sp_cleanup.switch=false +sp_cleanup.ternary_operator=false +sp_cleanup.try_with_resource=false +sp_cleanup.use_anonymous_class_creation=false +sp_cleanup.use_autoboxing=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_directly_map_method=false +sp_cleanup.use_lambda=true +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=false +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true +sp_cleanup.use_unboxing=false +sp_cleanup.use_var=false +sp_cleanup.useless_continue=false +sp_cleanup.useless_return=false diff --git a/org.sf.feeling.decompiler.procyon/.settings/org.eclipse.m2e.core.prefs b/org.sf.feeling.decompiler.procyon/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 00000000..f897a7f1 --- /dev/null +++ b/org.sf.feeling.decompiler.procyon/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/org.sf.feeling.decompiler.procyon/META-INF/MANIFEST.MF b/org.sf.feeling.decompiler.procyon/META-INF/MANIFEST.MF index 00be0900..395a349e 100644 --- a/org.sf.feeling.decompiler.procyon/META-INF/MANIFEST.MF +++ b/org.sf.feeling.decompiler.procyon/META-INF/MANIFEST.MF @@ -1,11 +1,11 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 -Bundle-Name: Eclipse Class Decompiler Procyon Extension +Bundle-Name: Enhanced Class Decompiler Procyon Extension Bundle-SymbolicName: org.sf.feeling.decompiler.procyon;singleton:=true -Bundle-Version: 2.10.0.qualifier +Bundle-Version: 3.5.1 Bundle-Activator: org.sf.feeling.decompiler.procyon.ProcyonDecompilerPlugin Require-Bundle: org.eclipse.core.runtime, - org.sf.feeling.decompiler, + org.sf.feeling.decompiler;bundle-version="3.2.2", org.eclipse.core.resources, org.eclipse.jface, org.eclipse.jface.text, @@ -20,11 +20,13 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.core.expressions, org.eclipse.ui.navigator, org.eclipse.ui.ide;resolution:=optional, - org.eclipse.core.filesystem -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 + org.eclipse.core.filesystem, + org.apache.commons.lang3;bundle-version="3.1.0" +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ActivationPolicy: lazy -Bundle-Vendor: Chen Chao +Bundle-Vendor: ECD Project Team Export-Package: org.sf.feeling.decompiler.procyon.actions, org.sf.feeling.decompiler.procyon.decompiler -Bundle-ClassPath: lib/procyon.jar, +Bundle-ClassPath: lib/procyon-core.jar, + lib/procyon-compilertools.jar, . diff --git a/org.sf.feeling.decompiler.procyon/build.properties b/org.sf.feeling.decompiler.procyon/build.properties index 454bb06a..4bc80c66 100644 --- a/org.sf.feeling.decompiler.procyon/build.properties +++ b/org.sf.feeling.decompiler.procyon/build.properties @@ -2,7 +2,7 @@ source.. = src/ output.. = bin/ bin.includes = META-INF/,\ .,\ - lib/,\ icons/,\ - plugin.xml -qualifier = 20170815 \ No newline at end of file + plugin.xml,\ + lib/procyon-compilertools.jar,\ + lib/procyon-core.jar diff --git a/org.sf.feeling.decompiler.procyon/lib/.gitignore b/org.sf.feeling.decompiler.procyon/lib/.gitignore new file mode 100644 index 00000000..3593ddb0 --- /dev/null +++ b/org.sf.feeling.decompiler.procyon/lib/.gitignore @@ -0,0 +1,2 @@ +/procyon-core.jar +/procyon-compilertools.jar diff --git a/org.sf.feeling.decompiler.procyon/lib/procyon.jar b/org.sf.feeling.decompiler.procyon/lib/procyon.jar deleted file mode 100644 index 51253e97..00000000 Binary files a/org.sf.feeling.decompiler.procyon/lib/procyon.jar and /dev/null differ diff --git a/org.sf.feeling.decompiler.procyon/plugin.xml b/org.sf.feeling.decompiler.procyon/plugin.xml index fbe129a7..1224007a 100644 --- a/org.sf.feeling.decompiler.procyon/plugin.xml +++ b/org.sf.feeling.decompiler.procyon/plugin.xml @@ -1,14 +1,11 @@ diff --git a/org.sf.feeling.decompiler.procyon/pom.xml b/org.sf.feeling.decompiler.procyon/pom.xml new file mode 100644 index 00000000..f6c77a5b --- /dev/null +++ b/org.sf.feeling.decompiler.procyon/pom.xml @@ -0,0 +1,57 @@ + + 4.0.0 + + + com.github.ecd-plugin + com.github.ecd-plugin.ecd + 3.5.1 + ../pom.xml + + + org.sf.feeling.decompiler.procyon + eclipse-plugin + + + 0.6.0 + + + + + org.apache.maven.plugins + maven-dependency-plugin + ${maven.dependency.plugin.version} + + + copy-libraries + validate + + copy + + + + + org.bitbucket.mstrobel + procyon-core + ${procyon.version} + procyon-core.jar + + + org.bitbucket.mstrobel + procyon-compilertools + ${procyon.version} + procyon-compilertools.jar + + + lib + true + true + + + + + + + + diff --git a/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/ProcyonDecompilerPlugin.java b/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/ProcyonDecompilerPlugin.java index d7879f51..8f702fa0 100644 --- a/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/ProcyonDecompilerPlugin.java +++ b/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/ProcyonDecompilerPlugin.java @@ -12,13 +12,16 @@ import org.osgi.framework.BundleContext; import org.sf.feeling.decompiler.JavaDecompilerPlugin; -public class ProcyonDecompilerPlugin extends AbstractUIPlugin implements IPropertyChangeListener -{ +import com.strobel.Procyon; + +public class ProcyonDecompilerPlugin extends AbstractUIPlugin implements IPropertyChangeListener { public static final String PLUGIN_ID = "org.sf.feeling.decompiler.procyon"; //$NON-NLS-1$ public static final String decompilerType = "Procyon"; //$NON-NLS-1$ + public static final String decompilerVersion = Procyon.version(); + private static ProcyonDecompilerPlugin plugin; private IPreferenceStore preferenceStore; @@ -27,14 +30,12 @@ public class ProcyonDecompilerPlugin extends AbstractUIPlugin implements IProper * (non-Javadoc) * * @see - * org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext - * ) + * org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext ) */ @Override - public void start( BundleContext context ) throws Exception - { - super.start( context ); - getPreferenceStore( ).addPropertyChangeListener( this ); + public void start(BundleContext context) throws Exception { + super.start(context); + getPreferenceStore().addPropertyChangeListener(this); } /* @@ -44,54 +45,45 @@ public void start( BundleContext context ) throws Exception * org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) */ @Override - public void stop( BundleContext context ) throws Exception - { - super.stop( context ); - getPreferenceStore( ).removePropertyChangeListener( this ); + public void stop(BundleContext context) throws Exception { + super.stop(context); + getPreferenceStore().removePropertyChangeListener(this); plugin = null; } @Override - public void propertyChange( PropertyChangeEvent event ) - { + public void propertyChange(PropertyChangeEvent event) { } @Override - public IPreferenceStore getPreferenceStore( ) - { - if ( preferenceStore == null ) - { - preferenceStore = JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ); + public IPreferenceStore getPreferenceStore() { + if (preferenceStore == null) { + preferenceStore = JavaDecompilerPlugin.getDefault().getPreferenceStore(); } return preferenceStore; } - public static ProcyonDecompilerPlugin getDefault( ) - { + public static ProcyonDecompilerPlugin getDefault() { return plugin; } - public ProcyonDecompilerPlugin( ) - { + public ProcyonDecompilerPlugin() { plugin = this; } - public static ImageDescriptor getImageDescriptor( String path ) - { - URL base = ProcyonDecompilerPlugin.getDefault( ).getBundle( ).getEntry( "/" ); //$NON-NLS-1$ + public static ImageDescriptor getImageDescriptor(String path) { + URL base = ProcyonDecompilerPlugin.getDefault().getBundle().getEntry("/"); //$NON-NLS-1$ URL url = null; - try - { - url = new URL( base, path ); // $NON-NLS-1$ - } - catch ( MalformedURLException e ) - { - e.printStackTrace( ); + try { + url = new URL(base, path); // $NON-NLS-1$ + } catch (MalformedURLException e) { + e.printStackTrace(); } ImageDescriptor actionIcon = null; - if ( url != null ) - actionIcon = ImageDescriptor.createFromURL( url ); + if (url != null) { + actionIcon = ImageDescriptor.createFromURL(url); + } return actionIcon; } diff --git a/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/actions/DecompileWithProcyonAction.java b/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/actions/DecompileWithProcyonAction.java index 8c2c05af..a46adc59 100644 --- a/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/actions/DecompileWithProcyonAction.java +++ b/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/actions/DecompileWithProcyonAction.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.procyon.actions; @@ -17,30 +14,23 @@ import org.sf.feeling.decompiler.procyon.i18n.Messages; import org.sf.feeling.decompiler.util.UIUtil; -public class DecompileWithProcyonAction extends Action -{ +public class DecompileWithProcyonAction extends Action { - public DecompileWithProcyonAction( ) - { - super( Messages.getString( "JavaDecompilerActionBarContributor.Action.DecompileWithProcyon" ) ); //$NON-NLS-1$ - this.setImageDescriptor( ProcyonDecompilerPlugin.getImageDescriptor( "icons/procyon_16.png" ) ); //$NON-NLS-1$ + public DecompileWithProcyonAction() { + super(Messages.getString("JavaDecompilerActionBarContributor.Action.DecompileWithProcyon")); //$NON-NLS-1$ + this.setImageDescriptor(ProcyonDecompilerPlugin.getImageDescriptor("icons/procyon_16.png")); //$NON-NLS-1$ } @Override - public void run( ) - { - try - { - new DecompileWithProcyonHandler( ).execute( null ); - } - catch ( ExecutionException e ) - { + public void run() { + try { + new DecompileWithProcyonHandler().execute(null); + } catch (ExecutionException e) { } } @Override - public boolean isEnabled( ) - { - return UIUtil.getActiveEditor( ) != null || UIUtil.getActiveSelection( ) != null; + public boolean isEnabled() { + return UIUtil.getActiveEditor() != null || UIUtil.getActiveSelection() != null; } } \ No newline at end of file diff --git a/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/actions/DecompileWithProcyonHandler.java b/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/actions/DecompileWithProcyonHandler.java index 97921a1c..827a87e1 100644 --- a/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/actions/DecompileWithProcyonHandler.java +++ b/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/actions/DecompileWithProcyonHandler.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.procyon.actions; @@ -16,12 +13,10 @@ import org.sf.feeling.decompiler.actions.BaseDecompilerHandler; import org.sf.feeling.decompiler.procyon.ProcyonDecompilerPlugin; -public class DecompileWithProcyonHandler extends BaseDecompilerHandler -{ +public class DecompileWithProcyonHandler extends BaseDecompilerHandler { @Override - public Object execute( ExecutionEvent event ) throws ExecutionException - { - return handleDecompile( ProcyonDecompilerPlugin.decompilerType ); + public Object execute(ExecutionEvent event) throws ExecutionException { + return handleDecompile(ProcyonDecompilerPlugin.decompilerType); } } diff --git a/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/decompiler/LineNumberFormatter.java b/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/decompiler/LineNumberFormatter.java new file mode 100644 index 00000000..afb76035 --- /dev/null +++ b/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/decompiler/LineNumberFormatter.java @@ -0,0 +1,244 @@ +/** + * Apache License + * Version 2.0, January 2004 + * https://www.apache.org/licenses/ + * + * Copied from package com.strobel.decompiler; + * + * Modified by Jan Peter Stotz + */ + +package org.sf.feeling.decompiler.procyon.decompiler; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.io.StringWriter; +import java.io.Writer; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.EnumSet; +import java.util.Iterator; +import java.util.List; + +import com.strobel.decompiler.languages.LineNumberPosition; + +/** + * A LineNumberFormatter is used to rewrite an existing .java file, + * introducing line number information. It can handle either, or both, of the + * following jobs: + * + *
        + *
      • Introduce line numbers as leading comments. + *
      • Stretch the file so that the line number comments match the physical + * lines. + *
      + */ +public class LineNumberFormatter { + private final List _positions; + private final File _file; + private final EnumSet _options; + + public enum LineNumberOption { + LEADING_COMMENTS, STRETCHED, + } + + /** + * Constructs an instance. + * + * @param file the file whose line numbers should be fixed + * @param lineNumberPositions a recipe for how to fix the line numbers in + * 'file'. + * @param options controls how 'this' represents line numbers in the + * resulting file + */ + public LineNumberFormatter(File file, List lineNumberPositions, + EnumSet options) { + _file = file; + _positions = lineNumberPositions; + _options = (options == null ? EnumSet.noneOf(LineNumberOption.class) : options); + } + + /** + * Rewrites the file passed to 'this' constructor so that the actual line + * numbers match the recipe passed to 'this' constructor. + * + * @return The formatted source code + */ + public String reformatFile() throws IOException { + List lineBrokenPositions = new ArrayList<>(); + List brokenLines = breakLines(lineBrokenPositions); + try (StringWriter sw = new StringWriter()) { + emitFormatted(brokenLines, lineBrokenPositions, sw); + return sw.toString(); + } + } + + /** + * Processes {@link #_file}, breaking apart any lines on which multiple + * line-number markers appear in different columns. + * + * @return the list of broken lines + */ + private List breakLines(List o_LineBrokenPositions) throws IOException { + int numLinesRead = 0; + int lineOffset = 0; + List brokenLines = new ArrayList<>(); + + try (BufferedReader r = new BufferedReader(new FileReader(_file))) { + for (int posIndex = 0; posIndex < _positions.size(); posIndex++) { + LineNumberPosition pos = _positions.get(posIndex); + o_LineBrokenPositions.add(new LineNumberPosition(pos.getOriginalLine(), + pos.getEmittedLine() + lineOffset, pos.getEmittedColumn())); + + // Copy the input file up to but not including the emitted line # in "pos". + while (numLinesRead < pos.getEmittedLine() - 1) { + brokenLines.add(r.readLine()); + numLinesRead++; + } + + // Read the line that contains the next line number annotations, but don't write + // it yet. + String line = r.readLine(); + numLinesRead++; + + // See if there are two original line annotations on the same emitted line. + LineNumberPosition nextPos; + int prevPartLen = 0; + char[] indent = {}; + do { + nextPos = (posIndex < _positions.size() - 1) ? _positions.get(posIndex + 1) : null; + if (nextPos != null && nextPos.getEmittedLine() == pos.getEmittedLine() + && nextPos.getOriginalLine() > pos.getOriginalLine()) { + // Two different source line numbers on the same emitted line! + posIndex++; + lineOffset++; + String firstPart = line.substring(0, nextPos.getEmittedColumn() - prevPartLen - 1); + brokenLines.add(new String(indent) + firstPart); + prevPartLen += firstPart.length(); + indent = new char[prevPartLen]; + Arrays.fill(indent, ' '); + line = line.substring(firstPart.length(), line.length()); + + // Alter the position while adding it. + o_LineBrokenPositions.add(new LineNumberPosition(nextPos.getOriginalLine(), + nextPos.getEmittedLine() + lineOffset, nextPos.getEmittedColumn())); + } else { + nextPos = null; + } + } while (nextPos != null); + + // Nothing special here-- just emit the line. + brokenLines.add(new String(indent) + line); + } + + // Copy out the remainder of the file. + String line; + while ((line = r.readLine()) != null) { + brokenLines.add(line); + } + } + return brokenLines; + } + + private void emitFormatted(List brokenLines, List lineBrokenPositions, Writer writer) + throws IOException { + File tempFile = new File(_file.getAbsolutePath() + ".fixed"); + int globalOffset = 0; + int numLinesRead = 0; + Iterator lines = brokenLines.iterator(); + + int maxLineNo = LineNumberPosition.computeMaxLineNumber(lineBrokenPositions); + try (LineNumberPrintWriter w = new LineNumberPrintWriter(maxLineNo, writer)) { + + // Suppress all line numbers if we weren't asked to show them. + if (!_options.contains(LineNumberOption.LEADING_COMMENTS)) { + w.suppressLineNumbers(); + } + + // Suppress stretching if we weren't asked to do it. + boolean doStretching = (_options.contains(LineNumberOption.STRETCHED)); + + for (LineNumberPosition pos : lineBrokenPositions) { + int nextTarget = pos.getOriginalLine(); + int nextActual = pos.getEmittedLine(); + int requiredAdjustment = (nextTarget - nextActual - globalOffset); + + if (doStretching && requiredAdjustment < 0) { + // We currently need to remove newlines to squeeze things together. + // prefer to remove empty lines, + // 1. read all lines before nextActual and remove empty lines as needed + List stripped = new ArrayList<>(); + while (numLinesRead < nextActual - 1) { + String line = lines.next(); + numLinesRead++; + if ((requiredAdjustment < 0) && line.trim().isEmpty()) { + requiredAdjustment++; + globalOffset--; + } else { + stripped.add(line); + } + } + // 2. print non empty lines while stripping further as needed + int lineNoToPrint = (stripped.size() + requiredAdjustment <= 0) ? nextTarget + : LineNumberPrintWriter.NO_LINE_NUMBER; + for (String line : stripped) { + if (requiredAdjustment < 0) { + w.print(lineNoToPrint, line); + w.print(" "); + requiredAdjustment++; + globalOffset--; + } else { + w.println(lineNoToPrint, line); + } + } + // 3. read and print next actual + String line = lines.next(); + numLinesRead++; + if (requiredAdjustment < 0) { + w.print(nextTarget, line); + w.print(" "); + globalOffset--; + } else { + w.println(nextTarget, line); + } + + } else { + while (numLinesRead < nextActual) { + String line = lines.next(); + numLinesRead++; + boolean isLast = (numLinesRead >= nextActual); + int lineNoToPrint = isLast ? nextTarget : LineNumberPrintWriter.NO_LINE_NUMBER; + + if (requiredAdjustment > 0 && doStretching) { + // We currently need to inject newlines to space things out. + do { + w.println(""); + requiredAdjustment--; + globalOffset++; + } while (isLast && requiredAdjustment > 0); + w.println(lineNoToPrint, line); + } else { + // No tweaks needed-- we are on the ball. + w.println(lineNoToPrint, line); + } + } + } + } + + // Finish out the file. + String line; + while (lines.hasNext()) { + line = lines.next(); + w.println(line); + } + } + + // Delete the original file and rename the formatted temp file over the + // original. + _file.delete(); + tempFile.renameTo(_file); + } + +} diff --git a/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/decompiler/LineNumberPrintWriter.java b/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/decompiler/LineNumberPrintWriter.java new file mode 100644 index 00000000..62f6296e --- /dev/null +++ b/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/decompiler/LineNumberPrintWriter.java @@ -0,0 +1,87 @@ +/** + * Apache License + * Version 2.0, January 2004 + * https://www.apache.org/licenses/ + * + * Copied from package com.strobel.decompiler; + */ + +package org.sf.feeling.decompiler.procyon.decompiler; + +import java.io.PrintWriter; +import java.io.Writer; +import java.util.Arrays; + +/** + * A specialization of {@link PrintWriter} which can automatically prefix lines + * with a Java-commented, justified line number. This class overrides only the + * {@link #print(String)} and {@link #println(String)} methods, therefore all + * other methods must be avoided. + */ +class LineNumberPrintWriter extends PrintWriter { + public static final int NO_LINE_NUMBER = -1; + private final String _emptyPrefix; + private final String _format; + private boolean _needsPrefix; + private boolean _suppressLineNumbers; + + /** + * Creates an instance. The only valid "print" methods to call are + * {@link #print(String)} and {@link #println(String)}. + * + * @param maxLineNo the highest line number that 'this' will ever encounter + * @param w the underlying {@link Writer} to which characters are + * printed. + */ + public LineNumberPrintWriter(int maxLineNo, Writer w) { + super(w); + String maxNumberString = String.format("%d", maxLineNo); + int numberWidth = maxNumberString.length(); + _format = "/*%" + numberWidth + "d*/"; + String samplePrefix = String.format(_format, maxLineNo); + char[] prefixChars = samplePrefix.toCharArray(); + Arrays.fill(prefixChars, ' '); + _emptyPrefix = new String(prefixChars); + _needsPrefix = true; + } + + /** + * Causes 'this' printer to not emit any line numbers or any whitespace padding. + */ + public void suppressLineNumbers() { + _suppressLineNumbers = true; + } + + @Override + public void print(String s) { + this.print(NO_LINE_NUMBER, s); + } + + @Override + public void println(String s) { + this.println(NO_LINE_NUMBER, s); + } + + public void println(int lineNumber, String s) { + this.doPrefix(lineNumber); + super.println(s); + _needsPrefix = true; + } + + public void print(int lineNumber, String s) { + this.doPrefix(lineNumber); + super.print(s); + } + + private void doPrefix(int lineNumber) { + if (_needsPrefix && !_suppressLineNumbers) { + if (lineNumber == NO_LINE_NUMBER) { + super.print(_emptyPrefix); + } else { + String prefix = String.format(_format, lineNumber); + super.print(prefix); + } + } + _needsPrefix = false; + } +} \ No newline at end of file diff --git a/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/decompiler/NoRetryMetadataSystem.java b/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/decompiler/NoRetryMetadataSystem.java index 81c29b04..605480f2 100644 --- a/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/decompiler/NoRetryMetadataSystem.java +++ b/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/decompiler/NoRetryMetadataSystem.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.procyon.decompiler; @@ -18,36 +15,25 @@ import com.strobel.assembler.metadata.MetadataSystem; import com.strobel.assembler.metadata.TypeDefinition; -public final class NoRetryMetadataSystem extends MetadataSystem -{ +public final class NoRetryMetadataSystem extends MetadataSystem { - private final Set _failedTypes = new HashSet( ); + private final Set _failedTypes = new HashSet<>(); - public NoRetryMetadataSystem( ) - { + public NoRetryMetadataSystem() { } - public NoRetryMetadataSystem( String classPath ) - { - super( classPath ); - } - - public NoRetryMetadataSystem( ITypeLoader typeLoader ) - { - super( typeLoader ); + public NoRetryMetadataSystem(ITypeLoader typeLoader) { + super(typeLoader); } @Override - protected TypeDefinition resolveType( String descriptor, boolean mightBePrimitive ) - { - if ( this._failedTypes.contains( descriptor ) ) - { + protected TypeDefinition resolveType(String descriptor, boolean mightBePrimitive) { + if (this._failedTypes.contains(descriptor)) { return null; } - TypeDefinition result = super.resolveType( descriptor, mightBePrimitive ); - if ( result == null ) - { - this._failedTypes.add( descriptor ); + TypeDefinition result = super.resolveType(descriptor, mightBePrimitive); + if (result == null) { + this._failedTypes.add(descriptor); } return result; } 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 40535a17..05d7fd9b 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 @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.procyon.decompiler; @@ -17,18 +14,22 @@ import java.io.IOException; import java.io.OutputStreamWriter; import java.io.Writer; -import java.util.Collections; import java.util.EnumSet; import java.util.List; -import java.util.regex.Matcher; -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; +import org.sf.feeling.decompiler.editor.LineNumberOutputType; import org.sf.feeling.decompiler.procyon.ProcyonDecompilerPlugin; +import org.sf.feeling.decompiler.procyon.decompiler.LineNumberFormatter.LineNumberOption; import org.sf.feeling.decompiler.util.ClassUtil; +import org.sf.feeling.decompiler.util.CommentUtil; import org.sf.feeling.decompiler.util.FileUtil; import org.sf.feeling.decompiler.util.JarClassExtractor; +import org.sf.feeling.decompiler.util.Logger; import org.sf.feeling.decompiler.util.UnicodeUtil; import com.strobel.assembler.metadata.DeobfuscationUtilities; @@ -37,206 +38,151 @@ import com.strobel.assembler.metadata.TypeReference; import com.strobel.decompiler.DecompilationOptions; import com.strobel.decompiler.DecompilerSettings; -import com.strobel.decompiler.LineNumberFormatter; import com.strobel.decompiler.PlainTextOutput; +import com.strobel.decompiler.languages.Language; +import com.strobel.decompiler.languages.LineNumberPosition; import com.strobel.decompiler.languages.TypeDecompilationResults; -public class ProcyonDecompiler implements IDecompiler -{ +public class ProcyonDecompiler extends BaseDecompiler { private String source = ""; // $NON-NLS-1$ //$NON-NLS-1$ - private long time, start; + private long time; private String log = ""; //$NON-NLS-1$ /** - * Performs a Runtime.exec() on jad executable with selected - * options. - * * @see IDecompiler#decompile(String, String, String) */ @Override - public void decompile( String root, String packege, String className ) - { - start = System.currentTimeMillis( ); + public void decompile(String root, String packege, String className) { + StopWatch stopWatch = new StopWatch(); + stopWatch.start(); log = ""; //$NON-NLS-1$ source = ""; //$NON-NLS-1$ - File workingDir = new File( root + "/" + packege ); //$NON-NLS-1$ + File workingDir = new File(root + "/" + packege); //$NON-NLS-1$ - final String classPathStr = new File( workingDir, className ).getAbsolutePath( ); + final String classPathStr = new File(workingDir, className).getAbsolutePath(); boolean includeLineNumbers = false; boolean stretchLines = false; - if ( ClassUtil.isDebug( ) ) - { + if (ClassUtil.isDebug()) { includeLineNumbers = true; stretchLines = true; } - DecompilationOptions decompilationOptions = new DecompilationOptions( ); + DecompilationOptions decompilationOptions = new DecompilationOptions(); - DecompilerSettings settings = DecompilerSettings.javaDefaults( ); - settings.setTypeLoader( new com.strobel.assembler.InputTypeLoader( ) ); - settings.setForceExplicitImports( true ); + DecompilerSettings settings = DecompilerSettings.javaDefaults(); + settings.setTypeLoader(new com.strobel.assembler.InputTypeLoader()); + settings.setForceExplicitImports(true); - decompilationOptions.setSettings( settings ); - decompilationOptions.setFullDecompilation( true ); + decompilationOptions.setSettings(settings); + decompilationOptions.setFullDecompilation(true); - MetadataSystem metadataSystem = new NoRetryMetadataSystem( - decompilationOptions.getSettings( ).getTypeLoader( ) ); - metadataSystem.setEagerMethodLoadingEnabled( false ); + MetadataSystem metadataSystem = new NoRetryMetadataSystem(decompilationOptions.getSettings().getTypeLoader()); + metadataSystem.setEagerMethodLoadingEnabled(false); - TypeReference type = metadataSystem.lookupType( classPathStr ); + TypeReference type = metadataSystem.lookupType(classPathStr); TypeDefinition resolvedType; - if ( ( type == null ) || ( ( resolvedType = type.resolve( ) ) == null ) ) - { - System.err.printf( "!!! ERROR: Failed to load class %s.\n", //$NON-NLS-1$ - new Object[]{ - classPathStr - } ); + if ((type == null) || ((resolvedType = type.resolve()) == null)) { + System.err.printf("!!! ERROR: Failed to load class %s.\n", //$NON-NLS-1$ + new Object[] { classPathStr }); return; } - DeobfuscationUtilities.processType( resolvedType ); + DeobfuscationUtilities.processType(resolvedType); String property = "java.io.tmpdir"; //$NON-NLS-1$ - String tempDir = System.getProperty( property ); - File classFile = new File( tempDir, System.currentTimeMillis( ) + className ); - Writer writer = null; - try - { - writer = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( classFile ) ) ); - - PlainTextOutput output = new PlainTextOutput( writer ); + String tempDir = System.getProperty(property); + File classFile = new File(tempDir, System.currentTimeMillis() + className); + try { + TypeDecompilationResults results; + try (Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(classFile)))) { - output.setUnicodeOutputEnabled( decompilationOptions.getSettings( ).isUnicodeOutputEnabled( ) ); + PlainTextOutput output = new PlainTextOutput(writer); - TypeDecompilationResults results = decompilationOptions.getSettings( ) - .getLanguage( ) - .decompileType( resolvedType, output, decompilationOptions ); + output.setUnicodeOutputEnabled(decompilationOptions.getSettings().isUnicodeOutputEnabled()); - writer.flush( ); - writer.close( ); + Language lang = decompilationOptions.getSettings().getLanguage(); - writer = null; + // perform the actual decompilation + results = lang.decompileType(resolvedType, output, decompilationOptions); + } - List lineNumberPositions = results.getLineNumberPositions( ); + List lineNumberPositions = results.getLineNumberPositions(); - if ( includeLineNumbers || stretchLines ) - { - EnumSet lineNumberOptions = EnumSet.noneOf( LineNumberFormatter.LineNumberOption.class ); + if (includeLineNumbers || stretchLines) { + EnumSet lineNumberOptions = EnumSet.noneOf(LineNumberOption.class); - if ( includeLineNumbers ) - { - lineNumberOptions.add( LineNumberFormatter.LineNumberOption.LEADING_COMMENTS ); + if (includeLineNumbers) { + lineNumberOptions.add(LineNumberFormatter.LineNumberOption.LEADING_COMMENTS); } - if ( stretchLines ) - { - lineNumberOptions.add( LineNumberFormatter.LineNumberOption.STRETCHED ); + if (stretchLines) { + lineNumberOptions.add(LineNumberFormatter.LineNumberOption.STRETCHED); } - LineNumberFormatter lineFormatter = new LineNumberFormatter( classFile, - lineNumberPositions, - lineNumberOptions ); + LineNumberFormatter lineFormatter = new LineNumberFormatter(classFile, lineNumberPositions, + lineNumberOptions); - lineFormatter.reformatFile( ); + source = lineFormatter.reformatFile(); + } else { + source = FileUtil.getContent(classFile); } - } - catch ( IOException e ) - { - e.printStackTrace( ); - } - finally - { - if ( writer != null ) - { - try - { - writer.close( ); - } - catch ( IOException e ) - { - e.printStackTrace( ); - } - } - } - source = UnicodeUtil.decode( FileUtil.getContent( classFile ) ); - - classFile.delete( ); - - Pattern wp = Pattern.compile( "/\\*.+?\\*/", Pattern.DOTALL ); //$NON-NLS-1$ - Matcher m = wp.matcher( source ); - while ( m.find( ) ) - { - if ( m.group( ).matches( "/\\*\\s*\\d*\\s*\\*/" ) ) //$NON-NLS-1$ - continue; - String group = m.group( ); - group = group.replace( "/*", "" ); //$NON-NLS-1$ //$NON-NLS-2$ - group = group.replace( "*/", "" ); //$NON-NLS-1$ //$NON-NLS-2$ - group = group.replace( "*", "" ); //$NON-NLS-1$ //$NON-NLS-2$ - if ( log.length( ) > 0 ) - log += "\n"; //$NON-NLS-1$ - log += group; - - source = source.replace( m.group( ), "" ); //$NON-NLS-1$ + } catch (IOException e) { + exceptions.add(e); + Logger.error(e); } - time = System.currentTimeMillis( ) - start; + source = UnicodeUtil.decode(source); + + classFile.delete(); + + source = CommentUtil.clearComments(source); + + time = stopWatch.getTime(); } /** * Jad doesn't support decompilation from archives. This methods extracts - * request class file from the specified archive into temp directory and - * then calls decompile. + * request class file from the specified archive into temp directory and then + * calls decompile. * * @see IDecompiler#decompileFromArchive(String, String, String) */ @Override - public void decompileFromArchive( String archivePath, String packege, String className ) - { - start = System.currentTimeMillis( ); + public void decompileFromArchive(String archivePath, String packege, String className) { + StopWatch stopWatch = new StopWatch(); + stopWatch.start(); File workingDir = new File( - JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ).getString( JavaDecompilerPlugin.TEMP_DIR ) - + "/" //$NON-NLS-1$ - + System.currentTimeMillis( ) ); - - try - { - workingDir.mkdirs( ); - JarClassExtractor.extract( archivePath, packege, className, true, workingDir.getAbsolutePath( ) ); - decompile( workingDir.getAbsolutePath( ), "", className ); //$NON-NLS-1$ - } - catch ( Exception e ) - { - JavaDecompilerPlugin.logError( e, e.getMessage( ) ); + JavaDecompilerPlugin.getDefault().getPreferenceStore().getString(JavaDecompilerConstants.TEMP_DIR) + "/" //$NON-NLS-1$ + + System.currentTimeMillis()); + + try { + workingDir.mkdirs(); + JarClassExtractor.extract(archivePath, packege, className, true, workingDir.getAbsolutePath()); + decompile(workingDir.getAbsolutePath(), "", className); //$NON-NLS-1$ + time = stopWatch.getTime(); + } catch (Exception e) { + exceptions.add(e); + JavaDecompilerPlugin.logError(e, e.getMessage()); return; - } - finally - { - FileUtil.deltree( workingDir ); + } finally { + FileUtil.deltree(workingDir); } } @Override - public long getDecompilationTime( ) - { + public long getDecompilationTime() { return time; } - @Override - public List getExceptions( ) - { - return Collections.EMPTY_LIST; - } - /** * @see IDecompiler#getLog() */ @Override - public String getLog( ) - { + public String getLog() { return log; } @@ -244,38 +190,46 @@ public String getLog( ) * @see IDecompiler#getSource() */ @Override - public String getSource( ) - { + public String getSource() { return source; } @Override - public String getDecompilerType( ) - { + public String getDecompilerType() { return ProcyonDecompilerPlugin.decompilerType; } @Override - public String removeComment( String source ) - { + public String removeComment(String source) { return source; } @Override - public boolean supportLevel( int level ) - { + public boolean supportLevel(int level) { return true; } @Override - public boolean supportDebugLevel( int level ) - { + public boolean supportDebugLevel(int level) { return true; } @Override - public boolean supportDebug( ) - { - return true; + public String getDecompilerName() { + return ProcyonDecompilerPlugin.decompilerType; } + + @Override + public String getDecompilerVersion() { + return ProcyonDecompilerPlugin.decompilerVersion; + } + + @Override + public LineNumberOutputType getLineNumberOutputType() { + // Procyon generates line number comments at the beginning of the line but only + // for those lines source line information is present. The other lines are just + // indented by spaces. + return LineNumberOutputType.BLOCK_COMMENT_BEGIN_OF_LINE; + } + } \ No newline at end of file diff --git a/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/decompiler/ProcyonDecompilerDescriptor.java b/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/decompiler/ProcyonDecompilerDescriptor.java index fb5c8dfc..b08b45c1 100644 --- a/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/decompiler/ProcyonDecompilerDescriptor.java +++ b/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/decompiler/ProcyonDecompilerDescriptor.java @@ -10,8 +10,7 @@ import org.sf.feeling.decompiler.procyon.actions.DecompileWithProcyonAction; import org.sf.feeling.decompiler.procyon.i18n.Messages; -public class ProcyonDecompilerDescriptor implements IDecompilerDescriptor -{ +public class ProcyonDecompilerDescriptor implements IDecompilerDescriptor { private ProcyonDecompiler decompiler = null; @@ -20,60 +19,50 @@ public class ProcyonDecompilerDescriptor implements IDecompilerDescriptor private Action decompileAction = null; @Override - public String getDecompilerType( ) - { + public String getDecompilerType() { return ProcyonDecompilerPlugin.decompilerType; } @Override - public String getDecompilerPreferenceLabel( ) - { - return Messages.getString( "ProcyonDecompilerDescriptor.PreferenceLabel" ); //$NON-NLS-1$ + public String getDecompilerPreferenceLabel() { + return Messages.getString("ProcyonDecompilerDescriptor.PreferenceLabel"); //$NON-NLS-1$ } @Override - public IDecompiler getDecompiler( ) - { - if ( decompiler == null ) - decompiler = new ProcyonDecompiler( ); + public IDecompiler getDecompiler() { + if (decompiler == null) + decompiler = new ProcyonDecompiler(); return decompiler; } @Override - public BaseDecompilerSourceMapper getDecompilerSourceMapper( ) - { - if ( sourceMapper == null ) - { - sourceMapper = new ProcyonSourceMapper( ); + public BaseDecompilerSourceMapper getDecompilerSourceMapper() { + if (sourceMapper == null) { + sourceMapper = new ProcyonSourceMapper(); } return sourceMapper; } @Override - public Action getDecompileAction( ) - { - if ( decompileAction == null ) - { - decompileAction = new DecompileWithProcyonAction( ); + public Action getDecompileAction() { + if (decompileAction == null) { + decompileAction = new DecompileWithProcyonAction(); } return decompileAction; } @Override - public boolean isEnabled( ) - { - return !( System.getProperty( "java.version" ).compareTo( "1.7" ) < 0 ); //$NON-NLS-1$ //$NON-NLS-2$ + public boolean isEnabled() { + return true; } @Override - public boolean isDefault( ) - { - return false; + public int getDefaultPriority() { + return 2; } @Override - public ImageDescriptor getDecompilerIcon( ) - { - return ProcyonDecompilerPlugin.getImageDescriptor( "icons/procyon_16.png" ); //$NON-NLS-1$ ; + public ImageDescriptor getDecompilerIcon() { + return ProcyonDecompilerPlugin.getImageDescriptor("icons/procyon_16.png"); //$NON-NLS-1$ ; } } diff --git a/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/decompiler/ProcyonSourceMapper.java b/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/decompiler/ProcyonSourceMapper.java index 91f8c1ef..21a04fb9 100644 --- a/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/decompiler/ProcyonSourceMapper.java +++ b/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/decompiler/ProcyonSourceMapper.java @@ -1,80 +1,32 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.procyon.decompiler; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Collection; -import java.util.Iterator; - import org.eclipse.core.runtime.Path; import org.sf.feeling.decompiler.editor.BaseDecompilerSourceMapper; +import org.sf.feeling.decompiler.procyon.ProcyonDecompilerPlugin; -import com.strobel.Procyon; - -public class ProcyonSourceMapper extends BaseDecompilerSourceMapper -{ +public class ProcyonSourceMapper extends BaseDecompilerSourceMapper { - public ProcyonSourceMapper( ) - { - super( new Path( "." ), "" ); //$NON-NLS-1$ //$NON-NLS-2$ - origionalDecompiler = new ProcyonDecompiler( ); + public ProcyonSourceMapper() { + super(new Path("."), ""); //$NON-NLS-1$ //$NON-NLS-2$ + originalDecompiler = new ProcyonDecompiler(); } @Override - protected void printDecompileReport( StringBuffer source, String fileLocation, Collection exceptions, - long decompilationTime ) - { - String location = "\tDecompiled from: " //$NON-NLS-1$ - + fileLocation; - source.append( "\n\n/*" ); //$NON-NLS-1$ - source.append( "\n\tDECOMPILATION REPORT\n\n" ); //$NON-NLS-1$ - source.append( location ).append( "\n" ); //$NON-NLS-1$ - source.append( "\tTotal time: " ) //$NON-NLS-1$ - .append( decompilationTime ) - .append( " ms\n" ); //$NON-NLS-1$ - source.append( "\t" //$NON-NLS-1$ - + origionalDecompiler.getLog( ) - .replaceAll( "\t", "" ) //$NON-NLS-1$ //$NON-NLS-2$ - .replaceAll( "\n\\s*", "\n\t" ) ); //$NON-NLS-1$ //$NON-NLS-2$ - exceptions.addAll( origionalDecompiler.getExceptions( ) ); - logExceptions( exceptions, source ); - source.append( "\n\tDecompiled with Procyon " //$NON-NLS-1$ - + Procyon.version( ) - + "." ); //$NON-NLS-1$ - source.append( "\n*/" ); //$NON-NLS-1$ + protected String getDecompilerName() { + return ProcyonDecompilerPlugin.decompilerType; } - protected void logExceptions( Collection exceptions, StringBuffer buffer ) - { - if ( !exceptions.isEmpty( ) ) - { - buffer.append( "\n\tCaught exceptions:" ); //$NON-NLS-1$ - if ( exceptions == null || exceptions.size( ) == 0 ) - return; // nothing to do - buffer.append( "\n" ); //$NON-NLS-1$ - StringWriter stackTraces = new StringWriter( ); - PrintWriter stackTracesP = new PrintWriter( stackTraces ); - - Iterator i = exceptions.iterator( ); - while ( i.hasNext( ) ) - { - ( (Exception) i.next( ) ).printStackTrace( stackTracesP ); - stackTracesP.println( "" ); //$NON-NLS-1$ - } - - stackTracesP.flush( ); - stackTracesP.close( ); - buffer.append( stackTraces.toString( ) ); - } + @Override + protected String getDecompilerVersion() { + return ProcyonDecompilerPlugin.decompilerVersion; } + } \ No newline at end of file diff --git a/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/i18n/Messages.java b/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/i18n/Messages.java index fc296b9e..a2ea7fc2 100644 --- a/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/i18n/Messages.java +++ b/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/i18n/Messages.java @@ -1,53 +1,27 @@ package org.sf.feeling.decompiler.procyon.i18n; -import java.io.UnsupportedEncodingException; -import java.text.MessageFormat; -import java.util.MissingResourceException; -import java.util.ResourceBundle; +import org.sf.feeling.decompiler.i18n.EcdResouceBundle; -public class Messages -{ +public class Messages { - private static final String BUNDLE_NAME = "org.sf.feeling.decompiler.procyon.i18n.messages"; //$NON-NLS-1$ + private static final EcdResouceBundle RESOURCE_BUNDLE = new EcdResouceBundle(Messages.class); - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); - - private Messages( ) - { + private Messages() { } - public static String getString( String key ) - { - - try - { - String result = RESOURCE_BUNDLE.getString( key ); - try - { - result = new String( result.getBytes( "ISO-8859-1" ), "utf-8" ); //$NON-NLS-1$ //$NON-NLS-2$ - } - catch ( UnsupportedEncodingException e ) - { - return '!' + key + '!'; - } - return result; - } - catch ( MissingResourceException e ) - { - return '!' + key + '!'; - } + public static String getString(String key) { + return RESOURCE_BUNDLE.getString(key); } /** * Gets formatted translation for current local * - * @param key - * the key + * @param key the key * @return translated value string */ - public static String getFormattedString( String key, Object[] arguments ) - { - return MessageFormat.format( getString( key ), arguments ); + public static String getFormattedString(String key, Object[] arguments) { + return RESOURCE_BUNDLE.getFormattedString(key, arguments); } + } diff --git a/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/i18n/messages.properties b/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/i18n/messages.properties index 460b14a1..a5ad0296 100644 --- a/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/i18n/messages.properties +++ b/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/i18n/messages.properties @@ -1,13 +1,10 @@ ############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). +# Copyright (c) 2017 Chen Chao and other ECD project contributors. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation +# https://www.eclipse.org/legal/epl-v10.html ############################################################################### -ProcyonDecompilerDescriptor.PreferenceLabel=Procyon (Support JDK8) +ProcyonDecompilerDescriptor.PreferenceLabel=Procyon (Support JDK9+) JavaDecompilerActionBarContributor.Action.DecompileWithProcyon=&Procyon \ No newline at end of file diff --git a/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/i18n/messages_zh_CN.properties b/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/i18n/messages_zh_CN.properties deleted file mode 100644 index 1d1eab93..00000000 --- a/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/i18n/messages_zh_CN.properties +++ /dev/null @@ -1,13 +0,0 @@ -############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation -############################################################################### - -ProcyonDecompilerDescriptor.PreferenceLabel=Procyon (支æŒJDK8) -JavaDecompilerActionBarContributor.Action.DecompileWithProcyon=&Procyon \ No newline at end of file diff --git a/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/i18n/messages_zh_HK.properties b/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/i18n/messages_zh_HK.properties deleted file mode 100644 index 1d1eab93..00000000 --- a/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/i18n/messages_zh_HK.properties +++ /dev/null @@ -1,13 +0,0 @@ -############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation -############################################################################### - -ProcyonDecompilerDescriptor.PreferenceLabel=Procyon (支æŒJDK8) -JavaDecompilerActionBarContributor.Action.DecompileWithProcyon=&Procyon \ No newline at end of file diff --git a/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/i18n/messages_zh_TW.properties b/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/i18n/messages_zh_TW.properties deleted file mode 100644 index 1d1eab93..00000000 --- a/org.sf.feeling.decompiler.procyon/src/org/sf/feeling/decompiler/procyon/i18n/messages_zh_TW.properties +++ /dev/null @@ -1,13 +0,0 @@ -############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation -############################################################################### - -ProcyonDecompilerDescriptor.PreferenceLabel=Procyon (支æŒJDK8) -JavaDecompilerActionBarContributor.Action.DecompileWithProcyon=&Procyon \ No newline at end of file diff --git a/org.sf.feeling.decompiler.source.attach/.classpath b/org.sf.feeling.decompiler.source.attach/.classpath deleted file mode 100644 index 4903274d..00000000 --- a/org.sf.feeling.decompiler.source.attach/.classpath +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.sf.feeling.decompiler.source.attach/.project b/org.sf.feeling.decompiler.source.attach/.project deleted file mode 100644 index 5c92187f..00000000 --- a/org.sf.feeling.decompiler.source.attach/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - org.sf.feeling.decompiler.source.attach - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/org.sf.feeling.decompiler.source.attach/.settings/org.eclipse.core.resources.prefs b/org.sf.feeling.decompiler.source.attach/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index e4a7ae6e..00000000 --- a/org.sf.feeling.decompiler.source.attach/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,4 +0,0 @@ -eclipse.preferences.version=1 -encoding//src/org/sf/feeling/decompiler/source/attach/i18n/messages_zh_CN.properties=UTF-8 -encoding//src/org/sf/feeling/decompiler/source/attach/i18n/messages_zh_HK.properties=UTF-8 -encoding//src/org/sf/feeling/decompiler/source/attach/i18n/messages_zh_TW.properties=UTF-8 diff --git a/org.sf.feeling.decompiler.source.attach/.settings/org.eclipse.jdt.core.prefs b/org.sf.feeling.decompiler.source.attach/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 8505da60..00000000 --- a/org.sf.feeling.decompiler.source.attach/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,12 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/org.sf.feeling.decompiler.source.attach/META-INF/MANIFEST.MF b/org.sf.feeling.decompiler.source.attach/META-INF/MANIFEST.MF deleted file mode 100644 index e37949bf..00000000 --- a/org.sf.feeling.decompiler.source.attach/META-INF/MANIFEST.MF +++ /dev/null @@ -1,57 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Eclipse Class Decompiler Source Attach -Bundle-SymbolicName: org.sf.feeling.decompiler.source.attach;singleton:=true -Bundle-Version: 2.10.0.qualifier -Bundle-Activator: org.sf.feeling.decompiler.source.attach.SourceAttachPlugin -Bundle-Localization: plugin -Require-Bundle: org.eclipse.ui, - org.eclipse.core.runtime, - org.eclipse.core.expressions, - org.eclipse.jdt.core, - org.eclipse.jdt.ui, - org.eclipse.core.resources, - org.eclipse.core.databinding, - org.eclipse.jface.databinding, - org.eclipse.core.databinding.beans, - org.sf.feeling.decompiler, - org.apache.ant, - org.eclipse.jgit;resolution:=optional, - com.jcraft.jsch;resolution:=optional, - org.eclipse.m2e.jdt;resolution:=optional -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Bundle-ActivationPolicy: lazy -Bundle-Vendor: Chen Chao -Bundle-ClassPath: lib/commons-lang-2.6.jar, - lib/commons-io-2.2.jar, - lib/commons-compress-1.3.jar, - lib/cvsclient-20060125.jar, - lib/maven-scm-api-1.9.4.jar, - lib/maven-scm-provider-accurev-1.9.4.jar, - lib/maven-scm-provider-bazaar-1.9.4.jar, - lib/maven-scm-provider-clearcase-1.9.4.jar, - lib/maven-scm-provider-cvs-commons-1.9.4.jar, - lib/maven-scm-provider-cvsexe-1.9.4.jar, - lib/maven-scm-provider-cvsjava-1.9.4.jar, - lib/maven-scm-provider-git-commons-1.9.4.jar, - lib/maven-scm-provider-gitexe-1.9.4.jar, - lib/maven-scm-provider-hg-1.9.4.jar, - lib/maven-scm-provider-integrity-1.9.4.jar, - lib/maven-scm-provider-jazz-1.9.4.jar, - lib/maven-scm-provider-local-1.9.4.jar, - lib/maven-scm-provider-perforce-1.9.4.jar, - lib/maven-scm-provider-starteam-1.9.4.jar, - lib/maven-scm-provider-svn-commons-1.9.4.jar, - lib/maven-scm-provider-svnexe-1.9.4.jar, - lib/maven-scm-provider-synergy-1.9.4.jar, - lib/maven-scm-provider-tfs-1.9.4.jar, - lib/maven-scm-provider-vss-1.9.4.jar, - lib/plexus-utils-3.0.15.jar, - lib/nexus-indexer-lucene-model-2.9.2-01.jar, - lib/nexus-restlet1x-model-2.9.2-01.jar, - . -Export-Package: org.sf.feeling.decompiler.source.attach, - org.sf.feeling.decompiler.source.attach.attacher, - org.sf.feeling.decompiler.source.attach.finder, - org.sf.feeling.decompiler.source.attach.handler, - org.sf.feeling.decompiler.source.attach.utils diff --git a/org.sf.feeling.decompiler.source.attach/lib/commons-compress-1.3.jar b/org.sf.feeling.decompiler.source.attach/lib/commons-compress-1.3.jar deleted file mode 100644 index 6c826c52..00000000 Binary files a/org.sf.feeling.decompiler.source.attach/lib/commons-compress-1.3.jar and /dev/null differ diff --git a/org.sf.feeling.decompiler.source.attach/lib/commons-io-2.2.jar b/org.sf.feeling.decompiler.source.attach/lib/commons-io-2.2.jar deleted file mode 100644 index 84ca5658..00000000 Binary files a/org.sf.feeling.decompiler.source.attach/lib/commons-io-2.2.jar and /dev/null differ diff --git a/org.sf.feeling.decompiler.source.attach/lib/commons-lang-2.6.jar b/org.sf.feeling.decompiler.source.attach/lib/commons-lang-2.6.jar deleted file mode 100644 index 98467d3a..00000000 Binary files a/org.sf.feeling.decompiler.source.attach/lib/commons-lang-2.6.jar and /dev/null differ diff --git a/org.sf.feeling.decompiler.source.attach/lib/cvsclient-20060125.jar b/org.sf.feeling.decompiler.source.attach/lib/cvsclient-20060125.jar deleted file mode 100644 index 0c2d7158..00000000 Binary files a/org.sf.feeling.decompiler.source.attach/lib/cvsclient-20060125.jar and /dev/null differ diff --git a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-api-1.9.4.jar b/org.sf.feeling.decompiler.source.attach/lib/maven-scm-api-1.9.4.jar deleted file mode 100644 index f648b6bc..00000000 Binary files a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-api-1.9.4.jar and /dev/null differ diff --git a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-accurev-1.9.4.jar b/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-accurev-1.9.4.jar deleted file mode 100644 index a41ae2c8..00000000 Binary files a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-accurev-1.9.4.jar and /dev/null differ diff --git a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-bazaar-1.9.4.jar b/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-bazaar-1.9.4.jar deleted file mode 100644 index b5b76977..00000000 Binary files a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-bazaar-1.9.4.jar and /dev/null differ diff --git a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-clearcase-1.9.4.jar b/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-clearcase-1.9.4.jar deleted file mode 100644 index 2a3f568c..00000000 Binary files a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-clearcase-1.9.4.jar and /dev/null differ diff --git a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-cvs-commons-1.9.4.jar b/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-cvs-commons-1.9.4.jar deleted file mode 100644 index 45c3fe7b..00000000 Binary files a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-cvs-commons-1.9.4.jar and /dev/null differ diff --git a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-cvsexe-1.9.4.jar b/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-cvsexe-1.9.4.jar deleted file mode 100644 index 4356666b..00000000 Binary files a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-cvsexe-1.9.4.jar and /dev/null differ diff --git a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-cvsjava-1.9.4.jar b/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-cvsjava-1.9.4.jar deleted file mode 100644 index 43ad40de..00000000 Binary files a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-cvsjava-1.9.4.jar and /dev/null differ diff --git a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-git-commons-1.9.4.jar b/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-git-commons-1.9.4.jar deleted file mode 100644 index 7d779f9e..00000000 Binary files a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-git-commons-1.9.4.jar and /dev/null differ diff --git a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-gitexe-1.9.4.jar b/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-gitexe-1.9.4.jar deleted file mode 100644 index a0454939..00000000 Binary files a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-gitexe-1.9.4.jar and /dev/null differ diff --git a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-hg-1.9.4.jar b/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-hg-1.9.4.jar deleted file mode 100644 index ec5d779f..00000000 Binary files a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-hg-1.9.4.jar and /dev/null differ diff --git a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-integrity-1.9.4.jar b/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-integrity-1.9.4.jar deleted file mode 100644 index 5f9100e9..00000000 Binary files a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-integrity-1.9.4.jar and /dev/null differ diff --git a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-jazz-1.9.4.jar b/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-jazz-1.9.4.jar deleted file mode 100644 index 28884ee7..00000000 Binary files a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-jazz-1.9.4.jar and /dev/null differ diff --git a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-local-1.9.4.jar b/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-local-1.9.4.jar deleted file mode 100644 index e66f3958..00000000 Binary files a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-local-1.9.4.jar and /dev/null differ diff --git a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-perforce-1.9.4.jar b/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-perforce-1.9.4.jar deleted file mode 100644 index c3d55c27..00000000 Binary files a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-perforce-1.9.4.jar and /dev/null differ diff --git a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-starteam-1.9.4.jar b/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-starteam-1.9.4.jar deleted file mode 100644 index 461501bc..00000000 Binary files a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-starteam-1.9.4.jar and /dev/null differ diff --git a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-svn-commons-1.9.4.jar b/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-svn-commons-1.9.4.jar deleted file mode 100644 index 4879a10d..00000000 Binary files a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-svn-commons-1.9.4.jar and /dev/null differ diff --git a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-svnexe-1.9.4.jar b/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-svnexe-1.9.4.jar deleted file mode 100644 index 5967a6ac..00000000 Binary files a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-svnexe-1.9.4.jar and /dev/null differ diff --git a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-synergy-1.9.4.jar b/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-synergy-1.9.4.jar deleted file mode 100644 index 609ee3ab..00000000 Binary files a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-synergy-1.9.4.jar and /dev/null differ diff --git a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-tfs-1.9.4.jar b/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-tfs-1.9.4.jar deleted file mode 100644 index 8b41f2b2..00000000 Binary files a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-tfs-1.9.4.jar and /dev/null differ diff --git a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-vss-1.9.4.jar b/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-vss-1.9.4.jar deleted file mode 100644 index 96ca9b24..00000000 Binary files a/org.sf.feeling.decompiler.source.attach/lib/maven-scm-provider-vss-1.9.4.jar and /dev/null differ diff --git a/org.sf.feeling.decompiler.source.attach/lib/nexus-indexer-lucene-model-2.9.2-01.jar b/org.sf.feeling.decompiler.source.attach/lib/nexus-indexer-lucene-model-2.9.2-01.jar deleted file mode 100644 index 8ca0da4a..00000000 Binary files a/org.sf.feeling.decompiler.source.attach/lib/nexus-indexer-lucene-model-2.9.2-01.jar and /dev/null differ diff --git a/org.sf.feeling.decompiler.source.attach/lib/nexus-restlet1x-model-2.9.2-01.jar b/org.sf.feeling.decompiler.source.attach/lib/nexus-restlet1x-model-2.9.2-01.jar deleted file mode 100644 index 2706dc62..00000000 Binary files a/org.sf.feeling.decompiler.source.attach/lib/nexus-restlet1x-model-2.9.2-01.jar and /dev/null differ diff --git a/org.sf.feeling.decompiler.source.attach/lib/plexus-utils-3.0.15.jar b/org.sf.feeling.decompiler.source.attach/lib/plexus-utils-3.0.15.jar deleted file mode 100644 index feab196e..00000000 Binary files a/org.sf.feeling.decompiler.source.attach/lib/plexus-utils-3.0.15.jar and /dev/null differ diff --git a/org.sf.feeling.decompiler.source.attach/plugin.xml b/org.sf.feeling.decompiler.source.attach/plugin.xml deleted file mode 100644 index 87046d66..00000000 --- a/org.sf.feeling.decompiler.source.attach/plugin.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/org.sf.feeling.decompiler.source.attach/plugin_zh_HK.properties b/org.sf.feeling.decompiler.source.attach/plugin_zh_HK.properties deleted file mode 100644 index 1eed8c2d..00000000 --- a/org.sf.feeling.decompiler.source.attach/plugin_zh_HK.properties +++ /dev/null @@ -1,12 +0,0 @@ -############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation -############################################################################### - -action.label=\u4E0B\u8F09\u6E90\u78BC \ No newline at end of file diff --git a/org.sf.feeling.decompiler.source.attach/plugin_zh_TW.properties b/org.sf.feeling.decompiler.source.attach/plugin_zh_TW.properties deleted file mode 100644 index 1eed8c2d..00000000 --- a/org.sf.feeling.decompiler.source.attach/plugin_zh_TW.properties +++ /dev/null @@ -1,12 +0,0 @@ -############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation -############################################################################### - -action.label=\u4E0B\u8F09\u6E90\u78BC \ No newline at end of file diff --git a/org.sf.feeling.decompiler.source.attach/src/java/lang/AutoCloseable.java b/org.sf.feeling.decompiler.source.attach/src/java/lang/AutoCloseable.java deleted file mode 100644 index bbf55ed2..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/java/lang/AutoCloseable.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package java.lang; - -/** - * A resource that must be closed when it is no longer needed. - * - * @author Josh Bloch - * @since 1.7 - */ -public interface AutoCloseable -{ - - /** - * Closes this resource, relinquishing any underlying resources. This method - * is invoked automatically on objects managed by the - * {@code try}-with-resources statement. - * - *

      - * While this interface method is declared to throw {@code - * Exception}, implementers are strongly encouraged to declare - * concrete implementations of the {@code close} method to throw more - * specific exceptions, or to throw no exception at all if the close - * operation cannot fail. - * - *

      - * Implementers of this interface are also strongly advised to not have - * the {@code close} method throw {@link InterruptedException}. - * - * This exception interacts with a thread's interrupted status, and runtime - * misbehavior is likely to occur if an {@code - * InterruptedException} is {@linkplain Throwable#addSuppressed suppressed}. - * - * More generally, if it would cause problems for an exception to be - * suppressed, the {@code AutoCloseable.close} method should not throw it. - * - *

      - * Note that unlike the {@link java.io.Closeable#close close} method of - * {@link java.io.Closeable}, this {@code close} method is not - * required to be idempotent. In other words, calling this {@code close} - * method more than once may have some visible side effect, unlike - * {@code Closeable.close} which is required to have no effect if called - * more than once. - * - * However, implementers of this interface are strongly encouraged to make - * their {@code close} methods idempotent. - * - * @throws Exception - * if this resource cannot be closed - */ - void close( ) throws Exception; -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/JGitScmProvider.java b/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/JGitScmProvider.java deleted file mode 100644 index 4665b5cf..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/JGitScmProvider.java +++ /dev/null @@ -1,209 +0,0 @@ - -package org.apache.maven.scm.provider.git.jgit; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.File; - -import org.apache.maven.scm.ScmException; -import org.apache.maven.scm.ScmFileSet; -import org.apache.maven.scm.command.info.InfoScmResult; -import org.apache.maven.scm.provider.git.AbstractGitScmProvider; -import org.apache.maven.scm.provider.git.command.GitCommand; -import org.apache.maven.scm.provider.git.command.info.GitInfoItem; -import org.apache.maven.scm.provider.git.jgit.command.add.JGitAddCommand; -import org.apache.maven.scm.provider.git.jgit.command.blame.JGitBlameCommand; -import org.apache.maven.scm.provider.git.jgit.command.branch.JGitBranchCommand; -import org.apache.maven.scm.provider.git.jgit.command.changelog.JGitChangeLogCommand; -import org.apache.maven.scm.provider.git.jgit.command.checkin.JGitCheckInCommand; -import org.apache.maven.scm.provider.git.jgit.command.checkout.JGitCheckOutCommand; -import org.apache.maven.scm.provider.git.jgit.command.diff.JGitDiffCommand; -import org.apache.maven.scm.provider.git.jgit.command.list.JGitListCommand; -import org.apache.maven.scm.provider.git.jgit.command.remoteinfo.JGitRemoteInfoCommand; -import org.apache.maven.scm.provider.git.jgit.command.status.JGitStatusCommand; -import org.apache.maven.scm.provider.git.jgit.command.tag.JGitTagCommand; -import org.apache.maven.scm.repository.ScmRepositoryException; - -/** - * @author Mark Struberg - * @author Dominik Bartholdi (imod) - * @plexus.component role="org.apache.maven.scm.provider.ScmProvider" - * role-hint="jgit" - * @since 1.9 - */ -public class JGitScmProvider extends AbstractGitScmProvider -{ - - /** - * {@inheritDoc} - */ - @Override - protected GitCommand getAddCommand( ) - { - return new JGitAddCommand( ); - } - - /** - * {@inheritDoc} - */ - @Override - protected GitCommand getBranchCommand( ) - { - return new JGitBranchCommand( ); - } - - /** - * {@inheritDoc} - */ - @Override - protected GitCommand getChangeLogCommand( ) - { - return new JGitChangeLogCommand( ); - } - - /** - * {@inheritDoc} - */ - @Override - protected GitCommand getCheckInCommand( ) - { - return new JGitCheckInCommand( ); - } - - /** - * {@inheritDoc} - */ - @Override - protected GitCommand getCheckOutCommand( ) - { - return new JGitCheckOutCommand( ); - } - - /** - * {@inheritDoc} - */ - @Override - protected GitCommand getDiffCommand( ) - { - return new JGitDiffCommand( ); - } - - /** - * {@inheritDoc} - */ - @Override - protected GitCommand getExportCommand( ) - { - throw new UnsupportedOperationException( "getExportCommand" ); //$NON-NLS-1$ - } - - /** - * {@inheritDoc} - */ - @Override - protected GitCommand getRemoveCommand( ) - { - throw new UnsupportedOperationException( "getRemoveCommand" ); //$NON-NLS-1$ - } - - /** - * {@inheritDoc} - */ - @Override - protected GitCommand getStatusCommand( ) - { - return new JGitStatusCommand( ); - } - - /** - * {@inheritDoc} - */ - @Override - protected GitCommand getTagCommand( ) - { - return new JGitTagCommand( ); - } - - /** - * {@inheritDoc} - */ - @Override - protected GitCommand getUpdateCommand( ) - { - throw new UnsupportedOperationException( "getUpdateCommand" ); //$NON-NLS-1$ - } - - /** - * {@inheritDoc} - */ - @Override - protected GitCommand getListCommand( ) - { - return new JGitListCommand( ); - } - - /** - * {@inheritDoc} - */ - @Override - public GitCommand getInfoCommand( ) - { - throw new UnsupportedOperationException( "getInfoCommand" ); //$NON-NLS-1$ - } - - /** - * {@inheritDoc} - */ - @Override - protected String getRepositoryURL( File path ) throws ScmException - { - // Note: I need to supply just 1 absolute path, but ScmFileSet won't let - // me without - // a basedir (which isn't used here anyway), so use a dummy file. - InfoScmResult result = info( null, new ScmFileSet( new File( "" ), path ), null ); //$NON-NLS-1$ - - if ( result.getInfoItems( ).size( ) != 1 ) - { - throw new ScmRepositoryException( "Cannot find URL: " //$NON-NLS-1$ - + ( result.getInfoItems( ).size( ) == 0 ? "no" : "multiple" ) //$NON-NLS-1$ //$NON-NLS-2$ - + " items returned by the info command" ); //$NON-NLS-1$ - } - - return ( (GitInfoItem) result.getInfoItems( ).get( 0 ) ).getURL( ); - } - - /** - * {@inheritDoc} - */ - @Override - protected GitCommand getBlameCommand( ) - { - return new JGitBlameCommand( ); - } - - /** - * {@inheritDoc} - */ - @Override - protected GitCommand getRemoteInfoCommand( ) - { - return new JGitRemoteInfoCommand( ); - } -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/command/JGitUtils.java b/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/command/JGitUtils.java deleted file mode 100644 index 4d6fff0d..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/command/JGitUtils.java +++ /dev/null @@ -1,483 +0,0 @@ - -package org.apache.maven.scm.provider.git.jgit.command; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.File; -import java.io.IOException; -import java.net.URI; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.apache.maven.scm.ScmFile; -import org.apache.maven.scm.ScmFileSet; -import org.apache.maven.scm.ScmFileStatus; -import org.apache.maven.scm.log.ScmLogger; -import org.apache.maven.scm.provider.git.repository.GitScmProviderRepository; -import org.apache.maven.scm.util.FilenameUtils; -import org.codehaus.plexus.util.StringUtils; -import org.eclipse.jgit.api.AddCommand; -import org.eclipse.jgit.api.Git; -import org.eclipse.jgit.api.Status; -import org.eclipse.jgit.api.errors.GitAPIException; -import org.eclipse.jgit.api.errors.InvalidRemoteException; -import org.eclipse.jgit.api.errors.NoFilepatternException; -import org.eclipse.jgit.api.errors.TransportException; -import org.eclipse.jgit.diff.DiffEntry; -import org.eclipse.jgit.diff.DiffEntry.ChangeType; -import org.eclipse.jgit.diff.DiffFormatter; -import org.eclipse.jgit.diff.RawTextComparator; -import org.eclipse.jgit.errors.CorruptObjectException; -import org.eclipse.jgit.errors.IncorrectObjectTypeException; -import org.eclipse.jgit.errors.MissingObjectException; -import org.eclipse.jgit.errors.StopWalkException; -import org.eclipse.jgit.lib.Constants; -import org.eclipse.jgit.lib.ObjectId; -import org.eclipse.jgit.lib.ObjectReader; -import org.eclipse.jgit.lib.ProgressMonitor; -import org.eclipse.jgit.lib.Repository; -import org.eclipse.jgit.lib.StoredConfig; -import org.eclipse.jgit.lib.TextProgressMonitor; -import org.eclipse.jgit.revwalk.RevCommit; -import org.eclipse.jgit.revwalk.RevFlag; -import org.eclipse.jgit.revwalk.RevSort; -import org.eclipse.jgit.revwalk.RevWalk; -import org.eclipse.jgit.revwalk.filter.CommitTimeRevFilter; -import org.eclipse.jgit.revwalk.filter.RevFilter; -import org.eclipse.jgit.transport.CredentialsProvider; -import org.eclipse.jgit.transport.PushResult; -import org.eclipse.jgit.transport.RefSpec; -import org.eclipse.jgit.transport.RemoteRefUpdate; -import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider; -import org.eclipse.jgit.treewalk.TreeWalk; -import org.eclipse.jgit.util.io.DisabledOutputStream; -import org.sf.feeling.decompiler.util.ReflectionUtils; - -/** - * JGit utility functions. - * - * @author Mark Struberg - * @author Dominik Bartholdi (imod) - * @since 1.9 - */ -public class JGitUtils -{ - - private JGitUtils( ) - { - // no op - } - - /** - * Closes the repository wrapped by the passed git object - * - * @param git - */ - public static void closeRepo( Git git ) - { - if ( git != null && git.getRepository( ) != null ) - { - git.getRepository( ).close( ); - } - } - - /** - * Construct a logging ProgressMonitor for all JGit operations. - * - * @param logger - * @return a ProgressMonitor for use - */ - public static ProgressMonitor getMonitor( ScmLogger logger ) - { - // X TODO write an own ProgressMonitor which logs to ScmLogger! - return new TextProgressMonitor( ); - } - - /** - * Prepares the in memory configuration of git to connect to the configured - * repository. It configures the following settings in memory:
      - *

    • push url
    • - *
    • fetch url
    • - *

      - * - * @param logger - * used to log some details - * @param git - * the instance to configure (only in memory, not saved) - * @param repository - * the repo config to be used - * @return {@link CredentialsProvider} in case there are credentials - * informations configured in the repository. - */ - public static CredentialsProvider prepareSession( ScmLogger logger, Git git, GitScmProviderRepository repository ) - { - StoredConfig config = git.getRepository( ).getConfig( ); - config.setString( "remote", "origin", "url", repository.getFetchUrl( ) ); - config.setString( "remote", "origin", "pushURL", repository.getPushUrl( ) ); - - // make sure we do not log any passwords to the output - String password = StringUtils.isNotBlank( repository.getPassword( ) ) ? repository.getPassword( ).trim( ) - : "no-pwd-defined"; - logger.info( "fetch url: " + repository.getFetchUrl( ).replace( password, "******" ) ); - logger.info( "push url: " + repository.getPushUrl( ).replace( password, "******" ) ); - return getCredentials( repository ); - } - - /** - * Creates a credentials provider from the information passed in the - * repository. Current implementation supports:
      - *

    • UserName/Password
    • - *

      - * - * @param repository - * the config to get the details from - * @return null if there is not enough info to create a - * provider with - */ - public static CredentialsProvider getCredentials( GitScmProviderRepository repository ) - { - if ( StringUtils.isNotBlank( repository.getUser( ) ) && StringUtils.isNotBlank( repository.getPassword( ) ) ) - { - return new UsernamePasswordCredentialsProvider( repository.getUser( ).trim( ), - repository.getPassword( ).trim( ) ); - } - return null; - } - - public static Iterable push( ScmLogger logger, Git git, GitScmProviderRepository repo, RefSpec refSpec ) - throws GitAPIException, InvalidRemoteException, TransportException - { - CredentialsProvider credentials = JGitUtils.prepareSession( logger, git, repo ); - Iterable pushResultList = git.push( ) - .setCredentialsProvider( credentials ) - .setRefSpecs( refSpec ) - .call( ); - for ( PushResult pushResult : pushResultList ) - { - Collection ru = pushResult.getRemoteUpdates( ); - for ( RemoteRefUpdate remoteRefUpdate : ru ) - { - logger.info( remoteRefUpdate.getStatus( ) + " - " + remoteRefUpdate.toString( ) ); - } - } - return pushResultList; - } - - /** - * Does the Repository have any commits? - * - * @param repo - * @return false if there are no commits - */ - public static boolean hasCommits( Repository repo ) - { - if ( repo != null && repo.getDirectory( ).exists( ) ) - { - return ( new File( repo.getDirectory( ), "objects" ).list( ).length > 2 ) - || ( new File( repo.getDirectory( ), "objects/pack" ).list( ).length > 0 ); - } - return false; - } - - /** - * get a list of all files in the given commit - * - * @param repository - * the repo - * @param commit - * the commit to get the files from - * @return a list of files included in the commit - * @throws MissingObjectException - * @throws IncorrectObjectTypeException - * @throws CorruptObjectException - * @throws IOException - */ - public static List getFilesInCommit( Repository repository, RevCommit commit ) - throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException, IOException - { - List list = new ArrayList( ); - if ( JGitUtils.hasCommits( repository ) ) - { - RevWalk rw = new RevWalk( repository ); - RevCommit realParant = commit.getParentCount( ) > 0 ? commit.getParent( 0 ) : commit; - RevCommit parent = rw.parseCommit( realParant.getId( ) ); - DiffFormatter df = new DiffFormatter( DisabledOutputStream.INSTANCE ); - df.setRepository( repository ); - df.setDiffComparator( RawTextComparator.DEFAULT ); - df.setDetectRenames( true ); - List diffs = df.scan( parent.getTree( ), commit.getTree( ) ); - for ( DiffEntry diff : diffs ) - { - list.add( new ScmFile( diff.getNewPath( ), ScmFileStatus.CHECKED_IN ) ); - } - closeDiffFormatter( df ); - closeRevWalk( rw ); - } - return list; - } - - /** - * Translate a {@code FileStatus} in the matching {@code ScmFileStatus}. - * - * @param changeType - * @return the matching ScmFileStatus - */ - public static ScmFileStatus getScmFileStatus( ChangeType changeType ) - { - switch ( changeType ) - { - case ADD : - return ScmFileStatus.ADDED; - case MODIFY : - return ScmFileStatus.MODIFIED; - case DELETE : - return ScmFileStatus.DELETED; - case RENAME : - return ScmFileStatus.RENAMED; - case COPY : - return ScmFileStatus.COPIED; - default : - return ScmFileStatus.UNKNOWN; - } - } - - /** - * Adds all files in the given fileSet to the repository. - * - * @param git - * the repo to add the files to - * @param fileSet - * the set of files within the workspace, the files are added - * relative to the basedir of this fileset - * @return a list of added files - * @throws GitAPIException - * @throws NoFilepatternException - */ - public static List addAllFiles( Git git, ScmFileSet fileSet ) - throws GitAPIException, NoFilepatternException - { - URI baseUri = fileSet.getBasedir( ).toURI( ); - AddCommand add = git.add( ); - for ( File file : fileSet.getFileList( ) ) - { - if ( !file.isAbsolute( ) ) - { - file = new File( fileSet.getBasedir( ).getPath( ), file.getPath( ) ); - } - - if ( file.exists( ) ) - { - String path = relativize( baseUri, file ); - add.addFilepattern( path ); - add.addFilepattern( file.getAbsolutePath( ) ); - } - } - add.call( ); - - Status status = git.status( ).call( ); - - Set allInIndex = new HashSet( ); - allInIndex.addAll( status.getAdded( ) ); - allInIndex.addAll( status.getChanged( ) ); - - // System.out.println("All in index: "+allInIndex.size()); - - List addedFiles = new ArrayList( allInIndex.size( ) ); - - // rewrite all detected files to now have status 'checked_in' - for ( String entry : allInIndex ) - { - ScmFile scmfile = new ScmFile( entry, ScmFileStatus.ADDED ); - - // if a specific fileSet is given, we have to check if the file is - // really tracked - for ( Iterator itfl = fileSet.getFileList( ).iterator( ); itfl.hasNext( ); ) - { - String path = FilenameUtils.normalizeFilename( relativize( baseUri, itfl.next( ) ) ); - if ( path.equals( FilenameUtils.normalizeFilename( scmfile.getPath( ) ) ) ) - { - addedFiles.add( scmfile ); - } - } - } - return addedFiles; - } - - private static String relativize( URI baseUri, File f ) - { - String path = f.getPath( ); - if ( f.isAbsolute( ) ) - { - path = baseUri.relativize( new File( path ).toURI( ) ).getPath( ); - } - return path; - } - - /** - * Get a list of commits between two revisions. - * - * @param repo - * the repository to work on - * @param sortings - * sorting - * @param fromRev - * start revision - * @param toRev - * if null, falls back to head - * @param fromDate - * from which date on - * @param toDate - * until which date - * @param maxLines - * max number of lines - * @return a list of commits, might be empty, but never null - * @throws IOException - * @throws MissingObjectException - * @throws IncorrectObjectTypeException - */ - public static List getRevCommits( Repository repo, RevSort[] sortings, String fromRev, String toRev, - final Date fromDate, final Date toDate, int maxLines ) - throws IOException, MissingObjectException, IncorrectObjectTypeException - { - - List revs = new ArrayList( ); - RevWalk walk = new RevWalk( repo ); - - ObjectId fromRevId = fromRev != null ? repo.resolve( fromRev ) : null; - ObjectId toRevId = toRev != null ? repo.resolve( toRev ) : null; - - if ( sortings == null || sortings.length == 0 ) - { - sortings = new RevSort[]{ - RevSort.TOPO, RevSort.COMMIT_TIME_DESC - }; - } - - for ( final RevSort s : sortings ) - { - walk.sort( s, true ); - } - - if ( fromDate != null && toDate != null ) - { - // walk.setRevFilter( CommitTimeRevFilter.between( fromDate, toDate - // ) ); - walk.setRevFilter( new RevFilter( ) { - - @Override - public boolean include( RevWalk walker, RevCommit cmit ) - throws StopWalkException, MissingObjectException, IncorrectObjectTypeException, IOException - { - int cmtTime = cmit.getCommitTime( ); - - return ( cmtTime >= ( fromDate.getTime( ) / 1000 ) ) && ( cmtTime <= ( toDate.getTime( ) / 1000 ) ); - } - - @Override - public RevFilter clone( ) - { - return this; - } - } ); - } - else - { - if ( fromDate != null ) - { - walk.setRevFilter( CommitTimeRevFilter.after( fromDate ) ); - } - if ( toDate != null ) - { - walk.setRevFilter( CommitTimeRevFilter.before( toDate ) ); - } - } - - if ( fromRevId != null ) - { - RevCommit c = walk.parseCommit( fromRevId ); - c.add( RevFlag.UNINTERESTING ); - RevCommit real = walk.parseCommit( c ); - walk.markUninteresting( real ); - } - - if ( toRevId != null ) - { - RevCommit c = walk.parseCommit( toRevId ); - c.remove( RevFlag.UNINTERESTING ); - RevCommit real = walk.parseCommit( c ); - walk.markStart( real ); - } - else - { - final ObjectId head = repo.resolve( Constants.HEAD ); - if ( head == null ) - { - closeRevWalk( walk ); - throw new RuntimeException( "Cannot resolve " + Constants.HEAD ); - } - RevCommit real = walk.parseCommit( head ); - walk.markStart( real ); - } - - int n = 0; - for ( final RevCommit c : walk ) - { - n++; - if ( maxLines != -1 && n > maxLines ) - { - break; - } - - revs.add( c ); - } - closeRevWalk( walk ); - return revs; - } - - public static void closeDiffFormatter( DiffFormatter df ) - { - ReflectionUtils.invokeMethod( df, "close", new Class[0], new Object[0] ); - ReflectionUtils.invokeMethod( df, "release", new Class[0], new Object[0] ); - } - - public static void closeRevWalk( RevWalk rw ) - { - ReflectionUtils.invokeMethod( rw, "close", new Class[0], new Object[0] ); - ReflectionUtils.invokeMethod( rw, "release", new Class[0], new Object[0] ); - } - - public static void closeTreeWalk( TreeWalk walk ) - { - ReflectionUtils.invokeMethod( walk, "close", new Class[0], new Object[0] ); - ReflectionUtils.invokeMethod( walk, "release", new Class[0], new Object[0] ); - } - - public static void closeObjectReader( ObjectReader or ) - { - ReflectionUtils.invokeMethod( or, "close", new Class[0], new Object[0] ); - ReflectionUtils.invokeMethod( or, "release", new Class[0], new Object[0] ); - } - -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/command/add/JGitAddCommand.java b/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/command/add/JGitAddCommand.java deleted file mode 100644 index abe93844..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/command/add/JGitAddCommand.java +++ /dev/null @@ -1,85 +0,0 @@ - -package org.apache.maven.scm.provider.git.jgit.command.add; - -import java.util.List; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.scm.ScmException; -import org.apache.maven.scm.ScmFile; -import org.apache.maven.scm.ScmFileSet; -import org.apache.maven.scm.ScmResult; -import org.apache.maven.scm.command.add.AbstractAddCommand; -import org.apache.maven.scm.command.add.AddScmResult; -import org.apache.maven.scm.provider.ScmProviderRepository; -import org.apache.maven.scm.provider.git.command.GitCommand; -import org.apache.maven.scm.provider.git.jgit.command.JGitUtils; -import org.eclipse.jgit.api.Git; - -/** - * @author Mark Struberg - * @author Dominik Bartholdi (imod) - * @since 1.9 - */ -public class JGitAddCommand extends AbstractAddCommand implements GitCommand -{ - - /** - * {@inheritDoc} - */ - @Override - protected ScmResult executeAddCommand( ScmProviderRepository repo, ScmFileSet fileSet, String message, - boolean binary ) throws ScmException - { - - if ( fileSet.getFileList( ).isEmpty( ) ) - { - throw new ScmException( "You must provide at least one file/directory to add (e.g. -Dincludes=...)" ); - } - Git git = null; - try - { - git = Git.open( fileSet.getBasedir( ) ); - - List addedFiles = JGitUtils.addAllFiles( git, fileSet ); - - if ( getLogger( ).isDebugEnabled( ) ) - { - for ( ScmFile scmFile : addedFiles ) - { - getLogger( ).info( "added file: " + scmFile ); - } - } - - return new AddScmResult( "JGit add", addedFiles ); - - } - catch ( Exception e ) - { - throw new ScmException( "JGit add failure!", e ); - } - finally - { - JGitUtils.closeRepo( git ); - } - - } - -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/command/blame/JGitBlameCommand.java b/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/command/blame/JGitBlameCommand.java deleted file mode 100644 index 15ec2e7a..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/command/blame/JGitBlameCommand.java +++ /dev/null @@ -1,80 +0,0 @@ - -package org.apache.maven.scm.provider.git.jgit.command.blame; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.scm.ScmException; -import org.apache.maven.scm.ScmFileSet; -import org.apache.maven.scm.command.blame.AbstractBlameCommand; -import org.apache.maven.scm.command.blame.BlameLine; -import org.apache.maven.scm.command.blame.BlameScmResult; -import org.apache.maven.scm.provider.ScmProviderRepository; -import org.apache.maven.scm.provider.git.command.GitCommand; -import org.apache.maven.scm.provider.git.jgit.command.JGitUtils; -import org.eclipse.jgit.api.Git; -import org.eclipse.jgit.blame.BlameResult; - -/** - * @author Dominik Bartholdi (imod) - * @since 1.9 - */ -public class JGitBlameCommand extends AbstractBlameCommand implements GitCommand -{ - - @Override - public BlameScmResult executeBlameCommand( ScmProviderRepository repo, ScmFileSet workingDirectory, - String filename ) throws ScmException - { - - Git git = null; - File basedir = workingDirectory.getBasedir( ); - try - { - git = Git.open( basedir ); - BlameResult blameResult = git.blame( ).setFilePath( filename ).call( ); - - List lines = new ArrayList( ); - - int i = 0; - while ( ( i = blameResult.computeNext( ) ) != -1 ) - { - lines.add( new BlameLine( blameResult.getSourceAuthor( i ).getWhen( ), - blameResult.getSourceCommit( i ).getName( ), - blameResult.getSourceAuthor( i ).getName( ), - blameResult.getSourceCommitter( i ).getName( ) ) ); - } - - return new BlameScmResult( "JGit blame", lines ); - } - catch ( Exception e ) - { - throw new ScmException( "JGit blame failure!", e ); - } - finally - { - JGitUtils.closeRepo( git ); - } - } - -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/command/branch/JGitBranchCommand.java b/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/command/branch/JGitBranchCommand.java deleted file mode 100644 index 76b264e5..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/command/branch/JGitBranchCommand.java +++ /dev/null @@ -1,148 +0,0 @@ - -package org.apache.maven.scm.provider.git.jgit.command.branch; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.scm.ScmException; -import org.apache.maven.scm.ScmFile; -import org.apache.maven.scm.ScmFileSet; -import org.apache.maven.scm.ScmFileStatus; -import org.apache.maven.scm.ScmResult; -import org.apache.maven.scm.command.branch.AbstractBranchCommand; -import org.apache.maven.scm.command.branch.BranchScmResult; -import org.apache.maven.scm.provider.ScmProviderRepository; -import org.apache.maven.scm.provider.git.command.GitCommand; -import org.apache.maven.scm.provider.git.jgit.command.JGitUtils; -import org.apache.maven.scm.provider.git.repository.GitScmProviderRepository; -import org.codehaus.plexus.util.StringUtils; -import org.eclipse.jgit.api.Git; -import org.eclipse.jgit.api.errors.GitAPIException; -import org.eclipse.jgit.lib.Constants; -import org.eclipse.jgit.lib.Ref; -import org.eclipse.jgit.lib.Repository; -import org.eclipse.jgit.revwalk.RevCommit; -import org.eclipse.jgit.revwalk.RevWalk; -import org.eclipse.jgit.transport.RefSpec; -import org.eclipse.jgit.treewalk.TreeWalk; - -/** - * @author Dominik Bartholdi (imod) - * @since 1.9 - */ -public class JGitBranchCommand extends AbstractBranchCommand implements GitCommand -{ - - /** - * {@inheritDoc} - */ - @Override - protected ScmResult executeBranchCommand( ScmProviderRepository repo, ScmFileSet fileSet, String branch, - String message ) throws ScmException - { - if ( branch == null || StringUtils.isEmpty( branch.trim( ) ) ) - { - throw new ScmException( "branch name must be specified" ); - } - - if ( !fileSet.getFileList( ).isEmpty( ) ) - { - throw new ScmException( "This provider doesn't support branching subsets of a directory" ); - } - - Git git = null; - try - { - git = Git.open( fileSet.getBasedir( ) ); - Ref branchResult = git.branchCreate( ).setName( branch ).call( ); - getLogger( ).info( "created [" + branchResult.getName( ) + "]" ); - - if ( getLogger( ).isDebugEnabled( ) ) - { - for ( String branchName : getShortLocalBranchNames( git ) ) - { - getLogger( ).debug( "local branch available: " + branchName ); - } - } - - if ( repo.isPushChanges( ) ) - { - getLogger( ).info( "push branch [" + branch + "] to remote..." ); - JGitUtils.push( getLogger( ), - git, - (GitScmProviderRepository) repo, - new RefSpec( Constants.R_HEADS + branch ) ); - } - - // search for the tagged files - final RevWalk revWalk = new RevWalk( git.getRepository( ) ); - RevCommit commit = revWalk.parseCommit( branchResult.getObjectId( ) ); - JGitUtils.closeRevWalk( revWalk ); - - final TreeWalk walk = new TreeWalk( git.getRepository( ) ); - walk.reset( ); // drop the first empty tree, which we do not need - // here - walk.setRecursive( true ); - walk.addTree( commit.getTree( ) ); - - List files = new ArrayList( ); - while ( walk.next( ) ) - { - files.add( new ScmFile( walk.getPathString( ), ScmFileStatus.CHECKED_OUT ) ); - } - JGitUtils.closeTreeWalk( walk ); - - return new BranchScmResult( "JGit branch", files ); - - } - catch ( Exception e ) - { - throw new ScmException( "JGit branch failed!", e ); - } - finally - { - JGitUtils.closeRepo( git ); - } - } - - /** - * gets a set of names of the available branches in the given repo - * - * @param git - * the repo to list the branches for - * @return set of short branch names - * @throws GitAPIException - */ - public static Set getShortLocalBranchNames( Git git ) throws GitAPIException - { - Set branches = new HashSet( ); - Iterator iter = git.branchList( ).call( ).iterator( ); - while ( iter.hasNext( ) ) - { - branches.add( Repository.shortenRefName( iter.next( ).getName( ) ) ); - } - return branches; - } -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/command/changelog/JGitChangeLogCommand.java b/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/command/changelog/JGitChangeLogCommand.java deleted file mode 100644 index c4ca7da8..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/command/changelog/JGitChangeLogCommand.java +++ /dev/null @@ -1,291 +0,0 @@ - -package org.apache.maven.scm.provider.git.jgit.command.changelog; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.scm.ChangeSet; -import org.apache.maven.scm.ScmBranch; -import org.apache.maven.scm.ScmException; -import org.apache.maven.scm.ScmFileSet; -import org.apache.maven.scm.ScmVersion; -import org.apache.maven.scm.command.changelog.AbstractChangeLogCommand; -import org.apache.maven.scm.command.changelog.ChangeLogScmResult; -import org.apache.maven.scm.command.changelog.ChangeLogSet; -import org.apache.maven.scm.provider.ScmProviderRepository; -import org.apache.maven.scm.provider.git.command.GitCommand; -import org.apache.maven.scm.provider.git.jgit.command.JGitUtils; -import org.eclipse.jgit.api.Git; -import org.eclipse.jgit.errors.IncorrectObjectTypeException; -import org.eclipse.jgit.errors.MissingObjectException; -import org.eclipse.jgit.lib.Repository; -import org.eclipse.jgit.revwalk.RevCommit; -import org.eclipse.jgit.revwalk.RevSort; - -/** - * @author Mark Struberg - * @author Dominik Bartholdi (imod) - * @since 1.9 - */ -public class JGitChangeLogCommand extends AbstractChangeLogCommand implements GitCommand -{ - - /** - * {@inheritDoc} - */ - @Override - protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repo, ScmFileSet fileSet, - ScmVersion startVersion, ScmVersion endVersion, String datePattern ) throws ScmException - { - return executeChangeLogCommand( repo, fileSet, null, null, null, datePattern, startVersion, endVersion ); - } - - /** - * {@inheritDoc} - */ - @Override - protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repo, ScmFileSet fileSet, - Date startDate, Date endDate, ScmBranch branch, String datePattern ) throws ScmException - { - return executeChangeLogCommand( repo, fileSet, startDate, endDate, branch, datePattern, null, null ); - } - - protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repo, ScmFileSet fileSet, - Date startDate, Date endDate, ScmBranch branch, String datePattern, ScmVersion startVersion, - ScmVersion endVersion ) throws ScmException - { - Git git = null; - try - { - git = Git.open( fileSet.getBasedir( ) ); - - String startRev = startVersion != null ? startVersion.getName( ) : null; - String endRev = endVersion != null ? endVersion.getName( ) : null; - - List gitChanges = this - .whatchanged( git.getRepository( ), null, startRev, endRev, startDate, endDate, -1 ); - - List modifications = new ArrayList( gitChanges.size( ) ); - - for ( ChangeEntry change : gitChanges ) - { - ChangeSet scmChange = new ChangeSet( ); - - scmChange.setAuthor( change.getAuthorName( ) ); - scmChange.setComment( change.getBody( ) ); - scmChange.setDate( change.getAuthorDate( ) ); - scmChange.setRevision( change.getCommitHash( ) ); - // X TODO scmChange.setFiles( change.get ) - - modifications.add( scmChange ); - } - - ChangeLogSet changeLogSet = new ChangeLogSet( modifications, startDate, endDate ); - changeLogSet.setStartVersion( startVersion ); - changeLogSet.setEndVersion( endVersion ); - - return new ChangeLogScmResult( "JGit changelog", changeLogSet ); - } - catch ( Exception e ) - { - throw new ScmException( "JGit changelog failure!", e ); - } - finally - { - JGitUtils.closeRepo( git ); - } - } - - public List whatchanged( Repository repo, RevSort[] sortings, String fromRev, String toRev, - Date fromDate, Date toDate, int maxLines ) - throws MissingObjectException, IncorrectObjectTypeException, IOException - { - List revs = JGitUtils.getRevCommits( repo, sortings, fromRev, toRev, fromDate, toDate, maxLines ); - List changes = new ArrayList( revs.size( ) ); - - for ( RevCommit c : revs ) - { - ChangeEntry ce = new ChangeEntry( ); - - ce.setAuthorDate( c.getAuthorIdent( ).getWhen( ) ); - ce.setAuthorEmail( c.getAuthorIdent( ).getEmailAddress( ) ); - ce.setAuthorName( c.getAuthorIdent( ).getName( ) ); - ce.setCommitterDate( c.getCommitterIdent( ).getWhen( ) ); - ce.setCommitterEmail( c.getCommitterIdent( ).getEmailAddress( ) ); - ce.setCommitterName( c.getCommitterIdent( ).getName( ) ); - - ce.setSubject( c.getShortMessage( ) ); - ce.setBody( c.getFullMessage( ) ); - - ce.setCommitHash( c.getId( ).name( ) ); - ce.setTreeHash( c.getTree( ).getId( ).name( ) ); - - // X TODO missing: file list - - changes.add( ce ); - } - - return changes; - } - - /** - * - */ - public static final class ChangeEntry - { - - private String commitHash; - - private String treeHash; - - private String authorName; - - private String authorEmail; - - private Date authorDate; - - private String committerName; - - private String committerEmail; - - private Date committerDate; - - private String subject; - - private String body; - - private List files; - - public String getCommitHash( ) - { - return commitHash; - } - - public void setCommitHash( String commitHash ) - { - this.commitHash = commitHash; - } - - public String getTreeHash( ) - { - return treeHash; - } - - public void setTreeHash( String treeHash ) - { - this.treeHash = treeHash; - } - - public String getAuthorName( ) - { - return authorName; - } - - public void setAuthorName( String authorName ) - { - this.authorName = authorName; - } - - public String getAuthorEmail( ) - { - return authorEmail; - } - - public void setAuthorEmail( String authorEmail ) - { - this.authorEmail = authorEmail; - } - - public Date getAuthorDate( ) - { - return authorDate; - } - - public void setAuthorDate( Date authorDate ) - { - this.authorDate = authorDate; - } - - public String getCommitterName( ) - { - return committerName; - } - - public void setCommitterName( String committerName ) - { - this.committerName = committerName; - } - - public String getCommitterEmail( ) - { - return committerEmail; - } - - public void setCommitterEmail( String committerEmail ) - { - this.committerEmail = committerEmail; - } - - public Date getCommitterDate( ) - { - return committerDate; - } - - public void setCommitterDate( Date committerDate ) - { - this.committerDate = committerDate; - } - - public String getSubject( ) - { - return subject; - } - - public void setSubject( String subject ) - { - this.subject = subject; - } - - public String getBody( ) - { - return body; - } - - public void setBody( String body ) - { - this.body = body; - } - - public List getFiles( ) - { - return files; - } - - public void setFiles( List files ) - { - this.files = files; - } - } -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/command/checkin/JGitCheckInCommand.java b/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/command/checkin/JGitCheckInCommand.java deleted file mode 100644 index 890b27af..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/command/checkin/JGitCheckInCommand.java +++ /dev/null @@ -1,289 +0,0 @@ - -package org.apache.maven.scm.provider.git.jgit.command.checkin; - -import java.io.File; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.util.Collections; -import java.util.List; -import java.util.Set; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.scm.ScmException; -import org.apache.maven.scm.ScmFile; -import org.apache.maven.scm.ScmFileSet; -import org.apache.maven.scm.ScmVersion; -import org.apache.maven.scm.command.checkin.AbstractCheckInCommand; -import org.apache.maven.scm.command.checkin.CheckInScmResult; -import org.apache.maven.scm.provider.ScmProviderRepository; -import org.apache.maven.scm.provider.git.command.GitCommand; -import org.apache.maven.scm.provider.git.jgit.command.JGitUtils; -import org.apache.maven.scm.provider.git.repository.GitScmProviderRepository; -import org.codehaus.plexus.util.StringUtils; -import org.eclipse.jgit.api.AddCommand; -import org.eclipse.jgit.api.CommitCommand; -import org.eclipse.jgit.api.Git; -import org.eclipse.jgit.lib.Constants; -import org.eclipse.jgit.lib.UserConfig; -import org.eclipse.jgit.revwalk.RevCommit; -import org.eclipse.jgit.transport.RefSpec; - -/** - * This provider uses the following strategy to discover the committer and - * author name/mail for a commit: - *

        - *
      1. "user" section in .gitconfig
      2. - *
      3. "username" passed to maven execution
      4. - *
      5. default git config (system user and hostname for email)
      6. - *
      - * the "maven-scm" config can be configured like this:
      - * the default email domain to be used (will be used to create an email from the - * username passed to maven):
      - * git config --global maven-scm.maildomain mycomp.com
      - * you can also enforce the usage of the username for the author and - * committer:
      - * git config --global maven-scm.forceUsername true
      - * - * @author Mark Struberg - * @author Dominik Bartholdi (imod) - * @since 1.9 - */ -public class JGitCheckInCommand extends AbstractCheckInCommand implements GitCommand -{ - - protected static final String GIT_MAVEN_SECTION = "maven-scm"; - - protected static final String GIT_MAILDOMAIN = "maildomain"; - - protected static final String GIT_FORCE = "forceUsername"; - - /** - * {@inheritDoc} - */ - @Override - protected CheckInScmResult executeCheckInCommand( ScmProviderRepository repo, ScmFileSet fileSet, String message, - ScmVersion version ) throws ScmException - { - - Git git = null; - try - { - File basedir = fileSet.getBasedir( ); - git = Git.open( basedir ); - - boolean doCommit = false; - - if ( !fileSet.getFileList( ).isEmpty( ) ) - { - doCommit = JGitUtils.addAllFiles( git, fileSet ).size( ) > 0; - } - else - { - // add all tracked files which are modified manually - Set changeds = git.status( ).call( ).getModified( ); - if ( changeds.isEmpty( ) ) - { - // warn there is nothing to add - getLogger( ).warn( "there are no files to be added" ); - doCommit = false; - } - else - { - AddCommand add = git.add( ); - for ( String changed : changeds ) - { - getLogger( ).debug( "add manualy: " + changed ); - add.addFilepattern( changed ); - doCommit = true; - } - add.call( ); - } - } - - List checkedInFiles = Collections.emptyList( ); - if ( doCommit ) - { - UserInfo author = getAuthor( repo, git ); - UserInfo committer = getCommitter( repo, git ); - - CommitCommand command = git.commit( ).setMessage( message ).setAuthor( author.name, author.email ); - command.setCommitter( committer.name, committer.email ); - RevCommit commitRev = command.call( ); - - getLogger( ).info( "commit done: " + commitRev.getShortMessage( ) ); - checkedInFiles = JGitUtils.getFilesInCommit( git.getRepository( ), commitRev ); - if ( getLogger( ).isDebugEnabled( ) ) - { - for ( ScmFile scmFile : checkedInFiles ) - { - getLogger( ).debug( "in commit: " + scmFile ); - } - } - } - - if ( repo.isPushChanges( ) ) - { - String branch = version != null ? version.getName( ) : null; - if ( StringUtils.isBlank( branch ) ) - { - branch = git.getRepository( ).getBranch( ); - } - RefSpec refSpec = new RefSpec( Constants.R_HEADS + branch + ":" + Constants.R_HEADS + branch ); - getLogger( ).info( "push changes to remote... " + refSpec.toString( ) ); - JGitUtils.push( getLogger( ), git, (GitScmProviderRepository) repo, refSpec ); - } - - return new CheckInScmResult( "JGit checkin", checkedInFiles ); - } - catch ( Exception e ) - { - throw new ScmException( "JGit checkin failure!", e ); - } - finally - { - JGitUtils.closeRepo( git ); - } - } - - private static final class UserInfo - { - - final String name; - - final String email; - - public UserInfo( String name, String email ) - { - this.name = name; - this.email = email; - } - } - - private UserInfo getCommitter( ScmProviderRepository repo, Git git ) - { - boolean forceMvnUser = git.getRepository( ).getConfig( ).getBoolean( GIT_MAVEN_SECTION, GIT_FORCE, false ); - - // git config - UserConfig user = git.getRepository( ).getConfig( ).get( UserConfig.KEY ); - String committerName = null; - if ( !forceMvnUser && !user.isCommitterNameImplicit( ) ) - { - committerName = user.getCommitterName( ); - } - - // mvn parameter - if ( StringUtils.isBlank( committerName ) ) - { - committerName = repo.getUser( ); - } - - // git default - if ( StringUtils.isBlank( committerName ) ) - { - committerName = user.getCommitterName( ); - } - - // git config - String committerMail = null; - if ( !user.isCommitterEmailImplicit( ) ) - { - committerMail = user.getCommitterEmail( ); - } - - if ( StringUtils.isBlank( committerMail ) ) - { - String defaultDomain = git.getRepository( ).getConfig( ).getString( GIT_MAVEN_SECTION, - null, - GIT_MAILDOMAIN ); - defaultDomain = StringUtils.isNotBlank( defaultDomain ) ? defaultDomain : getHostname( ); - - // mvn parameter (constructed with username) or git default - committerMail = StringUtils.isNotBlank( repo.getUser( ) ) ? repo.getUser( ) + "@" + defaultDomain - : user.getCommitterEmail( ); - } - - return new UserInfo( committerName, committerMail ); - } - - private UserInfo getAuthor( ScmProviderRepository repo, Git git ) - { - boolean forceMvnUser = git.getRepository( ).getConfig( ).getBoolean( GIT_MAVEN_SECTION, GIT_FORCE, false ); - - // git config - UserConfig user = git.getRepository( ).getConfig( ).get( UserConfig.KEY ); - String authorName = null; - if ( !forceMvnUser && !user.isAuthorNameImplicit( ) ) - { - authorName = user.getAuthorName( ); - } - - // mvn parameter - if ( StringUtils.isBlank( authorName ) ) - { - authorName = repo.getUser( ); - } - - // git default - if ( StringUtils.isBlank( authorName ) ) - { - authorName = user.getAuthorName( ); - } - - // git config - String authorMail = null; - if ( !user.isAuthorEmailImplicit( ) ) - { - authorMail = user.getAuthorEmail( ); - } - - if ( StringUtils.isBlank( authorMail ) ) - { - String defaultDomain = git.getRepository( ).getConfig( ).getString( GIT_MAVEN_SECTION, - null, - GIT_MAILDOMAIN ); - defaultDomain = StringUtils.isNotBlank( defaultDomain ) ? defaultDomain : getHostname( ); - - // mvn parameter (constructed with username) or git default - authorMail = StringUtils.isNotBlank( repo.getUser( ) ) ? repo.getUser( ) + "@" + defaultDomain - : user.getAuthorEmail( ); - } - - return new UserInfo( authorName, authorMail ); - } - - private String getHostname( ) - { - String hostname; - try - { - InetAddress localhost = java.net.InetAddress.getLocalHost( ); - hostname = localhost.getHostName( ); - } - catch ( UnknownHostException e ) - { - getLogger( ).warn( - "failed to resolve hostname to create mail address, " + "defaulting to 'maven-scm-provider-jgit'" ); - hostname = "maven-scm-provider-jgit"; - } - return hostname; - } - -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/command/checkout/JGitCheckOutCommand.java b/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/command/checkout/JGitCheckOutCommand.java deleted file mode 100644 index e941b40c..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/command/checkout/JGitCheckOutCommand.java +++ /dev/null @@ -1,207 +0,0 @@ - -package org.apache.maven.scm.provider.git.jgit.command.checkout; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.scm.ScmException; -import org.apache.maven.scm.ScmFile; -import org.apache.maven.scm.ScmFileSet; -import org.apache.maven.scm.ScmFileStatus; -import org.apache.maven.scm.ScmTag; -import org.apache.maven.scm.ScmVersion; -import org.apache.maven.scm.command.checkout.AbstractCheckOutCommand; -import org.apache.maven.scm.command.checkout.CheckOutScmResult; -import org.apache.maven.scm.command.remoteinfo.RemoteInfoScmResult; -import org.apache.maven.scm.provider.ScmProviderRepository; -import org.apache.maven.scm.provider.git.command.GitCommand; -import org.apache.maven.scm.provider.git.jgit.command.JGitUtils; -import org.apache.maven.scm.provider.git.jgit.command.branch.JGitBranchCommand; -import org.apache.maven.scm.provider.git.jgit.command.remoteinfo.JGitRemoteInfoCommand; -import org.apache.maven.scm.provider.git.repository.GitScmProviderRepository; -import org.codehaus.plexus.util.StringUtils; -import org.eclipse.jgit.api.CloneCommand; -import org.eclipse.jgit.api.Git; -import org.eclipse.jgit.lib.Constants; -import org.eclipse.jgit.lib.ProgressMonitor; -import org.eclipse.jgit.revwalk.RevCommit; -import org.eclipse.jgit.revwalk.RevWalk; -import org.eclipse.jgit.storage.file.WindowCacheConfig; -import org.eclipse.jgit.transport.CredentialsProvider; -import org.eclipse.jgit.treewalk.TreeWalk; -import org.sf.feeling.decompiler.util.ReflectionUtils; - -/** - * @author Mark Struberg - * @author Dominik Bartholdi (imod) - * @since 1.9 - */ -public class JGitCheckOutCommand extends AbstractCheckOutCommand implements GitCommand -{ - - /** - * For git, the given repository is a remote one. We have to clone it first - * if the working directory does not contain a git repo yet, otherwise we - * have to git-pull it. - *

      - * {@inheritDoc} - */ - @Override - protected CheckOutScmResult executeCheckOutCommand( ScmProviderRepository repo, ScmFileSet fileSet, - ScmVersion version, boolean recursive ) throws ScmException - { - GitScmProviderRepository repository = (GitScmProviderRepository) repo; - - if ( GitScmProviderRepository.PROTOCOL_FILE.equals( repository.getFetchInfo( ).getProtocol( ) ) - && repository.getFetchInfo( ).getPath( ).indexOf( fileSet.getBasedir( ).getPath( ) ) >= 0 ) - { - throw new ScmException( "remote repository must not be the working directory" ); - } - - Git git = null; - try - { - - ProgressMonitor monitor = JGitUtils.getMonitor( getLogger( ) ); - - String branch = version != null ? version.getName( ) : null; - - if ( StringUtils.isBlank( branch ) ) - { - branch = Constants.MASTER; - } - - getLogger( ).debug( "try checkout of branch: " + branch ); - - if ( !fileSet.getBasedir( ).exists( ) || !( new File( fileSet.getBasedir( ), ".git" ).exists( ) ) ) - { - if ( fileSet.getBasedir( ).exists( ) ) - { - // git refuses to clone otherwise - fileSet.getBasedir( ).delete( ); - } - - // FIXME only if windauze - WindowCacheConfig cfg = new WindowCacheConfig( ); - cfg.setPackedGitMMAP( false ); - ReflectionUtils.invokeMethod( cfg, "install", new Class[0], new Object[0] ); - - // no git repo seems to exist, let's clone the original repo - CredentialsProvider credentials = JGitUtils.getCredentials( (GitScmProviderRepository) repo ); - getLogger( ).info( "cloning [" + branch + "] to " + fileSet.getBasedir( ) ); - CloneCommand command = Git.cloneRepository( ).setURI( repository.getFetchUrl( ) ); - command.setCredentialsProvider( credentials ).setBranch( branch ).setDirectory( fileSet.getBasedir( ) ); - command.setProgressMonitor( monitor ); - git = command.call( ); - } - - JGitRemoteInfoCommand remoteInfoCommand = new JGitRemoteInfoCommand( ); - remoteInfoCommand.setLogger( getLogger( ) ); - RemoteInfoScmResult result = remoteInfoCommand.executeRemoteInfoCommand( repository, fileSet, null ); - - if ( git == null ) - { - git = Git.open( fileSet.getBasedir( ) ); - } - - if ( fileSet.getBasedir( ).exists( ) - && new File( fileSet.getBasedir( ), ".git" ).exists( ) - && result.getBranches( ).size( ) > 0 ) - { - // git repo exists, so we must git-pull the changes - CredentialsProvider credentials = JGitUtils.prepareSession( getLogger( ), git, repository ); - - if ( version != null && StringUtils.isNotEmpty( version.getName( ) ) && ( version instanceof ScmTag ) ) - { - // A tag will not be pulled but we only fetch all the - // commits from the upstream repo - // This is done because checking out a tag might not happen - // on the current branch - // but create a 'detached HEAD'. - // In fact, a tag in git may be in multiple branches. This - // occurs if - // you create a branch after the tag has been created - getLogger( ).debug( "fetch..." ); - git.fetch( ).setCredentialsProvider( credentials ).setProgressMonitor( monitor ).call( ); - } - else - { - getLogger( ).debug( "pull..." ); - git.pull( ).setCredentialsProvider( credentials ).setProgressMonitor( monitor ).call( ); - } - } - - Set localBranchNames = JGitBranchCommand.getShortLocalBranchNames( git ); - if ( version instanceof ScmTag ) - { - getLogger( ).info( "checkout tag [" + branch + "] at " + fileSet.getBasedir( ) ); - git.checkout( ).setName( branch ).call( ); - } - else if ( localBranchNames.contains( branch ) ) - { - getLogger( ).info( "checkout [" + branch + "] at " + fileSet.getBasedir( ) ); - git.checkout( ).setName( branch ).call( ); - } - else - { - getLogger( ).info( "checkout remote branch [" + branch + "] at " + fileSet.getBasedir( ) ); - git.checkout( ) - .setName( branch ) - .setCreateBranch( true ) - .setStartPoint( Constants.DEFAULT_REMOTE_NAME + "/" + branch ) - .call( ); - } - - RevWalk revWalk = new RevWalk( git.getRepository( ) ); - RevCommit commit = revWalk.parseCommit( git.getRepository( ).resolve( Constants.HEAD ) ); - JGitUtils.closeRevWalk( revWalk ); - - final TreeWalk walk = new TreeWalk( git.getRepository( ) ); - walk.reset( ); // drop the first empty tree, which we do not need - // here - walk.setRecursive( true ); - walk.addTree( commit.getTree( ) ); - - List listedFiles = new ArrayList( ); - while ( walk.next( ) ) - { - listedFiles.add( new ScmFile( walk.getPathString( ), ScmFileStatus.CHECKED_OUT ) ); - } - JGitUtils.closeTreeWalk( walk ); - - getLogger( ).debug( "current branch: " + git.getRepository( ).getBranch( ) ); - - return new CheckOutScmResult( "checkout via JGit", listedFiles ); - } - catch ( Exception e ) - { - throw new ScmException( "JGit checkout failure!", e ); - } - finally - { - JGitUtils.closeRepo( git ); - } - } - -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/command/diff/JGitDiffCommand.java b/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/command/diff/JGitDiffCommand.java deleted file mode 100644 index af8131f2..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/command/diff/JGitDiffCommand.java +++ /dev/null @@ -1,138 +0,0 @@ - -package org.apache.maven.scm.provider.git.jgit.command.diff; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.scm.ScmException; -import org.apache.maven.scm.ScmFileSet; -import org.apache.maven.scm.ScmVersion; -import org.apache.maven.scm.command.diff.AbstractDiffCommand; -import org.apache.maven.scm.command.diff.DiffScmResult; -import org.apache.maven.scm.provider.ScmProviderRepository; -import org.apache.maven.scm.provider.git.command.GitCommand; -import org.apache.maven.scm.provider.git.command.diff.GitDiffConsumer; -import org.apache.maven.scm.provider.git.jgit.command.JGitUtils; -import org.codehaus.plexus.util.StringUtils; -import org.eclipse.jgit.api.Git; -import org.eclipse.jgit.api.errors.GitAPIException; -import org.eclipse.jgit.lib.ObjectId; -import org.eclipse.jgit.lib.ObjectReader; -import org.eclipse.jgit.lib.Repository; -import org.eclipse.jgit.revwalk.RevWalk; -import org.eclipse.jgit.treewalk.AbstractTreeIterator; -import org.eclipse.jgit.treewalk.CanonicalTreeParser; - -/** - * @author Dominik Bartholdi (imod) - * @since 1.9 - */ -public class JGitDiffCommand extends AbstractDiffCommand implements GitCommand -{ - - @Override - protected DiffScmResult executeDiffCommand( ScmProviderRepository repository, ScmFileSet fileSet, - ScmVersion startRevision, ScmVersion endRevision ) throws ScmException - { - - Git git = null; - try - { - git = Git.open( fileSet.getBasedir( ) ); - DiffScmResult diff = callDiff( git, startRevision, endRevision ); - git.getRepository( ).close( ); - return diff; - } - catch ( Exception e ) - { - throw new ScmException( "JGit diff failure!", e ); - } - finally - { - JGitUtils.closeRepo( git ); - } - } - - public DiffScmResult callDiff( Git git, ScmVersion startRevision, ScmVersion endRevision ) - throws IOException, GitAPIException, ScmException - { - - AbstractTreeIterator oldTree = null; - if ( startRevision != null && StringUtils.isNotEmpty( startRevision.getName( ).trim( ) ) ) - { - String startRev = startRevision.getName( ).trim( ); - oldTree = getTreeIterator( git.getRepository( ), startRev ); - } - - AbstractTreeIterator newTree = null; - if ( endRevision != null && StringUtils.isNotEmpty( endRevision.getName( ).trim( ) ) ) - { - String endRev = endRevision.getName( ).trim( ); - newTree = getTreeIterator( git.getRepository( ), endRev ); - } - - OutputStream out = new ByteArrayOutputStream( ); - - git.diff( ).setOutputStream( out ).setOldTree( oldTree ).setNewTree( newTree ).setCached( false ).call( ); - git.diff( ).setOutputStream( out ).setOldTree( oldTree ).setNewTree( newTree ).setCached( true ).call( ); - - out.flush( ); - - GitDiffConsumer consumer = new GitDiffConsumer( getLogger( ), null ); - String fullDiff = out.toString( ); - out.close( ); - - String[] lines = fullDiff.split( "\n" ); - for ( String aLine : lines ) - { - consumer.consumeLine( aLine ); - } - - return new DiffScmResult( "JGit diff", - consumer.getChangedFiles( ), - consumer.getDifferences( ), - consumer.getPatch( ) ); - } - - private AbstractTreeIterator getTreeIterator( Repository repo, String name ) throws IOException - { - final ObjectId id = repo.resolve( name ); - if ( id == null ) - { - throw new IllegalArgumentException( name ); - } - final CanonicalTreeParser p = new CanonicalTreeParser( ); - final ObjectReader or = repo.newObjectReader( ); - try - { - RevWalk walk = new RevWalk( repo ); - p.reset( or, walk.parseTree( id ) ); - JGitUtils.closeRevWalk( walk ); - return p; - } - finally - { - JGitUtils.closeObjectReader( or ); - } - } -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/command/list/JGitListCommand.java b/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/command/list/JGitListCommand.java deleted file mode 100644 index 97e2b72f..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/command/list/JGitListCommand.java +++ /dev/null @@ -1,80 +0,0 @@ - -package org.apache.maven.scm.provider.git.jgit.command.list; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.scm.ScmException; -import org.apache.maven.scm.ScmFile; -import org.apache.maven.scm.ScmFileSet; -import org.apache.maven.scm.ScmFileStatus; -import org.apache.maven.scm.ScmVersion; -import org.apache.maven.scm.command.list.AbstractListCommand; -import org.apache.maven.scm.command.list.ListScmResult; -import org.apache.maven.scm.provider.ScmProviderRepository; -import org.apache.maven.scm.provider.git.command.GitCommand; -import org.apache.maven.scm.provider.git.jgit.command.JGitUtils; -import org.apache.maven.scm.provider.git.repository.GitScmProviderRepository; -import org.eclipse.jgit.api.Git; -import org.eclipse.jgit.lib.Ref; -import org.eclipse.jgit.transport.CredentialsProvider; - -/** - * @author Dominik Bartholdi (imod) - * @since 1.9 - */ -public class JGitListCommand extends AbstractListCommand implements GitCommand -{ - - @Override - protected ListScmResult executeListCommand( ScmProviderRepository repo, ScmFileSet fileSet, boolean recursive, - ScmVersion scmVersion ) throws ScmException - { - - Git git = null; - try - { - git = Git.open( fileSet.getBasedir( ) ); - CredentialsProvider credentials = JGitUtils - .prepareSession( getLogger( ), git, (GitScmProviderRepository) repo ); - - List list = new ArrayList( ); - Collection lsResult = git.lsRemote( ).setCredentialsProvider( credentials ).call( ); - for ( Ref ref : lsResult ) - { - getLogger( ).debug( ref.getObjectId( ).getName( ) + " " + ref.getTarget( ).getName( ) ); - list.add( new ScmFile( ref.getName( ), ScmFileStatus.CHECKED_IN ) ); - } - - return new ListScmResult( "JGit ls-remote", list ); - } - catch ( Exception e ) - { - throw new ScmException( "JGit ls-remote failure!", e ); - } - finally - { - JGitUtils.closeRepo( git ); - } - } -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/command/remoteinfo/JGitRemoteInfoCommand.java b/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/command/remoteinfo/JGitRemoteInfoCommand.java deleted file mode 100644 index ff992c64..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/command/remoteinfo/JGitRemoteInfoCommand.java +++ /dev/null @@ -1,89 +0,0 @@ - -package org.apache.maven.scm.provider.git.jgit.command.remoteinfo; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.scm.CommandParameters; -import org.apache.maven.scm.ScmException; -import org.apache.maven.scm.ScmFileSet; -import org.apache.maven.scm.command.remoteinfo.AbstractRemoteInfoCommand; -import org.apache.maven.scm.command.remoteinfo.RemoteInfoScmResult; -import org.apache.maven.scm.provider.ScmProviderRepository; -import org.apache.maven.scm.provider.git.command.GitCommand; -import org.apache.maven.scm.provider.git.jgit.command.JGitUtils; -import org.apache.maven.scm.provider.git.repository.GitScmProviderRepository; -import org.eclipse.jgit.api.Git; -import org.eclipse.jgit.api.LsRemoteCommand; -import org.eclipse.jgit.lib.Ref; -import org.eclipse.jgit.lib.Repository; -import org.eclipse.jgit.transport.CredentialsProvider; - -/** - * @author Dominik Bartholdi (imod) - * @since 1.9 - */ -public class JGitRemoteInfoCommand extends AbstractRemoteInfoCommand implements GitCommand -{ - - @Override - public RemoteInfoScmResult executeRemoteInfoCommand( ScmProviderRepository repository, ScmFileSet fileSet, - CommandParameters parameters ) throws ScmException - { - - GitScmProviderRepository repo = (GitScmProviderRepository) repository; - Git git = null; - try - { - git = Git.open( fileSet.getBasedir( ) ); - CredentialsProvider credentials = JGitUtils.getCredentials( repo ); - - LsRemoteCommand lsCommand = git.lsRemote( ).setRemote( repo.getPushUrl( ) ).setCredentialsProvider( - credentials ); - - Map tag = new HashMap( ); - Collection allTags = lsCommand.setHeads( false ).setTags( true ).call( ); - for ( Ref ref : allTags ) - { - tag.put( Repository.shortenRefName( ref.getName( ) ), ref.getObjectId( ).name( ) ); - } - - Map heads = new HashMap( ); - Collection allHeads = lsCommand.setHeads( true ).setTags( false ).call( ); - for ( Ref ref : allHeads ) - { - heads.put( Repository.shortenRefName( ref.getName( ) ), ref.getObjectId( ).name( ) ); - } - - return new RemoteInfoScmResult( "JGit remoteinfo", heads, tag ); - } - catch ( Exception e ) - { - throw new ScmException( "JGit remoteinfo failure!", e ); - } - finally - { - JGitUtils.closeRepo( git ); - } - } -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/command/status/JGitStatusCommand.java b/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/command/status/JGitStatusCommand.java deleted file mode 100644 index ea9ed3ec..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/command/status/JGitStatusCommand.java +++ /dev/null @@ -1,90 +0,0 @@ - -package org.apache.maven.scm.provider.git.jgit.command.status; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.scm.ScmException; -import org.apache.maven.scm.ScmFile; -import org.apache.maven.scm.ScmFileSet; -import org.apache.maven.scm.ScmFileStatus; -import org.apache.maven.scm.command.status.AbstractStatusCommand; -import org.apache.maven.scm.command.status.StatusScmResult; -import org.apache.maven.scm.provider.ScmProviderRepository; -import org.apache.maven.scm.provider.git.command.GitCommand; -import org.apache.maven.scm.provider.git.jgit.command.JGitUtils; -import org.eclipse.jgit.api.Git; -import org.eclipse.jgit.api.Status; - -/** - * @author Mark Struberg - * @author Dominik Bartholdi (imod) - * @since 1.9 - */ -public class JGitStatusCommand extends AbstractStatusCommand implements GitCommand -{ - - /** - * {@inheritDoc} - */ - @Override - protected StatusScmResult executeStatusCommand( ScmProviderRepository repo, ScmFileSet fileSet ) throws ScmException - { - Git git = null; - try - { - git = Git.open( fileSet.getBasedir( ) ); - Status status = git.status( ).call( ); - List changedFiles = getFileStati( status ); - - return new StatusScmResult( "JGit status", changedFiles ); - } - catch ( Exception e ) - { - throw new ScmException( "JGit status failure!", e ); - } - finally - { - JGitUtils.closeRepo( git ); - } - } - - private List getFileStati( Status status ) - { - List all = new ArrayList( ); - addAsScmFiles( all, status.getAdded( ), ScmFileStatus.ADDED ); - addAsScmFiles( all, status.getChanged( ), ScmFileStatus.UPDATED ); - addAsScmFiles( all, status.getConflicting( ), ScmFileStatus.CONFLICT ); - addAsScmFiles( all, status.getModified( ), ScmFileStatus.MODIFIED ); - addAsScmFiles( all, status.getRemoved( ), ScmFileStatus.DELETED ); - return all; - } - - private void addAsScmFiles( Collection all, Collection files, ScmFileStatus status ) - { - for ( String f : files ) - { - all.add( new ScmFile( f, status ) ); - } - } -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/command/tag/JGitTagCommand.java b/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/command/tag/JGitTagCommand.java deleted file mode 100644 index 66944f84..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/apache/maven/scm/provider/git/jgit/command/tag/JGitTagCommand.java +++ /dev/null @@ -1,129 +0,0 @@ - -package org.apache.maven.scm.provider.git.jgit.command.tag; - -import java.util.ArrayList; -import java.util.List; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.scm.ScmException; -import org.apache.maven.scm.ScmFile; -import org.apache.maven.scm.ScmFileSet; -import org.apache.maven.scm.ScmFileStatus; -import org.apache.maven.scm.ScmResult; -import org.apache.maven.scm.ScmTagParameters; -import org.apache.maven.scm.command.tag.AbstractTagCommand; -import org.apache.maven.scm.command.tag.TagScmResult; -import org.apache.maven.scm.provider.ScmProviderRepository; -import org.apache.maven.scm.provider.git.command.GitCommand; -import org.apache.maven.scm.provider.git.jgit.command.JGitUtils; -import org.apache.maven.scm.provider.git.repository.GitScmProviderRepository; -import org.codehaus.plexus.util.StringUtils; -import org.eclipse.jgit.api.Git; -import org.eclipse.jgit.lib.Constants; -import org.eclipse.jgit.lib.Ref; -import org.eclipse.jgit.revwalk.RevCommit; -import org.eclipse.jgit.revwalk.RevWalk; -import org.eclipse.jgit.transport.RefSpec; -import org.eclipse.jgit.treewalk.TreeWalk; - -/** - * @author Mark Struberg - * @author Dominik Bartholdi (imod) - * @since 1.9 - */ -public class JGitTagCommand extends AbstractTagCommand implements GitCommand -{ - - @Override - public ScmResult executeTagCommand( ScmProviderRepository repo, ScmFileSet fileSet, String tag, String message ) - throws ScmException - { - return executeTagCommand( repo, fileSet, tag, new ScmTagParameters( message ) ); - } - - /** - * {@inheritDoc} - */ - @Override - public ScmResult executeTagCommand( ScmProviderRepository repo, ScmFileSet fileSet, String tag, - ScmTagParameters scmTagParameters ) throws ScmException - { - if ( tag == null || StringUtils.isEmpty( tag.trim( ) ) ) - { - throw new ScmException( "tag name must be specified" ); - } - - if ( !fileSet.getFileList( ).isEmpty( ) ) - { - throw new ScmException( "This provider doesn't support tagging subsets of a directory" ); - } - - String escapedTagName = tag.trim( ).replace( ' ', '_' ); - - Git git = null; - try - { - git = Git.open( fileSet.getBasedir( ) ); - - // tag the revision - String tagMessage = scmTagParameters.getMessage( ); - Ref tagRef = git.tag( ).setName( escapedTagName ).setMessage( tagMessage ).setForceUpdate( false ).call( ); - - if ( repo.isPushChanges( ) ) - { - getLogger( ).info( "push tag [" + escapedTagName + "] to remote..." ); - JGitUtils.push( getLogger( ), - git, - (GitScmProviderRepository) repo, - new RefSpec( Constants.R_TAGS + escapedTagName ) ); - } - - // search for the tagged files - RevWalk revWalk = new RevWalk( git.getRepository( ) ); - RevCommit commit = revWalk.parseCommit( tagRef.getObjectId( ) ); - JGitUtils.closeRevWalk( revWalk ); - - final TreeWalk walk = new TreeWalk( git.getRepository( ) ); - walk.reset( ); // drop the first empty tree, which we do not need - // here - walk.setRecursive( true ); - walk.addTree( commit.getTree( ) ); - - List taggedFiles = new ArrayList( ); - while ( walk.next( ) ) - { - taggedFiles.add( new ScmFile( walk.getPathString( ), ScmFileStatus.CHECKED_OUT ) ); - } - JGitUtils.closeTreeWalk( walk ); - - return new TagScmResult( "JGit tag", taggedFiles ); - } - catch ( Exception e ) - { - throw new ScmException( "JGit tag failure!", e ); - } - finally - { - JGitUtils.closeRepo( git ); - } - } - -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/SourceAttachPlugin.java b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/SourceAttachPlugin.java deleted file mode 100644 index 5a0ba4b6..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/SourceAttachPlugin.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.source.attach; - -import java.io.File; - -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; -import org.sf.feeling.decompiler.source.attach.utils.SourceBindingUtil; -import org.sf.feeling.decompiler.source.attach.utils.SourceConstants; - -/** - * The activator class controls the plug-in life cycle - */ -public class SourceAttachPlugin extends AbstractUIPlugin -{ - - // The plug-in ID - public static final String PLUGIN_ID = "org.sf.feeling.decompiler.source.attach"; //$NON-NLS-1$ - - // The shared instance - private static SourceAttachPlugin plugin; - - /** - * The constructor - */ - public SourceAttachPlugin( ) - { - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework. - * BundleContext) - */ - @Override - public void start( BundleContext context ) throws Exception - { - super.start( context ); - plugin = this; - SourceBindingUtil.checkSourceBindingConfig( ); - flagTempFileDeleteOnExit( ); - } - - private void flagTempFileDeleteOnExit( ) - { - File dir = SourceConstants.SourceTempDir; - if ( dir.exists( ) ) - { - File[] children = dir.listFiles( ); - if ( children != null ) - { - for ( int i = 0; i < children.length; i++ ) - { - children[i].deleteOnExit( ); - } - } - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework. - * BundleContext) - */ - @Override - public void stop( BundleContext context ) throws Exception - { - plugin = null; - super.stop( context ); - } - - /** - * Returns the shared instance - * - * @return the shared instance - */ - public static SourceAttachPlugin getDefault( ) - { - return plugin; - } - -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/attacher/InternalBasedSourceAttacherImpl35.java b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/attacher/InternalBasedSourceAttacherImpl35.java deleted file mode 100644 index 339852e8..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/attacher/InternalBasedSourceAttacherImpl35.java +++ /dev/null @@ -1,145 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.source.attach.attacher; - -import java.io.File; -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.jdt.core.ClasspathContainerInitializer; -import org.eclipse.jdt.core.IClasspathContainer; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.internal.corext.util.JavaModelUtil; -import org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathSupport; -import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement; -import org.eclipse.swt.widgets.Shell; -import org.sf.feeling.decompiler.source.attach.utils.MethodUtils; -import org.sf.feeling.decompiler.util.Logger; - -@SuppressWarnings("restriction") -public class InternalBasedSourceAttacherImpl35 implements SourceAttacher -{ - - @Override - public boolean attachSource( final IPackageFragmentRoot fRoot, final File newSourcePath ) throws CoreException - { - try - { - IPath fContainerPath = null; - IClasspathEntry fEntry = null; - if ( fRoot == null || fRoot.getKind( ) != IPackageFragmentRoot.K_BINARY ) - { - Logger.debug( "error(!=K_BINARY)", null ); //$NON-NLS-1$ - return false; - } - IPath containerPath = null; - final IJavaProject jproject = fRoot.getJavaProject( ); - IClasspathEntry entry = fRoot.getRawClasspathEntry( ); - if ( entry == null ) - { - entry = JavaCore.newLibraryEntry( fRoot.getPath( ), (IPath) null, (IPath) null ); - } - else if ( entry.getEntryKind( ) == IClasspathEntry.CPE_CONTAINER ) - { - containerPath = entry.getPath( ); - final ClasspathContainerInitializer initializer = JavaCore - .getClasspathContainerInitializer( containerPath.segment( 0 ) ); - final IClasspathContainer container = JavaCore.getClasspathContainer( containerPath, jproject ); - if ( initializer == null || container == null ) - { - Logger.debug( "error(initializer == null || container == null)", null ); //$NON-NLS-1$ - return false; - } - final IStatus status = initializer.getSourceAttachmentStatus( containerPath, jproject ); - if ( status.getCode( ) == ClasspathContainerInitializer.ATTRIBUTE_NOT_SUPPORTED ) - { - Logger.debug( "error(ATTRIBUTE_NOT_SUPPORTED)", null ); //$NON-NLS-1$ - return false; - } - if ( status.getCode( ) == ClasspathContainerInitializer.ATTRIBUTE_READ_ONLY ) - { - Logger.debug( "error(ATTRIBUTE_READ_ONLY)", null ); //$NON-NLS-1$ - return false; - } - entry = JavaModelUtil.findEntryInContainer( container, fRoot.getPath( ) ); - Assert.isNotNull( entry ); - } - fContainerPath = containerPath; - fEntry = entry; - final CPListElement elem = CPListElement.createFromExisting( fEntry, (IJavaProject) null ); - IPath srcAttPath = Path.fromOSString( newSourcePath.getAbsolutePath( ) ).makeAbsolute( ); - if ( fEntry.getEntryKind( ) == IClasspathEntry.CPE_VARIABLE ) - { - final File sourceAttacherDir = newSourcePath.getParentFile( ); - JavaCore.setClasspathVariable( "SOURCE_ATTACHER", //$NON-NLS-1$ - new Path( sourceAttacherDir.getAbsolutePath( ) ), - (IProgressMonitor) null ); - srcAttPath = new Path( "SOURCE_ATTACHER/" + newSourcePath.getName( ) ); //$NON-NLS-1$ - } - elem.setAttribute( "sourcepath", srcAttPath ); //$NON-NLS-1$ - final IClasspathEntry entry2 = elem.getClasspathEntry( ); - if ( entry2.equals( fEntry ) ) - { - Logger.debug( "NO CHANGE", null ); //$NON-NLS-1$ - return true; - } - final IClasspathEntry newEntry = entry2; - final String[] changedAttributes = { - "sourcepath" //$NON-NLS-1$ - }; - try - { - MethodUtils.invokeExactStaticMethod( BuildPathSupport.class, - "modifyClasspathEntry", //$NON-NLS-1$ - new Object[]{ - null, newEntry, changedAttributes, jproject, fContainerPath, new NullProgressMonitor( ) - }, - new Class[]{ - Shell.class, - IClasspathEntry.class, - String[].class, - IJavaProject.class, - IPath.class, - IProgressMonitor.class - } ); - } - catch ( NoSuchMethodException e ) - { - throw new RuntimeException( e ); - } - catch ( IllegalAccessException e2 ) - { - throw new RuntimeException( e2 ); - } - } - catch ( InvocationTargetException e3 ) - { - Logger.debug( "error", e3 ); //$NON-NLS-1$ - return false; - } - catch ( CoreException e4 ) - { - Logger.debug( "error", e4 ); //$NON-NLS-1$ - return false; - } - return true; - } -} \ No newline at end of file diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/attacher/InternalBasedSourceAttacherImpl36.java b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/attacher/InternalBasedSourceAttacherImpl36.java deleted file mode 100644 index 0b9a865d..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/attacher/InternalBasedSourceAttacherImpl36.java +++ /dev/null @@ -1,135 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.source.attach.attacher; - -import java.io.File; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.jdt.core.ClasspathContainerInitializer; -import org.eclipse.jdt.core.IClasspathContainer; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.internal.corext.util.JavaModelUtil; -import org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathSupport; -import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement; -import org.eclipse.swt.widgets.Shell; -import org.sf.feeling.decompiler.util.Logger; - -@SuppressWarnings("restriction") -public class InternalBasedSourceAttacherImpl36 implements SourceAttacher -{ - - @Override - public boolean attachSource( final IPackageFragmentRoot fRoot, final File newSourcePath ) throws CoreException - { - try - { - IPath fContainerPath = null; - IClasspathEntry fEntry = null; - if ( fRoot == null || fRoot.getKind( ) != IPackageFragmentRoot.K_BINARY ) - { - Logger.debug( "error(!=K_BINARY)", null ); //$NON-NLS-1$ - return false; - } - IPath containerPath = null; - final IJavaProject jproject = fRoot.getJavaProject( ); - IClasspathEntry entry0 = JavaModelUtil.getClasspathEntry( fRoot ); - if ( entry0.getEntryKind( ) == IClasspathEntry.CPE_CONTAINER ) - { - containerPath = entry0.getPath( ); - final ClasspathContainerInitializer initializer = JavaCore - .getClasspathContainerInitializer( containerPath.segment( 0 ) ); - final IClasspathContainer container = JavaCore.getClasspathContainer( containerPath, jproject ); - if ( initializer == null || container == null ) - { - Logger.debug( "error(initializer == null || container == null)", null ); //$NON-NLS-1$ - return false; - } - final IStatus status = initializer.getSourceAttachmentStatus( containerPath, jproject ); - if ( status.getCode( ) == ClasspathContainerInitializer.ATTRIBUTE_NOT_SUPPORTED ) - { - Logger.debug( "error(ATTRIBUTE_NOT_SUPPORTED)", null ); //$NON-NLS-1$ - return false; - } - if ( status.getCode( ) == ClasspathContainerInitializer.ATTRIBUTE_READ_ONLY ) - { - Logger.debug( "error(ATTRIBUTE_READ_ONLY)", null ); //$NON-NLS-1$ - return false; - } - entry0 = JavaModelUtil.findEntryInContainer( container, fRoot.getPath( ) ); - } - fContainerPath = containerPath; - fEntry = entry0; - final CPListElement elem = CPListElement.createFromExisting( fEntry, (IJavaProject) null ); - IPath srcAttPath = Path.fromOSString( newSourcePath.getAbsolutePath( ) ).makeAbsolute( ); - if ( fEntry.getEntryKind( ) == IClasspathEntry.CPE_VARIABLE ) - { - final File sourceAttacherDir = newSourcePath.getParentFile( ); - JavaCore.setClasspathVariable( "SOURCE_ATTACHER", //$NON-NLS-1$ - new Path( sourceAttacherDir.getAbsolutePath( ) ), - (IProgressMonitor) null ); - srcAttPath = new Path( "SOURCE_ATTACHER/" + newSourcePath.getName( ) ); //$NON-NLS-1$ - } - elem.setAttribute( "sourcepath", srcAttPath ); //$NON-NLS-1$ - final IClasspathEntry entry2 = elem.getClasspathEntry( ); - if ( entry2.equals( fEntry ) ) - { - Logger.debug( "NO CHANGE", null ); //$NON-NLS-1$ - return true; - } - final IClasspathEntry newEntry = entry2; - final boolean isReferencedEntry = fEntry.getReferencingEntry( ) != null; - final String[] changedAttributes = { - "sourcepath" //$NON-NLS-1$ - }; - int count = 0; - while ( count < 10 ) - { - BuildPathSupport.modifyClasspathEntry( (Shell) null, - newEntry, - changedAttributes, - jproject, - fContainerPath, - isReferencedEntry, - new NullProgressMonitor( ) ); - if ( fRoot.getSourceAttachmentPath( ) != null && fRoot.getSourceAttachmentPath( ).toFile( ).exists( ) ) - { - break; - } - else - { - count++; - try - { - Thread.sleep( 200 ); - } - catch ( InterruptedException e ) - { - } - } - } - } - catch ( CoreException e ) - { - Logger.debug( "error", e ); //$NON-NLS-1$ - return false; - } - return true; - } -} \ No newline at end of file diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/attacher/MySourceAttacher.java b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/attacher/MySourceAttacher.java deleted file mode 100644 index e3aef7e5..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/attacher/MySourceAttacher.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.source.attach.attacher; - -import java.io.File; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.JavaCore; - -public class MySourceAttacher implements SourceAttacher -{ - - @Override - public boolean attachSource( final IPackageFragmentRoot root, final File sourcePath ) throws Exception - { - final IJavaProject javaProject = root.getJavaProject( ); - final IClasspathEntry[] entries = javaProject.getRawClasspath( ).clone( ); - boolean attached = false; - for ( int i = 0; i < entries.length; ++i ) - { - final IClasspathEntry entry = entries[i]; - String entryPath; - if ( entry.getEntryKind( ) == IClasspathEntry.CPE_VARIABLE ) - { - entryPath = JavaCore.getResolvedVariablePath( entry.getPath( ) ).toOSString( ); - } - else - { - entryPath = entry.getPath( ).toOSString( ); - } - final String rootPath = root.getPath( ).toOSString( ); - if ( entryPath.equals( rootPath ) ) - { - entries[i] = addSourceAttachment( root, entries[i], sourcePath.getAbsolutePath( ), null ); - attached = true; - break; - } - } - if ( !attached ) - { - root.attachSource( new Path( sourcePath.getAbsolutePath( ) ), (IPath) null, (IProgressMonitor) null ); - } - javaProject.setRawClasspath( entries, (IProgressMonitor) null ); - return true; - } - - private static IClasspathEntry addSourceAttachment( final IPackageFragmentRoot root, final IClasspathEntry entry, - final String sourcePath, final String sourceRoot ) throws Exception - { - final int entryKind = entry.getEntryKind( ); - IClasspathEntry result = null; - switch ( entryKind ) - { - case 1 : - { - result = JavaCore.newLibraryEntry( entry.getPath( ), - ( sourcePath == null ) ? null : new Path( sourcePath ), - ( sourceRoot == null ) ? null : new Path( sourceRoot ), - entry.getAccessRules( ), - entry.getExtraAttributes( ), - entry.isExported( ) ); - break; - } - case 4 : - { - final File sourceAttacherDir = new File( sourcePath ).getParentFile( ); - JavaCore.setClasspathVariable( "SOURCE_ATTACHER", //$NON-NLS-1$ - new Path( sourceAttacherDir.getAbsolutePath( ) ), - (IProgressMonitor) null ); - final Path varAttPath = new Path( "SOURCE_ATTACHER/" + new File( sourcePath ).getName( ) ); //$NON-NLS-1$ - result = JavaCore.newVariableEntry( entry.getPath( ), - varAttPath, - ( sourceRoot == null ) ? null : new Path( sourceRoot ), - entry.getAccessRules( ), - entry.getExtraAttributes( ), - entry.isExported( ) ); - break; - } - default : - { - result = entry; - break; - } - } - return result; - } -} \ No newline at end of file diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/attacher/MySourceAttacher2.java b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/attacher/MySourceAttacher2.java deleted file mode 100644 index 0c35577a..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/attacher/MySourceAttacher2.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.source.attach.attacher; - -import java.io.File; - -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.jdt.core.IClasspathContainer; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.internal.corext.util.JavaModelUtil; -import org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathSupport; -import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement; - -@SuppressWarnings("restriction") -public class MySourceAttacher2 implements SourceAttacher -{ - - @Override - public boolean attachSource( final IPackageFragmentRoot root, final File sourcePath ) throws Exception - { - IClasspathEntry entry; - try - { - entry = JavaModelUtil.getClasspathEntry( root ); - } - catch ( JavaModelException ex ) - { - if ( !ex.isDoesNotExist( ) ) - { - throw ex; - } - entry = null; - } - IPath containerPath = null; - final IJavaProject jproject = root.getJavaProject( ); - if ( entry.getEntryKind( ) == IClasspathEntry.CPE_CONTAINER ) - { - containerPath = entry.getPath( ); - final IClasspathContainer container = JavaCore.getClasspathContainer( containerPath, jproject ); - entry = JavaModelUtil.findEntryInContainer( container, root.getPath( ) ); - Assert.isNotNull( entry ); - } - final IClasspathEntry newEntry = this - .configureSourceAttachment( sourcePath.getAbsolutePath( ), entry, jproject ); - this.applySourceAttachment( newEntry, jproject, containerPath, entry.getReferencingEntry( ) != null ); - return true; - } - - private IClasspathEntry configureSourceAttachment( final String sourcePath, final IClasspathEntry initialEntry, - final IJavaProject jproject ) throws Exception - { - if ( initialEntry == null ) - { - throw new IllegalArgumentException( ); - } - final int entryKind = initialEntry.getEntryKind( ); - if ( entryKind != IClasspathEntry.CPE_LIBRARY && entryKind != IClasspathEntry.CPE_VARIABLE ) - { - throw new IllegalArgumentException( ); - } - return this.getNewEntry( sourcePath, initialEntry, jproject ); - } - - public IClasspathEntry getNewEntry( final String sourcePath, final IClasspathEntry fEntry, - final IJavaProject fProject ) throws Exception - { - final CPListElement elem = CPListElement.createFromExisting( fEntry, fProject ); - final IPath sourceAttachmentPath = Path.fromOSString( sourcePath ).makeAbsolute( ); - final String encoding = ResourcesPlugin.getWorkspace( ).getRoot( ).getDefaultCharset( ); - elem.setAttribute( "sourcepath", sourceAttachmentPath ); //$NON-NLS-1$ - elem.setAttribute( "source_encoding", encoding ); //$NON-NLS-1$ - return elem.getClasspathEntry( ); - } - - private void applySourceAttachment( final IClasspathEntry newEntry, final IJavaProject project, - final IPath containerPath, final boolean isReferencedEntry ) throws Exception - { - final String[] changedAttributes = { - "sourcepath", "source_encoding" //$NON-NLS-1$ //$NON-NLS-2$ - }; - BuildPathSupport.modifyClasspathEntry( null, - newEntry, - changedAttributes, - project, - containerPath, - isReferencedEntry, - new NullProgressMonitor( ) ); - } -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/attacher/SourceAttacher.java b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/attacher/SourceAttacher.java deleted file mode 100644 index 93b3087a..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/attacher/SourceAttacher.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.source.attach.attacher; - -import java.io.File; - -import org.eclipse.jdt.core.IPackageFragmentRoot; - -public interface SourceAttacher -{ - - public boolean attachSource( IPackageFragmentRoot paramIPackageFragmentRoot, File paramString ) throws Exception; -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/AbstractSourceCodeFinder.java b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/AbstractSourceCodeFinder.java deleted file mode 100644 index c530cf9f..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/AbstractSourceCodeFinder.java +++ /dev/null @@ -1,151 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.source.attach.finder; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.FileInputStream; -import java.io.InputStream; -import java.net.URL; -import java.net.URLConnection; -import java.util.Collection; -import java.util.HashSet; -import java.util.Properties; -import java.util.Set; -import java.util.zip.GZIPInputStream; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; - -import javax.swing.text.BadLocationException; -import javax.swing.text.html.HTMLDocument; - -import org.apache.commons.io.IOUtils; -import org.sf.feeling.decompiler.util.Logger; - -public abstract class AbstractSourceCodeFinder implements SourceCodeFinder -{ - - protected String downloadUrl; - - @Override - public String getDownloadUrl( ) - { - return downloadUrl; - } - - public void setDownloadUrl( String downloadUrl ) - { - this.downloadUrl = downloadUrl; - } - - protected String getString( URL url ) throws Exception - { - String result = null; - try - { - URLConnection con = url.openConnection( ); - con.setRequestProperty( "User-Agent", //$NON-NLS-1$ - "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36" ); //$NON-NLS-1$ - con.setRequestProperty( "Accept-Encoding", "gzip,deflate" ); //$NON-NLS-1$ //$NON-NLS-2$ - con.setConnectTimeout( 5000 ); - con.setReadTimeout( 5000 ); - InputStream is = null; - byte[] bytes = null; - InputStream conIs = null; - try - { - try - { - conIs = con.getInputStream( ); - bytes = IOUtils.toByteArray( conIs ); - is = new GZIPInputStream( new ByteArrayInputStream( bytes ) ); - result = IOUtils.toString( is ); - } - catch ( Exception e ) - { - if ( bytes != null ) - { - is = new ByteArrayInputStream( bytes ); - result = IOUtils.toString( is ); - } - } - } - finally - { - IOUtils.closeQuietly( conIs ); - IOUtils.closeQuietly( is ); - } - } - catch ( Exception e ) - { - Logger.debug( e ); - } - return result == null ? "" : result; //$NON-NLS-1$ - } - - protected Collection findGAVFromFile( String binFile ) throws Exception - { - Set gavs = new HashSet( ); - - // META-INF/maven/commons-beanutils/commons-beanutils/pom.properties - ZipInputStream in = new ZipInputStream( new FileInputStream( binFile ) ); - byte[] data = new byte[2048]; - do - { - ZipEntry entry = in.getNextEntry( ); - if ( entry == null ) - { - break; - } - - String zipEntryName = entry.getName( ); - if ( zipEntryName.startsWith( "META-INF/maven/" ) && zipEntryName.endsWith( "/pom.properties" ) ) //$NON-NLS-1$ //$NON-NLS-2$ - { - ByteArrayOutputStream os = new ByteArrayOutputStream( ); - do - { - int read = in.read( data ); - if ( read < 0 ) - break; - os.write( data, 0, read ); - } while ( true ); - Properties props = new Properties( ); - props.load( new ByteArrayInputStream( os.toByteArray( ) ) ); - String version = props.getProperty( "version" ); //$NON-NLS-1$ - String groupId = props.getProperty( "groupId" ); //$NON-NLS-1$ - String artifactId = props.getProperty( "artifactId" ); //$NON-NLS-1$ - if ( version != null && groupId != null && artifactId != null ) - { - GAV gav = new GAV( ); - gav.setG( groupId ); - gav.setA( artifactId ); - gav.setV( version ); - gavs.add( gav ); - } - } - } while ( true ); - in.close( ); - - if ( gavs.size( ) > 1 ) - gavs.clear( ); // a merged file, the result will not be correct - return gavs; - } - - protected String getText( HTMLDocument doc, HTMLDocument.Iterator iterator ) throws BadLocationException - { - int startOffset = iterator.getStartOffset( ); - int endOffset = iterator.getEndOffset( ); - int length = endOffset - startOffset; - String text = doc.getText( startOffset, length ); - return text; - } -} \ No newline at end of file diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/ArtifactorySourceCodeFinder.java b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/ArtifactorySourceCodeFinder.java deleted file mode 100644 index 548c021b..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/ArtifactorySourceCodeFinder.java +++ /dev/null @@ -1,253 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.source.attach.finder; - -import java.io.File; -import java.io.InputStream; -import java.net.URL; -import java.net.URLConnection; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; -import org.sf.feeling.decompiler.source.attach.utils.SourceAttachUtil; -import org.sf.feeling.decompiler.source.attach.utils.SourceBindingUtil; -import org.sf.feeling.decompiler.source.attach.utils.UrlDownloader; -import org.sf.feeling.decompiler.util.HashUtils; -import org.sf.feeling.decompiler.util.Logger; - -import com.eclipsesource.json.Json; -import com.eclipsesource.json.JsonObject; -import com.eclipsesource.json.JsonValue; - -public class ArtifactorySourceCodeFinder extends AbstractSourceCodeFinder implements SourceCodeFinder -{ - - protected boolean canceled = false; - private String serviceUrl; - - public ArtifactorySourceCodeFinder( String serviceUrl ) - { - this.serviceUrl = serviceUrl; - } - - @Override - public String toString( ) - { - return this.getClass( ) + "; serviceUrl=" + serviceUrl; //$NON-NLS-1$ - } - - @Override - public void cancel( ) - { - this.canceled = true; - } - - @Override - public void find( String binFile, List results ) - { - Collection gavs = new HashSet( ); - try - { - String sha1 = HashUtils.sha1Hash( new File( binFile ) ); - gavs.addAll( findArtifactsUsingArtifactory( null, null, null, null, sha1, false ) ); - } - catch ( Throwable e ) - { - Logger.debug( e ); - } - - if ( canceled ) - return; - - if ( gavs.isEmpty( ) ) - { - try - { - gavs.addAll( findGAVFromFile( binFile ) ); - } - catch ( Throwable e ) - { - Logger.debug( e ); - } - } - - if ( canceled ) - return; - - Map sourcesUrls = new HashMap( ); - try - { - sourcesUrls.putAll( findSourcesUsingArtifactory( gavs ) ); - } - catch ( Throwable e ) - { - Logger.debug( e ); - } - - for ( Map.Entry entry : sourcesUrls.entrySet( ) ) - { - try - { - String[] sourceFiles = SourceBindingUtil.getSourceFileByDownloadUrl( entry.getValue( ) ); - if ( sourceFiles != null && sourceFiles[0] != null && new File( sourceFiles[0] ).exists( ) ) - { - File sourceFile = new File( sourceFiles[0] ); - File tempFile = new File( sourceFiles[1] ); - SourceFileResult result = new SourceFileResult( this, binFile, sourceFile, tempFile, 100 ); - results.add( result ); - return; - } - } - catch ( Throwable e ) - { - Logger.debug( e ); - } - } - - for ( Map.Entry entry : sourcesUrls.entrySet( ) ) - { - String name = entry.getKey( ).getA( ) + '-' + entry.getKey( ).getV( ) + "-sources.jar"; //$NON-NLS-1$ - try - { - String result = new UrlDownloader( ).download( entry.getValue( ) ); - if ( result != null - && new File( result ).exists( ) - && SourceAttachUtil.isSourceCodeFor( result, binFile ) ) - { - setDownloadUrl( entry.getValue( ) ); - SourceFileResult object = new SourceFileResult( this, binFile, result, name, 100 ); - Logger.debug( this.toString( ) + " FOUND: " + object, null ); //$NON-NLS-1$ - results.add( object ); - } - } - catch ( Throwable e ) - { - Logger.debug( e ); - } - } - } - - protected Map findSourcesUsingArtifactory( Collection gavs ) throws Exception - { - Map results = new HashMap( ); - for ( GAV gav : gavs ) - { - if ( canceled ) - return results; - Set gavs2 = findArtifactsUsingArtifactory( gav - .getG( ), gav.getA( ), gav.getV( ), "sources", null, true ); //$NON-NLS-1$ - for ( GAV gav2 : gavs2 ) - { - if ( gav2.getArtifactLink( ).endsWith( "-sources.jar" ) //$NON-NLS-1$ - || gav2.getArtifactLink( ).endsWith( "-sources.zip" ) ) //$NON-NLS-1$ - { - String uri = gav2.getArtifactLink( ); - File file = new File( new UrlDownloader( ).download( uri ) ); - String json = FileUtils.readFileToString( file ); - JsonObject resp = Json.parse( json ).asObject( ); - results.put( gav, resp.getString( "downloadUri", "" ) ); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - } - - return results; - } - - protected Set findArtifactsUsingArtifactory( String g, String a, String v, String c, String sha1, - boolean getLink ) throws Exception - { - // https://repository.cloudera.com/artifactory/api/search/checksum?sha1=2bf96b7aa8b611c177d329452af1dc933e14501c - // {"results":[{"uri":"http://repository.cloudera.com/artifactory/api/storage/repo1-cache/commons-cli/commons-cli/1.2/commons-cli-1.2.jar"}]} - // GET - // /api/search/gavc?g=org.acme&a=artifact*&v=1.0&c=sources&repos=libs-release-local - - Set results = new HashSet( ); - String apiUrl = getArtifactApiUrl( ); - - String url; - if ( sha1 != null ) - { - url = apiUrl + "search/checksum?sha1=" + sha1; //$NON-NLS-1$ - } - else - { - url = apiUrl + "search/gavc?g=" + g + "&a=" + a + "&v=" + v + ( c != null ? "&c=" + c : "" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ - } - - URLConnection connection = new URL( url ).openConnection( ); - connection.setConnectTimeout( 5000 ); - connection.setReadTimeout( 5000 ); - connection.connect( ); - try - { - InputStream is = connection.getInputStream( ); - String json = IOUtils.toString( is ); - IOUtils.closeQuietly( is ); - - JsonObject resp = Json.parse( json ).asObject( ); - for ( JsonValue elem : resp.get( "results" ).asArray( ) ) //$NON-NLS-1$ - { - JsonObject result = elem.asObject( ); - String uri = result.getString( "uri", "" ); //$NON-NLS-1$ //$NON-NLS-2$ - // http://repository.cloudera.com/artifactory/api/storage/repo1-cache/commons-cli/commons-cli/1.2/commons-cli-1.2.jar - String regex = "/api/storage/[^/]+/(.+)$"; //$NON-NLS-1$ - Pattern pattern = Pattern.compile( regex ); - Matcher matcher = pattern.matcher( uri ); - if ( matcher.find( ) ) - { - String[] gavInArray = matcher.group( 1 ).split( "/" ); //$NON-NLS-1$ - - GAV gav = new GAV( ); - String group = gavInArray[0]; - for ( int i = 1; i < gavInArray.length - 3; i++ ) - { - group += "." + gavInArray[i]; //$NON-NLS-1$ - } - gav.setG( group ); - - gav.setA( gavInArray[gavInArray.length - 3] ); - gav.setV( gavInArray[gavInArray.length - 2] ); - - if ( getLink ) - gav.setArtifactLink( uri ); - results.add( gav ); - } - - } - - } - catch ( Throwable e ) - { - Logger.debug( e ); - } - - return results; - } - - private String getArtifactApiUrl( ) - { - String result = null; - if ( serviceUrl.endsWith( "/webapp/home.html" ) ) //$NON-NLS-1$ - { - result = serviceUrl.replace( "/webapp/home.html", "/api/" ); //$NON-NLS-1$ //$NON-NLS-2$ - } - return result; - } -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/EclipsePluginSourceByFTPSearchv3Finder.java b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/EclipsePluginSourceByFTPSearchv3Finder.java deleted file mode 100644 index 885dc787..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/EclipsePluginSourceByFTPSearchv3Finder.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.source.attach.finder; - -import java.net.URL; -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.swing.text.SimpleAttributeSet; -import javax.swing.text.html.HTMLDocument; - -public class EclipsePluginSourceByFTPSearchv3Finder extends EclipsePluginSourceByUrlPatternFinder -{ - - public EclipsePluginSourceByFTPSearchv3Finder( ) - { - super( "http://www.search-ftp.com/lsftp.ashx?s={0}" ); //$NON-NLS-1$ - } - - @Override - protected String getHtmlFromUrl( URL baseUrl, String fileName ) throws Exception - { - String html = getString( baseUrl ); - Pattern pattern = Pattern.compile( "(?i)" //$NON-NLS-1$ - + Pattern.compile( "" ) ); //$NON-NLS-1$ - Matcher matcher = pattern.matcher( html ); - if ( matcher.find( ) ) - { - String content = matcher.group( ); - content = "http://www.search-ftp.com" //$NON-NLS-1$ - + content.substring( content.indexOf( "\"" ) + 1, content.lastIndexOf( "\"" ) ); //$NON-NLS-1$ //$NON-NLS-2$ - html = getString( new URL( content ) ); - } - return html; - } - - @Override - protected void addLink( URL baseUrl, String fileName, javax.swing.text.html.HTMLDocument doc, - HTMLDocument.Iterator aElement, List links ) throws Exception - { - SimpleAttributeSet s = (SimpleAttributeSet) aElement.getAttributes( ); - - String href = (String) s.getAttribute( javax.swing.text.html.HTML.Attribute.HREF ); - if ( ( href != null ) && ( href.contains( "/lsftp.ashx?is=" ) ) ) //$NON-NLS-1$ - { - String text = getText( doc, aElement ); - String absHref = new URL( new URL( "ftp://" + text + "/" ), fileName ).toString( ); //$NON-NLS-1$ //$NON-NLS-2$ - links.add( absHref ); - } - } - - public static void main( String[] args ) - { - EclipsePluginSourceByFTPSearchv3Finder finder = new EclipsePluginSourceByFTPSearchv3Finder( ); - List results = new ArrayList( ); - finder.find( "C:\\develop\\eclipse\\plugins\\org.eclipse.jdt.core_3.10.0.v20140902-0626.jar", results ); //$NON-NLS-1$ - System.out.println( results.get( 0 ).getSource( ) ); - } -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/EclipsePluginSourceByUrlPatternFinder.java b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/EclipsePluginSourceByUrlPatternFinder.java deleted file mode 100644 index d4c63298..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/EclipsePluginSourceByUrlPatternFinder.java +++ /dev/null @@ -1,214 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.source.attach.finder; - -import java.io.File; -import java.io.Reader; -import java.io.StringReader; -import java.net.URL; -import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import javax.swing.text.EditorKit; -import javax.swing.text.SimpleAttributeSet; -import javax.swing.text.html.HTML; -import javax.swing.text.html.HTMLDocument; -import javax.swing.text.html.HTMLEditorKit; - -import org.sf.feeling.decompiler.source.attach.utils.SourceAttachUtil; -import org.sf.feeling.decompiler.source.attach.utils.SourceBindingUtil; -import org.sf.feeling.decompiler.source.attach.utils.UrlDownloader; -import org.sf.feeling.decompiler.util.Logger; - -public class EclipsePluginSourceByUrlPatternFinder extends AbstractSourceCodeFinder implements SourceCodeFinder -{ - - // http://www.mmnt.ru/int/get?st={0} - // http://www.searchftps.com/indexer/search.aspx?__LASTFOCUS=&__EVENTTARGET=ctl00%24MainContent%24SearchButton&__EVENTARGUMENT=&ctl00%24MainContent%24SearchKeywordTextBox={0}&ctl00%24MainContent%24SearchTypeDropDownList=And&ctl00%24MainContent%24SearchOrderDropDownList=DateDesc&ctl00%24MainContent%24SearchFilterDropDownList=NoFilter - private String urlPattern; - - public EclipsePluginSourceByUrlPatternFinder( String urlPattern ) - { - this.urlPattern = urlPattern; - } - - @Override - public String toString( ) - { - return this.getClass( ) + "; urlPattern=" + urlPattern; //$NON-NLS-1$ - } - - @Override - public void cancel( ) - { - } - - @Override - public void find( String binFile, List results ) - { - File bin = new File( binFile ); - Object fileResult = null; - try - { - String fileName = bin.getName( ); - int position = fileName.lastIndexOf( '_' ); - if ( position != -1 ) - { - String baseName = fileName.substring( 0, position ); - String version = fileName.substring( position + 1 ); - String sourceFileName = baseName + ".source_" + version; //$NON-NLS-1$ - fileResult = findFile( sourceFileName, bin ); - } - } - catch ( Throwable e ) - { - Logger.debug( e ); - } - - if ( fileResult instanceof SourceFileResult ) - { - results.add( (SourceFileResult) fileResult ); - } - else if ( fileResult instanceof String[] ) - { - String[] result = (String[]) fileResult; - if ( result[0] != null ) - { - String name = result[0].substring( result[0].lastIndexOf( '/' ) + 1 ); - SourceFileResult object = new SourceFileResult( this, binFile, result[1], name, 50 ); - Logger.debug( toString( ) + " FOUND: " + object, null ); //$NON-NLS-1$ - results.add( object ); - } - } - - } - - private Object findFile( String fileName, File bin ) throws Exception - { - String file = null; - String url = null; - - List links = searchFileLinksByName( fileName ); - String link; - for ( Iterator it = links.iterator( ); it.hasNext( ); ) - { - link = it.next( ); - boolean keep = false; - if ( link.endsWith( "/" + fileName ) ) //$NON-NLS-1$ - { - keep = true; - } - if ( !keep ) - { - it.remove( ); - } - } - - for ( String url1 : links ) - { - String[] sourceFiles = SourceBindingUtil.getSourceFileByDownloadUrl( url1 ); - if ( sourceFiles != null && sourceFiles[0] != null && new File( sourceFiles[0] ).exists( ) ) - { - File sourceFile = new File( sourceFiles[0] ); - File tempFile = new File( sourceFiles[1] ); - SourceFileResult result = new SourceFileResult( this, - bin.getAbsolutePath( ), - sourceFile, - tempFile, - 100 ); - return result; - } - } - - for ( String url1 : links ) - { - String tmpFile = new UrlDownloader( ).download( url1 ); - - if ( tmpFile != null - && new File( tmpFile ).exists( ) - && SourceAttachUtil.isSourceCodeFor( tmpFile, bin.getAbsolutePath( ) ) ) - { - setDownloadUrl( url1 ); - file = tmpFile; - url = url1; - break; - } - } - return new String[]{ - url, file - }; - } - - private List searchFileLinksByName( String fileName ) throws Exception - { - List result = new ArrayList( ); - URL baseUrl = new URL( this.urlPattern.replace( "{0}", URLEncoder.encode( fileName, "UTF-8" ) ) ); //$NON-NLS-1$ //$NON-NLS-2$ - String html = getHtmlFromUrl( baseUrl, fileName ); - - List links = new ArrayList( ); - - EditorKit kit = new HTMLEditorKit( ); - HTMLDocument doc = (HTMLDocument) kit.createDefaultDocument( ); - doc.putProperty( "IgnoreCharsetDirective", new Boolean( true ) ); //$NON-NLS-1$ - Reader reader = new StringReader( html ); - kit.read( reader, doc, 0 ); - - HTMLDocument.Iterator it = doc.getIterator( HTML.Tag.A ); - while ( it.isValid( ) ) - { - addLink( baseUrl, fileName, doc, it, links ); - it.next( ); - } - - result.addAll( links ); - return result; - } - - protected String getHtmlFromUrl( URL baseUrl, String fileName ) throws Exception - { - return getString( baseUrl ); - } - - protected void addLink( URL baseUrl, String fileName, HTMLDocument doc, HTMLDocument.Iterator aElement, - List links ) throws Exception - { - SimpleAttributeSet s = (SimpleAttributeSet) aElement.getAttributes( ); - - String href = (String) s.getAttribute( HTML.Attribute.HREF ); - if ( ( href != null ) - && ( !href.startsWith( "javascript:" ) ) //$NON-NLS-1$ - && ( !href.startsWith( "news:" ) ) //$NON-NLS-1$ - && ( href.indexOf( '#' ) == -1 ) ) - { - String absHref = new URL( new URL( baseUrl.toString( ) ), href ).toString( ); - links.add( absHref ); - } - } - - public static void main( String[] args ) - { - EclipsePluginSourceByUrlPatternFinder finder = new EclipsePluginSourceByUrlPatternFinder( - "http://www.mmnt.ru/int/get?st={0}" ); //$NON-NLS-1$ - List results = new ArrayList( ); - // finder.find( - // "C:\\Users\\Feeling\\.m2\\repository\\ant\\ant\\1.6.5\\ant-1.6.5.jar", - // results ); - // System.out.println( results.get( 0 ).getSource( ) ); - - finder = new EclipsePluginSourceByUrlPatternFinder( "http://www.filewatcher.com/_/?q={0}" ); //$NON-NLS-1$ - results = new ArrayList( ); - finder.find( "C:\\Users\\Feeling\\.m2\\repository\\ant\\ant\\1.6.5\\ant-1.6.5.jar", results ); //$NON-NLS-1$ - System.out.println( results.get( 0 ).getSource( ) ); - } -} \ No newline at end of file diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/EclipseSourceReferencesSourceCodeFinder.java b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/EclipseSourceReferencesSourceCodeFinder.java deleted file mode 100644 index 835e4df0..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/EclipseSourceReferencesSourceCodeFinder.java +++ /dev/null @@ -1,120 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.source.attach.finder; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.jar.Attributes; -import java.util.jar.Manifest; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; - -import org.sf.feeling.decompiler.source.attach.utils.SourceAttachUtil; -import org.sf.feeling.decompiler.source.attach.utils.SourceBindingUtil; -import org.sf.feeling.decompiler.source.attach.utils.SourceConstants; -import org.sf.feeling.decompiler.source.attach.utils.UrlDownloader; -import org.sf.feeling.decompiler.util.Logger; - -public class EclipseSourceReferencesSourceCodeFinder extends AbstractSourceCodeFinder -{ - - private String findMetaInfoFromFile( String binFile ) throws Exception - { - String result = null; - - ZipInputStream in = new ZipInputStream( new java.io.FileInputStream( binFile ) ); - byte[] data = new byte[2048]; - String zipEntryName; - do - { - ZipEntry entry = in.getNextEntry( ); - if ( entry == null ) - { - break; - } - - zipEntryName = entry.getName( ); - } while ( !zipEntryName.equals( "META-INF/MANIFEST.MF" ) ); //$NON-NLS-1$ - ByteArrayOutputStream os = new ByteArrayOutputStream( ); - for ( ;; ) - { - int read = in.read( data ); - if ( read < 0 ) - break; - os.write( data, 0, read ); - } - - Manifest manifest = new Manifest( new java.io.ByteArrayInputStream( os.toByteArray( ) ) ); - Attributes attr = manifest.getMainAttributes( ); - String ESR = attr.getValue( "Eclipse-SourceReferences" ); //$NON-NLS-1$ - result = ESR; - - in.close( ); - return result; - } - - @Override - public void find( String binFile, List results ) - { - try - { - String sourceReferences = findMetaInfoFromFile( binFile ); - if ( sourceReferences == null ) - { - return; - } - - String[] sourceFiles = SourceBindingUtil.getSourceFileByDownloadUrl( sourceReferences ); - if ( sourceFiles != null && sourceFiles[0] != null && new File( sourceFiles[0] ).exists( ) ) - { - File sourceFile = new File( sourceFiles[0] ); - File tempFile = new File( sourceFiles[1] ); - SourceFileResult result = new SourceFileResult( this, binFile, sourceFile, tempFile, 100 ); - results.add( result ); - return; - } - - String tmpFile = new UrlDownloader( ).download( sourceReferences ); - if ( tmpFile != null - && new File( tmpFile ).exists( ) - && SourceAttachUtil.isSourceCodeFor( tmpFile, new File( binFile ).getAbsolutePath( ) ) ) - { - setDownloadUrl( sourceReferences ); - String name = new File( tmpFile ).getName( ).replace( SourceConstants.TEMP_SOURCE_PREFIX, "eclipse" ); //$NON-NLS-1$ - SourceFileResult object = new SourceFileResult( this, binFile, tmpFile, name, 50 ); - Logger.debug( toString( ) + " FOUND: " + object, null ); //$NON-NLS-1$ - results.add( object ); - } - } - catch ( Throwable e ) - { - Logger.debug( e ); - } - } - - @Override - public void cancel( ) - { - } - - public static void main( String[] args ) - { - EclipseSourceReferencesSourceCodeFinder finder = new EclipseSourceReferencesSourceCodeFinder( ); - List results = new ArrayList( ); - finder.find( - "C:\\develop\\eclipse-jee-luna-SR2-win32\\eclipse\\plugins\\org.apache.commons.codec_1.6.0.v201305230611.jar", //$NON-NLS-1$ - results ); - System.out.println( results.get( 0 ).getSource( ) ); - } -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/FinderManager.java b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/FinderManager.java deleted file mode 100644 index 3ff5832e..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/FinderManager.java +++ /dev/null @@ -1,140 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.source.attach.finder; - -import java.util.LinkedList; -import java.util.List; - -import org.sf.feeling.decompiler.util.Logger; - -public class FinderManager -{ - - private Worker[] workers; - - public FinderManager( ) - { - this.workers = new Worker[10]; - } - - public boolean isRunning( ) - { - boolean result = false; - for ( int i = 0; i < this.workers.length; i++ ) - { - if ( ( this.workers[i] != null ) && ( this.workers[i].isAlive( ) ) ) - { - result = true; - break; - } - } - return result; - } - - public void cancel( ) - { - for ( int i = 0; i < this.workers.length; i++ ) - { - if ( ( this.workers[i] != null ) && ( this.workers[i].isAlive( ) ) ) - { - this.workers[i].cancel( ); - } - } - } - - public void findSources( List libs, List results ) - { - WorkQueue queue = new WorkQueue( ); - - for ( int i = 0; i < this.workers.length; i++ ) - { - this.workers[i] = new Worker( queue, results ); - this.workers[i].start( ); - } - - for ( String lib : libs ) - { - queue.addWork( lib ); - } - - for ( int i = 0; i < this.workers.length; i++ ) - { - queue.addWork( Worker.NO_MORE_WORK ); - } - } - - private static class WorkQueue - { - - LinkedList queue = new LinkedList( ); - - public synchronized void addWork( String o ) - { - this.queue.addLast( o ); - notify( ); - } - - public synchronized String getWork( ) throws InterruptedException - { - while ( this.queue.isEmpty( ) ) - { - wait( ); - } - return this.queue.removeFirst( ); - } - } - - private static class Worker extends Thread - { - - public static final String NO_MORE_WORK = new String( "NO_MORE_WORK" ); //$NON-NLS-1$ - private FinderManager.WorkQueue q; - private List results; - private boolean canceled; - private SourceCodeFinder finder; - - public Worker( FinderManager.WorkQueue q, List results ) - { - this.q = q; - this.results = results; - this.finder = new SourceCodeFinderFacade( ); - } - - public void cancel( ) - { - this.canceled = true; - this.finder.cancel( ); - } - - @Override - public void run( ) - { - try - { - while ( !this.canceled ) - { - String binFile = this.q.getWork( ); - if ( binFile == NO_MORE_WORK ) - { - break; - } - - this.finder.find( binFile, this.results ); - } - } - catch ( InterruptedException e ) - { - Logger.debug( e ); - } - } - } -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/GAV.java b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/GAV.java deleted file mode 100644 index 87f8dd09..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/GAV.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.source.attach.finder; - -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; - -public class GAV -{ - - private String g; - private String a; - private String v; - private String artifactLink; - - public String getG( ) - { - return g; - } - - public void setG( String g ) - { - this.g = g; - } - - public String getA( ) - { - return a; - } - - public void setA( String a ) - { - this.a = a; - } - - public String getV( ) - { - return v; - } - - public void setV( String v ) - { - this.v = v; - } - - public String getArtifactLink( ) - { - return artifactLink; - } - - public void setArtifactLink( String artifactLink ) - { - this.artifactLink = artifactLink; - } - - @Override - public boolean equals( Object obj ) - { - return EqualsBuilder.reflectionEquals( this, obj ); - } - - @Override - public int hashCode( ) - { - return HashCodeBuilder.reflectionHashCode( this ); - } - -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/GrepCodeSourceCodeFinder.java b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/GrepCodeSourceCodeFinder.java deleted file mode 100644 index db29b7f4..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/GrepCodeSourceCodeFinder.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.source.attach.finder; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.io.FilenameUtils; -import org.sf.feeling.decompiler.source.attach.utils.SourceAttachUtil; -import org.sf.feeling.decompiler.source.attach.utils.SourceBindingUtil; -import org.sf.feeling.decompiler.source.attach.utils.UrlDownloader; -import org.sf.feeling.decompiler.util.HashUtils; -import org.sf.feeling.decompiler.util.Logger; - -public class GrepCodeSourceCodeFinder extends AbstractSourceCodeFinder -{ - - protected boolean canceled = false; - - @Override - public void cancel( ) - { - this.canceled = true; - } - - @Override - public void find( String binFile, List results ) - { - try - { - String md5 = HashUtils.md5Hash( new File( binFile ) ); - String srcUrl = "http://grepcode.com/snapshot/" + md5 + "?rel=file&kind=source&n=0"; //$NON-NLS-1$ //$NON-NLS-2$ - - String[] sourceFiles = SourceBindingUtil.getSourceFileByDownloadUrl( srcUrl ); - if ( sourceFiles != null && sourceFiles[0] != null && new File( sourceFiles[0] ).exists( ) ) - { - File sourceFile = new File( sourceFiles[0] ); - File tempFile = new File( sourceFiles[1] ); - SourceFileResult result = new SourceFileResult( this, binFile, sourceFile, tempFile, 100 ); - results.add( result ); - return; - } - - String tmpFile = new UrlDownloader( ).download( srcUrl ); - if ( tmpFile != null - && new File( tmpFile ).exists( ) - && SourceAttachUtil.isSourceCodeFor( tmpFile, binFile ) ) - { - setDownloadUrl( srcUrl ); - String name = FilenameUtils.getBaseName( binFile ) + "-sources.jar"; //$NON-NLS-1$ - SourceFileResult object = new SourceFileResult( this, binFile, tmpFile, name, 50 ); - Logger.debug( toString( ) + " FOUND: " + object, null ); //$NON-NLS-1$ - results.add( object ); - } - } - catch ( Throwable e ) - { - Logger.debug( e ); - } - } - - public static void main( String[] args ) - { - GrepCodeSourceCodeFinder finder = new GrepCodeSourceCodeFinder( ); - List results = new ArrayList( ); - finder.find( "C:\\Users\\Feeling\\.m2\\repository\\ant\\ant\\1.6.5\\ant-1.6.5.jar", results ); //$NON-NLS-1$ - System.out.println( results.get( 0 ).getSource( ) ); - } -} \ No newline at end of file diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/JreSourceCodeFinder.java b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/JreSourceCodeFinder.java deleted file mode 100644 index 8fbff5e9..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/JreSourceCodeFinder.java +++ /dev/null @@ -1,189 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.source.attach.finder; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.Reader; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; - -import javax.swing.text.EditorKit; -import javax.swing.text.SimpleAttributeSet; -import javax.swing.text.html.HTML; -import javax.swing.text.html.HTMLDocument; -import javax.swing.text.html.HTMLEditorKit; - -import org.sf.feeling.decompiler.source.attach.utils.SourceAttachUtil; -import org.sf.feeling.decompiler.source.attach.utils.SourceBindingUtil; -import org.sf.feeling.decompiler.source.attach.utils.UrlDownloader; -import org.sf.feeling.decompiler.util.FileUtil; -import org.sf.feeling.decompiler.util.FileUtil.Filter; -import org.sf.feeling.decompiler.util.Logger; - -public class JreSourceCodeFinder extends AbstractSourceCodeFinder -{ - - private boolean canceled = false; - - @Override - public void cancel( ) - { - this.canceled = true; - } - - @Override - public void find( String binFile, List results ) - { - try - { - String[] metaInfo = findMetaInfoFromFile( binFile ); - if ( ( metaInfo == null ) || ( !"Java Runtime Environment".equals( metaInfo[0] ) ) ) //$NON-NLS-1$ - return; - String version = metaInfo[1]; - String lookup = null; - String linkText = null; - if ( version.startsWith( "1.7.0" ) ) //$NON-NLS-1$ - { - lookup = "http://hg.openjdk.java.net/jdk7u/jdk7u/jdk/tags"; //$NON-NLS-1$ - String u = "u" + version.substring( 6 ); //$NON-NLS-1$ - linkText = "jdk7" + u + "-"; //$NON-NLS-1$ //$NON-NLS-2$ - } - if ( version.startsWith( "1.8.0" ) ) //$NON-NLS-1$ - { - lookup = "http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/tags"; //$NON-NLS-1$ - String u = "u" + version.substring( 6 ); //$NON-NLS-1$ - linkText = "jdk8" + u + "-"; //$NON-NLS-1$ //$NON-NLS-2$ - } - if ( lookup != null ) - { - URL baseUrl = new URL( lookup ); - String html = getString( baseUrl ); - - EditorKit kit = new HTMLEditorKit( ); - HTMLDocument doc = (HTMLDocument) kit.createDefaultDocument( ); - doc.putProperty( "IgnoreCharsetDirective", new Boolean( true ) ); //$NON-NLS-1$ - Reader reader = new java.io.StringReader( html ); - kit.read( reader, doc, 0 ); - - HTMLDocument.Iterator it = doc.getIterator( HTML.Tag.A ); - String srcUrl = null; - while ( it.isValid( ) ) - { - SimpleAttributeSet s = (SimpleAttributeSet) it.getAttributes( ); - String href = (String) s.getAttribute( HTML.Attribute.HREF ); - if ( ( href != null ) && ( href.contains( "/rev/" ) ) ) //$NON-NLS-1$ - { - String text = getText( doc, it ).trim( ); - if ( text.startsWith( linkText ) ) - { - - srcUrl = new URL( baseUrl, href.replace( "/rev/", "/archive/" ) + ".zip" ).toString( ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - break; - } - } - it.next( ); - } - if ( ( srcUrl != null ) && ( !this.canceled ) ) - { - String[] sourceFiles = SourceBindingUtil.getSourceFileByDownloadUrl( srcUrl ); - if ( sourceFiles != null && sourceFiles[0] != null && new File( sourceFiles[0] ).exists( ) ) - { - File sourceFile = new File( sourceFiles[0] ); - File tempFile = new File( sourceFiles[1] ); - SourceFileResult result = new SourceFileResult( this, binFile, sourceFile, tempFile, 100 ); - results.add( result ); - return; - } - - String tmpFile = new UrlDownloader( ).download( srcUrl ); - - FileUtil.filterZipFile( tmpFile, new Filter( ) { - - @Override - public boolean accept( String fileName ) - { - return fileName.endsWith( ".java" ) && fileName.indexOf( "src/share/classes" ) != -1; //$NON-NLS-1$ //$NON-NLS-2$ - } - } ); - - if ( tmpFile != null - && new File( tmpFile ).exists( ) - && SourceAttachUtil.isSourceCodeFor( tmpFile, binFile ) ) - { - setDownloadUrl( srcUrl ); - String name = srcUrl.substring( srcUrl.lastIndexOf( '/' ) + 1 ); - name = "jre_" + name; //$NON-NLS-1$ - SourceFileResult object = new SourceFileResult( this, binFile, tmpFile, name, 50 ); - Logger.debug( toString( ) + " FOUND: " + object, null ); //$NON-NLS-1$ - results.add( object ); - } - } - } - } - catch ( Exception e ) - { - Logger.debug( e ); - } - } - - protected String[] findMetaInfoFromFile( String binFile ) throws Exception - { - String[] result = null; - - ZipInputStream in = new ZipInputStream( new FileInputStream( binFile ) ); - byte[] data = new byte[2048]; - String zipEntryName; - do - { - ZipEntry entry = in.getNextEntry( ); - if ( entry == null ) - { - break; - } - - zipEntryName = entry.getName( ); - } while ( !zipEntryName.equals( "META-INF/MANIFEST.MF" ) ); //$NON-NLS-1$ - ByteArrayOutputStream os = new ByteArrayOutputStream( ); - for ( ;; ) - { - int read = in.read( data ); - if ( read < 0 ) - break; - os.write( data, 0, read ); - } - Properties props = new Properties( ); - props.load( new ByteArrayInputStream( os.toByteArray( ) ) ); - String title = props.getProperty( "Implementation-Title" ); //$NON-NLS-1$ - String version = props.getProperty( "Implementation-Version" ); //$NON-NLS-1$ - result = new String[]{ - title, version - }; - - in.close( ); - return result; - } - - public static void main( String[] args ) - { - JreSourceCodeFinder finder = new JreSourceCodeFinder( ); - List results = new ArrayList( ); - finder.find( "C:\\develop\\jdk1.6\\jre\\lib\\deploy.jar", results ); //$NON-NLS-1$ - System.out.println( results.get( 0 ).getSource( ) ); - } -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/MavenRepoSourceCodeFinder.java b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/MavenRepoSourceCodeFinder.java deleted file mode 100644 index c84c9e43..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/MavenRepoSourceCodeFinder.java +++ /dev/null @@ -1,203 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.source.attach.finder; - -import java.io.File; -import java.net.URL; -import java.net.URLEncoder; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.commons.io.IOUtils; -import org.sf.feeling.decompiler.source.attach.utils.SourceAttachUtil; -import org.sf.feeling.decompiler.source.attach.utils.SourceBindingUtil; -import org.sf.feeling.decompiler.source.attach.utils.UrlDownloader; -import org.sf.feeling.decompiler.util.HashUtils; -import org.sf.feeling.decompiler.util.Logger; - -import com.eclipsesource.json.Json; -import com.eclipsesource.json.JsonArray; -import com.eclipsesource.json.JsonObject; - -public class MavenRepoSourceCodeFinder extends AbstractSourceCodeFinder implements SourceCodeFinder -{ - - private boolean canceled = false; - - @Override - public void cancel( ) - { - this.canceled = true; - - } - - @Override - public String toString( ) - { - return this.getClass( ).toString( ); - } - - @Override - public void find( String binFile, List results ) - { - Collection gavs = new HashSet( ); - try - { - String sha1 = HashUtils.sha1Hash( new File( binFile ) ); - gavs.addAll( findArtifactsUsingMavenCentral( sha1 ) ); - } - catch ( Exception e ) - { - Logger.debug( e ); - } - - if ( canceled ) - return; - - if ( gavs.isEmpty( ) ) - { - try - { - gavs.addAll( findGAVFromFile( binFile ) ); - } - catch ( Exception e ) - { - Logger.debug( e ); - } - } - - if ( canceled ) - return; - - Map sourcesUrls = new HashMap( ); - try - { - sourcesUrls.putAll( findSourcesUsingMavenCentral( gavs ) ); - } - catch ( Exception e ) - { - Logger.debug( e ); - } - - for ( Map.Entry entry : sourcesUrls.entrySet( ) ) - { - try - { - String[] sourceFiles = SourceBindingUtil.getSourceFileByDownloadUrl( entry.getValue( ) ); - if ( sourceFiles != null && sourceFiles[0] != null && new File( sourceFiles[0] ).exists( ) ) - { - File sourceFile = new File( sourceFiles[0] ); - File tempFile = new File( sourceFiles[1] ); - SourceFileResult result = new SourceFileResult( this, binFile, sourceFile, tempFile, 100 ); - results.add( result ); - return; - } - } - catch ( Throwable e ) - { - Logger.debug( e ); - } - } - - for ( Map.Entry entry : sourcesUrls.entrySet( ) ) - { - String name = entry.getKey( ).getA( ) + '-' + entry.getKey( ).getV( ) + "-sources.jar"; //$NON-NLS-1$ - try - { - String tmpFile = new UrlDownloader( ).download( entry.getValue( ) ); - if ( tmpFile != null - && new File( tmpFile ).exists( ) - && SourceAttachUtil.isSourceCodeFor( tmpFile, binFile ) ) - { - setDownloadUrl( entry.getValue( ) ); - SourceFileResult object = new SourceFileResult( this, binFile, tmpFile, name, 100 ); - Logger.debug( this.toString( ) + " FOUND: " + object, null ); //$NON-NLS-1$ - results.add( object ); - - } - } - catch ( Exception e ) - { - Logger.debug( e ); - } - } - } - - private Map findSourcesUsingMavenCentral( Collection gavs ) throws Exception - { - Map results = new HashMap( ); - for ( GAV gav : gavs ) - { - if ( canceled ) - return results; - - // g:"ggg" AND a:"aaa" AND v:"vvv" AND l:"sources" - String qVal = "g:\"" //$NON-NLS-1$ - + gav.getG( ) - + "\" AND a:\"" //$NON-NLS-1$ - + gav.getA( ) - + "\" AND v:\"" //$NON-NLS-1$ - + gav.getV( ) - + "\" AND l:\"sources\""; //$NON-NLS-1$ - String url = "http://search.maven.org/solrsearch/select?q=" //$NON-NLS-1$ - + URLEncoder.encode( qVal, "UTF-8" ) //$NON-NLS-1$ - + "&rows=20&wt=json"; //$NON-NLS-1$ - String json = IOUtils.toString( new URL( url ).openStream( ) ); - JsonObject jsonObject = Json.parse( json ).asObject( ); - JsonObject response = jsonObject.get( "response" ).asObject( ); //$NON-NLS-1$ - - for ( int i = 0; i < response.getInt( "numFound", 0 ); i++ ) //$NON-NLS-1$ - { - JsonArray docs = response.get( "docs" ).asArray( ); //$NON-NLS-1$ - JsonObject doci = docs.get( i ).asObject( ); - String g = doci.getString( "g", "" ); //$NON-NLS-1$ //$NON-NLS-2$ - String a = doci.getString( "a", "" ); //$NON-NLS-1$ //$NON-NLS-2$ - String v = doci.getString( "v", "" ); //$NON-NLS-1$ //$NON-NLS-2$ - JsonArray array = doci.get( "ec" ).asArray( ); //$NON-NLS-1$ - if ( array.toString( ).contains( "-sources.jar" ) ) //$NON-NLS-1$ - { - String path = g.replace( '.', '/' ) + '/' + a + '/' + v + '/' + a + '-' + v + "-sources.jar"; //$NON-NLS-1$ - path = "http://search.maven.org/remotecontent?filepath=" + path; //$NON-NLS-1$ - results.put( gav, path ); - } - } - } - - return results; - } - - private Collection findArtifactsUsingMavenCentral( String sha1 ) throws Exception - { - Set results = new HashSet( ); - String json = IOUtils.toString( new URL( "http://search.maven.org/solrsearch/select?q=" //$NON-NLS-1$ - + URLEncoder.encode( "1:\"" + sha1 + "\"", "UTF-8" ) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - + "&rows=20&wt=json" ).openStream( ) ); //$NON-NLS-1$ - JsonObject jsonObject = Json.parse( json ).asObject( ); - JsonObject response = jsonObject.get( "response" ).asObject( ); //$NON-NLS-1$ - - for ( int i = 0; i < response.getInt( "numFound", 0 ); i++ ) //$NON-NLS-1$ - { - JsonArray docs = response.get( "docs" ).asArray( ); //$NON-NLS-1$ - JsonObject doci = docs.get( i ).asObject( ); - GAV gav = new GAV( ); - gav.setG( doci.getString( "g", "" ) ); //$NON-NLS-1$ //$NON-NLS-2$ - gav.setA( doci.getString( "a", "" ) ); //$NON-NLS-1$ //$NON-NLS-2$ - gav.setV( doci.getString( "v", "" ) ); //$NON-NLS-1$ //$NON-NLS-2$ - results.add( gav ); - } - return results; - } -} \ No newline at end of file diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/NexusSourceCodeFinder.java b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/NexusSourceCodeFinder.java deleted file mode 100644 index 36a480e8..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/NexusSourceCodeFinder.java +++ /dev/null @@ -1,260 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.source.attach.finder; - -import java.io.File; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLEncoder; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.Unmarshaller; - -import org.sf.feeling.decompiler.source.attach.utils.SourceAttachUtil; -import org.sf.feeling.decompiler.source.attach.utils.SourceBindingUtil; -import org.sf.feeling.decompiler.source.attach.utils.UrlDownloader; -import org.sf.feeling.decompiler.util.HashUtils; -import org.sf.feeling.decompiler.util.Logger; -import org.sonatype.nexus.rest.model.NexusArtifact; -import org.sonatype.nexus.rest.model.SearchNGResponse; -import org.sonatype.nexus.rest.model.SearchResponse; - -public class NexusSourceCodeFinder extends AbstractSourceCodeFinder implements SourceCodeFinder -{ - - private boolean canceled = false; - private String serviceUrl; - - public NexusSourceCodeFinder( String serviceUrl ) - { - this.serviceUrl = serviceUrl; - } - - @Override - public String toString( ) - { - return this.getClass( ) + "; serviceUrl=" + serviceUrl; //$NON-NLS-1$ - } - - @Override - public void cancel( ) - { - this.canceled = true; - } - - @Override - public void find( String binFile, List results ) - { - Collection gavs = new HashSet( ); - try - { - String sha1 = HashUtils.sha1Hash( new File( binFile ) ); - gavs.addAll( findArtifactsUsingNexus( null, null, null, null, sha1, false ) ); - } - catch ( Throwable e ) - { - Logger.debug( e ); - } - - if ( canceled ) - return; - - if ( gavs.isEmpty( ) ) - { - try - { - gavs.addAll( findGAVFromFile( binFile ) ); - } - catch ( Throwable e ) - { - Logger.debug( e ); - } - } - - if ( canceled ) - return; - - Map sourcesUrls = new HashMap( ); - try - { - sourcesUrls.putAll( findSourcesUsingNexus( gavs ) ); - } - catch ( Throwable e ) - { - Logger.debug( e ); - } - - for ( Map.Entry entry : sourcesUrls.entrySet( ) ) - { - try - { - String[] sourceFiles = SourceBindingUtil.getSourceFileByDownloadUrl( entry.getValue( ) ); - if ( sourceFiles != null && sourceFiles[0] != null && new File( sourceFiles[0] ).exists( ) ) - { - File sourceFile = new File( sourceFiles[0] ); - File tempFile = new File( sourceFiles[1] ); - SourceFileResult result = new SourceFileResult( this, binFile, sourceFile, tempFile, 100 ); - results.add( result ); - return; - } - } - catch ( Throwable e ) - { - Logger.debug( e ); - } - } - - for ( Map.Entry entry : sourcesUrls.entrySet( ) ) - { - String name = entry.getKey( ).getA( ) + '-' + entry.getKey( ).getV( ) + "-sources.jar"; //$NON-NLS-1$ - try - { - String tmpFile = new UrlDownloader( ).download( entry.getValue( ) ); - if ( tmpFile != null - && new File( tmpFile ).exists( ) - && SourceAttachUtil.isSourceCodeFor( tmpFile, binFile ) ) - { - setDownloadUrl( entry.getValue( ) ); - SourceFileResult object = new SourceFileResult( this, binFile, tmpFile, name, 100 ); - Logger.debug( this.toString( ) + " FOUND: " + object, null ); //$NON-NLS-1$ - results.add( object ); - - } - } - catch ( Throwable e ) - { - Logger.debug( e ); - } - } - } - - private Map findSourcesUsingNexus( Collection gavs ) throws Exception - { - Map results = new HashMap( ); - for ( GAV gav : gavs ) - { - if ( canceled ) - return results; - Set gavs2 = findArtifactsUsingNexus( gav.getG( ), gav.getA( ), gav.getV( ), "sources", null, true ); //$NON-NLS-1$ - for ( GAV gav2 : gavs2 ) - { - results.put( gav, gav2.getArtifactLink( ) ); - } - } - - return results; - } - - private Set findArtifactsUsingNexus( String g, String a, String v, String c, String sha1, boolean getLink ) - throws Exception - { - // http://repository.sonatype.org/service/local/lucene/search?sha1=686ef3410bcf4ab8ce7fd0b899e832aaba5facf7 - // http://repository.sonatype.org/service/local/data_index?sha1=686ef3410bcf4ab8ce7fd0b899e832aaba5facf7 - Set results = new HashSet( ); - String nexusUrl = getNexusContextUrl( ); - - String[] endpoints = new String[]{ - nexusUrl + "service/local/data_index"/* //$NON-NLS-1$ - * //$NON-NLS-1$ , - * nexusUrl + - * "service/local/lucene/search" - */ - }; - for ( String endpoint : endpoints ) - { - if ( canceled ) - return results; - String urlStr = endpoint; - LinkedHashMap params = new LinkedHashMap( ); - if ( g != null ) - { - params.put( "g", g ); //$NON-NLS-1$ - } - if ( a != null ) - { - params.put( "a", a ); //$NON-NLS-1$ - } - if ( v != null ) - { - params.put( "v", v ); //$NON-NLS-1$ - } - if ( c != null ) - { - params.put( "c", c ); //$NON-NLS-1$ - } - if ( sha1 != null ) - { - params.put( "sha1", sha1 ); //$NON-NLS-1$ - } - for ( Map.Entry entry : params.entrySet( ) ) - { - if ( !urlStr.endsWith( "&" ) && !urlStr.endsWith( "?" ) ) //$NON-NLS-1$ //$NON-NLS-2$ - { - if ( urlStr.indexOf( '?' ) == -1 ) - urlStr += "?"; //$NON-NLS-1$ - else - urlStr += "&"; //$NON-NLS-1$ - } - urlStr += URLEncoder.encode( entry.getKey( ), "UTF-8" ) //$NON-NLS-1$ - + "=" //$NON-NLS-1$ - + URLEncoder.encode( entry.getValue( ), "UTF-8" ); //$NON-NLS-1$ - } - - JAXBContext context = JAXBContext.newInstance( SearchResponse.class, SearchNGResponse.class ); - Unmarshaller unmarshaller = context.createUnmarshaller( ); - URLConnection connection = new URL( urlStr ).openConnection( ); - connection.setConnectTimeout( 5000 ); - connection.setReadTimeout( 5000 ); - connection.connect( ); - try - { - Object resp = unmarshaller.unmarshal( connection.getInputStream( ) ); - if ( resp instanceof SearchResponse ) - { - SearchResponse srsp = (SearchResponse) resp; - for ( NexusArtifact ar : srsp.getData( ) ) - { - GAV gav = new GAV( ); - gav.setG( ar.getGroupId( ) ); - gav.setA( ar.getArtifactId( ) ); - gav.setV( ar.getVersion( ) ); - if ( getLink ) - gav.setArtifactLink( ar.getArtifactLink( ) ); - results.add( gav ); - } - } - } - catch ( Throwable e ) - { - Logger.debug( e ); - } - } - return results; - } - - private String getNexusContextUrl( ) - { - String result = serviceUrl.substring( 0, serviceUrl.lastIndexOf( '/' ) ); - if ( !result.endsWith( "/" ) ) //$NON-NLS-1$ - { - result += '/'; - } - return result; - } -} \ No newline at end of file diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/SourceAttacherServiceSourceCodeFinder.java b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/SourceAttacherServiceSourceCodeFinder.java deleted file mode 100644 index c076e990..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/SourceAttacherServiceSourceCodeFinder.java +++ /dev/null @@ -1,157 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.source.attach.finder; - -import java.io.File; -import java.io.InputStream; -import java.net.URL; -import java.net.URLConnection; -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.io.IOUtils; -import org.sf.feeling.decompiler.source.attach.utils.SourceAttachUtil; -import org.sf.feeling.decompiler.source.attach.utils.SourceBindingUtil; -import org.sf.feeling.decompiler.source.attach.utils.UrlDownloader; -import org.sf.feeling.decompiler.util.HashUtils; -import org.sf.feeling.decompiler.util.Logger; - -import com.eclipsesource.json.Json; -import com.eclipsesource.json.JsonArray; -import com.eclipsesource.json.JsonObject; - -public class SourceAttacherServiceSourceCodeFinder extends AbstractSourceCodeFinder implements SourceCodeFinder -{ - - public static final String SERVICE = "http://javasourceattacher2.appspot.com"; //$NON-NLS-1$ - private boolean canceled = false; - - @Override - public String toString( ) - { - return getClass( ).toString( ); - } - - @Override - public void cancel( ) - { - this.canceled = true; - } - - @Override - public void find( String binFile, List results ) - { - File bin = new File( binFile ); - String url = null; - String fileDownloaded = null; - try - { - if ( this.canceled ) - return; - InputStream is2 = null; - URLConnection conn = null; - try - { - String md5 = HashUtils.md5Hash( bin ); - String serviceUrl = "http://javasourceattacher2.appspot.com/rest/libraries?md5=" + md5; //$NON-NLS-1$ - conn = new URL( serviceUrl ).openConnection( ); - conn.setConnectTimeout( 5000 ); - conn.setReadTimeout( 5000 ); - conn.setReadTimeout( 5000 ); - is2 = conn.getInputStream( ); - String str = IOUtils.toString( is2 ); - JsonArray json = Json.parse( str ).asArray( ); - - for ( int i = 0; i < json.size( ); i++ ) - { - if ( this.canceled ) - return; - JsonObject obj = json.get( i ).asObject( ); - JsonObject source = obj.get( "source" ).asObject( ); //$NON-NLS-1$ - if ( ( source != null ) && ( !source.isNull( ) ) ) - { - JsonArray ar = source.get( "urls" ).asArray( ); //$NON-NLS-1$ - if ( ( ar != null ) && ( !ar.isEmpty( ) ) ) - { - String url1 = ar.get( 0 ).asString( ); - String[] sourceFiles = SourceBindingUtil.getSourceFileByDownloadUrl( url1 ); - if ( sourceFiles != null && sourceFiles[0] != null && new File( sourceFiles[0] ).exists( ) ) - { - File sourceFile = new File( sourceFiles[0] ); - File tempFile = new File( sourceFiles[1] ); - SourceFileResult result = new SourceFileResult( this, - bin.getAbsolutePath( ), - sourceFile, - tempFile, - 100 ); - results.add( result ); - return; - } - } - } - } - - for ( int i = 0; i < json.size( ); i++ ) - { - if ( this.canceled ) - return; - JsonObject obj = json.get( i ).asObject( ); - JsonObject source = obj.get( "source" ).asObject( ); //$NON-NLS-1$ - if ( ( source != null ) && ( !source.isNull( ) ) ) - { - JsonArray ar = source.get( "urls" ).asArray( ); //$NON-NLS-1$ - if ( ( ar != null ) && ( !ar.isEmpty( ) ) ) - { - String url1 = ar.get( 0 ).asString( ); - String tmpFile = new UrlDownloader( ).download( url1 ); - if ( tmpFile != null - && new File( tmpFile ).exists( ) - && SourceAttachUtil.isSourceCodeFor( tmpFile, bin.getAbsolutePath( ) ) ) - { - setDownloadUrl( url ); - fileDownloaded = tmpFile; - url = url1; - break; - } - } - } - } - - if ( ( url != null ) && ( fileDownloaded != null ) ) - { - String name = url.substring( url.lastIndexOf( '/' ) + 1 ); - - SourceFileResult object = new SourceFileResult( this, binFile, fileDownloaded, name, 90 ); - Logger.debug( toString( ) + " FOUND: " + object, null ); //$NON-NLS-1$ - results.add( object ); - } - } - finally - { - IOUtils.closeQuietly( is2 ); - } - IOUtils.closeQuietly( is2 ); - } - catch ( Throwable e ) - { - Logger.debug( e ); - } - } - - public static void main( String[] args ) - { - SourceAttacherServiceSourceCodeFinder finder = new SourceAttacherServiceSourceCodeFinder( ); - List results = new ArrayList( ); - finder.find( "C:\\Users\\Feeling\\.m2\\repository\\ant\\ant\\1.6.5\\ant-1.6.5.jar", results ); //$NON-NLS-1$ - System.out.println( results.get( 0 ).getSource( ) ); - } -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/SourceCheck.java b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/SourceCheck.java deleted file mode 100644 index 0167875f..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/SourceCheck.java +++ /dev/null @@ -1,169 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.source.attach.finder; - -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.io.UnsupportedEncodingException; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; -import org.apache.commons.compress.archivers.zip.ZipFile; -import org.apache.commons.io.FilenameUtils; -import org.apache.commons.lang.StringUtils; -import org.sf.feeling.decompiler.source.attach.utils.UrlDownloader; -import org.sf.feeling.decompiler.util.HashUtils; -import org.sf.feeling.decompiler.util.Logger; - -public class SourceCheck -{ - - public static boolean proposeSourceLink( String path, String url ) throws IOException - { - boolean success = false; - try - { - if ( StringUtils.isNotBlank( path ) && StringUtils.isNotBlank( url ) ) - { - path = StringUtils.trimToEmpty( path ); - url = StringUtils.trimToEmpty( url ); - final File file1 = new File( path ); - final List classnames = getJavaFileNames( file1, ".class" ); //$NON-NLS-1$ - final File file2 = download( url ); - final List javanames = getJavaFileNames( file2, ".java" ); //$NON-NLS-1$ - final boolean isSource = isSource( javanames, classnames ); - if ( isSource ) - { - final String origin = path; - final String md5 = HashUtils.md5Hash( file1 ); - final String sha1 = HashUtils.sha1Hash( file1 ); - final String src_origin = url; - final String src_md5 = HashUtils.md5Hash( file2 ); - final String src_sha1 = HashUtils.md5Hash( file2 ); - final String src_urls = url; - postToServer( origin, md5, sha1, src_origin, src_md5, src_sha1, src_urls ); - success = true; - } - } - } - catch ( Exception e ) - { - Logger.debug( e ); - } - return success; - } - - private static void postToServer( final String origin, final String md5, final String sha1, final String src_origin, - final String src_md5, final String src_sha1, final String src_urls ) - throws UnsupportedEncodingException, MalformedURLException, IOException - { - String data = "origin=" + URLEncoder.encode( origin, "UTF-8" ); //$NON-NLS-1$ //$NON-NLS-2$ - data = String.valueOf( data ) + "&md5=" + md5; //$NON-NLS-1$ - data = String.valueOf( data ) + "&sha1=" + sha1; //$NON-NLS-1$ - data = String.valueOf( data ) + "&src_origin=" + URLEncoder.encode( src_origin, "UTF-8" ); //$NON-NLS-1$ //$NON-NLS-2$ - data = String.valueOf( data ) + "&src_md5=" + src_md5; //$NON-NLS-1$ - data = String.valueOf( data ) + "&src_sha1=" + src_sha1; //$NON-NLS-1$ - data = String.valueOf( data ) + "&src_urls=" + URLEncoder.encode( src_urls, "UTF-8" ); //$NON-NLS-1$ //$NON-NLS-2$ - final URL url2 = new URL( "http://javasourceattacher2.appspot.com/rest/libraries" ); //$NON-NLS-1$ - final HttpURLConnection conn = (HttpURLConnection) url2.openConnection( ); - conn.setConnectTimeout( 5000 ); - conn.setReadTimeout( 5000 ); - conn.setDoOutput( true ); - final OutputStreamWriter wr = new OutputStreamWriter( conn.getOutputStream( ) ); - wr.write( data ); - wr.flush( ); - final BufferedReader rd = new BufferedReader( new InputStreamReader( conn.getInputStream( ) ) ); - while ( rd.readLine( ) != null ) - { - } - wr.close( ); - rd.close( ); - if ( conn.getResponseCode( ) != 200 ) - { - throw new IllegalStateException( "Cannot submit " + src_origin ); //$NON-NLS-1$ - } - } - - private static File download( final String str ) throws Exception - { - return new File( new UrlDownloader( ).download( str ) ); - } - - public static boolean isWrongSource( final File srcFile, final File binFile ) throws IOException - { - final List classnames = getJavaFileNames( binFile, ".class" ); //$NON-NLS-1$ - final List javanames = getJavaFileNames( srcFile, ".java" ); //$NON-NLS-1$ - final boolean isWrongSource = !classnames.isEmpty( ) && javanames.isEmpty( ); - return isWrongSource; - } - - private static boolean isSource( final List javanames, final List classnames ) - { - final Set javanames2 = new HashSet( ); - for ( final String javaname : javanames ) - { - final String name = FilenameUtils.getName( javaname ); - if ( name.endsWith( ".java" ) ) //$NON-NLS-1$ - { - javanames2.add( name.substring( 0, name.length( ) - ".java".length( ) ) ); //$NON-NLS-1$ - } - } - final Set classnames2 = new HashSet( ); - for ( final String classname : classnames ) - { - final String name2 = FilenameUtils.getName( classname ); - if ( name2.endsWith( ".class" ) && !name2.contains( "$" ) ) //$NON-NLS-1$ //$NON-NLS-2$ - { - classnames2.add( name2.substring( 0, name2.length( ) - ".class".length( ) ) ); //$NON-NLS-1$ - } - } - javanames2.retainAll( classnames2 ); - final int commonCount = javanames2.size( ); - return commonCount / classnames2.size( ) >= 0.5; - } - - private static List getJavaFileNames( final File file, final String ext ) throws IOException - { - final List classnames = new ArrayList( ); - final ZipFile zf = new ZipFile( file ); - try - { - final Enumeration entries = zf.getEntries( ); - while ( entries.hasMoreElements( ) ) - { - final ZipArchiveEntry entry = entries.nextElement( ); - final String entryName = entry.getName( ); - if ( entryName.endsWith( ext ) ) - { - classnames.add( entryName ); - } - } - } - finally - { - zf.close( ); - } - zf.close( ); - return classnames; - } -} \ No newline at end of file diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/SourceCodeFinder.java b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/SourceCodeFinder.java deleted file mode 100644 index dfdcdfa9..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/SourceCodeFinder.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.source.attach.finder; - -import java.util.List; - -public abstract interface SourceCodeFinder -{ - - public abstract void find( String paramString, List paramList ); - - public abstract void cancel( ); - - public abstract String getDownloadUrl( ); -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/SourceCodeFinderFacade.java b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/SourceCodeFinderFacade.java deleted file mode 100644 index 77dac346..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/SourceCodeFinderFacade.java +++ /dev/null @@ -1,176 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.source.attach.finder; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import org.sf.feeling.decompiler.source.attach.utils.SourceBindingUtil; -import org.sf.feeling.decompiler.util.HashUtils; -import org.sf.feeling.decompiler.util.Logger; - -public class SourceCodeFinderFacade implements SourceCodeFinder -{ - - private SourceCodeFinder[] finders = { - - new MavenRepoSourceCodeFinder( ), - new NexusSourceCodeFinder( "https://repository.jboss.org/nexus/index.html" ), //$NON-NLS-1$ - new NexusSourceCodeFinder( "https://oss.sonatype.org/index.html" ), //$NON-NLS-1$ - new ArtifactorySourceCodeFinder( "https://repo.grails.org/grails/webapp/home.html" ), //$NON-NLS-1$ - new EclipsePluginSourceByUrlPatternFinder( "http://www.filewatcher.com/_/?q={0}" ), //$NON-NLS-1$ - new GrepCodeSourceCodeFinder( ), - new SourceAttacherServiceSourceCodeFinder( ), - - new NexusSourceCodeFinder( "https://repository.apache.org/index.html" ), //$NON-NLS-1$ - new NexusSourceCodeFinder( "https://repository.ow2.org/nexus/index.html" ), //$NON-NLS-1$ - new NexusSourceCodeFinder( "https://maven.java.net/index.html" ), //$NON-NLS-1$ - new NexusSourceCodeFinder( "https://maven.nuxeo.org/nexus/index.html" ), //$NON-NLS-1$ - new NexusSourceCodeFinder( "https://maven.alfresco.com/nexus/index.html" ), //$NON-NLS-1$ - new NexusSourceCodeFinder( "http://nexus.xwiki.org/nexus/index.html" ), //$NON-NLS-1$ - - new ArtifactorySourceCodeFinder( "https://repository.cloudera.com/artifactory/webapp/home.html" ), //$NON-NLS-1$ - new ArtifactorySourceCodeFinder( "https://repo.spring.io/webapp/home.html" ), //$NON-NLS-1$ - - new EclipsePluginSourceByFTPSearchv3Finder( ), - new EclipsePluginSourceByUrlPatternFinder( "http://www.mmnt.ru/int/get?st={0}" ), //$NON-NLS-1$ - - new EclipseSourceReferencesSourceCodeFinder( ), - new JreSourceCodeFinder( ) - }; - - private SourceCodeFinder[] jreFinders = { - - new MavenRepoSourceCodeFinder( ), - new NexusSourceCodeFinder( "https://repository.jboss.org/nexus/index.html" ), //$NON-NLS-1$ - new JreSourceCodeFinder( ), - - new NexusSourceCodeFinder( "https://oss.sonatype.org/index.html" ), //$NON-NLS-1$ - new ArtifactorySourceCodeFinder( "https://repo.grails.org/grails/webapp/home.html" ), //$NON-NLS-1$ - new EclipsePluginSourceByUrlPatternFinder( "http://www.filewatcher.com/_/?q={0}" ), //$NON-NLS-1$ - new GrepCodeSourceCodeFinder( ), - new SourceAttacherServiceSourceCodeFinder( ), - - new NexusSourceCodeFinder( "https://repository.apache.org/index.html" ), //$NON-NLS-1$ - new NexusSourceCodeFinder( "https://repository.ow2.org/nexus/index.html" ), //$NON-NLS-1$ - new NexusSourceCodeFinder( "https://maven.java.net/index.html" ), //$NON-NLS-1$ - new NexusSourceCodeFinder( "https://maven.nuxeo.org/nexus/index.html" ), //$NON-NLS-1$ - new NexusSourceCodeFinder( "https://maven.alfresco.com/nexus/index.html" ), //$NON-NLS-1$ - new NexusSourceCodeFinder( "http://nexus.xwiki.org/nexus/index.html" ), //$NON-NLS-1$ - - new ArtifactorySourceCodeFinder( "https://repository.cloudera.com/artifactory/webapp/home.html" ), //$NON-NLS-1$ - new ArtifactorySourceCodeFinder( "https://repo.spring.io/webapp/home.html" ), //$NON-NLS-1$ - - new EclipsePluginSourceByFTPSearchv3Finder( ), - new EclipsePluginSourceByUrlPatternFinder( "http://www.mmnt.ru/int/get?st={0}" ), //$NON-NLS-1$ - - new EclipseSourceReferencesSourceCodeFinder( ) - }; - - private SourceCodeFinder[] eclipseFinders = { - - new EclipsePluginSourceByFTPSearchv3Finder( ), - new EclipsePluginSourceByUrlPatternFinder( "http://www.mmnt.ru/int/get?st={0}" ), //$NON-NLS-1$ - - new MavenRepoSourceCodeFinder( ), - new NexusSourceCodeFinder( "https://repository.jboss.org/nexus/index.html" ), //$NON-NLS-1$ - new EclipseSourceReferencesSourceCodeFinder( ), - - new NexusSourceCodeFinder( "https://oss.sonatype.org/index.html" ), //$NON-NLS-1$ - new ArtifactorySourceCodeFinder( "https://repo.grails.org/grails/webapp/home.html" ), //$NON-NLS-1$ - new EclipsePluginSourceByUrlPatternFinder( "http://www.filewatcher.com/_/?q={0}" ), //$NON-NLS-1$ - new GrepCodeSourceCodeFinder( ), - new SourceAttacherServiceSourceCodeFinder( ), - - new NexusSourceCodeFinder( "https://repository.apache.org/index.html" ), //$NON-NLS-1$ - new NexusSourceCodeFinder( "https://repository.ow2.org/nexus/index.html" ), //$NON-NLS-1$ - new NexusSourceCodeFinder( "https://maven.java.net/index.html" ), //$NON-NLS-1$ - new NexusSourceCodeFinder( "https://maven.nuxeo.org/nexus/index.html" ), //$NON-NLS-1$ - new NexusSourceCodeFinder( "https://maven.alfresco.com/nexus/index.html" ), //$NON-NLS-1$ - new NexusSourceCodeFinder( "http://nexus.xwiki.org/nexus/index.html" ), //$NON-NLS-1$ - - new ArtifactorySourceCodeFinder( "https://repository.cloudera.com/artifactory/webapp/home.html" ), //$NON-NLS-1$ - new ArtifactorySourceCodeFinder( "https://repo.spring.io/webapp/home.html" ), //$NON-NLS-1$ - - new JreSourceCodeFinder( ) - }; - - private boolean canceled; - - @Override - public void find( String binFilePath, List results ) - { - File binFile = new File( binFilePath ); - if ( !binFile.exists( ) || binFile.isDirectory( ) ) - return; - String sha1 = HashUtils.sha1Hash( binFile ); - String[] sourceFiles = SourceBindingUtil.getSourceFileBySha( sha1 ); - if ( sourceFiles != null && sourceFiles[0] != null && new File( sourceFiles[0] ).exists( ) ) - { - File sourceFile = new File( sourceFiles[0] ); - File tempFile = new File( sourceFiles[1] ); - SourceFileResult result = new SourceFileResult( this, binFilePath, sourceFile, tempFile, 100 ); - results.add( result ); - return; - } - - SourceCodeFinder[] searchFinders = finders; - if ( binFilePath.toLowerCase( ).indexOf( "jre" ) != -1 ) //$NON-NLS-1$ - { - searchFinders = jreFinders; - } - else if ( binFilePath.toLowerCase( ).indexOf( "eclipse" ) != -1 ) //$NON-NLS-1$ - { - searchFinders = eclipseFinders; - } - - for ( int i = 0; i < searchFinders.length && !this.canceled; i++ ) - { - List results2 = new ArrayList( ); - SourceCodeFinder finder = searchFinders[i]; - Logger.debug( finder + " " + binFile, null ); //$NON-NLS-1$ - - finder.find( binFilePath, results2 ); - if ( !results2.isEmpty( ) ) - { - results.addAll( results2 ); - break; - } - } - } - - @Override - public void cancel( ) - { - this.canceled = true; - for ( int i = 0; i < this.finders.length && !this.canceled; i++ ) - { - SourceCodeFinder finder = this.finders[i]; - finder.cancel( ); - } - } - - public static void main( String[] args ) - { - SourceCodeFinderFacade finder = new SourceCodeFinderFacade( ); - List results = new ArrayList( ); - finder.find( "C:\\develop\\runtime-EclipseApplication\\Test\\lib\\groovy-all-1.7.6.jar", results ); //$NON-NLS-1$ - System.out.println( results.get( 0 ).getSource( ) ); - } - - @Override - public String getDownloadUrl( ) - { - return null; - } -} \ No newline at end of file diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/SourceFileResult.java b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/SourceFileResult.java deleted file mode 100644 index e01c00e0..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/finder/SourceFileResult.java +++ /dev/null @@ -1,122 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.source.attach.finder; - -import java.io.File; - -public class SourceFileResult -{ - - private String binFile; - private String source; - private String suggestedSourceFileName; - private int accuracy; - private SourceCodeFinder finder; - private String tempSource; - - public SourceFileResult( SourceCodeFinder finder, String binFile, String source, String suggestedSourceFileName, - int accuracy ) - { - this.finder = finder; - this.binFile = binFile; - this.source = source; - this.suggestedSourceFileName = suggestedSourceFileName; - this.accuracy = accuracy; - } - - public SourceFileResult( SourceCodeFinder finder, String binFile, File sourceFile, File tempFile, int accuracy ) - { - this.finder = finder; - this.binFile = binFile; - this.source = sourceFile.getAbsolutePath( ); - this.suggestedSourceFileName = sourceFile.getName( ); - this.accuracy = accuracy; - this.tempSource = tempFile.getAbsolutePath( ); - } - - @Override - public String toString( ) - { - String s = "SourceFileResult[source = " //$NON-NLS-1$ - + this.source - + " ; suggestedSourceFileName = " //$NON-NLS-1$ - + this.suggestedSourceFileName - + " ; accuracy = " //$NON-NLS-1$ - + this.accuracy - + " ; binFile = " //$NON-NLS-1$ - + this.binFile - + " ; finder = " //$NON-NLS-1$ - + this.finder - + "]"; //$NON-NLS-1$ - return s; - } - - public String getBinFile( ) - { - return this.binFile; - } - - public void setBinFile( String binFile ) - { - this.binFile = binFile; - } - - public String getSource( ) - { - return this.source; - } - - public void setSource( String source ) - { - this.source = source; - } - - public String getSuggestedSourceFileName( ) - { - return this.suggestedSourceFileName; - } - - public void setSuggestedSourceFileName( String suggestedSourceFileName ) - { - this.suggestedSourceFileName = suggestedSourceFileName; - } - - public int getAccuracy( ) - { - return this.accuracy; - } - - public void setAccuracy( int accuracy ) - { - this.accuracy = accuracy; - } - - public SourceCodeFinder getFinder( ) - { - return finder; - } - - public void setFinder( SourceCodeFinder finder ) - { - this.finder = finder; - } - - public String getTempSource( ) - { - return tempSource; - } - - public void setTempSource( String tempSource ) - { - this.tempSource = tempSource; - } -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/handler/AttachSourceAction.java b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/handler/AttachSourceAction.java deleted file mode 100644 index 8bc0ff43..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/handler/AttachSourceAction.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.source.attach.handler; - -import java.util.List; - -import org.eclipse.jdt.core.IClassFile; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jface.action.Action; -import org.sf.feeling.decompiler.JavaDecompilerPlugin; -import org.sf.feeling.decompiler.source.attach.i18n.Messages; - -@SuppressWarnings("rawtypes") -public class AttachSourceAction extends Action -{ - - private List selection = null; - - public AttachSourceAction( List selection ) - { - super( Messages.getString( "AttachSourceAction.Action.Name" ) ); //$NON-NLS-1$ - this.selection = selection; - } - - @Override - public void run( ) - { - if ( JavaDecompilerPlugin.getDefault( ).isEnableExtension( ) ) - { - if ( selection == null || selection.isEmpty( ) ) - return; - - Object firstElement = selection.get( 0 ); - if ( selection.size( ) == 1 && firstElement instanceof IClassFile ) - { - IClassFile classFile = (IClassFile) firstElement; - IPackageFragmentRoot root = (IPackageFragmentRoot) classFile.getParent( ).getParent( ); - JavaDecompilerPlugin.getDefault( ).attachSource( root, true ); - } - else if ( selection.size( ) == 1 && firstElement instanceof IPackageFragmentRoot ) - { - IPackageFragmentRoot root = (IPackageFragmentRoot) firstElement; - JavaDecompilerPlugin.getDefault( ).attachSource( root, true ); - } - else - { - IPackageFragmentRoot root = null; - if ( firstElement instanceof IClassFile ) - { - root = (IPackageFragmentRoot) ( (IClassFile) firstElement ).getParent( ).getParent( ); - } - else if ( firstElement instanceof IPackageFragment ) - { - root = (IPackageFragmentRoot) ( (IPackageFragment) firstElement ).getParent( ); - } - if ( root == null ) - return; - JavaDecompilerPlugin.getDefault( ).attachSource( root, true ); - } - } - } - - @Override - public boolean isEnabled( ) - { - return JavaDecompilerPlugin.getDefault( ).isEnableExtension( ) && selection != null; - } - -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/handler/AttachSourceContributionFactory.java b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/handler/AttachSourceContributionFactory.java deleted file mode 100644 index ad2129f5..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/handler/AttachSourceContributionFactory.java +++ /dev/null @@ -1,134 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.source.attach.handler; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.expressions.EvaluationResult; -import org.eclipse.core.expressions.Expression; -import org.eclipse.core.expressions.IEvaluationContext; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jdt.core.IClassFile; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jface.action.ActionContributionItem; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.ISelectionService; -import org.eclipse.ui.menus.ExtensionContributionFactory; -import org.eclipse.ui.menus.IContributionRoot; -import org.eclipse.ui.services.IServiceLocator; -import org.sf.feeling.decompiler.JavaDecompilerPlugin; -import org.sf.feeling.decompiler.source.attach.utils.SourceAttachUtil; - -@SuppressWarnings({ - "rawtypes", "unchecked" -}) -public class AttachSourceContributionFactory extends ExtensionContributionFactory -{ - - @Override - public void createContributionItems( IServiceLocator serviceLocator, IContributionRoot additions ) - { - if ( !JavaDecompilerPlugin.getDefault( ).isEnableExtension( ) ) - { - return; - } - - final ISelectionService selService = (ISelectionService)serviceLocator.getService( ISelectionService.class ); - final List selectedJars = getSelectedElements( selService, IPackageFragmentRoot.class ); - boolean attachRoot = ( selectedJars.size( ) == 1 ); - if ( attachRoot ) - { - additions.addContributionItem( new ActionContributionItem( new AttachSourceAction( selectedJars ) ), - new Expression( ) { - - @Override - public EvaluationResult evaluate( IEvaluationContext context ) throws CoreException - { - boolean menuVisible = SourceAttachUtil.needDownloadSource( selectedJars ); - - if ( menuVisible ) - return EvaluationResult.TRUE; - - return EvaluationResult.FALSE; - } - } ); - return; - } - - if ( selectedJars.size( ) > 1 ) - return; - - final List selectedPackages = getSelectedElements( selService, IPackageFragment.class ); - final List selectedClasses = getSelectedElements( selService, IClassFile.class ); - selectedClasses.addAll( selectedPackages ); - boolean attachClasses = ( !selectedClasses.isEmpty( ) ); - if ( attachClasses ) - { - additions.addContributionItem( new ActionContributionItem( new AttachSourceAction( selectedClasses ) ), - new Expression( ) { - - @Override - public EvaluationResult evaluate( IEvaluationContext context ) throws CoreException - { - boolean menuVisible = SourceAttachUtil.needDownloadSource( selectedClasses ); - - if ( menuVisible ) - return EvaluationResult.TRUE; - - return EvaluationResult.FALSE; - } - } ); - return; - } - - } - - - - private List getSelectedElements( ISelectionService selService, Class eleClass ) - { - - Iterator selections = getSelections( selService ); - List elements = new ArrayList( ); - - while ( ( selections != null ) && selections.hasNext( ) ) - { - Object select = selections.next( ); - - if ( eleClass.isInstance( select ) ) - elements.add( select ); - } - - return elements; - } - - private Iterator getSelections( ISelectionService selService ) - { - ISelection selection = selService.getSelection( ); - - if ( selection != null ) - { - if ( selection instanceof IStructuredSelection ) - { - IStructuredSelection structuredSelection = (IStructuredSelection) selection; - return structuredSelection.iterator( ); - } - } - - return null; - } - -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/handler/AttachSourceHandler.java b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/handler/AttachSourceHandler.java deleted file mode 100644 index 80bc87a8..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/handler/AttachSourceHandler.java +++ /dev/null @@ -1,108 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.source.attach.handler; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.sf.feeling.decompiler.JavaDecompilerPlugin; -import org.sf.feeling.decompiler.source.attach.IAttachSourceHandler; -import org.sf.feeling.decompiler.source.attach.i18n.Messages; -import org.sf.feeling.decompiler.source.attach.utils.SourceAttachUtil; -import org.sf.feeling.decompiler.util.Logger; - -public class AttachSourceHandler implements IAttachSourceHandler -{ - - @Override - public void execute( final IPackageFragmentRoot library, final boolean showUI ) - { - if ( !JavaDecompilerPlugin.getDefault( ).isEnableExtension( ) ) - { - return; - } - - if ( !showUI && SourceAttachUtil.isMavenLibrary( library ) && SourceAttachUtil.enableMavenDownload( ) ) - { - return; - } - - final List selections = new ArrayList( ); - selections.add( library ); - if ( !selections.isEmpty( ) ) - { - if ( showUI ) - { - final Job job = new Job( Messages.getString( "AttachSourceHandler.Job.Name" ) ) { //$NON-NLS-1$ - - @Override - protected IStatus run( final IProgressMonitor monitor ) - { - return JavaSourceAttacherHandler.updateSourceAttachments( selections, monitor ); - } - }; - job.setPriority( 30 ); - job.schedule( ); - } - else - { - Thread thread = new Thread( ) { - - @Override - public void run( ) - { - JavaSourceAttacherHandler.updateSourceAttachments( selections, null ); - } - }; - thread.setDaemon( true ); - thread.start( ); - - } - } - - } - - @Override - public boolean syncAttachSource( final IPackageFragmentRoot root ) - { - if ( !JavaDecompilerPlugin.getDefault( ).isEnableExtension( ) ) - { - return false; - } - - try - { - boolean download = SourceAttachUtil.needDownloadSource( Arrays.asList( new IPackageFragmentRoot[]{ - root - } ) ); - - if ( download ) - { - return SourceAttachUtil.refreshSourceAttachStatus( root ); - } - else - { - return true; - } - } - catch ( Exception e ) - { - Logger.debug( e ); - } - return false; - } -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/handler/JavaSourceAttacherHandler.java b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/handler/JavaSourceAttacherHandler.java deleted file mode 100644 index 54d888d9..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/handler/JavaSourceAttacherHandler.java +++ /dev/null @@ -1,515 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.source.attach.handler; - -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.commons.io.FileUtils; -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.handlers.HandlerUtil; -import org.sf.feeling.decompiler.JavaDecompilerPlugin; -import org.sf.feeling.decompiler.source.attach.attacher.SourceAttacher; -import org.sf.feeling.decompiler.source.attach.finder.EclipseSourceReferencesSourceCodeFinder; -import org.sf.feeling.decompiler.source.attach.finder.FinderManager; -import org.sf.feeling.decompiler.source.attach.finder.JreSourceCodeFinder; -import org.sf.feeling.decompiler.source.attach.finder.SourceCheck; -import org.sf.feeling.decompiler.source.attach.finder.SourceCodeFinderFacade; -import org.sf.feeling.decompiler.source.attach.finder.SourceFileResult; -import org.sf.feeling.decompiler.source.attach.i18n.Messages; -import org.sf.feeling.decompiler.source.attach.utils.SourceAttachUtil; -import org.sf.feeling.decompiler.source.attach.utils.SourceBindingUtil; -import org.sf.feeling.decompiler.source.attach.utils.SourceConstants; -import org.sf.feeling.decompiler.util.HashUtils; -import org.sf.feeling.decompiler.util.Logger; - -public class JavaSourceAttacherHandler extends AbstractHandler -{ - - final static Map requests = new HashMap( ); - - @Override - public Object execute( final ExecutionEvent event ) throws ExecutionException - { - if ( !JavaDecompilerPlugin.getDefault( ).isEnableExtension( ) ) - { - return null; - } - - final ISelection selection = HandlerUtil.getCurrentSelection( event ); - if ( !( selection instanceof IStructuredSelection ) ) - { - return null; - } - final IStructuredSelection structuredSelection = (IStructuredSelection) selection; - final List selections = new ArrayList( ); - for ( Iterator iterator = structuredSelection.iterator( ); iterator.hasNext( ); ) - { - IJavaElement aSelection = (IJavaElement) iterator.next( ); - if ( aSelection instanceof IPackageFragmentRoot ) - { - final IPackageFragmentRoot pkgRoot = (IPackageFragmentRoot) aSelection; - selections.add( pkgRoot ); - } - else - { - if ( !( aSelection instanceof IJavaProject ) ) - { - continue; - } - final IJavaProject p = (IJavaProject) aSelection; - try - { - IPackageFragmentRoot[] packageFragmentRoots; - for ( int length = ( packageFragmentRoots = p - .getPackageFragmentRoots( ) ).length, i = 0; i < length; ++i ) - { - final IPackageFragmentRoot pkgRoot2 = packageFragmentRoots[i]; - selections.add( pkgRoot2 ); - } - } - catch ( Exception e ) - { - Logger.debug( e ); - } - } - } - final Iterator it = selections.iterator( ); - while ( it.hasNext( ) ) - { - final IPackageFragmentRoot pkgRoot3 = it.next( ); - try - { - if ( pkgRoot3.getKind( ) == IPackageFragmentRoot.K_BINARY - && pkgRoot3.isArchive( ) - && ( pkgRoot3.getRawClasspathEntry( ).getEntryKind( ) == IClasspathEntry.CPE_LIBRARY - || pkgRoot3.getRawClasspathEntry( ).getEntryKind( ) == IClasspathEntry.CPE_VARIABLE - || pkgRoot3.getRawClasspathEntry( ).getEntryKind( ) == IClasspathEntry.CPE_CONTAINER ) ) - { - final IPath source = pkgRoot3.getSourceAttachmentPath( ); - if ( source == null || source.isEmpty( ) || !new File( source.toOSString( ) ).exists( ) ) - { - continue; - } - File binFile; - if ( !pkgRoot3.isExternal( ) ) - { - binFile = pkgRoot3.getResource( ).getLocation( ).toFile( ); - } - else - { - binFile = pkgRoot3.getPath( ).toFile( ); - } - if ( SourceCheck.isWrongSource( new File( source.toOSString( ) ), binFile ) ) - { - continue; - } - it.remove( ); - } - else - { - it.remove( ); - } - } - catch ( Exception e2 ) - { - Logger.debug( e2 ); - } - } - - if ( !selections.isEmpty( ) ) - { - final Job job = new Job( Messages.getString( "JavaSourceAttacherHandler.Job.Name" ) ) { //$NON-NLS-1$ - - @Override - protected IStatus run( final IProgressMonitor monitor ) - { - return JavaSourceAttacherHandler.updateSourceAttachments( selections, monitor ); - } - }; - job.setPriority( 30 ); - job.schedule( ); - } - return null; - } - - public static IStatus updateSourceAttachments( final List roots, - final IProgressMonitor monitor ) - { - - for ( final IPackageFragmentRoot pkgRoot : roots ) - { - File file; - - if ( !pkgRoot.isExternal( ) ) - { - file = pkgRoot.getResource( ).getLocation( ).toFile( ); - } - else - { - file = pkgRoot.getPath( ).toFile( ); - } - try - { - if ( roots.size( ) == 1 && requests.containsKey( file.getCanonicalPath( ) ) ) - { - return Status.CANCEL_STATUS; - } - requests.put( file.getCanonicalPath( ), pkgRoot ); - } - catch ( Exception e ) - { - Logger.debug( e ); - } - } - final Set notProcessedLibs = new HashSet( ); - notProcessedLibs.addAll( requests.keySet( ) ); - final List responses = Collections.synchronizedList( new ArrayList( ) ); - final List libs = new ArrayList( ); - libs.addAll( requests.keySet( ) ); - final FinderManager mgr = new FinderManager( ); - mgr.findSources( libs, responses ); - if ( monitor == null ) - { - while ( mgr.isRunning( ) && !notProcessedLibs.isEmpty( ) ) - { - processLibSources( notProcessedLibs, responses ); - try - { - Thread.sleep( 1000L ); - } - catch ( Exception e2 ) - { - Logger.debug( e2 ); - } - } - } - else - { - while ( !monitor.isCanceled( ) && mgr.isRunning( ) && !notProcessedLibs.isEmpty( ) ) - { - processLibSources( notProcessedLibs, responses ); - try - { - Thread.sleep( 1000L ); - } - catch ( Exception e2 ) - { - Logger.debug( e2 ); - } - } - } - - mgr.cancel( ); - if ( !notProcessedLibs.isEmpty( ) ) - { - processLibSources( notProcessedLibs, responses ); - } - - for ( final IPackageFragmentRoot pkgRoot : roots ) - { - File file; - - if ( !pkgRoot.isExternal( ) ) - { - file = pkgRoot.getResource( ).getLocation( ).toFile( ); - } - else - { - file = pkgRoot.getPath( ).toFile( ); - } - try - { - - requests.remove( file.getCanonicalPath( ) ); - } - catch ( Exception e ) - { - Logger.debug( e ); - } - } - - return Status.OK_STATUS; - } - - private static void processLibSources( final Set notProcessedLibs, final List responses ) - { - - while ( !responses.isEmpty( ) ) - { - final SourceFileResult response = responses.remove( 0 ); - final String binFile = response.getBinFile( ); - if ( notProcessedLibs.contains( binFile ) && response.getSource( ) != null ) - { - final IPackageFragmentRoot pkgRoot = requests.get( binFile ); - try - { - notProcessedLibs.remove( response.getBinFile( ) ); - final String source = response.getSource( ); - final String tempSource = response.getTempSource( ); - final String suggestedSourceFileName = response.getSuggestedSourceFileName( ); - final String downloadUrl = response.getFinder( ).getDownloadUrl( ); - if ( downloadUrl == null && !( response.getFinder( ) instanceof SourceCodeFinderFacade ) ) - { - continue; - } - if ( !SourceConstants.SourceAttacherDir.exists( ) ) - { - SourceConstants.SourceAttacherDir.mkdirs( ); - } - - if ( !SourceConstants.SourceTempDir.exists( ) ) - { - SourceConstants.SourceTempDir.mkdirs( ); - } - - File sourceTempFile; - File sourceFile; - if ( tempSource == null || !new File( tempSource ).exists( ) ) - { - File tempFile = new File( source ); - sourceFile = new File( SourceConstants.SourceAttacherDir, suggestedSourceFileName ); - if ( !sourceFile.exists( ) ) - { - FileUtils.copyFile( tempFile, sourceFile ); - } - - sourceTempFile = new File( SourceConstants.SourceTempDir, suggestedSourceFileName ); - if ( !sourceTempFile.exists( ) ) - { - FileUtils.copyFile( tempFile, sourceTempFile ); - } - sourceTempFile.deleteOnExit( ); - if ( !tempFile.getAbsolutePath( ).startsWith( SourceConstants.SourceAttachPath ) ) - { - tempFile.delete( ); - } - } - else - { - sourceFile = new File( source ); - sourceTempFile = new File( tempSource ); - sourceTempFile.deleteOnExit( ); - } - - if ( pkgRoot.getSourceAttachmentPath( ) != null - && sourceTempFile.equals( pkgRoot.getSourceAttachmentPath( ).toFile( ) ) ) - { - if ( SourceAttachUtil.reattchSource( pkgRoot, sourceFile, sourceTempFile, downloadUrl ) ) - { - String[] files = SourceBindingUtil.getSourceFileByDownloadUrl( downloadUrl ); - attachLibrarys( response, pkgRoot, new File( files[1] ), sourceFile ); - } - } - else if ( attachSource( pkgRoot, sourceTempFile ) ) - { - SourceBindingUtil.saveSourceBindingRecord( sourceFile, - HashUtils.sha1Hash( new File( response.getBinFile( ) ) ), - downloadUrl, - sourceTempFile ); - String[] files = SourceBindingUtil.getSourceFileByDownloadUrl( downloadUrl ); - attachLibrarys( response, pkgRoot, new File( files[1] ), sourceFile ); - } - } - catch ( Exception e ) - { - if ( pkgRoot != null - && pkgRoot.getResource( ) != null - && pkgRoot.getResource( ).getLocation( ) != null ) - { - Logger.debug( "Cannot attach to " + pkgRoot.getResource( ).getLocation( ).toOSString( ), e ); //$NON-NLS-1$ - } - } - } - } - } - - private static void attachLibrarys( final SourceFileResult response, final IPackageFragmentRoot pkgRoot, - final File sourceTempFile, final File sourceFile ) - { - Thread thread = new Thread( ) { - - @Override - public void run( ) - { - try - { - if ( sourceFile.getName( ).startsWith( "jre_" ) ) //$NON-NLS-1$ - { - attachJRELibrarySources( response, pkgRoot, sourceTempFile ); - } - if ( sourceFile.getName( ).startsWith( "eclipse_" ) ) //$NON-NLS-1$ - { - attachEclipseLibrarySources( response, pkgRoot, sourceTempFile ); - } - } - catch ( Exception e ) - { - Logger.debug( e ); - } - } - }; - thread.setDaemon( true ); - thread.start( ); - } - - private static void attachJRELibrarySources( final SourceFileResult response, final IPackageFragmentRoot pkgRoot, - File sourceTempFile ) throws Exception - { - if ( response.getFinder( ) instanceof JreSourceCodeFinder ) - { - IPackageFragmentRoot[] roots = pkgRoot.getJavaProject( ).getAllPackageFragmentRoots( ); - for ( int i = 0; i < roots.length; i++ ) - { - IPackageFragmentRoot element = roots[i]; - if ( element.equals( pkgRoot ) ) - continue; - List paths = Arrays.asList( element.getPath( ).segments( ) ); - if ( paths.contains( "jre" ) ) //$NON-NLS-1$ - { - if ( element.getSourceAttachmentPath( ) == null - || element.getSourceAttachmentPath( ).toOSString( ) == null - || !new File( element.getSourceAttachmentPath( ).toOSString( ) ).exists( ) ) - { - attachSource( element, sourceTempFile ); - } - } - } - } - } - - private static void attachEclipseLibrarySources( final SourceFileResult response, - final IPackageFragmentRoot pkgRoot, File sourceTempFile ) throws Exception - { - if ( response.getFinder( ) instanceof EclipseSourceReferencesSourceCodeFinder ) - { - List plugins = SourceAttachUtil.getEclipsePlugins( sourceTempFile ); - - IPackageFragmentRoot[] roots = pkgRoot.getJavaProject( ).getAllPackageFragmentRoots( ); - for ( int i = 0; i < roots.length; i++ ) - { - IPackageFragmentRoot element = roots[i]; - if ( element.equals( pkgRoot ) ) - continue; - String fileName = element.getPath( ).lastSegment( ); - if ( plugins.contains( fileName.split( "_" )[0] ) ) //$NON-NLS-1$ - { - if ( element.getSourceAttachmentPath( ) == null - || element.getSourceAttachmentPath( ).toOSString( ) == null - || !new File( element.getSourceAttachmentPath( ).toOSString( ) ).exists( ) - || !SourceAttachUtil.isSourceCodeFor( element.getSourceAttachmentPath( ).toOSString( ), - SourceAttachUtil.getBinFile( element ).getAbsolutePath( ) ) ) - { - attachSource( element, sourceTempFile ); - } - } - } - } - } - - public static boolean attachSource( final IPackageFragmentRoot root, final File sourcePath ) throws Exception - { - boolean attached = false; - try - { - final SourceAttacher attacher = (SourceAttacher) Class - .forName( "org.sf.feeling.decompiler.source.attach.attacher.InternalBasedSourceAttacherImpl36" ) //$NON-NLS-1$ - .newInstance( ); - Logger.debug( "Trying (using InternalBasedSourceAttacherImpl36): " + sourcePath, null ); //$NON-NLS-1$ - attached = attacher.attachSource( root, sourcePath ); - } - catch ( Throwable e ) - { - Logger.debug( "Exception when trying InternalBasedSourceAttacherImpl36 to attach to " + sourcePath, e ); //$NON-NLS-1$ - } - if ( !attached ) - { - Logger.debug( "Previous attempt failed: " + sourcePath, null ); //$NON-NLS-1$ - try - { - final SourceAttacher attacher = (SourceAttacher) Class - .forName( "org.sf.feeling.decompiler.source.attach.attacher.InternalBasedSourceAttacherImpl35" ) //$NON-NLS-1$ - .newInstance( ); - Logger.debug( "Trying (using InternalBasedSourceAttacherImpl35): " + sourcePath, null ); //$NON-NLS-1$ - attached = attacher.attachSource( root, sourcePath ); - } - catch ( Throwable e ) - { - Logger.debug( "Exception when trying InternalBasedSourceAttacherImpl35 to attach to " + sourcePath, e ); //$NON-NLS-1$ - } - } - if ( !attached ) - { - Logger.debug( "Previous attempt failed: " + sourcePath, null ); //$NON-NLS-1$ - try - { - final SourceAttacher attacher = (SourceAttacher) Class - .forName( "org.sf.feeling.decompiler.source.attach.attacher.MySourceAttacher" ) //$NON-NLS-1$ - .newInstance( ); - Logger.debug( "Trying (using MySourceAttacher): " + sourcePath, null ); //$NON-NLS-1$ - attached = attacher.attachSource( root, sourcePath ); - } - catch ( Throwable e ) - { - Logger.debug( "Exception when trying MySourceAttacher to attach to " + sourcePath, e ); //$NON-NLS-1$ - } - } - if ( !attached ) - { - Logger.debug( "Previous attempt failed: " + sourcePath, null ); //$NON-NLS-1$ - try - { - final SourceAttacher attacher = (SourceAttacher) Class - .forName( "org.sf.feeling.decompiler.source.attach.attacher.MySourceAttacher2" ) //$NON-NLS-1$ - .newInstance( ); - Logger.debug( "Trying (using MySourceAttacher2): " + sourcePath, null ); //$NON-NLS-1$ - attached = attacher.attachSource( root, sourcePath ); - } - catch ( Throwable e ) - { - Logger.debug( "Exception when trying MySourceAttacher2 to attach to " + sourcePath, e ); //$NON-NLS-1$ - } - } - if ( attached ) - { - SourceAttachUtil.updateSourceAttachStatus( root ); - Logger.debug( "Attached library source " + sourcePath, null ); //$NON-NLS-1$ - } - else - { - Logger.info( "Failed to attach library source " + sourcePath ); //$NON-NLS-1$ - } - - return attached; - } -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/i18n/Messages.java b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/i18n/Messages.java deleted file mode 100644 index aefa7d69..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/i18n/Messages.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.source.attach.i18n; - -import java.io.UnsupportedEncodingException; -import java.text.MessageFormat; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -public class Messages -{ - - private static final String BUNDLE_NAME = "org.sf.feeling.decompiler.source.attach.i18n.messages"; //$NON-NLS-1$ - - public static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); - - private Messages( ) - { - } - - public static String getString( String key ) - { - - try - { - String result = RESOURCE_BUNDLE.getString( key ); - try - { - result = new String( result.getBytes( "ISO-8859-1" ), "utf-8" ); //$NON-NLS-1$ //$NON-NLS-2$ - } - catch ( UnsupportedEncodingException e ) - { - return '!' + key + '!'; - } - return result; - } - catch ( MissingResourceException e ) - { - return '!' + key + '!'; - } - } - - /** - * Gets formatted translation for current local - * - * @param key - * the key - * @return translated value string - */ - public static String getFormattedString( String key, Object[] arguments ) - { - return MessageFormat.format( getString( key ), arguments ); - } - -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/i18n/messages.properties b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/i18n/messages.properties deleted file mode 100644 index df1152d7..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/i18n/messages.properties +++ /dev/null @@ -1,14 +0,0 @@ -############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation -############################################################################### - -AttachSourceAction.Action.Name=Attach Library Source -AttachSourceHandler.Job.Name=Attaching source to library... -JavaSourceAttacherHandler.Job.Name=Attaching source to library... diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/i18n/messages_zh_CN.properties b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/i18n/messages_zh_CN.properties deleted file mode 100644 index 1c8a6b56..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/i18n/messages_zh_CN.properties +++ /dev/null @@ -1,14 +0,0 @@ -############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation -############################################################################### - -AttachSourceAction.Action.Name=绑定类库æºç  -AttachSourceHandler.Job.Name=正在å°è¯•绑定类库æºç ... -JavaSourceAttacherHandler.Job.Name=正在å°è¯•绑定类库æºç ... diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/i18n/messages_zh_HK.properties b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/i18n/messages_zh_HK.properties deleted file mode 100644 index 64de6b85..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/i18n/messages_zh_HK.properties +++ /dev/null @@ -1,14 +0,0 @@ -############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation -############################################################################### - -AttachSourceAction.Action.Name=ç¶å®šé¡žåº«æºç¢¼ -AttachSourceHandler.Job.Name=正在嘗試ç¶å®šé¡žåº«æºç¢¼... -JavaSourceAttacherHandler.Job.Name=正在嘗試ç¶å®šé¡žåº«æºç¢¼... diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/i18n/messages_zh_TW.properties b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/i18n/messages_zh_TW.properties deleted file mode 100644 index 7d4a81a3..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/i18n/messages_zh_TW.properties +++ /dev/null @@ -1,14 +0,0 @@ -############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation -############################################################################### - -AttachSourceAction.Action.Name=ç¶å®šé¡žåº«æºç¢¼ -AttachSourceHandler.Job.Name=正在嘗試ç¶å®šé¡žåº«æºç¢¼... -JavaSourceAttacherHandler.Job.Name=正在嘗試ç¶å®šé¡žåº«æºç¢¼... \ No newline at end of file diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/m2e/DownloadSourcesActionDelegate.java b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/m2e/DownloadSourcesActionDelegate.java deleted file mode 100644 index 6600de6b..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/m2e/DownloadSourcesActionDelegate.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.source.attach.m2e; - -import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ui.IEditorActionDelegate; -import org.eclipse.ui.IEditorPart; -import org.sf.feeling.decompiler.source.attach.utils.SourceAttachUtil; - -@SuppressWarnings("restriction") -public class DownloadSourcesActionDelegate implements IEditorActionDelegate -{ - - @Override - public void setActiveEditor( IAction action, IEditorPart part ) - { - if ( ( part != null ) && ( ( part.getEditorInput( ) instanceof IClassFileEditorInput ) ) ) - { - if ( SourceAttachUtil.enableMavenDownload( ) ) - { - new MavenSourceDownloader( ).downloadSource( part ); - } - } - } - - @Override - public void run( IAction action ) - { - } - - @Override - public void selectionChanged( IAction action, ISelection selection ) - { - } -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/m2e/MavenSourceDownloader.java b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/m2e/MavenSourceDownloader.java deleted file mode 100644 index 2c5a672a..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/m2e/MavenSourceDownloader.java +++ /dev/null @@ -1,140 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.source.attach.m2e; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; -import java.util.concurrent.ConcurrentSkipListSet; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.internal.core.PackageFragmentRoot; -import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput; -import org.eclipse.m2e.jdt.IClasspathManager; -import org.eclipse.m2e.jdt.MavenJdtPlugin; -import org.eclipse.ui.IEditorPart; -import org.sf.feeling.decompiler.source.attach.handler.AttachSourceHandler; -import org.sf.feeling.decompiler.source.attach.handler.JavaSourceAttacherHandler; -import org.sf.feeling.decompiler.source.attach.utils.SourceAttachUtil; -import org.sf.feeling.decompiler.util.Logger; - -@SuppressWarnings("restriction") -public class MavenSourceDownloader -{ - - private IPackageFragmentRoot root = null; - private static Set librarys = new ConcurrentSkipListSet( ); - - public void downloadSource( IEditorPart part ) - { - root = null; - try - { - IClasspathManager buildpathManager = MavenJdtPlugin.getDefault( ).getBuildpathManager( ); - IClassFileEditorInput input = (IClassFileEditorInput) part.getEditorInput( ); - IJavaElement element = input.getClassFile( ); - while ( element.getParent( ) != null ) - { - element = element.getParent( ); - if ( ( element instanceof IPackageFragmentRoot ) ) - { - root = (IPackageFragmentRoot) element; - if ( root.getPath( ) == null || root.getPath( ).toOSString( ) == null ) - continue; - if ( librarys.contains( root.getPath( ).toOSString( ) ) ) - { - continue; - } - else - { - librarys.add( root.getPath( ).toOSString( ) ); - } - if ( !SourceAttachUtil.isMavenLibrary( root ) ) - { - continue; - } - final IPath sourcePath = root.getSourceAttachmentPath( ); - if ( sourcePath != null && sourcePath.toOSString( ) != null ) - { - File tempfile = new File( sourcePath.toOSString( ) ); - if ( tempfile.exists( ) && tempfile.isFile( ) ) - { - break; - } - } - buildpathManager.scheduleDownload( root, true, false ); - - Thread thread = new Thread( ) { - - @Override - public void run( ) - { - if ( root instanceof PackageFragmentRoot ) - { - long time = System.currentTimeMillis( ); - PackageFragmentRoot fRoot = (PackageFragmentRoot) root; - while ( true ) - { - if ( System.currentTimeMillis( ) - time > 60 * 1000 ) - { - new AttachSourceHandler( ).execute( root, true ); - break; - } - try - { - if ( fRoot.getSourceAttachmentPath( ) != null - && fRoot.getSourceAttachmentPath( ).toFile( ).exists( ) ) - { - SourceAttachUtil.updateSourceAttachStatus( fRoot ); - break; - } - } - catch ( JavaModelException e ) - { - Logger.debug( e ); - break; - } - } - } - } - }; - thread.setDaemon( true ); - thread.start( ); - } - } - } - catch ( JavaModelException e ) - { - Logger.debug( e ); - if ( root != null ) - { - final List selections = new ArrayList( ); - selections.add( root ); - Thread thread = new Thread( ) { - - @Override - public void run( ) - { - JavaSourceAttacherHandler.updateSourceAttachments( selections, null ); - } - }; - thread.setDaemon( true ); - thread.start( ); - } - } - } - -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/utils/MethodUtils.java b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/utils/MethodUtils.java deleted file mode 100644 index 9af9bad5..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/utils/MethodUtils.java +++ /dev/null @@ -1,1521 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.source.attach.utils; - -import java.lang.ref.Reference; -import java.lang.ref.WeakReference; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.HashMap; - -@SuppressWarnings({ - "rawtypes", "unchecked" -}) -public class MethodUtils -{ - - // --------------------------------------------------------- Private Methods - - /** - * Only log warning about accessibility work around once. - *

      - * Note that this is broken when this class is deployed via a shared - * classloader in a container, as the warning message will be emitted only - * once, not once per webapp. However making the warning appear once per - * webapp means having a map keyed by context classloader which introduces - * nasty memory-leak problems. As this warning is really optional we can - * ignore this problem; only one of the webapps will get the warning in its - * logs but that should be good enough. - */ - private static boolean loggedAccessibleWarning = false; - - /** - * Indicates whether methods should be cached for improved performance. - *

      - * Note that when this class is deployed via a shared classloader in a - * container, this will affect all webapps. However making this configurable - * per webapp would mean having a map keyed by context classloader which may - * introduce memory-leak problems. - */ - private static boolean CACHE_METHODS = true; - - /** An empty class array */ - private static final Class[] EMPTY_CLASS_PARAMETERS = new Class[0]; - /** An empty object array */ - private static final Object[] EMPTY_OBJECT_ARRAY = new Object[0]; - - /** - * Stores a cache of MethodDescriptor -> Method in a WeakHashMap. - *

      - * The keys into this map only ever exist as temporary variables within - * methods of this class, and are never exposed to users of this class. This - * means that the WeakHashMap is used only as a mechanism for limiting the - * size of the cache, ie a way to tell the garbage collector that the - * contents of the cache can be completely garbage-collected whenever it - * needs the memory. Whether this is a good approach to this problem is - * doubtful; something like the commons-collections LRUMap may be more - * appropriate (though of course selecting an appropriate size is an issue). - *

      - * This static variable is safe even when this code is deployed via a shared - * classloader because it is keyed via a MethodDescriptor object which has a - * Class as one of its members and that member is used in the - * MethodDescriptor.equals method. So two components that load the same - * class via different classloaders will generate non-equal MethodDescriptor - * objects and hence end up with different entries in the map. - */ - private static final HashMap cache = new HashMap( ); - - /** - * Set whether methods should be cached for greater performance or not, - * default is true. - * - * @param cacheMethods - * true if methods should be cached for greater - * performance, otherwise false - */ - public static synchronized void setCacheMethods( boolean cacheMethods ) - { - CACHE_METHODS = cacheMethods; - if ( !CACHE_METHODS ) - { - clearCache( ); - } - } - - /** - * Clear the method cache. - * - * @return the number of cached methods cleared - */ - public static synchronized int clearCache( ) - { - int size = cache.size( ); - cache.clear( ); - return size; - } - - /** - *

      - * Invoke a named method whose parameter type matches the object type. - *

      - * - *

      - * The behaviour of this method is less deterministic than - * invokeExactMethod(). It loops through all methods with names - * that match and then executes the first it finds with compatable - * parameters. - *

      - * - *

      - * This method supports calls to methods taking primitive parameters via - * passing in wrapping classes. So, for example, a Boolean - * class would match a boolean primitive. - *

      - * - *

      - * This is a convenient wrapper for - * {@link #invokeMethod(Object object,String methodName,Object [] args)}. - *

      - * - * @param object - * invoke method on this object - * @param methodName - * get method with this name - * @param arg - * use this argument - * @return The value returned by the invoked method - * - * @throws NoSuchMethodException - * if there is no such accessible method - * @throws InvocationTargetException - * wraps an exception thrown by the method invoked - * @throws IllegalAccessException - * if the requested method is not accessible via reflection - */ - public static Object invokeMethod( Object object, String methodName, Object arg ) - throws NoSuchMethodException, IllegalAccessException, InvocationTargetException - { - - Object[] args = { - arg - }; - return invokeMethod( object, methodName, args ); - - } - - /** - *

      - * Invoke a named method whose parameter type matches the object type. - *

      - * - *

      - * The behaviour of this method is less deterministic than - * {@link #invokeExactMethod(Object object,String methodName,Object [] args)} - * . It loops through all methods with names that match and then executes - * the first it finds with compatable parameters. - *

      - * - *

      - * This method supports calls to methods taking primitive parameters via - * passing in wrapping classes. So, for example, a Boolean - * class would match a boolean primitive. - *

      - * - *

      - * This is a convenient wrapper for - * {@link #invokeMethod(Object object,String methodName,Object [] args,Class[] parameterTypes)} - * . - *

      - * - * @param object - * invoke method on this object - * @param methodName - * get method with this name - * @param args - * use these arguments - treat null as empty array - * @return The value returned by the invoked method - * - * @throws NoSuchMethodException - * if there is no such accessible method - * @throws InvocationTargetException - * wraps an exception thrown by the method invoked - * @throws IllegalAccessException - * if the requested method is not accessible via reflection - */ - public static Object invokeMethod( Object object, String methodName, Object[] args ) - throws NoSuchMethodException, IllegalAccessException, InvocationTargetException - { - - if ( args == null ) - { - args = EMPTY_OBJECT_ARRAY; - } - int arguments = args.length; - Class[] parameterTypes = new Class[arguments]; - for ( int i = 0; i < arguments; i++ ) - { - parameterTypes[i] = args[i].getClass( ); - } - return invokeMethod( object, methodName, args, parameterTypes ); - - } - - /** - *

      - * Invoke a named method whose parameter type matches the object type. - *

      - * - *

      - * The behaviour of this method is less deterministic than - * {@link #invokeExactMethod(Object object,String methodName,Object [] args,Class[] parameterTypes)} - * . It loops through all methods with names that match and then executes - * the first it finds with compatable parameters. - *

      - * - *

      - * This method supports calls to methods taking primitive parameters via - * passing in wrapping classes. So, for example, a Boolean - * class would match a boolean primitive. - *

      - * - * - * @param object - * invoke method on this object - * @param methodName - * get method with this name - * @param args - * use these arguments - treat null as empty array - * @param parameterTypes - * match these parameters - treat null as empty array - * @return The value returned by the invoked method - * - * @throws NoSuchMethodException - * if there is no such accessible method - * @throws InvocationTargetException - * wraps an exception thrown by the method invoked - * @throws IllegalAccessException - * if the requested method is not accessible via reflection - */ - public static Object invokeMethod( Object object, String methodName, Object[] args, Class[] parameterTypes ) - throws NoSuchMethodException, IllegalAccessException, InvocationTargetException - { - - if ( parameterTypes == null ) - { - parameterTypes = EMPTY_CLASS_PARAMETERS; - } - if ( args == null ) - { - args = EMPTY_OBJECT_ARRAY; - } - - Method method = getMatchingAccessibleMethod( object.getClass( ), methodName, parameterTypes ); - if ( method == null ) - { - throw new NoSuchMethodException( - "No such accessible method: " + methodName + "() on object: " + object.getClass( ).getName( ) ); //$NON-NLS-1$ //$NON-NLS-2$ - } - return method.invoke( object, args ); - } - - /** - *

      - * Invoke a method whose parameter type matches exactly the object type. - *

      - * - *

      - * This is a convenient wrapper for - * {@link #invokeExactMethod(Object object,String methodName,Object [] args)} - * . - *

      - * - * @param object - * invoke method on this object - * @param methodName - * get method with this name - * @param arg - * use this argument - * @return The value returned by the invoked method - * - * @throws NoSuchMethodException - * if there is no such accessible method - * @throws InvocationTargetException - * wraps an exception thrown by the method invoked - * @throws IllegalAccessException - * if the requested method is not accessible via reflection - */ - public static Object invokeExactMethod( Object object, String methodName, Object arg ) - throws NoSuchMethodException, IllegalAccessException, InvocationTargetException - { - - Object[] args = { - arg - }; - return invokeExactMethod( object, methodName, args ); - - } - - /** - *

      - * Invoke a method whose parameter types match exactly the object types. - *

      - * - *

      - * This uses reflection to invoke the method obtained from a call to - * getAccessibleMethod(). - *

      - * - * @param object - * invoke method on this object - * @param methodName - * get method with this name - * @param args - * use these arguments - treat null as empty array - * @return The value returned by the invoked method - * - * @throws NoSuchMethodException - * if there is no such accessible method - * @throws InvocationTargetException - * wraps an exception thrown by the method invoked - * @throws IllegalAccessException - * if the requested method is not accessible via reflection - */ - public static Object invokeExactMethod( Object object, String methodName, Object[] args ) - throws NoSuchMethodException, IllegalAccessException, InvocationTargetException - { - if ( args == null ) - { - args = EMPTY_OBJECT_ARRAY; - } - int arguments = args.length; - Class[] parameterTypes = new Class[arguments]; - for ( int i = 0; i < arguments; i++ ) - { - parameterTypes[i] = args[i].getClass( ); - } - return invokeExactMethod( object, methodName, args, parameterTypes ); - - } - - /** - *

      - * Invoke a method whose parameter types match exactly the parameter types - * given. - *

      - * - *

      - * This uses reflection to invoke the method obtained from a call to - * getAccessibleMethod(). - *

      - * - * @param object - * invoke method on this object - * @param methodName - * get method with this name - * @param args - * use these arguments - treat null as empty array - * @param parameterTypes - * match these parameters - treat null as empty array - * @return The value returned by the invoked method - * - * @throws NoSuchMethodException - * if there is no such accessible method - * @throws InvocationTargetException - * wraps an exception thrown by the method invoked - * @throws IllegalAccessException - * if the requested method is not accessible via reflection - */ - public static Object invokeExactMethod( Object object, String methodName, Object[] args, Class[] parameterTypes ) - throws NoSuchMethodException, IllegalAccessException, InvocationTargetException - { - - if ( args == null ) - { - args = EMPTY_OBJECT_ARRAY; - } - - if ( parameterTypes == null ) - { - parameterTypes = EMPTY_CLASS_PARAMETERS; - } - - Method method = getAccessibleMethod( object.getClass( ), methodName, parameterTypes ); - if ( method == null ) - { - throw new NoSuchMethodException( - "No such accessible method: " + methodName + "() on object: " + object.getClass( ).getName( ) ); //$NON-NLS-1$ //$NON-NLS-2$ - } - return method.invoke( object, args ); - - } - - /** - *

      - * Invoke a static method whose parameter types match exactly the parameter - * types given. - *

      - * - *

      - * This uses reflection to invoke the method obtained from a call to - * {@link #getAccessibleMethod(Class, String, Class[])}. - *

      - * - * @param objectClass - * invoke static method on this class - * @param methodName - * get method with this name - * @param args - * use these arguments - treat null as empty array - * @param parameterTypes - * match these parameters - treat null as empty array - * @return The value returned by the invoked method - * - * @throws NoSuchMethodException - * if there is no such accessible method - * @throws InvocationTargetException - * wraps an exception thrown by the method invoked - * @throws IllegalAccessException - * if the requested method is not accessible via reflection - */ - public static Object invokeExactStaticMethod( Class objectClass, String methodName, Object[] args, - Class[] parameterTypes ) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException - { - - if ( args == null ) - { - args = EMPTY_OBJECT_ARRAY; - } - - if ( parameterTypes == null ) - { - parameterTypes = EMPTY_CLASS_PARAMETERS; - } - - Method method = getAccessibleMethod( objectClass, methodName, parameterTypes ); - if ( method == null ) - { - throw new NoSuchMethodException( - "No such accessible method: " + methodName + "() on class: " + objectClass.getName( ) ); //$NON-NLS-1$ //$NON-NLS-2$ - } - return method.invoke( null, args ); - - } - - /** - *

      - * Invoke a named static method whose parameter type matches the object - * type. - *

      - * - *

      - * The behaviour of this method is less deterministic than - * {@link #invokeExactMethod(Object, String, Object[], Class[])}. It loops - * through all methods with names that match and then executes the first it - * finds with compatable parameters. - *

      - * - *

      - * This method supports calls to methods taking primitive parameters via - * passing in wrapping classes. So, for example, a Boolean - * class would match a boolean primitive. - *

      - * - *

      - * This is a convenient wrapper for - * {@link #invokeStaticMethod(Class objectClass,String methodName,Object [] args)} - * . - *

      - * - * @param objectClass - * invoke static method on this class - * @param methodName - * get method with this name - * @param arg - * use this argument - * @return The value returned by the invoked method - * - * @throws NoSuchMethodException - * if there is no such accessible method - * @throws InvocationTargetException - * wraps an exception thrown by the method invoked - * @throws IllegalAccessException - * if the requested method is not accessible via reflection - */ - public static Object invokeStaticMethod( Class objectClass, String methodName, Object arg ) - throws NoSuchMethodException, IllegalAccessException, InvocationTargetException - { - - Object[] args = { - arg - }; - return invokeStaticMethod( objectClass, methodName, args ); - - } - - /** - *

      - * Invoke a named static method whose parameter type matches the object - * type. - *

      - * - *

      - * The behaviour of this method is less deterministic than - * {@link #invokeExactMethod(Object object,String methodName,Object [] args)} - * . It loops through all methods with names that match and then executes - * the first it finds with compatable parameters. - *

      - * - *

      - * This method supports calls to methods taking primitive parameters via - * passing in wrapping classes. So, for example, a Boolean - * class would match a boolean primitive. - *

      - * - *

      - * This is a convenient wrapper for - * {@link #invokeStaticMethod(Class objectClass,String methodName,Object [] args,Class[] parameterTypes)} - * . - *

      - * - * @param objectClass - * invoke static method on this class - * @param methodName - * get method with this name - * @param args - * use these arguments - treat null as empty array - * @return The value returned by the invoked method - * - * @throws NoSuchMethodException - * if there is no such accessible method - * @throws InvocationTargetException - * wraps an exception thrown by the method invoked - * @throws IllegalAccessException - * if the requested method is not accessible via reflection - */ - public static Object invokeStaticMethod( Class objectClass, String methodName, Object[] args ) - throws NoSuchMethodException, IllegalAccessException, InvocationTargetException - { - - if ( args == null ) - { - args = EMPTY_OBJECT_ARRAY; - } - int arguments = args.length; - Class[] parameterTypes = new Class[arguments]; - for ( int i = 0; i < arguments; i++ ) - { - parameterTypes[i] = args[i].getClass( ); - } - return invokeStaticMethod( objectClass, methodName, args, parameterTypes ); - - } - - /** - *

      - * Invoke a named static method whose parameter type matches the object - * type. - *

      - * - *

      - * The behaviour of this method is less deterministic than - * {@link #invokeExactStaticMethod(Class objectClass,String methodName,Object [] args,Class[] parameterTypes)} - * . It loops through all methods with names that match and then executes - * the first it finds with compatable parameters. - *

      - * - *

      - * This method supports calls to methods taking primitive parameters via - * passing in wrapping classes. So, for example, a Boolean - * class would match a boolean primitive. - *

      - * - * - * @param objectClass - * invoke static method on this class - * @param methodName - * get method with this name - * @param args - * use these arguments - treat null as empty array - * @param parameterTypes - * match these parameters - treat null as empty array - * @return The value returned by the invoked method - * - * @throws NoSuchMethodException - * if there is no such accessible method - * @throws InvocationTargetException - * wraps an exception thrown by the method invoked - * @throws IllegalAccessException - * if the requested method is not accessible via reflection - */ - public static Object invokeStaticMethod( Class objectClass, String methodName, Object[] args, - Class[] parameterTypes ) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException - { - - if ( parameterTypes == null ) - { - parameterTypes = EMPTY_CLASS_PARAMETERS; - } - if ( args == null ) - { - args = EMPTY_OBJECT_ARRAY; - } - - Method method = getMatchingAccessibleMethod( objectClass, methodName, parameterTypes ); - if ( method == null ) - { - throw new NoSuchMethodException( - "No such accessible method: " + methodName + "() on class: " + objectClass.getName( ) ); //$NON-NLS-1$ //$NON-NLS-2$ - } - return method.invoke( null, args ); - } - - /** - *

      - * Invoke a static method whose parameter type matches exactly the object - * type. - *

      - * - *

      - * This is a convenient wrapper for - * {@link #invokeExactStaticMethod(Class objectClass,String methodName,Object [] args)} - * . - *

      - * - * @param objectClass - * invoke static method on this class - * @param methodName - * get method with this name - * @param arg - * use this argument - * @return The value returned by the invoked method - * - * @throws NoSuchMethodException - * if there is no such accessible method - * @throws InvocationTargetException - * wraps an exception thrown by the method invoked - * @throws IllegalAccessException - * if the requested method is not accessible via reflection - */ - public static Object invokeExactStaticMethod( Class objectClass, String methodName, Object arg ) - throws NoSuchMethodException, IllegalAccessException, InvocationTargetException - { - - Object[] args = { - arg - }; - return invokeExactStaticMethod( objectClass, methodName, args ); - - } - - /** - *

      - * Invoke a static method whose parameter types match exactly the object - * types. - *

      - * - *

      - * This uses reflection to invoke the method obtained from a call to - * {@link #getAccessibleMethod(Class, String, Class[])}. - *

      - * - * @param objectClass - * invoke static method on this class - * @param methodName - * get method with this name - * @param args - * use these arguments - treat null as empty array - * @return The value returned by the invoked method - * - * @throws NoSuchMethodException - * if there is no such accessible method - * @throws InvocationTargetException - * wraps an exception thrown by the method invoked - * @throws IllegalAccessException - * if the requested method is not accessible via reflection - */ - public static Object invokeExactStaticMethod( Class objectClass, String methodName, Object[] args ) - throws NoSuchMethodException, IllegalAccessException, InvocationTargetException - { - if ( args == null ) - { - args = EMPTY_OBJECT_ARRAY; - } - int arguments = args.length; - Class[] parameterTypes = new Class[arguments]; - for ( int i = 0; i < arguments; i++ ) - { - parameterTypes[i] = args[i].getClass( ); - } - return invokeExactStaticMethod( objectClass, methodName, args, parameterTypes ); - - } - - /** - *

      - * Return an accessible method (that is, one that can be invoked via - * reflection) with given name and a single parameter. If no such method can - * be found, return null. Basically, a convenience wrapper that - * constructs a Class array for you. - *

      - * - * @param clazz - * get method from this class - * @param methodName - * get method with this name - * @param parameterType - * taking this type of parameter - * @return The accessible method - */ - public static Method getAccessibleMethod( Class clazz, String methodName, Class parameterType ) - { - - Class[] parameterTypes = { - parameterType - }; - return getAccessibleMethod( clazz, methodName, parameterTypes ); - - } - - /** - *

      - * Return an accessible method (that is, one that can be invoked via - * reflection) with given name and parameters. If no such method can be - * found, return null. This is just a convenient wrapper for - * {@link #getAccessibleMethod(Method method)}. - *

      - * - * @param clazz - * get method from this class - * @param methodName - * get method with this name - * @param parameterTypes - * with these parameters types - * @return The accessible method - */ - public static Method getAccessibleMethod( Class clazz, String methodName, Class[] parameterTypes ) - { - - try - { - MethodDescriptor md = new MethodDescriptor( clazz, methodName, parameterTypes, true ); - // Check the cache first - Method method = getCachedMethod( md ); - if ( method != null ) - { - return method; - } - - method = getAccessibleMethod( clazz, clazz.getMethod( methodName, parameterTypes ) ); - cacheMethod( md, method ); - return method; - } - catch ( NoSuchMethodException e ) - { - return ( null ); - } - - } - - /** - *

      - * Return an accessible method (that is, one that can be invoked via - * reflection) that implements the specified Method. If no such method can - * be found, return null. - *

      - * - * @param method - * The method that we wish to call - * @return The accessible method - */ - public static Method getAccessibleMethod( Method method ) - { - - // Make sure we have a method to check - if ( method == null ) - { - return ( null ); - } - - return getAccessibleMethod( method.getDeclaringClass( ), method ); - - } - - /** - *

      - * Return an accessible method (that is, one that can be invoked via - * reflection) that implements the specified Method. If no such method can - * be found, return null. - *

      - * - * @param clazz - * The class of the object - * @param method - * The method that we wish to call - * @return The accessible method - */ - public static Method getAccessibleMethod( Class clazz, Method method ) - { - - // Make sure we have a method to check - if ( method == null ) - { - return ( null ); - } - - // If the requested method is not public we cannot call it - if ( !Modifier.isPublic( method.getModifiers( ) ) ) - { - return ( null ); - } - - boolean sameClass = true; - if ( clazz == null ) - { - clazz = method.getDeclaringClass( ); - } - else - { - sameClass = clazz.equals( method.getDeclaringClass( ) ); - if ( !method.getDeclaringClass( ).isAssignableFrom( clazz ) ) - { - throw new IllegalArgumentException( - clazz.getName( ) + " is not assignable from " + method.getDeclaringClass( ).getName( ) ); //$NON-NLS-1$ - } - } - - // If the class is public, we are done - if ( Modifier.isPublic( clazz.getModifiers( ) ) ) - { - if ( !sameClass && !Modifier.isPublic( method.getDeclaringClass( ).getModifiers( ) ) ) - { - setMethodAccessible( method ); // Default access superclass - // workaround - } - return ( method ); - } - - String methodName = method.getName( ); - Class[] parameterTypes = method.getParameterTypes( ); - - // Check the implemented interfaces and subinterfaces - method = getAccessibleMethodFromInterfaceNest( clazz, methodName, parameterTypes ); - - // Check the superclass chain - if ( method == null ) - { - method = getAccessibleMethodFromSuperclass( clazz, methodName, parameterTypes ); - } - - return ( method ); - - } - - // -------------------------------------------------------- Private Methods - - /** - *

      - * Return an accessible method (that is, one that can be invoked via - * reflection) by scanning through the superclasses. If no such method can - * be found, return null. - *

      - * - * @param clazz - * Class to be checked - * @param methodName - * Method name of the method we wish to call - * @param parameterTypes - * The parameter type signatures - */ - private static Method getAccessibleMethodFromSuperclass( Class clazz, String methodName, Class[] parameterTypes ) - { - - Class parentClazz = clazz.getSuperclass( ); - while ( parentClazz != null ) - { - if ( Modifier.isPublic( parentClazz.getModifiers( ) ) ) - { - try - { - return parentClazz.getMethod( methodName, parameterTypes ); - } - catch ( NoSuchMethodException e ) - { - return null; - } - } - parentClazz = parentClazz.getSuperclass( ); - } - return null; - } - - /** - *

      - * Return an accessible method (that is, one that can be invoked via - * reflection) that implements the specified method, by scanning through all - * implemented interfaces and subinterfaces. If no such method can be found, - * return null. - *

      - * - *

      - * There isn't any good reason why this method must be private. It is - * because there doesn't seem any reason why other classes should call this - * rather than the higher level methods. - *

      - * - * @param clazz - * Parent class for the interfaces to be checked - * @param methodName - * Method name of the method we wish to call - * @param parameterTypes - * The parameter type signatures - */ - private static Method getAccessibleMethodFromInterfaceNest( Class clazz, String methodName, Class[] parameterTypes ) - { - - Method method = null; - - // Search up the superclass chain - for ( ; clazz != null; clazz = clazz.getSuperclass( ) ) - { - - // Check the implemented interfaces of the parent class - Class[] interfaces = clazz.getInterfaces( ); - for ( int i = 0; i < interfaces.length; i++ ) - { - - // Is this interface public? - if ( !Modifier.isPublic( interfaces[i].getModifiers( ) ) ) - { - continue; - } - - // Does the method exist on this interface? - try - { - method = interfaces[i].getDeclaredMethod( methodName, parameterTypes ); - } - catch ( NoSuchMethodException e ) - { - /* - * Swallow, if no method is found after the loop then this - * method returns null. - */ - } - if ( method != null ) - { - return method; - } - - // Recursively check our parent interfaces - method = getAccessibleMethodFromInterfaceNest( interfaces[i], methodName, parameterTypes ); - if ( method != null ) - { - return method; - } - - } - - } - - return method; - } - - /** - *

      - * Find an accessible method that matches the given name and has compatible - * parameters. Compatible parameters mean that every method parameter is - * assignable from the given parameters. In other words, it finds a method - * with the given name that will take the parameters given. - *

      - * - *

      - * This method is slightly undeterminstic since it loops through methods - * names and return the first matching method. - *

      - * - *

      - * This method is used by - * {@link #invokeMethod(Object object,String methodName,Object [] args,Class[] parameterTypes)}. - * - *

      - * This method can match primitive parameter by passing in wrapper classes. - * For example, a Boolean will match a primitive - * boolean parameter. - * - * @param clazz - * find method in this class - * @param methodName - * find method with this name - * @param parameterTypes - * find method with compatible parameters - * @return The accessible method - */ - public static Method getMatchingAccessibleMethod( Class clazz, String methodName, Class[] parameterTypes ) - { - MethodDescriptor md = new MethodDescriptor( clazz, methodName, parameterTypes, false ); - - // see if we can find the method directly - // most of the time this works and it's much faster - try - { - // Check the cache first - Method method = getCachedMethod( md ); - if ( method != null ) - { - return method; - } - - method = clazz.getMethod( methodName, parameterTypes ); - - setMethodAccessible( method ); // Default access superclass - // workaround - - cacheMethod( md, method ); - return method; - - } - catch ( NoSuchMethodException e ) - { /* SWALLOW */ - } - - // search through all methods - int paramSize = parameterTypes.length; - Method bestMatch = null; - Method[] methods = clazz.getMethods( ); - float bestMatchCost = Float.MAX_VALUE; - float myCost = Float.MAX_VALUE; - for ( int i = 0, size = methods.length; i < size; i++ ) - { - if ( methods[i].getName( ).equals( methodName ) ) - { - - // compare parameters - Class[] methodsParams = methods[i].getParameterTypes( ); - int methodParamSize = methodsParams.length; - if ( methodParamSize == paramSize ) - { - boolean match = true; - for ( int n = 0; n < methodParamSize; n++ ) - { - - if ( !isAssignmentCompatible( methodsParams[n], parameterTypes[n] ) ) - { - - match = false; - break; - } - } - - if ( match ) - { - // get accessible version of method - Method method = getAccessibleMethod( clazz, methods[i] ); - if ( method != null ) - { - - setMethodAccessible( method ); // Default access - // superclass - // workaround - myCost = getTotalTransformationCost( parameterTypes, method.getParameterTypes( ) ); - if ( myCost < bestMatchCost ) - { - bestMatch = method; - bestMatchCost = myCost; - } - } - - } - } - } - } - if ( bestMatch != null ) - { - cacheMethod( md, bestMatch ); - } - else - { - // didn't find a match - - } - - return bestMatch; - } - - /** - * Try to make the method accessible - * - * @param method - * The source arguments - */ - private static void setMethodAccessible( Method method ) - { - try - { - // - // XXX Default access superclass workaround - // - // When a public class has a default access superclass - // with public methods, these methods are accessible. - // Calling them from compiled code works fine. - // - // Unfortunately, using reflection to invoke these methods - // seems to (wrongly) to prevent access even when the method - // modifer is public. - // - // The following workaround solves the problem but will only - // work from sufficiently privilages code. - // - // Better workarounds would be greatfully accepted. - // - method.setAccessible( true ); - - } - catch ( SecurityException se ) - { - // log but continue just in case the method.invoke works anyway - if ( !loggedAccessibleWarning ) - { - boolean vulnerableJVM = false; - try - { - String specVersion = System.getProperty( "java.specification.version" ); //$NON-NLS-1$ - if ( specVersion.charAt( 0 ) == '1' - && ( specVersion.charAt( 2 ) == '0' - || specVersion.charAt( 2 ) == '1' - || specVersion.charAt( 2 ) == '2' - || specVersion.charAt( 2 ) == '3' ) ) - { - - vulnerableJVM = true; - } - } - catch ( SecurityException e ) - { - // don't know - so display warning - vulnerableJVM = true; - } - if ( vulnerableJVM ) - { - - } - loggedAccessibleWarning = true; - } - - } - } - - /** - * Returns the sum of the object transformation cost for each class in the - * source argument list. - * - * @param srcArgs - * The source arguments - * @param destArgs - * The destination arguments - * @return The total transformation cost - */ - private static float getTotalTransformationCost( Class[] srcArgs, Class[] destArgs ) - { - - float totalCost = 0.0f; - for ( int i = 0; i < srcArgs.length; i++ ) - { - Class srcClass, destClass; - srcClass = srcArgs[i]; - destClass = destArgs[i]; - totalCost += getObjectTransformationCost( srcClass, destClass ); - } - - return totalCost; - } - - /** - * Gets the number of steps required needed to turn the source class into - * the destination class. This represents the number of steps in the object - * hierarchy graph. - * - * @param srcClass - * The source class - * @param destClass - * The destination class - * @return The cost of transforming an object - */ - private static float getObjectTransformationCost( Class srcClass, Class destClass ) - { - float cost = 0.0f; - while ( destClass != null && !destClass.equals( srcClass ) ) - { - if ( destClass.isInterface( ) && isAssignmentCompatible( destClass, srcClass ) ) - { - // slight penalty for interface match. - // we still want an exact match to override an interface match, - // but - // an interface match should override anything where we have to - // get a - // superclass. - cost += 0.25f; - break; - } - cost++; - destClass = destClass.getSuperclass( ); - } - - /* - * If the destination class is null, we've travelled all the way up to - * an Object match. We'll penalize this by adding 1.5 to the cost. - */ - if ( destClass == null ) - { - cost += 1.5f; - } - - return cost; - } - - /** - *

      - * Determine whether a type can be used as a parameter in a method - * invocation. This method handles primitive conversions correctly. - *

      - * - *

      - * In order words, it will match a Boolean to a - * boolean, a Long to a long, a - * Float to a float, a Integer to a - * int, and a Double to a double. Now - * logic widening matches are allowed. For example, a Long will - * not match a int. - * - * @param parameterType - * the type of parameter accepted by the method - * @param parameterization - * the type of parameter being tested - * - * @return true if the assignement is compatible. - */ - public static final boolean isAssignmentCompatible( Class parameterType, Class parameterization ) - { - // try plain assignment - if ( parameterType.isAssignableFrom( parameterization ) ) - { - return true; - } - - if ( parameterType.isPrimitive( ) ) - { - // this method does *not* do widening - you must specify exactly - // is this the right behaviour? - Class parameterWrapperClazz = getPrimitiveWrapper( parameterType ); - if ( parameterWrapperClazz != null ) - { - return parameterWrapperClazz.equals( parameterization ); - } - } - - return false; - } - - /** - * Gets the wrapper object class for the given primitive type class. For - * example, passing boolean.class returns - * Boolean.class - * - * @param primitiveType - * the primitive type class for which a match is to be found - * @return the wrapper type associated with the given primitive or null if - * no match is found - */ - public static Class getPrimitiveWrapper( Class primitiveType ) - { - // does anyone know a better strategy than comparing names? - if ( boolean.class.equals( primitiveType ) ) - { - return Boolean.class; - } - else if ( float.class.equals( primitiveType ) ) - { - return Float.class; - } - else if ( long.class.equals( primitiveType ) ) - { - return Long.class; - } - else if ( int.class.equals( primitiveType ) ) - { - return Integer.class; - } - else if ( short.class.equals( primitiveType ) ) - { - return Short.class; - } - else if ( byte.class.equals( primitiveType ) ) - { - return Byte.class; - } - else if ( double.class.equals( primitiveType ) ) - { - return Double.class; - } - else if ( char.class.equals( primitiveType ) ) - { - return Character.class; - } - else - { - - return null; - } - } - - /** - * Gets the class for the primitive type corresponding to the primitive - * wrapper class given. For example, an instance of - * Boolean.class returns a boolean.class. - * - * @param wrapperType - * the - * @return the primitive type class corresponding to the given wrapper - * class, null if no match is found - */ - public static Class getPrimitiveType( Class wrapperType ) - { - // does anyone know a better strategy than comparing names? - if ( Boolean.class.equals( wrapperType ) ) - { - return boolean.class; - } - else if ( Float.class.equals( wrapperType ) ) - { - return float.class; - } - else if ( Long.class.equals( wrapperType ) ) - { - return long.class; - } - else if ( Integer.class.equals( wrapperType ) ) - { - return int.class; - } - else if ( Short.class.equals( wrapperType ) ) - { - return short.class; - } - else if ( Byte.class.equals( wrapperType ) ) - { - return byte.class; - } - else if ( Double.class.equals( wrapperType ) ) - { - return double.class; - } - else if ( Character.class.equals( wrapperType ) ) - { - return char.class; - } - else - { - return null; - } - } - - /** - * Find a non primitive representation for given primitive class. - * - * @param clazz - * the class to find a representation for, not null - * @return the original class if it not a primitive. Otherwise the wrapper - * class. Not null - */ - public static Class toNonPrimitiveClass( Class clazz ) - { - if ( clazz.isPrimitive( ) ) - { - Class primitiveClazz = MethodUtils.getPrimitiveWrapper( clazz ); - // the above method returns - if ( primitiveClazz != null ) - { - return primitiveClazz; - } - else - { - return clazz; - } - } - else - { - return clazz; - } - } - - /** - * Return the method from the cache, if present. - * - * @param md - * The method descriptor - * @return The cached method - */ - private static Method getCachedMethod( MethodDescriptor md ) - { - if ( CACHE_METHODS ) - { - Reference methodRef = (Reference) cache.get( md ); - if ( methodRef != null ) - { - return (Method) methodRef.get( ); - } - } - return null; - } - - /** - * Add a method to the cache. - * - * @param md - * The method descriptor - * @param method - * The method to cache - */ - private static void cacheMethod( MethodDescriptor md, Method method ) - { - if ( CACHE_METHODS ) - { - if ( method != null ) - { - cache.put( md, new WeakReference( method ) ); - } - } - } - - /** - * Represents the key to looking up a Method by reflection. - */ - private static class MethodDescriptor - { - - private Class cls; - private String methodName; - private Class[] paramTypes; - private boolean exact; - private int hashCode; - - /** - * The sole constructor. - * - * @param cls - * the class to reflect, must not be null - * @param methodName - * the method name to obtain - * @param paramTypes - * the array of classes representing the paramater types - * @param exact - * whether the match has to be exact. - */ - public MethodDescriptor( Class cls, String methodName, Class[] paramTypes, boolean exact ) - { - if ( cls == null ) - { - throw new IllegalArgumentException( "Class cannot be null" ); //$NON-NLS-1$ - } - if ( methodName == null ) - { - throw new IllegalArgumentException( "Method Name cannot be null" ); //$NON-NLS-1$ - } - if ( paramTypes == null ) - { - paramTypes = EMPTY_CLASS_PARAMETERS; - } - - this.cls = cls; - this.methodName = methodName; - this.paramTypes = paramTypes; - this.exact = exact; - - this.hashCode = methodName.length( ); - } - - /** - * Checks for equality. - * - * @param obj - * object to be tested for equality - * @return true, if the object describes the same Method. - */ - @Override - public boolean equals( Object obj ) - { - if ( !( obj instanceof MethodDescriptor ) ) - { - return false; - } - MethodDescriptor md = (MethodDescriptor) obj; - - return ( exact == md.exact - && methodName.equals( md.methodName ) - && cls.equals( md.cls ) - && java.util.Arrays.equals( paramTypes, md.paramTypes ) ); - } - - /** - * Returns the string length of method name. I.e. if the hashcodes are - * different, the objects are different. If the hashcodes are the same, - * need to use the equals method to determine equality. - * - * @return the string length of method name. - */ - @Override - public int hashCode( ) - { - return hashCode; - } - } -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/utils/SourceAttachUtil.java b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/utils/SourceAttachUtil.java deleted file mode 100644 index acdb1bc4..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/utils/SourceAttachUtil.java +++ /dev/null @@ -1,470 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.source.attach.utils; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Enumeration; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -import org.apache.commons.io.FilenameUtils; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.jdt.core.IClassFile; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.internal.core.PackageFragmentRoot; -import org.eclipse.jdt.internal.corext.util.JavaModelUtil; -import org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathSupport; -import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement; -import org.sf.feeling.decompiler.source.attach.handler.JavaSourceAttacherHandler; -import org.sf.feeling.decompiler.util.FileUtil; -import org.sf.feeling.decompiler.util.HashUtils; -import org.sf.feeling.decompiler.util.Logger; -import org.sf.feeling.decompiler.util.ReflectionUtils; - -@SuppressWarnings("restriction") -public class SourceAttachUtil -{ - - public static File getBinFile( IPackageFragmentRoot root ) - { - File binFile; - if ( !root.isExternal( ) ) - { - binFile = root.getResource( ).getLocation( ).toFile( ); - } - else - { - binFile = root.getPath( ).toFile( ); - } - return binFile; - } - - public static boolean reattchSource( final IPackageFragmentRoot pkgRoot, File sourceFile, File tempSourceFile, - String downloadUrl ) - { - try - { - IPath sourcePath = pkgRoot.getSourceAttachmentPath( ); - File tempfile = new File( sourcePath.toOSString( ) ); - File tempFile; - - if ( !tempfile.getAbsolutePath( ).equals( tempSourceFile.getAbsolutePath( ) ) ) - { - tempFile = tempSourceFile; - } - else - { - String suffix = "-" + System.currentTimeMillis( ) + ".jar"; //$NON-NLS-1$ //$NON-NLS-2$ - tempFile = new File( SourceConstants.SourceTempDir, - sourceFile.getName( ) - .replaceAll( "(?i)(\\-)*(\\d)*(\\.)jar", suffix ) //$NON-NLS-1$ - .replaceAll( "(?i)(\\-)*(\\d)*(\\.)zip", suffix ) ); //$NON-NLS-1$ - } - - if ( !tempFile.exists( ) ) - { - if ( tempSourceFile.exists( ) ) - { - tempSourceFile.renameTo( tempFile ); - } - else - { - FileUtil.copyFile( sourceFile.getAbsolutePath( ), tempFile.getAbsolutePath( ) ); - } - } - JavaSourceAttacherHandler.attachSource( pkgRoot, tempFile ); - tempFile.deleteOnExit( ); - String sha = HashUtils.sha1Hash( SourceAttachUtil.getBinFile( pkgRoot ) ); - SourceBindingUtil.saveSourceBindingRecord( sourceFile, sha, downloadUrl, tempFile ); - return true; - } - catch ( Exception e ) - { - Logger.debug( e ); - } - return false; - } - - public static boolean refreshSourceAttachStatus( final IPackageFragmentRoot root ) - { - try - { - String sha = HashUtils.sha1Hash( getBinFile( root ) ); - String[] files = SourceBindingUtil.getSourceFileBySha( sha ); - if ( files != null && files[0] != null ) - { - File sourceFile = new File( files[0] ); - if ( !sourceFile.exists( ) ) - { - return false; - } - File tempFile = new File( files[1] ); - if ( files[1] != null && tempFile.exists( ) ) - { - JavaSourceAttacherHandler.attachSource( root, tempFile ); - SourceBindingUtil.saveSourceBindingRecord( sourceFile, sha, null, tempFile ); - - if ( sourceFile.getName( ).startsWith( "jre_" ) ) //$NON-NLS-1$ - { - refreshJRELibrarySources( root ); - } - - if ( sourceFile.getName( ).startsWith( "eclipse_" ) ) //$NON-NLS-1$ - { - List packages = getEclipsePlugins( sourceFile ); - refreshEclipseLibrarySources( root, packages ); - } - - return true; - } - else - { - String suffix = "-" + System.currentTimeMillis( ) + ".jar"; //$NON-NLS-1$ //$NON-NLS-2$ - tempFile = new File( SourceConstants.SourceTempDir, - sourceFile.getName( ) - .replaceAll( "(?i)(\\-)*(\\d)*(\\.)jar", suffix ) //$NON-NLS-1$ - .replaceAll( "(?i)(\\-)*(\\d)*(\\.)zip", suffix ) ); //$NON-NLS-1$ - FileUtil.copyFile( sourceFile.getAbsolutePath( ), tempFile.getAbsolutePath( ) ); - JavaSourceAttacherHandler.attachSource( root, tempFile ); - tempFile.deleteOnExit( ); - SourceBindingUtil.saveSourceBindingRecord( sourceFile, sha, null, tempFile ); - - if ( sourceFile.getName( ).startsWith( "jre_" ) ) //$NON-NLS-1$ - { - refreshJRELibrarySources( root ); - } - - if ( sourceFile.getName( ).startsWith( "eclipse_" ) ) //$NON-NLS-1$ - { - List packages = getEclipsePlugins( sourceFile ); - refreshEclipseLibrarySources( root, packages ); - } - - return true; - } - } - - } - catch ( Exception e ) - { - Logger.debug( e ); - } - return false; - } - - public static List getEclipsePlugins( final File file ) throws IOException - { - final Set plugins = new HashSet( ); - ZipFile zf = new ZipFile( file ); - for ( Enumeration entries = zf.entries( ); entries.hasMoreElements( ); ) - { - String zipEntryName = ( (ZipEntry) entries.nextElement( ) ).getName( ); - if ( zipEntryName.endsWith( ".project" ) ) //$NON-NLS-1$ - { - String[] segements = zipEntryName.replace( "/.project", "" ).split( "/" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - plugins.add( segements[segements.length - 1] ); - } - } - zf.close( ); - return new ArrayList( plugins ); - } - - private static boolean refreshLibrarySources( final IPackageFragmentRoot root, String[] files ) - { - try - { - String sha = HashUtils.sha1Hash( getBinFile( root ) ); - File sourceFile = new File( files[0] ); - if ( !sourceFile.exists( ) ) - return false; - File tempFile = new File( files[1] ); - if ( files[1] != null && tempFile.exists( ) ) - { - JavaSourceAttacherHandler.attachSource( root, tempFile ); - tempFile.deleteOnExit( ); - SourceBindingUtil.saveSourceBindingRecord( sourceFile, sha, null, tempFile ); - return true; - } - else - { - String suffix = "-" + System.currentTimeMillis( ) + ".jar"; //$NON-NLS-1$ //$NON-NLS-2$ - tempFile = new File( SourceConstants.SourceTempDir, - sourceFile.getName( ) - .replaceAll( "(?i)(\\-)*(\\d)*(\\.)jar", suffix ) //$NON-NLS-1$ - .replaceAll( "(?i)(\\-)*(\\d)*(\\.)zip", suffix ) ); //$NON-NLS-1$ - FileUtil.copyFile( sourceFile.getAbsolutePath( ), tempFile.getAbsolutePath( ) ); - JavaSourceAttacherHandler.attachSource( root, tempFile ); - tempFile.deleteOnExit( ); - SourceBindingUtil.saveSourceBindingRecord( sourceFile, sha, null, tempFile ); - return true; - } - } - catch ( Exception e ) - { - Logger.debug( e ); - } - return false; - } - - private static void refreshJRELibrarySources( final IPackageFragmentRoot pkgRoot ) - { - Thread thread = new Thread( ) { - - @Override - public void run( ) - { - try - { - String sha = HashUtils.sha1Hash( getBinFile( pkgRoot ) ); - String[] files = SourceBindingUtil.getSourceFileBySha( sha ); - - IPackageFragmentRoot[] roots = pkgRoot.getJavaProject( ).getAllPackageFragmentRoots( ); - for ( int i = 0; i < roots.length; i++ ) - { - IPackageFragmentRoot element = roots[i]; - if ( element.equals( pkgRoot ) ) - continue; - List paths = Arrays.asList( element.getPath( ).segments( ) ); - if ( paths.contains( "jre" ) ) //$NON-NLS-1$ - { - refreshLibrarySources( element, files ); - } - } ; - } - catch ( JavaModelException e ) - { - e.printStackTrace( ); - } - } - }; - thread.setDaemon( true ); - thread.start( ); - } - - private static void refreshEclipseLibrarySources( final IPackageFragmentRoot pkgRoot, final List plugins ) - { - Thread thread = new Thread( ) { - - @Override - public void run( ) - { - try - { - String sha = HashUtils.sha1Hash( getBinFile( pkgRoot ) ); - String[] files = SourceBindingUtil.getSourceFileBySha( sha ); - - IPackageFragmentRoot[] roots = pkgRoot.getJavaProject( ).getAllPackageFragmentRoots( ); - for ( int i = 0; i < roots.length; i++ ) - { - IPackageFragmentRoot element = roots[i]; - if ( element.equals( pkgRoot ) ) - continue; - String fileName = element.getPath( ).lastSegment( ); - if ( plugins.contains( fileName.split( "_" )[0] ) ) //$NON-NLS-1$ - { - refreshLibrarySources( element, files ); - } - } ; - } - catch ( JavaModelException e ) - { - e.printStackTrace( ); - } - } - }; - thread.start( ); - } - - public static void updateSourceAttachStatus( final IPackageFragmentRoot root ) - { - try - { - final IClasspathEntry entry = JavaModelUtil.getClasspathEntry( root ); - - IPath containerPath = null; - if ( entry.getEntryKind( ) == IClasspathEntry.CPE_CONTAINER ) - { - containerPath = entry.getPath( ); - } - - String[] changedAttributes = { - CPListElement.SOURCEATTACHMENT, "source_encoding" //$NON-NLS-1$ - }; - BuildPathSupport.modifyClasspathEntry( null, - entry, - changedAttributes, - root.getJavaProject( ), - containerPath, - entry.getReferencingEntry( ) != null, - new NullProgressMonitor( ) ); - - if ( root instanceof PackageFragmentRoot ) - { - Object rootInfo = ( (PackageFragmentRoot) root ).getElementInfo( ); - ReflectionUtils.setFieldValue( rootInfo, "sourceMapper", null ); //$NON-NLS-1$ - } - } - catch ( Exception e ) - { - Logger.debug( e ); - } - } - - @SuppressWarnings("rawtypes") - public static boolean isSourceCodeFor( String src, String bin ) - { - boolean result = false; - try - { - List binList = new ArrayList( ); - ZipFile zf = new ZipFile( bin ); - for ( Enumeration entries = zf.entries( ); entries.hasMoreElements( ); ) - { - String zipEntryName = ( (ZipEntry) entries.nextElement( ) ).getName( ); - binList.add( zipEntryName ); - } - zf.close( ); - - zf = new ZipFile( src ); - for ( Enumeration entries = zf.entries( ); entries.hasMoreElements( ); ) - { - String zipEntryName = ( (ZipEntry) entries.nextElement( ) ).getName( ); - String fileBaseName = FilenameUtils.getBaseName( zipEntryName ); - String fileExt = FilenameUtils.getExtension( zipEntryName ); - if ( "java".equals( fileExt ) && fileBaseName != null ) //$NON-NLS-1$ - { - for ( String zipEntryName2 : binList ) - { - String fileBaseName2 = FilenameUtils.getBaseName( zipEntryName2 ); - String fileExt2 = FilenameUtils.getExtension( zipEntryName2 ); - if ( "class".equals( fileExt2 ) && fileBaseName.equals( fileBaseName2 ) ) //$NON-NLS-1$ - { - result = true; - zf.close( ); - return result; - } - } - } - binList.add( zipEntryName ); - } - zf.close( ); - } - catch ( Exception e ) - { - Logger.debug( e ); - } - - return result; - } - - public static boolean isMavenLibrary( IPackageFragmentRoot library ) - { - try - { - IClasspathEntry entry = JavaModelUtil.getClasspathEntry( library ); - return entry.getPath( ).toString( ).indexOf( "MAVEN2_CLASSPATH_CONTAINER" ) != -1; //$NON-NLS-1$ - } - catch ( Exception e ) - { - Logger.debug( e ); - } - return false; - } - - public static boolean enableMavenDownload( ) - { - try - { - Class clazz = Class.forName( "org.eclipse.m2e.jdt.IClasspathManager" ); //$NON-NLS-1$ - Class[] parameterTypes = new Class[]{ - IPackageFragmentRoot.class, boolean.class, boolean.class - }; - if ( clazz.getMethod( "scheduleDownload", parameterTypes ) != null ) //$NON-NLS-1$ - { - return true; - } - } - catch ( ClassNotFoundException ex ) - { - Logger.debug( "Class org.eclipse.m2e.jdt.IClasspathManager not found.", null ); //$NON-NLS-1$ - } - catch ( NoSuchMethodException ex ) - { - Logger.debug( "Method scheduleDownload not found.", null ); //$NON-NLS-1$ - } - catch ( Exception e ) - { - Logger.debug( e ); - } - return false; - } - - public static boolean needDownloadSource( List selection ) - { - IPackageFragmentRoot root = null; - for ( int i = 0; i < selection.size( ); i++ ) - { - IPackageFragmentRoot packRoot = null; - Object obj = selection.get( i ); - if ( obj instanceof IPackageFragment ) - { - IPackageFragment packageFragment = (IPackageFragment) obj; - packRoot = (IPackageFragmentRoot) packageFragment.getParent( ); - } - else if ( obj instanceof IClassFile ) - { - IClassFile classFile = (IClassFile) obj; - packRoot = (IPackageFragmentRoot) classFile.getParent( ).getParent( ); - } - else if ( obj instanceof IPackageFragmentRoot ) - { - packRoot = (IPackageFragmentRoot) obj; - } - else - return false; - if ( root == null ) - { - root = packRoot; - } - else - { - if ( root != packRoot ) - return false; - } - } - try - { - if ( root != null - && root.getSourceAttachmentPath( ) != null - && root.getSourceAttachmentPath( ).toFile( ).exists( ) - && !root.getPath( ).toFile( ).equals( root.getSourceAttachmentPath( ).toFile( ) ) ) - { - return false; - } - } - catch ( JavaModelException e ) - { - Logger.debug( e ); - } - return true; - } -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/utils/SourceBindingUtil.java b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/utils/SourceBindingUtil.java deleted file mode 100644 index 987e47c5..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/utils/SourceBindingUtil.java +++ /dev/null @@ -1,227 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.source.attach.utils; - -import java.io.File; -import java.io.StringWriter; - -import org.sf.feeling.decompiler.util.FileUtil; -import org.sf.feeling.decompiler.util.Logger; - -import com.eclipsesource.json.Json; -import com.eclipsesource.json.JsonArray; -import com.eclipsesource.json.JsonObject; - -public class SourceBindingUtil -{ - - private static final File sourceBindingJsonFile = new File( SourceConstants.SourceAttacherDir, "source.json" ); //$NON-NLS-1$ - - private static synchronized JsonObject loadSourceBindingJson( ) - { - if ( sourceBindingJsonFile.exists( ) ) - { - try - { - return Json.parse( FileUtil.getContent( sourceBindingJsonFile ) ).asObject( ); - } - catch ( Exception e ) - { - Logger.error( "Load source attach binding configuration failed.", e ); //$NON-NLS-1$ - } - } - return null; - } - - private static synchronized void saveSourceBindingJson( JsonObject json ) - { - try - { - StringWriter sw = new StringWriter( ); - json.writeTo( sw ); - String jsonString = sw.toString( ); - FileUtil.writeToFile( sourceBindingJsonFile, jsonString ); - } - catch ( Exception e ) - { - Logger.error( "Save source attach binding configuration failed.", e ); //$NON-NLS-1$ - } - } - - public static synchronized String[] getSourceFileBySha( String sha ) - { - JsonObject config = loadSourceBindingJson( ); - if ( config == null ) - { - return null; - } - - JsonArray records = config.get( "records" ).asArray( ); //$NON-NLS-1$ - for ( int i = 0; i < records.size( ); i++ ) - { - JsonObject item = records.get( i ).asObject( ); - JsonArray shaArray = item.get( "sha" ).asArray( );; //$NON-NLS-1$ - for ( int j = 0; j < shaArray.size( ); j++ ) - { - String shaString = shaArray.get( j ).asString( ); - if ( sha != null && sha.equalsIgnoreCase( shaString ) ) - { - String source = item.getString( "source", null ); //$NON-NLS-1$ - String temp = item.getString( "temp", null ); //$NON-NLS-1$ - return new String[]{ - source, temp - }; - } - } - } - return null; - } - - public static synchronized String[] getSourceFileByDownloadUrl( String downloadUrl ) - { - JsonObject config = loadSourceBindingJson( ); - if ( config == null ) - { - return null; - } - - JsonArray records = config.get( "records" ).asArray( ); //$NON-NLS-1$ - for ( int i = 0; i < records.size( ); i++ ) - { - JsonObject item = records.get( i ).asObject( ); - if ( item.get( "downloadUrl" ).isNull( ) ) //$NON-NLS-1$ - continue; - String downloadUrlValue = item.getString( "downloadUrl", null ); //$NON-NLS-1$ - if ( downloadUrl != null && downloadUrl.equals( downloadUrlValue ) ) - { - String source = item.getString( "source", null ); //$NON-NLS-1$ - String temp = item.getString( "temp", null ); //$NON-NLS-1$ - return new String[]{ - source, temp - }; - } - } - return null; - } - - public static synchronized void saveSourceBindingRecord( File sourceFile, String sha, String downloadUrl, - File tempSourceFile ) - { - if ( sourceFile == null || tempSourceFile == null || !sourceFile.exists( ) || !tempSourceFile.exists( ) ) - return; - - JsonObject config = loadSourceBindingJson( ); - if ( config == null ) - { - config = createSourceBindingConfig( sourceFile, sha, downloadUrl, tempSourceFile ); - saveSourceBindingJson( config ); - return; - } - - JsonArray records = config.get( "records" ).asArray( ); //$NON-NLS-1$ - String sourcePath = sourceFile.getAbsolutePath( ); - - boolean exist = false; - for ( int i = 0; i < records.size( ); i++ ) - { - JsonObject item = records.get( i ).asObject( ); - String source = item.getString( "source", null ); //$NON-NLS-1$ - if ( sourcePath.equals( source ) ) - { - modifySourceBindingRecord( item, sha, downloadUrl, tempSourceFile ); - exist = true; - } - } - - if ( !exist ) - { - JsonObject record = createSourceBindingRecord( sourceFile, sha, downloadUrl, tempSourceFile ); - records.add( record ); - } - - saveSourceBindingJson( config ); - } - - private static synchronized void modifySourceBindingRecord( JsonObject item, String sha, String downloadUrl, - File tempSourceFile ) - { - JsonArray shaArray = item.get( "sha" ).asArray( ); //$NON-NLS-1$ - boolean exist = false; - for ( int i = 0; i < shaArray.size( ); i++ ) - { - String shaString = shaArray.get( i ).asString( ); - if ( sha.equalsIgnoreCase( shaString ) ) - { - exist = true; - break; - } - } - if ( !exist ) - { - shaArray.add( sha ); - } - if ( downloadUrl != null ) - { - item.set( "downloadUrl", downloadUrl ); //$NON-NLS-1$ - } - if ( tempSourceFile != null && tempSourceFile.exists( ) ) - { - item.set( "temp", tempSourceFile.getAbsolutePath( ) ); //$NON-NLS-1$ - } - } - - private static synchronized JsonObject createSourceBindingConfig( File sourceFile, String sha, String downloadUrl, - File tempSourceFile ) - { - JsonObject config = new JsonObject( ); - config.set( "version", "1.0" ); //$NON-NLS-1$ //$NON-NLS-2$ - JsonArray records = new JsonArray( ); - config.set( "records", records ); //$NON-NLS-1$ - JsonObject record = createSourceBindingRecord( sourceFile, sha, downloadUrl, tempSourceFile ); - records.add( record ); - return config; - } - - private static synchronized JsonObject createSourceBindingRecord( File sourceFile, String sha, String downloadUrl, - File tempSourceFile ) - { - JsonObject record = new JsonObject( ); - record.set( "source", sourceFile.getAbsolutePath( ) ); //$NON-NLS-1$ - record.set( "downloadUrl", downloadUrl ); //$NON-NLS-1$ - JsonArray shaArray = new JsonArray( ); - shaArray.add( sha ); - record.set( "sha", shaArray ); //$NON-NLS-1$ - record.set( "temp", tempSourceFile.getAbsolutePath( ) ); //$NON-NLS-1$ - return record; - } - - public static void checkSourceBindingConfig( ) - { - JsonObject config = loadSourceBindingJson( ); - if ( config == null ) - { - return; - } - - JsonArray records = config.get( "records" ).asArray( ); //$NON-NLS-1$ - for ( int i = records.size( ) - 1; i >= 0; i-- ) - { - JsonObject item = records.get( i ).asObject( ); - String source = item.getString( "source", null ); //$NON-NLS-1$ - if ( source == null || !new File( source ).exists( ) ) - { - records.remove( i ); - } - } - saveSourceBindingJson( config ); - } -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/utils/SourceConstants.java b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/utils/SourceConstants.java deleted file mode 100644 index 5144ac13..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/utils/SourceConstants.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.source.attach.utils; - -import java.io.File; - -import org.sf.feeling.decompiler.JavaDecompilerPlugin; - -public class SourceConstants -{ - - public static final File SourceAttacherDir = new File( String.valueOf( - System.getProperty( "user.home" ) ) + File.separatorChar + ".decompiler" + File.separatorChar + "source" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - - public static final File SourceTempDir = new File( - JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ).getString( JavaDecompilerPlugin.TEMP_DIR ) - + File.separatorChar - + "source" ); //$NON-NLS-1$ - - public static final String SourceAttachPath = SourceAttacherDir.getAbsolutePath( ); - public static final String SourceTempPath = SourceTempDir.getAbsolutePath( ); - public static final String TEMP_SOURCE_PREFIX = "source"; //$NON-NLS-1$ - -} diff --git a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/utils/UrlDownloader.java b/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/utils/UrlDownloader.java deleted file mode 100644 index cb85c8f9..00000000 --- a/org.sf.feeling.decompiler.source.attach/src/org/sf/feeling/decompiler/source/attach/utils/UrlDownloader.java +++ /dev/null @@ -1,326 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.source.attach.utils; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.net.URL; -import java.net.URLConnection; - -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang.StringUtils; -import org.apache.maven.scm.ScmBranch; -import org.apache.maven.scm.ScmFileSet; -import org.apache.maven.scm.ScmRevision; -import org.apache.maven.scm.ScmTag; -import org.apache.maven.scm.ScmVersion; -import org.apache.maven.scm.manager.BasicScmManager; -import org.apache.maven.scm.manager.ScmManager; -import org.apache.maven.scm.provider.accurev.AccuRevScmProvider; -import org.apache.maven.scm.provider.bazaar.BazaarScmProvider; -import org.apache.maven.scm.provider.clearcase.ClearCaseScmProvider; -import org.apache.maven.scm.provider.cvslib.cvsexe.CvsExeScmProvider; -import org.apache.maven.scm.provider.cvslib.cvsjava.CvsJavaScmProvider; -import org.apache.maven.scm.provider.git.jgit.JGitScmProvider; -import org.apache.maven.scm.provider.hg.HgScmProvider; -import org.apache.maven.scm.provider.jazz.JazzScmProvider; -import org.apache.maven.scm.provider.local.LocalScmProvider; -import org.apache.maven.scm.provider.perforce.PerforceScmProvider; -import org.apache.maven.scm.provider.starteam.StarteamScmProvider; -import org.apache.maven.scm.provider.svn.svnexe.SvnExeScmProvider; -import org.apache.maven.scm.provider.synergy.SynergyScmProvider; -import org.apache.maven.scm.provider.vss.VssScmProvider; -import org.apache.maven.scm.repository.ScmRepository; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.Target; -import org.apache.tools.ant.taskdefs.Delete; -import org.apache.tools.ant.taskdefs.Zip; -import org.sf.feeling.decompiler.util.HashUtils; -import org.sf.feeling.decompiler.util.Logger; - -public class UrlDownloader -{ - - public String download( final String url ) throws Exception - { - String result; - if ( StringUtils.startsWith( url, "scm:" ) ) //$NON-NLS-1$ - { - result = this.downloadFromScm( url ); - } - else if ( new File( url ).exists( ) ) - { - result = url; - } - else - { - result = this.downloadFromUrl( url ); - } - return result; - } - - private String downloadFromScm( String url ) throws Exception - { - if ( url.indexOf( "cvs:pserver:" ) != -1 && url.indexOf( "@" ) == -1 ) //$NON-NLS-1$ //$NON-NLS-2$ - { - url = url.replace( "cvs:pserver:", "cvs:pserver:anonymous:@" ); //$NON-NLS-1$ //$NON-NLS-2$ - } - final File tmpDir = new File( System.getProperty( "java.io.tmpdir" ) ); //$NON-NLS-1$ - final File checkoutDirectory = new File( tmpDir, - SourceConstants.TEMP_SOURCE_PREFIX + "_" + HashUtils.md5Hash( url ) ); //$NON-NLS-1$ - final File file = new File( tmpDir, - SourceConstants.TEMP_SOURCE_PREFIX + "_" + HashUtils.md5Hash( url ) + ".zip" ); //$NON-NLS-1$ //$NON-NLS-2$ - if ( !file.exists( ) ) - { - if ( !checkoutDirectory.exists( ) - || checkoutDirectory.list( ).length == 0 - || ( checkoutDirectory.list( ).length == 1 && checkoutDirectory.list( )[0].startsWith( "." ) ) ) //$NON-NLS-1$ - { - final ScmManager scmManager = new BasicScmManager( ); - scmManager.setScmProvider( "accurev", new AccuRevScmProvider( ) ); //$NON-NLS-1$ - scmManager.setScmProvider( "bazaar", new BazaarScmProvider( ) ); //$NON-NLS-1$ - scmManager.setScmProvider( "clearcase", new ClearCaseScmProvider( ) ); //$NON-NLS-1$ - scmManager.setScmProvider( "hg", new HgScmProvider( ) ); //$NON-NLS-1$ - scmManager.setScmProvider( "local", new LocalScmProvider( ) ); //$NON-NLS-1$ - scmManager.setScmProvider( "perforce", new PerforceScmProvider( ) ); //$NON-NLS-1$ - scmManager.setScmProvider( "cvs_native", new CvsExeScmProvider( ) ); //$NON-NLS-1$ - scmManager.setScmProvider( "cvs", new CvsJavaScmProvider( ) ); //$NON-NLS-1$ - scmManager.setScmProvider( "git", new JGitScmProvider( ) ); //$NON-NLS-1$ - scmManager.setScmProvider( "svn", new SvnExeScmProvider( ) ); //$NON-NLS-1$ - scmManager.setScmProvider( "starteam", new StarteamScmProvider( ) ); //$NON-NLS-1$ - scmManager.setScmProvider( "synergy", new SynergyScmProvider( ) ); //$NON-NLS-1$ - scmManager.setScmProvider( "vss", new VssScmProvider( ) ); //$NON-NLS-1$ - scmManager.setScmProvider( "jazz", new JazzScmProvider( ) ); //$NON-NLS-1$ - String scmUrl; - ScmVersion scmVersion; - if ( url.indexOf( '#' ) != -1 ) - { - scmUrl = StringUtils.trimToEmpty( url.substring( 0, url.indexOf( '#' ) ) ); - final String fragment = StringUtils.trimToEmpty( url.substring( url.indexOf( '#' ) + 1 ) ); - if ( fragment.indexOf( '=' ) != -1 ) - { - final String[] versionTypeAndVersion = StringUtils.split( fragment, '=' ); - final String version = StringUtils.trim( versionTypeAndVersion[1] ); - final String type = StringUtils.trim( versionTypeAndVersion[0] ); - if ( "tag".equals( type ) ) //$NON-NLS-1$ - { - scmVersion = new ScmTag( version ); - } - else if ( "branch".equals( type ) ) //$NON-NLS-1$ - { - scmVersion = new ScmBranch( version ); - } - else if ( "revision".equals( type ) ) //$NON-NLS-1$ - { - scmVersion = new ScmRevision( version ); - } - else - { - if ( !"commitId".equals( type ) ) //$NON-NLS-1$ - { - throw new IllegalArgumentException( "'" + type + "' version type isn't known." ); //$NON-NLS-1$ //$NON-NLS-2$ - } - scmVersion = new ScmRevision( version ); - } - } - else - { - scmVersion = new ScmTag( fragment ); - } - } - else if ( url.indexOf( ';' ) != -1 ) - { - scmUrl = StringUtils.trimToEmpty( url.substring( 0, url.indexOf( ';' ) ) ); - final String fragment = StringUtils.trimToEmpty( url.substring( url.indexOf( ';' ) + 1 ) ); - scmVersion = null; - if ( fragment.indexOf( '=' ) != -1 ) - { - final String[] properties = StringUtils.split( fragment, ';' ); - String[] array; - for ( int length = ( array = properties ).length, i = 0; i < length; ++i ) - { - final String property = array[i]; - final String[] versionTypeAndVersion2 = StringUtils.split( property, '=' ); - final String version2 = StringUtils.strip( versionTypeAndVersion2[1], " \"" ); //$NON-NLS-1$ - final String type2 = StringUtils.trim( versionTypeAndVersion2[0] ); - if ( "tag".equals( type2 ) ) //$NON-NLS-1$ - { - scmVersion = new ScmTag( version2 ); - break; - } - if ( "branch".equals( type2 ) ) //$NON-NLS-1$ - { - scmVersion = new ScmBranch( version2 ); - break; - } - if ( "revision".equals( type2 ) ) //$NON-NLS-1$ - { - scmVersion = new ScmRevision( version2 ); - break; - } - if ( "commitId".equals( type2 ) ) //$NON-NLS-1$ - { - scmVersion = new ScmRevision( version2 ); - break; - } - } - } - else - { - scmVersion = new ScmTag( fragment ); - } - } - else - { - scmUrl = url; - scmVersion = null; - } - if ( !checkoutDirectory.exists( ) ) - { - checkoutDirectory.mkdir( ); - } - final ScmRepository repository = scmManager.makeScmRepository( scmUrl ); - - try - { - scmManager.checkOut( repository, new ScmFileSet( checkoutDirectory ), scmVersion ); - } - catch ( Exception e ) - { - Logger.debug( e ); - if ( checkoutDirectory.exists( ) ) - { - FileUtils.deleteDirectory( checkoutDirectory ); - } - } - } - if ( checkoutDirectory.exists( ) && checkoutDirectory.list( ).length > 0 ) - { - this.zipFolder( checkoutDirectory, file ); - FileUtils.deleteDirectory( checkoutDirectory ); - } - } - String result = null; - if ( file.exists( ) ) - { - result = file.getAbsolutePath( ); - } - return result; - } - - public void zipFolder( final File srcFolder, final File destZipFile ) - { - final Zip zipper = new Zip( ); - zipper.setLevel( 1 ); - zipper.setDestFile( destZipFile ); - zipper.setBasedir( srcFolder ); - zipper.setIncludes( "**/*.java" ); //$NON-NLS-1$ - zipper.setTaskName( "zip" ); //$NON-NLS-1$ - zipper.setTaskType( "zip" ); //$NON-NLS-1$ - zipper.setProject( new Project( ) ); - zipper.setOwningTarget( new Target( ) ); - zipper.execute( ); - } - - public void delete( final File folder ) - { - final Delete delete = new Delete( ); - delete.setDir( folder ); - delete.setTaskName( "delete" ); //$NON-NLS-1$ - delete.setTaskType( "delete" ); //$NON-NLS-1$ - delete.setProject( new Project( ) ); - delete.setOwningTarget( new Target( ) ); - delete.execute( ); - } - - private String downloadFromUrl( final String url ) throws IOException - { - final File file = File.createTempFile( SourceConstants.TEMP_SOURCE_PREFIX, ".tmp" ); //$NON-NLS-1$ - InputStream is = null; - OutputStream os = null; - try - { - final URLConnection conn = new URL( url ).openConnection( ); - conn.setConnectTimeout( 5000 ); - conn.setReadTimeout( 5000 ); - is = this.openConnectionCheckRedirects( conn ); - os = FileUtils.openOutputStream( file ); - IOUtils.copy( is, os ); - } - catch ( Exception ex ) - { - IOUtils.closeQuietly( os ); - file.delete( ); - return file.getAbsolutePath( ); - } - finally - { - IOUtils.closeQuietly( os ); - IOUtils.closeQuietly( is ); - } - IOUtils.closeQuietly( os ); - IOUtils.closeQuietly( is ); - final String result = file.getAbsolutePath( ); - return result; - } - - private InputStream openConnectionCheckRedirects( URLConnection c ) throws IOException - { - int redirects = 0; - InputStream in = null; - boolean redir; - do - { - if ( c instanceof HttpURLConnection ) - { - ( (HttpURLConnection) c ).setInstanceFollowRedirects( false ); - c.setRequestProperty( "User-Agent", //$NON-NLS-1$ - "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7" ); //$NON-NLS-1$ - } - in = c.getInputStream( ); - redir = false; - if ( c instanceof HttpURLConnection ) - { - final HttpURLConnection http = (HttpURLConnection) c; - final int stat = http.getResponseCode( ); - if ( stat < 300 || stat > 307 || stat == 306 || stat == 304 ) - { - continue; - } - final URL base = http.getURL( ); - final String loc = http.getHeaderField( "Location" ); //$NON-NLS-1$ - URL target = null; - if ( loc != null ) - { - target = new URL( base, loc ); - } - http.disconnect( ); - if ( target == null - || ( !target.getProtocol( ).equals( "http" ) && !target.getProtocol( ).equals( "https" ) ) //$NON-NLS-1$ //$NON-NLS-2$ - || redirects >= 5 ) - { - throw new SecurityException( "illegal URL redirect" ); //$NON-NLS-1$ - } - redir = true; - c = target.openConnection( ); - c.setConnectTimeout( 5000 ); - c.setReadTimeout( 5000 ); - ++redirects; - } - } while ( redir ); - return in; - } -} \ No newline at end of file diff --git a/org.sf.feeling.decompiler.source.feature/build.properties b/org.sf.feeling.decompiler.source.feature/build.properties deleted file mode 100644 index cf9614dd..00000000 --- a/org.sf.feeling.decompiler.source.feature/build.properties +++ /dev/null @@ -1,12 +0,0 @@ -bin.includes = feature.xml,\ - eclipse_update_120.jpg,\ - epl-v10.html,\ - feature.properties,\ - license.html -individualSourceBundles=true -generate.plugin@org.sf.feeling.decompiler.source = org.sf.feeling.decompiler -generate.plugin@org.sf.feeling.decompiler.jd.source = org.sf.feeling.decompiler.jd -generate.plugin@org.sf.feeling.decompiler.jad.source = org.sf.feeling.decompiler.jad -generate.plugin@org.sf.feeling.decompiler.cfr.source = org.sf.feeling.decompiler.cfr -generate.plugin@org.sf.feeling.decompiler.procyon.source = org.sf.feeling.decompiler.procyon -qualifier = 20170815 \ No newline at end of file diff --git a/org.sf.feeling.decompiler.source.feature/feature.properties b/org.sf.feeling.decompiler.source.feature/feature.properties deleted file mode 100644 index 36168e99..00000000 --- a/org.sf.feeling.decompiler.source.feature/feature.properties +++ /dev/null @@ -1,135 +0,0 @@ -############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation -############################################################################### - -# feature.properties -# contains externalized strings for feature.xml -# "%foo" in feature.xml corresponds to the key "foo" in this file -# java.io.Properties file (ISO 8859-1 with "\" escapes) -# This file should be translated. - -# "featureName" property - name of the feature -featureName=Eclipse Class Decompiler Source (Optional) - -# "providerName" property - name of the company that provides the feature -providerName=Chen Chao - -# "updateSiteName" property - label for the update site -updateSiteName=Eclipse Class Decompiler Updates - -# "description" property - description of the feature -description=Eclipse Class Decompiler integrates JD, Jad, FernFlower, CFR, Procyon with Eclipse seamlessly. \ -It allows Java developers to debug class files without source code directly. - -copyrightURL=http://www.cpupk.com/decompiler/update - -copyright=(c) Copyright 2017 Chen Chao(cnfree2000@hotmail.com). All rights reserved.\n - -# "licenseURL" property - URL of the "Feature License" -# do not translate value - just change to point to a locale-specific HTML page -licenseURL=license.html - -# "aboutURL" property - URL of the "About and Change log" -# do not translate value - just change to point to a locale-specific HTML page -aboutURL=about.html - -# "license" property - text of the "Feature Update License" -# should be plain text version of license agreement pointed to be "licenseURL" -license=\ -ECLIPSE FOUNDATION SOFTWARE USER AGREEMENT\n\ -January 28, 2004\n\ -\n\ -Usage Of Content\n\ -\n\ -THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\ -OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\ -USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\ -AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\ -NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU\n\ -AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\ -AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\ -OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\ -TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\ -OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\ -BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\ -\n\ -Applicable Licenses\n\ -\n\ -Unless otherwise indicated, all Content made available by the Eclipse Foundation\n\ -is provided to you under the terms and conditions of the Eclipse Public\n\ -License Version 1.0 ("EPL"). A copy of the EPL is provided with this\n\ -Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\ -For purposes of the EPL, "Program" will mean the Content.\n\ -\n\ -Content includes, but is not limited to, source code, object code,\n\ -documentation and other files maintained in the Eclipse.org CVS\n\ -repository ("Repository") in CVS modules ("Modules") and made available\n\ -as downloadable archives ("Downloads").\n\ -\n\ -Content may be apportioned into plug-ins ("Plug-ins"), plug-in fragments\n\ -("Fragments"), and features ("Features"). A Feature is a bundle of one or\n\ -more Plug-ins and/or Fragments and associated material. Files named\n\ -"feature.xml" may contain a list of the names and version numbers of the\n\ -Plug-ins and/or Fragments associated with a Feature. Plug-ins and Fragments\n\ -are located in directories named "plugins" and Features are located in\n\ -directories named "features".\n\ -\n\ -Features may also include other Features ("Included Features"). Files named\n\ -"feature.xml" may contain a list of the names and version numbers of\n\ -Included Features.\n\ -\n\ -The terms and conditions governing Plug-ins and Fragments should be\n\ -contained in files named "about.html" ("Abouts"). The terms and\n\ -conditions governing Features and Included Features should be contained\n\ -in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\ -Licenses may be located in any directory of a Download or Module\n\ -including, but not limited to the following locations:\n\ -\n\ - - The top-level (root) directory\n\ - - Plug-in and Fragment directories\n\ - - Subdirectories of the directory named "src" of certain Plug-ins\n\ - - Feature directories\n\ -\n\ -Note: if a Feature made available by the Eclipse Foundation is installed using the\n\ -Eclipse Update Manager, you must agree to a license ("Feature Update\n\ -License") during the installation process. If the Feature contains\n\ -Included Features, the Feature Update License should either provide you\n\ -with the terms and conditions governing the Included Features or inform\n\ -you where you can locate them. Feature Update Licenses may be found in\n\ -the "license" property of files named "feature.properties". Such Abouts,\n\ -Feature Licenses and Feature Update Licenses contain the terms and\n\ -conditions (or references to such terms and conditions) that govern your\n\ -use of the associated Content in that directory.\n\ -\n\ -THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER\n\ -TO THE CPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\ -SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\ -\n\ - - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\ - - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\ - - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\ - - IBM Public License 1.0 (available at http://oss.software.ibm.com/developerworks/opensource/license10.html)\n\ - - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\ - - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\ -\n\ -IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\ -TO USE OF THE CONTENT. If no About, Feature License or Feature Update License\n\ -is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\ -govern that particular Content.\n\ -\n\ -Cryptography\n\ -\n\ -Content may contain encryption software. The country in which you are\n\ -currently may have restrictions on the import, possession, and use,\n\ -and/or re-export to another country, of encryption software. BEFORE\n\ -using any encryption software, please check the country's laws,\n\ -regulations and policies concerning the import, possession, or use,\n\ -and re-export of encryption software, to see if this is permitted.\n -########### end of license property ########################################## \ No newline at end of file diff --git a/org.sf.feeling.decompiler.source.feature/feature.xml b/org.sf.feeling.decompiler.source.feature/feature.xml deleted file mode 100644 index 393434a0..00000000 --- a/org.sf.feeling.decompiler.source.feature/feature.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - - - %description - - - - %copyright - - - - %license - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.sf.feeling.decompiler.source.feature/license.html b/org.sf.feeling.decompiler.source.feature/license.html deleted file mode 100644 index e2323dfc..00000000 --- a/org.sf.feeling.decompiler.source.feature/license.html +++ /dev/null @@ -1,73 +0,0 @@ - - - - -Eclipse.org Software User Agreement - - - -

      Eclipse Foundation Software User Agreement

      -

      January 28, 2005

      - -

      Usage Of Content

      - -

      THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS - (COLLECTIVELY "CONTENT"). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND - CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE - OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR - NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND - CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.

      - -

      Applicable Licenses

      - -

      Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0 - ("EPL"). A copy of the EPL is provided with this Content and is also available at http://www.eclipse.org/legal/epl-v10.html. - For purposes of the EPL, "Program" will mean the Content.

      - -

      Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse.org CVS repository ("Repository") in CVS - modules ("Modules") and made available as downloadable archives ("Downloads").

      - -

      Content may be apportioned into plug-ins ("Plug-ins"), plug-in fragments ("Fragments"), and features ("Features"). A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material. Files named "feature.xml" may contain a list of the names and version numbers of the Plug-ins and/or Fragments associated with a Feature. Plug-ins and Fragments are located in directories - named "plugins" and Features are located in directories named "features".

      - -

      Features may also include other Features ("Included Features"). Files named "feature.xml" may contain a list of the names and version numbers of Included Features.

      - -

      The terms and conditions governing Plug-ins and Fragments should be contained in files named "about.html" ("Abouts"). The terms and conditions governing Features and -Included Features should be contained in files named "license.html" ("Feature Licenses"). Abouts and Feature Licenses may be located in any directory of a Download or Module -including, but not limited to the following locations:

      - -
        -
      • The top-level (root) directory
      • -
      • Plug-in and Fragment directories
      • -
      • Subdirectories of the directory named "src" of certain Plug-ins
      • -
      • Feature directories
      • -
      - -

      Note: if a Feature made available by the Eclipse Foundation is installed using the Eclipse Update Manager, you must agree to a license ("Feature Update License") during the -installation process. If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or -inform you where you can locate them. Feature Update Licenses may be found in the "license" property of files named "feature.properties". -Such Abouts, Feature Licenses and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in -that directory.

      - -

      THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE -OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):

      - - - -

      IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License or Feature Update License is provided, please -contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.

      - -

      Cryptography

      - -

      Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to - another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import, - possession, or use, and re-export of encryption software, to see if this is permitted.

      - - diff --git a/org.sf.feeling.decompiler.update/.gitignore b/org.sf.feeling.decompiler.update/.gitignore deleted file mode 100644 index ae3c1726..00000000 --- a/org.sf.feeling.decompiler.update/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin/ diff --git a/org.sf.feeling.decompiler.update/.settings/org.eclipse.core.resources.prefs b/org.sf.feeling.decompiler.update/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 7bd55519..00000000 --- a/org.sf.feeling.decompiler.update/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,4 +0,0 @@ -eclipse.preferences.version=1 -encoding//src/org/sf/feeling/decompiler/update/i18n/messages_zh_CN.properties=UTF-8 -encoding//src/org/sf/feeling/decompiler/update/i18n/messages_zh_HK.properties=UTF-8 -encoding//src/org/sf/feeling/decompiler/update/i18n/messages_zh_TW.properties=UTF-8 diff --git a/org.sf.feeling.decompiler.update/.settings/org.eclipse.jdt.core.prefs b/org.sf.feeling.decompiler.update/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 7412c1fa..00000000 --- a/org.sf.feeling.decompiler.update/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,12 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.methodParameters=generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/org.sf.feeling.decompiler.update/META-INF/MANIFEST.MF b/org.sf.feeling.decompiler.update/META-INF/MANIFEST.MF deleted file mode 100644 index abb96ffb..00000000 --- a/org.sf.feeling.decompiler.update/META-INF/MANIFEST.MF +++ /dev/null @@ -1,32 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Eclipse Class Decompiler Update -Bundle-SymbolicName: org.sf.feeling.decompiler.update;singleton:=true -Bundle-Version: 2.10.0.qualifier -Bundle-Activator: org.sf.feeling.decompiler.update.DecompilerUpdatePlugin -Require-Bundle: org.eclipse.ui, - org.eclipse.core.runtime, - org.eclipse.core.expressions, - org.sf.feeling.decompiler, - org.eclipse.equinox.p2.operations;resolution:=optional, - org.eclipse.equinox.p2.core;resolution:=optional, - org.eclipse.equinox.p2.metadata;resolution:=optional, - org.eclipse.equinox.p2.repository;resolution:=optional, - org.eclipse.equinox.p2.ui.discovery;resolution:=optional, - org.eclipse.equinox.p2.discovery;resolution:=optional, - org.eclipse.equinox.p2.ui;resolution:=optional, - org.eclipse.e4.ui.workbench;resolution:=optional, - org.eclipse.e4.ui.model.workbench;resolution:=optional, - org.eclipse.e4.core.contexts;resolution:=optional, - org.eclipse.jdt.ui -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Bundle-ActivationPolicy: lazy -Bundle-Vendor: Chen Chao -Eclipse-ExtensibleAPI: true -Export-Package: org.sf.feeling.decompiler.update, - org.sf.feeling.decompiler.update.util, - org.sf.feeling.decompiler.update.widget -Bundle-ClassPath: ., - lib/org.eclipse.ui.workbench_3.7.1.v20120104-1859.jar -Import-Package: javax.annotation;version="1.0.0";resolution:=optional, - javax.inject;version="1.0.0";resolution:=optional diff --git a/org.sf.feeling.decompiler.update/build.properties b/org.sf.feeling.decompiler.update/build.properties deleted file mode 100644 index 9dbd3ee2..00000000 --- a/org.sf.feeling.decompiler.update/build.properties +++ /dev/null @@ -1,6 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - plugin.xml -qualifier = 20170815 diff --git a/org.sf.feeling.decompiler.update/lib/org.eclipse.ui.workbench_3.7.1.v20120104-1859.jar b/org.sf.feeling.decompiler.update/lib/org.eclipse.ui.workbench_3.7.1.v20120104-1859.jar deleted file mode 100644 index 39f4261c..00000000 Binary files a/org.sf.feeling.decompiler.update/lib/org.eclipse.ui.workbench_3.7.1.v20120104-1859.jar and /dev/null differ diff --git a/org.sf.feeling.decompiler.update/plugin.xml b/org.sf.feeling.decompiler.update/plugin.xml deleted file mode 100644 index 3f2cf859..00000000 --- a/org.sf.feeling.decompiler.update/plugin.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - diff --git a/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/BackgroundHandler.java b/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/BackgroundHandler.java deleted file mode 100644 index e22d2d4b..00000000 --- a/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/BackgroundHandler.java +++ /dev/null @@ -1,258 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.update; - -import java.io.IOException; -import java.io.InputStream; -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.concurrent.TimeUnit; - -import org.eclipse.core.runtime.IBundleGroup; -import org.eclipse.core.runtime.IBundleGroupProvider; -import org.eclipse.core.runtime.Platform; -import org.eclipse.equinox.internal.p2.metadata.OSGiVersion; -import org.eclipse.equinox.p2.metadata.Version; -import org.eclipse.ui.PlatformUI; -import org.sf.feeling.decompiler.JavaDecompilerPlugin; -import org.sf.feeling.decompiler.extension.IDecompilerExtensionHandler; -import org.sf.feeling.decompiler.update.util.ExecutorUtil; -import org.sf.feeling.decompiler.update.util.TrayLinkUtil; -import org.sf.feeling.decompiler.util.IOUtils; -import org.sf.feeling.decompiler.util.Logger; -import org.sf.feeling.decompiler.util.MarkUtil; -import org.sf.feeling.decompiler.util.UserUtil; - -import com.eclipsesource.json.Json; -import com.eclipsesource.json.JsonArray; -import com.eclipsesource.json.JsonObject; -import com.eclipsesource.json.JsonValue; - -@SuppressWarnings("restriction") -public class BackgroundHandler implements IDecompilerExtensionHandler -{ - - @Override - public void execute( ) - { - if ( PlatformUI.getWorkbench( ) == null || PlatformUI.getWorkbench( ).getActiveWorkbenchWindow( ) == null ) - return; - - TrayLinkUtil.displayTrayLink( PlatformUI.getWorkbench( ).getActiveWorkbenchWindow( ) ); - - Runnable scheduledTask = new Runnable( ) { - - @Override - public void run( ) - { - JsonObject userIpInfo = UserUtil.collectUserIp( ); - UserUtil.setUserIpInfo( userIpInfo ); - analyzeUserInfo( ); - } - }; - - ExecutorUtil.submitScheduledTask( scheduledTask, 0, 720, TimeUnit.MINUTES ); - } - - private String getDecompilerVersion( ) - { - OSGiVersion decompilerVersion = (OSGiVersion) getFeatureVersion( "org.sf.feeling.decompiler" ); //$NON-NLS-1$ - return decompilerVersion == null ? null : decompilerVersion.toString( ); - } - - private Version getFeatureVersion( String featureId ) - { - for ( IBundleGroupProvider provider : Platform.getBundleGroupProviders( ) ) - { - for ( IBundleGroup feature : provider.getBundleGroups( ) ) - { - if ( feature.getIdentifier( ).equals( featureId ) ) - return Version.create( feature.getVersion( ) ); - } - } - return null; - } - - private boolean analyzeUserInfo( ) - { - boolean result = false; - int decompileCount = JavaDecompilerPlugin.getDefault( ).getDecompileCount( ).get( ); - int adClickCount = JavaDecompilerPlugin.getDefault( ).getAdClickCount( ).get( ); - if ( decompileCount > 1024 * 365 || decompileCount < 0 ) - { - decompileCount = 0; - } - if ( adClickCount > 1024 * 365 || adClickCount < 0 ) - { - adClickCount = 0; - } - try - { - JsonObject userData = new JsonObject( ); - String[] userIds = UserUtil.getUserIds( ); - if ( userIds != null && userIds.length == 2 ) - { - userData.add( "user_hash", userIds[0] );//$NON-NLS-1$ - userData.add( "user_uuid", userIds[1] );//$NON-NLS-1$ - } - userData.add( "cip", UserUtil.getUserIp( ) ); //$NON-NLS-1$ - userData.add( "country", UserUtil.getUserCountry( ) ); //$NON-NLS-1$ - userData.add( "country_code", UserUtil.getUserCountryCode( ) ); //$NON-NLS-1$ - userData.add( "province", UserUtil.getUserProvince( ) ); //$NON-NLS-1$ - userData.add( "city", UserUtil.getUserCity( ) ); //$NON-NLS-1$ - - userData.add( "user_country", System.getProperty( "user.country" ) ); //$NON-NLS-1$ //$NON-NLS-2$ - userData.add( "os_name", System.getProperty( "os.name" ) ); //$NON-NLS-1$ //$NON-NLS-2$ - userData.add( "os_arch", System.getProperty( "os.arch" ) ); //$NON-NLS-1$ //$NON-NLS-2$ - userData.add( "os_version", System.getProperty( "os.version" ) ); //$NON-NLS-1$ //$NON-NLS-2$ - userData.add( "java_version", System.getProperty( "java.version" ) ); //$NON-NLS-1$ //$NON-NLS-2$ - userData.add( "eclipse_product", System.getProperty( "eclipse.product" ) ); //$NON-NLS-1$ //$NON-NLS-2$ - userData.add( "eclipse_version", System.getProperty( "eclipse.buildId" ) ); //$NON-NLS-1$ //$NON-NLS-2$ - userData.add( "decompiler_version", getDecompilerVersion( ) ); //$NON-NLS-1$ - userData.add( "decompile_count", decompileCount );//$NON-NLS-1$ - userData.add( "total_decompile_count", UserUtil.getUserCount( ) + decompileCount );//$NON-NLS-1$ - userData.add( "adclick_count", adClickCount );//$NON-NLS-1$ - userData.add( "total_adclick_count", UserUtil.getAdClickCount( ) + adClickCount );//$NON-NLS-1$ - - URL location = new URL( "http://decompiler.cpupk.com/statistics.php" ); //$NON-NLS-1$ - HttpURLConnection con = (HttpURLConnection) location.openConnection( ); - con.setRequestMethod( "POST" ); //$NON-NLS-1$ - con.setRequestProperty( "User-Agent", "Mozilla/5.0" ); //$NON-NLS-1$ //$NON-NLS-2$ - con.setDoOutput( true ); - con.setConnectTimeout( 30000 ); - - StringBuffer params = new StringBuffer( ); - params.append( "data" ).append( "=" ).append( userData.toString( ) ); //$NON-NLS-1$ //$NON-NLS-2$ - byte[] bypes = params.toString( ).getBytes( "UTF-8" ); //$NON-NLS-1$ - con.getOutputStream( ).write( bypes ); - - int responseCode = con.getResponseCode( ); - if ( responseCode == HttpURLConnection.HTTP_OK ) - { - try - { - InputStream inStream = con.getInputStream( ); - byte[] resultValue = IOUtils.readInputStream( inStream ); - JsonObject returnValue = Json.parse( new String( resultValue, "UTF-8" ) ).asObject( ); //$NON-NLS-1$ - if ( returnValue.getBoolean( "status", false ) ) //$NON-NLS-1$ - { - UserUtil.updateCount( ); - try - { - JsonValue data = returnValue.get( "data" ); //$NON-NLS-1$ - if ( data != null && data.isObject( ) ) - { - JsonObject dataObject = data.asObject( ); - checkAdConfig( dataObject ); - checkTrayLink( dataObject ); - checkDecompilerMark( dataObject ); - } - } - catch ( Exception e ) - { - Logger.debug( e ); - } - JavaDecompilerPlugin.getDefault( ).resetCount( ); - } - } - catch ( Exception e ) - { - Logger.debug( e ); - } - con.disconnect( ); - } - else - { - con.disconnect( ); - } - } - catch ( IOException e ) - { - Logger.debug( e ); - } - return result; - } - - private void checkAdConfig( JsonObject dataObject ) - { - JsonValue configValue = dataObject.get( "adConfig" ); //$NON-NLS-1$ - if ( configValue == null || configValue.isNull( ) ) - return; - - JsonObject config = configValue.asObject( ); - - JsonValue conditionValue = config.get( "adCondition" ); //$NON-NLS-1$ - if ( conditionValue != null && conditionValue.isNumber( ) ) - { - JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ).setValue( "adCondition", //$NON-NLS-1$ - conditionValue.asInt( ) ); - } - - JsonValue stylesValue = config.get( "adStyles" ); //$NON-NLS-1$ - if ( stylesValue == null || stylesValue.isNull( ) || !stylesValue.isObject( ) ) - { - return; - } - - JsonValue brightValue = stylesValue.asObject( ).get( "bright" ); //$NON-NLS-1$ - if ( brightValue != null && !brightValue.isNull( ) && brightValue.isObject( ) ) - { - JsonObject bright = brightValue.asObject( ); - JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ).setValue( "brightStyle", bright.toString( ) ); //$NON-NLS-1$ - } - - JsonValue darkValue = stylesValue.asObject( ).get( "dark" ); //$NON-NLS-1$ - if ( darkValue != null && !darkValue.isNull( ) && darkValue.isObject( ) ) - { - JsonObject dark = darkValue.asObject( ); - JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ).setValue( "darkStyle", dark.toString( ) ); //$NON-NLS-1$ - } - } - - private void checkDecompilerMark( JsonObject retrunValue ) - { - JsonValue markValue = retrunValue.get( "marks" ); //$NON-NLS-1$ - if ( markValue != null && markValue.isArray( ) && UserUtil.matchAdCondition( ) ) - { - JsonArray marks = markValue.asArray( ); - for ( int i = 0; i < marks.size( ); i++ ) - { - JsonObject value = marks.get( i ).asObject( ); - String mark = value.get( "mark" ).asString( ); //$NON-NLS-1$ - - int priority = 1; - if ( value.get( "priority" ) != null ) //$NON-NLS-1$ - { - priority = value.get( "priority" ).asInt( ); //$NON-NLS-1$ - } - - MarkUtil.addMark( "/** " + mark + " **/", priority ); //$NON-NLS-1$ //$NON-NLS-2$ - MarkUtil.addSourceMark( "/** " + mark + " */", priority ); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - } - - - private void checkTrayLink( JsonObject returnValue ) - { - JsonValue trayLinkValue = returnValue.get( "trayLink" ); //$NON-NLS-1$ - boolean result = TrayLinkUtil.handleTrayLinkJson( trayLinkValue ); - if ( result ) - { - if ( PlatformUI.getWorkbench( ) == null || PlatformUI.getWorkbench( ).getActiveWorkbenchWindow( ) == null ) - return; - - TrayLinkUtil.displayTrayLink( PlatformUI.getWorkbench( ).getActiveWorkbenchWindow( ) ); - } - } - -} diff --git a/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/DecompilerUpdatePlugin.java b/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/DecompilerUpdatePlugin.java deleted file mode 100644 index 0388ffc4..00000000 --- a/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/DecompilerUpdatePlugin.java +++ /dev/null @@ -1,169 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.update; - -import java.io.File; - -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.ui.IWindowListener; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.BundleException; -import org.sf.feeling.decompiler.JavaDecompilerPlugin; -import org.sf.feeling.decompiler.update.util.TrayLinkUtil; -import org.sf.feeling.decompiler.util.Logger; -import org.sf.feeling.decompiler.util.ReflectionUtils; - -/** - * The activator class controls the plug-in life cycle - */ -public class DecompilerUpdatePlugin extends AbstractUIPlugin implements IPropertyChangeListener -{ - - // The plug-in ID - public static final String PLUGIN_ID = "org.sf.feeling.decompiler.update"; //$NON-NLS-1$ - - // The shared instance - private static DecompilerUpdatePlugin plugin; - - private IPreferenceStore preferenceStore; - - private File patchFile; - - private IWindowListener windowListener = new IWindowListener( ) { - - @Override - public void windowOpened( IWorkbenchWindow window ) - { - TrayLinkUtil.displayTrayLink( window ); - } - - @Override - public void windowActivated( IWorkbenchWindow window ) - { - } - - @Override - public void windowDeactivated( IWorkbenchWindow window ) - { - } - - @Override - public void windowClosed( IWorkbenchWindow window ) - { - } - }; - - /** - * The constructor - */ - public DecompilerUpdatePlugin( ) - { - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework. - * BundleContext ) - */ - @Override - public void start( BundleContext context ) throws Exception - { - super.start( context ); - plugin = this; - getPreferenceStore( ).addPropertyChangeListener( this ); - if ( PlatformUI.getWorkbench( ) != null ) - { - PlatformUI.getWorkbench( ).addWindowListener( windowListener ); - } - } - - @Override - public IPreferenceStore getPreferenceStore( ) - { - if ( preferenceStore == null ) - { - preferenceStore = JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ); - } - return preferenceStore; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework. - * BundleContext ) - */ - @Override - public void stop( BundleContext context ) throws Exception - { - getPreferenceStore( ).removePropertyChangeListener( this ); - if ( PlatformUI.getWorkbench( ) != null ) - { - PlatformUI.getWorkbench( ).removeWindowListener( windowListener ); - } - if ( patchFile != null ) - { - try - { - Bundle bundle = (Bundle) ReflectionUtils.invokeMethod( context, "getBundle", new Class[]{ //$NON-NLS-1$ - String.class - }, new Object[]{ - patchFile.toURI( ).toString( ) - } ); - if ( bundle == null ) - { - return; - } - bundle.uninstall( ); - } - catch ( BundleException e ) - { - Logger.debug( e ); - } - } - plugin = null; - super.stop( context ); - } - - /** - * Returns the shared instance - * - * @return the shared instance - */ - public static DecompilerUpdatePlugin getDefault( ) - { - return plugin; - } - - @Override - public void propertyChange( PropertyChangeEvent event ) - { - - } - - public File getPatchFile( ) - { - return patchFile; - } - - public void setPatchFile( File patchFile ) - { - this.patchFile = patchFile; - } -} diff --git a/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/i18n/Messages.java b/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/i18n/Messages.java deleted file mode 100644 index be92282e..00000000 --- a/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/i18n/Messages.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.update.i18n; - -import java.io.UnsupportedEncodingException; -import java.text.MessageFormat; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -public class Messages -{ - - private static final String BUNDLE_NAME = "org.sf.feeling.decompiler.update.i18n.messages"; //$NON-NLS-1$ - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); - - private Messages( ) - { - } - - public static String getString( String key ) - { - - try - { - String result = RESOURCE_BUNDLE.getString( key ); - try - { - result = new String( result.getBytes( "ISO-8859-1" ), "utf-8" ); //$NON-NLS-1$ //$NON-NLS-2$ - } - catch ( UnsupportedEncodingException e ) - { - return '!' + key + '!'; - } - return result; - } - catch ( MissingResourceException e ) - { - return '!' + key + '!'; - } - } - - /** - * Gets formatted translation for current local - * - * @param key - * the key - * @return translated value string - */ - public static String getFormattedString( String key, Object[] arguments ) - { - return MessageFormat.format( getString( key ), arguments ); - } -} diff --git a/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/i18n/messages.properties b/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/i18n/messages.properties deleted file mode 100644 index 38c50b7d..00000000 --- a/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/i18n/messages.properties +++ /dev/null @@ -1,17 +0,0 @@ -############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation -############################################################################### - -DecompilerUpdateHandler.ConfirmDialog.Button.Continue=&Continue -DecompilerUpdateHandler.ConfirmDialog.Button.NotAskAgain=Do not ask again until the next update is available -DecompilerUpdateHandler.ConfirmDialog.Button.NotNow=&Not Now -DecompilerUpdateHandler.ConfirmDialog.Message=Eclipse Class Decompiler plugin update is available for your eclipse.\nDo you want to download and install it? -DecompilerUpdateHandler.ConfirmDialog.Force.Message=Eclipse Class Decompiler plugin has an important update for your eclipse.\nDo you want to download and install it? -DecompilerUpdateHandler.ConfirmDialog.Title=Plugin Update diff --git a/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/i18n/messages_zh_CN.properties b/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/i18n/messages_zh_CN.properties deleted file mode 100644 index 754ac0e3..00000000 --- a/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/i18n/messages_zh_CN.properties +++ /dev/null @@ -1,17 +0,0 @@ -############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation -############################################################################### - -DecompilerUpdateHandler.ConfirmDialog.Button.Continue=ç»§ç»­(&C) -DecompilerUpdateHandler.ConfirmDialog.Button.NotAskAgain=ä¸å†è¯¢é—®æœ¬æ¬¡æ›´æ–° -DecompilerUpdateHandler.ConfirmDialog.Button.NotNow=以åŽå†è¯´(&N) -DecompilerUpdateHandler.ConfirmDialog.Message=Eclipseå编译æ’ä»¶å‘布了一个新的更新,您是å¦å¸Œæœ›ä¸‹è½½å¹¶å®‰è£…这个更新? -DecompilerUpdateHandler.ConfirmDialog.Force.Message=Eclipseå编译æ’ä»¶å‘布了一个é‡è¦æ›´æ–°ï¼Œæ‚¨æ˜¯å¦å¸Œæœ›ä¸‹è½½å¹¶å®‰è£…这个更新? -DecompilerUpdateHandler.ConfirmDialog.Title=æ’ä»¶æ›´æ–° \ No newline at end of file diff --git a/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/i18n/messages_zh_HK.properties b/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/i18n/messages_zh_HK.properties deleted file mode 100644 index 27656b55..00000000 --- a/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/i18n/messages_zh_HK.properties +++ /dev/null @@ -1,17 +0,0 @@ -############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation -############################################################################### - -DecompilerUpdateHandler.ConfirmDialog.Button.Continue=繼續(&C) -DecompilerUpdateHandler.ConfirmDialog.Button.NotAskAgain=ä¸å†è©¢å•本次更新 -DecompilerUpdateHandler.ConfirmDialog.Button.NotNow=以後å†èªª(&N) -DecompilerUpdateHandler.ConfirmDialog.Message=Eclipseå編譯æ’件發佈了一個新的更新,您是å¦å¸Œæœ›ä¸‹è¼‰ä¸¦å®‰è£é€™å€‹æ›´æ–°ï¼Ÿ -DecompilerUpdateHandler.ConfirmDialog.Force.Message=Eclipseå編譯æ’件發佈了一個é‡è¦æ›´æ–°ï¼Œæ‚¨æ˜¯å¦å¸Œæœ›ä¸‹è¼‰ä¸¦å®‰è£é€™å€‹æ›´æ–°ï¼Ÿ -DecompilerUpdateHandler.ConfirmDialog.Title=æ’ä»¶æ›´æ–° \ No newline at end of file diff --git a/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/i18n/messages_zh_TW.properties b/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/i18n/messages_zh_TW.properties deleted file mode 100644 index 09cf7ae7..00000000 --- a/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/i18n/messages_zh_TW.properties +++ /dev/null @@ -1,17 +0,0 @@ -############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation -############################################################################### - -DecompilerUpdateHandler.ConfirmDialog.Button.Continue=繼續(&C) -DecompilerUpdateHandler.ConfirmDialog.Button.NotAskAgain=ä¸å†è©¢å•本次更新 -DecompilerUpdateHandler.ConfirmDialog.Button.NotNow=以後å†èªª(&N) -DecompilerUpdateHandler.ConfirmDialog.Message=Eclipseå編譯æ’件發布了一個新的更新,您是å¦å¸Œæœ›ä¸‹è¼‰ä¸¦å®‰è£é€™å€‹æ›´æ–°ï¼Ÿ -DecompilerUpdateHandler.ConfirmDialog.Force.Message=Eclipseå編譯æ’件發布了一個é‡è¦æ›´æ–°ï¼Œæ‚¨æ˜¯å¦å¸Œæœ›ä¸‹è¼‰ä¸¦å®‰è£é€™å€‹æ›´æ–°ï¼Ÿ -DecompilerUpdateHandler.ConfirmDialog.Title=æ’ä»¶æ›´æ–° \ No newline at end of file diff --git a/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/util/ExecutorUtil.java b/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/util/ExecutorUtil.java deleted file mode 100644 index 79b8e08b..00000000 --- a/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/util/ExecutorUtil.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.update.util; - -import java.util.concurrent.Callable; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - -public class ExecutorUtil -{ - - private final static ScheduledExecutorService scheduledPool = Executors.newScheduledThreadPool( 1 ); - - public static Future submitTask( Callable task ) - { - return scheduledPool.schedule( task, 0, TimeUnit.SECONDS ); - } - - public static void submitScheduledTask( Runnable task, long initialDelay, long period, TimeUnit unit ) - { - scheduledPool.scheduleAtFixedRate( task, initialDelay, period, unit ); - } - - public static void submitScheduledTask( Runnable task, long initialDelay, TimeUnit unit ) - { - scheduledPool.schedule( task, initialDelay, unit ); - } - -} diff --git a/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/util/TrayLinkUtil.java b/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/util/TrayLinkUtil.java deleted file mode 100644 index cf70b34c..00000000 --- a/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/util/TrayLinkUtil.java +++ /dev/null @@ -1,224 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.update.util; - -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.TreeMap; - -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IWorkbenchWindow; -import org.sf.feeling.decompiler.JavaDecompilerPlugin; -import org.sf.feeling.decompiler.update.widget.LinkTrimChecker; -import org.sf.feeling.decompiler.util.UserUtil; - -import com.eclipsesource.json.Json; -import com.eclipsesource.json.JsonArray; -import com.eclipsesource.json.JsonObject; -import com.eclipsesource.json.JsonValue; - -public class TrayLinkUtil -{ - - public static void displayTrayLink( final IWorkbenchWindow window ) - { - Display.getDefault( ).asyncExec( new Runnable( ) { - - @Override - public void run( ) - { - new LinkTrimChecker( ).displayTrayLink( window, enableShowTrayLink( ) ); - } - } ); - } - - public static boolean handleTrayLinkJson( JsonValue trayLinkValue ) - { - if ( trayLinkValue != null ) - { - JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ).setValue( "trayLinkStrategy", //$NON-NLS-1$ - trayLinkValue.toString( ) ); - return true; - } - return false; - } - - public static boolean enableShowTrayLink( ) - { - return JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ).contains( "trayLinkStrategy" ) //$NON-NLS-1$ - && UserUtil.matchAdCondition( ); - } - - public static String getTrayUrl( ) - { - String strategyString = JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ).getString( - "trayLinkStrategy" ); //$NON-NLS-1$ - if ( strategyString == null || "".equals( strategyString ) ) //$NON-NLS-1$ - return null; - return getRandomTrayUrl( strategyString ); - } - - private static String getRandomTrayUrl( String strategyString ) - { - JsonValue strategyValue = Json.parse( strategyString ); - if ( strategyValue.isObject( ) ) - { - JsonObject strategy = strategyValue.asObject( ); - if ( strategy.get( "url" ) != null ) //$NON-NLS-1$ - { - return strategy.get( "url" ).asString( ); //$NON-NLS-1$ - } - } - else if ( strategyValue.isArray( ) ) - { - JsonArray strategyArray = strategyValue.asArray( ); - List values = strategyArray.values( ); - Map urlMap = new TreeMap( ); - int weight = 0; - for ( int i = 0; i < values.size( ); i++ ) - { - JsonObject strategy = values.get( i ).asObject( ); - if ( strategy.get( "url" ) != null ) //$NON-NLS-1$ - { - String url = strategy.get( "url" ).asString( ); //$NON-NLS-1$ - int priority = 1; - if ( strategy.get( "priority" ) != null ) //$NON-NLS-1$ - { - priority = strategy.get( "priority" ).asInt( ); //$NON-NLS-1$ - } - weight += priority; - urlMap.put( weight, url ); - } - } - - if ( weight > 0 ) - { - int randomWeight = new Random( new Random( System.currentTimeMillis( ) ).nextLong( ) ) - .nextInt( weight * 100 ); - Iterator iter = urlMap.keySet( ).iterator( ); - while ( iter.hasNext( ) ) - { - Integer priority = iter.next( ); - if ( randomWeight < priority * 100 ) - { - return urlMap.get( priority ); - } - } - } - } - return null; - } - - public static Integer getTrayUrlDisplayTime( String url ) - { - String strategyString = JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ).getString( - "trayLinkStrategy" ); //$NON-NLS-1$ - if ( strategyString == null ) - return null; - JsonValue strategyValue = Json.parse( strategyString ); - if ( strategyValue.isObject( ) ) - { - JsonObject strategy = strategyValue.asObject( ); - if ( strategy.get( "showTime" ) != null ) //$NON-NLS-1$ - { - return strategy.get( "showTime" ).asInt( ); //$NON-NLS-1$ - } - } - else if ( strategyValue.isArray( ) ) - { - JsonArray strategyArray = strategyValue.asArray( ); - List values = strategyArray.values( ); - for ( int i = 0; i < values.size( ); i++ ) - { - JsonObject strategy = values.get( i ).asObject( ); - if ( strategy.get( "url" ) != null && url.equals( strategy.get( "url" ).asString( ) ) ) //$NON-NLS-1$ //$NON-NLS-2$ - { - if ( strategy.get( "showTime" ) != null ) //$NON-NLS-1$ - { - return strategy.get( "showTime" ).asInt( ); //$NON-NLS-1$ - } - } - } - } - return null; - } - - public static boolean isUseExternalBrowser( String url ) - { - String strategyString = JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ).getString( - "trayLinkStrategy" ); //$NON-NLS-1$ - if ( strategyString == null ) - return true; - JsonValue strategyValue = Json.parse( strategyString ); - if ( strategyValue.isObject( ) ) - { - JsonObject strategy = strategyValue.asObject( ); - if ( strategy.get( "external" ) != null ) //$NON-NLS-1$ - { - return strategy.get( "external" ).asBoolean( ); //$NON-NLS-1$ - } - } - else if ( strategyValue.isArray( ) ) - { - JsonArray strategyArray = strategyValue.asArray( ); - List values = strategyArray.values( ); - for ( int i = 0; i < values.size( ); i++ ) - { - JsonObject strategy = values.get( i ).asObject( ); - if ( strategy.get( "url" ) != null && url.equals( strategy.get( "url" ).asString( ) ) ) //$NON-NLS-1$ //$NON-NLS-2$ - { - if ( strategy.get( "external" ) != null ) //$NON-NLS-1$ - { - return strategy.get( "external" ).asBoolean( ); //$NON-NLS-1$ - } - } - } - } - return true; - } - - public static boolean useSystemColor( String url ) - { - String strategyString = JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ).getString( - "trayLinkStrategy" ); //$NON-NLS-1$ - if ( strategyString == null ) - return true; - JsonValue strategyValue = Json.parse( strategyString ); - if ( strategyValue.isObject( ) ) - { - JsonObject strategy = strategyValue.asObject( ); - if ( strategy.get( "useSystemColor" ) != null ) //$NON-NLS-1$ - { - return strategy.get( "useSystemColor" ).asBoolean( ); //$NON-NLS-1$ - } - } - else if ( strategyValue.isArray( ) ) - { - JsonArray strategyArray = strategyValue.asArray( ); - List values = strategyArray.values( ); - for ( int i = 0; i < values.size( ); i++ ) - { - JsonObject strategy = values.get( i ).asObject( ); - if ( strategy.get( "url" ) != null && url.equals( strategy.get( "url" ).asString( ) ) ) //$NON-NLS-1$ //$NON-NLS-2$ - { - if ( strategy.get( "useSystemColor" ) != null ) //$NON-NLS-1$ - { - return strategy.get( "useSystemColor" ).asBoolean( ); //$NON-NLS-1$ - } - } - } - } - return true; - } -} diff --git a/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/widget/HtmlLinkTrimItem.java b/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/widget/HtmlLinkTrimItem.java deleted file mode 100644 index 810f0274..00000000 --- a/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/widget/HtmlLinkTrimItem.java +++ /dev/null @@ -1,525 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.update.widget; - -import java.net.InetSocketAddress; -import java.net.Socket; -import java.net.URL; -import java.util.concurrent.Callable; -import java.util.concurrent.TimeUnit; - -import org.eclipse.jdt.internal.ui.JavaPlugin; -import org.eclipse.jdt.ui.text.IJavaColorConstants; -import org.eclipse.jdt.ui.text.JavaTextTools; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.swt.SWT; -import org.eclipse.swt.browser.Browser; -import org.eclipse.swt.browser.BrowserFunction; -import org.eclipse.swt.browser.ProgressEvent; -import org.eclipse.swt.browser.ProgressListener; -import org.eclipse.swt.custom.ScrolledComposite; -import org.eclipse.swt.events.ControlAdapter; -import org.eclipse.swt.events.ControlEvent; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.internal.TrimUtil; -import org.eclipse.ui.themes.ColorUtil; -import org.sf.feeling.decompiler.JavaDecompilerPlugin; -import org.sf.feeling.decompiler.update.util.ExecutorUtil; -import org.sf.feeling.decompiler.update.util.TrayLinkUtil; -import org.sf.feeling.decompiler.util.Logger; -import org.sf.feeling.decompiler.util.ReflectionUtils; -import org.sf.feeling.decompiler.util.UIUtil; - -@SuppressWarnings("restriction") -public class HtmlLinkTrimItem extends Composite -{ - - private double width, height; - private Browser browser; - private volatile String browserUrl; - private volatile boolean isDisposed = false; - private boolean isUseExternalBrowser = true; - - private Composite container; - private ScrolledComposite sComposite; - private String trayLinkUrl; - - static class CustomFunction extends BrowserFunction - { - - private String funcName; - private HtmlLinkTrimItem linkItem; - - CustomFunction( HtmlLinkTrimItem linkItem, Browser browser, String name ) - { - super( browser, name ); - this.funcName = name; - this.linkItem = linkItem; - } - - @Override - public Object function( Object[] arguments ) - { - if ( "gotoUrl".equals( funcName ) ) //$NON-NLS-1$ - { - if ( arguments != null && arguments.length > 0 && arguments[0] != null ) - { - UIUtil.openBrowser( arguments[0].toString( ) ); - } - } - else if ( "updateAdCount".equals( funcName ) ) //$NON-NLS-1$ - { - JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ).setValue( JavaDecompilerPlugin.ADCLICK_COUNT, - JavaDecompilerPlugin.getDefault( ).getAdClickCount( ).getAndIncrement( ) ); - } - else if ( "resize".equals( funcName ) ) //$NON-NLS-1$ - { - linkItem.resize( "" ); //$NON-NLS-1$ - } - return super.function( arguments ); - } - } - - public HtmlLinkTrimItem( Composite parent ) - { - super( parent, SWT.NONE ); - this.setBackgroundMode( SWT.INHERIT_FORCE ); - - GridLayout trimLayout = new GridLayout( ); - trimLayout.marginWidth = 0; - trimLayout.marginHeight = 0; - this.setLayout( trimLayout ); - - sComposite = new ScrolledComposite( this, SWT.NONE ); - sComposite.setBackgroundMode( SWT.INHERIT_FORCE ); - sComposite.setLayoutData( new GridData( GridData.FILL_BOTH ) ); - sComposite.setExpandHorizontal( true ); - sComposite.setExpandVertical( true ); - sComposite.setAlwaysShowScrollBars( false ); - - container = new Composite( sComposite, SWT.NONE ); - container.setBackgroundMode( SWT.INHERIT_FORCE ); - sComposite.setContent( container ); - GridLayout layout = new GridLayout( ); - layout.marginWidth = 0; - layout.marginHeight = 0; - container.setLayout( layout ); - - browser = new Browser( container, SWT.NONE ); - browser.setVisible( false ); - browser.setBackgroundMode( SWT.INHERIT_FORCE ); - - new CustomFunction( this, browser, "gotoUrl" ); //$NON-NLS-1$ - new CustomFunction( this, browser, "updateAdCount" ); //$NON-NLS-1$ - new CustomFunction( this, browser, "resize" ); //$NON-NLS-1$ - - final ProgressListener[] listeners = new ProgressListener[1]; - ProgressListener listener = new ProgressListener( ) { - - @Override - public void completed( ProgressEvent event ) - { - handleEvent( ); - getDisplay( ).asyncExec( new Runnable( ) { - - @Override - public void run( ) - { - if ( !browser.isDisposed( ) ) - { - registerLinkClickListener( ); - } - } - } ); - } - - private void handleEvent( ) - { - browser.execute( updateBrowserStyle( ) ); - - getDisplay( ).asyncExec( new Runnable( ) { - - @Override - public void run( ) - { - if ( browser == null || browser.isDisposed( ) ) - return; - try - { - resize( updateBrowserStyle( ) ); - browserUrl = browser.getUrl( ); - } - catch ( Exception e ) - { - if ( browser.isVisible( ) ) - { - browser.setVisible( false ); - } - Logger.debug( e ); - } - } - } ); - - } - - @Override - public void changed( ProgressEvent event ) - { - handleEvent( ); - } - }; - listeners[0] = listener; - browser.addProgressListener( listener ); - - GridData gd = new GridData( ); - gd.heightHint = getDisplay( ).getBounds( ).height; - gd.widthHint = getDisplay( ).getBounds( ).width; - browser.setLayoutData( gd ); - - updateTrimUrl( ); - - sComposite.addControlListener( new ControlAdapter( ) { - - private void computeSize( ) - { - sComposite.setMinSize( container.computeSize( SWT.DEFAULT, SWT.DEFAULT ) ); - container.layout( ); - } - - @Override - public void controlResized( ControlEvent e ) - { - computeSize( ); - } - } ); - container.layout( ); - } - - private String updateBrowserStyle( ) - { - StringBuilder buffer = new StringBuilder( ); - buffer.append( updateBrowserColor( ) ); - if ( trayLinkUrl == null || TrayLinkUtil.useSystemColor( trayLinkUrl ) || UIUtil.isDark( getParent( ) ) ) - { - buffer.append( updateBrowserFontColor( ) ); - } - buffer.append( updateBrowserFontFamily( ) ); - buffer.append( updateBrowserFontSize( ) ); - - return buffer.toString( ); - } - - private void updateTrimUrl( ) - { - if ( isDisposed || browser.isDisposed( ) ) - { - return; - } - - trayLinkUrl = TrayLinkUtil.getTrayUrl( ); - if ( trayLinkUrl == null ) - { - return; - } - - Integer time = TrayLinkUtil.getTrayUrlDisplayTime( trayLinkUrl ); - - if ( time == null ) - { - time = 10; - } - - if ( UIUtil.isWin32( ) ) - { - isUseExternalBrowser = TrayLinkUtil.isUseExternalBrowser( trayLinkUrl ); - } - else - { - isUseExternalBrowser = true; - } - if ( !trayLinkUrl.equals( browserUrl ) ) - { - ExecutorUtil.submitTask( new Callable( ) { - - @Override - public Boolean call( ) throws Exception - { - Socket socket = new Socket( ); - try - { - if ( HtmlLinkTrimItem.this.isDisposed( ) ) - return true; - socket.connect( new InetSocketAddress( new URL( trayLinkUrl ).getHost( ), 80 ), 5000 ); - HtmlLinkTrimItem.this.getDisplay( ).asyncExec( new Runnable( ) { - - @Override - public void run( ) - { - if ( browser != null && !browser.isDisposed( ) ) - { - browser.setData( "linkClick", false ); //$NON-NLS-1$ - browser.setVisible( false ); - browser.setUrl( trayLinkUrl ); - } - else - { - isDisposed = true; - } - } - } ); - return true; - } - catch ( Exception e ) - { - browserUrl = null; - HtmlLinkTrimItem.this.getDisplay( ).asyncExec( new Runnable( ) { - - @Override - public void run( ) - { - if ( browser != null && !browser.isDisposed( ) ) - { - browser.setVisible( false ); - } - else - { - isDisposed = true; - } - } - } ); - Logger.debug( e ); - return false; - } - finally - { - socket.close( ); - } - } - } ); - } - - ExecutorUtil.submitScheduledTask( new Runnable( ) { - - @Override - public void run( ) - { - updateTrimUrl( ); - } - }, time, TimeUnit.MINUTES ); - } - - @Override - public Point computeSize( int wHint, int hHint, boolean changed ) - { - int trimWidth = (int) width + 5 * 2 + 4; - int trimHeight = getParent( ) instanceof Shell ? (int) height : getParent( ).getBounds( ).height; - trimHeight = Math.max( TrimUtil.TRIM_DEFAULT_HEIGHT, trimHeight ); - return new Point( trimWidth, trimHeight ); - } - - private String updateBrowserColor( ) - { - Color color = getBackground( ); - String script = "document.body.style.background=\"rgb(" //$NON-NLS-1$ - + color.getRed( ) - + "," //$NON-NLS-1$ - + color.getGreen( ) - + "," //$NON-NLS-1$ - + color.getBlue( ) - + ")\";"; //$NON-NLS-1$ - // script += "$('div').css('background-color','rgb(" //$NON-NLS-1$ - // + color.getRed( ) - // + "," //$NON-NLS-1$ - // + color.getGreen( ) - // + "," //$NON-NLS-1$ - // + color.getBlue( ) - // + ")');"; //$NON-NLS-1$ - return script; - } - - /** - * On Windows: points(SWT) = points(browser) != pixels(SWT) = - * pixels(browser)
      - * On Mac: points(SWT) = pixels(SWT) = pixels(browser) != points(browser) - */ - protected String updateBrowserFontSize( ) - { - int fontHeight = HtmlLinkTrimItem.this.getFont( ).getFontData( )[0].getHeight( ); - String script = "$('a').css('font-size','" //$NON-NLS-1$ - + fontHeight - + ( UIUtil.isMacOS( ) ? "px" : "pt" ) //$NON-NLS-1$ //$NON-NLS-2$ - + "');"; //$NON-NLS-1$ - return script; - } - - protected String updateBrowserFontFamily( ) - { - String fontFamily = HtmlLinkTrimItem.this.getFont( ).getFontData( )[0].getName( ); - if ( UIUtil.isMacOS( ) ) - { - fontFamily = "sans-serif"; //$NON-NLS-1$ - } - String script = "$('a').css('font-family','" + fontFamily + "');"; //$NON-NLS-1$ //$NON-NLS-2$ - return script; - } - - protected String updateBrowserFontColor( ) - { - - Color color = HtmlLinkTrimItem.this.getParent( ).getForeground( ); - if ( color.equals( getDisplay( ).getSystemColor( SWT.COLOR_WIDGET_FOREGROUND ) ) ) - { - color = getDisplay( ).getSystemColor( SWT.COLOR_BLUE ); - } - else if ( UIUtil.isDark( this ) ) - { - JavaTextTools textTools = JavaPlugin.getDefault( ).getJavaTextTools( ); - IPreferenceStore preferences = (IPreferenceStore) ReflectionUtils.getFieldValue( textTools, - "fPreferenceStore" ); //$NON-NLS-1$ - String defaultColorSetting = preferences.getString( IJavaColorConstants.JAVA_DEFAULT ); - color = JFaceResources.getResources( ).createColor( ColorUtil.getColorValue( defaultColorSetting ) ); - } - String script = "$('a').css('color','rgb(" //$NON-NLS-1$ - + color.getRed( ) - + "," //$NON-NLS-1$ - + color.getGreen( ) - + "," //$NON-NLS-1$ - + color.getBlue( ) - + ")');"; //$NON-NLS-1$ - return script; - } - - private void registerLinkClickListener( ) - { - if ( isUseExternalBrowser ) - { - if ( !Boolean.TRUE.equals( browser.getData( "linkClick" ) ) ) //$NON-NLS-1$ - { - String script = "var script = document.createElement('script'); script.innerHTML=\"$('a').click( function(e) {e.preventDefault(); gotoUrl(this.href); updateAdCount(); return false; } );\"; document.head.appendChild(script);"; //$NON-NLS-1$ - if ( browser.execute( script ) ) - { - browser.setData( "linkClick", true ); //$NON-NLS-1$ - } ; - } - } - else - { - if ( !Boolean.TRUE.equals( browser.getData( "linkClick" ) ) ) //$NON-NLS-1$ - { - String script = "var script = document.createElement('script'); script.innerHTML=\"$('a').click( function(e) { updateAdCount(); return true; } );\"; document.head.appendChild(script);"; //$NON-NLS-1$ - if ( browser.execute( script ) ) - { - browser.setData( "linkClick", true ); //$NON-NLS-1$ - } - } - } - } - - private void resize( final String updatedStyle ) - { - if ( browser.isDisposed( ) ) - { - return; - } - if ( updatedStyle != null && updatedStyle.length( ) > 0 ) - { - browser.execute( updatedStyle ); // $NON-NLS-1$ - } - - try - { - if ( browser.isDisposed( ) ) - { - return; - } - - browser.execute( updatedStyle ); // $NON-NLS-1$ - Object[] area = (Object[]) browser.evaluate( "return getContentArea();" ); //$NON-NLS-1$ - if ( area == null || area[0] == null || area[1] == null ) - return; - double tempWidth = Double.valueOf( area[0].toString( ) ); - double tempHeight = Double.valueOf( area[1].toString( ) ); - if ( tempWidth > 0 && tempHeight > 0 ) - { - width = tempWidth; - height = tempHeight; - - Point computeSize = computeSize( -1, -1, true ); - HtmlLinkTrimItem.this.pack( ); - HtmlLinkTrimItem.this.setSize( computeSize ); - GridData gd = (GridData) browser.getLayoutData( ); - if ( gd == null ) - { - gd = new GridData( ); - } - gd.verticalIndent = (int) Math.ceil( HtmlLinkTrimItem.this.getBounds( ).height - height ) / 2 - 1; - gd.heightHint = (int) height + 1; - browser.setLayoutData( gd ); - HtmlLinkTrimItem.this.layout( true, true ); - HtmlLinkTrimItem.this.getParent( ).layout( true, true ); - if ( HtmlLinkTrimItem.this.getParent( ).getParent( ) != null ) - { - HtmlLinkTrimItem.this.getParent( ).getParent( ).layout( true, true ); - if ( HtmlLinkTrimItem.this.getParent( ).getParent( ).getParent( ) != null ) - { - HtmlLinkTrimItem.this.getParent( ).getParent( ).getParent( ).layout( true, true ); - } - } - showBrowser( ); - } - else if ( browser.isVisible( ) ) - { - browser.setVisible( false ); - } - } - catch ( Exception e ) - { - Logger.debug( e ); - } - } - - private void showBrowser( ) - { - if ( browser.isDisposed( ) ) - { - return; - } - getDisplay( ).asyncExec( new Runnable( ) { - - @Override - public void run( ) - { - if ( browser.isDisposed( ) ) - { - return; - } - getDisplay( ).timerExec( 50, new Runnable( ) { - - @Override - public void run( ) - { - if ( !browser.isDisposed( ) && !browser.isVisible( ) ) - { - browser.setVisible( true ); - } - } - } ); - } - } ); - } -} diff --git a/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/widget/LinkTrimChecker.java b/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/widget/LinkTrimChecker.java deleted file mode 100644 index d2f29531..00000000 --- a/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/widget/LinkTrimChecker.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.update.widget; - -import org.eclipse.ui.IWorkbenchWindow; -import org.sf.feeling.decompiler.util.Logger; - -public class LinkTrimChecker -{ - - public void displayTrayLink( IWorkbenchWindow window, boolean show ) - { - if ( supportV1( ) ) - { - TrayLinkV1.displayTrayLink( window, show ); - } - else if ( supportV2( ) ) - { - TrayLinkV2.displayTrayLink( window, show ); - } - } - - private boolean supportV1( ) - { - try - { - Class.forName( "org.eclipse.e4.ui.model.application.ui.menu.MToolControl" ); //$NON-NLS-1$ - return true; - } - catch ( Exception e ) - { - Logger.debug( e ); - } - return false; - } - - private boolean supportV2( ) - { - try - { - Class.forName( "org.eclipse.ui.internal.WindowTrimProxy" ); //$NON-NLS-1$ - return true; - } - catch ( Exception e ) - { - Logger.debug( e ); - } - return false; - } -} diff --git a/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/widget/MToolControlFactory.java b/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/widget/MToolControlFactory.java deleted file mode 100644 index 2c0e17fc..00000000 --- a/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/widget/MToolControlFactory.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.update.widget; - -import org.eclipse.e4.ui.model.application.ui.menu.MToolControl; -import org.eclipse.e4.ui.workbench.modeling.EModelService; -import org.sf.feeling.decompiler.util.Logger; -import org.sf.feeling.decompiler.util.ReflectionUtils; - -@SuppressWarnings({ - "rawtypes" -}) -public class MToolControlFactory -{ - - public static MToolControl getToolControl( EModelService modelService ) - { - if ( supportV1( modelService ) ) - { - return MToolControlV1.createToolControl( modelService ); - } - else if ( supportV2( ) ) - { - return MToolControlV2.createToolControl( ); - } - return null; - } - - private static boolean supportV2( ) - { - try - { - Class clazz = Class.forName( "org.eclipse.e4.ui.model.application.ui.menu.impl.MenuFactoryImpl" ); //$NON-NLS-1$ - return ReflectionUtils.getDeclaredMethod( clazz, "createToolControl", new Class[0] ) != null; //$NON-NLS-1$ - } - catch ( Exception e ) - { - Logger.debug( e ); - } - return false; - } - - private static boolean supportV1( EModelService modelService ) - { - return ReflectionUtils.getDeclaredMethod( modelService, "createModelElement", new Class[]{ //$NON-NLS-1$ - MToolControl.class - } ) != null; - } -} diff --git a/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/widget/MToolControlV1.java b/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/widget/MToolControlV1.java deleted file mode 100644 index 1086cd37..00000000 --- a/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/widget/MToolControlV1.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.update.widget; - -import org.eclipse.e4.ui.model.application.ui.menu.MToolControl; -import org.eclipse.e4.ui.workbench.modeling.EModelService; - -public class MToolControlV1 -{ - - public static MToolControl createToolControl( EModelService modelService ) - { - return modelService.createModelElement( MToolControl.class ); - } -} diff --git a/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/widget/MToolControlV2.java b/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/widget/MToolControlV2.java deleted file mode 100644 index e20058ef..00000000 --- a/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/widget/MToolControlV2.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.update.widget; - -import org.eclipse.e4.ui.model.application.ui.menu.MToolControl; -import org.eclipse.e4.ui.model.application.ui.menu.impl.MenuFactoryImpl; - -@SuppressWarnings("restriction") -public class MToolControlV2 -{ - - public static MToolControl createToolControl( ) - { - return MenuFactoryImpl.eINSTANCE.createToolControl( ); - } - -} diff --git a/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/widget/StandardTrimExtension.java b/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/widget/StandardTrimExtension.java deleted file mode 100644 index 3c41bf3b..00000000 --- a/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/widget/StandardTrimExtension.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.update.widget; - -import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; -import javax.inject.Inject; - -import org.eclipse.e4.ui.model.application.ui.menu.MToolControl; -import org.eclipse.e4.ui.workbench.modeling.EModelService; -import org.eclipse.jface.action.StatusLineManager; -import org.eclipse.swt.widgets.Composite; - -public class StandardTrimExtension -{ - - @Inject - EModelService modelService; - - private StatusLineManager manager; - - @PostConstruct - void createWidget( Composite parent, MToolControl toolControl ) - { - if ( toolControl.getElementId( ).equals( "org.sf.feeling.decompiler.update.widget.HtmlLinkTrimItem" ) ) //$NON-NLS-1$ - { - createTrayLink( parent, toolControl ); - } - } - - @PreDestroy - void destroy( ) - { - if ( manager != null ) - { - manager.dispose( ); - manager = null; - } - } - - /** - * @param parent - * @param toolControl - */ - private void createTrayLink( Composite parent, MToolControl toolControl ) - { - new HtmlLinkTrimItem( parent ); - } -} diff --git a/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/widget/TrayLinkV1.java b/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/widget/TrayLinkV1.java deleted file mode 100644 index 5472d18e..00000000 --- a/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/widget/TrayLinkV1.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.update.widget; - -import org.eclipse.e4.ui.model.application.ui.SideValue; -import org.eclipse.e4.ui.model.application.ui.basic.MTrimBar; -import org.eclipse.e4.ui.model.application.ui.basic.MTrimmedWindow; -import org.eclipse.e4.ui.model.application.ui.menu.MToolControl; -import org.eclipse.e4.ui.workbench.modeling.EModelService; -import org.eclipse.ui.IWorkbenchWindow; -import org.sf.feeling.decompiler.util.ReflectionUtils; - -public class TrayLinkV1 -{ - - public static final String TRIM_CONTRIBUTION_URI = "bundleclass://org.sf.feeling.decompiler.update/org.sf.feeling.decompiler.update.widget.StandardTrimExtension"; //$NON-NLS-1$ - - public static void displayTrayLink( IWorkbenchWindow window, boolean show ) - { - EModelService modelService = (EModelService) ReflectionUtils.getFieldValue( window, "modelService" ); //$NON-NLS-1$ - MTrimmedWindow model = (MTrimmedWindow) ReflectionUtils.getFieldValue( window, "model" ); //$NON-NLS-1$ - if ( modelService == null || model == null ) - return; - MTrimBar bottomTrim = modelService.getTrim( model, SideValue.BOTTOM ); - - MToolControl hsElement = (MToolControl) modelService.find( - "org.sf.feeling.decompiler.update.widget.HtmlLinkTrimItem", //$NON-NLS-1$ - model ); - if ( hsElement == null ) - { - hsElement = MToolControlFactory.getToolControl( modelService ); - if ( hsElement != null ) - { - hsElement.setElementId( "org.sf.feeling.decompiler.update.widget.HtmlLinkTrimItem" ); //$NON-NLS-1$ - hsElement.setContributionURI( TRIM_CONTRIBUTION_URI ); - hsElement.getTags( ).add( "Draggable" ); //$NON-NLS-1$ - bottomTrim.getChildren( ).add( hsElement ); - } - else - { - return; - } - } - hsElement.setToBeRendered( show ); - } -} diff --git a/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/widget/TrayLinkV2.java b/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/widget/TrayLinkV2.java deleted file mode 100644 index 76cd97cd..00000000 --- a/org.sf.feeling.decompiler.update/src/org/sf/feeling/decompiler/update/widget/TrayLinkV2.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.update.widget; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.eclipse.swt.SWT; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.internal.WindowTrimProxy; -import org.eclipse.ui.internal.WorkbenchWindow; -import org.eclipse.ui.internal.layout.TrimLayout; -import org.sf.feeling.decompiler.util.ReflectionUtils; - -public class TrayLinkV2 -{ - - private static Map trayLinks = new ConcurrentHashMap( ); - private static Map trayLinkTrims = new ConcurrentHashMap( ); - - public static void displayTrayLink( IWorkbenchWindow window, boolean show ) - { - if ( window == null ) - return; - - if ( !trayLinks.containsKey( window ) ) - { - HtmlLinkTrimItem trayLink = new HtmlLinkTrimItem( window.getShell( ) ); - WindowTrimProxy trayLinkTrim = new WindowTrimProxy( trayLink, - "org.sf.feeling.decompiler.update.widget.HtmlLinkTrimItem", //$NON-NLS-1$ - "Tray Link", //$NON-NLS-1$ - SWT.BOTTOM | SWT.TOP ) { - - @Override - public void handleClose( ) - { - getControl( ).dispose( ); - } - - @Override - public boolean isCloseable( ) - { - return true; - } - }; - trayLinks.put( window, trayLink ); - trayLinkTrims.put( window, trayLinkTrim ); - } - - if ( trayLinks.containsKey( window ) ) - { - HtmlLinkTrimItem trayLink = trayLinks.get( window ); - WindowTrimProxy trayLinkTrim = trayLinkTrims.get( window ); - if ( show ) - { - if ( trayLink.getLayoutData( ) == null ) - { - trayLinkTrim.setWidthHint( trayLink.computeSize( SWT.DEFAULT, SWT.DEFAULT ).x ); - trayLinkTrim.setHeightHint( - ( (WorkbenchWindow) window ).getStatusLineManager( ).getControl( ).computeSize( SWT.DEFAULT, - SWT.DEFAULT ).y ); - } - - TrimLayout defaultLayout = (TrimLayout) ReflectionUtils.getFieldValue( window, "defaultLayout" ); //$NON-NLS-1$ - if ( defaultLayout != null ) - { - if ( defaultLayout.getTrim( trayLinkTrim.getId( ) ) == null ) - { - defaultLayout.addTrim( SWT.BOTTOM, trayLinkTrim ); - } - trayLink.setVisible( true ); - } - } - else - { - TrimLayout defaultLayout = (TrimLayout) ReflectionUtils.getFieldValue( window, "defaultLayout" ); //$NON-NLS-1$ - if ( defaultLayout != null ) - { - defaultLayout.removeTrim( trayLinkTrim ); - trayLink.setVisible( false );; - } - } - } - } -} diff --git a/org.sf.feeling.decompiler.updatesite/build/index.html b/org.sf.feeling.decompiler.updatesite/build/index.html deleted file mode 100644 index 5731ef18..00000000 --- a/org.sf.feeling.decompiler.updatesite/build/index.html +++ /dev/null @@ -1,87 +0,0 @@ - - -Eclipse Class Decompiler Project Update - - - - - - -
      - - diff --git a/org.sf.feeling.decompiler.updatesite/build/site.css b/org.sf.feeling.decompiler.updatesite/build/site.css deleted file mode 100644 index 3ab6f9bf..00000000 --- a/org.sf.feeling.decompiler.updatesite/build/site.css +++ /dev/null @@ -1,12 +0,0 @@ - diff --git a/org.sf.feeling.decompiler.updatesite/build/site.xml b/org.sf.feeling.decompiler.updatesite/build/site.xml deleted file mode 100644 index 72ee193a..00000000 --- a/org.sf.feeling.decompiler.updatesite/build/site.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - Eclipse Class Decompiler project update site. - - - - - - - - - - - - - - - - - - - - - - Eclipse Class Decompiler integrates JD, Jad, FernFlower, CFR, Procyon with Eclipse seamlessly. It allows Java developers to debug class files without source code directly. - - - - - Eclipse Class Decompiler integrates JD, Jad, FernFlower, CFR, Procyon with Eclipse seamlessly. It allows Java developers to debug class files without source code directly. - - - diff --git a/org.sf.feeling.decompiler.updatesite/build/site.xsl b/org.sf.feeling.decompiler.updatesite/build/site.xsl deleted file mode 100644 index a6eed759..00000000 --- a/org.sf.feeling.decompiler.updatesite/build/site.xsl +++ /dev/null @@ -1,315 +0,0 @@ - - - - - - - - - Eclipse Class Decompiler Project Update - - - -

      Eclipse Class Decompiler Project Update

      -

      - - Eclipse Class Decompiler plugin, Copyright (c) 2017 Chen Chao. - Any question, please mail to - Chen Chao(cnfree2000@hotmail.com) - . More details, please visit - cpupk.com -
      -
      -

      - - - -

      - - - - : - -

      - - - - - - - - - - - - - dark-row - - - light-row - - - - - - - - - - - -
      - Feature Name - - Feature Environments -
      - - - - - -
      -
      - ( - - - - - ) -
      -
      - - - - - - - - -
      -
      -
      - - - - - - - - - - - - - - - - - - - - - - - - - -
      Operating Systems: - -
      Windows Systems: - -
      Languages: - -
      Architecture: - -
      -
      -
      -
      -
      -
      -
      - - - - - -
      - Uncategorized -
      -
      - - - - - - - - - - - - - - - - - dark-row - - - light-row - - - - - - -
      - - - - - -
      -
      - ( - - - - - ) -
      -
      - - - - - - - - -
      -
      -
      -
      - - - - - - - - - - - - - - - - - - - - - - - - - -
      Operating Systems: - -
      Windows Systems: - -
      Languages: - -
      Architecture: - -
      -
      -
      - - - - - - - - - dark-row - - - light-row - - - - - - -
      - - - - - -
      -
      - ( - - - - - ) -
      -
      - - - - - - - - -
      -
      -
      -
      - - - - - - - - - - - - - - - - - - - - - - - - - -
      Operating Systems: - -
      Windows Systems: - -
      Languages: - -
      Architecture: - -
      -
      -
      -
      - - -
      -
      -
      diff --git a/org.sf.feeling.decompiler.source.feature/.project b/org.sf.feeling.decompiler.vineflower.feature/.project similarity index 82% rename from org.sf.feeling.decompiler.source.feature/.project rename to org.sf.feeling.decompiler.vineflower.feature/.project index 5c340930..353a5e6e 100644 --- a/org.sf.feeling.decompiler.source.feature/.project +++ b/org.sf.feeling.decompiler.vineflower.feature/.project @@ -1,17 +1,17 @@ - - - org.sf.feeling.decompiler.source.feature - - - - - - org.eclipse.pde.FeatureBuilder - - - - - - org.eclipse.pde.FeatureNature - - + + + org.sf.feeling.decompiler.vineflower.feature + + + + + + org.eclipse.pde.FeatureBuilder + + + + + + org.eclipse.pde.FeatureNature + + diff --git a/org.sf.feeling.decompiler.vineflower.feature/.settings/org.eclipse.core.resources.prefs b/org.sf.feeling.decompiler.vineflower.feature/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000..99f26c02 --- /dev/null +++ b/org.sf.feeling.decompiler.vineflower.feature/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/org.sf.feeling.decompiler.vineflower.feature/.settings/org.eclipse.core.runtime.prefs b/org.sf.feeling.decompiler.vineflower.feature/.settings/org.eclipse.core.runtime.prefs new file mode 100644 index 00000000..deae05a9 --- /dev/null +++ b/org.sf.feeling.decompiler.vineflower.feature/.settings/org.eclipse.core.runtime.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +line.separator=\r\n diff --git a/org.sf.feeling.decompiler.vineflower.feature/build.properties b/org.sf.feeling.decompiler.vineflower.feature/build.properties new file mode 100644 index 00000000..40b08e1e --- /dev/null +++ b/org.sf.feeling.decompiler.vineflower.feature/build.properties @@ -0,0 +1,5 @@ +bin.includes = feature.xml,\ + eclipse_update_120.jpg,\ + epl-v10.html,\ + feature.properties,\ + license.html \ No newline at end of file diff --git a/org.sf.feeling.decompiler.source.feature/eclipse_update_120.jpg b/org.sf.feeling.decompiler.vineflower.feature/eclipse_update_120.jpg similarity index 100% rename from org.sf.feeling.decompiler.source.feature/eclipse_update_120.jpg rename to org.sf.feeling.decompiler.vineflower.feature/eclipse_update_120.jpg diff --git a/org.sf.feeling.decompiler.source.feature/epl-v10.html b/org.sf.feeling.decompiler.vineflower.feature/epl-v10.html similarity index 98% rename from org.sf.feeling.decompiler.source.feature/epl-v10.html rename to org.sf.feeling.decompiler.vineflower.feature/epl-v10.html index 90f2d5ea..ed4b1966 100644 --- a/org.sf.feeling.decompiler.source.feature/epl-v10.html +++ b/org.sf.feeling.decompiler.vineflower.feature/epl-v10.html @@ -1,328 +1,328 @@ - - - - - - - - -Eclipse Public License - Version 1.0 - - - - - - -
      - -

      Eclipse Public License - v 1.0 -

      - -

      THE ACCOMPANYING PROGRAM IS PROVIDED UNDER -THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, -REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE -OF THIS AGREEMENT.

      - -

      1. DEFINITIONS

      - -

      "Contribution" means:

      - -

      a) -in the case of the initial Contributor, the initial code and documentation -distributed under this Agreement, and
      -b) in the case of each subsequent Contributor:

      - -

      i) -changes to the Program, and

      - -

      ii) -additions to the Program;

      - -

      where -such changes and/or additions to the Program originate from and are distributed -by that particular Contributor. A Contribution 'originates' from a Contributor -if it was added to the Program by such Contributor itself or anyone acting on -such Contributor's behalf. Contributions do not include additions to the -Program which: (i) are separate modules of software distributed in conjunction -with the Program under their own license agreement, and (ii) are not derivative -works of the Program.

      - -

      "Contributor" means any person or -entity that distributes the Program.

      - -

      "Licensed Patents " mean patent -claims licensable by a Contributor which are necessarily infringed by the use -or sale of its Contribution alone or when combined with the Program.

      - -

      "Program" means the Contributions -distributed in accordance with this Agreement.

      - -

      "Recipient" means anyone who -receives the Program under this Agreement, including all Contributors.

      - -

      2. GRANT OF RIGHTS

      - -

      a) -Subject to the terms of this Agreement, each Contributor hereby grants Recipient -a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly -display, publicly perform, distribute and sublicense the Contribution of such -Contributor, if any, and such derivative works, in source code and object code -form.

      - -

      b) -Subject to the terms of this Agreement, each Contributor hereby grants -Recipient a non-exclusive, worldwide, royalty-free -patent license under Licensed Patents to make, use, sell, offer to sell, import -and otherwise transfer the Contribution of such Contributor, if any, in source -code and object code form. This patent license shall apply to the combination -of the Contribution and the Program if, at the time the Contribution is added -by the Contributor, such addition of the Contribution causes such combination -to be covered by the Licensed Patents. The patent license shall not apply to -any other combinations which include the Contribution. No hardware per se is -licensed hereunder.

      - -

      c) -Recipient understands that although each Contributor grants the licenses to its -Contributions set forth herein, no assurances are provided by any Contributor -that the Program does not infringe the patent or other intellectual property -rights of any other entity. Each Contributor disclaims any liability to Recipient -for claims brought by any other entity based on infringement of intellectual -property rights or otherwise. As a condition to exercising the rights and -licenses granted hereunder, each Recipient hereby assumes sole responsibility -to secure any other intellectual property rights needed, if any. For example, -if a third party patent license is required to allow Recipient to distribute -the Program, it is Recipient's responsibility to acquire that license before -distributing the Program.

      - -

      d) -Each Contributor represents that to its knowledge it has sufficient copyright -rights in its Contribution, if any, to grant the copyright license set forth in -this Agreement.

      - -

      3. REQUIREMENTS

      - -

      A Contributor may choose to distribute the -Program in object code form under its own license agreement, provided that: -

      - -

      a) -it complies with the terms and conditions of this Agreement; and

      - -

      b) -its license agreement:

      - -

      i) -effectively disclaims on behalf of all Contributors all warranties and -conditions, express and implied, including warranties or conditions of title -and non-infringement, and implied warranties or conditions of merchantability -and fitness for a particular purpose;

      - -

      ii) -effectively excludes on behalf of all Contributors all liability for damages, -including direct, indirect, special, incidental and consequential damages, such -as lost profits;

      - -

      iii) -states that any provisions which differ from this Agreement are offered by that -Contributor alone and not by any other party; and

      - -

      iv) -states that source code for the Program is available from such Contributor, and -informs licensees how to obtain it in a reasonable manner on or through a -medium customarily used for software exchange.

      - -

      When the Program is made available in source -code form:

      - -

      a) -it must be made available under this Agreement; and

      - -

      b) a -copy of this Agreement must be included with each copy of the Program.

      - -

      Contributors may not remove or alter any -copyright notices contained within the Program.

      - -

      Each Contributor must identify itself as the -originator of its Contribution, if any, in a manner that reasonably allows -subsequent Recipients to identify the originator of the Contribution.

      - -

      4. COMMERCIAL DISTRIBUTION

      - -

      Commercial distributors of software may -accept certain responsibilities with respect to end users, business partners -and the like. While this license is intended to facilitate the commercial use -of the Program, the Contributor who includes the Program in a commercial -product offering should do so in a manner which does not create potential -liability for other Contributors. Therefore, if a Contributor includes the -Program in a commercial product offering, such Contributor ("Commercial -Contributor") hereby agrees to defend and indemnify every other -Contributor ("Indemnified Contributor") against any losses, damages and -costs (collectively "Losses") arising from claims, lawsuits and other -legal actions brought by a third party against the Indemnified Contributor to -the extent caused by the acts or omissions of such Commercial Contributor in -connection with its distribution of the Program in a commercial product -offering. The obligations in this section do not apply to any claims or Losses -relating to any actual or alleged intellectual property infringement. In order -to qualify, an Indemnified Contributor must: a) promptly notify the Commercial -Contributor in writing of such claim, and b) allow the Commercial Contributor -to control, and cooperate with the Commercial Contributor in, the defense and -any related settlement negotiations. The Indemnified Contributor may participate -in any such claim at its own expense.

      - -

      For example, a Contributor might include the -Program in a commercial product offering, Product X. That Contributor is then a -Commercial Contributor. If that Commercial Contributor then makes performance -claims, or offers warranties related to Product X, those performance claims and -warranties are such Commercial Contributor's responsibility alone. Under this -section, the Commercial Contributor would have to defend claims against the -other Contributors related to those performance claims and warranties, and if a -court requires any other Contributor to pay any damages as a result, the -Commercial Contributor must pay those damages.

      - -

      5. NO WARRANTY

      - -

      EXCEPT AS EXPRESSLY SET FORTH IN THIS -AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, -WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, -MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely -responsible for determining the appropriateness of using and distributing the -Program and assumes all risks associated with its exercise of rights under this -Agreement , including but not limited to the risks and costs of program errors, -compliance with applicable laws, damage to or loss of data, programs or -equipment, and unavailability or interruption of operations.

      - -

      6. DISCLAIMER OF LIABILITY

      - -

      EXCEPT AS EXPRESSLY SET FORTH IN THIS -AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY -OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF -THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF -THE POSSIBILITY OF SUCH DAMAGES.

      - -

      7. GENERAL

      - -

      If any provision of this Agreement is invalid -or unenforceable under applicable law, it shall not affect the validity or -enforceability of the remainder of the terms of this Agreement, and without -further action by the parties hereto, such provision shall be reformed to the -minimum extent necessary to make such provision valid and enforceable.

      - -

      If Recipient institutes patent litigation -against any entity (including a cross-claim or counterclaim in a lawsuit) -alleging that the Program itself (excluding combinations of the Program with -other software or hardware) infringes such Recipient's patent(s), then such -Recipient's rights granted under Section 2(b) shall terminate as of the date -such litigation is filed.

      - -

      All Recipient's rights under this Agreement -shall terminate if it fails to comply with any of the material terms or -conditions of this Agreement and does not cure such failure in a reasonable -period of time after becoming aware of such noncompliance. If all Recipient's -rights under this Agreement terminate, Recipient agrees to cease use and -distribution of the Program as soon as reasonably practicable. However, -Recipient's obligations under this Agreement and any licenses granted by -Recipient relating to the Program shall continue and survive.

      - -

      Everyone is permitted to copy and distribute -copies of this Agreement, but in order to avoid inconsistency the Agreement is -copyrighted and may only be modified in the following manner. The Agreement -Steward reserves the right to publish new versions (including revisions) of -this Agreement from time to time. No one other than the Agreement Steward has -the right to modify this Agreement. The Eclipse Foundation is the initial -Agreement Steward. The Eclipse Foundation may assign the responsibility to -serve as the Agreement Steward to a suitable separate entity. Each new version -of the Agreement will be given a distinguishing version number. The Program -(including Contributions) may always be distributed subject to the version of -the Agreement under which it was received. In addition, after a new version of -the Agreement is published, Contributor may elect to distribute the Program -(including its Contributions) under the new version. Except as expressly stated -in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to -the intellectual property of any Contributor under this Agreement, whether -expressly, by implication, estoppel or otherwise. All rights in the Program not -expressly granted under this Agreement are reserved.

      - -

      This Agreement is governed by the laws of the -State of New York and the intellectual property laws of the United States of -America. No party to this Agreement will bring a legal action under this -Agreement more than one year after the cause of action arose. Each party waives -its rights to a jury trial in any resulting litigation.

      - -

       

      - -
      - - - + + + + + + + + +Eclipse Public License - Version 1.0 + + + + + + +
      + +

      Eclipse Public License - v 1.0 +

      + +

      THE ACCOMPANYING PROGRAM IS PROVIDED UNDER +THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, +REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE +OF THIS AGREEMENT.

      + +

      1. DEFINITIONS

      + +

      "Contribution" means:

      + +

      a) +in the case of the initial Contributor, the initial code and documentation +distributed under this Agreement, and
      +b) in the case of each subsequent Contributor:

      + +

      i) +changes to the Program, and

      + +

      ii) +additions to the Program;

      + +

      where +such changes and/or additions to the Program originate from and are distributed +by that particular Contributor. A Contribution 'originates' from a Contributor +if it was added to the Program by such Contributor itself or anyone acting on +such Contributor's behalf. Contributions do not include additions to the +Program which: (i) are separate modules of software distributed in conjunction +with the Program under their own license agreement, and (ii) are not derivative +works of the Program.

      + +

      "Contributor" means any person or +entity that distributes the Program.

      + +

      "Licensed Patents " mean patent +claims licensable by a Contributor which are necessarily infringed by the use +or sale of its Contribution alone or when combined with the Program.

      + +

      "Program" means the Contributions +distributed in accordance with this Agreement.

      + +

      "Recipient" means anyone who +receives the Program under this Agreement, including all Contributors.

      + +

      2. GRANT OF RIGHTS

      + +

      a) +Subject to the terms of this Agreement, each Contributor hereby grants Recipient +a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly +display, publicly perform, distribute and sublicense the Contribution of such +Contributor, if any, and such derivative works, in source code and object code +form.

      + +

      b) +Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide, royalty-free +patent license under Licensed Patents to make, use, sell, offer to sell, import +and otherwise transfer the Contribution of such Contributor, if any, in source +code and object code form. This patent license shall apply to the combination +of the Contribution and the Program if, at the time the Contribution is added +by the Contributor, such addition of the Contribution causes such combination +to be covered by the Licensed Patents. The patent license shall not apply to +any other combinations which include the Contribution. No hardware per se is +licensed hereunder.

      + +

      c) +Recipient understands that although each Contributor grants the licenses to its +Contributions set forth herein, no assurances are provided by any Contributor +that the Program does not infringe the patent or other intellectual property +rights of any other entity. Each Contributor disclaims any liability to Recipient +for claims brought by any other entity based on infringement of intellectual +property rights or otherwise. As a condition to exercising the rights and +licenses granted hereunder, each Recipient hereby assumes sole responsibility +to secure any other intellectual property rights needed, if any. For example, +if a third party patent license is required to allow Recipient to distribute +the Program, it is Recipient's responsibility to acquire that license before +distributing the Program.

      + +

      d) +Each Contributor represents that to its knowledge it has sufficient copyright +rights in its Contribution, if any, to grant the copyright license set forth in +this Agreement.

      + +

      3. REQUIREMENTS

      + +

      A Contributor may choose to distribute the +Program in object code form under its own license agreement, provided that: +

      + +

      a) +it complies with the terms and conditions of this Agreement; and

      + +

      b) +its license agreement:

      + +

      i) +effectively disclaims on behalf of all Contributors all warranties and +conditions, express and implied, including warranties or conditions of title +and non-infringement, and implied warranties or conditions of merchantability +and fitness for a particular purpose;

      + +

      ii) +effectively excludes on behalf of all Contributors all liability for damages, +including direct, indirect, special, incidental and consequential damages, such +as lost profits;

      + +

      iii) +states that any provisions which differ from this Agreement are offered by that +Contributor alone and not by any other party; and

      + +

      iv) +states that source code for the Program is available from such Contributor, and +informs licensees how to obtain it in a reasonable manner on or through a +medium customarily used for software exchange.

      + +

      When the Program is made available in source +code form:

      + +

      a) +it must be made available under this Agreement; and

      + +

      b) a +copy of this Agreement must be included with each copy of the Program.

      + +

      Contributors may not remove or alter any +copyright notices contained within the Program.

      + +

      Each Contributor must identify itself as the +originator of its Contribution, if any, in a manner that reasonably allows +subsequent Recipients to identify the originator of the Contribution.

      + +

      4. COMMERCIAL DISTRIBUTION

      + +

      Commercial distributors of software may +accept certain responsibilities with respect to end users, business partners +and the like. While this license is intended to facilitate the commercial use +of the Program, the Contributor who includes the Program in a commercial +product offering should do so in a manner which does not create potential +liability for other Contributors. Therefore, if a Contributor includes the +Program in a commercial product offering, such Contributor ("Commercial +Contributor") hereby agrees to defend and indemnify every other +Contributor ("Indemnified Contributor") against any losses, damages and +costs (collectively "Losses") arising from claims, lawsuits and other +legal actions brought by a third party against the Indemnified Contributor to +the extent caused by the acts or omissions of such Commercial Contributor in +connection with its distribution of the Program in a commercial product +offering. The obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. In order +to qualify, an Indemnified Contributor must: a) promptly notify the Commercial +Contributor in writing of such claim, and b) allow the Commercial Contributor +to control, and cooperate with the Commercial Contributor in, the defense and +any related settlement negotiations. The Indemnified Contributor may participate +in any such claim at its own expense.

      + +

      For example, a Contributor might include the +Program in a commercial product offering, Product X. That Contributor is then a +Commercial Contributor. If that Commercial Contributor then makes performance +claims, or offers warranties related to Product X, those performance claims and +warranties are such Commercial Contributor's responsibility alone. Under this +section, the Commercial Contributor would have to defend claims against the +other Contributors related to those performance claims and warranties, and if a +court requires any other Contributor to pay any damages as a result, the +Commercial Contributor must pay those damages.

      + +

      5. NO WARRANTY

      + +

      EXCEPT AS EXPRESSLY SET FORTH IN THIS +AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, +WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, +MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely +responsible for determining the appropriateness of using and distributing the +Program and assumes all risks associated with its exercise of rights under this +Agreement , including but not limited to the risks and costs of program errors, +compliance with applicable laws, damage to or loss of data, programs or +equipment, and unavailability or interruption of operations.

      + +

      6. DISCLAIMER OF LIABILITY

      + +

      EXCEPT AS EXPRESSLY SET FORTH IN THIS +AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF +THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGES.

      + +

      7. GENERAL

      + +

      If any provision of this Agreement is invalid +or unenforceable under applicable law, it shall not affect the validity or +enforceability of the remainder of the terms of this Agreement, and without +further action by the parties hereto, such provision shall be reformed to the +minimum extent necessary to make such provision valid and enforceable.

      + +

      If Recipient institutes patent litigation +against any entity (including a cross-claim or counterclaim in a lawsuit) +alleging that the Program itself (excluding combinations of the Program with +other software or hardware) infringes such Recipient's patent(s), then such +Recipient's rights granted under Section 2(b) shall terminate as of the date +such litigation is filed.

      + +

      All Recipient's rights under this Agreement +shall terminate if it fails to comply with any of the material terms or +conditions of this Agreement and does not cure such failure in a reasonable +period of time after becoming aware of such noncompliance. If all Recipient's +rights under this Agreement terminate, Recipient agrees to cease use and +distribution of the Program as soon as reasonably practicable. However, +Recipient's obligations under this Agreement and any licenses granted by +Recipient relating to the Program shall continue and survive.

      + +

      Everyone is permitted to copy and distribute +copies of this Agreement, but in order to avoid inconsistency the Agreement is +copyrighted and may only be modified in the following manner. The Agreement +Steward reserves the right to publish new versions (including revisions) of +this Agreement from time to time. No one other than the Agreement Steward has +the right to modify this Agreement. The Eclipse Foundation is the initial +Agreement Steward. The Eclipse Foundation may assign the responsibility to +serve as the Agreement Steward to a suitable separate entity. Each new version +of the Agreement will be given a distinguishing version number. The Program +(including Contributions) may always be distributed subject to the version of +the Agreement under which it was received. In addition, after a new version of +the Agreement is published, Contributor may elect to distribute the Program +(including its Contributions) under the new version. Except as expressly stated +in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to +the intellectual property of any Contributor under this Agreement, whether +expressly, by implication, estoppel or otherwise. All rights in the Program not +expressly granted under this Agreement are reserved.

      + +

      This Agreement is governed by the laws of the +State of New York and the intellectual property laws of the United States of +America. No party to this Agreement will bring a legal action under this +Agreement more than one year after the cause of action arose. Each party waives +its rights to a jury trial in any resulting litigation.

      + +

       

      + +
      + + + \ No newline at end of file diff --git a/org.sf.feeling.decompiler.vineflower.feature/feature.properties b/org.sf.feeling.decompiler.vineflower.feature/feature.properties new file mode 100644 index 00000000..a11e8c93 --- /dev/null +++ b/org.sf.feeling.decompiler.vineflower.feature/feature.properties @@ -0,0 +1,720 @@ +############################################################################### +# Copyright (c) 2017 Chen Chao and other ECD project contributors. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# https://www.eclipse.org/legal/epl-v10.html +############################################################################### + +# feature.properties +# contains externalized strings for feature.xml +# "%foo" in feature.xml corresponds to the key "foo" in this file +# java.io.Properties file (ISO 8859-1 with "\" escapes) +# This file should be translated. + +# "featureName" property - name of the feature +featureName=Enhanced Class Decompiler Vineflower Extension (Optional) + +# "providerName" property - name of the company that provides the feature +providerName=ECD project contributors + +# "updateSiteName" property - label for the update site +updateSiteName=Enhanced Class Decompiler Updates + +# "description" property - description of the feature +description=Enhanced Class Decompiler integrates JD, FernFlower, Vineflower, CFR, Procyon with Eclipse seamlessly. \ +It allows Java developers to debug class files without source code directly. + +copyrightURL=https://ecd-plugin.github.io + +copyright=(c) Copyright 2023 Chen Chao and other ECD project contributors. All rights reserved.\n + +# "licenseURL" property - URL of the "Feature License" +# do not translate value - just change to point to a locale-specific HTML page +licenseURL=license.html + +# "aboutURL" property - URL of the "About and Change log" +# do not translate value - just change to point to a locale-specific HTML page +aboutURL=about.html + +# "license" property - text of the "Feature Update License" +# should be plain text version of license agreement pointed to be "licenseURL" +license=\ + GNU GENERAL PUBLIC LICENSE\n\ +\n\ + Version 3, 29 June 2007\n\ +\n\ + Copyright (C) 2007 Free Software Foundation, Inc. \n\ + Everyone is permitted to copy and distribute verbatim copies\n\ + of this license document, but changing it is not allowed.\n\ +\n\ + Preamble\n\ +\n\ + The GNU General Public License is a free, copyleft license for\n\ +software and other kinds of works.\n\ +\n\ + The licenses for most software and other practical works are designed\n\ +to take away your freedom to share and change the works. By contrast,\n\ +the GNU General Public License is intended to guarantee your freedom to\n\ +share and change all versions of a program--to make sure it remains free\n\ +software for all its users. We, the Free Software Foundation, use the\n\ +GNU General Public License for most of our software; it applies also to\n\ +any other work released this way by its authors. You can apply it to\n\ +your programs, too.\n\ +\n\ + When we speak of free software, we are referring to freedom, not\n\ +price. Our General Public Licenses are designed to make sure that you\n\ +have the freedom to distribute copies of free software (and charge for\n\ +them if you wish), that you receive source code or can get it if you\n\ +want it, that you can change the software or use pieces of it in new\n\ +free programs, and that you know you can do these things.\n\ +\n\ + To protect your rights, we need to prevent others from denying you\n\ +these rights or asking you to surrender the rights. Therefore, you have\n\ +certain responsibilities if you distribute copies of the software, or if\n\ +you modify it: responsibilities to respect the freedom of others.\n\ +\n\ + For example, if you distribute copies of such a program, whether\n\ +gratis or for a fee, you must pass on to the recipients the same\n\ +freedoms that you received. You must make sure that they, too, receive\n\ +or can get the source code. And you must show them these terms so they\n\ +know their rights.\n\ +\n\ + Developers that use the GNU GPL protect your rights with two steps:\n\ +(1) assert copyright on the software, and (2) offer you this License\n\ +giving you legal permission to copy, distribute and/or modify it.\n\ +\n\ + For the developers' and authors' protection, the GPL clearly explains\n\ +that there is no warranty for this free software. For both users' and\n\ +authors' sake, the GPL requires that modified versions be marked as\n\ +changed, so that their problems will not be attributed erroneously to\n\ +authors of previous versions.\n\ +\n\ + Some devices are designed to deny users access to install or run\n\ +modified versions of the software inside them, although the manufacturer\n\ +can do so. This is fundamentally incompatible with the aim of\n\ +protecting users' freedom to change the software. The systematic\n\ +pattern of such abuse occurs in the area of products for individuals to\n\ +use, which is precisely where it is most unacceptable. Therefore, we\n\ +have designed this version of the GPL to prohibit the practice for those\n\ +products. If such problems arise substantially in other domains, we\n\ +stand ready to extend this provision to those domains in future versions\n\ +of the GPL, as needed to protect the freedom of users.\n\ +\n\ + Finally, every program is threatened constantly by software patents.\n\ +States should not allow patents to restrict development and use of\n\ +software on general-purpose computers, but in those that do, we wish to\n\ +avoid the special danger that patents applied to a free program could\n\ +make it effectively proprietary. To prevent this, the GPL assures that\n\ +patents cannot be used to render the program non-free.\n\ +\n\ + The precise terms and conditions for copying, distribution and\n\ +modification follow.\n\ +\n\ + TERMS AND CONDITIONS\n\ +\n\ + 0. Definitions.\n\ +\n\ + "This License" refers to version 3 of the GNU General Public License.\n\ +\n\ + "Copyright" also means copyright-like laws that apply to other kinds of\n\ +works, such as semiconductor masks.\n\ +\n\ + "The Program" refers to any copyrightable work licensed under this\n\ +License. Each licensee is addressed as "you". "Licensees" and\n\ +"recipients" may be individuals or organizations.\n\ +\n\ + To "modify" a work means to copy from or adapt all or part of the work\n\ +in a fashion requiring copyright permission, other than the making of an\n\ +exact copy. The resulting work is called a "modified version" of the\n\ +earlier work or a work "based on" the earlier work.\n\ +\n\ + A "covered work" means either the unmodified Program or a work based\n\ +on the Program.\n\ +\n\ + To "propagate" a work means to do anything with it that, without\n\ +permission, would make you directly or secondarily liable for\n\ +infringement under applicable copyright law, except executing it on a\n\ +computer or modifying a private copy. Propagation includes copying,\n\ +distribution (with or without modification), making available to the\n\ +public, and in some countries other activities as well.\n\ +\n\ + To "convey" a work means any kind of propagation that enables other\n\ +parties to make or receive copies. Mere interaction with a user through\n\ +a computer network, with no transfer of a copy, is not conveying.\n\ +\n\ + An interactive user interface displays "Appropriate Legal Notices"\n\ +to the extent that it includes a convenient and prominently visible\n\ +feature that (1) displays an appropriate copyright notice, and (2)\n\ +tells the user that there is no warranty for the work (except to the\n\ +extent that warranties are provided), that licensees may convey the\n\ +work under this License, and how to view a copy of this License. If\n\ +the interface presents a list of user commands or options, such as a\n\ +menu, a prominent item in the list meets this criterion.\n\ +\n\ + 1. Source Code.\n\ +\n\ + The "source code" for a work means the preferred form of the work\n\ +for making modifications to it. "Object code" means any non-source\n\ +form of a work.\n\ +\n\ + A "Standard Interface" means an interface that either is an official\n\ +standard defined by a recognized standards body, or, in the case of\n\ +interfaces specified for a particular programming language, one that\n\ +is widely used among developers working in that language.\n\ +\n\ + The "System Libraries" of an executable work include anything, other\n\ +than the work as a whole, that (a) is included in the normal form of\n\ +packaging a Major Component, but which is not part of that Major\n\ +Component, and (b) serves only to enable use of the work with that\n\ +Major Component, or to implement a Standard Interface for which an\n\ +implementation is available to the public in source code form. A\n\ +"Major Component", in this context, means a major essential component\n\ +(kernel, window system, and so on) of the specific operating system\n\ +(if any) on which the executable work runs, or a compiler used to\n\ +produce the work, or an object code interpreter used to run it.\n\ +\n\ + The "Corresponding Source" for a work in object code form means all\n\ +the source code needed to generate, install, and (for an executable\n\ +work) run the object code and to modify the work, including scripts to\n\ +control those activities. However, it does not include the work's\n\ +System Libraries, or general-purpose tools or generally available free\n\ +programs which are used unmodified in performing those activities but\n\ +which are not part of the work. For example, Corresponding Source\n\ +includes interface definition files associated with source files for\n\ +the work, and the source code for shared libraries and dynamically\n\ +linked subprograms that the work is specifically designed to require,\n\ +such as by intimate data communication or control flow between those\n\ +subprograms and other parts of the work.\n\ +\n\ + The Corresponding Source need not include anything that users\n\ +can regenerate automatically from other parts of the Corresponding\n\ +Source.\n\ +\n\ + The Corresponding Source for a work in source code form is that\n\ +same work.\n\ +\n\ + 2. Basic Permissions.\n\ +\n\ + All rights granted under this License are granted for the term of\n\ +copyright on the Program, and are irrevocable provided the stated\n\ +conditions are met. This License explicitly affirms your unlimited\n\ +permission to run the unmodified Program. The output from running a\n\ +covered work is covered by this License only if the output, given its\n\ +content, constitutes a covered work. This License acknowledges your\n\ +rights of fair use or other equivalent, as provided by copyright law.\n\ +\n\ + You may make, run and propagate covered works that you do not\n\ +convey, without conditions so long as your license otherwise remains\n\ +in force. You may convey covered works to others for the sole purpose\n\ +of having them make modifications exclusively for you, or provide you\n\ +with facilities for running those works, provided that you comply with\n\ +the terms of this License in conveying all material for which you do\n\ +not control copyright. Those thus making or running the covered works\n\ +for you must do so exclusively on your behalf, under your direction\n\ +and control, on terms that prohibit them from making any copies of\n\ +your copyrighted material outside their relationship with you.\n\ +\n\ + Conveying under any other circumstances is permitted solely under\n\ +the conditions stated below. Sublicensing is not allowed; section 10\n\ +makes it unnecessary.\n\ +\n\ + 3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\ +\n\ + No covered work shall be deemed part of an effective technological\n\ +measure under any applicable law fulfilling obligations under article\n\ +11 of the WIPO copyright treaty adopted on 20 December 1996, or\n\ +similar laws prohibiting or restricting circumvention of such\n\ +measures.\n\ +\n\ + When you convey a covered work, you waive any legal power to forbid\n\ +circumvention of technological measures to the extent such circumvention\n\ +is effected by exercising rights under this License with respect to\n\ +the covered work, and you disclaim any intention to limit operation or\n\ +modification of the work as a means of enforcing, against the work's\n\ +users, your or third parties' legal rights to forbid circumvention of\n\ +technological measures.\n\ +\n\ + 4. Conveying Verbatim Copies.\n\ +\n\ + You may convey verbatim copies of the Program's source code as you\n\ +receive it, in any medium, provided that you conspicuously and\n\ +appropriately publish on each copy an appropriate copyright notice;\n\ +keep intact all notices stating that this License and any\n\ +non-permissive terms added in accord with section 7 apply to the code;\n\ +keep intact all notices of the absence of any warranty; and give all\n\ +recipients a copy of this License along with the Program.\n\ +\n\ + You may charge any price or no price for each copy that you convey,\n\ +and you may offer support or warranty protection for a fee.\n\ +\n\ + 5. Conveying Modified Source Versions.\n\ +\n\ + You may convey a work based on the Program, or the modifications to\n\ +produce it from the Program, in the form of source code under the\n\ +terms of section 4, provided that you also meet all of these conditions:\n\ +\n\ + a) The work must carry prominent notices stating that you modified\n\ + it, and giving a relevant date.\n\ +\n\ + b) The work must carry prominent notices stating that it is\n\ + released under this License and any conditions added under section\n\ + 7. This requirement modifies the requirement in section 4 to\n\ + "keep intact all notices".\n\ +\n\ + c) You must license the entire work, as a whole, under this\n\ + License to anyone who comes into possession of a copy. This\n\ + License will therefore apply, along with any applicable section 7\n\ + additional terms, to the whole of the work, and all its parts,\n\ + regardless of how they are packaged. This License gives no\n\ + permission to license the work in any other way, but it does not\n\ + invalidate such permission if you have separately received it.\n\ +\n\ + d) If the work has interactive user interfaces, each must display\n\ + Appropriate Legal Notices; however, if the Program has interactive\n\ + interfaces that do not display Appropriate Legal Notices, your\n\ + work need not make them do so.\n\ +\n\ + A compilation of a covered work with other separate and independent\n\ +works, which are not by their nature extensions of the covered work,\n\ +and which are not combined with it such as to form a larger program,\n\ +in or on a volume of a storage or distribution medium, is called an\n\ +"aggregate" if the compilation and its resulting copyright are not\n\ +used to limit the access or legal rights of the compilation's users\n\ +beyond what the individual works permit. Inclusion of a covered work\n\ +in an aggregate does not cause this License to apply to the other\n\ +parts of the aggregate.\n\ +\n\ + 6. Conveying Non-Source Forms.\n\ +\n\ + You may convey a covered work in object code form under the terms\n\ +of sections 4 and 5, provided that you also convey the\n\ +machine-readable Corresponding Source under the terms of this License,\n\ +in one of these ways:\n\ +\n\ + a) Convey the object code in, or embodied in, a physical product\n\ + (including a physical distribution medium), accompanied by the\n\ + Corresponding Source fixed on a durable physical medium\n\ + customarily used for software interchange.\n\ +\n\ + b) Convey the object code in, or embodied in, a physical product\n\ + (including a physical distribution medium), accompanied by a\n\ + written offer, valid for at least three years and valid for as\n\ + long as you offer spare parts or customer support for that product\n\ + model, to give anyone who possesses the object code either (1) a\n\ + copy of the Corresponding Source for all the software in the\n\ + product that is covered by this License, on a durable physical\n\ + medium customarily used for software interchange, for a price no\n\ + more than your reasonable cost of physically performing this\n\ + conveying of source, or (2) access to copy the\n\ + Corresponding Source from a network server at no charge.\n\ +\n\ + c) Convey individual copies of the object code with a copy of the\n\ + written offer to provide the Corresponding Source. This\n\ + alternative is allowed only occasionally and noncommercially, and\n\ + only if you received the object code with such an offer, in accord\n\ + with subsection 6b.\n\ +\n\ + d) Convey the object code by offering access from a designated\n\ + place (gratis or for a charge), and offer equivalent access to the\n\ + Corresponding Source in the same way through the same place at no\n\ + further charge. You need not require recipients to copy the\n\ + Corresponding Source along with the object code. If the place to\n\ + copy the object code is a network server, the Corresponding Source\n\ + may be on a different server (operated by you or a third party)\n\ + that supports equivalent copying facilities, provided you maintain\n\ + clear directions next to the object code saying where to find the\n\ + Corresponding Source. Regardless of what server hosts the\n\ + Corresponding Source, you remain obligated to ensure that it is\n\ + available for as long as needed to satisfy these requirements.\n\ +\n\ + e) Convey the object code using peer-to-peer transmission, provided\n\ + you inform other peers where the object code and Corresponding\n\ + Source of the work are being offered to the general public at no\n\ + charge under subsection 6d.\n\ +\n\ + A separable portion of the object code, whose source code is excluded\n\ +from the Corresponding Source as a System Library, need not be\n\ +included in conveying the object code work.\n\ +\n\ + A "User Product" is either (1) a "consumer product", which means any\n\ +tangible personal property which is normally used for personal, family,\n\ +or household purposes, or (2) anything designed or sold for incorporation\n\ +into a dwelling. In determining whether a product is a consumer product,\n\ +doubtful cases shall be resolved in favor of coverage. For a particular\n\ +product received by a particular user, "normally used" refers to a\n\ +typical or common use of that class of product, regardless of the status\n\ +of the particular user or of the way in which the particular user\n\ +actually uses, or expects or is expected to use, the product. A product\n\ +is a consumer product regardless of whether the product has substantial\n\ +commercial, industrial or non-consumer uses, unless such uses represent\n\ +the only significant mode of use of the product.\n\ +\n\ + "Installation Information" for a User Product means any methods,\n\ +procedures, authorization keys, or other information required to install\n\ +and execute modified versions of a covered work in that User Product from\n\ +a modified version of its Corresponding Source. The information must\n\ +suffice to ensure that the continued functioning of the modified object\n\ +code is in no case prevented or interfered with solely because\n\ +modification has been made.\n\ +\n\ + If you convey an object code work under this section in, or with, or\n\ +specifically for use in, a User Product, and the conveying occurs as\n\ +part of a transaction in which the right of possession and use of the\n\ +User Product is transferred to the recipient in perpetuity or for a\n\ +fixed term (regardless of how the transaction is characterized), the\n\ +Corresponding Source conveyed under this section must be accompanied\n\ +by the Installation Information. But this requirement does not apply\n\ +if neither you nor any third party retains the ability to install\n\ +modified object code on the User Product (for example, the work has\n\ +been installed in ROM).\n\ +\n\ + The requirement to provide Installation Information does not include a\n\ +requirement to continue to provide support service, warranty, or updates\n\ +for a work that has been modified or installed by the recipient, or for\n\ +the User Product in which it has been modified or installed. Access to a\n\ +network may be denied when the modification itself materially and\n\ +adversely affects the operation of the network or violates the rules and\n\ +protocols for communication across the network.\n\ +\n\ + Corresponding Source conveyed, and Installation Information provided,\n\ +in accord with this section must be in a format that is publicly\n\ +documented (and with an implementation available to the public in\n\ +source code form), and must require no special password or key for\n\ +unpacking, reading or copying.\n\ +\n\ + 7. Additional Terms.\n\ +\n\ + "Additional permissions" are terms that supplement the terms of this\n\ +License by making exceptions from one or more of its conditions.\n\ +Additional permissions that are applicable to the entire Program shall\n\ +be treated as though they were included in this License, to the extent\n\ +that they are valid under applicable law. If additional permissions\n\ +apply only to part of the Program, that part may be used separately\n\ +under those permissions, but the entire Program remains governed by\n\ +this License without regard to the additional permissions.\n\ +\n\ + When you convey a copy of a covered work, you may at your option\n\ +remove any additional permissions from that copy, or from any part of\n\ +it. (Additional permissions may be written to require their own\n\ +removal in certain cases when you modify the work.) You may place\n\ +additional permissions on material, added by you to a covered work,\n\ +for which you have or can give appropriate copyright permission.\n\ +\n\ + Notwithstanding any other provision of this License, for material you\n\ +add to a covered work, you may (if authorized by the copyright holders of\n\ +that material) supplement the terms of this License with terms:\n\ +\n\ + a) Disclaiming warranty or limiting liability differently from the\n\ + terms of sections 15 and 16 of this License; or\n\ +\n\ + b) Requiring preservation of specified reasonable legal notices or\n\ + author attributions in that material or in the Appropriate Legal\n\ + Notices displayed by works containing it; or\n\ +\n\ + c) Prohibiting misrepresentation of the origin of that material, or\n\ + requiring that modified versions of such material be marked in\n\ + reasonable ways as different from the original version; or\n\ +\n\ + d) Limiting the use for publicity purposes of names of licensors or\n\ + authors of the material; or\n\ +\n\ + e) Declining to grant rights under trademark law for use of some\n\ + trade names, trademarks, or service marks; or\n\ +\n\ + f) Requiring indemnification of licensors and authors of that\n\ + material by anyone who conveys the material (or modified versions of\n\ + it) with contractual assumptions of liability to the recipient, for\n\ + any liability that these contractual assumptions directly impose on\n\ + those licensors and authors.\n\ +\n\ + All other non-permissive additional terms are considered "further\n\ +restrictions" within the meaning of section 10. If the Program as you\n\ +received it, or any part of it, contains a notice stating that it is\n\ +governed by this License along with a term that is a further\n\ +restriction, you may remove that term. If a license document contains\n\ +a further restriction but permits relicensing or conveying under this\n\ +License, you may add to a covered work material governed by the terms\n\ +of that license document, provided that the further restriction does\n\ +not survive such relicensing or conveying.\n\ +\n\ + If you add terms to a covered work in accord with this section, you\n\ +must place, in the relevant source files, a statement of the\n\ +additional terms that apply to those files, or a notice indicating\n\ +where to find the applicable terms.\n\ +\n\ + Additional terms, permissive or non-permissive, may be stated in the\n\ +form of a separately written license, or stated as exceptions;\n\ +the above requirements apply either way.\n\ +\n\ + 8. Termination.\n\ +\n\ + You may not propagate or modify a covered work except as expressly\n\ +provided under this License. Any attempt otherwise to propagate or\n\ +modify it is void, and will automatically terminate your rights under\n\ +this License (including any patent licenses granted under the third\n\ +paragraph of section 11).\n\ +\n\ + However, if you cease all violation of this License, then your\n\ +license from a particular copyright holder is reinstated (a)\n\ +provisionally, unless and until the copyright holder explicitly and\n\ +finally terminates your license, and (b) permanently, if the copyright\n\ +holder fails to notify you of the violation by some reasonable means\n\ +prior to 60 days after the cessation.\n\ +\n\ + Moreover, your license from a particular copyright holder is\n\ +reinstated permanently if the copyright holder notifies you of the\n\ +violation by some reasonable means, this is the first time you have\n\ +received notice of violation of this License (for any work) from that\n\ +copyright holder, and you cure the violation prior to 30 days after\n\ +your receipt of the notice.\n\ +\n\ + Termination of your rights under this section does not terminate the\n\ +licenses of parties who have received copies or rights from you under\n\ +this License. If your rights have been terminated and not permanently\n\ +reinstated, you do not qualify to receive new licenses for the same\n\ +material under section 10.\n\ +\n\ + 9. Acceptance Not Required for Having Copies.\n\ +\n\ + You are not required to accept this License in order to receive or\n\ +run a copy of the Program. Ancillary propagation of a covered work\n\ +occurring solely as a consequence of using peer-to-peer transmission\n\ +to receive a copy likewise does not require acceptance. However,\n\ +nothing other than this License grants you permission to propagate or\n\ +modify any covered work. These actions infringe copyright if you do\n\ +not accept this License. Therefore, by modifying or propagating a\n\ +covered work, you indicate your acceptance of this License to do so.\n\ +\n\ + 10. Automatic Licensing of Downstream Recipients.\n\ +\n\ + Each time you convey a covered work, the recipient automatically\n\ +receives a license from the original licensors, to run, modify and\n\ +propagate that work, subject to this License. You are not responsible\n\ +for enforcing compliance by third parties with this License.\n\ +\n\ + An "entity transaction" is a transaction transferring control of an\n\ +organization, or substantially all assets of one, or subdividing an\n\ +organization, or merging organizations. If propagation of a covered\n\ +work results from an entity transaction, each party to that\n\ +transaction who receives a copy of the work also receives whatever\n\ +licenses to the work the party's predecessor in interest had or could\n\ +give under the previous paragraph, plus a right to possession of the\n\ +Corresponding Source of the work from the predecessor in interest, if\n\ +the predecessor has it or can get it with reasonable efforts.\n\ +\n\ + You may not impose any further restrictions on the exercise of the\n\ +rights granted or affirmed under this License. For example, you may\n\ +not impose a license fee, royalty, or other charge for exercise of\n\ +rights granted under this License, and you may not initiate litigation\n\ +(including a cross-claim or counterclaim in a lawsuit) alleging that\n\ +any patent claim is infringed by making, using, selling, offering for\n\ +sale, or importing the Program or any portion of it.\n\ +\n\ + 11. Patents.\n\ +\n\ + A "contributor" is a copyright holder who authorizes use under this\n\ +License of the Program or a work on which the Program is based. The\n\ +work thus licensed is called the contributor's "contributor version".\n\ +\n\ + A contributor's "essential patent claims" are all patent claims\n\ +owned or controlled by the contributor, whether already acquired or\n\ +hereafter acquired, that would be infringed by some manner, permitted\n\ +by this License, of making, using, or selling its contributor version,\n\ +but do not include claims that would be infringed only as a\n\ +consequence of further modification of the contributor version. For\n\ +purposes of this definition, "control" includes the right to grant\n\ +patent sublicenses in a manner consistent with the requirements of\n\ +this License.\n\ +\n\ + Each contributor grants you a non-exclusive, worldwide, royalty-free\n\ +patent license under the contributor's essential patent claims, to\n\ +make, use, sell, offer for sale, import and otherwise run, modify and\n\ +propagate the contents of its contributor version.\n\ +\n\ + In the following three paragraphs, a "patent license" is any express\n\ +agreement or commitment, however denominated, not to enforce a patent\n\ +(such as an express permission to practice a patent or covenant not to\n\ +sue for patent infringement). To "grant" such a patent license to a\n\ +party means to make such an agreement or commitment not to enforce a\n\ +patent against the party.\n\ +\n\ + If you convey a covered work, knowingly relying on a patent license,\n\ +and the Corresponding Source of the work is not available for anyone\n\ +to copy, free of charge and under the terms of this License, through a\n\ +publicly available network server or other readily accessible means,\n\ +then you must either (1) cause the Corresponding Source to be so\n\ +available, or (2) arrange to deprive yourself of the benefit of the\n\ +patent license for this particular work, or (3) arrange, in a manner\n\ +consistent with the requirements of this License, to extend the patent\n\ +license to downstream recipients. "Knowingly relying" means you have\n\ +actual knowledge that, but for the patent license, your conveying the\n\ +covered work in a country, or your recipient's use of the covered work\n\ +in a country, would infringe one or more identifiable patents in that\n\ +country that you have reason to believe are valid.\n\ +\n\ + If, pursuant to or in connection with a single transaction or\n\ +arrangement, you convey, or propagate by procuring conveyance of, a\n\ +covered work, and grant a patent license to some of the parties\n\ +receiving the covered work authorizing them to use, propagate, modify\n\ +or convey a specific copy of the covered work, then the patent license\n\ +you grant is automatically extended to all recipients of the covered\n\ +work and works based on it.\n\ +\n\ + A patent license is "discriminatory" if it does not include within\n\ +the scope of its coverage, prohibits the exercise of, or is\n\ +conditioned on the non-exercise of one or more of the rights that are\n\ +specifically granted under this License. You may not convey a covered\n\ +work if you are a party to an arrangement with a third party that is\n\ +in the business of distributing software, under which you make payment\n\ +to the third party based on the extent of your activity of conveying\n\ +the work, and under which the third party grants, to any of the\n\ +parties who would receive the covered work from you, a discriminatory\n\ +patent license (a) in connection with copies of the covered work\n\ +conveyed by you (or copies made from those copies), or (b) primarily\n\ +for and in connection with specific products or compilations that\n\ +contain the covered work, unless you entered into that arrangement,\n\ +or that patent license was granted, prior to 28 March 2007.\n\ +\n\ + Nothing in this License shall be construed as excluding or limiting\n\ +any implied license or other defenses to infringement that may\n\ +otherwise be available to you under applicable patent law.\n\ +\n\ + 12. No Surrender of Others' Freedom.\n\ +\n\ + If conditions are imposed on you (whether by court order, agreement or\n\ +otherwise) that contradict the conditions of this License, they do not\n\ +excuse you from the conditions of this License. If you cannot convey a\n\ +covered work so as to satisfy simultaneously your obligations under this\n\ +License and any other pertinent obligations, then as a consequence you may\n\ +not convey it at all. For example, if you agree to terms that obligate you\n\ +to collect a royalty for further conveying from those to whom you convey\n\ +the Program, the only way you could satisfy both those terms and this\n\ +License would be to refrain entirely from conveying the Program.\n\ +\n\ + 13. Use with the GNU Affero General Public License.\n\ +\n\ + Notwithstanding any other provision of this License, you have\n\ +permission to link or combine any covered work with a work licensed\n\ +under version 3 of the GNU Affero General Public License into a single\n\ +combined work, and to convey the resulting work. The terms of this\n\ +License will continue to apply to the part which is the covered work,\n\ +but the special requirements of the GNU Affero General Public License,\n\ +section 13, concerning interaction through a network will apply to the\n\ +combination as such.\n\ +\n\ + 14. Revised Versions of this License.\n\ +\n\ + The Free Software Foundation may publish revised and/or new versions of\n\ +the GNU General Public License from time to time. Such new versions will\n\ +be similar in spirit to the present version, but may differ in detail to\n\ +address new problems or concerns.\n\ +\n\ + Each version is given a distinguishing version number. If the\n\ +Program specifies that a certain numbered version of the GNU General\n\ +Public License "or any later version" applies to it, you have the\n\ +option of following the terms and conditions either of that numbered\n\ +version or of any later version published by the Free Software\n\ +Foundation. If the Program does not specify a version number of the\n\ +GNU General Public License, you may choose any version ever published\n\ +by the Free Software Foundation.\n\ +\n\ + If the Program specifies that a proxy can decide which future\n\ +versions of the GNU General Public License can be used, that proxy's\n\ +public statement of acceptance of a version permanently authorizes you\n\ +to choose that version for the Program.\n\ +\n\ + Later license versions may give you additional or different\n\ +permissions. However, no additional obligations are imposed on any\n\ +author or copyright holder as a result of your choosing to follow a\n\ +later version.\n\ +\n\ + 15. Disclaimer of Warranty.\n\ +\n\ + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\n\ +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\n\ +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY\n\ +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\n\ +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n\ +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\n\ +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\n\ +ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\ +\n\ + 16. Limitation of Liability.\n\ +\n\ + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\n\ +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\n\ +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\n\ +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\n\ +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\n\ +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\n\ +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\n\ +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\n\ +SUCH DAMAGES.\n\ +\n\ + 17. Interpretation of Sections 15 and 16.\n\ +\n\ + If the disclaimer of warranty and limitation of liability provided\n\ +above cannot be given local legal effect according to their terms,\n\ +reviewing courts shall apply local law that most closely approximates\n\ +an absolute waiver of all civil liability in connection with the\n\ +Program, unless a warranty or assumption of liability accompanies a\n\ +copy of the Program in return for a fee.\n\ +\n\ + END OF TERMS AND CONDITIONS\n\ +\n\ + How to Apply These Terms to Your New Programs\n\ +\n\ + If you develop a new program, and you want it to be of the greatest\n\ +possible use to the public, the best way to achieve this is to make it\n\ +free software which everyone can redistribute and change under these terms.\n\ +\n\ + To do so, attach the following notices to the program. It is safest\n\ +to attach them to the start of each source file to most effectively\n\ +state the exclusion of warranty; and each file should have at least\n\ +the "copyright" line and a pointer to where the full notice is found.\n\ +\n\ + JD-Eclipse is a plug-in for the Eclipse platform. It allows you to \n\ + display all the Java sources during your debugging process, even if \n\ + you do not have them all.\n\ + Copyright (C) 2008-2015 Emmanuel Dupuy\n\ +\n\ + This program is free software: you can redistribute it and/or modify\n\ + it under the terms of the GNU General Public License as published by\n\ + the Free Software Foundation, either version 3 of the License, or\n\ + (at your option) any later version.\n\ +\n\ + This program is distributed in the hope that it will be useful,\n\ + but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ + GNU General Public License for more details.\n\ +\n\ + You should have received a copy of the GNU General Public License\n\ + along with this program. If not, see .\n\ +\n\ +Also add information on how to contact you by electronic and paper mail.\n\ +\n\ + If the program does terminal interaction, make it output a short\n\ +notice like this when it starts in an interactive mode:\n\ +\n\ + JD-Eclipse Copyright (C) 2008-2015 Emmanuel Dupuy\n\ + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n\ + This is free software, and you are welcome to redistribute it\n\ + under certain conditions; type `show c' for details.\n\ +\n\ +The hypothetical commands `show w' and `show c' should show the appropriate\n\ +parts of the General Public License. Of course, your program's commands\n\ +might be different; for a GUI interface, you would use an "about box".\n\ +\n\ + You should also get your employer (if you work as a programmer) or school,\n\ +if any, to sign a "copyright disclaimer" for the program, if necessary.\n\ +For more information on this, and how to apply and follow the GNU GPL, see\n\ +.\n\ +\n\ + The GNU General Public License does not permit incorporating your program\n\ +into proprietary programs. If your program is a subroutine library, you\n\ +may consider it more useful to permit linking proprietary applications with\n\ +the library. If this is what you want to do, use the GNU Lesser General\n\ +Public License instead of this License. But first, please read\n\ +.\n +########### end of license property ########################################## diff --git a/org.sf.feeling.decompiler.vineflower.feature/feature.xml b/org.sf.feeling.decompiler.vineflower.feature/feature.xml new file mode 100644 index 00000000..51349a60 --- /dev/null +++ b/org.sf.feeling.decompiler.vineflower.feature/feature.xml @@ -0,0 +1,53 @@ + + + + + %description + + + + %copyright + + + + %license + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/org.sf.feeling.decompiler.vineflower.feature/license.html b/org.sf.feeling.decompiler.vineflower.feature/license.html new file mode 100644 index 00000000..87eb9824 --- /dev/null +++ b/org.sf.feeling.decompiler.vineflower.feature/license.html @@ -0,0 +1,696 @@ + + + + + + GNU General Public License v3.0 - GNU Project - Free Software Foundation (FSF) + + + +

      GNU GENERAL PUBLIC LICENSE

      +

      Version 3, 29 June 2007

      + +

      Copyright © 2007 Free Software Foundation, Inc. + <https://fsf.org/>

      + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed.

      + +

      Preamble

      + +

      The GNU General Public License is a free, copyleft license for +software and other kinds of works.

      + +

      The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too.

      + +

      When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things.

      + +

      To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others.

      + +

      For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights.

      + +

      Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it.

      + +

      For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions.

      + +

      Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users.

      + +

      Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free.

      + +

      The precise terms and conditions for copying, distribution and +modification follow.

      + +

      TERMS AND CONDITIONS

      + +

      0. Definitions.

      + +

      “This License” refers to version 3 of the GNU General Public License.

      + +

      “Copyright” also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks.

      + +

      “The Program” refers to any copyrightable work licensed under this +License. Each licensee is addressed as “you”. “Licensees” and +“recipients” may be individuals or organizations.

      + +

      To “modify” a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a “modified version” of the +earlier work or a work “based on” the earlier work.

      + +

      A “covered work” means either the unmodified Program or a work based +on the Program.

      + +

      To “propagate” a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well.

      + +

      To “convey” a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying.

      + +

      An interactive user interface displays “Appropriate Legal Notices” +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion.

      + +

      1. Source Code.

      + +

      The “source code” for a work means the preferred form of the work +for making modifications to it. “Object code” means any non-source +form of a work.

      + +

      A “Standard Interface” means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language.

      + +

      The “System Libraries” of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +“Major Component”, in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it.

      + +

      The “Corresponding Source” for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work.

      + +

      The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source.

      + +

      The Corresponding Source for a work in source code form is that +same work.

      + +

      2. Basic Permissions.

      + +

      All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law.

      + +

      You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you.

      + +

      Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary.

      + +

      3. Protecting Users' Legal Rights From Anti-Circumvention Law.

      + +

      No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures.

      + +

      When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures.

      + +

      4. Conveying Verbatim Copies.

      + +

      You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program.

      + +

      You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee.

      + +

      5. Conveying Modified Source Versions.

      + +

      You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions:

      + +
        +
      • a) The work must carry prominent notices stating that you modified + it, and giving a relevant date.
      • + +
      • b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + “keep intact all notices”.
      • + +
      • c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it.
      • + +
      • d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so.
      • +
      + +

      A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +“aggregate” if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate.

      + +

      6. Conveying Non-Source Forms.

      + +

      You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways:

      + +
        +
      • a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange.
      • + +
      • b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge.
      • + +
      • c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b.
      • + +
      • d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements.
      • + +
      • e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d.
      • +
      + +

      A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work.

      + +

      A “User Product” is either (1) a “consumer product”, which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, “normally used” refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product.

      + +

      “Installation Information” for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made.

      + +

      If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM).

      + +

      The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network.

      + +

      Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying.

      + +

      7. Additional Terms.

      + +

      “Additional permissions” are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions.

      + +

      When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission.

      + +

      Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms:

      + +
        +
      • a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or
      • + +
      • b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or
      • + +
      • c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or
      • + +
      • d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or
      • + +
      • e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or
      • + +
      • f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors.
      • +
      + +

      All other non-permissive additional terms are considered “further +restrictions” within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying.

      + +

      If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms.

      + +

      Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way.

      + +

      8. Termination.

      + +

      You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11).

      + +

      However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation.

      + +

      Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice.

      + +

      Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10.

      + +

      9. Acceptance Not Required for Having Copies.

      + +

      You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so.

      + +

      10. Automatic Licensing of Downstream Recipients.

      + +

      Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License.

      + +

      An “entity transaction” is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts.

      + +

      You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it.

      + +

      11. Patents.

      + +

      A “contributor” is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's “contributor version”.

      + +

      A contributor's “essential patent claims” are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, “control” includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License.

      + +

      Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version.

      + +

      In the following three paragraphs, a “patent license” is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To “grant” such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party.

      + +

      If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. “Knowingly relying” means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid.

      + +

      If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it.

      + +

      A patent license is “discriminatory” if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007.

      + +

      Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law.

      + +

      12. No Surrender of Others' Freedom.

      + +

      If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program.

      + +

      13. Use with the GNU Affero General Public License.

      + +

      Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such.

      + +

      14. Revised Versions of this License.

      + +

      The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns.

      + +

      Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License “or any later version” applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation.

      + +

      If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program.

      + +

      Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version.

      + +

      15. Disclaimer of Warranty.

      + +

      THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

      + +

      16. Limitation of Liability.

      + +

      IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES.

      + +

      17. Interpretation of Sections 15 and 16.

      + +

      If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee.

      + +

      END OF TERMS AND CONDITIONS

      + +

      How to Apply These Terms to Your New Programs

      + +

      If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +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.

      + +
          <one line to give the program's name and a brief idea of what it does.>
      +    Copyright (C) <year>  <name of author>
      +
      +    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
      +    the Free Software Foundation, either version 3 of the License, or
      +    (at your option) any later version.
      +
      +    This program is distributed in the hope that it will be useful,
      +    but WITHOUT ANY WARRANTY; without even the implied warranty of
      +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      +    GNU General Public License for more details.
      +
      +    You should have received a copy of the GNU General Public License
      +    along with this program.  If not, see <https://www.gnu.org/licenses/>.
      +
      + +

      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:

      + +
          <program>  Copyright (C) <year>  <name of author>
      +    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.
      +
      + +

      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. +For more information on this, and how to apply and follow the GNU GPL, see +<https://www.gnu.org/licenses/>.

      + +

      The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<https://www.gnu.org/licenses/why-not-lgpl.html>.

      + + diff --git a/org.sf.feeling.decompiler.vineflower.feature/pom.xml b/org.sf.feeling.decompiler.vineflower.feature/pom.xml new file mode 100644 index 00000000..3bc85241 --- /dev/null +++ b/org.sf.feeling.decompiler.vineflower.feature/pom.xml @@ -0,0 +1,15 @@ + + 4.0.0 + + + com.github.ecd-plugin + com.github.ecd-plugin.ecd + 3.5.1 + ../pom.xml + + + com.github.ecd-plugin.features + org.sf.feeling.decompiler.vineflower + eclipse-feature + diff --git a/org.sf.feeling.decompiler.jad/.classpath b/org.sf.feeling.decompiler.vineflower/.classpath similarity index 58% rename from org.sf.feeling.decompiler.jad/.classpath rename to org.sf.feeling.decompiler.vineflower/.classpath index 8a8f1668..458b7151 100644 --- a/org.sf.feeling.decompiler.jad/.classpath +++ b/org.sf.feeling.decompiler.vineflower/.classpath @@ -1,7 +1,12 @@ - - - - - - - + + + + + + + + + + + + diff --git a/org.sf.feeling.decompiler.jad/.project b/org.sf.feeling.decompiler.vineflower/.project similarity index 73% rename from org.sf.feeling.decompiler.jad/.project rename to org.sf.feeling.decompiler.vineflower/.project index 0a6d74ce..4f88522e 100644 --- a/org.sf.feeling.decompiler.jad/.project +++ b/org.sf.feeling.decompiler.vineflower/.project @@ -1,28 +1,34 @@ - - - org.sf.feeling.decompiler.jad - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - + + + org.sf.feeling.decompiler.vineflower + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.m2e.core.maven2Nature + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/org.sf.feeling.decompiler.vineflower/.settings/org.eclipse.core.resources.prefs b/org.sf.feeling.decompiler.vineflower/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000..99f26c02 --- /dev/null +++ b/org.sf.feeling.decompiler.vineflower/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/org.sf.feeling.decompiler.vineflower/.settings/org.eclipse.core.runtime.prefs b/org.sf.feeling.decompiler.vineflower/.settings/org.eclipse.core.runtime.prefs new file mode 100644 index 00000000..deae05a9 --- /dev/null +++ b/org.sf.feeling.decompiler.vineflower/.settings/org.eclipse.core.runtime.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +line.separator=\r\n diff --git a/org.sf.feeling.decompiler.vineflower/.settings/org.eclipse.jdt.core.prefs b/org.sf.feeling.decompiler.vineflower/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..4bd042ca --- /dev/null +++ b/org.sf.feeling.decompiler.vineflower/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,466 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 +org.eclipse.jdt.core.compiler.compliance=11 +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=ignore +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore +org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=ignore +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=11 +org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false +org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false +org.eclipse.jdt.core.formatter.align_with_spaces=false +org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_enum_constant=49 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field=49 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable=49 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_method=49 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package=49 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter=0 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type=49 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assertion_message=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain=0 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0 +org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_module_statements=16 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_record_components=16 +org.eclipse.jdt.core.formatter.alignment_for_relational_operator=0 +org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_shift_operator=0 +org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_record_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_type_annotations=0 +org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0 +org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0 +org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_last_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_abstract_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_statement_group_in_switch=0 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_record_constructor=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_record_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped=true +org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false +org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=true +org.eclipse.jdt.core.formatter.comment.format_block_comments=true +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true +org.eclipse.jdt.core.formatter.comment.format_line_comments=true +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=false +org.eclipse.jdt.core.formatter.comment.indent_root_tags=false +org.eclipse.jdt.core.formatter.comment.indent_tag_description=false +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_between_different_tags=do not insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert +org.eclipse.jdt.core.formatter.comment.line_length=80 +org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true +org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true +org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false +org.eclipse.jdt.core.formatter.compact_else_if=true +org.eclipse.jdt.core.formatter.continuation_indentation=2 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 +org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=false +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_record_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false +org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_default=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_record_components=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_switch_case_expressions=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_not_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_record_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert +org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_case=insert +org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_default=insert +org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_record_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_record_components=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_switch_case_expressions=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_constructor=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_record_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=true +org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_code_block_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_method_body_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_record_constructor_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_record_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line=false +org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.lineSplit=120 +org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false +org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false +org.eclipse.jdt.core.formatter.number_of_blank_lines_after_code_block=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_code_block=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_code_block=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_before_code_block=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 +org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_record_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true +org.eclipse.jdt.core.formatter.tabulation.char=tab +org.eclipse.jdt.core.formatter.tabulation.size=4 +org.eclipse.jdt.core.formatter.text_block_indentation=0 +org.eclipse.jdt.core.formatter.use_on_off_tags=true +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true +org.eclipse.jdt.core.formatter.wrap_before_assertion_message_operator=true +org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false +org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true +org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true +org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true +org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true +org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_before_relational_operator=true +org.eclipse.jdt.core.formatter.wrap_before_shift_operator=true +org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true +org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter diff --git a/org.sf.feeling.decompiler.vineflower/.settings/org.eclipse.jdt.ui.prefs b/org.sf.feeling.decompiler.vineflower/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 00000000..9a4e91e5 --- /dev/null +++ b/org.sf.feeling.decompiler.vineflower/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,106 @@ +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +formatter_profile=org.eclipse.jdt.ui.default.eclipse_profile +formatter_settings_version=20 +sp_cleanup.add_all=false +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.arrays_fill=false +sp_cleanup.bitwise_conditional_expression=false +sp_cleanup.boolean_literal=false +sp_cleanup.break_loop=false +sp_cleanup.collection_cloning=false +sp_cleanup.comparison_statement=false +sp_cleanup.convert_functional_interfaces=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.convert_to_enhanced_for_loop_if_loop_var_used=false +sp_cleanup.convert_to_switch_expressions=false +sp_cleanup.correct_indentation=false +sp_cleanup.double_negation=false +sp_cleanup.else_if=false +sp_cleanup.embedded_if=false +sp_cleanup.evaluate_nullable=false +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=false +sp_cleanup.hash=false +sp_cleanup.if_condition=false +sp_cleanup.insert_inferred_type_arguments=false +sp_cleanup.instanceof=false +sp_cleanup.join=false +sp_cleanup.lazy_logical_operator=false +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=true +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=false +sp_cleanup.map_cloning=false +sp_cleanup.merge_conditional_blocks=false +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.no_string_creation=false +sp_cleanup.no_super=false +sp_cleanup.number_suffix=false +sp_cleanup.objects_equals=false +sp_cleanup.on_save_use_additional_actions=false +sp_cleanup.organize_imports=true +sp_cleanup.overridden_assignment=false +sp_cleanup.precompile_regex=false +sp_cleanup.primitive_serialization=false +sp_cleanup.pull_up_assignment=false +sp_cleanup.push_down_negation=false +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=false +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.redundant_falling_through_block_end=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_redundant_modifiers=false +sp_cleanup.remove_redundant_semicolons=false +sp_cleanup.remove_redundant_type_arguments=false +sp_cleanup.remove_trailing_whitespaces=false +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_array_creation=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=false +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.simplify_lambda_expression_and_method_ref=false +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.strictly_equal_or_different=false +sp_cleanup.stringbuilder=false +sp_cleanup.switch=false +sp_cleanup.ternary_operator=false +sp_cleanup.try_with_resource=false +sp_cleanup.use_anonymous_class_creation=false +sp_cleanup.use_autoboxing=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_directly_map_method=false +sp_cleanup.use_lambda=true +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=false +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true +sp_cleanup.use_unboxing=false +sp_cleanup.use_var=false +sp_cleanup.useless_continue=false +sp_cleanup.useless_return=false diff --git a/org.sf.feeling.decompiler.vineflower/.settings/org.eclipse.m2e.core.prefs b/org.sf.feeling.decompiler.vineflower/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 00000000..f897a7f1 --- /dev/null +++ b/org.sf.feeling.decompiler.vineflower/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/org.sf.feeling.decompiler.vineflower/META-INF/MANIFEST.MF b/org.sf.feeling.decompiler.vineflower/META-INF/MANIFEST.MF new file mode 100644 index 00000000..3ff4907d --- /dev/null +++ b/org.sf.feeling.decompiler.vineflower/META-INF/MANIFEST.MF @@ -0,0 +1,31 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Enhanced Class Decompiler Vineflower Extension +Bundle-SymbolicName: org.sf.feeling.decompiler.vineflower;singleton:=true +Bundle-Version: 3.5.1 +Bundle-Activator: org.sf.feeling.decompiler.vineflower.VineflowerDecompilerPlugin +Require-Bundle: org.eclipse.core.runtime, + org.sf.feeling.decompiler;bundle-version="3.2.2", + org.eclipse.core.resources, + org.eclipse.jface, + org.eclipse.jface.text, + org.eclipse.ui.editors, + org.eclipse.ui.workbench, + org.eclipse.ui.workbench.texteditor, + org.eclipse.jdt.core, + org.eclipse.jdt.ui, + org.eclipse.jdt.debug.ui, + org.eclipse.debug.ui, + org.eclipse.jdt.launching, + org.eclipse.core.expressions, + org.eclipse.ui.navigator, + org.eclipse.ui.ide;resolution:=optional, + org.eclipse.core.filesystem, + org.apache.commons.lang3;bundle-version="3.1.0" +Bundle-RequiredExecutionEnvironment: JavaSE-11 +Bundle-ActivationPolicy: lazy +Bundle-Vendor: ECD Project Team +Export-Package: org.sf.feeling.decompiler.vineflower.actions, + org.sf.feeling.decompiler.vineflower.decompiler +Bundle-ClassPath: ., + lib/vineflower.jar diff --git a/org.sf.feeling.decompiler.source.attach/build.properties b/org.sf.feeling.decompiler.vineflower/build.properties similarity index 56% rename from org.sf.feeling.decompiler.source.attach/build.properties rename to org.sf.feeling.decompiler.vineflower/build.properties index 7536f7e1..f8bfdf18 100644 --- a/org.sf.feeling.decompiler.source.attach/build.properties +++ b/org.sf.feeling.decompiler.vineflower/build.properties @@ -1,8 +1,7 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - plugin.xml,\ - lib/,\ - plugin.properties -qualifier = 20170815 \ No newline at end of file +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + icons/,\ + lib/vineflower.jar \ No newline at end of file diff --git a/org.sf.feeling.decompiler.vineflower/icons/LICENSE.txt b/org.sf.feeling.decompiler.vineflower/icons/LICENSE.txt new file mode 100644 index 00000000..23aa5ede --- /dev/null +++ b/org.sf.feeling.decompiler.vineflower/icons/LICENSE.txt @@ -0,0 +1,427 @@ +Attribution-ShareAlike 4.0 International + +======================================================================= + +Creative Commons Corporation ("Creative Commons") is not a law firm and +does not provide legal services or legal advice. Distribution of +Creative Commons public licenses does not create a lawyer-client or +other relationship. Creative Commons makes its licenses and related +information available on an "as-is" basis. Creative Commons gives no +warranties regarding its licenses, any material licensed under their +terms and conditions, or any related information. Creative Commons +disclaims all liability for damages resulting from their use to the +fullest extent possible. + +Using Creative Commons Public Licenses + +Creative Commons public licenses provide a standard set of terms and +conditions that creators and other rights holders may use to share +original works of authorship and other material subject to copyright +and certain other rights specified in the public license below. The +following considerations are for informational purposes only, are not +exhaustive, and do not form part of our licenses. + + Considerations for licensors: Our public licenses are + intended for use by those authorized to give the public + permission to use material in ways otherwise restricted by + copyright and certain other rights. Our licenses are + irrevocable. Licensors should read and understand the terms + and conditions of the license they choose before applying it. + Licensors should also secure all rights necessary before + applying our licenses so that the public can reuse the + material as expected. Licensors should clearly mark any + material not subject to the license. This includes other CC- + licensed material, or material used under an exception or + limitation to copyright. More considerations for licensors: + wiki.creativecommons.org/Considerations_for_licensors + + Considerations for the public: By using one of our public + licenses, a licensor grants the public permission to use the + licensed material under specified terms and conditions. If + the licensor's permission is not necessary for any reason--for + example, because of any applicable exception or limitation to + copyright--then that use is not regulated by the license. Our + licenses grant only permissions under copyright and certain + other rights that a licensor has authority to grant. Use of + the licensed material may still be restricted for other + reasons, including because others have copyright or other + rights in the material. A licensor may make special requests, + such as asking that all changes be marked or described. + Although not required by our licenses, you are encouraged to + respect those requests where reasonable. More_considerations + for the public: + wiki.creativecommons.org/Considerations_for_licensees + +======================================================================= + +Creative Commons Attribution-ShareAlike 4.0 International Public +License + +By exercising the Licensed Rights (defined below), You accept and agree +to be bound by the terms and conditions of this Creative Commons +Attribution-ShareAlike 4.0 International Public License ("Public +License"). To the extent this Public License may be interpreted as a +contract, You are granted the Licensed Rights in consideration of Your +acceptance of these terms and conditions, and the Licensor grants You +such rights in consideration of benefits the Licensor receives from +making the Licensed Material available under these terms and +conditions. + + +Section 1 -- Definitions. + + a. Adapted Material means material subject to Copyright and Similar + Rights that is derived from or based upon the Licensed Material + and in which the Licensed Material is translated, altered, + arranged, transformed, or otherwise modified in a manner requiring + permission under the Copyright and Similar Rights held by the + Licensor. For purposes of this Public License, where the Licensed + Material is a musical work, performance, or sound recording, + Adapted Material is always produced where the Licensed Material is + synched in timed relation with a moving image. + + b. Adapter's License means the license You apply to Your Copyright + and Similar Rights in Your contributions to Adapted Material in + accordance with the terms and conditions of this Public License. + + c. BY-SA Compatible License means a license listed at + creativecommons.org/compatiblelicenses, approved by Creative + Commons as essentially the equivalent of this Public License. + + d. Copyright and Similar Rights means copyright and/or similar rights + closely related to copyright including, without limitation, + performance, broadcast, sound recording, and Sui Generis Database + Rights, without regard to how the rights are labeled or + categorized. For purposes of this Public License, the rights + specified in Section 2(b)(1)-(2) are not Copyright and Similar + Rights. + + e. Effective Technological Measures means those measures that, in the + absence of proper authority, may not be circumvented under laws + fulfilling obligations under Article 11 of the WIPO Copyright + Treaty adopted on December 20, 1996, and/or similar international + agreements. + + f. Exceptions and Limitations means fair use, fair dealing, and/or + any other exception or limitation to Copyright and Similar Rights + that applies to Your use of the Licensed Material. + + g. License Elements means the license attributes listed in the name + of a Creative Commons Public License. The License Elements of this + Public License are Attribution and ShareAlike. + + h. Licensed Material means the artistic or literary work, database, + or other material to which the Licensor applied this Public + License. + + i. Licensed Rights means the rights granted to You subject to the + terms and conditions of this Public License, which are limited to + all Copyright and Similar Rights that apply to Your use of the + Licensed Material and that the Licensor has authority to license. + + j. Licensor means the individual(s) or entity(ies) granting rights + under this Public License. + + k. Share means to provide material to the public by any means or + process that requires permission under the Licensed Rights, such + as reproduction, public display, public performance, distribution, + dissemination, communication, or importation, and to make material + available to the public including in ways that members of the + public may access the material from a place and at a time + individually chosen by them. + + l. Sui Generis Database Rights means rights other than copyright + resulting from Directive 96/9/EC of the European Parliament and of + the Council of 11 March 1996 on the legal protection of databases, + as amended and/or succeeded, as well as other essentially + equivalent rights anywhere in the world. + + m. You means the individual or entity exercising the Licensed Rights + under this Public License. Your has a corresponding meaning. + + +Section 2 -- Scope. + + a. License grant. + + 1. Subject to the terms and conditions of this Public License, + the Licensor hereby grants You a worldwide, royalty-free, + non-sublicensable, non-exclusive, irrevocable license to + exercise the Licensed Rights in the Licensed Material to: + + a. reproduce and Share the Licensed Material, in whole or + in part; and + + b. produce, reproduce, and Share Adapted Material. + + 2. Exceptions and Limitations. For the avoidance of doubt, where + Exceptions and Limitations apply to Your use, this Public + License does not apply, and You do not need to comply with + its terms and conditions. + + 3. Term. The term of this Public License is specified in Section + 6(a). + + 4. Media and formats; technical modifications allowed. The + Licensor authorizes You to exercise the Licensed Rights in + all media and formats whether now known or hereafter created, + and to make technical modifications necessary to do so. The + Licensor waives and/or agrees not to assert any right or + authority to forbid You from making technical modifications + necessary to exercise the Licensed Rights, including + technical modifications necessary to circumvent Effective + Technological Measures. For purposes of this Public License, + simply making modifications authorized by this Section 2(a) + (4) never produces Adapted Material. + + 5. Downstream recipients. + + a. Offer from the Licensor -- Licensed Material. Every + recipient of the Licensed Material automatically + receives an offer from the Licensor to exercise the + Licensed Rights under the terms and conditions of this + Public License. + + b. Additional offer from the Licensor -- Adapted Material. + Every recipient of Adapted Material from You + automatically receives an offer from the Licensor to + exercise the Licensed Rights in the Adapted Material + under the conditions of the Adapter's License You apply. + + c. No downstream restrictions. You may not offer or impose + any additional or different terms or conditions on, or + apply any Effective Technological Measures to, the + Licensed Material if doing so restricts exercise of the + Licensed Rights by any recipient of the Licensed + Material. + + 6. No endorsement. Nothing in this Public License constitutes or + may be construed as permission to assert or imply that You + are, or that Your use of the Licensed Material is, connected + with, or sponsored, endorsed, or granted official status by, + the Licensor or others designated to receive attribution as + provided in Section 3(a)(1)(A)(i). + + b. Other rights. + + 1. Moral rights, such as the right of integrity, are not + licensed under this Public License, nor are publicity, + privacy, and/or other similar personality rights; however, to + the extent possible, the Licensor waives and/or agrees not to + assert any such rights held by the Licensor to the limited + extent necessary to allow You to exercise the Licensed + Rights, but not otherwise. + + 2. Patent and trademark rights are not licensed under this + Public License. + + 3. To the extent possible, the Licensor waives any right to + collect royalties from You for the exercise of the Licensed + Rights, whether directly or through a collecting society + under any voluntary or waivable statutory or compulsory + licensing scheme. In all other cases the Licensor expressly + reserves any right to collect such royalties. + + +Section 3 -- License Conditions. + +Your exercise of the Licensed Rights is expressly made subject to the +following conditions. + + a. Attribution. + + 1. If You Share the Licensed Material (including in modified + form), You must: + + a. retain the following if it is supplied by the Licensor + with the Licensed Material: + + i. identification of the creator(s) of the Licensed + Material and any others designated to receive + attribution, in any reasonable manner requested by + the Licensor (including by pseudonym if + designated); + + ii. a copyright notice; + + iii. a notice that refers to this Public License; + + iv. a notice that refers to the disclaimer of + warranties; + + v. a URI or hyperlink to the Licensed Material to the + extent reasonably practicable; + + b. indicate if You modified the Licensed Material and + retain an indication of any previous modifications; and + + c. indicate the Licensed Material is licensed under this + Public License, and include the text of, or the URI or + hyperlink to, this Public License. + + 2. You may satisfy the conditions in Section 3(a)(1) in any + reasonable manner based on the medium, means, and context in + which You Share the Licensed Material. For example, it may be + reasonable to satisfy the conditions by providing a URI or + hyperlink to a resource that includes the required + information. + + 3. If requested by the Licensor, You must remove any of the + information required by Section 3(a)(1)(A) to the extent + reasonably practicable. + + b. ShareAlike. + + In addition to the conditions in Section 3(a), if You Share + Adapted Material You produce, the following conditions also apply. + + 1. The Adapter's License You apply must be a Creative Commons + license with the same License Elements, this version or + later, or a BY-SA Compatible License. + + 2. You must include the text of, or the URI or hyperlink to, the + Adapter's License You apply. You may satisfy this condition + in any reasonable manner based on the medium, means, and + context in which You Share Adapted Material. + + 3. You may not offer or impose any additional or different terms + or conditions on, or apply any Effective Technological + Measures to, Adapted Material that restrict exercise of the + rights granted under the Adapter's License You apply. + + +Section 4 -- Sui Generis Database Rights. + +Where the Licensed Rights include Sui Generis Database Rights that +apply to Your use of the Licensed Material: + + a. for the avoidance of doubt, Section 2(a)(1) grants You the right + to extract, reuse, reproduce, and Share all or a substantial + portion of the contents of the database; + + b. if You include all or a substantial portion of the database + contents in a database in which You have Sui Generis Database + Rights, then the database in which You have Sui Generis Database + Rights (but not its individual contents) is Adapted Material, + + including for purposes of Section 3(b); and + c. You must comply with the conditions in Section 3(a) if You Share + all or a substantial portion of the contents of the database. + +For the avoidance of doubt, this Section 4 supplements and does not +replace Your obligations under this Public License where the Licensed +Rights include other Copyright and Similar Rights. + + +Section 5 -- Disclaimer of Warranties and Limitation of Liability. + + a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE + EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS + AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF + ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, + IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, + WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR + PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, + ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT + KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT + ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. + + b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE + TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, + NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, + INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, + COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR + USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN + ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR + DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR + IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. + + c. The disclaimer of warranties and limitation of liability provided + above shall be interpreted in a manner that, to the extent + possible, most closely approximates an absolute disclaimer and + waiver of all liability. + + +Section 6 -- Term and Termination. + + a. This Public License applies for the term of the Copyright and + Similar Rights licensed here. However, if You fail to comply with + this Public License, then Your rights under this Public License + terminate automatically. + + b. Where Your right to use the Licensed Material has terminated under + Section 6(a), it reinstates: + + 1. automatically as of the date the violation is cured, provided + it is cured within 30 days of Your discovery of the + violation; or + + 2. upon express reinstatement by the Licensor. + + For the avoidance of doubt, this Section 6(b) does not affect any + right the Licensor may have to seek remedies for Your violations + of this Public License. + + c. For the avoidance of doubt, the Licensor may also offer the + Licensed Material under separate terms or conditions or stop + distributing the Licensed Material at any time; however, doing so + will not terminate this Public License. + + d. Sections 1, 5, 6, 7, and 8 survive termination of this Public + License. + + +Section 7 -- Other Terms and Conditions. + + a. The Licensor shall not be bound by any additional or different + terms or conditions communicated by You unless expressly agreed. + + b. Any arrangements, understandings, or agreements regarding the + Licensed Material not stated herein are separate from and + independent of the terms and conditions of this Public License. + + +Section 8 -- Interpretation. + + a. For the avoidance of doubt, this Public License does not, and + shall not be interpreted to, reduce, limit, restrict, or impose + conditions on any use of the Licensed Material that could lawfully + be made without permission under this Public License. + + b. To the extent possible, if any provision of this Public License is + deemed unenforceable, it shall be automatically reformed to the + minimum extent necessary to make it enforceable. If the provision + cannot be reformed, it shall be severed from this Public License + without affecting the enforceability of the remaining terms and + conditions. + + c. No term or condition of this Public License will be waived and no + failure to comply consented to unless expressly agreed to by the + Licensor. + + d. Nothing in this Public License constitutes or may be interpreted + as a limitation upon, or waiver of, any privileges and immunities + that apply to the Licensor or You, including from the legal + processes of any jurisdiction or authority. + + +======================================================================= + +Creative Commons is not a party to its public +licenses. Notwithstanding, Creative Commons may elect to apply one of +its public licenses to material it publishes and in those instances +will be considered the “Licensor.” The text of the Creative Commons +public licenses is dedicated to the public domain under the CC0 Public +Domain Dedication. Except for the limited purpose of indicating that +material is shared under a Creative Commons public license or as +otherwise permitted by the Creative Commons policies published at +creativecommons.org/policies, Creative Commons does not authorize the +use of the trademark "Creative Commons" or any other trademark or logo +of Creative Commons without its prior written consent including, +without limitation, in connection with any unauthorized modifications +to any of its public licenses or any other arrangements, +understandings, or agreements concerning use of licensed material. For +the avoidance of doubt, this paragraph does not form part of the +public licenses. + +Creative Commons may be contacted at creativecommons.org. diff --git a/org.sf.feeling.decompiler.vineflower/icons/favicon.ico b/org.sf.feeling.decompiler.vineflower/icons/favicon.ico new file mode 100644 index 00000000..f1ff8386 Binary files /dev/null and b/org.sf.feeling.decompiler.vineflower/icons/favicon.ico differ diff --git a/org.sf.feeling.decompiler.vineflower/icons/pluginIcon.txt b/org.sf.feeling.decompiler.vineflower/icons/pluginIcon.txt new file mode 100644 index 00000000..5b64e829 --- /dev/null +++ b/org.sf.feeling.decompiler.vineflower/icons/pluginIcon.txt @@ -0,0 +1,4 @@ +Icon source: +https://github.com/Vineflower/vineflower-site/blob/main/source/_static/favicon.ico + +License: Creative Commons Attribution Share Alike 4.0 International diff --git a/org.sf.feeling.decompiler.vineflower/icons/vineflower_16.png b/org.sf.feeling.decompiler.vineflower/icons/vineflower_16.png new file mode 100644 index 00000000..ea5eb4a2 Binary files /dev/null and b/org.sf.feeling.decompiler.vineflower/icons/vineflower_16.png differ diff --git a/org.sf.feeling.decompiler.vineflower/lib/.gitignore b/org.sf.feeling.decompiler.vineflower/lib/.gitignore new file mode 100644 index 00000000..459b5c05 --- /dev/null +++ b/org.sf.feeling.decompiler.vineflower/lib/.gitignore @@ -0,0 +1 @@ +/vineflower.jar diff --git a/org.sf.feeling.decompiler.vineflower/plugin.xml b/org.sf.feeling.decompiler.vineflower/plugin.xml new file mode 100644 index 00000000..db615f82 --- /dev/null +++ b/org.sf.feeling.decompiler.vineflower/plugin.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + diff --git a/org.sf.feeling.decompiler.vineflower/pom.xml b/org.sf.feeling.decompiler.vineflower/pom.xml new file mode 100644 index 00000000..1be134b4 --- /dev/null +++ b/org.sf.feeling.decompiler.vineflower/pom.xml @@ -0,0 +1,47 @@ + + 4.0.0 + + + com.github.ecd-plugin + com.github.ecd-plugin.ecd + 3.5.1 + ../pom.xml + + + org.sf.feeling.decompiler.vineflower + eclipse-plugin + + + + org.apache.maven.plugins + maven-dependency-plugin + ${maven.dependency.plugin.version} + + + copy-libraries + validate + + copy + + + + + + + org.vineflower + vineflower + 1.9.3 + vineflower.jar + + + lib + true + true + + + + + + + diff --git a/org.sf.feeling.decompiler.vineflower/src/org/sf/feeling/decompiler/vineflower/VineflowerDecompilerPlugin.java b/org.sf.feeling.decompiler.vineflower/src/org/sf/feeling/decompiler/vineflower/VineflowerDecompilerPlugin.java new file mode 100644 index 00000000..1c729f5b --- /dev/null +++ b/org.sf.feeling.decompiler.vineflower/src/org/sf/feeling/decompiler/vineflower/VineflowerDecompilerPlugin.java @@ -0,0 +1,88 @@ + +package org.sf.feeling.decompiler.vineflower; + +import java.net.*; + +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.util.*; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; +import org.sf.feeling.decompiler.JavaDecompilerPlugin; + +public class VineflowerDecompilerPlugin extends AbstractUIPlugin implements IPropertyChangeListener { + + public static final String PLUGIN_ID = "org.sf.feeling.decompiler.vineflower"; //$NON-NLS-1$ + + public static final String CMD = "org.sf.feeling.decompiler.vineflower.cmd"; //$NON-NLS-1$ + + public static final String decompilerType = "Vineflower"; //$NON-NLS-1$ + + public static final String decompilerVersion = "1.9.3"; //$NON-NLS-1$ + + private static VineflowerDecompilerPlugin plugin; + + private IPreferenceStore preferenceStore; + + /* + * (non-Javadoc) + * + * @see + * org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext ) + */ + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + getPreferenceStore().addPropertyChangeListener(this); + } + + /* + * (non-Javadoc) + * + * @see + * org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) + */ + @Override + public void stop(BundleContext context) throws Exception { + super.stop(context); + getPreferenceStore().removePropertyChangeListener(this); + plugin = null; + } + + @Override + public void propertyChange(PropertyChangeEvent event) { + + } + + @Override + public IPreferenceStore getPreferenceStore() { + if (preferenceStore == null) { + preferenceStore = JavaDecompilerPlugin.getDefault().getPreferenceStore(); + } + return preferenceStore; + } + + public static VineflowerDecompilerPlugin getDefault() { + return plugin; + } + + public VineflowerDecompilerPlugin() { + plugin = this; + } + + public static ImageDescriptor getImageDescriptor(String path) { + URL base = VineflowerDecompilerPlugin.getDefault().getBundle().getEntry("/"); //$NON-NLS-1$ + URL url = null; + try { + url = new URL(base, path); // $NON-NLS-1$ + } catch (MalformedURLException e) { + throw new RuntimeException(e); + } + ImageDescriptor actionIcon = null; + if (url != null) { + actionIcon = ImageDescriptor.createFromURL(url); + } + return actionIcon; + } + +} diff --git a/org.sf.feeling.decompiler.vineflower/src/org/sf/feeling/decompiler/vineflower/actions/DecompileWithVineflowerAction.java b/org.sf.feeling.decompiler.vineflower/src/org/sf/feeling/decompiler/vineflower/actions/DecompileWithVineflowerAction.java new file mode 100644 index 00000000..12e3e24d --- /dev/null +++ b/org.sf.feeling.decompiler.vineflower/src/org/sf/feeling/decompiler/vineflower/actions/DecompileWithVineflowerAction.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2017 Chen Chao and other ECD project contributors. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.sf.feeling.decompiler.vineflower.actions; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.jface.action.Action; +import org.sf.feeling.decompiler.vineflower.VineflowerDecompilerPlugin; +import org.sf.feeling.decompiler.vineflower.i18n.Messages; +import org.sf.feeling.decompiler.util.UIUtil; + +public class DecompileWithVineflowerAction extends Action { + + public DecompileWithVineflowerAction() { + super(Messages.getString("JavaDecompilerActionBarContributor.Action.DecompileWithVineflower")); //$NON-NLS-1$ + this.setImageDescriptor(VineflowerDecompilerPlugin.getImageDescriptor("icons/vineflower_16.png")); //$NON-NLS-1$ + } + + @Override + public void run() { + try { + new DecompileWithVineflowerHandler().execute(null); + } catch (ExecutionException e) { + } + } + + @Override + public boolean isEnabled() { + return UIUtil.getActiveEditor() != null || UIUtil.getActiveSelection() != null; + } +} \ No newline at end of file diff --git a/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/actions/DecompileWithJadHandler.java b/org.sf.feeling.decompiler.vineflower/src/org/sf/feeling/decompiler/vineflower/actions/DecompileWithVineflowerHandler.java similarity index 51% rename from org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/actions/DecompileWithJadHandler.java rename to org.sf.feeling.decompiler.vineflower/src/org/sf/feeling/decompiler/vineflower/actions/DecompileWithVineflowerHandler.java index 020183b7..8e1eac46 100644 --- a/org.sf.feeling.decompiler.jad/src/org/sf/feeling/decompiler/jad/actions/DecompileWithJadHandler.java +++ b/org.sf.feeling.decompiler.vineflower/src/org/sf/feeling/decompiler/vineflower/actions/DecompileWithVineflowerHandler.java @@ -1,28 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.jad.actions; - -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.sf.feeling.decompiler.actions.BaseDecompilerHandler; -import org.sf.feeling.decompiler.jad.JadDecompilerPlugin; - -public class DecompileWithJadHandler extends BaseDecompilerHandler -{ - - @Override - public Object execute( ExecutionEvent event ) throws ExecutionException - { - return handleDecompile( JadDecompilerPlugin.decompilerType ); - } - -} +/******************************************************************************* + * Copyright (c) 2017 Chen Chao and other ECD project contributors. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.sf.feeling.decompiler.vineflower.actions; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.sf.feeling.decompiler.actions.BaseDecompilerHandler; +import org.sf.feeling.decompiler.vineflower.VineflowerDecompilerPlugin; + +public class DecompileWithVineflowerHandler extends BaseDecompilerHandler { + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + return handleDecompile(VineflowerDecompilerPlugin.decompilerType); + } + +} \ No newline at end of file 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 new file mode 100644 index 00000000..914611af --- /dev/null +++ b/org.sf.feeling.decompiler.vineflower/src/org/sf/feeling/decompiler/vineflower/decompiler/VineflowerDecompiler.java @@ -0,0 +1,219 @@ +/******************************************************************************* + * Copyright (c) 2017 Chen Chao and other ECD project contributors. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.sf.feeling.decompiler.vineflower.decompiler; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FilenameFilter; +import java.io.IOException; +import java.io.PrintStream; +import java.nio.file.Files; +import java.util.HashMap; +import java.util.Map; + +import org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler; +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; +import org.sf.feeling.decompiler.editor.LineNumberOutputType; +import org.sf.feeling.decompiler.util.ClassUtil; +import org.sf.feeling.decompiler.util.CommentUtil; +import org.sf.feeling.decompiler.util.FileUtil; +import org.sf.feeling.decompiler.util.JarClassExtractor; +import org.sf.feeling.decompiler.util.UnicodeUtil; +import org.sf.feeling.decompiler.vineflower.VineflowerDecompilerPlugin; + +public class VineflowerDecompiler extends BaseDecompiler { + + private String source = ""; // $NON-NLS-1$ + private long time, start; + private String log = ""; //$NON-NLS-1$ + + ByteArrayOutputStream loggerStream; + + /** + * Performs a Runtime.exec() on Vineflower executable with selected + * options. + * + * @see IDecompiler#decompile(String, String, String) + */ + @Override + public void decompile(String root, String packege, final String className) { + if (root == null || packege == null || className == null) { + return; + } + + start = System.currentTimeMillis(); + log = ""; //$NON-NLS-1$ + source = ""; //$NON-NLS-1$ + + loggerStream = new ByteArrayOutputStream(); + + File workingDir = new File(root + "/" + packege); //$NON-NLS-1$ + + final Map mapOptions = new HashMap<>(); + + mapOptions.put(IFernflowerPreferences.REMOVE_SYNTHETIC, "1"); //$NON-NLS-1$ + mapOptions.put(IFernflowerPreferences.DECOMPILE_GENERIC_SIGNATURES, "1"); //$NON-NLS-1$ + mapOptions.put(IFernflowerPreferences.DECOMPILE_INNER, "1"); //$NON-NLS-1$ + mapOptions.put(IFernflowerPreferences.DECOMPILE_ENUM, "1"); //$NON-NLS-1$ + mapOptions.put(IFernflowerPreferences.LOG_LEVEL, IFernflowerLogger.Severity.ERROR.name()); + mapOptions.put(IFernflowerPreferences.ASCII_STRING_CHARACTERS, "1"); //$NON-NLS-1$ + if (ClassUtil.isDebug()) { + mapOptions.put(IFernflowerPreferences.DUMP_ORIGINAL_LINES, "1"); //$NON-NLS-1$ + mapOptions.put(IFernflowerPreferences.BYTECODE_SOURCE_MAPPING, "1"); //$NON-NLS-1$ + } + + File tmpDir; + try { + tmpDir = Files.createTempDirectory("ecd_vineflower").toFile(); + } catch (IOException e) { + throw new RuntimeException("Failed to create temporary working directory", e); //$NON-NLS-1$ + } + + // Work around protected constructor + class EmbeddedConsoleDecompiler extends ConsoleDecompiler { + + protected EmbeddedConsoleDecompiler() { + super(tmpDir, mapOptions, new PrintStreamLogger(new PrintStream(loggerStream))); + } + + } + + String classNameFilterTmp = className.toLowerCase(); + if (classNameFilterTmp.endsWith(".class")) { + classNameFilterTmp = classNameFilterTmp.substring(0, classNameFilterTmp.length() - 6); + } + final String classNameFilter = classNameFilterTmp; + + File[] files = workingDir.listFiles(new FilenameFilter() { + + @Override + public boolean accept(File dir, String name) { + name = name.toLowerCase(); + if (name.startsWith(classNameFilter) && name.endsWith(".class")) { + return true; + } + return false; + } + }); + + try (ConsoleDecompiler decompiler = new EmbeddedConsoleDecompiler()) { + for (File f : files) { + decompiler.addSource(f); + } + decompiler.decompileContext(); + + File classFile = new File(tmpDir, className.replaceAll("(?i)\\.class", ".java")); //$NON-NLS-1$ //$NON-NLS-2$ + + source = UnicodeUtil.decode(FileUtil.getContent(classFile)); + + classFile.delete(); + + } catch (IOException e) { + throw new RuntimeException(e); + } finally { + FileUtil.deltree(tmpDir); + } + + source = CommentUtil.clearComments(source); + + time = System.currentTimeMillis() - start; + } + + /** + * Vineflower doesn't support decompilation from archives. This method extracts + * request class file from the specified archive into temp directory and then + * calls decompile. + * + * @see IDecompiler#decompileFromArchive(String, String, String) + */ + @Override + public void decompileFromArchive(String archivePath, String packege, String className) { + start = System.currentTimeMillis(); + File workingDir = new File( + JavaDecompilerPlugin.getDefault().getPreferenceStore().getString(JavaDecompilerConstants.TEMP_DIR) + "/" //$NON-NLS-1$ + + System.currentTimeMillis()); + + try { + workingDir.mkdirs(); + JarClassExtractor.extract(archivePath, packege, className, true, workingDir.getAbsolutePath()); + decompile(workingDir.getAbsolutePath(), "", className); //$NON-NLS-1$ + } catch (Exception e) { + exceptions.add(e); + JavaDecompilerPlugin.logError(e, e.getMessage()); + return; + } finally { + FileUtil.deltree(workingDir); + } + } + + @Override + public long getDecompilationTime() { + return time; + } + + /** + * @see IDecompiler#getLog() + */ + @Override + public String getLog() { + if (loggerStream != null) { + return log + loggerStream.toString(); + } + return log; + } + + /** + * @see IDecompiler#getSource() + */ + @Override + public String getSource() { + return source; + } + + @Override + public String getDecompilerType() { + return VineflowerDecompilerPlugin.decompilerType; + } + + @Override + public String removeComment(String source) { + return source; + } + + @Override + public boolean supportLevel(int level) { + return true; + } + + @Override + public boolean supportDebugLevel(int level) { + return true; + } + + @Override + public LineNumberOutputType getLineNumberOutputType() { + return LineNumberOutputType.SINGLE_LINE_COMMENT_END_OF_LINE; + } + + @Override + public String getDecompilerName() { + return VineflowerDecompilerPlugin.decompilerType; + } + + @Override + public String getDecompilerVersion() { + return VineflowerDecompilerPlugin.decompilerVersion; + } +} \ No newline at end of file diff --git a/org.sf.feeling.decompiler.vineflower/src/org/sf/feeling/decompiler/vineflower/decompiler/VineflowerDecompilerDescriptor.java b/org.sf.feeling.decompiler.vineflower/src/org/sf/feeling/decompiler/vineflower/decompiler/VineflowerDecompilerDescriptor.java new file mode 100644 index 00000000..e85c0a4e --- /dev/null +++ b/org.sf.feeling.decompiler.vineflower/src/org/sf/feeling/decompiler/vineflower/decompiler/VineflowerDecompilerDescriptor.java @@ -0,0 +1,67 @@ +package org.sf.feeling.decompiler.vineflower.decompiler; + +import org.eclipse.jface.action.Action; +import org.eclipse.jface.resource.ImageDescriptor; +import org.sf.feeling.decompiler.editor.BaseDecompilerSourceMapper; +import org.sf.feeling.decompiler.editor.IDecompiler; +import org.sf.feeling.decompiler.editor.IDecompilerDescriptor; +import org.sf.feeling.decompiler.vineflower.VineflowerDecompilerPlugin; +import org.sf.feeling.decompiler.vineflower.actions.DecompileWithVineflowerAction; +import org.sf.feeling.decompiler.vineflower.i18n.Messages; + +public class VineflowerDecompilerDescriptor implements IDecompilerDescriptor { + private VineflowerDecompiler decompiler = null; + private VineflowerSourceMapper sourceMapper = null; + private Action decompileAction; + + @Override + public String getDecompilerType() { + return VineflowerDecompilerPlugin.decompilerType; + } + + @Override + public String getDecompilerPreferenceLabel() { + return Messages.getString("VineflowerDecompilerDescriptor.PreferenceLabel"); //$NON-NLS-1$ + } + + @Override + public IDecompiler getDecompiler() { + if (decompiler == null) { + decompiler = new VineflowerDecompiler(); + } + return decompiler; + + } + + @Override + public BaseDecompilerSourceMapper getDecompilerSourceMapper() { + if (sourceMapper == null) { + sourceMapper = new VineflowerSourceMapper(); + } + return sourceMapper; + } + + @Override + public Action getDecompileAction() { + if (decompileAction == null) { + decompileAction = new DecompileWithVineflowerAction(); + } + return decompileAction; + } + + @Override + public boolean isEnabled() { + return true; + } + + @Override + public int getDefaultPriority() { + return 10; + } + + @Override + public ImageDescriptor getDecompilerIcon() { + return VineflowerDecompilerPlugin.getImageDescriptor("icons/vineflower_16.png"); //$NON-NLS-1$ + } + +} diff --git a/org.sf.feeling.decompiler.vineflower/src/org/sf/feeling/decompiler/vineflower/decompiler/VineflowerSourceMapper.java b/org.sf.feeling.decompiler.vineflower/src/org/sf/feeling/decompiler/vineflower/decompiler/VineflowerSourceMapper.java new file mode 100644 index 00000000..49439ce5 --- /dev/null +++ b/org.sf.feeling.decompiler.vineflower/src/org/sf/feeling/decompiler/vineflower/decompiler/VineflowerSourceMapper.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2017 Chen Chao and other ECD project contributors. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.sf.feeling.decompiler.vineflower.decompiler; + +import org.eclipse.core.runtime.Path; +import org.sf.feeling.decompiler.editor.BaseDecompilerSourceMapper; +import org.sf.feeling.decompiler.vineflower.VineflowerDecompilerPlugin; + +public class VineflowerSourceMapper extends BaseDecompilerSourceMapper { + + public VineflowerSourceMapper() { + super(new Path("."), ""); //$NON-NLS-1$ //$NON-NLS-2$ + originalDecompiler = new VineflowerDecompiler(); + } + + @Override + protected String getDecompilerName() { + return VineflowerDecompilerPlugin.decompilerType; + } + + @Override + protected String getDecompilerVersion() { + return VineflowerDecompilerPlugin.decompilerVersion; + } + +} \ No newline at end of file diff --git a/org.sf.feeling.decompiler.vineflower/src/org/sf/feeling/decompiler/vineflower/i18n/Messages.java b/org.sf.feeling.decompiler.vineflower/src/org/sf/feeling/decompiler/vineflower/i18n/Messages.java new file mode 100644 index 00000000..2c4528ce --- /dev/null +++ b/org.sf.feeling.decompiler.vineflower/src/org/sf/feeling/decompiler/vineflower/i18n/Messages.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2017 Chen Chao and other ECD project contributors. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.sf.feeling.decompiler.vineflower.i18n; + +import org.sf.feeling.decompiler.i18n.EcdResouceBundle; + +public class Messages { + + private static final EcdResouceBundle RESOURCE_BUNDLE = new EcdResouceBundle(Messages.class); + + private Messages() { + } + + public static String getString(String key) { + return RESOURCE_BUNDLE.getString(key); + } + + /** + * Gets formatted translation for current local + * + * @param key the key + * @return translated value string + */ + public static String getFormattedString(String key, Object[] arguments) { + return RESOURCE_BUNDLE.getFormattedString(key, arguments); + } + +} diff --git a/org.sf.feeling.decompiler.source.attach/plugin_zh_CN.properties b/org.sf.feeling.decompiler.vineflower/src/org/sf/feeling/decompiler/vineflower/i18n/messages.properties similarity index 59% rename from org.sf.feeling.decompiler.source.attach/plugin_zh_CN.properties rename to org.sf.feeling.decompiler.vineflower/src/org/sf/feeling/decompiler/vineflower/i18n/messages.properties index a96a0954..1de73054 100644 --- a/org.sf.feeling.decompiler.source.attach/plugin_zh_CN.properties +++ b/org.sf.feeling.decompiler.vineflower/src/org/sf/feeling/decompiler/vineflower/i18n/messages.properties @@ -1,12 +1,10 @@ -############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation -############################################################################### - -action.label=\u4E0B\u8F7D\u6E90\u7801 \ No newline at end of file +############################################################################### +# Copyright (c) 2017 Chen Chao and other ECD project contributors. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# https://www.eclipse.org/legal/epl-v10.html +############################################################################### + +VineflowerDecompilerDescriptor.PreferenceLabel=Vineflower +JavaDecompilerActionBarContributor.Action.DecompileWithVineflower=&Vineflower \ No newline at end of file diff --git a/org.sf.feeling.decompiler/.classpath b/org.sf.feeling.decompiler/.classpath index b3b48c49..4c923924 100644 --- a/org.sf.feeling.decompiler/.classpath +++ b/org.sf.feeling.decompiler/.classpath @@ -1,13 +1,27 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/org.sf.feeling.decompiler/.gitignore b/org.sf.feeling.decompiler/.gitignore deleted file mode 100644 index ae3c1726..00000000 --- a/org.sf.feeling.decompiler/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin/ diff --git a/org.sf.feeling.decompiler/.project b/org.sf.feeling.decompiler/.project index f9e4adcd..50e89356 100644 --- a/org.sf.feeling.decompiler/.project +++ b/org.sf.feeling.decompiler/.project @@ -20,8 +20,14 @@ + + org.eclipse.m2e.core.maven2Builder + + + + org.eclipse.m2e.core.maven2Nature org.eclipse.pde.PluginNature org.eclipse.jdt.core.javanature diff --git a/org.sf.feeling.decompiler/.settings/org.eclipse.core.resources.prefs b/org.sf.feeling.decompiler/.settings/org.eclipse.core.resources.prefs index c26f3276..45f8ba6f 100644 --- a/org.sf.feeling.decompiler/.settings/org.eclipse.core.resources.prefs +++ b/org.sf.feeling.decompiler/.settings/org.eclipse.core.resources.prefs @@ -1,5 +1,3 @@ eclipse.preferences.version=1 encoding//src/org/sf/feeling/decompiler/i18n/messages.properties=UTF-8 -encoding//src/org/sf/feeling/decompiler/i18n/messages_zh_CN.properties=UTF-8 -encoding//src/org/sf/feeling/decompiler/i18n/messages_zh_HK.properties=UTF-8 -encoding//src/org/sf/feeling/decompiler/i18n/messages_zh_TW.properties=UTF-8 +encoding/=UTF-8 diff --git a/org.sf.feeling.decompiler/.settings/org.eclipse.core.runtime.prefs b/org.sf.feeling.decompiler/.settings/org.eclipse.core.runtime.prefs new file mode 100644 index 00000000..f8a67de1 --- /dev/null +++ b/org.sf.feeling.decompiler/.settings/org.eclipse.core.runtime.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +line.separator=\r\n diff --git a/org.sf.feeling.decompiler/.settings/org.eclipse.jdt.core.prefs b/org.sf.feeling.decompiler/.settings/org.eclipse.jdt.core.prefs index 611341b2..d1889bca 100644 --- a/org.sf.feeling.decompiler/.settings/org.eclipse.jdt.core.prefs +++ b/org.sf.feeling.decompiler/.settings/org.eclipse.jdt.core.prefs @@ -1,15 +1,9 @@ eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled -org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore -org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull -org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault -org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable -org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -23,24 +17,22 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning -org.eclipse.jdt.core.compiler.problem.forbiddenReference=error +org.eclipse.jdt.core.compiler.problem.forbiddenReference=ignore org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning -org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning -org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore -org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled @@ -49,33 +41,26 @@ org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignor org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore -org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning -org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error org.eclipse.jdt.core.compiler.problem.nullReference=warning -org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error -org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore -org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore -org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled -org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore -org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore @@ -94,76 +79,108 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference= org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning -org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=80 +org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false +org.eclipse.jdt.core.formatter.align_with_spaces=false +org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_enum_constant=49 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field=49 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable=49 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_method=49 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package=49 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter=0 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type=49 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=80 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=80 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assertion_message=16 org.eclipse.jdt.core.formatter.alignment_for_assignment=0 -org.eclipse.jdt.core.formatter.alignment_for_binary_expression=48 -org.eclipse.jdt.core.formatter.alignment_for_compact_if=84 +org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16 org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 -org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 -org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=80 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain=0 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0 +org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16 org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_module_statements=16 org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16 org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_record_components=16 +org.eclipse.jdt.core.formatter.alignment_for_relational_operator=0 org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 -org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=80 -org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=80 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_shift_operator=0 +org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=80 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_record_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_type_annotations=0 org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0 org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0 org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_last_class_body_declaration=0 org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_abstract_method=1 org.eclipse.jdt.core.formatter.blank_lines_before_field=0 -org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=1 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 org.eclipse.jdt.core.formatter.blank_lines_before_method=1 -org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=0 -org.eclipse.jdt.core.formatter.blank_lines_before_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_statement_group_in_switch=0 org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block=next_line -org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=next_line -org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=next_line -org.eclipse.jdt.core.formatter.brace_position_for_switch=next_line -org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_record_constructor=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_record_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped=true +org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions=false org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false -org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=false +org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=true org.eclipse.jdt.core.formatter.comment.format_block_comments=true org.eclipse.jdt.core.formatter.comment.format_header=false org.eclipse.jdt.core.formatter.comment.format_html=true org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true org.eclipse.jdt.core.formatter.comment.format_line_comments=true org.eclipse.jdt.core.formatter.comment.format_source_code=true -org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true -org.eclipse.jdt.core.formatter.comment.indent_root_tags=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=false +org.eclipse.jdt.core.formatter.comment.indent_root_tags=false +org.eclipse.jdt.core.formatter.comment.indent_tag_description=false org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert -org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_between_different_tags=do not insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert org.eclipse.jdt.core.formatter.comment.line_length=80 org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true @@ -174,17 +191,18 @@ org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false -org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=false org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_record_header=true org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true org.eclipse.jdt.core.formatter.indent_empty_lines=false org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false org.eclipse.jdt.core.formatter.indentation.size=4 org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert @@ -194,27 +212,23 @@ org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=inser org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert -org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=insert -org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_default=insert org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert @@ -239,66 +253,79 @@ org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arg org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_record_components=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_switch_case_expressions=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_not_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_record_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_case=insert +org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_default=insert org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_record_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert @@ -317,22 +344,28 @@ org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_ar org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_record_components=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_switch_case_expressions=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_constructor=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert @@ -348,6 +381,7 @@ org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_record_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert @@ -358,28 +392,52 @@ org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not inser org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert org.eclipse.jdt.core.formatter.join_lines_in_comments=true org.eclipse.jdt.core.formatter.join_wrapped_lines=true +org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_code_block_on_one_line=one_line_never org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false -org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=true +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line=one_line_never org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_method_body_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_record_constructor_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_record_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line=false +org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line=false org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line=one_line_never org.eclipse.jdt.core.formatter.lineSplit=120 org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false +org.eclipse.jdt.core.formatter.number_of_blank_lines_after_code_block=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_code_block=0 org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_code_block=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_blank_lines_before_code_block=0 org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines @@ -389,15 +447,25 @@ org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=commo org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_record_declaration=common_lines org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines -org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=false +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true org.eclipse.jdt.core.formatter.tabulation.char=tab org.eclipse.jdt.core.formatter.tabulation.size=4 -org.eclipse.jdt.core.formatter.use_on_off_tags=false +org.eclipse.jdt.core.formatter.text_block_indentation=0 +org.eclipse.jdt.core.formatter.use_on_off_tags=true org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true +org.eclipse.jdt.core.formatter.wrap_before_assertion_message_operator=true org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false -org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true +org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true +org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_before_relational_operator=true +org.eclipse.jdt.core.formatter.wrap_before_shift_operator=true +org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true +org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter diff --git a/org.sf.feeling.decompiler/.settings/org.eclipse.jdt.ui.prefs b/org.sf.feeling.decompiler/.settings/org.eclipse.jdt.ui.prefs index ad000ceb..19923525 100644 --- a/org.sf.feeling.decompiler/.settings/org.eclipse.jdt.ui.prefs +++ b/org.sf.feeling.decompiler/.settings/org.eclipse.jdt.ui.prefs @@ -1,3 +1,106 @@ eclipse.preferences.version=1 -formatter_profile=_birt -formatter_settings_version=13 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +formatter_profile=org.eclipse.jdt.ui.default.eclipse_profile +formatter_settings_version=20 +sp_cleanup.add_all=false +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.arrays_fill=false +sp_cleanup.bitwise_conditional_expression=false +sp_cleanup.boolean_literal=false +sp_cleanup.break_loop=false +sp_cleanup.collection_cloning=false +sp_cleanup.comparison_statement=false +sp_cleanup.convert_functional_interfaces=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.convert_to_enhanced_for_loop_if_loop_var_used=false +sp_cleanup.convert_to_switch_expressions=false +sp_cleanup.correct_indentation=false +sp_cleanup.double_negation=false +sp_cleanup.else_if=false +sp_cleanup.embedded_if=false +sp_cleanup.evaluate_nullable=false +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=false +sp_cleanup.hash=false +sp_cleanup.if_condition=false +sp_cleanup.insert_inferred_type_arguments=false +sp_cleanup.instanceof=false +sp_cleanup.join=false +sp_cleanup.lazy_logical_operator=false +sp_cleanup.make_local_variable_final=true +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=true +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=false +sp_cleanup.map_cloning=false +sp_cleanup.merge_conditional_blocks=false +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.no_string_creation=false +sp_cleanup.no_super=false +sp_cleanup.number_suffix=false +sp_cleanup.objects_equals=false +sp_cleanup.on_save_use_additional_actions=false +sp_cleanup.organize_imports=true +sp_cleanup.overridden_assignment=false +sp_cleanup.precompile_regex=false +sp_cleanup.primitive_serialization=false +sp_cleanup.pull_up_assignment=false +sp_cleanup.push_down_negation=false +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=false +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.redundant_falling_through_block_end=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_redundant_modifiers=false +sp_cleanup.remove_redundant_semicolons=false +sp_cleanup.remove_redundant_type_arguments=false +sp_cleanup.remove_trailing_whitespaces=false +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_array_creation=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=false +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.simplify_lambda_expression_and_method_ref=false +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.strictly_equal_or_different=false +sp_cleanup.stringbuilder=false +sp_cleanup.switch=false +sp_cleanup.ternary_operator=false +sp_cleanup.try_with_resource=false +sp_cleanup.use_anonymous_class_creation=false +sp_cleanup.use_autoboxing=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_directly_map_method=false +sp_cleanup.use_lambda=true +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=false +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true +sp_cleanup.use_unboxing=false +sp_cleanup.use_var=false +sp_cleanup.useless_continue=false +sp_cleanup.useless_return=false diff --git a/org.sf.feeling.decompiler/.settings/org.eclipse.m2e.core.prefs b/org.sf.feeling.decompiler/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 00000000..f897a7f1 --- /dev/null +++ b/org.sf.feeling.decompiler/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/org.sf.feeling.decompiler/META-INF/MANIFEST.MF b/org.sf.feeling.decompiler/META-INF/MANIFEST.MF index e7be57d6..eb2cbc5f 100644 --- a/org.sf.feeling.decompiler/META-INF/MANIFEST.MF +++ b/org.sf.feeling.decompiler/META-INF/MANIFEST.MF @@ -1,62 +1,48 @@ Manifest-Version: 1.0 Bundle-ActivationPolicy: lazy -Bundle-ClassPath: lib/commons-codec-1.5.jar, - lib/fernflower.jar, - lib/json.jar, - lib/jsoup.jar, - library.jar, - lib/com.drgarbage.asm_5.0.3.jar, +Bundle-ClassPath: lib/com.drgarbage.asm_5.0.3.jar, lib/com.drgarbage.asm.util_5.0.3.jar, + lib/com.drgarbage.bytecodevisualizer.plugin_4.4.1.201408050542.jar, + lib/com.drgarbage.core.plugin_4.4.1.201408050542.jar, + lib/asm-9.1.jar, . -Bundle-Name: Eclipse Class Decompiler +Bundle-Name: Enhanced Class Decompiler Bundle-Localization: plugin -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Require-Bundle: org.eclipse.core.runtime, - org.eclipse.core.resources, +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Require-Bundle: org.eclipse.core.runtime;bundle-version="3.14.0", + org.eclipse.core.resources;bundle-version="3.13.0", org.eclipse.jface, org.eclipse.jface.text, org.eclipse.ui.editors, - org.eclipse.ui.workbench, + org.eclipse.ui.workbench;bundle-version="3.111.0", org.eclipse.ui.workbench.texteditor, - org.eclipse.jdt.core, + org.eclipse.jdt.core;bundle-version="3.14.0", org.eclipse.jdt.ui, - org.eclipse.jdt.debug, + org.eclipse.jdt.debug;bundle-version="3.11.100", org.eclipse.jdt.debug.ui, org.eclipse.debug.ui, org.eclipse.jdt.launching, - org.eclipse.core.expressions, + org.eclipse.core.expressions;bundle-version="3.6.100", org.eclipse.ui.navigator, org.eclipse.ui.views, org.eclipse.ui.ide;resolution:=optional, org.eclipse.search, - org.eclipse.core.filesystem, + org.eclipse.core.filesystem;bundle-version="1.7.100", org.eclipse.equinox.p2.metadata;resolution:=optional, org.eclipse.help.base -Bundle-Vendor: Chen Chao -Bundle-Version: 2.10.0.qualifier +Bundle-Vendor: ECD Project Team +Bundle-Version: 3.5.1 Bundle-ManifestVersion: 2 Bundle-Activator: org.sf.feeling.decompiler.JavaDecompilerPlugin Bundle-SymbolicName: org.sf.feeling.decompiler;singleton:=true Eclipse-ExtensibleAPI: true -Export-Package: com.eclipsesource.json, - org.jetbrains.java.decompiler.main, - org.jetbrains.java.decompiler.main.collectors, - org.jetbrains.java.decompiler.main.extern, - org.jetbrains.java.decompiler.struct, - org.jetbrains.java.decompiler.struct.lazy, - org.jsoup, - org.jsoup.helper, - org.jsoup.nodes, - org.jsoup.parser, - org.jsoup.safety, - org.jsoup.select, +Export-Package: org.objectweb.asm, org.sf.feeling.decompiler, org.sf.feeling.decompiler.actions, org.sf.feeling.decompiler.editor, org.sf.feeling.decompiler.extension, - org.sf.feeling.decompiler.fernflower, org.sf.feeling.decompiler.i18n, + org.sf.feeling.decompiler.postprocessing, org.sf.feeling.decompiler.preferences, org.sf.feeling.decompiler.source.attach, - org.sf.feeling.decompiler.update, org.sf.feeling.decompiler.util diff --git a/org.sf.feeling.decompiler/about.ini b/org.sf.feeling.decompiler/about.ini index f65e7885..c5b852d0 100644 --- a/org.sf.feeling.decompiler/about.ini +++ b/org.sf.feeling.decompiler/about.ini @@ -1,12 +1,9 @@ ############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). +# Copyright (c) 2017 Chen Chao and other ECD project contributors. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation +# https://www.eclipse.org/legal/epl-v10.html ############################################################################### # about.ini diff --git a/org.sf.feeling.decompiler/about.properties b/org.sf.feeling.decompiler/about.properties index 284427d2..baf20cc6 100644 --- a/org.sf.feeling.decompiler/about.properties +++ b/org.sf.feeling.decompiler/about.properties @@ -1,19 +1,34 @@ ############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). +# Copyright (c) 2017 Chen Chao and other ECD project contributors. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation +# https://www.eclipse.org/legal/epl-v10.html ############################################################################### -featureName=Eclipse Class Decompiler -featureText=Eclipse Class Decompiler \n\ +featureName=Enhanced Class Decompiler +featureText=Enhanced Class Decompiler \n\ Version: {1}\n\ Build id: {0}\n\ \n\ -Eclipse Class Decompiler plugin, Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). All rights reserved. \n\ -For more information on Eclipse Class Decompiler, visit http://www.cpupk.com/decompiler \n\ -For more information on other open source projects, visit http://www.cpupk.com \ No newline at end of file +Enhanced Class Decompiler plugin, Copyright (c) 2018 Chen Chao and other ECD project contributors. All rights reserved. \n\ +For more information on Enhanced Class Decompiler, visit https://ecd-plugin.github.io\n\ +\n\ +Code partially based on:\n\ +* JD-Eclipse: Copyright Emmanuel Dupuy, [GPL 3](https://www.gnu.org/licenses/gpl-3.0-standalone.html)\n\ +* Java Source Attacher: Copyright Thai Ha, [Apache License V2.0](https://www.apache.org/licenses/LICENSE-2.0.html)\n\ +\n\ +Used libraries by this feature and optional subprojects:\n\ +* Dr. Garbage Tools: Copyright � Dr. Garbage Ltd. & Co KG, Apache License V2.0 - https://www.apache.org/licenses/LICENSE-2.0.html\n\ +* Apache commons: Copyright � Apache Software Foundation, Apache License V2.0 - https://www.apache.org/licenses/LICENSE-2.0.html\n\ +* Fernflower: Copyright � JetBrains, Apache License V2.0 - https://www.apache.org/licenses/LICENSE-2.0.html\n\ +* Minimal JSON: Copyright � 2013, 2014 EclipseSource, MIT License - https://opensource.org/licenses/MIT\n\ +* CFR: Copyright Leee Benfield, MIT License - https://opensource.org/licenses/MIT\n\ +* Procyon: Copyright Mike Strobel, Apache License V2.0 - https://www.apache.org/licenses/LICENSE-2.0.html\n\ +* Netbeans CVSClient: Copyright � NetBeans Community, Eclipse Public License v1.0 - https://www.eclipse.org/legal/epl-v10.html and Apache License V2.0 - https://www.apache.org/licenses/LICENSE-2.0.html\n\ +* Maven SCM: Copyright � Apache Software Foundation, Apache License V2.0 - https://www.apache.org/licenses/LICENSE-2.0.html\n\ +* Nexus Indexer: Apache License V2.0 - https://www.apache.org/licenses/LICENSE-2.0.html\n\ +* Nexus Restlet1x Model: Eclipse Public License v1.0 - https://www.eclipse.org/legal/epl-v10.html\n\ +* Plexus Utils: Copyright The Codehaus Foundation, Apache License V2.0 - https://www.apache.org/licenses/LICENSE-2.0.html\n\ +* JD-Core: Copyright Emmanuel Dupuy, GPL 3 - https://www.gnu.org/licenses/gpl-3.0-standalone.html +* vineflower: Apache License 2.0 - https://www.apache.org/licenses/LICENSE-2.0.html\n\ \ No newline at end of file diff --git a/org.sf.feeling.decompiler/build.properties b/org.sf.feeling.decompiler/build.properties index c91b11f9..2d5ef673 100644 --- a/org.sf.feeling.decompiler/build.properties +++ b/org.sf.feeling.decompiler/build.properties @@ -1,12 +1,9 @@ ############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). +# Copyright (c) 2017 Chen Chao and other ECD project contributors. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation +# https://www.eclipse.org/legal/epl-v10.html ############################################################################### source.. = src/ @@ -16,14 +13,10 @@ bin.includes = META-INF/,\ about.ini,\ about.mappings,\ about.properties,\ - nl/,\ plugin.properties,\ plugin.xml,\ - plugin_zh_CN.properties,\ - plugin_zh_HK.properties,\ - plugin_zh_TW.properties,\ icons/,\ lib/,\ - doc/ + doc/,\ + lib/asm-9.1.jar jars.compile.order = . -qualifier = 20170815 diff --git a/org.sf.feeling.decompiler/lib/asm-9.1.jar b/org.sf.feeling.decompiler/lib/asm-9.1.jar new file mode 100644 index 00000000..82380198 Binary files /dev/null and b/org.sf.feeling.decompiler/lib/asm-9.1.jar differ diff --git a/org.sf.feeling.decompiler/lib/com.drgarbage.bytecodevisualizer.plugin_4.4.1.201408050542.jar b/org.sf.feeling.decompiler/lib/com.drgarbage.bytecodevisualizer.plugin_4.4.1.201408050542.jar new file mode 100644 index 00000000..0a262dc5 Binary files /dev/null and b/org.sf.feeling.decompiler/lib/com.drgarbage.bytecodevisualizer.plugin_4.4.1.201408050542.jar differ diff --git a/org.sf.feeling.decompiler/lib/com.drgarbage.core.plugin_4.4.1.201408050542.jar b/org.sf.feeling.decompiler/lib/com.drgarbage.core.plugin_4.4.1.201408050542.jar new file mode 100644 index 00000000..385e4228 Binary files /dev/null and b/org.sf.feeling.decompiler/lib/com.drgarbage.core.plugin_4.4.1.201408050542.jar differ diff --git a/org.sf.feeling.decompiler/lib/commons-codec-1.5.jar b/org.sf.feeling.decompiler/lib/commons-codec-1.5.jar deleted file mode 100644 index e9013fed..00000000 Binary files a/org.sf.feeling.decompiler/lib/commons-codec-1.5.jar and /dev/null differ diff --git a/org.sf.feeling.decompiler/lib/fernflower.jar b/org.sf.feeling.decompiler/lib/fernflower.jar deleted file mode 100644 index be77fd98..00000000 Binary files a/org.sf.feeling.decompiler/lib/fernflower.jar and /dev/null differ diff --git a/org.sf.feeling.decompiler/lib/json.jar b/org.sf.feeling.decompiler/lib/json.jar index a0b36278..14c06335 100644 Binary files a/org.sf.feeling.decompiler/lib/json.jar and b/org.sf.feeling.decompiler/lib/json.jar differ diff --git a/org.sf.feeling.decompiler/lib/jsoup.jar b/org.sf.feeling.decompiler/lib/jsoup.jar deleted file mode 100644 index 720b761b..00000000 Binary files a/org.sf.feeling.decompiler/lib/jsoup.jar and /dev/null differ diff --git a/org.sf.feeling.decompiler/nl/zh_CN/about.properties b/org.sf.feeling.decompiler/nl/zh_CN/about.properties deleted file mode 100644 index adcf9a52..00000000 --- a/org.sf.feeling.decompiler/nl/zh_CN/about.properties +++ /dev/null @@ -1,19 +0,0 @@ -############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation -############################################################################### - -featureName=Eclipse\u53CD\u7F16\u8BD1\u63D2\u4EF6 -featureText=Eclipse\u53CD\u7F16\u8BD1\u63D2\u4EF6 \n\ -\u7248\u672C: {1}\n\ -\u6784\u5EFAID: {0}\n\ -\n\ -Eclipse\u53CD\u7F16\u8BD1\u63D2\u4EF6\uFF0C\u7248\u6743\u6240\u6709 (c) 2017 Chen Chao(cnfree2000@hotmail.com)\uFF0C\u4FDD\u7559\u6240\u6709\u6743\u5229\u3002 \n\ -\u6709\u5173Eclipse\u53CD\u7F16\u8BD1\u63D2\u4EF6\u7684\u8BE6\u7EC6\u4FE1\u606F\uFF0C\u8BF7\u8BBF\u95EE http://www.blogjava.net/cnfree/archive/2012/10/30/390457.html \n\ -\u6709\u5173\u5176\u4ED6\u5F00\u6E90\u9879\u76EE\u7684\u8BE6\u7EC6\u4FE1\u606F\uFF0C\u8BF7\u8BBF\u95EE http://opensource.cpupk.com \u6216\u8005 http://www.blogjava.net/cnfree \ No newline at end of file diff --git a/org.sf.feeling.decompiler/nl/zh_HK/about.properties b/org.sf.feeling.decompiler/nl/zh_HK/about.properties deleted file mode 100644 index 93c060ae..00000000 --- a/org.sf.feeling.decompiler/nl/zh_HK/about.properties +++ /dev/null @@ -1,19 +0,0 @@ -############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation -############################################################################### - -featureName=Eclipse\u53CD\u7DE8\u8B6F\u63D2\u4EF6 -featureText=Eclipse\u53CD\u7DE8\u8B6F\u63D2\u4EF6 \n\ -\u7248\u672C: {1}\n\ -\u69CB\u5EFAID: {0}\n\ -\n\ -Eclipse\u53CD\u7DE8\u8B6F\u63D2\u4EF6\uFF0C\u7248\u6B0A\u6240\u6709(c) 2017 Chen Chao(cnfree2000@hotmail.com)\uFF0C\u4FDD\u7559\u6240\u6709\u6B0A\u5229\u3002 \n\ -\u6709\u95DCEclipse\u53CD\u7DE8\u8B6F\u63D2\u4EF6\u7684\u8A73\u7D30\u4FE1\u606F\uFF0C\u8ACB\u8A2A\u554Fhttp://www.blogjava.net/cnfree/archive/2012/10/30/390457.html \n\ -\u6709\u95DC\u5176\u4ED6\u958B\u6E90\u9805\u76EE\u7684\u8A73\u7D30\u4FE1\u606F\uFF0C\u8ACB\u8A2A\u554F http://opensource.cpupk.com \u6216\u8005 http://www.blogjava.net/cnfree \ No newline at end of file diff --git a/org.sf.feeling.decompiler/nl/zh_TW/about.properties b/org.sf.feeling.decompiler/nl/zh_TW/about.properties deleted file mode 100644 index 93c060ae..00000000 --- a/org.sf.feeling.decompiler/nl/zh_TW/about.properties +++ /dev/null @@ -1,19 +0,0 @@ -############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation -############################################################################### - -featureName=Eclipse\u53CD\u7DE8\u8B6F\u63D2\u4EF6 -featureText=Eclipse\u53CD\u7DE8\u8B6F\u63D2\u4EF6 \n\ -\u7248\u672C: {1}\n\ -\u69CB\u5EFAID: {0}\n\ -\n\ -Eclipse\u53CD\u7DE8\u8B6F\u63D2\u4EF6\uFF0C\u7248\u6B0A\u6240\u6709(c) 2017 Chen Chao(cnfree2000@hotmail.com)\uFF0C\u4FDD\u7559\u6240\u6709\u6B0A\u5229\u3002 \n\ -\u6709\u95DCEclipse\u53CD\u7DE8\u8B6F\u63D2\u4EF6\u7684\u8A73\u7D30\u4FE1\u606F\uFF0C\u8ACB\u8A2A\u554Fhttp://www.blogjava.net/cnfree/archive/2012/10/30/390457.html \n\ -\u6709\u95DC\u5176\u4ED6\u958B\u6E90\u9805\u76EE\u7684\u8A73\u7D30\u4FE1\u606F\uFF0C\u8ACB\u8A2A\u554F http://opensource.cpupk.com \u6216\u8005 http://www.blogjava.net/cnfree \ No newline at end of file diff --git a/org.sf.feeling.decompiler/plugin.properties b/org.sf.feeling.decompiler/plugin.properties index d5a62f70..90c35c6f 100644 --- a/org.sf.feeling.decompiler/plugin.properties +++ b/org.sf.feeling.decompiler/plugin.properties @@ -1,12 +1,9 @@ ############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). +# Copyright (c) 2017 Chen Chao and other ECD project contributors. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation +# https://www.eclipse.org/legal/epl-v10.html ############################################################################### DecompilerView=Class Decompiler Viewer diff --git a/org.sf.feeling.decompiler/plugin.xml b/org.sf.feeling.decompiler/plugin.xml index 99e56ff0..7b36adf6 100644 --- a/org.sf.feeling.decompiler/plugin.xml +++ b/org.sf.feeling.decompiler/plugin.xml @@ -1,14 +1,11 @@ @@ -105,7 +102,7 @@ + name="Enhanced Class Decompiler"> - - diff --git a/org.sf.feeling.decompiler/plugin_zh_CN.properties b/org.sf.feeling.decompiler/plugin_zh_CN.properties deleted file mode 100644 index 21636d2a..00000000 --- a/org.sf.feeling.decompiler/plugin_zh_CN.properties +++ /dev/null @@ -1,26 +0,0 @@ -############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation -############################################################################### - -DecompilerView=\u7c7b\u53cd\u7f16\u8bd1\u67e5\u770b\u5668 -Decompiler=\u53cd\u7f16\u8bd1\u5668 -Disassembler=\u53CD\u6C47\u7F16 -DecompilerBar=\u53cd\u7f16\u8bd1\u5668(&D) -DecompilerAction=\u53cd\u7f16\u8bd1\u5668(&E)@Ctrl+Alt+, -Preferences=\u9996\u9009\u9879(&P) -ExportSource=\u5bfc\u51fa\u53cd\u7f16\u8bd1\u6e90\u7801(&S)... -DebugMode=\u8C03\u8BD5\u6A21\u5F0F(&M)@Ctrl+Alt+. -ShowDisassembler=\u663E\u793A\u53CD\u6C47\u7F16\u4EE3\u7801(&L) -ShowByteCode=\u663E\u793A\u5B57\u8282\u7801(&B) -ShowSourceCode=\u663E\u793A\u6E90\u4EE3\u7801(&C) -Decompiler.Filter.Description=\u9690\u85cf\u7c7b\u53cd\u7f16\u8bd1\u5668\u4e34\u65f6\u6784\u5efa\u9879\u76ee. -Decompiler.Filter=\u7c7b\u53cd\u7f16\u8bd1\u5668\u4e34\u65f6\u6784\u5efa\u9879\u76ee -Opcode.Hover.Lable=JVM Opcode Doc -Opcode.Hover.Description=\u663E\u793A\u9009\u4E2D\u7684JVM\u64CD\u4F5C\u7801\u6587\u6863\u3002 \ No newline at end of file diff --git a/org.sf.feeling.decompiler/plugin_zh_HK.properties b/org.sf.feeling.decompiler/plugin_zh_HK.properties deleted file mode 100644 index a7a99124..00000000 --- a/org.sf.feeling.decompiler/plugin_zh_HK.properties +++ /dev/null @@ -1,26 +0,0 @@ -############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation -############################################################################### - -DecompilerView=\u985e\u53cd\u7de8\u8b6f\u67e5\u770b\u5668 -Decompiler=\u53cd\u7de8\u8b6f\u5668 -Disassembler=\u53CD\u532F\u7DE8 -DecompilerBar=\u53cd\u7de8\u8b6f\u5668(&D) -DecompilerAction=\u53cd\u7de8\u8b6f\u5668(&E)@Ctrl+Alt+, -Preferences=\u9996\u9078\u9805(&P) -ExportSource=\u5c0e\u51fa\u53cd\u7de8\u8b6f\u6e90\u78bc(&S)... -DebugMode=\u8ABF\u8A66\u6A21\u5F0F(&M)@Ctrl+Alt+. -ShowDisassembler=\u986F\u793A\u53CD\u532F\u7DE8\u4EE3\u78BC(&L) -ShowByteCode=\u986F\u793A\u5B57\u7BC0\u78BC(&B) -ShowSourceCode=\u986F\u793A\u6E90\u4EE3\u78BC(&C) -Decompiler.Filter.Description=\u96b1\u85cf\u985e\u53cd\u7de8\u8b6f\u5668\u81e8\u6642\u69cb\u5efa\u9805\u76ee. -Decompiler.Filter=\u985e\u53cd\u7de8\u8b6f\u5668\u81e8\u6642\u69cb\u5efa\u9805\u76ee -Opcode.Hover.Lable=JVM Opcode Doc -Opcode.Hover.Description=\u986F\u793A\u9078\u4E2D\u7684JVM\u64CD\u4F5C\u78BC\u6587\u6A94\u3002 \ No newline at end of file diff --git a/org.sf.feeling.decompiler/plugin_zh_TW.properties b/org.sf.feeling.decompiler/plugin_zh_TW.properties deleted file mode 100644 index a7a99124..00000000 --- a/org.sf.feeling.decompiler/plugin_zh_TW.properties +++ /dev/null @@ -1,26 +0,0 @@ -############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation -############################################################################### - -DecompilerView=\u985e\u53cd\u7de8\u8b6f\u67e5\u770b\u5668 -Decompiler=\u53cd\u7de8\u8b6f\u5668 -Disassembler=\u53CD\u532F\u7DE8 -DecompilerBar=\u53cd\u7de8\u8b6f\u5668(&D) -DecompilerAction=\u53cd\u7de8\u8b6f\u5668(&E)@Ctrl+Alt+, -Preferences=\u9996\u9078\u9805(&P) -ExportSource=\u5c0e\u51fa\u53cd\u7de8\u8b6f\u6e90\u78bc(&S)... -DebugMode=\u8ABF\u8A66\u6A21\u5F0F(&M)@Ctrl+Alt+. -ShowDisassembler=\u986F\u793A\u53CD\u532F\u7DE8\u4EE3\u78BC(&L) -ShowByteCode=\u986F\u793A\u5B57\u7BC0\u78BC(&B) -ShowSourceCode=\u986F\u793A\u6E90\u4EE3\u78BC(&C) -Decompiler.Filter.Description=\u96b1\u85cf\u985e\u53cd\u7de8\u8b6f\u5668\u81e8\u6642\u69cb\u5efa\u9805\u76ee. -Decompiler.Filter=\u985e\u53cd\u7de8\u8b6f\u5668\u81e8\u6642\u69cb\u5efa\u9805\u76ee -Opcode.Hover.Lable=JVM Opcode Doc -Opcode.Hover.Description=\u986F\u793A\u9078\u4E2D\u7684JVM\u64CD\u4F5C\u78BC\u6587\u6A94\u3002 \ No newline at end of file diff --git a/org.sf.feeling.decompiler/pom.xml b/org.sf.feeling.decompiler/pom.xml new file mode 100644 index 00000000..2fecf398 --- /dev/null +++ b/org.sf.feeling.decompiler/pom.xml @@ -0,0 +1,16 @@ + + 4.0.0 + + + com.github.ecd-plugin + com.github.ecd-plugin.ecd + 3.5.1 + ../pom.xml + + + org.sf.feeling.decompiler + eclipse-plugin + + diff --git a/org.sf.feeling.decompiler/schema/decompilerAdapters.exsd b/org.sf.feeling.decompiler/schema/decompilerAdapters.exsd index 116fb8d6..297525c8 100644 --- a/org.sf.feeling.decompiler/schema/decompilerAdapters.exsd +++ b/org.sf.feeling.decompiler/schema/decompilerAdapters.exsd @@ -3,7 +3,7 @@ - + [Enter description of this extension point.] diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/impl/AbstractClassFileDocument.java b/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/impl/AbstractClassFileDocument.java deleted file mode 100644 index 264a1e53..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/impl/AbstractClassFileDocument.java +++ /dev/null @@ -1,4378 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.asm.render.impl; - -import java.io.IOException; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; - -import org.eclipse.jface.preference.IPreferenceStore; -import org.sf.feeling.decompiler.JavaDecompilerPlugin; - -import com.drgarbage.asm.AnnotationVisitor; -import com.drgarbage.asm.Attribute; -import com.drgarbage.asm.ClassVisitor; -import com.drgarbage.asm.FieldVisitor; -import com.drgarbage.asm.Label; -import com.drgarbage.asm.MethodVisitor; -import com.drgarbage.asm.Type; -import com.drgarbage.asm.render.impl.ClassFileDocument.ExceptionTableEntryComparator; -import com.drgarbage.asm.render.impl.ClassFileDocument.ListMap; -import com.drgarbage.asm.render.intf.IClassFileDocument; -import com.drgarbage.asm.render.intf.IFieldSection; -import com.drgarbage.asm.render.intf.IInstructionLine; -import com.drgarbage.asm.render.intf.ILocalVariableTable; -import com.drgarbage.asm.render.intf.IMethodSection; -import com.drgarbage.asm.render.intf.ITryBlock; -import com.drgarbage.asm.signature.SignatureReader; -import com.drgarbage.asm.signature.SignatureVisitor; -import com.drgarbage.asm_ext.ICodeVisitor; -import com.drgarbage.asm_ext.IConstantPoolVisitor; -import com.drgarbage.asm_ext.ILocalVariableTableVisitor; -import com.drgarbage.bytecode.ByteCodeConstants; -import com.drgarbage.bytecode.ByteCodeConstants.Align; -import com.drgarbage.bytecode.BytecodeUtils; -import com.drgarbage.bytecode.ConstantPoolParser; -import com.drgarbage.bytecode.ExceptionTableEntry; -import com.drgarbage.bytecode.InstructionParser; -import com.drgarbage.bytecode.LineNumberTableEntry; -import com.drgarbage.bytecode.LocalVariableTableEntry; -import com.drgarbage.bytecode.LocalVariableTypeTableEntry; -import com.drgarbage.bytecode.constant_pool.AbstractConstantPoolEntry; -import com.drgarbage.bytecode.constant_pool.ConstantClassInfo; -import com.drgarbage.bytecode.constant_pool.ConstantDoubleInfo; -import com.drgarbage.bytecode.constant_pool.ConstantFieldrefInfo; -import com.drgarbage.bytecode.constant_pool.ConstantFloatInfo; -import com.drgarbage.bytecode.constant_pool.ConstantIntegerInfo; -import com.drgarbage.bytecode.constant_pool.ConstantInterfaceMethodrefInfo; -import com.drgarbage.bytecode.constant_pool.ConstantInvokeDynamicInfo; -import com.drgarbage.bytecode.constant_pool.ConstantLongInfo; -import com.drgarbage.bytecode.constant_pool.ConstantMethodHandleInfo; -import com.drgarbage.bytecode.constant_pool.ConstantMethodTypeInfo; -import com.drgarbage.bytecode.constant_pool.ConstantMethodrefInfo; -import com.drgarbage.bytecode.constant_pool.ConstantNameAndTypeInfo; -import com.drgarbage.bytecode.constant_pool.ConstantStringInfo; -import com.drgarbage.bytecode.constant_pool.ConstantUtf8Info; -import com.drgarbage.bytecode.instructions.AbstractInstruction; -import com.drgarbage.bytecode.instructions.BranchInstruction; -import com.drgarbage.bytecode.instructions.IConstantPoolIndexProvider; -import com.drgarbage.bytecode.instructions.ILocalVariableIndexProvider; -import com.drgarbage.bytecode.instructions.ImmediateByteInstruction; -import com.drgarbage.bytecode.instructions.ImmediateIntInstruction; -import com.drgarbage.bytecode.instructions.ImmediateShortInstruction; -import com.drgarbage.bytecode.instructions.IncrementInstruction; -import com.drgarbage.bytecode.instructions.InvokeInterfaceInstruction; -import com.drgarbage.bytecode.instructions.LookupSwitchInstruction; -import com.drgarbage.bytecode.instructions.LookupSwitchInstruction.MatchOffsetEntry; -import com.drgarbage.bytecode.instructions.MultianewarrayInstruction; -import com.drgarbage.bytecode.instructions.NewArrayInstruction; -import com.drgarbage.bytecode.instructions.SimpleInstruction; -import com.drgarbage.bytecode.instructions.TableSwitchInstruction; -import com.drgarbage.javasrc.JavaAnnotations; -import com.drgarbage.javasrc.JavaKeywords; -import com.drgarbage.javasrc.JavaLexicalConstants; -import com.drgarbage.javasrc.JavaSourceUtils; - -public abstract class AbstractClassFileDocument extends ClassVisitor implements - com.drgarbage.asm.Opcodes, - IClassFileDocument, - IConstantPoolVisitor -{ - - protected abstract class AbstractClassFileElement extends MethodVisitor - { - - // ------------------------------------------------------------------------ - // Utility methods - // ------------------------------------------------------------------------ - - public AbstractClassFileElement( int arg0 ) - { - super( arg0 ); - } - - /** - * Appends an internal name, a type descriptor or a type signature to - * {@link #buf buf}. - * - * @param type - * indicates if desc is an internal name, a field descriptor, - * a method descriptor, a class signature, ... - * @param desc - * an internal name, type descriptor, or type signature. May - * be null. - */ - protected void appendDescriptor( final int type, final String desc ) - { - // TODO: test this - sb.append( desc ); - } - - } - - protected abstract class AbstractMethodRenderer extends AbstractClassFileElement implements - com.drgarbage.asm.Opcodes, - ICodeVisitor, - ILocalVariableTableVisitor, - IMethodSection - { - - protected class Block - { - - protected TryBlock enclosingTryBlock; - protected int endLine = ByteCodeConstants.INVALID_OFFSET; - protected int endOffset = ByteCodeConstants.INVALID_OFFSET; - protected String startKeyWord; - protected int startLine = ByteCodeConstants.INVALID_OFFSET; - protected int startOffset = ByteCodeConstants.INVALID_OFFSET; - - public Block( TryBlock parent, String startKeyWord, int start ) - { - super( ); - this.enclosingTryBlock = parent; - this.startKeyWord = startKeyWord; - this.startOffset = start; - } - - public Block( TryBlock parent, String startKeyWord, int startOffset, int endOffset ) - { - super( ); - this.enclosingTryBlock = parent; - this.startKeyWord = startKeyWord; - this.startOffset = startOffset; - this.endOffset = endOffset; - } - - public void appendEnd( ) - { - - endLine = AbstractClassFileDocument.this.lineCount; - - if ( renderTryCatchFinallyBlocks ) - { - decrementIndent( ); - appendRightBrace( ); - // append(" /* endOffset of try */"); - appendNewline( ); - } - } - - public void appendStart( ) - { - - startLine = AbstractClassFileDocument.this.lineCount; - - if ( renderTryCatchFinallyBlocks ) - { - append( startKeyWord ); - appendSpace( ); - appendLeftBrace( ); - appendNewline( ); - incrementIndent( ); - } - } - - public boolean encloses( ExceptionTableEntry en ) - { - if ( en == null ) - { - return false; - } - else - { - return en.getStartPc( ) >= startOffset && en.getEndPc( ) <= endOffset; - } - } - - public int getEndLine( ) - { - return endLine; - } - - public int getStartLine( ) - { - return startLine; - } - - } - - protected class CatchBlock extends FinallyBlock - { - - protected String catchType; - protected String variableName; - - public CatchBlock( TryBlock parent, ExceptionTableEntry en ) - { - super( parent, en.getHandlerPc( ) ); - startKeyWord = JavaKeywords.CATCH; - - if ( constantPool == null ) - { - catchType = String.valueOf( ByteCodeConstants.UNKNOWN_INFORMATION ); - } - else - { - AbstractConstantPoolEntry cpInfo = constantPool[en.getCatchType( )]; - if ( cpInfo instanceof ConstantClassInfo ) - { - ConstantClassInfo constantClassInfo = (ConstantClassInfo) cpInfo; - String name = ( (ConstantUtf8Info) constantPool[constantClassInfo.getNameIndex( )] ) - .getString( ); - catchType = name.replace( ByteCodeConstants.CLASS_NAME_SLASH, JavaLexicalConstants.DOT ); - } - } - } - - @Override - public void appendStart( ) - { - startLine = AbstractClassFileDocument.this.lineCount; - - if ( renderTryCatchFinallyBlocks ) - { - append( JavaKeywords.CATCH ); - appendSpace( ); - appendLeftParenthesis( ); - - if ( catchType != null ) - { - append( catchType ); - } - - appendRightParenthesis( ); - appendSpace( ); - appendLeftBrace( ); - - appendStartComment( ); - - appendNewline( ); - incrementIndent( ); - } - } - - } - - protected class FinallyBlock extends Block - { - - public FinallyBlock( TryBlock parent, int start ) - { - super( parent, JavaKeywords.FINALLY, start ); - } - - public FinallyBlock( TryBlock parent, int start, int end ) - { - super( parent, JavaKeywords.FINALLY, start, end ); - } - - @Override - public void appendStart( ) - { - startLine = AbstractClassFileDocument.this.lineCount; - - if ( renderTryCatchFinallyBlocks ) - { - append( startKeyWord ); - appendSpace( ); - appendLeftBrace( ); - - appendStartComment( ); - - appendNewline( ); - incrementIndent( ); - } - } - - protected void appendStartComment( ) - { - appendPaddedCommentBegin( ); - appendSpace( ); - append( formatCoversBytesXToY.format( new Object[]{ - enclosingTryBlock.startOffset, enclosingTryBlock.endOffset - } ) ); - appendSpace( ); - appendCommentEnd( ); - } - - } - - protected class TryBlock extends Block implements ITryBlock - { - - protected List catchBlocks; - protected int enclosedGotoTarget = ByteCodeConstants.INVALID_OFFSET; - protected List enclosedTryBlocks; - - private FinallyBlock finallyBlock; - - public TryBlock( ExceptionTableEntry en ) - { - this( null, en.getStartPc( ), en.getEndPc( ) ); - // if (tryBlocks == null) { - // tryBlocks = new ArrayList(); - // } - // tryBlocks.add(this); - - adoptHandler( en ); - } - - public TryBlock( TryBlock parent, int start, int end ) - { - super( parent, JavaKeywords.TRY, start, end ); - // if (tryBlocks == null) { - // tryBlocks = new ArrayList(); - // } - // tryBlocks.add(this); - } - - private void adoptHandler( ExceptionTableEntry en ) - { - if ( en.getCatchType( ) == 0 ) - { - /* finally handler */ - if ( finallyBlock != null ) - { - /* this should not happen */ - throw new IllegalStateException( ); - } - finallyBlock = new FinallyBlock( this, en.getHandlerPc( ) ); - } - else - { - /* the catch block */ - if ( catchBlocks == null ) - { - catchBlocks = new ArrayList( ); - } - catchBlocks.add( new CatchBlock( this, en ) ); - } - } - - public void computeHandlersEnds( Map offsetInstructionMap ) - { - if ( enclosedTryBlocks != null ) - { - for ( TryBlock t : enclosedTryBlocks ) - { - t.computeHandlersEnds( offsetInstructionMap ); - } - } - - if ( catchBlocks != null ) - { - CatchBlock lastCatchBlock = null; - for ( CatchBlock c : catchBlocks ) - { - if ( lastCatchBlock != null && lastCatchBlock.endOffset == ByteCodeConstants.INVALID_OFFSET ) - { - lastCatchBlock.endOffset = c.startOffset; - - blockStarts.putToList( lastCatchBlock.startOffset, lastCatchBlock ); - blockEnds.putToList( lastCatchBlock.endOffset, lastCatchBlock ); - } - lastCatchBlock = c; - } - if ( lastCatchBlock != null && lastCatchBlock.endOffset == ByteCodeConstants.INVALID_OFFSET ) - { - - AbstractInstruction inst = offsetInstructionMap.get( endOffset ); - int gotoTarget = Integer.MAX_VALUE; - if ( inst instanceof BranchInstruction ) - { - BranchInstruction bi = (BranchInstruction) inst; - gotoTarget = bi.getOffset( ) + bi.getBranchOffset( ); - if ( enclosingTryBlock.enclosedGotoTarget == ByteCodeConstants.INVALID_OFFSET ) - { - enclosingTryBlock.enclosedGotoTarget = gotoTarget; - } - } - lastCatchBlock.endOffset = Math.min( enclosingTryBlock.endOffset, gotoTarget ); - blockStarts.putToList( lastCatchBlock.startOffset, lastCatchBlock ); - blockEnds.putToList( lastCatchBlock.endOffset, lastCatchBlock ); - - } - } - - if ( finallyBlock != null ) - { - AbstractInstruction inst = offsetInstructionMap.get( endOffset ); - int gotoTarget = Integer.MAX_VALUE; - if ( inst instanceof BranchInstruction ) - { - if ( inst instanceof BranchInstruction ) - { - BranchInstruction bi = (BranchInstruction) inst; - gotoTarget = bi.getOffset( ) + bi.getBranchOffset( ); - } - } - if ( enclosingTryBlock.endOffset >= gotoTarget ) - { - finallyBlock.endOffset = gotoTarget; - } - else - { - /* - * the above did not function we have to find some - * better way - */ - if ( this.enclosedGotoTarget != ByteCodeConstants.INVALID_OFFSET ) - { - finallyBlock.endOffset = Math.min( enclosingTryBlock.endOffset, this.enclosedGotoTarget ); - } - else - { - finallyBlock.endOffset = enclosingTryBlock.endOffset; - } - } - blockStarts.putToList( finallyBlock.startOffset, finallyBlock ); - blockEnds.putToList( finallyBlock.endOffset, finallyBlock ); - } - - blockStarts.putToList( startOffset, this ); - blockEnds.putToList( endOffset, this ); - - } - - public TryBlock createEnclosedTryBlock( ExceptionTableEntry en ) - { - if ( en.getStartPc( ) < startOffset || en.getEndPc( ) > endOffset ) - { - throw new IllegalArgumentException( ); - } - TryBlock result = null; - if ( en.getStartPc( ) == startOffset - && en.getEndPc( ) == endOffset - && ( en.getCatchType( ) != 0 || this.finallyBlock == null ) ) - { - /* - * this covers the same area and the handler to add is - * either not finally or finallyBlock is not set yet only - * add handlers - */ - result = this; - } - else - { - /* enclosed try block */ - result = new TryBlock( this, en.getStartPc( ), en.getEndPc( ) ); - if ( enclosedTryBlocks == null ) - { - enclosedTryBlocks = new ArrayList( ); - } - enclosedTryBlocks.add( result ); - } - - result.adoptHandler( en ); - - return result; - } - - public List getExceptionHandlerLines( ) - { - int cnt = 0; - if ( catchBlocks != null ) - { - cnt += catchBlocks.size( ); - } - if ( finallyBlock != null ) - { - cnt++; - } - if ( cnt > 0 ) - { - ArrayList result = new ArrayList( cnt ); - if ( catchBlocks != null ) - { - for ( CatchBlock cb : catchBlocks ) - { - result.add( Integer.valueOf( cb.getStartLine( ) ) ); - } - } - if ( finallyBlock != null ) - { - result.add( Integer.valueOf( finallyBlock.getStartLine( ) ) ); - } - return result; - } - else - { - return null; - } - } - - } - - protected int access; - private ListMap blockEnds = new ListMap( ); - private ListMap blockStarts = new ListMap( ); - - protected int currentLineNumberTableIndex = 0; - - protected String descriptor; - - protected String[] exceptions; - - protected int firstLine = ByteCodeConstants.INVALID_LINE; - - private ArrayList instructionLines = new ArrayList( ); - - private List instructions; - - protected boolean isConstructor = false; - - protected int lastLine = ByteCodeConstants.INVALID_LINE; - - private LineNumberTableEntry[] lineNumberTable; - private ExceptionTableEntry[] exceptionTable; - protected ILocalVariableTable localVariableTable; - - /** - * The {@link MethodVisitor} to which this visitor delegates calls. May - * be null. - */ - protected MethodVisitor mv; - protected String name; - private Map offsetInstructionMap; - private TryBlock openedTryBlock; - private List rootTryBlocks; - protected String signature; - private int max_stack = ByteCodeConstants.INVALID_OFFSET; - private int max_locals = ByteCodeConstants.INVALID_OFFSET; - - private List tryBlocks; - - /** - * Constructs a new {@link AbstractMethodRenderer}. - */ - public AbstractMethodRenderer( int access, String name, String descriptor, String signature, - String[] exceptions ) - { - this( access, name, descriptor, signature, exceptions, null ); - } - - /** - * Constructs a new {@link AbstractMethodRenderer}. - * - * @param mv - * the {@link MethodVisitor} to which this visitor delegates - * calls. May be null. - */ - public AbstractMethodRenderer( int access, String name, String descriptor, String signature, - String[] exceptions, final MethodVisitor mv ) - { - super( com.drgarbage.asm.Opcodes.ASM4 ); - this.access = access; - this.name = name; - this.descriptor = descriptor; - this.exceptions = exceptions; - this.mv = mv; - } - - protected abstract ILocalVariableTable createLocalVariableTable( boolean available ); - - private TryBlock findEnclosingTryBlock( ExceptionTableEntry en ) - { - TryBlock b = openedTryBlock; - while ( b != null ) - { - if ( b.encloses( en ) ) - { - return b; - } - b = b.enclosingTryBlock; - } - return null; - } - - /* - * (non-Javadoc) - * - * @see - * com.drgarbage.asm.render.intf.IMethodSection#getLocalVariableTable() - */ - public ILocalVariableTable getLocalVariableTable( ) - { - return localVariableTable; - } - - /* - * (non-Javadoc) - * - * @see com.drgarbage.asm.render.intf.IMethodSection# - * isLocalVariableTableAvailable() - */ - public boolean isLocalVariableTableAvailable( ) - { - if ( localVariableTable == null ) - return false; - - return localVariableTable.isAvailable( ); - } - - /* - * (non-Javadoc) - * - * @see com.drgarbage.asm.render.intf.IMethodSection#getExceptionTable() - */ - public ExceptionTableEntry[] getExceptionTable( ) - { - return exceptionTable; - } - - /* - * (non-Javadoc) - * - * @see com.drgarbage.asm.render.intf.IMethodSection# - * isExceptionTableAvailable() - */ - public boolean isExceptionTableAvailable( ) - { - if ( exceptionTable == null || exceptionTable.length == 0 ) - { - return false; - } - - return true; - } - - /* - * (non-Javadoc) - * - * @see com.drgarbage.asm.render.intf.IMethodSection#getMaxStack() - */ - public int getMaxStack( ) - { - return max_stack; - } - - /* - * (non-Javadoc) - * - * @see com.drgarbage.asm.render.intf.IMethodSection#getMaxLocals() - */ - public int getMaxLocals( ) - { - return max_locals; - } - - /* - * (non-Javadoc) - * - * @see com.drgarbage.asm.render.intf.IMethodSection#findOffsetLine(int) - */ - public int findOffsetLine( int offset ) - { - List ils = getInstructionLines( ); - if ( ils != null && ils.size( ) > 0 ) - { - for ( IInstructionLine il : ils ) - { - if ( il.getInstruction( ).getOffset( ) == offset ) - { - return il.getLine( ); - } - } - } - return IInstructionLine.INVALID_LINE; - } - - /* - * (non-Javadoc) - * - * @see com.drgarbage.asm.render.intf.IMethodSection#getDocLine(int) - */ - public int getBytecodeLine( int sourceCodeLine ) - { - if ( lineNumberTable == null - || lineNumberTable.length == 0 - || sourceCodeLine == ByteCodeConstants.INVALID_OFFSET - - /* - * if there are no instructions we will find nothing either - */ - || instructionLines.size( ) == 0 ) - { - return ByteCodeConstants.INVALID_OFFSET; - } - - int offset = lookUpLineNumberTableForStartPC( sourceCodeLine ); - - int byteCodeDocLine = ByteCodeConstants.INVALID_OFFSET; - int n = instructionLines.size( ); - for ( int i = 0; i < n; i++ ) - { - IInstructionLine il = instructionLines.get( i ); - - if ( offset == il.getInstruction( ).getOffset( ) ) - { - byteCodeDocLine = il.getLine( ); - break; - } - } - - /* not found */ - return byteCodeDocLine; - } - - /** - * @return the descriptor - */ - public String getDescriptor( ) - { - return descriptor; - } - - // ------------------------------------------------------------------------ - // Implementation of the MethodVisitor interface - // ------------------------------------------------------------------------ - - /* - * (non-Javadoc) - * - * @see - * com.drgarbage.classfile.render.intf.IMethodSection#getFirstLine() - */ - public int getFirstLine( ) - { - return firstLine; - } - - /* - * (non-Javadoc) - * - * @see com.drgarbage.classfile.render.intf.IMethodSection# - * getInstructionLines() - */ - public List getInstructionLines( ) - { - return instructionLines; - } - - /* - * (non-Javadoc) - * - * @see com.drgarbage.classfile.render.intf.IMethodSection#getLastLine() - */ - public int getLastLine( ) - { - return lastLine; - } - - /** - * @return the name - */ - public String getName( ) - { - return name; - } - - /* - * (non-Javadoc) - * - * @see - * com.drgarbage.asm.render.intf.IMethodSection#getSourceCodeLine(int) - */ - public int getSourceCodeLine( int byteCodeDocLine ) - { - - if ( lineNumberTable == null - || lineNumberTable.length == 0 - || byteCodeDocLine < firstLine - || byteCodeDocLine > lastLine - - /* - * if there are no instructions we will find nothing either - */ - || instructionLines.size( ) == 0 ) - { - return ByteCodeConstants.INVALID_OFFSET; - } - - int offset = ByteCodeConstants.INVALID_OFFSET; - int n = instructionLines.size( ); - for ( int i = 0; i < n; i++ ) - { - IInstructionLine il = instructionLines.get( i ); - if ( byteCodeDocLine <= il.getLine( ) ) - { - offset = il.getInstruction( ).getOffset( ); - break; - } - } - if ( offset == ByteCodeConstants.INVALID_OFFSET ) - { - /* - * if we have not found it yet we are after the last instruction - * let us use the offset of the last instruction - */ - offset = instructionLines.get( n - 1 ).getInstruction( ).getOffset( ); - } - - return lookUpLineNumberTable( offset ); - } - - /* - * (non-Javadoc) - * - * @see - * com.drgarbage.classfile.render.intf.IMethodSection#getTryBlocks() - */ - public List getTryBlocks( ) - { - return tryBlocks; - } - - /* - * (non-Javadoc) - * - * @see com.drgarbage.asm.render.intf.IMethodSection#hasCode() - */ - public boolean hasCode( ) - { - return !isNative( ) && !isAbstract( ); - } - - /* - * (non-Javadoc) - * - * @see - * com.drgarbage.asm.render.intf.IMethodSection#hasLineNumberTable() - */ - public boolean hasLineNumberTable( ) - { - return lineNumberTable != null; - } - - /* - * (non-Javadoc) - * - * @see com.drgarbage.classfile.render.intf.IMethodSection#isAbstract() - */ - public boolean isAbstract( ) - { - return ( access & ACC_ABSTRACT ) != 0; - } - - /* - * (non-Javadoc) - * - * @see com.drgarbage.asm.render.intf.IMethodSection#isConstructor() - */ - public boolean isConstructor( ) - { - return isConstructor; - } - - /* - * (non-Javadoc) - * - * @see com.drgarbage.asm.render.intf.IMethodSection#isNative() - */ - public boolean isNative( ) - { - return ( access & ACC_NATIVE ) != 0; - } - - private int lookUpLineNumberTable( int offset ) - { - if ( offset != ByteCodeConstants.INVALID_OFFSET ) - { - - /* - * Added by Sergej on 08.05.2008 FIX: if the lineNumberTable - * includes only one entry, then this entry is valid for all - * offsets. - */ - if ( lineNumberTable.length == 1 ) - { - LineNumberTableEntry en = lineNumberTable[0]; - return en.getLineNumber( ); - } - - /* - * Added by Sergej on 09.05.2008 FIX: Check if the current - * offset > the startPC of the last entry. The last entry is not - * checked in the loop. - */ - LineNumberTableEntry en = lineNumberTable[lineNumberTable.length - 1]; - if ( offset > en.getStartPc( ) ) - { - return en.getLineNumber( ); - } - - /* find offset */ - LineNumberTableEntry lastEntry = null; - for ( int i = 0; i < lineNumberTable.length; i++ ) - { - en = lineNumberTable[i]; - if ( offset == en.getStartPc( ) ) - { - return en.getLineNumber( ); - } - else if ( lastEntry != null && offset < en.getStartPc( ) ) - { - return lastEntry.getLineNumber( ); - } - lastEntry = en; - } - } - - /* not found */ - return ByteCodeConstants.INVALID_OFFSET; - } - - /** - * Returns an offset of the startPC for the given sourceCodeLine. - * - * @param sourceCodeLine - * 1-based source code line - * @return the offset of the startPC - */ - private int lookUpLineNumberTableForStartPC( int oneBasedsourceCodeLine ) - { - if ( oneBasedsourceCodeLine != ByteCodeConstants.INVALID_OFFSET ) - { - - /* find startPointCode */ - LineNumberTableEntry lastEntry = null; - for ( int i = 0; i < lineNumberTable.length; i++ ) - { - LineNumberTableEntry en = lineNumberTable[i]; - if ( oneBasedsourceCodeLine == en.getLineNumber( ) ) - { - return en.getStartPc( ); - } - else if ( lastEntry != null && oneBasedsourceCodeLine < en.getLineNumber( ) ) - { - return lastEntry.getStartPc( ); - } - lastEntry = en; - } - } - - /* not found */ - return ByteCodeConstants.INVALID_OFFSET; - } - - private void renderLineNumberTable( LineNumberTableEntry[] lineNumberTable ) - { - if ( lineNumberTable == null ) - { - appendNewline( ); - appendCommentBegin( ); - appendSpace( ); - sb.append( ByteCodeConstants.LINE_NUMBER_TABLE_NOT_AVAILABLE ); - appendSpace( ); - appendCommentEnd( ); - appendNewline( ); - } - else - { - appendNewline( ); - - TextTable tbl = new TextTable( new ByteCodeConstants.Align[]{ - ByteCodeConstants.Align.RIGHT, ByteCodeConstants.Align.RIGHT - } ); - - tbl.addRow( new String[]{ - ByteCodeConstants.START_PC, ByteCodeConstants.LINE_NUMBER - } ); - - for ( int i = 0; i < lineNumberTable.length; i++ ) - { - LineNumberTableEntry en = lineNumberTable[i]; - tbl.addRow( new String[]{ - String.valueOf( en.getStartPc( ) ), String.valueOf( en.getLineNumber( ) ) - } ); - } - - tbl.recomputeColumnWidths( ); - tbl.beginRow( ); - tbl.appendValue( ByteCodeConstants.LINE_NUMBER_TABLE, - ByteCodeConstants.Align.CENTER, - tbl.computeWidth( ) ); - tbl.endRow( ); - tbl.render( ); - - } - } - - private void renderLocalVariableTable( ) - { - if ( localVariableTable == null || !localVariableTable.isAvailable( ) ) - { - appendNewline( ); - appendCommentBegin( ); - appendSpace( ); - sb.append( ByteCodeConstants.LOCAL_VARIABLE_TABLE_NOT_AVAILABLE ); - appendSpace( ); - appendCommentEnd( ); - appendNewline( ); - } - else if ( localVariableTable.getLength( ) == 0 ) - { - appendNewline( ); - appendCommentBegin( ); - appendSpace( ); - sb.append( ByteCodeConstants.LOCAL_VARIABLE_TABLE_EMPTY ); - appendSpace( ); - appendCommentEnd( ); - appendNewline( ); - } - else - { - appendNewline( ); - - String[] header = localVariableTable.getHeader( ); - ByteCodeConstants.Align[] alignments = new ByteCodeConstants.Align[header.length]; - for ( int i = 0; i < alignments.length; i++ ) - { - alignments[i] = localVariableTable.getAlignment( i ); - } - - TextTable tbl = new TextTable( alignments ); - - tbl.addRow( header ); - int len = localVariableTable.getLength( ); - if ( len > 0 ) - { - for ( int i = 0; i < len; i++ ) - { - tbl.addRow( localVariableTable.getRow( i ) ); - } - } - - tbl.recomputeColumnWidths( ); - - tbl.beginRow( ); - tbl.appendValue( ByteCodeConstants.LOCAL_VARIABLE_TABLE, - ByteCodeConstants.Align.CENTER, - tbl.computeWidth( ) ); - tbl.endRow( ); - - tbl.render( ); - - } - } - - private void renderExceptionTable( ) - { - if ( exceptionTable == null ) - { - appendNewline( ); - appendCommentBegin( ); - appendSpace( ); - sb.append( ByteCodeConstants.EXCEPTION_TABLE_NOT_AVAILABLE ); - appendSpace( ); - appendCommentEnd( ); - appendNewline( ); - } - else if ( exceptionTable.length == 0 ) - { - appendNewline( ); - appendCommentBegin( ); - appendSpace( ); - sb.append( ByteCodeConstants.EXCEPTION_TABLE_EMPTY ); - appendSpace( ); - appendCommentEnd( ); - appendNewline( ); - } - else - { - appendNewline( ); - - TextTable tbl = new TextTable( new ByteCodeConstants.Align[]{ - ByteCodeConstants.Align.RIGHT, - ByteCodeConstants.Align.RIGHT, - ByteCodeConstants.Align.RIGHT, - ByteCodeConstants.Align.RIGHT - } ); - - /* - * u2 exception_table_length; { u2 start_pc; u2 end_pc; u2 - * handler_pc; u2 catch_type; } - * exception_table[exception_table_length]; - */ - tbl.addRow( new String[]{ - ByteCodeConstants.START_PC, - ByteCodeConstants.END_PC, - ByteCodeConstants.HANDLER_PC, - ByteCodeConstants.CATCH_TYPE - } ); - - for ( int i = 0; i < exceptionTable.length; i++ ) - { - ExceptionTableEntry en = exceptionTable[i]; - - String catch_type_class = String.valueOf( ByteCodeConstants.UNKNOWN_INFORMATION ); - - int catch_type = en.getCatchType( ); - if ( catch_type == 0 ) - { - catch_type_class = ByteCodeConstants.ANY_EXCEPTION; - } - else - { - AbstractConstantPoolEntry cpInfo = constantPool[catch_type]; - if ( cpInfo instanceof ConstantClassInfo ) - { - ConstantClassInfo constantClassInfo = (ConstantClassInfo) cpInfo; - String name = ( (ConstantUtf8Info) constantPool[constantClassInfo.getNameIndex( )] ) - .getString( ); - catch_type_class = name.replace( ByteCodeConstants.CLASS_NAME_SLASH, - JavaLexicalConstants.DOT ); - } - } - - tbl.addRow( new String[]{ - String.valueOf( en.getStartPc( ) ), - String.valueOf( en.getEndPc( ) ), - String.valueOf( en.getHandlerPc( ) ), - catch_type_class - } ); - } - - tbl.recomputeColumnWidths( ); - tbl.beginRow( ); - tbl.appendValue( ByteCodeConstants.EXCEPTION_TABLE, - ByteCodeConstants.Align.CENTER, - tbl.computeWidth( ) ); - tbl.endRow( ); - tbl.render( ); - - } - } - - private void renderMaxs( ) - { - appendNewline( ); - appendCommentBegin( ); - appendSpace( ); - sb.append( ByteCodeConstants.MAX_STACK ); - appendColon( ); - appendSpace( ); - sb.append( max_stack ); - appendSpace( ); - sb.append( ByteCodeConstants.MAX_LOCALS ); - appendColon( ); - appendSpace( ); - sb.append( max_locals ); - appendSpace( ); - appendCommentEnd( ); - appendNewline( ); - } - - private void renderSignature( ) - { - - appendNewline( ); - - if ( ( access & ACC_BRIDGE ) != 0 ) - { - appendCommentBegin( ); - appendSpace( ); - sb.append( ByteCodeConstants.BRIDGE_METHOD_GENERATED_BY_THE_COMPILER ); - appendSpace( ); - appendCommentEnd( ); - appendNewline( ); - } - appendDeprecated( access ); - - /* changed to 0-based */ - this.firstLine = lineCount; - - appendAccess( access ); - if ( ( access & ACC_NATIVE ) != 0 ) - { - sb.append( JavaKeywords.NATIVE ); - appendSpace( ); - } - if ( ( access & ACC_VARARGS ) != 0 ) - { - appendCommentBegin( ); - appendSpace( ); - sb.append( ByteCodeConstants.VARARGS ); - appendSpace( ); - appendCommentEnd( ); - appendSpace( ); - } - - if ( signature != null ) - { - - // TODO test generic signature - SignatureRenderer v = new SignatureRenderer( 0 ); - SignatureReader r = new SignatureReader( signature ); - r.accept( v ); - String genericDecl = v.getDeclaration( ); - String genericReturn = v.getReturnType( ); - String genericExceptions = v.getExceptions( ); - - sb.append( genericReturn ); - appendSpace( ); - sb.append( name ); - sb.append( genericDecl ); - - // TODO will this generic exceptions get doubled with the normal - // ones below? - if ( genericExceptions != null ) - { - appendSpace( ); - sb.append( genericExceptions ); - } - - } - else - { - /* null signature */ - isConstructor = true; - - try - { - if ( ByteCodeConstants.INIT.equals( name ) ) - { - /* constructor */ - BytecodeUtils.appendMethodDescriptor( classSimpleName, - true, - ( access & ACC_STATIC ) != 0, - descriptor, - 0, - localVariableTable, - constantPool, - sb ); - } - else if ( ByteCodeConstants.CLINIT.equals( name ) ) - { - /* static block */ - /* - * remove the final space, that has been appended by - * appendAccessFlags() - */ - sb.setLength( sb.length( ) - 1 ); - } - else - { - BytecodeUtils.appendMethodDescriptor( name, - false, - ( access & ACC_STATIC ) != 0, - descriptor, - 0, - localVariableTable, - constantPool, - sb ); - } - } - catch ( IOException e ) - { - throw new RuntimeException( e ); - } - } - - if ( exceptions != null && exceptions.length > 0 ) - { - appendSpace( ); - sb.append( JavaKeywords.THROWS ); - appendSpace( ); - for ( int i = 0; i < exceptions.length; ++i ) - { - if ( i > 0 ) - { - appendComma( ); - appendSpace( ); - } - sb.append( exceptions[i].replace( ByteCodeConstants.CLASS_NAME_SLASH, JavaLexicalConstants.DOT ) ); - } - } - if ( !hasCode( ) ) - { - /* no instructions for interface and abstract methods */ - appendSemicolon( ); - appendNewline( ); - } - else - { - appendSpace( ); - appendLeftBrace( ); - appendNewline( ); - incrementIndent( ); - } - } - - public AnnotationVisitor visitAnnotation( final String desc, final boolean visible ) - { - if ( mv != null ) - { - return mv.visitAnnotation( desc, visible ); - } - return null; - } - - public AnnotationVisitor visitAnnotationDefault( ) - { - if ( mv != null ) - { - return mv.visitAnnotationDefault( ); - } - return null; - } - - public void visitAttribute( final Attribute attr ) - { - if ( mv != null ) - { - mv.visitAttribute( attr ); - } - } - - public void visitCode( ) - { - if ( mv != null ) - { - mv.visitCode( ); - } - } - - public boolean visitCode( byte[] bytes ) - { - return visitCode( bytes, 0, bytes.length ); - } - - public boolean visitCode( byte[] bytes, int offset, int length ) - { - IndexedInstructionParser parser = new IndexedInstructionParser( bytes, offset, length ); - instructions = parser.parse( ); - offsetInstructionMap = parser.offsetInstructionMap; - - /* load try blocks */ - exceptionTable = parser.parseExceptionTable( ); - - HashSet attributeNames = new HashSet( ); - attributeNames.add( ByteCodeConstants.LINE_NUMBER_TABLE ); - attributeNames.add( ByteCodeConstants.LOCAL_VARIABLE_TABLE ); - attributeNames.add( ByteCodeConstants.LOCAL_VARIABLE_TYPE_TABLE ); - - Map attrs = parser.parseAttributes( attributeNames, constantPool ); - - lineNumberTable = (LineNumberTableEntry[]) attrs.get( ByteCodeConstants.LINE_NUMBER_TABLE ); - - LocalVariableTableEntry[] varTableEntries = (LocalVariableTableEntry[]) attrs - .get( ByteCodeConstants.LOCAL_VARIABLE_TABLE ); - LocalVariableTypeTableEntry[] varTypeTable = (LocalVariableTypeTableEntry[]) attrs - .get( ByteCodeConstants.LOCAL_VARIABLE_TYPE_TABLE ); - localVariableTable = createLocalVariableTable( varTableEntries != null ); - if ( varTableEntries != null && varTableEntries.length > 0 ) - { - for ( LocalVariableTableEntry entry : varTableEntries ) - { - localVariableTable.addLocalVariableTableEntry( entry ); - } - } - if ( varTypeTable != null && varTypeTable.length > 0 ) - { - for ( LocalVariableTypeTableEntry entry : varTypeTable ) - { - localVariableTable.addLocalVariableTypeTableEntry( entry ); - } - } - - renderSignature( ); - - if ( exceptionTable != null && exceptionTable.length > 0 ) - { - - rootTryBlocks = new ArrayList( ); - - ExceptionTableEntry[] sortedExceptionTable = new ExceptionTableEntry[exceptionTable.length]; - System.arraycopy( exceptionTable, 0, sortedExceptionTable, 0, exceptionTable.length ); - Arrays.sort( sortedExceptionTable, new ExceptionTableEntryComparator( ) ); - - for ( ExceptionTableEntry en : sortedExceptionTable ) - { - TryBlock b = findEnclosingTryBlock( en ); - TryBlock newTryBlock = null; - if ( b == null ) - { - /* this is a new root block */ - newTryBlock = new TryBlock( en ); - rootTryBlocks.add( newTryBlock ); - } - else - { - newTryBlock = b.createEnclosedTryBlock( en ); - } - openedTryBlock = newTryBlock; - } - - TryBlock dummyParentTryBlock = new TryBlock( null, 0, length ); - for ( TryBlock tb : rootTryBlocks ) - { - tb.enclosingTryBlock = dummyParentTryBlock; - tb.computeHandlersEnds( offsetInstructionMap ); - } - } - - for ( AbstractInstruction instruction : instructions ) - { - - /* starting try blocks */ - List blocks = blockStarts.get( instruction.getOffset( ) ); - if ( blocks != null ) - { - for ( Block block : blocks ) - { - block.appendStart( ); - } - } - - InstructionRenderer r = null; - if ( instruction instanceof SimpleInstruction ) - { - r = new InstructionRenderer( (SimpleInstruction) instruction ); - } - else if ( instruction instanceof AbstractInstruction ) - { - r = new InstructionRenderer( (AbstractInstruction) instruction ); - } - else - { - throw new RuntimeException( - "Could not find renderer for '" + instruction.getClass( ).getName( ) + "'" ); - } - - try - { - r.render( this ); - } - catch ( IOException e ) - { - throw new RuntimeException( e ); - } - - if ( r instanceof IInstructionLine ) - { - instructionLines.add( (IInstructionLine) r ); - } - - /* ending try blocks */ - blocks = blockEnds.get( instruction.getOffset( ) + instruction.getLength( ) ); - if ( blocks != null ) - { - for ( Block block : blocks ) - { - block.appendEnd( ); - } - } - } - - if ( showLineNumberTable ) - { - renderLineNumberTable( lineNumberTable ); - } - - if ( showLocalVariableTable ) - { - renderLocalVariableTable( ); - } - - if ( showExceptionTable ) - { - renderExceptionTable( ); - } - - return true; - } - - public void visitEnd( ) - { - - if ( !hasCode( ) ) - { - /* - * signature of an abstract or native method we must call it - * here as visitCode(...) will not be called for abstract - * methods - */ - renderSignature( ); - } - else - { - /* end of non-abstract method */ - decrementIndent( ); - appendRightBrace( ); - appendNewline( ); - } - /* changed to 0-based */ - lastLine = lineCount - 1; - - if ( mv != null ) - { - mv.visitEnd( ); - } - - /* add every method, no matter if it is abstract */ - methodSections.add( this ); - - methodBorderLinesList.add( firstLine ); - methodBorderLinesList.add( lastLine ); - - } - - public void visitFieldInsn( final int opcode, final String owner, final String name, final String desc ) - { - if ( mv != null ) - { - mv.visitFieldInsn( opcode, owner, name, desc ); - } - } - - public void visitFrame( final int type, final int nLocal, final Object[] local, final int nStack, - final Object[] stack ) - { - if ( mv != null ) - { - mv.visitFrame( type, nLocal, local, nStack, stack ); - } - } - - public void visitIincInsn( final int var, final int increment ) - { - if ( mv != null ) - { - mv.visitIincInsn( var, increment ); - } - } - - public void visitInsn( final int opcode ) - { - if ( mv != null ) - { - mv.visitInsn( opcode ); - } - } - - public void visitIntInsn( final int opcode, final int operand ) - { - if ( mv != null ) - { - mv.visitIntInsn( opcode, operand ); - } - } - - public void visitJumpInsn( final int opcode, final Label label ) - { - if ( mv != null ) - { - mv.visitJumpInsn( opcode, label ); - } - } - - public void visitLabel( final Label label ) - { - if ( mv != null ) - { - mv.visitLabel( label ); - } - } - - public void visitLdcInsn( final Object cst ) - { - if ( mv != null ) - { - mv.visitLdcInsn( cst ); - } - } - - public void visitLineNumber( final int line, final Label start ) - { - - if ( mv != null ) - { - mv.visitLineNumber( line, start ); - } - } - - public void visitLocalVariable( final String name, final String desc, final String signature, final Label start, - final Label end, final int index ) - { - if ( mv != null ) - { - mv.visitLocalVariable( name, desc, signature, start, end, index ); - } - } - - public void visitLocalVariableTable( byte[] bytes, int offset, int entryCount ) - { - // LocalVariableTableParser p = new LocalVariableTableParser(bytes, - // offset, entryCount); - // LocalVariableTableEntry[] tbl = p.parse(); - // for (LocalVariableTableEntry entry : tbl) { - // System.out.println(); - // //addLocalVariableTableEntry(entry); - // } - } - - // public void addLocalVariableTableEntry(LocalVariableTableEntry entry) - // { - // indexedLocalVariableTable.put(entry.getIndex(), entry); - // } - - public void visitLookupSwitchInsn( final Label dflt, final int[] keys, final Label[] labels ) - { - if ( mv != null ) - { - mv.visitLookupSwitchInsn( dflt, keys, labels ); - } - } - - public void visitMaxs( final int maxStack, final int maxLocals ) - { - if ( mv != null ) - { - mv.visitMaxs( maxStack, maxLocals ); - } - max_stack = maxStack; - max_locals = maxLocals; - - if ( showMaxs ) - { - renderMaxs( ); - } - } - - public void visitMethodInsn( final int opcode, final String owner, final String name, final String desc ) - { - if ( mv != null ) - { - mv.visitMethodInsn( opcode, owner, name, desc ); - } - } - - public void visitMultiANewArrayInsn( final String desc, final int dims ) - { - if ( mv != null ) - { - mv.visitMultiANewArrayInsn( desc, dims ); - } - } - - public AnnotationVisitor visitParameterAnnotation( final int parameter, final String desc, - final boolean visible ) - { - if ( mv != null ) - { - return mv.visitParameterAnnotation( parameter, desc, visible ); - } - return null; - } - - public void visitTableSwitchInsn( final int min, final int max, final Label dflt, final Label... labels ) - { - if ( mv != null ) - { - mv.visitTableSwitchInsn( min, max, dflt, labels ); - } - } - - public void visitTryCatchBlock( final Label start, final Label end, final Label handler, final String type ) - { - if ( mv != null ) - { - mv.visitTryCatchBlock( start, end, handler, type ); - } - } - - public void visitTypeInsn( final int opcode, final String type ) - { - if ( mv != null ) - { - mv.visitTypeInsn( opcode, type ); - } - } - - public void visitVarInsn( final int opcode, final int var ) - { - if ( mv != null ) - { - mv.visitVarInsn( opcode, var ); - } - } - - public IInstructionLine findInstructionLine( int sourceCodeLine ) - { - if ( lineNumberTable == null - || lineNumberTable.length == 0 - || sourceCodeLine == ByteCodeConstants.INVALID_OFFSET - - /* - * if there are no instructions we will find nothing either - */ - || instructionLines.size( ) == 0 ) - { - return null; - } - - int offset = lookUpLineNumberTableForStartPC( sourceCodeLine + 1 ); - if ( offset != ByteCodeConstants.INVALID_OFFSET ) - { - - List lines = getInstructionLines( ); - for ( IInstructionLine line : lines ) - { - if ( offset == line.getInstruction( ).getOffset( ) ) - { - return line; - } - } - - } - return null; - } - - } - - protected class AnnotationRenderer extends AnnotationVisitor - { - - /** - * The {@link AnnotationVisitor} to which this visitor delegates calls. - * May be null. - */ - protected AnnotationVisitor av; - - private int valueNumber = 0; - - /** - * Constructs a new {@link AnnotationRenderer}. - */ - public AnnotationRenderer( ) - { - super( com.drgarbage.asm.Opcodes.ASM4 ); - } - - // ------------------------------------------------------------------------ - // Implementation of the AnnotationVisitor interface - // ------------------------------------------------------------------------ - - private void appendComa( final int i ) - { - if ( i != 0 ) - { - sb.append( ", " ); - } - } - - public void visit( final String name, final Object value ) - { - // sb.setLength(0); - appendComa( valueNumber++ ); - - if ( name != null ) - { - sb.append( name ).append( '=' ); - } - - if ( value instanceof String ) - { - visitString( (String) value ); - } - else if ( value instanceof Type ) - { - visitType( (Type) value ); - } - else if ( value instanceof Byte ) - { - visitByte( ( (Byte) value ).byteValue( ) ); - } - else if ( value instanceof Boolean ) - { - visitBoolean( ( (Boolean) value ).booleanValue( ) ); - } - else if ( value instanceof Short ) - { - visitShort( ( (Short) value ).shortValue( ) ); - } - else if ( value instanceof Character ) - { - visitChar( ( (Character) value ).charValue( ) ); - } - else if ( value instanceof Integer ) - { - visitInt( ( (Integer) value ).intValue( ) ); - } - else if ( value instanceof Float ) - { - visitFloat( ( (Float) value ).floatValue( ) ); - } - else if ( value instanceof Long ) - { - visitLong( ( (Long) value ).longValue( ) ); - } - else if ( value instanceof Double ) - { - visitDouble( ( (Double) value ).doubleValue( ) ); - } - else if ( value.getClass( ).isArray( ) ) - { - sb.append( '{' ); - if ( value instanceof byte[] ) - { - byte[] v = (byte[]) value; - for ( int i = 0; i < v.length; i++ ) - { - appendComa( i ); - visitByte( v[i] ); - } - } - else if ( value instanceof boolean[] ) - { - boolean[] v = (boolean[]) value; - for ( int i = 0; i < v.length; i++ ) - { - appendComa( i ); - visitBoolean( v[i] ); - } - } - else if ( value instanceof short[] ) - { - short[] v = (short[]) value; - for ( int i = 0; i < v.length; i++ ) - { - appendComa( i ); - visitShort( v[i] ); - } - } - else if ( value instanceof char[] ) - { - char[] v = (char[]) value; - for ( int i = 0; i < v.length; i++ ) - { - appendComa( i ); - visitChar( v[i] ); - } - } - else if ( value instanceof int[] ) - { - int[] v = (int[]) value; - for ( int i = 0; i < v.length; i++ ) - { - appendComa( i ); - visitInt( v[i] ); - } - } - else if ( value instanceof long[] ) - { - long[] v = (long[]) value; - for ( int i = 0; i < v.length; i++ ) - { - appendComa( i ); - visitLong( v[i] ); - } - } - else if ( value instanceof float[] ) - { - float[] v = (float[]) value; - for ( int i = 0; i < v.length; i++ ) - { - appendComa( i ); - visitFloat( v[i] ); - } - } - else if ( value instanceof double[] ) - { - double[] v = (double[]) value; - for ( int i = 0; i < v.length; i++ ) - { - appendComa( i ); - visitDouble( v[i] ); - } - } - sb.append( '}' ); - } - - // text.add(sb.toString()); - - if ( av != null ) - { - av.visit( name, value ); - } - } - - // FIXME Annotations rendering - public AnnotationVisitor visitAnnotation( final String name, final String desc ) - { - // sb.setLength(0); - appendComa( valueNumber++ ); - if ( name != null ) - { - sb.append( name ).append( '=' ); - } - sb.append( '@' ); - sb.append( desc ); - sb.append( '(' ); - // text.add(sb.toString()); - AnnotationRenderer tav = createTraceAnnotationVisitor( ); - // sb.append(tav.getText()); - sb.append( ")" ); - if ( av != null ) - { - tav.av = av.visitAnnotation( name, desc ); - } - return tav; - } - - // FIXME Annotations rendering - public AnnotationVisitor visitArray( final String name ) - { - // sb.setLength(0); - appendComa( valueNumber++ ); - if ( name != null ) - { - sb.append( name ).append( '=' ); - } - sb.append( '{' ); - // text.add(sb.toString()); - AnnotationRenderer tav = createTraceAnnotationVisitor( ); - // sb.append(tav.getText()); - sb.append( "}" ); - if ( av != null ) - { - tav.av = av.visitArray( name ); - } - return tav; - } - - private void visitBoolean( final boolean value ) - { - sb.append( value ); - } - - private void visitByte( final byte value ) - { - sb.append( "(byte)" ).append( value ); - } - - private void visitChar( final char value ) - { - sb.append( "(char)" ).append( (int) value ); - } - - private void visitDouble( final double value ) - { - sb.append( value ).append( 'D' ); - } - - public void visitEnd( ) - { - if ( av != null ) - { - av.visitEnd( ); - } - } - - public void visitEnum( final String name, final String desc, final String value ) - { - // FIXME annotation rendering - appendComa( valueNumber++ ); - if ( name != null ) - { - sb.append( name ).append( '=' ); - } - sb.append( desc ); - sb.append( '.' ).append( value ); - // text.add(sb.toString()); - - if ( av != null ) - { - av.visitEnum( name, desc, value ); - } - } - - private void visitFloat( final float value ) - { - sb.append( value ).append( 'F' ); - } - - private void visitInt( final int value ) - { - sb.append( value ); - } - - private void visitLong( final long value ) - { - sb.append( value ).append( 'L' ); - } - - private void visitShort( final short value ) - { - sb.append( "(short)" ).append( value ); - } - - private void visitString( final String value ) - { - BytecodeUtils.appendString( sb, value ); - } - - // ------------------------------------------------------------------------ - // Utility methods - // ------------------------------------------------------------------------ - - private void visitType( final Type value ) - { - sb.append( value.getClassName( ) ).append( ".class" ); - } - } - - protected class FieldRenderer extends FieldVisitor implements IFieldSection - { - - /** - * Type signature. - */ - private String descriptor; - protected int documentLine = ByteCodeConstants.INVALID_OFFSET; - /** - * The {@link FieldVisitor} to which this visitor delegates calls. May - * be null. - */ - protected FieldVisitor fv; - protected String name; - - public FieldRenderer( String name, String descriptor, int documentLine ) - { - super( com.drgarbage.asm.Opcodes.ASM4 ); - this.name = name; - this.descriptor = descriptor; - this.documentLine = documentLine; - } - - /* - * (non-Javadoc) - * - * @see com.drgarbage.classfile.render.intf.IOutlineElement# - * getBytecodeDocumentLine() - */ - public int getBytecodeDocumentLine( ) - { - return documentLine; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jdt.core.IField#getTypeSignature() - */ - public String getDescriptor( ) - { - return descriptor; - } - - public String getName( ) - { - return name; - } - - public AnnotationVisitor visitAnnotation( final String desc, final boolean visible ) - { - AnnotationVisitor av = visitAnnotationImpl( desc, visible ); - if ( fv != null ) - { - ( (AnnotationRenderer) av ).av = fv.visitAnnotation( desc, visible ); - } - return av; - } - - public void visitAttribute( final Attribute attr ) - { - visitAttributeImpl( attr ); - - if ( fv != null ) - { - fv.visitAttribute( attr ); - } - } - - public void visitEnd( ) - { - if ( fv != null ) - { - fv.visitEnd( ); - } - } - } - - public static class IndexedInstructionParser extends InstructionParser - { - - private HashMap offsetInstructionMap = new HashMap( ); - - public IndexedInstructionParser( byte[] code, int offset, int length ) - { - super( code, offset, length ); - } - - @Override - protected AbstractInstruction parseNextInstruction( boolean wide ) throws IOException - { - AbstractInstruction instruction = super.parseNextInstruction( wide ); - offsetInstructionMap.put( instruction.getOffset( ), instruction ); - return instruction; - } - - } - - protected class InstructionRenderer implements IInstructionLine - { - - protected boolean commentOpened = false; - protected AbstractInstruction instruction; - - private int line = INVALID_LINE; - - private AbstractMethodRenderer methodRenderer; - - public InstructionRenderer( AbstractInstruction instruction ) - { - this.instruction = instruction; - } - - protected void appendComment( ) - { - try - { - if ( instruction instanceof ILocalVariableIndexProvider ) - { - if ( methodRenderer != null ) - { - - String name = methodRenderer.localVariableTable.findArgName( - ( (ILocalVariableIndexProvider) instruction ).getLocalVariableIndex( ), - instruction.getOffset( ), - methodRenderer.isConstructor( ), - methodRenderer.isAbstract( ) ); - - if ( name != null ) - { - openCommentIfNeeded( ); - if ( instruction instanceof IncrementInstruction ) - { - appendSpace( ); - append( name ); - int incr = ( (IncrementInstruction) instruction ).getIncrementConst( ); - char sign = incr >= 0 ? JavaLexicalConstants.PLUS : JavaLexicalConstants.MINUS; - if ( Math.abs( incr ) == 1 ) - { - append( sign ); - append( sign ); - } - else - { - appendSpace( ); - append( sign ); - append( JavaLexicalConstants.EQUALS ); - appendSpace( ); - append( Math.abs( incr ) ); - } - } - else - { - appendSpace( ); - append( name ); - } - appendSpace( ); - } - } - } - if ( instruction instanceof IConstantPoolIndexProvider ) - { - if ( methodRenderer != null && constantPool != null ) - { - - AbstractConstantPoolEntry cpInfo = constantPool[( (IConstantPoolIndexProvider) instruction ) - .getConstantPoolIndex( )]; - - String const_ = null; - if ( cpInfo instanceof ConstantFloatInfo ) - { - const_ = String.valueOf( ( (ConstantFloatInfo) cpInfo ).getFloat( ) ); - } - else if ( cpInfo instanceof ConstantIntegerInfo ) - { - const_ = String.valueOf( ( (ConstantIntegerInfo) cpInfo ).getInt( ) ); - } - else if ( cpInfo instanceof ConstantDoubleInfo ) - { - const_ = String.valueOf( ( (ConstantDoubleInfo) cpInfo ).getDouble( ) ); - } - else if ( cpInfo instanceof ConstantLongInfo ) - { - const_ = String.valueOf( ( (ConstantLongInfo) cpInfo ).getLong( ) ); - } - else if ( cpInfo instanceof ConstantStringInfo ) - { - int i = ( (ConstantStringInfo) cpInfo ).getStringIndex( ); - StringBuffer buf = new StringBuffer( ); - BytecodeUtils.appendString( buf, ( (ConstantUtf8Info) constantPool[i] ).getString( ) ); - const_ = buf.toString( ); - } - else if ( cpInfo instanceof ConstantFieldrefInfo ) - { - ConstantFieldrefInfo constantFieldrefInfo = (ConstantFieldrefInfo) cpInfo; - if ( instruction.getOpcode( ) == Opcodes.GETSTATIC - || instruction.getOpcode( ) == Opcodes.PUTSTATIC ) - { - ConstantClassInfo constantClassInfo = (ConstantClassInfo) constantPool[constantFieldrefInfo - .getClassIndex( )]; - String name = ( (ConstantUtf8Info) constantPool[constantClassInfo.getNameIndex( )] ) - .getString( ); - const_ = name.replace( ByteCodeConstants.CLASS_NAME_SLASH, JavaLexicalConstants.DOT ); - } - else - { - const_ = ""; - } - ConstantNameAndTypeInfo constantNameAndTypeInfo = (ConstantNameAndTypeInfo) constantPool[constantFieldrefInfo - .getNameAndTypeIndex( )]; - String fieldName = ( (ConstantUtf8Info) constantPool[constantNameAndTypeInfo - .getNameIndex( )] ).getString( ); - const_ += JavaLexicalConstants.DOT + fieldName; - } - else if ( cpInfo instanceof ConstantMethodrefInfo ) - { - ConstantMethodrefInfo constantMethodrefInfo = (ConstantMethodrefInfo) cpInfo; - ConstantNameAndTypeInfo constantNameAndTypeInfo = (ConstantNameAndTypeInfo) constantPool[constantMethodrefInfo - .getNameAndTypeIndex( )]; - String methodName = ( (ConstantUtf8Info) constantPool[constantNameAndTypeInfo - .getNameIndex( )] ).getString( ); - if ( ByteCodeConstants.INIT.equals( methodName ) ) - { - ConstantClassInfo constantClassInfo = (ConstantClassInfo) constantPool[constantMethodrefInfo - .getClassIndex( )]; - String name = ( (ConstantUtf8Info) constantPool[constantClassInfo.getNameIndex( )] ) - .getString( ); - methodName = name.replace( ByteCodeConstants.CLASS_NAME_SLASH, - JavaLexicalConstants.DOT ); - } - else if ( instruction.getOpcode( ) == Opcodes.INVOKESTATIC ) - { - ConstantClassInfo constantClassInfo = (ConstantClassInfo) constantPool[constantMethodrefInfo - .getClassIndex( )]; - String name = ( (ConstantUtf8Info) constantPool[constantClassInfo.getNameIndex( )] ) - .getString( ); - methodName = name.replace( ByteCodeConstants.CLASS_NAME_SLASH, - JavaLexicalConstants.DOT ) + JavaLexicalConstants.DOT + methodName; - } - StringBuilder sb = new StringBuilder( ); - - boolean isConstructor = instruction.getOpcode( ) == Opcodes.INVOKESPECIAL; - boolean isStatic = false; - - String descriptor = ( (ConstantUtf8Info) constantPool[constantNameAndTypeInfo - .getDescriptorIndex( )] ).getString( ); - BytecodeUtils.appendMethodDescriptor( methodName, - isConstructor, - isStatic, - descriptor, - 0, - methodRenderer.localVariableTable, - constantPool, - sb ); - // ClassFileDocument.appendMethodDescriptor(methodName, - // isConstructor, isStatic, - // constantMethodrefInfo.getNameAndTypeInfo().getDescriptor(), - // methodRenderer.getIndexedLocalVariableTable(), - // methodRenderer.methodInfo.getClassFile(), 0, sb); - const_ = sb.toString( ); - - } - else if ( cpInfo instanceof ConstantInterfaceMethodrefInfo ) - { - ConstantInterfaceMethodrefInfo constantInterfaceMethodrefInfo = (ConstantInterfaceMethodrefInfo) cpInfo; - ConstantNameAndTypeInfo constantNameAndTypeInfo = (ConstantNameAndTypeInfo) constantPool[constantInterfaceMethodrefInfo - .getNameAndTypeIndex( )]; - String methodName = ( (ConstantUtf8Info) constantPool[constantNameAndTypeInfo - .getNameIndex( )] ).getString( ); - StringBuilder sb = new StringBuilder( ); - - boolean isStatic = false; - - String descriptor = ( (ConstantUtf8Info) constantPool[constantNameAndTypeInfo - .getDescriptorIndex( )] ).getString( ); - BytecodeUtils.appendMethodDescriptor( methodName, - false, - isStatic, - descriptor, - 0, - methodRenderer.localVariableTable, - constantPool, - sb ); - const_ = sb.toString( ); - - } - else if ( cpInfo instanceof ConstantClassInfo ) - { - /* - * the constructor info should be clear from the - * subsequent invokespecial - */ - // ConstantClassInfo constantClassInfo = - // (ConstantClassInfo) cpInfo; - // String methodName = - // constantClassInfo.getName().replace(ByteCodeConstants.CLASS_NAME_SLASH, - // JavaLexicalConstants.DOT); - // const_ = JavaKeywords.NEW + - // JavaLexicalConstants.SPACE + methodName; - ConstantClassInfo constantClassInfo = (ConstantClassInfo) cpInfo; - if ( instruction.getOpcode( ) == Opcodes.ANEWARRAY ) - { - - String className = BytecodeUtils.resolveConstantPoolTypeName( constantClassInfo, - constantPool ); - - // String className = - // ((ConstantUtf8Info)constantPool[constantClassInfo.getNameIndex()]).getString(); - className = className.replace( ByteCodeConstants.CLASS_NAME_SLASH, - JavaLexicalConstants.DOT ); - StringBuilder sb = new StringBuilder( ); - sb.append( JavaKeywords.NEW ); - sb.append( JavaLexicalConstants.SPACE ); - sb.append( className ); - sb.append( JavaLexicalConstants.LEFT_SQUARE_BRACKET ); - sb.append( JavaLexicalConstants.RIGHT_SQUARE_BRACKET ); - const_ = sb.toString( ); - } - else if ( instruction.getOpcode( ) == Opcodes.MULTIANEWARRAY ) - { - String className = ( (ConstantUtf8Info) constantPool[constantClassInfo - .getNameIndex( )] ).getString( ); - StringBuilder sb = new StringBuilder( ); - sb.append( JavaKeywords.NEW ); - sb.append( JavaLexicalConstants.SPACE ); - BytecodeUtils.appendFieldDescriptor( className, 0, sb ); - const_ = sb.toString( ); - } - else if ( instruction.getOpcode( ) == Opcodes.CHECKCAST ) - { - String className = ( (ConstantUtf8Info) constantPool[constantClassInfo - .getNameIndex( )] ).getString( ); - const_ = className.replace( ByteCodeConstants.CLASS_NAME_SLASH, - JavaLexicalConstants.DOT ); - } - else if ( instruction.getOpcode( ) == Opcodes.INSTANCEOF ) - { - String className = ( (ConstantUtf8Info) constantPool[constantClassInfo - .getNameIndex( )] ).getString( ); - if ( className.charAt( 0 ) == ByteCodeConstants.ARRAY_BEGINNING_BRACKET ) - { - StringBuilder sbb = new StringBuilder( ); - BytecodeUtils.appendArrayDescriptor( className, 0, sbb ); - className = sbb.toString( ); - } - else - { - className = className.replace( ByteCodeConstants.CLASS_NAME_SLASH, - JavaLexicalConstants.DOT ); - } - const_ = JavaKeywords.INSTANCEOF + JavaLexicalConstants.SPACE + className; - } - } - else if ( cpInfo instanceof ConstantMethodHandleInfo ) - { - // ConstantMethodHandleInfo constantMethodHandleInfo - // = (ConstantMethodHandleInfo) cpInfo; - // int index = - // constantMethodHandleInfo.getReferenceIndex(); - } - else if ( cpInfo instanceof ConstantMethodTypeInfo ) - { - ConstantMethodTypeInfo constantMethodTypeInfo = (ConstantMethodTypeInfo) cpInfo; - String descriptor = ( (ConstantUtf8Info) constantPool[constantMethodTypeInfo - .getDescriptorIndex( )] ).getString( ); - const_ = descriptor; - } - else if ( cpInfo instanceof ConstantInvokeDynamicInfo ) - { - ConstantInvokeDynamicInfo constantInvokeDynamicInfo = (ConstantInvokeDynamicInfo) cpInfo; - ConstantNameAndTypeInfo nameAndTypeInfo = (ConstantNameAndTypeInfo) constantPool[constantInvokeDynamicInfo - .getNameAndTypeIndex( )]; - String nameAndType_name = ( (ConstantUtf8Info) constantPool[nameAndTypeInfo - .getNameIndex( )] ).getString( ); - String nameAndType_descr = ( (ConstantUtf8Info) constantPool[nameAndTypeInfo - .getDescriptorIndex( )] ).getString( ); - - StringBuilder sb = new StringBuilder( ); - boolean isConstructor = false; - boolean isStatic = false; - BytecodeUtils.appendMethodDescriptor( nameAndType_name, - isConstructor, - isStatic, - nameAndType_descr, - 0, - methodRenderer.localVariableTable, - constantPool, - sb ); - const_ = sb.toString( ); - } - else - { - throw new RuntimeException( "invalid type " + cpInfo.getClass( ) ); - } - if ( const_ != null ) - { - openCommentIfNeeded( ); - appendSpace( ); - append( const_ ); - appendSpace( ); - } - } - } - // FIX: bug #5 - // if (instruction instanceof BranchInstruction) { - // if (methodRenderer != null) { - // BranchInstruction bi = (BranchInstruction) instruction; - // openCommentIfNeeded(); - // - // appendSpace(); - // append(bi.getOffset()); - // appendSpace(); - // append(JavaLexicalConstants.PLUS); - // appendSpace(); - // append(bi.getBranchOffset()); - // appendSpace(); - // append(JavaLexicalConstants.EQUALS); - // appendSpace(); - // append(bi.getBranchOffset() + bi.getOffset()); - // appendSpace(); - // } - // } - if ( instruction instanceof NewArrayInstruction ) - { - if ( methodRenderer != null ) - { - NewArrayInstruction newArrayInstruction = (NewArrayInstruction) instruction; - - openCommentIfNeeded( ); - appendSpace( ); - append( JavaKeywords.NEW ); - appendSpace( ); - append( NewArrayInstruction.resolveType( newArrayInstruction.getImmediateByte( ) ) ); - append( JavaLexicalConstants.LEFT_SQUARE_BRACKET ); - append( JavaLexicalConstants.RIGHT_SQUARE_BRACKET ); - appendSpace( ); - - } - } - - closeCommentIfNeeded( ); - } - catch ( IOException e ) - { - throw new RuntimeException( e ); - } - } - - private void appendInt( int i ) - { - appendSpace( ); - append( String.valueOf( i ) ); - } - - protected void appendOperands( ) - { - if ( instruction instanceof MultianewarrayInstruction ) - { - appendInt( ( (MultianewarrayInstruction) instruction ).getImmediateShort( ) ); - appendInt( ( (MultianewarrayInstruction) instruction ).getDimensions( ) ); - } - else if ( instruction instanceof IncrementInstruction ) - { - appendInt( ( (IncrementInstruction) instruction ).getImmediateByte( ) ); - appendInt( ( (IncrementInstruction) instruction ).getIncrementConst( ) ); - } - else if ( instruction instanceof InvokeInterfaceInstruction ) - { - appendInt( ( (InvokeInterfaceInstruction) instruction ).getImmediateShort( ) ); - appendInt( ( (InvokeInterfaceInstruction) instruction ).getCount( ) ); - } - else if ( instruction instanceof ImmediateByteInstruction ) - { - appendInt( ( (ImmediateByteInstruction) instruction ).getImmediateByte( ) ); - } - else if ( instruction instanceof ImmediateShortInstruction ) - { - appendInt( ( (ImmediateShortInstruction) instruction ).getImmediateShort( ) ); - } - else if ( instruction instanceof ImmediateIntInstruction ) - { - appendInt( ( (ImmediateIntInstruction) instruction ).getImmediateInt( ) ); - } - else if ( instruction instanceof BranchInstruction ) - { - BranchInstruction bi = (BranchInstruction) instruction; - int val = bi.getBranchOffset( ); - if ( !showRelativeBranchTargetOffsets ) - { - /* compute absolute offset */ - val += bi.getOffset( ); - } - appendInt( val ); - } - else if ( instruction instanceof TableSwitchInstruction ) - { - TableSwitchInstruction tsi = (TableSwitchInstruction) instruction; - appendInt( tsi.getDefaultOffset( ) ); - appendInt( tsi.getLow( ) ); - appendInt( tsi.getHigh( ) ); - - appendSpace( ); - append( JavaLexicalConstants.LEFT_SQUARE_BRACKET ); - int[] offs = tsi.getJumpOffsets( ); - for ( int i = 0; i < offs.length; i++ ) - { - if ( i != 0 ) - { - appendComma( ); - appendSpace( ); - } - int val = offs[i]; - if ( !showRelativeBranchTargetOffsets ) - { - /* compute absolute offset */ - val += tsi.getOffset( ); - } - append( String.valueOf( val ) ); - } - append( JavaLexicalConstants.RIGHT_SQUARE_BRACKET ); - } - else if ( instruction instanceof LookupSwitchInstruction ) - { - LookupSwitchInstruction lsi = (LookupSwitchInstruction) instruction; - appendInt( lsi.getDefaultOffset( ) ); - - List ens = lsi.getMatchOffsetPairs( ); - appendInt( ens.size( ) ); - - appendSpace( ); - append( JavaLexicalConstants.LEFT_SQUARE_BRACKET ); - for ( int i = 0; i < ens.size( ); i++ ) - { - if ( i != 0 ) - { - appendComma( ); - appendSpace( ); - } - MatchOffsetEntry en = ens.get( i ); - append( en.getMatch( ) ); - append( " => " ); - - int val = en.getOffset( ); - if ( !showRelativeBranchTargetOffsets ) - { - /* compute absolute offset */ - val += lsi.getOffset( ); - } - append( String.valueOf( val ) ); - } - append( JavaLexicalConstants.RIGHT_SQUARE_BRACKET ); - } - } - - protected void closeCommentIfNeeded( ) - { - if ( commentOpened ) - { - appendCommentEnd( ); - commentOpened = false; - } - } - - public AbstractInstruction getInstruction( ) - { - return instruction; - } - - /* - * (non-Javadoc) - * - * @see com.drgarbage.asm.render.intf.IInstructionLine#getLine() - */ - public int getLine( ) - { - return line; - } - - protected void openCommentIfNeeded( ) - { - if ( !commentOpened ) - { - - appendPaddedCommentBegin( ); - commentOpened = true; - } - } - - public void render( AbstractMethodRenderer methodRenderer ) throws IOException - { - this.methodRenderer = methodRenderer; - - if ( showSourceLineNumbers && methodRenderer.lineNumberTable != null ) - { - int currentStartPc = ByteCodeConstants.INVALID_OFFSET; - if ( methodRenderer.currentLineNumberTableIndex >= 0 - && methodRenderer.currentLineNumberTableIndex < methodRenderer.lineNumberTable.length ) - { - currentStartPc = methodRenderer.lineNumberTable[methodRenderer.currentLineNumberTableIndex] - .getStartPc( ); - } - - if ( currentStartPc == instruction.getOffset( ) ) - { - /* yes, this is the begining of a line */ - - appendCommentBegin( ); - appendSpace( ); - append( ByteCodeConstants.L_LINE ); - append( methodRenderer.lineNumberTable[methodRenderer.currentLineNumberTableIndex] - .getLineNumber( ) ); - appendSpace( ); - appendCommentEnd( ); - appendNewline( ); - - methodRenderer.currentLineNumberTableIndex++; - } - - } - - line = AbstractClassFileDocument.this.lineCount; - - /* - * leading spaces to padd the offsets commented out as this padding - * does not look nice in combination with try and catch blocks for - * (int i = String.valueOf(instruction.getOffset()).length(); i < - * methodRenderer.getLengthsOrderMagnitude(); i++) { appendSpace(); - * } - */ - append( String.valueOf( instruction.getOffset( ) ) ); - - appendSpace( ); - append( ByteCodeConstants.OPCODE_MNEMONICS[instruction.getOpcode( )] ); - appendOperands( ); - appendSemicolon( ); - appendComment( ); - appendNewline( ); - - this.methodRenderer = null; - } - - } - - protected class SignatureRenderer extends SignatureVisitor - { - - /** - * Stack used to keep track of class types that have arguments. Each - * element of this stack is a boolean encoded in one bit. The top of the - * stack is the lowest order bit. Pushing false = *2, pushing true = - * *2+1, popping = /2. - */ - private int argumentStack; - - /** - * Stack used to keep track of array class types. Each element of this - * stack is a boolean encoded in one bit. The top of the stack is the - * lowest order bit. Pushing false = *2, pushing true = *2+1, popping = - * /2. - */ - private int arrayStack; - - private final StringBuffer declaration; - - private StringBuffer exceptions; - - private boolean isInterface; - - private StringBuffer returnType; - - private boolean seenFormalParameter; - - private boolean seenInterface; - - private boolean seenInterfaceBound; - - private boolean seenParameter; - - private String separator = ""; - - public SignatureRenderer( final int access ) - { - super( com.drgarbage.asm.Opcodes.ASM4 ); - isInterface = ( access & ACC_INTERFACE ) != 0; - this.declaration = new StringBuffer( ); - } - - private SignatureRenderer( final StringBuffer buf ) - { - super( com.drgarbage.asm.Opcodes.ASM4 ); - this.declaration = buf; - } - - private void endFormals( ) - { - if ( seenFormalParameter ) - { - declaration.append( JavaLexicalConstants.GT ); - seenFormalParameter = false; - } - } - - private void endType( ) - { - if ( arrayStack % 2 == 0 ) - { - arrayStack /= 2; - } - else - { - while ( arrayStack % 2 != 0 ) - { - arrayStack /= 2; - declaration.append( JavaLexicalConstants.LEFT_SQUARE_BRACKET ) - .append( JavaLexicalConstants.RIGHT_SQUARE_BRACKET ); - } - } - } - - public String getDeclaration( ) - { - return declaration.toString( ); - } - - public String getExceptions( ) - { - return exceptions == null ? null : exceptions.toString( ); - } - - public String getReturnType( ) - { - return returnType == null ? null : returnType.toString( ); - } - - private void startType( ) - { - arrayStack *= 2; - } - - public SignatureVisitor visitArrayType( ) - { - startType( ); - arrayStack |= 1; - return this; - } - - public void visitBaseType( final char descriptor ) - { - - switch ( descriptor ) - { - case ByteCodeConstants.V_VOID : - declaration.append( JavaKeywords.VOID ); - break; - case ByteCodeConstants.B_BYTE : - declaration.append( JavaKeywords.BYTE ); - break; - case ByteCodeConstants.J_LONG : - declaration.append( JavaKeywords.LONG ); - break; - case ByteCodeConstants.Z_BOOLEAN : - declaration.append( JavaKeywords.BOOLEAN ); - break; - case ByteCodeConstants.I_INT : - declaration.append( JavaKeywords.INT ); - break; - case ByteCodeConstants.S_SHORT : - declaration.append( JavaKeywords.SHORT ); - break; - case ByteCodeConstants.C_CHAR : - declaration.append( JavaKeywords.CHAR ); - break; - case ByteCodeConstants.F_FLOAT : - declaration.append( JavaKeywords.FLOAT ); - break; - case ByteCodeConstants.D_DOUBLE : - declaration.append( JavaKeywords.DOUBLE ); - break; - default : - throw new IllegalArgumentException( - "Unexpected base type character '" + descriptor + "' in descriptor." ); - } - endType( ); - } - - public SignatureVisitor visitClassBound( ) - { - separator = _EXTENDS_; - startType( ); - return this; - } - - public void visitClassType( final String name ) - { - if ( ByteCodeConstants.JAVA_LANG_OBJECT.equals( name ) ) - { - // Map - // or - // abstract public V get(Object key); (seen in Dictionary.class) - // should have Object - // but java.lang.String extends java.lang.Object is unnecessary - boolean needObjectClass = argumentStack % 2 != 0 || seenParameter; - if ( needObjectClass ) - { - declaration.append( separator ) - .append( name.replace( JavaLexicalConstants.SLASH, JavaLexicalConstants.DOT ) ); - } - } - else - { - declaration.append( separator ) - .append( name.replace( JavaLexicalConstants.SLASH, JavaLexicalConstants.DOT ) ); - } - separator = ""; - argumentStack *= 2; - } - - public void visitEnd( ) - { - if ( argumentStack % 2 != 0 ) - { - declaration.append( JavaLexicalConstants.GT ); - } - argumentStack /= 2; - endType( ); - } - - public SignatureVisitor visitExceptionType( ) - { - if ( exceptions == null ) - { - exceptions = new StringBuffer( ); - } - else - { - exceptions.append( COMMA_ ); - } - // startType(); - return new SignatureRenderer( exceptions ); - } - - public void visitFormalTypeParameter( final String name ) - { - if ( seenFormalParameter ) - { - declaration.append( JavaLexicalConstants.COMMA ).append( JavaLexicalConstants.SPACE ); - } - else - { - declaration.append( JavaLexicalConstants.LT ); - seenFormalParameter = true; - } - declaration.append( name ); - seenInterfaceBound = false; - } - - public void visitInnerClassType( final String name ) - { - if ( argumentStack % 2 != 0 ) - { - declaration.append( JavaLexicalConstants.GT ); - } - argumentStack /= 2; - declaration.append( JavaLexicalConstants.DOT ); - declaration.append( separator ) - .append( name.replace( JavaLexicalConstants.SLASH, JavaLexicalConstants.DOT ) ); - separator = ""; - argumentStack *= 2; - } - - public SignatureVisitor visitInterface( ) - { - separator = seenInterface ? COMMA_ : isInterface ? _EXTENDS_ : _IMPLEMENTS_; - seenInterface = true; - startType( ); - return this; - } - - public SignatureVisitor visitInterfaceBound( ) - { - if ( seenInterfaceBound ) - { - separator = COMMA_; - } - else - { - separator = _EXTENDS_; - } - startType( ); - return this; - } - - public SignatureVisitor visitParameterType( ) - { - endFormals( ); - if ( seenParameter ) - { - declaration.append( COMMA_ ); - } - else - { - seenParameter = true; - declaration.append( JavaLexicalConstants.LEFT_PARENTHESIS ); - } - startType( ); - return this; - } - - public SignatureVisitor visitReturnType( ) - { - endFormals( ); - if ( seenParameter ) - { - seenParameter = false; - } - else - { - declaration.append( JavaLexicalConstants.LEFT_PARENTHESIS ); - } - declaration.append( JavaLexicalConstants.RIGHT_PARENTHESIS ); - returnType = new StringBuffer( ); - return new SignatureRenderer( returnType ); - } - - public SignatureVisitor visitSuperclass( ) - { - endFormals( ); - separator = _EXTENDS_; - startType( ); - return this; - } - - // ----------------------------------------------- - - public void visitTypeArgument( ) - { - if ( argumentStack % 2 == 0 ) - { - ++argumentStack; - declaration.append( JavaLexicalConstants.LT ); - } - else - { - declaration.append( JavaLexicalConstants.COMMA ).append( JavaLexicalConstants.SPACE ); - } - declaration.append( JavaLexicalConstants.QUESTION_MARK ); - } - - public SignatureVisitor visitTypeArgument( final char tag ) - { - if ( argumentStack % 2 == 0 ) - { - ++argumentStack; - declaration.append( JavaLexicalConstants.LT ); - } - else - { - declaration.append( JavaLexicalConstants.COMMA ).append( JavaLexicalConstants.SPACE ); - } - - if ( tag == EXTENDS ) - { - declaration.append( JavaLexicalConstants.QUESTION_MARK ).append( _EXTENDS_ ); - } - else if ( tag == SUPER ) - { - declaration.append( JavaLexicalConstants.QUESTION_MARK ) - .append( JavaLexicalConstants.SPACE ) - .append( JavaKeywords.SUPER ) - .append( JavaLexicalConstants.SPACE ); - } - - startType( ); - return this; - } - - public void visitTypeVariable( final String name ) - { - declaration.append( name ); - endType( ); - } - } - - protected class TextTable - { - - private ByteCodeConstants.Align[] columnAlignments; - private int[] columnWidths; - private List rows; - - public TextTable( Align[] columnAlignments ) - { - super( ); - this.columnAlignments = columnAlignments; - } - - public void addRow( String[] values ) - { - if ( rows == null ) - { - rows = new ArrayList( 4 ); - } - rows.add( values ); - } - - public void appendLine( ) - { - beginRow( ); - for ( int i = 0; i < columnWidths.length; i++ ) - { - if ( i > 0 ) - { - sb.append( JavaLexicalConstants.PLUS ).append( JavaLexicalConstants.MINUS ); - } - else - { - /* first column */ - sb.append( JavaLexicalConstants.MINUS ); - } - for ( int j = 0; j < columnWidths[i]; j++ ) - { - sb.append( JavaLexicalConstants.MINUS ); - } - sb.append( JavaLexicalConstants.MINUS ); - } - endRow( ); - } - - public void appendRow( String[] values ) - { - beginRow( ); - for ( int i = 0; i < values.length; i++ ) - { - if ( i > 0 ) - { - sb.append( JavaLexicalConstants.PIPE ).append( JavaLexicalConstants.SPACE ); - } - else - { - /* first column */ - sb.append( JavaLexicalConstants.SPACE ); - } - appendValue( values[i], columnAlignments[i], columnWidths[i] ); - sb.append( JavaLexicalConstants.SPACE ); - } - endRow( ); - } - - public void appendValue( String value, ByteCodeConstants.Align align, int width ) - { - if ( value == null ) - { - value = ""; - } - int diff = width - value.length( ); - if ( diff < 0 ) - { - diff = 0; - } - switch ( align ) - { - case LEFT : - sb.append( value ); - for ( int i = 0; i < diff; i++ ) - { - sb.append( JavaLexicalConstants.SPACE ); - } - break; - case CENTER : - int halfDiff = diff / 2; - for ( int i = 0; i < halfDiff; i++ ) - { - sb.append( JavaLexicalConstants.SPACE ); - } - sb.append( value ); - if ( diff % 2 != 0 ) - { - /* diff was not even */ - sb.append( JavaLexicalConstants.SPACE ); - } - for ( int i = 0; i < halfDiff; i++ ) - { - sb.append( JavaLexicalConstants.SPACE ); - } - break; - case RIGHT : - for ( int i = 0; i < diff; i++ ) - { - sb.append( JavaLexicalConstants.SPACE ); - } - sb.append( value ); - break; - default : - throw new IllegalStateException( "Unexpected alignment type '" + align + "'" ); - } - } - - public void beginRow( ) - { - appendCommentBegin( ); - sb.append( JavaLexicalConstants.SPACE ); - } - - public int computeWidth( ) - { - int result = 0; - for ( int i = 0; i < columnWidths.length; i++ ) - { - if ( i > 0 ) - { - result += 2; - } - else - { - /* first column */ - result++; - } - result += columnWidths[i]; - result++; - } - return result; - } - - public void endRow( ) - { - sb.append( JavaLexicalConstants.SPACE ); - appendCommentEnd( ); - appendNewline( ); - } - - protected void recomputeColumnWidths( ) - { - this.columnWidths = new int[columnAlignments.length]; - /* compute column widths */ - for ( int col = 0; col < columnAlignments.length; col++ ) - { - int w = 0; - if ( rows != null ) - { - for ( String[] row : rows ) - { - String val = row[col]; - if ( val != null && val.length( ) > w ) - { - w = val.length( ); - } - } - } - columnWidths[col] = w; - } - } - - public void render( ) - { - - if ( rows != null ) - { - if ( this.columnWidths == null ) - { - recomputeColumnWidths( ); - } - - int row = 0; - appendLine( ); - appendRow( rows.get( row ) ); - appendLine( ); - - for ( int i = 1; i < rows.size( ); i++ ) - { - appendRow( rows.get( i ) ); - } - - appendLine( ); - } - - } - } - - public static final String _EXTENDS_ = new StringBuilder( ).append( JavaLexicalConstants.SPACE ) - .append( JavaKeywords.EXTENDS ) - .append( JavaLexicalConstants.SPACE ) - .toString( ); - - public static final String _IMPLEMENTS_ = new StringBuilder( ).append( JavaLexicalConstants.SPACE ) - .append( JavaKeywords.IMPLEMENTS ) - .append( JavaLexicalConstants.SPACE ) - .toString( ); - protected static final String COMMA_ = new StringBuilder( ).append( JavaLexicalConstants.COMMA ) - .append( JavaLexicalConstants.SPACE ) - .toString( ); - public static final Attribute[] DEFAULT_ATTRIBUTES = new Attribute[0]; - public static final int DEFAULT_COMMENT_OFFSET = 24; - public static final String L_JAVA_LANG_DEPRECATED_SEMICOLON = new StringBuilder( ) - .append( ByteCodeConstants.L_REFERENCE ) - .append( ByteCodeConstants.JAVA_LANG_DEPRECATED ) - .append( JavaLexicalConstants.SEMICOLON ) - .toString( ); - protected int classSignatureDocumentLine; - - protected String classSimpleName; - - protected int commentOffset = DEFAULT_COMMENT_OFFSET; - protected AbstractConstantPoolEntry[] constantPool; - - protected ArrayList fieldSections = new ArrayList( ); - - protected MessageFormat formatCoversBytesXToY = new MessageFormat( ByteCodeConstants.COVERS_BYTES_X_TO_Y ); - protected ArrayList headerLines; - protected int indent = 0; - - protected String indentationString = " "; - protected int lineCount = 0; - protected int[] methodBorderLines; - protected ArrayList methodBorderLinesList = new ArrayList( ); - protected ArrayList methodSections = new ArrayList( ); - protected String name; - protected boolean renderTryCatchFinallyBlocks = false; - protected StringBuffer sb = new StringBuffer( ); - - protected boolean showConstantPool = false; - protected boolean showLineNumberTable = false; - - protected boolean showLocalVariableTable = false; - protected boolean showExceptionTable = false; - protected boolean showRelativeBranchTargetOffsets = true; - protected boolean showSourceLineNumbers = false; - protected boolean showMaxs = false; - - public AbstractClassFileDocument( ) - { - super( com.drgarbage.asm.Opcodes.ASM4 ); - - IPreferenceStore store = JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ); - showConstantPool = store.getBoolean( JavaDecompilerPlugin.CLASS_FILE_ATTR_SHOW_CONSTANT_POOL ); - showLineNumberTable = store.getBoolean( JavaDecompilerPlugin.CLASS_FILE_ATTR_SHOW_LINE_NUMBER_TABLE ); - showSourceLineNumbers = store.getBoolean( JavaDecompilerPlugin.CLASS_FILE_ATTR_SHOW_SOURCE_LINE_NUMBERS ); - showLocalVariableTable = store.getBoolean( JavaDecompilerPlugin.CLASS_FILE_ATTR_SHOW_VARIABLE_TABLE ); - showExceptionTable = store.getBoolean( JavaDecompilerPlugin.CLASS_FILE_ATTR_SHOW_EXCEPTION_TABLE ); - showMaxs = store.getBoolean( JavaDecompilerPlugin.CLASS_FILE_ATTR_SHOW_MAXS ); - renderTryCatchFinallyBlocks = store.getBoolean( JavaDecompilerPlugin.CLASS_FILE_ATTR_RENDER_TRYCATCH_BLOCKS ); - - if ( JavaDecompilerPlugin.BRANCH_TARGET_ADDRESS_ABSOLUTE - .equals( store.getString( JavaDecompilerPlugin.BRANCH_TARGET_ADDRESS_RENDERING ) ) ) - { - showRelativeBranchTargetOffsets = false; - } - } - - /* - * (non-Javadoc) - * - * @see - * com.drgarbage.asm.render.intf.IClassFileDocument#addFieldSection(com. - * drgarbage.asm.render.intf.IFieldSection) - */ - public void addFieldSection( IFieldSection f ) - { - fieldSections.add( f ); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Appendable#append(char) - */ - public Appendable append( char c ) - { - if ( c == '\n' ) - { - appendNewline( ); - } - else - { - appendIndentationIfNeeded( ); - sb.append( c ); - } - return null; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Appendable#append(java.lang.CharSequence) - */ - public Appendable append( CharSequence str ) - { - for ( int i = 0; i < str.length( ); i++ ) - { - append( str.charAt( i ) ); - } - return null; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Appendable#append(java.lang.CharSequence, int, int) - */ - public Appendable append( CharSequence str, int start, int end ) throws IOException - { - for ( int i = start; i < end; i++ ) - { - append( str.charAt( i ) ); - } - return null; - } - - /** - * Append an indentation string if needed an the - * String.valueOf(obj). - * - * @param obj - */ - public void append( Object obj ) - { - appendIndentationIfNeeded( ); - String s = String.valueOf( obj ); - append( s ); - } - - /** - * Appends a string representation of the given access modifiers to - * {@link #buf buf}. - * - * @param access - * some access modifiers. - */ - protected void appendAccess( final int access ) - { - appendIndentationIfNeeded( ); - if ( ( access & ACC_PUBLIC ) != 0 ) - { - append( JavaKeywords.PUBLIC ); - appendSpace( ); - } - if ( ( access & ACC_PRIVATE ) != 0 ) - { - append( JavaKeywords.PRIVATE ); - appendSpace( ); - } - if ( ( access & ACC_PROTECTED ) != 0 ) - { - append( JavaKeywords.PROTECTED ); - appendSpace( ); - } - if ( ( access & ACC_FINAL ) != 0 ) - { - append( JavaKeywords.FINAL ); - appendSpace( ); - } - if ( ( access & ACC_STATIC ) != 0 ) - { - append( JavaKeywords.STATIC ); - appendSpace( ); - } - if ( ( access & ACC_SYNCHRONIZED ) != 0 ) - { - append( JavaKeywords.SYNCHRONIZED ); - appendSpace( ); - } - if ( ( access & ACC_VOLATILE ) != 0 ) - { - append( JavaKeywords.VOLATILE ); - appendSpace( ); - } - if ( ( access & ACC_TRANSIENT ) != 0 ) - { - append( JavaKeywords.TRANSIENT ); - appendSpace( ); - } - if ( ( access & ACC_ABSTRACT ) != 0 ) - { - append( JavaKeywords.ABSTRACT ); - appendSpace( ); - } - if ( ( access & ACC_STRICT ) != 0 ) - { - append( JavaKeywords.STRICTFP ); - appendSpace( ); - } - if ( ( access & ACC_ENUM ) != 0 ) - { - append( JavaKeywords.ENUM ); - appendSpace( ); - } - } - - /** - * Appends a {@link JavaLexicalConstants#AT} and annotation. - * - * @param annotation - */ - public void appendAnnotation( String annotation ) - { - appendIndentationIfNeeded( ); - append( JavaLexicalConstants.AT ); - append( annotation ); - - } - - protected void appendClassFileFormatVersion( int version ) - { - int major = BytecodeUtils.getMajor( version ); - int minor = BytecodeUtils.getMinor( version ); - appendClassFileFormatVersion( major, minor ); - } - - protected void appendClassFileFormatVersion( int major, int minor ) - { - appendCommentBegin( ); - appendSpace( ); - sb.append( ByteCodeConstants.CLASS_FILE_FORMAT_VERSION ); - appendSpace( ); - - if ( major == ByteCodeConstants.INVALID_OFFSET || minor == ByteCodeConstants.INVALID_OFFSET ) - { - sb.append( ByteCodeConstants.UNKNOWN_INFORMATION ); - } - else - { - sb.append( major ); - appendDot( ); - sb.append( minor ); - - appendSpace( ); - appendLeftParenthesis( ); - sb.append( ByteCodeConstants.JAVA ); - appendSpace( ); - sb.append( BytecodeUtils.getLowestJavaPlatformVersion( major, minor ) ); - appendRightParenthesis( ); - appendSpace( ); - appendCommentEnd( ); - appendNewline( ); - } - } - - /** - * Append an indentation string if needed and - * {@link JavaLexicalConstants#COLON}. - * - */ - public void appendColon( ) - { - appendIndentationIfNeeded( ); - sb.append( JavaLexicalConstants.COLON ); - } - - /** - * Append an indentation string if needed and - * {@link JavaLexicalConstants#COMMA}. - * - */ - public void appendComma( ) - { - appendIndentationIfNeeded( ); - sb.append( JavaLexicalConstants.COMMA ); - } - - /** - * Append an indentation string if needed and - * {@link JavaLexicalConstants#COMMENT_BEGIN}. - * - */ - public void appendCommentBegin( ) - { - appendIndentationIfNeeded( ); - sb.append( JavaLexicalConstants.COMMENT_BEGIN ); - } - - /** - * Append an indentation string if needed and - * {@link JavaLexicalConstants#COMMENT_END}. - * - */ - public void appendCommentEnd( ) - { - appendIndentationIfNeeded( ); - sb.append( JavaLexicalConstants.COMMENT_END ); - } - - protected void appendConstantPool( ) - { - if ( showConstantPool ) - { - if ( constantPool == null ) - { - appendNewline( ); - appendCommentBegin( ); - appendSpace( ); - sb.append( ByteCodeConstants.CONSTANT_POOL_NOT_AVAILABLE ); - appendSpace( ); - appendCommentEnd( ); - appendNewline( ); - - } - else if ( constantPool.length == 0 ) - { - appendNewline( ); - appendCommentBegin( ); - appendSpace( ); - sb.append( ByteCodeConstants.CONSTANT_POOL_EMPTY ); - appendSpace( ); - appendCommentEnd( ); - appendNewline( ); - } - else - { - /* available and not empty */ - - appendNewline( ); - - TextTable tbl = new TextTable( new ByteCodeConstants.Align[]{ - ByteCodeConstants.Align.RIGHT, ByteCodeConstants.Align.LEFT, ByteCodeConstants.Align.LEFT - } ); - - tbl.addRow( new String[]{ - ByteCodeConstants.INDEX, ByteCodeConstants.TAG, ByteCodeConstants.INFO - } ); - - for ( int i = 0; i < constantPool.length; i++ ) - { - AbstractConstantPoolEntry en = constantPool[i]; - - if ( en != null ) - { - tbl.addRow( new String[]{ - String.valueOf( i ), en.getTagMnemonics( ), en.getInfo( ) - } ); - } - } - - tbl.recomputeColumnWidths( ); - tbl.beginRow( ); - tbl.appendValue( ByteCodeConstants.CONSTANT_POOL, ByteCodeConstants.Align.CENTER, tbl.computeWidth( ) ); - tbl.endRow( ); - tbl.render( ); - - } - } - } - - protected void appendDebugInfoComment( String debugInfo ) - { - appendCommentBegin( ); - appendSpace( ); - sb.append( ByteCodeConstants.DEBUG_INFO ); - appendSpace( ); - sb.append( debugInfo ); - appendSpace( ); - appendCommentEnd( ); - appendNewline( ); - } - - protected void appendDeprecated( int access ) - { - if ( ( access & ACC_DEPRECATED ) != 0 ) - { - appendAnnotation( JavaAnnotations.DEPRECATED ); - appendNewline( ); - } - } - - /** - * Append an indentation string if needed and - * {@link JavaLexicalConstants#DOT}. - * - */ - public void appendDot( ) - { - appendIndentationIfNeeded( ); - sb.append( JavaLexicalConstants.DOT ); - } - - /** - * Append an indentation string if needed and - * {@link JavaLexicalConstants#GT}. - * - */ - public void appendGt( ) - { - appendIndentationIfNeeded( ); - sb.append( JavaLexicalConstants.GT ); - } - - protected void appendHeaderComment( String classLoadedFrom, String debugTargetName ) - { - - // Bundle bundle = BytecodeVisualizerPlugin.getDefault().getBundle(); - // - // bundle = - // Platform.getBundle(CoreConstants.BYTECODE_VISUALIZER_PLUGIN_ID); - // if (bundle == null) { - // /* this should not happen */ - // throw new RuntimeException(""+ - // CoreConstants.BYTECODE_VISUALIZER_PLUGIN_ID +" not installed."); - // } - // - // String providerWww = Platform.getResourceString(bundle, "%"+ - // CoreConstants.providerWww); - // String provider = Platform.getResourceString(bundle, "%"+ - // CoreConstants.providerNameLabel); - // String pluginName = Platform.getResourceString(bundle, "%"+ - // CoreConstants.pluginName); - - // String msg = MessageFormat.format(ByteCodeConstants.Generated_by_x, - // new Object[] {provider + " "+ pluginName}); - - // appendHeaderLine(msg); - // appendHeaderLine(providerWww); - - // if (BytecodeVisualizerPlugin.getDefault() != null) { - // /* jUnit tests work only if we test for null here */ - // - // appendHeaderLine(ByteCodeConstants.Version, - // BytecodeVisualizerPlugin.PLUGIN_VERSION); - // - // } - // if (classLoadedFrom != null) { - // appendHeaderLine(ByteCodeConstants.Class_retrieved_from, - // classLoadedFrom); - // } - // if (debugTargetName != null) { - // appendHeaderLine(ByteCodeConstants.Debug_target, debugTargetName); - // } - // - // //SimpleDateFormat sdf = new - // SimpleDateFormat(CoreConstants.ISO_DATE_TIME_FORMAT_FULL); - // //appendHeaderLine(ByteCodeConstants.Retrieved_on, sdf.format(new - // Date())); - // - // - // flushHeader(); - - } - - protected void appendHeaderLine( String line ) - { - if ( headerLines == null ) - { - headerLines = new ArrayList( 8 ); - } - headerLines.add( line ); - } - - protected void appendHeaderLine( String key, String value ) - { - appendHeaderLine( key + JavaLexicalConstants.COLON + JavaLexicalConstants.SPACE + value ); - } - - /** - * Appends the indentation string {@link #indent}-times. - */ - protected void appendIndentation( ) - { - for ( int i = 0; i < indent; i++ ) - { - sb.append( indentationString ); - } - } - - /** - * Appends the indentation string {@link #indent}-times if we are just at - * the beginning of a line. - */ - protected void appendIndentationIfNeeded( ) - { - if ( sb.length( ) > 0 && sb.charAt( sb.length( ) - 1 ) == '\n' ) - { - appendIndentation( ); - } - } - - public void appendJavaSourcePath( String byteCodePath ) - { - appendIndentationIfNeeded( ); - sb.append( byteCodePath.replace( ByteCodeConstants.CLASS_NAME_SLASH, JavaLexicalConstants.DOT ) ); - } - - public void appendLeftBrace( ) - { - appendIndentationIfNeeded( ); - sb.append( JavaLexicalConstants.LEFT_BRACE ); - } - - public void appendLeftParenthesis( ) - { - sb.append( JavaLexicalConstants.LEFT_PARENTHESIS ); - - } - - /** - * Append an indentation string if needed and - * {@link JavaLexicalConstants#LT}. - * - */ - public void appendLt( ) - { - appendIndentationIfNeeded( ); - sb.append( JavaLexicalConstants.LT ); - } - - /* - * (non-Javadoc) - * - * @see - * com.drgarbage.classfile.render.intf.IClassFileDocument#appendNewline() - */ - public void appendNewline( ) - { - sb.append( JavaLexicalConstants.NEWLINE ); - lineCount++; - } - - protected void appendPackage( String thisClassName ) - { - String packageName = getPackageName( thisClassName ); - if ( packageName != null ) - { - append( JavaKeywords.PACKAGE ); - appendSpace( ); - append( packageName ); - appendSemicolon( ); - appendNewline( ); - } - } - - public void appendPaddedCommentBegin( ) - { - /* - * count the chars fom the endOffset to the last \n or beginning of the - * document - */ - int i = sb.length( ) - 1; - int lastNonWsIndex = i; - for ( ; i >= 0 && sb.charAt( i ) != '\n'; i-- ) - { - if ( !Character.isWhitespace( sb.charAt( i ) ) ) - { - lastNonWsIndex = i; - } - } - if ( sb.charAt( i ) == '\n' ) - { - i++; - } - - int targetLenghth = lastNonWsIndex + getCommentOffset( ) + 1; - if ( targetLenghth <= sb.length( ) ) - { - targetLenghth = sb.length( ) + 1; - } - - for ( int j = sb.length( ) - 1; j < targetLenghth; j++ ) - { - sb.append( JavaLexicalConstants.SPACE ); - } - - appendCommentBegin( ); - } - - public void appendRightBrace( ) - { - appendIndentationIfNeeded( ); - sb.append( JavaLexicalConstants.RIGHT_BRACE ); - } - - public void appendRightParenthesis( ) - { - sb.append( JavaLexicalConstants.RIGHT_PARENTHESIS ); - - } - - public void appendSemicolon( ) - { - appendIndentationIfNeeded( ); - sb.append( JavaLexicalConstants.SEMICOLON ); - } - - protected void appendSourcePathComment( String path ) - { - appendNewline( ); - appendCommentBegin( ); - appendSpace( ); - sb.append( ByteCodeConstants.COMPILED_FROM ); - appendSpace( ); - sb.append( path ); - appendSpace( ); - appendCommentEnd( ); - appendNewline( ); - - } - - public void appendSpace( ) - { - appendIndentationIfNeeded( ); - sb.append( JavaLexicalConstants.SPACE ); - } - - protected AnnotationRenderer createTraceAnnotationVisitor( ) - { - return new AnnotationRenderer( ); - } - - /* - * (non-Javadoc) - * - * @see - * com.drgarbage.classfile.render.intf.IClassFileDocument#decrementIndent() - */ - public void decrementIndent( ) - { - indent--; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals( Object obj ) - { - return sb.equals( obj ); - } - - /* - * (non-Javadoc) - * - * @see com.drgarbage.asm.render.intf.IClassFileDocument#findField(int) - */ - public IFieldSection findFieldSection( int line ) - { - for ( IFieldSection f : getFieldSections( ) ) - { - if ( f.getBytecodeDocumentLine( ) == line ) - { - return f; - } - } - - return null; - } - - /* - * (non-Javadoc) - * - * @see - * com.drgarbage.asm.render.intf.IClassFileDocument#findFieldSection(java. - * lang.String) - */ - public IFieldSection findFieldSection( String fieldName ) - { - for ( IFieldSection f : getFieldSections( ) ) - { - if ( f.getName( ).equals( fieldName ) ) - { - return f; - } - } - - return null; - } - - public int findIndentationAt( int index ) - { - int result = 0; - int i = index; - while ( ( sb.charAt( i ) ) != '\n' ) - { - i--; - } - while ( i + indentationString.length( ) < index && matchPosition( i, indentationString ) ) - { - result++; - i += indentationString.length( ); - } - return result; - } - - public IInstructionLine findInstructionLine( int sourceCodeLine ) - { - List methodSections = getMethodSections( ); - if ( methodSections != null ) - { - for ( IMethodSection methodSection : methodSections ) - { - IInstructionLine result = methodSection.findInstructionLine( sourceCodeLine ); - if ( result != null ) - { - return result; - } - } - } - return null; - } - - /* - * (non-Javadoc) - * - * @see - * com.drgarbage.classfile.render.intf.IClassFileDocument#findMethod(int) - */ - public IMethodSection findMethodSection( int line ) - { - for ( IMethodSection ms : methodSections ) - { - if ( ms.getFirstLine( ) != ByteCodeConstants.INVALID_OFFSET - && ms.getFirstLine( ) <= line - && ms.getLastLine( ) != ByteCodeConstants.INVALID_OFFSET - && ms.getLastLine( ) >= line ) - { - return ms; - } - } - return null; - } - - /* - * (non-Javadoc) - * - * @see - * com.drgarbage.asm.render.intf.IClassFileDocument#findMethodSection(java. - * lang.String, java.lang.String) - */ - public IMethodSection findMethodSection( String methodName, String methodSignature ) - { - for ( IMethodSection m : getMethodSections( ) ) - { - if ( m.getDescriptor( ).equals( methodSignature ) && m.getName( ).equals( methodName ) ) - { - return m; - } - } - - return null; - } - - @SuppressWarnings("unused") - private void flushHeader( ) - { - if ( headerLines != null && headerLines.size( ) > 0 ) - { - int maxLength = 0; - for ( String line : headerLines ) - { - if ( line.length( ) > maxLength ) - { - maxLength = line.length( ); - } - } - - appendCommentBegin( ); - appendSpace( ); - for ( int i = 0; i < maxLength; i++ ) - { - sb.append( JavaLexicalConstants.ASTERISK ); - } - appendSpace( ); - appendCommentEnd( ); - appendNewline( ); - - for ( String line : headerLines ) - { - appendCommentBegin( ); - appendSpace( ); - sb.append( line ); - for ( int i = 0; i < maxLength - line.length( ); i++ ) - { - appendSpace( ); - } - appendSpace( ); - appendCommentEnd( ); - appendNewline( ); - } - - appendCommentBegin( ); - appendSpace( ); - for ( int i = 0; i < maxLength; i++ ) - { - sb.append( JavaLexicalConstants.ASTERISK ); - } - appendSpace( ); - appendCommentEnd( ); - appendNewline( ); - - } - - /* free the list */ - headerLines = null; - } - - public String getClassName( ) - { - return name; - } - - public int getClassSignatureDocumentLine( ) - { - return classSignatureDocumentLine; - } - - public String getClassSimpleName( ) - { - return classSimpleName; - } - - public int getCommentOffset( ) - { - return commentOffset; - } - - public AbstractConstantPoolEntry[] getConstantPool( ) - { - return constantPool; - } - - /* - * (non-Javadoc) - * - * @see com.drgarbage.asm.render.intf.IClassFileDocument#getFieldSections() - */ - public List getFieldSections( ) - { - return fieldSections; - } - - public int getIndent( ) - { - return indent; - } - - public String getIndentationString( ) - { - return indentationString; - } - - public int getLineCount( ) - { - return lineCount; - } - - /* - * (non-Javadoc) - * - * @see - * com.drgarbage.classfile.render.intf.IClassFileDocument#getMethodSections( - * ) - */ - public List getMethodSections( ) - { - return methodSections; - } - - protected String getPackageName( String thisClassName ) - { - return JavaSourceUtils.getPackage( name ); - } - - public int hashCode( ) - { - return sb.hashCode( ); - } - - /* - * (non-Javadoc) - * - * @see - * com.drgarbage.classfile.render.intf.IClassFileDocument#incrementIndent() - */ - public void incrementIndent( ) - { - indent++; - } - - /* - * (non-Javadoc) - * - * @see - * com.drgarbage.asm.render.intf.IClassFileDocument#isFieldSelected(int) - */ - public boolean isLineInField( int line ) - { - for ( IFieldSection fs : fieldSections ) - { - if ( fs.getBytecodeDocumentLine( ) == line ) - { - return true; - } - } - return false; - } - - /* - * (non-Javadoc) - * - * @see - * com.drgarbage.classfile.render.intf.IClassFileDocument#isLineInMethod( - * int) - */ - public boolean isLineInMethod( int line ) - { - int found = Arrays.binarySearch( methodBorderLines, line ); - if ( found >= 0 ) - { - /* - * we found a border line which is in a method - */ - return true; - } - else - { - /* the match is somewhere in between the border line numbers */ - /* - * the theory here is very simple: test, if the found = - * (-(insertion point) - 1) is even or odd even means between - * start and end of a method so return true or false otherwise - */ - return found % 2 == 0; - } - } - - /** - * true if the try, catch and - * finally blocks are rendered by this; false - * otherwise. - * - * @return the renderTryCatchFinallyBlocks - */ - public boolean isRenderTryCatchFinallyBlocks( ) - { - return renderTryCatchFinallyBlocks; - } - - /** - * Returns the number of characters in the internal {@link StringBuilder}. - * - * @return true or false - */ - - public int length( ) - { - return sb.length( ); - } - - protected boolean matchPosition( int position, String str ) - { - for ( int i = 0; i < str.length( ); i++ ) - { - if ( sb.charAt( i + position ) != str.charAt( i ) ) - { - return false; - } - } - return true; - } - - public void setCommentOffset( int commentOffset ) - { - this.commentOffset = commentOffset; - } - - public void setIndent( int indent ) - { - this.indent = indent; - } - - public void setIndentationString( String indentationString ) - { - this.indentationString = indentationString; - } - - /** - * Sets the boolean flag telling if the the try, - * catch and finally blocks will be rendered - * (true) by this or not (false). - * - * @param renderTryCatchFinallyBlocks - * the renderTryCatchFinallyBlocks to set - */ - public void setRenderTryCatchFinallyBlocks( boolean renderTryCatchFinallyBlocks ) - { - this.renderTryCatchFinallyBlocks = renderTryCatchFinallyBlocks; - } - - /** - * Returns the textual representation of this {@link ClassFileDocument}. - * - * @return the textual representation of this {@link ClassFileDocument} - */ - public String toString( ) - { - return sb.toString( ); - } - - /** - * Prints a disassembled view of the given annotation. - * - * @param desc - * the class descriptor of the annotation class. - * @param visible - * true if the annotation is visible at runtime. - * @return a visitor to visit the annotation values. - */ - protected AnnotationVisitor visitAnnotationImpl( final String desc, final boolean visible ) - { - if ( !L_JAVA_LANG_DEPRECATED_SEMICOLON.equals( desc ) ) - { - // TODO test the annotation - appendNewline( ); - appendCommentBegin( ); - appendSpace( ); - if ( visible ) - { - sb.append( ByteCodeConstants.VISIBLE ); - } - else - { - sb.append( ByteCodeConstants.INVISIBLE ); - } - appendSpace( ); - sb.append( ByteCodeConstants.ANNOTATION ); - appendSpace( ); - appendCommentEnd( ); - appendNewline( ); - - append( JavaLexicalConstants.AT ); - // FIXME render the descriptor - sb.append( desc ); - sb.append( JavaLexicalConstants.LEFT_PARENTHESIS ); - // FIXME Annotations rendering - AnnotationRenderer tav = createTraceAnnotationVisitor( ); - sb.append( JavaLexicalConstants.RIGHT_PARENTHESIS ); - appendNewline( ); - return tav; - } - else - { - return null; - } - } - - /** - * Prints a disassembled view of the given attribute. - * - * @param attr - * an attribute. - */ - public void visitAttributeImpl( final Attribute attr ) - { - // FIXME attribute rendering - appendNewline( ); - appendCommentBegin( ); - appendSpace( ); - sb.append( ByteCodeConstants.ATTRIBUTE ); - appendSpace( ); - appendCommentEnd( ); - appendNewline( ); - - appendCommentBegin( ); - appendSpace( ); - // TODO class name rendering - sb.append( attr.type ); - appendSpace( ); - appendCommentEnd( ); - appendNewline( ); - - // if (attr instanceof Traceable) { - // ((Traceable) attr).trace(sb, null); - // } - } - - public void visitConstantPool( final byte[] bytes, int offset, int entryCount ) - { - if ( bytes == null || entryCount == 0 ) - { - constantPool = null; - } - else - { - ConstantPoolParser cpp = new ConstantPoolParser( bytes, offset, entryCount ); - constantPool = cpp.parse( ); - } - } - - protected FieldVisitor visitField( final int access, final String name, final String desc, final String signature - // final Object value - ) - { - - appendNewline( ); - appendDeprecated( access ); - - int fieldLine = lineCount; - - appendAccess( access ); - - if ( signature != null ) - { - - SignatureRenderer sv = new SignatureRenderer( 0 ); - SignatureReader r = new SignatureReader( signature ); - r.acceptType( sv ); - sb.append( sv.getDeclaration( ) ); - appendSpace( ); - append( name ); - appendSemicolon( ); - appendNewline( ); - } - else - { - try - { - BytecodeUtils.appendFieldDescriptor( desc, 0, sb ); - } - catch ( IOException e ) - { - throw new RuntimeException( e ); - } - appendSpace( ); - append( name ); - appendSemicolon( ); - appendNewline( ); - - } - - FieldRenderer fieldRenderer = new FieldRenderer( name, desc, fieldLine ); - - fieldSections.add( fieldRenderer ); - - return fieldRenderer; - - } - -} \ No newline at end of file diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/impl/ClassFileDocument.java b/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/impl/ClassFileDocument.java deleted file mode 100644 index c51c5a37..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/impl/ClassFileDocument.java +++ /dev/null @@ -1,449 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.asm.render.impl; - -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -import com.drgarbage.asm.AnnotationVisitor; -import com.drgarbage.asm.Attribute; -import com.drgarbage.asm.ClassReader; -import com.drgarbage.asm.ClassVisitor; -import com.drgarbage.asm.FieldVisitor; -import com.drgarbage.asm.MethodVisitor; -import com.drgarbage.asm.render.intf.IClassFileDocument; -import com.drgarbage.asm.render.intf.ILocalVariableTable; -import com.drgarbage.asm.signature.SignatureReader; -import com.drgarbage.bytecode.ByteCodeConstants; -import com.drgarbage.bytecode.BytecodeUtils; -import com.drgarbage.bytecode.ExceptionTableEntry; -import com.drgarbage.javasrc.JavaKeywords; - -public class ClassFileDocument extends AbstractClassFileDocument { - - /** - * Renderer Class for Exception Table Objects. - */ - protected static class ExceptionTableEntryComparator implements java.util.Comparator { - - public int compare(ExceptionTableEntry o1, ExceptionTableEntry o2) { - if (o1 == o2) { - return 0; - } - else if (o1 == null) { - return -1; - } - else if (o2 == null) { - return 1; - } - else { - /* none of the two is null */ - - if (o1.getStartPc() < o2.getStartPc()) { - return -1; - } - else if (o1.getStartPc() > o2.getStartPc()) { - return 1; - } - else { - /* equal start_pc */ - if (o1.getEndPc() > o2.getEndPc()) { - /* we want wider try blocks to occur first */ - return -1; - } - else if (o1.getEndPc() < o2.getEndPc()) { - return 1; - } - else { - /* they cover the same block */ - if (o1.getHandlerPc() < o2.getHandlerPc()) { - /* let the handler with the handler - * closer to 0 win */ - return -1; - } - else if (o1.getHandlerPc() < o2.getHandlerPc()) { - return 1; - } - else { - /* they are completely equal */ - return 0; - } - } - } - } - } - - } - - - protected static class ListMap extends HashMap> { - - private static final long serialVersionUID = 2842382259729658163L; - - public void putToList(K key, V value) { - List list = get(key); - if (list == null) { - list = new ArrayList(); - super.put(key, list); - } - list.add(value); - } - - } - - protected class MethodRenderer extends AbstractMethodRenderer { - - public MethodRenderer(int access, String name, String descriptor, - String signature, String[] exceptions) { - super(access, name, descriptor, signature, exceptions); - } - - public MethodRenderer(int access, String name, String descriptor, - String signature, String[] exceptions, MethodVisitor mv) { - super(access, name, descriptor, signature, exceptions, mv); - } - - @Override - protected ILocalVariableTable createLocalVariableTable(boolean available) { - return new LocalVariableTable(ClassFileDocument.this.constantPool, available); - } - - } - - /** - * Prints a disassembled view of the given class to the standard output.

      - * Usage: TraceClassVisitor [-debug] <fully qualified class name or class - * file name > - * - * @param args the command line arguments. - * - * @throws Exception if the class cannot be found, or if an IO exception - * occurs. - */ - public static void main(final String[] args) throws Exception { - int i = 0; - int flags = ClassReader.SKIP_DEBUG; - - boolean ok = true; - if (args.length < 1 || args.length > 2) { - ok = false; - } - if (ok && "-debug".equals(args[0])) { - i = 1; - flags = 0; - if (args.length != 2) { - ok = false; - } - } - if (!ok) { - System.err.println("Prints a disassembled view of the given class."); - System.err.println("Usage: TraceClassVisitor [-debug] " - + ""); - return; - } - ClassReader cr; - if (args[i].endsWith(".class") || args[i].indexOf('\\') > -1 - || args[i].indexOf('/') > -1) - { - cr = new ClassReader(new FileInputStream(args[i])); - } else { - cr = new ClassReader(args[i]); - } - cr.accept(new ClassFileDocument(null), - DEFAULT_ATTRIBUTES, - flags); - } - - - public static IClassFileDocument readClass(InputStream in) throws IOException { - ClassFileDocument doc = new ClassFileDocument(); - ClassReader cr = new ClassReader(in, doc); - cr.accept(doc, AbstractClassFileDocument.DEFAULT_ATTRIBUTES, 0); - return doc; - } - - - - /** - * The print writer to be used to print the class. - */ - //protected final PrintWriter pw; - - private ClassVisitor classVisitor; - - private ClassFileDocument() { - this(null); - } - /** - * Constructs a new class file document. - * - * @param classVisitor the class visitor. - * @see ClassVisitor - */ - public ClassFileDocument(ClassVisitor classVisitor) { - //this.pw = pw; - this.classVisitor = classVisitor; - - } - - // ------------------------------------------------------------------------ - // Implementation of the ClassVisitor interface - // ------------------------------------------------------------------------ - - - public void visit( - final int version, - final int access, - final String name, - final String signature, - final String superName, - final String[] interfaces) - { - this.name = BytecodeUtils.toJavaSrcName(name); - classSimpleName = BytecodeUtils.getSimpleName(name); - - //appendHeaderComment(ByteCodeConstants.Filesystem, null); - //appendNewline(); - appendClassFileFormatVersion(version); - - appendPackage(name); - appendNewline(); - - appendDeprecated(access); - - appendAccess(access & ~ACC_SUPER); - if ((access & ACC_ANNOTATION) != 0) { - appendAnnotation(JavaKeywords.INTERFACE); - appendSpace(); - } else if ((access & ACC_INTERFACE) != 0) { - sb.append(JavaKeywords.INTERFACE); - appendSpace(); - } else if ((access & ACC_ENUM) == 0) { - sb.append(JavaKeywords.CLASS); - appendSpace(); - } - - sb.append(classSimpleName); - classSignatureDocumentLine = lineCount; /* set class file line number reference */ - if (signature != null) { - SignatureRenderer sv = new SignatureRenderer(access); - SignatureReader r = new SignatureReader(signature); - r.accept(sv); - sb.append(sv.getDeclaration()); - } - else { - /* null signature */ - if (superName != null && !ByteCodeConstants.JAVA_LANG_OBJECT.equals(superName)) { - appendSpace(); - append(JavaKeywords.EXTENDS); - appendSpace(); - appendJavaSourcePath(superName); - } - if (interfaces != null && interfaces.length > 0) { - appendSpace(); - append(JavaKeywords.IMPLEMENTS); - - for (int i = 0; i < interfaces.length; ++i) { - if (i != 0) { - appendComma(); - } - appendSpace(); - appendJavaSourcePath(interfaces[i]); - } - } - } - - appendSpace(); - appendLeftBrace(); - appendNewline(); - incrementIndent(); - - appendConstantPool(); - - if (classVisitor != null) { - classVisitor.visit(version, - access, - name, - signature, - superName, - interfaces); - } - } - - public AnnotationVisitor visitAnnotation( - final String desc, - final boolean visible) - { - return visitAnnotationImpl(desc, visible); - } - - - public void visitAttribute(final Attribute attr) { - //FIXME Attribute rendering - visitAttributeImpl(attr); - - if (classVisitor != null) { - classVisitor.visitAttribute(attr); - } - - } - - public void visitEnd() { - decrementIndent(); - appendRightBrace(); - appendNewline(); - - if (classVisitor != null) { - classVisitor.visitEnd(); - } - - methodBorderLines = new int[methodBorderLinesList.size()]; - for (int i = 0; i < methodBorderLinesList.size(); i++) { - methodBorderLines[i] = methodBorderLinesList.get(i).intValue(); - } - methodBorderLinesList = null; - - } - - public FieldVisitor visitField( - final int access, - final String name, - final String desc, - final String signature, - final Object value) - { - FieldVisitor fieldVisitor = super.visitField(access, name, desc, signature); - if (classVisitor != null) { - classVisitor.visitField(access, name, desc, signature, value); - } - - return fieldVisitor; - } - - public void visitInnerClass( - final String name, - final String outerName, - final String innerName, - final int access) - { - - if (name == null || !BytecodeUtils.toJavaSrcName(name).equals(this.name)) { - /* only show as inner class - * if the name of thisClass is unequal with name */ - appendNewline(); - appendCommentBegin(); - appendSpace(); - sb.append(ByteCodeConstants.INNER_CLASS); - appendSpace(); - appendCommentEnd(); - appendNewline(); - - appendCommentBegin(); - appendSpace(); - appendAccess(access & ~ACC_SUPER); - sb.append(innerName); - appendSpace(); - appendCommentEnd(); - appendNewline(); - - } - - if (classVisitor != null) { - classVisitor.visitInnerClass(name, outerName, innerName, access); - } - } - - public MethodVisitor visitMethod( - final int access, - final String name, - final String desc, - final String signature, - final String[] exceptions) - { - if (classVisitor != null) { - classVisitor.visitMethod( - access, - name, - desc, - signature, - exceptions); - } - return new MethodRenderer(access, name, desc, signature, exceptions); - } - - public void visitOuterClass( - final String owner, - final String name, - final String desc) - { - // TODO test outer class - appendNewline(); - appendCommentBegin(); - appendSpace(); - sb.append(ByteCodeConstants.OUTER_CLASS); - appendSpace(); - appendCommentEnd(); - appendNewline(); - - appendCommentBegin(); - appendSpace(); - //FIXME format the owner - sb.append(owner); - appendSpace(); - appendCommentEnd(); - appendNewline(); - - if (name != null) { - appendCommentBegin(); - appendSpace(); - sb.append(ByteCodeConstants.IN_METHOD); - appendSpace(); - - //FIXME format the name - sb.append(name); - appendSpace(); - //FIXME format the descriptor - sb.append(desc); - appendSpace(); - appendCommentEnd(); - appendNewline(); - } - - if (classVisitor != null) { - classVisitor.visitOuterClass(owner, name, desc); - } - } - - public void visitSource(final String file, final String debugInfo) { - if (file != null) { - appendSourcePathComment(file); - } - if (debugInfo != null) { - appendDebugInfoComment(debugInfo); - } - - if (classVisitor != null) { - classVisitor.visitSource(file, debugInfo); - } - - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/impl/ClassFileOutlineElement.java b/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/impl/ClassFileOutlineElement.java deleted file mode 100644 index 54ed1135..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/impl/ClassFileOutlineElement.java +++ /dev/null @@ -1,199 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.asm.render.impl; - -import org.eclipse.jdt.core.IJavaElement; - -import com.drgarbage.asm.AnnotationVisitor; -import com.drgarbage.asm.Attribute; -import com.drgarbage.asm.FieldVisitor; -import com.drgarbage.asm.MethodVisitor; -import com.drgarbage.asm.render.intf.IClassFileDocument; -import com.drgarbage.bytecode.ByteCodeConstants; -import com.drgarbage.bytecode.BytecodeUtils; - -public class ClassFileOutlineElement extends OutlineElement { - private IClassFileDocument classFileDocument; - private int fieldCount = 0; - private int methodCount = 0; - /** - * The type outline element. Class, Interface or Enum. - */ - private OutlineElementType typeElement; - - /** - * - */ - public ClassFileOutlineElement() { - super(com.drgarbage.asm.Opcodes.ASM4); - typeElement = new OutlineElementType(); - } - - @Override - public IJavaElement getPrimaryElement() { - return typeElement; - } - - /** - * @param classFileDocument the classFileDocument to set - */ - public void setClassFileDocument(IClassFileDocument classFileDocument) { - this.classFileDocument = classFileDocument; - } - - /* (non-Javadoc) - * @see com.drgarbage.asm.ClassVisitor#visit(int, int, java.lang.String, java.lang.String, java.lang.String, java.lang.String[]) - */ - public void visit(int version, int access, String name, String signature, - String superName, String[] interfaces) { - - typeElement.setFlags(access); - - if(name.contains(String.valueOf(ByteCodeConstants.CLASS_NAME_POINT))){ - name = name.replace(ByteCodeConstants.CLASS_NAME_POINT, ByteCodeConstants.CLASS_NAME_SLASH); - } - - int i = name.lastIndexOf(ByteCodeConstants.CLASS_NAME_SLASH); - - if (i >= 0) { - /* create outline object*/ - OutlineElement packageElement = new OutlineElement(com.drgarbage.asm.Opcodes.ASM4); - packageElement.setElementType(IJavaElement.PACKAGE_DECLARATION); - packageElement.setElementName(name.substring(0, i)); - - // TODO test if the -3 works for all circumstances - packageElement.setBytecodeDocumentLine(classFileDocument.getLineCount() - 3); - - /* add package and type outline element */ - addChild(packageElement); - } - - addChild(typeElement); - - /* set the outline property */ - typeElement.setElementName(BytecodeUtils.getSimpleName(name)); - typeElement.setFullyQualifiedName(name); - typeElement.setBytecodeDocumentLine(classFileDocument.getLineCount() - 1); - } - - /* (non-Javadoc) - * @see com.drgarbage.asm.ClassVisitor#visitAnnotation(java.lang.String, boolean) - */ - public AnnotationVisitor visitAnnotation(String desc, boolean visible) { - return null; - } - - /* (non-Javadoc) - * @see com.drgarbage.asm.ClassVisitor#visitAttribute(com.drgarbage.asm.Attribute) - */ - public void visitAttribute(Attribute attr) { - } - - /* (non-Javadoc) - * @see com.drgarbage.asm.ClassVisitor#visitEnd() - */ - public void visitEnd() { - } - - /* (non-Javadoc) - * @see com.drgarbage.asm.ClassVisitor#visitField(int, java.lang.String, java.lang.String, java.lang.String, java.lang.Object) - */ - public FieldVisitor visitField(int access, String name, String desc, - String signature, Object value) { - - /* create outline objects */ - OutlineElementField field = new OutlineElementField(typeElement,classFileDocument, fieldCount++); - field.setElementName(name); - field.setFlags(access); - field.setTypeSignature(desc); - field.setBytecodeDocumentLine(classFileDocument.getLineCount() - 1); - typeElement.addChild(field); - - return null; - } - - /* (non-Javadoc) - * @see com.drgarbage.asm.ClassVisitor#visitInnerClass(java.lang.String, java.lang.String, java.lang.String, int) - */ - public void visitInnerClass(String name, String outerName, - String innerName, int access) { - } - - /* (non-Javadoc) - * @see com.drgarbage.asm.ClassVisitor#visitMethod(int, java.lang.String, java.lang.String, java.lang.String, java.lang.String[]) - */ - public MethodVisitor visitMethod(int access, String name, String desc, - String signature, String[] exceptions) { - - OutlineElementMethod method = new OutlineElementMethod(typeElement, classFileDocument, methodCount++); - if(name.startsWith(ByteCodeConstants.INIT)){ - method.setConstructor(true); - method.setElementName(typeElement.getElementName()); - } - else if(name.startsWith(ByteCodeConstants.CLINIT)){ - method.setConstructor(false); - method.setElementName(ByteCodeConstants.CLINIT_MNEMONICS); - } - else{ - method.setConstructor(false); - method.setElementName(name); - } - method.setFlags(access); - - /* - * FIX: bug#47 Selection of the last element of javax.servlet.http.HttpServletRequest - * in the outline not working properly - * DESCRIPTION: - * The reason is the key @Deprecated - * The first line variable of the method section is set to 70 instead of 71 by - * class file document parser. - * - * 70 @Deprecated - * 71 public abstract boolean isRequestedSessionIdFromUrl(); - * - * If you are clcking on the corresponding outline element of the method - * isRequestedSessionIdFromUrl the line 70 is selected in the bytecode view. - * This line is not assigned to any method sections and the focus is set to the - * class element. - */ - if ((access & com.drgarbage.asm.Opcodes.ACC_DEPRECATED) != 0) { - method.setBytecodeDocumentLine(classFileDocument.getLineCount() + 2); - } - else{ - method.setBytecodeDocumentLine(classFileDocument.getLineCount() + 1); - } - - method.setMethodDescriptor(desc); - typeElement.addChild(method); - - - return null; - } - - /* (non-Javadoc) - * @see com.drgarbage.asm.ClassVisitor#visitOuterClass(java.lang.String, java.lang.String, java.lang.String) - */ - public void visitOuterClass(String owner, String name, String desc) { - } - - /* (non-Javadoc) - * @see com.drgarbage.asm.ClassVisitor#visitSource(java.lang.String, java.lang.String) - */ - public void visitSource(String source, String debug) { - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/impl/LocalVariableTable.java b/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/impl/LocalVariableTable.java deleted file mode 100644 index db6b347a..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/impl/LocalVariableTable.java +++ /dev/null @@ -1,178 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.asm.render.impl; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; - -import com.drgarbage.asm.render.intf.ILocalVariableTable; -import com.drgarbage.bytecode.ByteCodeConstants; -import com.drgarbage.bytecode.LocalVariableTableEntry; -import com.drgarbage.bytecode.LocalVariableTypeTableEntry; -import com.drgarbage.bytecode.ByteCodeConstants.Align; -import com.drgarbage.bytecode.constant_pool.AbstractConstantPoolEntry; -import com.drgarbage.bytecode.constant_pool.ConstantUtf8Info; - -public class LocalVariableTable implements ILocalVariableTable { - - private static String[] HEADER = new String[] { - ByteCodeConstants.INDEX, - ByteCodeConstants.START_PC, - ByteCodeConstants.LENGTH, - ByteCodeConstants.NAME_INDEX, - ByteCodeConstants.DESCRIPTOR_INDEX, -// ByteCodeConstants.NAME, -// ByteCodeConstants.DESCRIPTOR - }; - - private boolean available = true; - protected AbstractConstantPoolEntry[] constantPool; - - private HashMap indexedLocalVariableTable = new HashMap(); - - private List localVariableTable; - - private List localVariableTypeTable; - public LocalVariableTable(AbstractConstantPoolEntry[] constantPool, - boolean available) { - super(); - this.constantPool = constantPool; - this.available = available; - } - - public void addLocalVariableTableEntry(LocalVariableTableEntry entry) { - if (localVariableTable == null) { - localVariableTable = new LinkedList(); - } - localVariableTable.add(entry); - - Integer key = Integer.valueOf(entry.getIndex()); - LocalVariableTableEntry[] entries = indexedLocalVariableTable.get(key); - if (entries == null) { - entries = new LocalVariableTableEntry[1]; - entries[0] = entry; - } - else { - /* realloc */ - LocalVariableTableEntry[] newEntries = new LocalVariableTableEntry[entries.length +1]; - System.arraycopy(entries, 0, newEntries, 0, entries.length); - entries = newEntries; - entries[entries.length - 1] = entry; - - /* check if reordering is necessary */ - LocalVariableTableEntry last = entries[entries.length -2]; - if (ILocalVariableTable.END_OFFSET_COMPARATOR.compare(last, entry) > 0) { - /* last > entry: reordering needed */ - Arrays.sort(entries, ILocalVariableTable.END_OFFSET_COMPARATOR); - } - } - indexedLocalVariableTable.put(key, entries); - } - public void addLocalVariableTypeTableEntry(LocalVariableTypeTableEntry entry) { - if (localVariableTypeTable == null) { - localVariableTypeTable = new LinkedList(); - } - localVariableTypeTable.add(entry); - } - - public String findArgName(int i, int offset, boolean isConstructor, boolean isStatic) { - if (constantPool == null) { - return null; - } - int argi = isStatic || isConstructor ? i : i+1; - - LocalVariableTableEntry[] entries = indexedLocalVariableTable.get(Integer.valueOf(argi)); - LocalVariableTableEntry match = null; - if (entries != null) { - if (entries.length == 1) { - match = entries[0]; - } - else if (entries.length > 1) { - /* search */ - for (LocalVariableTableEntry e : entries) { - if (offset < e.getStartPc() + e.getLength()) { - /* take the first which is just lower than - * we can do it, as entries are sorted according to - * their end offsets. - * We do not check the start offset: - * - * "The given local variable must have a value at indices into - * the code array in the interval [start_pc, start_pc+length], - * that is, between start_pc and start_pc+length inclusive." - * - * http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html#5956 - * - * Note that the specification mentions only where the variable - * must have a value. As a matter of fact, a variable is initialized - * at offsets where it is still does not have a value. - * So the name of the variable is valid even before the start_pc. - * - * This has to do with BUG#118 - * - * */ - match = e; - break; - } - } - } - } - - if (match != null) { - return ((ConstantUtf8Info)constantPool[match.getNameIndex()]).getString(); - } - return null; - } - - - - public Align getAlignment(int column) { - return Align.RIGHT; - } - - public List getEntries() { - return localVariableTable; - } - - public String[] getHeader() { - return HEADER; - } - - public int getLength() { - return localVariableTable == null ? 0 : localVariableTable.size(); - } - - public String[] getRow(int index) { - LocalVariableTableEntry en = localVariableTable.get(index); - return new String[] { - String.valueOf(en.getIndex()), - String.valueOf(en.getStartPc()), - String.valueOf(en.getLength()), - String.valueOf(en.getNameIndex()), - String.valueOf(en.getDescriptorIndex()) - -// ((ConstantUtf8Info)constantPool[en.getNameIndex()]).getString(), -// ((ConstantUtf8Info)constantPool[en.getDescriptorIndex()]).getString() - }; - } - - public boolean isAvailable() { - return available; - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/impl/Opcodes.java b/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/impl/Opcodes.java deleted file mode 100644 index e1fccae2..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/impl/Opcodes.java +++ /dev/null @@ -1,239 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.asm.render.impl; - -import com.drgarbage.bytecode.ByteCodeConstants; - -/** - * Opcode constants. Use the {@link ByteCodeConstants} to map - * the numeric opcodes to their textual mnemonics. - * - * @see ByteCodeConstants - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision:81 $ - * $Id:Opcodes.java 81 2007-05-10 08:38:47Z Peter Palaga $ - */ -public interface Opcodes { - - public static final int NOP = 0x00; - public static final int ACONST_NULL = 0x01; - public static final int ICONST_M1 = 0x02; - public static final int ICONST_0 = 0x03; - public static final int ICONST_1 = 0x04; - public static final int ICONST_2 = 0x05; - public static final int ICONST_3 = 0x06; - public static final int ICONST_4 = 0x07; - public static final int ICONST_5 = 0x08; - public static final int LCONST_0 = 0x09; - public static final int LCONST_1 = 0x0a; - public static final int FCONST_0 = 0x0b; - public static final int FCONST_1 = 0x0c; - public static final int FCONST_2 = 0x0d; - public static final int DCONST_0 = 0x0e; - public static final int DCONST_1 = 0x0f; - public static final int BIPUSH = 0x10; - public static final int SIPUSH = 0x11; - public static final int LDC = 0x12; - public static final int LDC_W = 0x13; - public static final int LDC2_W = 0x14; - public static final int ILOAD = 0x15; - public static final int LLOAD = 0x16; - public static final int FLOAD = 0x17; - public static final int DLOAD = 0x18; - public static final int ALOAD = 0x19; - public static final int ILOAD_0 = 0x1a; - public static final int ILOAD_1 = 0x1b; - public static final int ILOAD_2 = 0x1c; - public static final int ILOAD_3 = 0x1d; - public static final int LLOAD_0 = 0x1e; - public static final int LLOAD_1 = 0x1f; - public static final int LLOAD_2 = 0x20; - public static final int LLOAD_3 = 0x21; - public static final int FLOAD_0 = 0x22; - public static final int FLOAD_1 = 0x23; - public static final int FLOAD_2 = 0x24; - public static final int FLOAD_3 = 0x25; - public static final int DLOAD_0 = 0x26; - public static final int DLOAD_1 = 0x27; - public static final int DLOAD_2 = 0x28; - public static final int DLOAD_3 = 0x29; - public static final int ALOAD_0 = 0x2a; - public static final int ALOAD_1 = 0x2b; - public static final int ALOAD_2 = 0x2c; - public static final int ALOAD_3 = 0x2d; - public static final int IALOAD = 0x2e; - public static final int LALOAD = 0x2f; - public static final int FALOAD = 0x30; - public static final int DALOAD = 0x31; - public static final int AALOAD = 0x32; - public static final int BALOAD = 0x33; - public static final int CALOAD = 0x34; - public static final int SALOAD = 0x35; - public static final int ISTORE = 0x36; - public static final int LSTORE = 0x37; - public static final int FSTORE = 0x38; - public static final int DSTORE = 0x39; - public static final int ASTORE = 0x3a; - public static final int ISTORE_0 = 0x3b; - public static final int ISTORE_1 = 0x3c; - public static final int ISTORE_2 = 0x3d; - public static final int ISTORE_3 = 0x3e; - public static final int LSTORE_0 = 0x3f; - public static final int LSTORE_1 = 0x40; - public static final int LSTORE_2 = 0x41; - public static final int LSTORE_3 = 0x42; - public static final int FSTORE_0 = 0x43; - public static final int FSTORE_1 = 0x44; - public static final int FSTORE_2 = 0x45; - public static final int FSTORE_3 = 0x46; - public static final int DSTORE_0 = 0x47; - public static final int DSTORE_1 = 0x48; - public static final int DSTORE_2 = 0x49; - public static final int DSTORE_3 = 0x4a; - public static final int ASTORE_0 = 0x4b; - public static final int ASTORE_1 = 0x4c; - public static final int ASTORE_2 = 0x4d; - public static final int ASTORE_3 = 0x4e; - public static final int IASTORE = 0x4f; - public static final int LASTORE = 0x50; - public static final int FASTORE = 0x51; - public static final int DASTORE = 0x52; - public static final int AASTORE = 0x53; - public static final int BASTORE = 0x54; - public static final int CASTORE = 0x55; - public static final int SASTORE = 0x56; - public static final int POP = 0x57; - public static final int POP2 = 0x58; - public static final int DUP = 0x59; - public static final int DUP_X1 = 0x5a; - public static final int DUP_X2 = 0x5b; - public static final int DUP2 = 0x5c; - public static final int DUP2_X1 = 0x5d; - public static final int DUP2_X2 = 0x5e; - public static final int SWAP = 0x5f; - public static final int IADD = 0x60; - public static final int LADD = 0x61; - public static final int FADD = 0x62; - public static final int DADD = 0x63; - public static final int ISUB = 0x64; - public static final int LSUB = 0x65; - public static final int FSUB = 0x66; - public static final int DSUB = 0x67; - public static final int IMUL = 0x68; - public static final int LMUL = 0x69; - public static final int FMUL = 0x6a; - public static final int DMUL = 0x6b; - public static final int IDIV = 0x6c; - public static final int LDIV = 0x6d; - public static final int FDIV = 0x6e; - public static final int DDIV = 0x6f; - public static final int IREM = 0x70; - public static final int LREM = 0x71; - public static final int FREM = 0x72; - public static final int DREM = 0x73; - public static final int INEG = 0x74; - public static final int LNEG = 0x75; - public static final int FNEG = 0x76; - public static final int DNEG = 0x77; - public static final int ISHL = 0x78; - public static final int LSHL = 0x79; - public static final int ISHR = 0x7a; - public static final int LSHR = 0x7b; - public static final int IUSHR = 0x7c; - public static final int LUSHR = 0x7d; - public static final int IAND = 0x7e; - public static final int LAND = 0x7f; - public static final int IOR = 0x80; - public static final int LOR = 0x81; - public static final int IXOR = 0x82; - public static final int LXOR = 0x83; - public static final int IINC = 0x84; - public static final int I2L = 0x85; - public static final int I2F = 0x86; - public static final int I2D = 0x87; - public static final int L2I = 0x88; - public static final int L2F = 0x89; - public static final int L2D = 0x8a; - public static final int F2I = 0x8b; - public static final int F2L = 0x8c; - public static final int F2D = 0x8d; - public static final int D2I = 0x8e; - public static final int D2L = 0x8f; - public static final int D2F = 0x90; - public static final int I2B = 0x91; - public static final int I2C = 0x92; - public static final int I2S = 0x93; - public static final int LCMP = 0x94; - public static final int FCMPL = 0x95; - public static final int FCMPG = 0x96; - public static final int DCMPL = 0x97; - public static final int DCMPG = 0x98; - public static final int IFEQ = 0x99; - public static final int IFNE = 0x9a; - public static final int IFLT = 0x9b; - public static final int IFGE = 0x9c; - public static final int IFGT = 0x9d; - public static final int IFLE = 0x9e; - public static final int IF_ICMPEQ = 0x9f; - public static final int IF_ICMPNE = 0xa0; - public static final int IF_ICMPLT = 0xa1; - public static final int IF_ICMPGE = 0xa2; - public static final int IF_ICMPGT = 0xa3; - public static final int IF_ICMPLE = 0xa4; - public static final int IF_ACMPEQ = 0xa5; - public static final int IF_ACMPNE = 0xa6; - public static final int GOTO = 0xa7; - public static final int JSR = 0xa8; - public static final int RET = 0xa9; - public static final int TABLESWITCH = 0xaa; - public static final int LOOKUPSWITCH = 0xab; - public static final int IRETURN = 0xac; - public static final int LRETURN = 0xad; - public static final int FRETURN = 0xae; - public static final int DRETURN = 0xaf; - public static final int ARETURN = 0xb0; - public static final int RETURN = 0xb1; - public static final int GETSTATIC = 0xb2; - public static final int PUTSTATIC = 0xb3; - public static final int GETFIELD = 0xb4; - public static final int PUTFIELD = 0xb5; - public static final int INVOKEVIRTUAL = 0xb6; - public static final int INVOKESPECIAL = 0xb7; - public static final int INVOKESTATIC = 0xb8; - public static final int INVOKEINTERFACE = 0xb9; - public static final int XXXUNUSEDXXX = 0xba; - public static final int NEW = 0xbb; - public static final int NEWARRAY = 0xbc; - public static final int ANEWARRAY = 0xbd; - public static final int ARRAYLENGTH = 0xbe; - public static final int ATHROW = 0xbf; - public static final int CHECKCAST = 0xc0; - public static final int INSTANCEOF = 0xc1; - public static final int MONITORENTER = 0xc2; - public static final int MONITOREXIT = 0xc3; - public static final int WIDE = 0xc4; - public static final int MULTIANEWARRAY = 0xc5; - public static final int IFNULL = 0xc6; - public static final int IFNONNULL = 0xc7; - public static final int GOTO_W = 0xc8; - public static final int JSR_W = 0xc9; - public static final int BREAKPOINT = 0xca; - public static final int IMPDEP1 = 0xfe; - public static final int IMPDEP2 = 0xff; - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/impl/OutlineElement.java b/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/impl/OutlineElement.java deleted file mode 100644 index 38c0c6ba..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/impl/OutlineElement.java +++ /dev/null @@ -1,281 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.asm.render.impl; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IJavaModel; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IOpenable; -import org.eclipse.jdt.core.IParent; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.internal.core.JavaProject; - -import com.drgarbage.asm.ClassVisitor; -import com.drgarbage.asm.render.intf.IOutlineElement; -import com.drgarbage.bytecode.ByteCodeConstants; - - -/** - * The basis class for an outline element. - * - * @author Sergej Alekseev - * @version $Revision: 203 $ - * $Id: OutlineElement.java 203 2013-06-07 09:27:41Z salekseev $ - */ -public class OutlineElement extends ClassVisitor implements IJavaElement, IParent, IOutlineElement { - - public OutlineElement(int arg0) { - super(arg0); - } - - /** - * The name of the element - */ - private String elementName; - - /** - * The type of the element from IJavaElement interface. - * CLASS_FILE -> TYPE -> METHOD ... - * Default is 0 (unspecified). - */ - private int type = 0; - - /** - * Children of the element. - */ - private List children = new ArrayList(); - - /** - * Document line. - */ - private int documentLine = -1; - - /** - * Sets the elemet name. - * @param elementName - */ - public void setElementName(String elementName) { - this.elementName = elementName; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IJavaElement#getElementName() - */ - public String getElementName() { - return elementName; - } - - /** - * Add an element. - * @param child - */ - public void addChild(IJavaElement child){ - children.add(child); - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IParent#getChildren() - */ - public IJavaElement[] getChildren() throws JavaModelException { - IJavaElement[] c = new IJavaElement[children.size()]; - for (int i = 0; i < children.size(); i++){ - c[i]=children.get(i); - } - - return c; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IParent#hasChildren() - */ - public boolean hasChildren() throws JavaModelException { - return children.size()!= 0; - } - - /** - * Sets the element type. - * @param type - */ - public void setElementType(int type) { - this.type = type; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IJavaElement#getElementType() - */ - public int getElementType() { - return type; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IJavaElement#exists() - */ - public boolean exists() { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IJavaElement#getAncestor(int) - */ - public IJavaElement getAncestor(int ancestorType) { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IJavaElement#getAttachedJavadoc(org.eclipse.core.runtime.IProgressMonitor) - */ - public String getAttachedJavadoc(IProgressMonitor monitor) throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IJavaElement#getCorrespondingResource() - */ - public IResource getCorrespondingResource() throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IJavaElement#getHandleIdentifier() - */ - public String getHandleIdentifier() { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IJavaElement#getJavaModel() - */ - public IJavaModel getJavaModel() { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IJavaElement#getJavaProject() - */ - public IJavaProject getJavaProject() { - /* workaround to avoid an exception */ - return new MJavaProject(); - } - - /* workaround to avoid an exception during rendering of the outline */ - private class MJavaProject extends JavaProject { - /* - * @see IJavaProject - */ - public boolean isOnClasspath(IJavaElement element) { - return false; - } - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IJavaElement#getOpenable() - */ - public IOpenable getOpenable() { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IJavaElement#getParent() - */ - public IJavaElement getParent() { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IJavaElement#getPath() - */ - public IPath getPath() { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IJavaElement#getPrimaryElement() - */ - public IJavaElement getPrimaryElement() { - return this; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IJavaElement#getResource() - */ - public IResource getResource() { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IJavaElement#getSchedulingRule() - */ - public ISchedulingRule getSchedulingRule() { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IJavaElement#getUnderlyingResource() - */ - public IResource getUnderlyingResource() throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IJavaElement#isReadOnly() - */ - public boolean isReadOnly() { - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IJavaElement#isStructureKnown() - */ - public boolean isStructureKnown() throws JavaModelException { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) - */ - public Object getAdapter(Class adapter) { - return null; - } - - /* (non-Javadoc) - * @see com.drgarbage.classfile.render.intf.IOutlineElement#getBytecodeDocumentLine() - */ - public int getBytecodeDocumentLine() { - return documentLine; - } - - /** - * @param documentLine the documentLine to set - */ - public void setBytecodeDocumentLine(int documentLine) { - this.documentLine = documentLine; - } - - /* (non-Javadoc) - * @see com.drgarbage.classfile.render.intf.IOutlineElement#getSourceCodeDocumentLine() - */ - public int getSourceCodeDocumentLine() { - return ByteCodeConstants.INVALID_OFFSET; - } -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/impl/OutlineElementField.java b/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/impl/OutlineElementField.java deleted file mode 100644 index e2d85611..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/impl/OutlineElementField.java +++ /dev/null @@ -1,291 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.asm.render.impl; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.IClassFile; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.IField; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.ISourceRange; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.ITypeRoot; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.Signature; - -import com.drgarbage.asm.render.intf.IClassFileDocument; -import com.drgarbage.asm.render.intf.IFieldSection; -import com.drgarbage.asm.render.intf.IOutlineElementField; - -/** - * Outline structure for fields. - * - * @author Sergej Alekseev - * @version $Revision: 203 $ - * $Id: OutlineElementField.java 203 2013-06-07 09:27:41Z salekseev $ - */ -public class OutlineElementField extends OutlineElement implements IField, IOutlineElementField { - /** - * The declaring type object is a reference - * to the class or interface object. - */ - private IType declaringType; - - /** - * Method flags. - */ - private int flags; - - /** - * Type signature. - */ - private String typeSignature; - - private int fieldIndex; - private IClassFileDocument classFileDocument; - - /** - * Constructs a method outline object. - * @param parent - */ - public OutlineElementField(IType parent, IClassFileDocument document, int fieldIndex) { - super(com.drgarbage.asm.Opcodes.ASM4); - this.classFileDocument = document; - this.fieldIndex = fieldIndex; - setElementType(IJavaElement.FIELD); - setDeclaringType(parent); - } - - /** - * Sets the declaring type. The declaring type object is - * a reference to the class or interface object. - * @param declaringType - */ - public void setDeclaringType(IType declaringType) { - this.declaringType = declaringType; - } - - /** - * Sets the method flags. - * @param flags - */ - public void setFlags(int flags) { - this.flags = flags; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMember#getFlags() - */ - public int getFlags() throws JavaModelException { - return flags; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMember#getDeclaringType() - */ - public IType getDeclaringType() { - return declaringType; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IField#getConstant() - */ - public Object getConstant() throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IField#getKey() - */ - public String getKey() { - return null; - } - - /** - * Sets the type signature. - * @param typeSignature - */ - public void setTypeSignature(String typeSignature) { - this.typeSignature = typeSignature; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IField#getTypeSignature() - */ - public String getTypeSignature() throws JavaModelException { - return typeSignature; - } - - /* (non-Javadoc) - * @see com.drgarbage.classfile.render.impl.OutlineElement#getElementName() - */ - @Override - public String getElementName() { - StringBuffer buf = new StringBuffer(super.getElementName()); - buf.append(" : "); - String sig = Signature.getSignatureSimpleName(typeSignature); - //TODO: convert to unqualified name, Define preference - buf.append(sig); - return buf.toString(); - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IField#isEnumConstant() - */ - public boolean isEnumConstant() throws JavaModelException { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IField#isResolved() - */ - public boolean isResolved() { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMember#getCategories() - */ - public String[] getCategories() throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMember#getClassFile() - */ - public IClassFile getClassFile() { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMember#getCompilationUnit() - */ - public ICompilationUnit getCompilationUnit() { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMember#getJavadocRange() - */ - public ISourceRange getJavadocRange() throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMember#getNameRange() - */ - public ISourceRange getNameRange() throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMember#getOccurrenceCount() - */ - public int getOccurrenceCount() { - return 0; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMember#getType(java.lang.String, int) - */ - public IType getType(String name, int occurrenceCount) { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMember#isBinary() - */ - public boolean isBinary() { - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.ISourceReference#getSource() - */ - public String getSource() throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.ISourceReference#getSourceRange() - */ - public ISourceRange getSourceRange() throws JavaModelException { - //FIXME outline selection not shown in source because of this - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.ISourceManipulation#copy(org.eclipse.jdt.core.IJavaElement, org.eclipse.jdt.core.IJavaElement, java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor) - */ - public void copy(IJavaElement container, IJavaElement sibling, String rename, boolean replace, IProgressMonitor monitor) throws JavaModelException { - /* ignore */ - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.ISourceManipulation#delete(boolean, org.eclipse.core.runtime.IProgressMonitor) - */ - public void delete(boolean force, IProgressMonitor monitor) throws JavaModelException { - /* ignore */ - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.ISourceManipulation#move(org.eclipse.jdt.core.IJavaElement, org.eclipse.jdt.core.IJavaElement, java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor) - */ - public void move(IJavaElement container, IJavaElement sibling, String rename, boolean replace, IProgressMonitor monitor) throws JavaModelException { - /* ignore */ - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.ISourceManipulation#rename(java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor) - */ - public void rename(String name, boolean replace, IProgressMonitor monitor) throws JavaModelException { - /* ignore */ - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMember#getTypeRoot() - */ - public ITypeRoot getTypeRoot() { - /* nothing todo*/ - return null; - } - - /* (non-Javadoc) - * @see com.drgarbage.asm.render.intf.IOutlineElementField#getFieldSection() - */ - public IFieldSection getFieldSection() { - return classFileDocument.getFieldSections().get(fieldIndex); - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IAnnotatable#getAnnotation(java.lang.String) - */ - public IAnnotation getAnnotation(String name) { - /* since eclipse 3.4 (ganymede) */ - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IAnnotatable#getAnnotations() - */ - public IAnnotation[] getAnnotations() throws JavaModelException { - /* since eclipse 3.4 (ganymede) */ - return null; - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/impl/OutlineElementMethod.java b/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/impl/OutlineElementMethod.java deleted file mode 100644 index 0c604e72..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/impl/OutlineElementMethod.java +++ /dev/null @@ -1,431 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.asm.render.impl; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.IClassFile; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.ILocalVariable; -import org.eclipse.jdt.core.IMemberValuePair; -import org.eclipse.jdt.core.IMethod; -import org.eclipse.jdt.core.ISourceRange; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.ITypeParameter; -import org.eclipse.jdt.core.ITypeRoot; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.Signature; - -import com.drgarbage.asm.render.intf.IClassFileDocument; -import com.drgarbage.asm.render.intf.IMethodSection; -import com.drgarbage.bytecode.ByteCodeConstants; - -/** - * Outline structure for methods. - * - * @author Sergej Alekseev - * @version $Revision: 600 $ - * $Id: OutlineElementMethod.java 600 2014-07-02 09:52:35Z kvbx $ - */ -public class OutlineElementMethod extends OutlineElement implements IMethod { - - public boolean isLambdaMethod() { - return false; - } - - private IClassFileDocument classFileDocument; - - /** - * The declaring type object is a reference - * to the class or interface object. - */ - private IType declaringType; - - /** - * Method flags. - */ - private int flags; - - /** - * Array of the method parameters. - */ - private String[] methodDescriptor; - - - /** - * Method signature. - */ - private String signature; - - /** - * Flag constructor. - */ - private boolean constructor = false; - - /** - * Flag main method. - */ - private boolean mainMethod = false; - - private static final String[] NO_STRINGS = new String[0]; - private int methodIndex = ByteCodeConstants.INVALID_OFFSET; - /** - * Constructs a method outline object. - * @param parent - */ - public OutlineElementMethod(IType parent, IClassFileDocument document, int methodIndex) { - super(com.drgarbage.asm.Opcodes.ASM4); - this.classFileDocument = document; - this.methodIndex = methodIndex; - setElementType(IJavaElement.METHOD); - setDeclaringType(parent); - } - - - - /** - * Sets the declaring type. The declaring type object is - * a reference to the class or interface object. - * @param declaringType - */ - public void setDeclaringType(IType declaringType) { - this.declaringType = declaringType; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMember#getDeclaringType() - */ - public IType getDeclaringType() { - return declaringType; - } - - /** - * Sets the method flags. - * @param flags - */ - public void setFlags(int flags) { - this.flags = flags; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMember#getFlags() - */ - public int getFlags() throws JavaModelException { - return flags; - } - - /** - * Sets the method descriptor. - * @param signature the method signature to set - */ - public void setMethodDescriptor(String signature) { - this.signature = signature; - - /* create parameter array */ - String[] list= Signature.getParameterTypes(signature); - - if(list.length == 0){ - methodDescriptor = NO_STRINGS; - } - else{ - //TODO: unqualified names - methodDescriptor = list; - } - - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMethod#getParameterTypes() - */ - public String[] getParameterTypes() { - return methodDescriptor; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMethod#getExceptionTypes() - */ - public String[] getExceptionTypes() throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMethod#getKey() - */ - public String getKey() { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMethod#getNumberOfParameters() - */ - public int getNumberOfParameters() { - return -1; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMethod#getParameterNames() - */ - public String[] getParameterNames() throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMethod#getRawParameterNames() - */ - public String[] getRawParameterNames() throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMethod#getReturnType() - */ - public String getReturnType() throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMethod#getSignature() - */ - public String getSignature() throws JavaModelException { - return signature; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMethod#getTypeParameter(java.lang.String) - */ - public ITypeParameter getTypeParameter(String name) { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMethod#getTypeParameterSignatures() - */ - public String[] getTypeParameterSignatures() throws JavaModelException { - return methodDescriptor; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMethod#getTypeParameters() - */ - public ITypeParameter[] getTypeParameters() throws JavaModelException { - return null; - } - - /** - * Sets the flag constructor. - * @param b true or false - */ - public void setConstructor(boolean b) { - this.constructor = b; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMethod#isConstructor() - */ - public boolean isConstructor() throws JavaModelException { - return constructor; - } - - /** - * Sets the main method flag. - * @param b true or false - */ - public void setMainMethod(boolean b) { - this.mainMethod = b; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMethod#isMainMethod() - */ - public boolean isMainMethod() throws JavaModelException { - return mainMethod; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMethod#isResolved() - */ - public boolean isResolved() { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMethod#isSimilar(org.eclipse.jdt.core.IMethod) - */ - public boolean isSimilar(IMethod method) { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMember#getCategories() - */ - public String[] getCategories() throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMember#getClassFile() - */ - public IClassFile getClassFile() { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMember#getCompilationUnit() - */ - public ICompilationUnit getCompilationUnit() { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMember#getJavadocRange() - */ - public ISourceRange getJavadocRange() throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMember#getNameRange() - */ - public ISourceRange getNameRange() throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMember#getOccurrenceCount() - */ - public int getOccurrenceCount() { - return 0; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMember#getType(java.lang.String, int) - */ - public IType getType(String name, int occurrenceCount) { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMember#isBinary() - */ - public boolean isBinary() { - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.ISourceReference#getSource() - */ - public String getSource() throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.ISourceReference#getSourceRange() - */ - public ISourceRange getSourceRange() throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.ISourceManipulation#copy(org.eclipse.jdt.core.IJavaElement, org.eclipse.jdt.core.IJavaElement, java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor) - */ - public void copy(IJavaElement container, IJavaElement sibling, String rename, boolean replace, IProgressMonitor monitor) throws JavaModelException { - /* ignore */ - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.ISourceManipulation#delete(boolean, org.eclipse.core.runtime.IProgressMonitor) - */ - public void delete(boolean force, IProgressMonitor monitor) throws JavaModelException { - /* ignore */ - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.ISourceManipulation#move(org.eclipse.jdt.core.IJavaElement, org.eclipse.jdt.core.IJavaElement, java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor) - */ - public void move(IJavaElement container, IJavaElement sibling, String rename, boolean replace, IProgressMonitor monitor) throws JavaModelException { - /* ignore */ - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.ISourceManipulation#rename(java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor) - */ - public void rename(String name, boolean replace, IProgressMonitor monitor) throws JavaModelException { - /* ignore */ - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMember#getTypeRoot() - */ - public ITypeRoot getTypeRoot() { - /*nothing todo*/ - return null; - } - - /* (non-Javadoc) - * @see com.drgarbage.classfile.render.intf.IOutlineElement#getSourceCodeDocumentLine() - */ - public int getSourceCodeDocumentLine() { - IMethodSection m = classFileDocument.getMethodSections().get(methodIndex); - int byteCodeDocLine = m.getFirstLine(); - - if(byteCodeDocLine == ByteCodeConstants.INVALID_OFFSET){ - return ByteCodeConstants.INVALID_OFFSET; - } - - return m.getSourceCodeLine(byteCodeDocLine); - } - - /** - * Returns the reference to the method section. - * @return method section - */ - public IMethodSection getMethodSection(){ - return classFileDocument.getMethodSections().get(methodIndex); - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMethod#getDefaultValue() - */ - public IMemberValuePair getDefaultValue() throws JavaModelException { - /* since eclipse 3.4 (ganymede) */ - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IAnnotatable#getAnnotation(java.lang.String) - */ - public IAnnotation getAnnotation(String name) { - /* since eclipse 3.4 (ganymede) */ - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IAnnotatable#getAnnotations() - */ - public IAnnotation[] getAnnotations() throws JavaModelException { - /* since eclipse 3.4 (ganymede) */ - return null; - } - - - - public ILocalVariable[] getParameters() throws JavaModelException { - /* only for 3.7 compatibility */ - return null; - } -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/impl/OutlineElementType.java b/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/impl/OutlineElementType.java deleted file mode 100644 index e9724a99..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/impl/OutlineElementType.java +++ /dev/null @@ -1,669 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.asm.render.impl; - -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jdt.core.CompletionRequestor; -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.IClassFile; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.ICompletionRequestor; -import org.eclipse.jdt.core.IField; -import org.eclipse.jdt.core.IInitializer; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IMethod; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.ISourceRange; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.ITypeHierarchy; -import org.eclipse.jdt.core.ITypeParameter; -import org.eclipse.jdt.core.ITypeRoot; -import org.eclipse.jdt.core.IWorkingCopy; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.WorkingCopyOwner; - -import com.drgarbage.bytecode.BytecodeUtils; - - -/** - * Outline structure for class, interface or enum elements. - * - * @author Sergej Alekseev - * @version $Revision: 600 $ - * $Id: OutlineElementType.java 600 2014-07-02 09:52:35Z kvbx $ - */ -public class OutlineElementType extends OutlineElement implements IType { - - public boolean isLambda() { - return false; - } - - /* flags */ - private int flags = 0; - - /* empty constants */ - @SuppressWarnings("unused") - private static final IField[] NO_FIELDS = new IField[0]; - private static final IMethod[] NO_METHODS = new IMethod[0]; - private static final IType[] NO_TYPES = new IType[0]; - private static final IInitializer[] NO_INITIALIZERS = new IInitializer[0]; - private static final String[] NO_STRINGS = new String[0]; - public static final String EMPTY_JAVADOC = new String(); - - /** - * Fully qualified name. For exampe: org.test.Test - */ - private String fullyQualifiedName; - private PackageFragment packageFragment; - - /** - * - */ - public OutlineElementType() { - super(com.drgarbage.asm.Opcodes.ASM4); - setElementType(IJavaElement.TYPE); - } - - /** - * Super class name. - */ - private String superclassName; - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#isAnnotation() - */ - public boolean isAnnotation() throws JavaModelException { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#isClass() - */ - public boolean isClass() throws JavaModelException { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#isEnum() - */ - public boolean isEnum() throws JavaModelException { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#isInterface() - */ - public boolean isInterface() throws JavaModelException { - return false; - } - - /** - * Sets flags. - * @param flags the flags to set - */ - public void setFlags(int flags) { - this.flags = flags; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMember#getFlags() - */ - public int getFlags() throws JavaModelException { - return flags; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#codeComplete(char[], int, int, char[][], char[][], int[], boolean, org.eclipse.jdt.core.ICompletionRequestor) - */ - public void codeComplete(char[] snippet, int insertion, int position, char[][] localVariableTypeNames, char[][] localVariableNames, int[] localVariableModifiers, boolean isStatic, ICompletionRequestor requestor) throws JavaModelException { - /* ignore */ - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#codeComplete(char[], int, int, char[][], char[][], int[], boolean, org.eclipse.jdt.core.CompletionRequestor) - */ - public void codeComplete(char[] snippet, int insertion, int position, char[][] localVariableTypeNames, char[][] localVariableNames, int[] localVariableModifiers, boolean isStatic, CompletionRequestor requestor) throws JavaModelException { - /* ignore */ - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#codeComplete(char[], int, int, char[][], char[][], int[], boolean, org.eclipse.jdt.core.ICompletionRequestor, org.eclipse.jdt.core.WorkingCopyOwner) - */ - public void codeComplete(char[] snippet, int insertion, int position, char[][] localVariableTypeNames, char[][] localVariableNames, int[] localVariableModifiers, boolean isStatic, ICompletionRequestor requestor, WorkingCopyOwner owner) throws JavaModelException { - /* ignore */ - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#codeComplete(char[], int, int, char[][], char[][], int[], boolean, org.eclipse.jdt.core.CompletionRequestor, org.eclipse.jdt.core.WorkingCopyOwner) - */ - public void codeComplete(char[] snippet, int insertion, int position, char[][] localVariableTypeNames, char[][] localVariableNames, int[] localVariableModifiers, boolean isStatic, CompletionRequestor requestor, WorkingCopyOwner owner) throws JavaModelException { - /* ignore */ - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#createField(java.lang.String, org.eclipse.jdt.core.IJavaElement, boolean, org.eclipse.core.runtime.IProgressMonitor) - */ - public IField createField(String contents, IJavaElement sibling, boolean force, IProgressMonitor monitor) throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#createInitializer(java.lang.String, org.eclipse.jdt.core.IJavaElement, org.eclipse.core.runtime.IProgressMonitor) - */ - public IInitializer createInitializer(String contents, IJavaElement sibling, IProgressMonitor monitor) throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#createMethod(java.lang.String, org.eclipse.jdt.core.IJavaElement, boolean, org.eclipse.core.runtime.IProgressMonitor) - */ - public IMethod createMethod(String contents, IJavaElement sibling, boolean force, IProgressMonitor monitor) throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#createType(java.lang.String, org.eclipse.jdt.core.IJavaElement, boolean, org.eclipse.core.runtime.IProgressMonitor) - */ - public IType createType(String contents, IJavaElement sibling, boolean force, IProgressMonitor monitor) throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#findMethods(org.eclipse.jdt.core.IMethod) - */ - public IMethod[] findMethods(IMethod method) { - return NO_METHODS; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#getChildrenForCategory(java.lang.String) - */ - public IJavaElement[] getChildrenForCategory(String category) throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#getField(java.lang.String) - */ - public IField getField(String name) { - for (IField f : fields) { - if (name.equals(f.getElementName())) { - return f; - } - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#getFields() - */ - public IField[] getFields() throws JavaModelException { - return fields.toArray(new IField[fields.size()]); - } - - /** - * @param fullyQualifiedName the fullyQualifiedName to set - */ - public void setFullyQualifiedName(String fullyQualifiedName) { - this.fullyQualifiedName = fullyQualifiedName; - - this.packageFragment = new PackageFragment(com.drgarbage.asm.Opcodes.ASM4); - this.packageFragment.setElementName(BytecodeUtils.getPackage(fullyQualifiedName)); - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#getFullyQualifiedName() - */ - public String getFullyQualifiedName() { - return fullyQualifiedName; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#getFullyQualifiedName(char) - */ - public String getFullyQualifiedName(char enclosingTypeSeparator) { - return fullyQualifiedName.replace('/', enclosingTypeSeparator); - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#getFullyQualifiedParameterizedName() - */ - public String getFullyQualifiedParameterizedName() throws JavaModelException { - return fullyQualifiedName; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#getInitializer(int) - */ - public IInitializer getInitializer(int occurrenceCount) { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#getInitializers() - */ - public IInitializer[] getInitializers() throws JavaModelException { - return NO_INITIALIZERS; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#getKey() - */ - public String getKey() { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#getMethod(java.lang.String, java.lang.String[]) - */ - public IMethod getMethod(String name, String[] parameterTypeSignatures) { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#getMethods() - */ - public IMethod[] getMethods() throws JavaModelException { - return methods.toArray(new IMethod[methods.size()]); - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#getPackageFragment() - */ - public IPackageFragment getPackageFragment() { - return packageFragment; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#getSuperInterfaceNames() - */ - public String[] getSuperInterfaceNames() throws JavaModelException { - return NO_STRINGS; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#getSuperInterfaceTypeSignatures() - */ - public String[] getSuperInterfaceTypeSignatures() throws JavaModelException { - return NO_STRINGS; - } - - /** - * Sets super class name. - * @param superclassName - */ - public void setSuperclassName(String superclassName) { - this.superclassName = superclassName; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#getSuperclassName() - */ - public String getSuperclassName() throws JavaModelException { - return superclassName; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#getSuperclassTypeSignature() - */ - public String getSuperclassTypeSignature() throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#getType(java.lang.String) - */ - public IType getType(String name) { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#getTypeParameter(java.lang.String) - */ - public ITypeParameter getTypeParameter(String name) { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#getTypeParameterSignatures() - */ - public String[] getTypeParameterSignatures() throws JavaModelException { - return NO_STRINGS; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#getTypeParameters() - */ - public ITypeParameter[] getTypeParameters() throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#getTypeQualifiedName() - */ - public String getTypeQualifiedName() { - return fullyQualifiedName; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#getTypeQualifiedName(char) - */ - public String getTypeQualifiedName(char enclosingTypeSeparator) { - return fullyQualifiedName.replace('/', enclosingTypeSeparator); - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#getTypes() - */ - public IType[] getTypes() throws JavaModelException { - return NO_TYPES; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#isAnonymous() - */ - public boolean isAnonymous() throws JavaModelException { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#isLocal() - */ - public boolean isLocal() throws JavaModelException { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#isMember() - */ - public boolean isMember() throws JavaModelException { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#isResolved() - */ - public boolean isResolved() { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#loadTypeHierachy(java.io.InputStream, org.eclipse.core.runtime.IProgressMonitor) - */ - public ITypeHierarchy loadTypeHierachy(InputStream input, IProgressMonitor monitor) throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#newSupertypeHierarchy(org.eclipse.core.runtime.IProgressMonitor) - */ - public ITypeHierarchy newSupertypeHierarchy(IProgressMonitor monitor) throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#newSupertypeHierarchy(org.eclipse.jdt.core.ICompilationUnit[], org.eclipse.core.runtime.IProgressMonitor) - */ - public ITypeHierarchy newSupertypeHierarchy(ICompilationUnit[] workingCopies, IProgressMonitor monitor) throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#newSupertypeHierarchy(org.eclipse.jdt.core.IWorkingCopy[], org.eclipse.core.runtime.IProgressMonitor) - */ - public ITypeHierarchy newSupertypeHierarchy(IWorkingCopy[] workingCopies, IProgressMonitor monitor) throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#newSupertypeHierarchy(org.eclipse.jdt.core.WorkingCopyOwner, org.eclipse.core.runtime.IProgressMonitor) - */ - public ITypeHierarchy newSupertypeHierarchy(WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#newTypeHierarchy(org.eclipse.core.runtime.IProgressMonitor) - */ - public ITypeHierarchy newTypeHierarchy(IProgressMonitor monitor) throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#newTypeHierarchy(org.eclipse.jdt.core.IJavaProject, org.eclipse.core.runtime.IProgressMonitor) - */ - public ITypeHierarchy newTypeHierarchy(IJavaProject project, IProgressMonitor monitor) throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#newTypeHierarchy(org.eclipse.jdt.core.ICompilationUnit[], org.eclipse.core.runtime.IProgressMonitor) - */ - public ITypeHierarchy newTypeHierarchy(ICompilationUnit[] workingCopies, IProgressMonitor monitor) throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#newTypeHierarchy(org.eclipse.jdt.core.IWorkingCopy[], org.eclipse.core.runtime.IProgressMonitor) - */ - public ITypeHierarchy newTypeHierarchy(IWorkingCopy[] workingCopies, IProgressMonitor monitor) throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#newTypeHierarchy(org.eclipse.jdt.core.WorkingCopyOwner, org.eclipse.core.runtime.IProgressMonitor) - */ - public ITypeHierarchy newTypeHierarchy(WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#newTypeHierarchy(org.eclipse.jdt.core.IJavaProject, org.eclipse.jdt.core.WorkingCopyOwner, org.eclipse.core.runtime.IProgressMonitor) - */ - public ITypeHierarchy newTypeHierarchy(IJavaProject project, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#resolveType(java.lang.String) - */ - public String[][] resolveType(String typeName) throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#resolveType(java.lang.String, org.eclipse.jdt.core.WorkingCopyOwner) - */ - public String[][] resolveType(String typeName, WorkingCopyOwner owner) throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMember#getCategories() - */ - public String[] getCategories() throws JavaModelException { - return NO_STRINGS; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMember#getClassFile() - */ - public IClassFile getClassFile() { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMember#getCompilationUnit() - */ - public ICompilationUnit getCompilationUnit() { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMember#getJavadocRange() - */ - public ISourceRange getJavadocRange() throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMember#getNameRange() - */ - public ISourceRange getNameRange() throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMember#getOccurrenceCount() - */ - public int getOccurrenceCount() { - return 0; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMember#getType(java.lang.String, int) - */ - public IType getType(String name, int occurrenceCount) { - return this; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMember#isBinary() - */ - public boolean isBinary() { - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.ISourceReference#getSource() - */ - public String getSource() throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.ISourceReference#getSourceRange() - */ - public ISourceRange getSourceRange() throws JavaModelException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.ISourceManipulation#copy(org.eclipse.jdt.core.IJavaElement, org.eclipse.jdt.core.IJavaElement, java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor) - */ - public void copy(IJavaElement container, IJavaElement sibling, String rename, boolean replace, IProgressMonitor monitor) throws JavaModelException { - /* ignore */ - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.ISourceManipulation#delete(boolean, org.eclipse.core.runtime.IProgressMonitor) - */ - public void delete(boolean force, IProgressMonitor monitor) throws JavaModelException { - /* ignore */ - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.ISourceManipulation#move(org.eclipse.jdt.core.IJavaElement, org.eclipse.jdt.core.IJavaElement, java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor) - */ - public void move(IJavaElement container, IJavaElement sibling, String rename, boolean replace, IProgressMonitor monitor) throws JavaModelException { - /* ignore */ - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.ISourceManipulation#rename(java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor) - */ - public void rename(String name, boolean replace, IProgressMonitor monitor) throws JavaModelException { - /* ignore */ - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMember#getDeclaringType() - */ - public IType getDeclaringType() { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IMember#getTypeRoot() - */ - public ITypeRoot getTypeRoot() { - /*nothing todo*/ - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IAnnotatable#getAnnotation(java.lang.String) - */ - public IAnnotation getAnnotation(String name) { - /* since eclipse 3.4 (ganymede) */ - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IAnnotatable#getAnnotations() - */ - public IAnnotation[] getAnnotations() throws JavaModelException { - /* since eclipse 3.4 (ganymede) */ - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#codeComplete(char[], int, int, char[][], char[][], int[], boolean, org.eclipse.jdt.core.CompletionRequestor, org.eclipse.core.runtime.IProgressMonitor) - */ - public void codeComplete(char[] snippet, int insertion, int position, - char[][] localVariableTypeNames, char[][] localVariableNames, - int[] localVariableModifiers, boolean isStatic, - CompletionRequestor requestor, IProgressMonitor monitor) - throws JavaModelException { - /* since eclipse 3.5 (galileo) */ - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.core.IType#codeComplete(char[], int, int, char[][], char[][], int[], boolean, org.eclipse.jdt.core.CompletionRequestor, org.eclipse.jdt.core.WorkingCopyOwner, org.eclipse.core.runtime.IProgressMonitor) - */ - public void codeComplete(char[] snippet, int insertion, int position, - char[][] localVariableTypeNames, char[][] localVariableNames, - int[] localVariableModifiers, boolean isStatic, - CompletionRequestor requestor, WorkingCopyOwner owner, - IProgressMonitor monitor) throws JavaModelException { - /* since eclipse 3.5 (galileo) */ - } - - private List fields = new ArrayList(4); - private List methods = new ArrayList(4); - - @Override - public void addChild(IJavaElement child) { - - if (child instanceof IField) { - fields.add((IField)child); - } - else if (child instanceof IMethod) { - methods.add((IMethod)child); - } - - super.addChild(child); - } - - - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/impl/PackageFragment.java b/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/impl/PackageFragment.java deleted file mode 100644 index 8b974e32..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/impl/PackageFragment.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.asm.render.impl; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jdt.core.IBuffer; -import org.eclipse.jdt.core.IClassFile; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.WorkingCopyOwner; - -public class PackageFragment extends OutlineElement implements IPackageFragment { - - public PackageFragment(int arg0) { - super(arg0); - } - - public boolean containsJavaResources() throws JavaModelException { - return false; - } - - public ICompilationUnit createCompilationUnit(String name, String contents, - boolean force, IProgressMonitor monitor) throws JavaModelException { - return null; - } - - public IClassFile getClassFile(String name) { - return null; - } - - public IClassFile[] getClassFiles() throws JavaModelException { - return null; - } - - public ICompilationUnit getCompilationUnit(String name) { - return null; - } - - public ICompilationUnit[] getCompilationUnits() throws JavaModelException { - return null; - } - - public ICompilationUnit[] getCompilationUnits(WorkingCopyOwner owner) - throws JavaModelException { - return null; - } - - public int getKind() throws JavaModelException { - return IPackageFragmentRoot.K_BINARY; - } - - public Object[] getNonJavaResources() throws JavaModelException { - return null; - } - - public boolean hasSubpackages() throws JavaModelException { - return false; - } - - public boolean isDefaultPackage() { - return false; - } - - public void close() throws JavaModelException { - } - - public String findRecommendedLineSeparator() throws JavaModelException { - return null; - } - - public IBuffer getBuffer() throws JavaModelException { - return null; - } - - public boolean hasUnsavedChanges() throws JavaModelException { - return false; - } - - public boolean isConsistent() throws JavaModelException { - return false; - } - - public boolean isOpen() { - return false; - } - - public void makeConsistent(IProgressMonitor progress) - throws JavaModelException { - } - - public void open(IProgressMonitor progress) throws JavaModelException { - } - - public void save(IProgressMonitor progress, boolean force) - throws JavaModelException { - } - - public void copy(IJavaElement container, IJavaElement sibling, - String rename, boolean replace, IProgressMonitor monitor) - throws JavaModelException { - } - - public void delete(boolean force, IProgressMonitor monitor) - throws JavaModelException { - } - - public void move(IJavaElement container, IJavaElement sibling, - String rename, boolean replace, IProgressMonitor monitor) - throws JavaModelException { - } - - public void rename(String name, boolean replace, IProgressMonitor monitor) - throws JavaModelException { - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/intf/IClassFileDocument.java b/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/intf/IClassFileDocument.java deleted file mode 100644 index a61a2083..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/intf/IClassFileDocument.java +++ /dev/null @@ -1,185 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.asm.render.intf; - -import java.util.List; - -import com.drgarbage.bytecode.ByteCodeConstants; -import com.drgarbage.bytecode.constant_pool.AbstractConstantPoolEntry; - -/** - * A visualized class file. - * - * @author Peter Palaga - * @version $Revision: 516 $ - * $Id: IClassFileDocument.java 516 2014-02-05 09:17:35Z salekseev $ - */ -public interface IClassFileDocument extends Appendable { - - /** - * Adds a field Section to the document. - * @param f the field section - */ - public void addFieldSection(IFieldSection f); - - /** - * Appends '\n' to this {@link IClassFileDocument} and increments the internal - * line counter. - */ - public void appendNewline(); - - /** - * Decrements the current indentation by 1. - */ - public void decrementIndent(); - - /** - * Returns a {@link IFieldSection} of the given line number - * or null if no such exists. - * - * @param line 0-based line number - * @return a {@link IFieldSection} of the given line number - * or null if no such exists. - */ - public IFieldSection findFieldSection(int line); - - /** - * Search for a a {@link IFieldSection} by field name. - * @param fieldName field name - * @return a {@link IFieldSection} or null if no such exists. - */ - public IFieldSection findFieldSection(String fieldName); - - /** - * Returns the first instruction of the given source code line - * or null if none found. - * - * @param sourceCodeLine 0-based line number - * @return the instruction line object - * @see IInstructionLine - */ - public IInstructionLine findInstructionLine(int sourceCodeLine); - - /** - * Returns a {@link IMethodSection} containing the given line number - * or null if no such exists. - * - * @param line 0-based line number - * @return a {@link IMethodSection} containing the given line number - * or null if no such exists. - */ - public IMethodSection findMethodSection(int line); - - /** - * Search for a a {@link IMethodSection} by method name and method signature. - * @param methodName method name - * @param methodSignature method signature - * @return a {@link IMethodSection} or null if no such exists. - */ - public IMethodSection findMethodSection(String methodName, String methodSignature); - - /** - * Returns a fully qualified class name. - * @return class name - */ - public String getClassName(); - - /** - * Returns byte code document line number where the class signature begins. - * @return byte code document line or {@link ByteCodeConstants#INVALID_OFFSET} - */ - public int getClassSignatureDocumentLine(); - - /** - * Returns a simple unqualified class name. - * @return class name - */ - public String getClassSimpleName(); - - /** - * Returns a {@link List} of {@link IFeldSection}s representing - * the fields of this {@link IClassFileDocument}. - * - * @return {@link List} of {@link IFieldSection}s. - */ - public List getFieldSections(); - - /** - * Returns a string used for indentation in this document. - * @return an indentation string. - */ - public String getIndentationString(); - - /** - * Returns the number of lines in this {@link IClassFileDocument}. - * @return th eline count. - */ - public int getLineCount(); - - /** - * Returns a {@link List} of {@link IMethodSection}s representing - * the methods of this {@link IClassFileDocument}, excluding abstract - * methods. - * - * @return {@link List} of {@link IMethodSection}s representing - * the methods of this {@link IClassFileDocument}, excluding abstract - * methods; or null if this {@link IClassFileDocument} has - * no non-abstract methods. - */ - public List getMethodSections(); - /** - * Increments the current indentation by 1. - */ - public void incrementIndent(); - - /** - * Tells if the given line number includes a field declaration. - * The implementations should return quickly, e.g. should use some - * sort of index or similar. - * - * @param line 0-based line number - * @return true if the given line number includes a field declaration, false otherwise. - */ - public boolean isLineInField(int line); - - /** - * Tells if the given line number is enclosed in some method. - * The implementations should return quickly, e.g. should use some - * sort of index or similar. - * - * @param line 0-based line number - * @return true if the given line number is enclosed in some method, false otherwise. - */ - public boolean isLineInMethod(int line); - - /** - * Sets a string used for indentation in this document, - * e.g. "\t", or " ". This method should be used - * before nay rendering is done; the - * results will not look consistent otherwise. - * - * @param indentationString - */ - public void setIndentationString(String indentationString); - - /** - * Returns the constant pool object. - * @return constant pool reference - */ - public AbstractConstantPoolEntry[] getConstantPool(); - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/intf/IDocumentUpdateListener.java b/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/intf/IDocumentUpdateListener.java deleted file mode 100644 index 9a5a1c21..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/intf/IDocumentUpdateListener.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.asm.render.intf; - -/** - * A listener that will be fired on each update of the {@link IClassFileDocument} - * by which it is registered. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision: 187 $ - * $Id: IDocumentUpdateListener.java 187 2013-06-03 05:47:37Z salekseev $ - */ -public interface IDocumentUpdateListener { - - /** - * fired on each update of the {@link IClassFileDocument} - * by which this {@link IDocumentUpdateListener} is registered. - */ - public void documentUpdated(IClassFileDocument classFileDocument); - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/intf/IFieldSection.java b/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/intf/IFieldSection.java deleted file mode 100644 index 0626b106..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/intf/IFieldSection.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.asm.render.intf; - -import com.drgarbage.bytecode.ByteCodeConstants; - -/** - * Representation of a filed. - * - * @author Sergej Alekseev - * @version $Revision: 187 $ - * $Id: IFieldSection.java 187 2013-06-03 05:47:37Z salekseev $ - */ -public interface IFieldSection { - - /** - * Returns the simple name of this field. - * @return the simple name of this field. - */ - public String getName(); - - /** - * Returns the type signature of this field. For enum constants, - * this returns the signature of the declaring enum class. - *

      - * @return the type signature of this field - */ - public String getDescriptor(); - - /** - * Returns byte code document line number. - * @return byte code document line or {@link ByteCodeConstants#INVALID_OFFSET} - */ - public int getBytecodeDocumentLine(); - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/intf/IInstructionLine.java b/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/intf/IInstructionLine.java deleted file mode 100644 index 11769f32..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/intf/IInstructionLine.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.asm.render.intf; - -import com.drgarbage.bytecode.instructions.AbstractInstruction; - -/** - * Represenation of a line in a method. - * - * @author Peter Palaga - * @version $Revision:25 $ - * $Id:ByteCodeDocumentProvider.java 25 2007-04-01 17:56:22Z aleks $ - */ -public interface IInstructionLine { - - /** - * A constant used to initialize the implementor's field line. - */ - public static final int INVALID_LINE = -1; - - /** - * Returns the instruction occuring at this line. - * - * @return the instruction - */ - public AbstractInstruction getInstruction(); - - - /** - * Returns 0-based line number. - * @return line number - */ - public int getLine(); -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/intf/ILocalVariableTable.java b/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/intf/ILocalVariableTable.java deleted file mode 100644 index ee910b32..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/intf/ILocalVariableTable.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.asm.render.intf; - -import java.util.Comparator; -import java.util.List; - -import com.drgarbage.bytecode.LocalVariableTableEntry; -import com.drgarbage.bytecode.LocalVariableTypeTableEntry; -import com.drgarbage.bytecode.ByteCodeConstants.Align; - -public interface ILocalVariableTable { - public static class LocalVariableTableEntryEndOffsetComparator implements Comparator { - - /* (non-Javadoc) - * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) - */ - public int compare(LocalVariableTableEntry e1, LocalVariableTableEntry e2) { - int i1 = e1.getStartPc() + e1.getLength(); - int i2 = e2.getStartPc() + e2.getLength(); - return (i1 < i2 ? -1 : (i1 == i2 ? 0 : 1)); - } - - } - public static final LocalVariableTableEntryEndOffsetComparator END_OFFSET_COMPARATOR = new LocalVariableTableEntryEndOffsetComparator(); - - String findArgName(int i, int offset, boolean isConstructor, boolean isStatic); - int getLength(); - List getEntries(); - public boolean isAvailable(); - public void addLocalVariableTableEntry(LocalVariableTableEntry entry); - public void addLocalVariableTypeTableEntry(LocalVariableTypeTableEntry entry); - - public String[] getHeader(); - public String[] getRow(int index); - public Align getAlignment(int column); - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/intf/IMethodSection.java b/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/intf/IMethodSection.java deleted file mode 100644 index df492cfd..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/intf/IMethodSection.java +++ /dev/null @@ -1,190 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.asm.render.intf; - -import java.util.List; - -import com.drgarbage.bytecode.ByteCodeConstants; -import com.drgarbage.bytecode.ExceptionTableEntry; - -/** - * Representation of a method. - * - * @author Peter Palaga - * @version $Revision: 516 $ - * $Id: IMethodSection.java 516 2014-02-05 09:17:35Z salekseev $ - */ -public interface IMethodSection { - - /** - * Returns the first instruction of the given source code line - * or null if none found. - * - * @param sourceCodeLine 0-based line number - * @return the instruction line object - * @see IInstructionLine - */ - public IInstructionLine findInstructionLine(int sourceCodeLine); - - /** - * Returns 0-based bytecode document line number for the given offset of an instruction. - * @param offset offset of an instruction - * @return 0-based bytecode document line. - */ - public int findOffsetLine(int offset); - - /** - * Returns 0-based bytecode document line number for the given source code. - * @param sourceCodeLine the source code line number - * @return the 0-based bytecode document line. - */ - public int getBytecodeLine(int sourceCodeLine); - - /** - * Returns the method descriptor. - * @return the method descriptor - */ - public String getDescriptor(); - - /** - * Returns 0-based line number. - * @return line number - */ - public int getFirstLine(); - - /** - * Returns a {@link List} of {@link IInstructionLine}s. - * - * @return {@link List} of {@link IInstructionLine}s - * or null if the method does not have any instructions. - */ - public List getInstructionLines(); - - /** - * Returns 0-based line number. - * @return line number - */ - public int getLastLine(); - - /** - * Returns the method name. - * @return method name - */ - public String getName(); - - /** - * Returns 0-based source code line number for the given byte - * code document line or {@link ByteCodeConstants#INVALID_OFFSET} if the line info - * is unavailable. - * - * @param byteCodeDocLine 0-based line number - * @return 0-based source code or {@link ByteCodeConstants#INVALID_OFFSET} - */ - public int getSourceCodeLine(int byteCodeDocLine); - - /** - * Returns a {@link List} of {@link ITryBlock}s. - * - * @return {@link List} of {@link ITryBlock}s - * or null if the method does not have any try blocks. - */ - public List getTryBlocks(); - - /** - * Returns true if the method has code, - * false otherwise. Typically a method - * has no code if it is abstract or native. - * @return true or false - */ - public boolean hasCode(); - - /** - * True if the LineNumberTable is available - * otherwise false. - * @return true or false - */ - public boolean hasLineNumberTable(); - - /** - * Returns true if the method is abstract, - * false otherwise. - * - * @return true or false - */ - public boolean isAbstract(); - - /** - * Returns true if the method is a constructor, - * false otherwise. - * - * @return true or false - */ - public boolean isConstructor(); - - /** - * Returns true if the method is native, - * false otherwise. - * @return true or false - */ - public boolean isNative(); - - /** - * Returns the local variable table if exists or null. - * @return table or null - */ - public ILocalVariableTable getLocalVariableTable(); - - /** - * Returns true if the local variable table is available - * otherwise false. - * @return true or false - */ - public boolean isLocalVariableTableAvailable(); - - /** - * Returns the value of the max_stack item calculated by the compiler - * and stored in the class file. The max_stack gives the maximum depth - * of the operand stack of this method. - * @return The value of the max_stack - */ - public int getMaxStack(); - - /** - * Returns the value of the max_locals item calculated by the compiler - * and stored in the class file. The max_locals gives the number of - * local variables in the local variable array allocated upon invocation of this method, - * including the local variables used to pass parameters to the method on its invocation. - * @return The value of the max_locals - */ - public int getMaxLocals(); - - - /** - * Returns the exception table if exists or null. - * @return table or null - */ - public ExceptionTableEntry[] getExceptionTable(); - - /** - * Returns true if the exception table is available - * otherwise false. - * @return true or false - */ - public boolean isExceptionTableAvailable(); - - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/intf/IOutlineElement.java b/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/intf/IOutlineElement.java deleted file mode 100644 index abba6796..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/intf/IOutlineElement.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.asm.render.intf; - -/** - * Interface for the outline synchronization. - * @author Sergej Alekseev - * @version $Revision: 187 $ - * $Id: IOutlineElement.java 187 2013-06-03 05:47:37Z salekseev $ - */ -public interface IOutlineElement { - - /** - * Returns the line number of the visualizer - * instruction in the bytecode editor. - * @return line - */ - public int getBytecodeDocumentLine(); - - /** - * Returns the source code line number if available - * or -1 if not. - * @return line - */ - public int getSourceCodeDocumentLine(); -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/intf/IOutlineElementField.java b/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/intf/IOutlineElementField.java deleted file mode 100644 index b4a12330..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/intf/IOutlineElementField.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.asm.render.intf; - -/** - * Interface for the outline synchronization of fields. - * @author Sergej Alekseev - * @version $Revision: 187 $ - * $Id: IOutlineElementField.java 187 2013-06-03 05:47:37Z salekseev $ - */ -public interface IOutlineElementField { - - /** - * Returns the reference to the field section. - * @return the field section - */ - public IFieldSection getFieldSection(); - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/intf/ITryBlock.java b/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/intf/ITryBlock.java deleted file mode 100644 index c3ec2da2..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/asm/render/intf/ITryBlock.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.asm.render.intf; - -import java.util.List; - -/** - * Represenation of a try block. - * - * @author Peter Palaga - * @version $Revision: 187 $ - * $Id: ITryBlock.java 187 2013-06-03 05:47:37Z salekseev $ - */ -public interface ITryBlock { - /** - * Returns 1-based number of line on which this try block ends. - * - * @return 1-based line number. - */ - public int getEndLine(); - - /** - * {@link List} of {@link Integer}s representing 1-based line numbers - * on which the associated exception handlers startOffset. - * - * @return {@link List} of 1-based line numbers - */ - public List getExceptionHandlerLines(); - - /** - * Returns 1-based number of line on which this try block starts. - * - * @return 1-based line number. - */ - public int getStartLine(); -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/ByteCodeConstants.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/ByteCodeConstants.java deleted file mode 100644 index 251a11c8..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/ByteCodeConstants.java +++ /dev/null @@ -1,602 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode; - -import com.drgarbage.bytecode.constant_pool.ConstantPoolTags; -import com.drgarbage.bytecode.instructions.Opcodes; - -/** - * Byte code Constants. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision: 190 $ - * $Id: ByteCodeConstants.java 190 2013-06-04 16:47:24Z salekseev $ - */ -public class ByteCodeConstants implements Opcodes { - - public static final int MAGIC = 0xcafebabe; - public static final String CLASS_FILE_FORMAT_VERSION = "class file format version"; - public static final String Generated_by_x = "Generated by {0}"; - public static final String Version = "Version"; - public static final String Class_retrieved_from = "Class retrieved from"; - - public static final String COMPILED_FROM = "compiled from"; - public static final char UNKNOWN_INFORMATION = '?'; - - /** - * The '/' separator character used in the class names, e.g. - * java/lang/String. - */ - public static final char CLASS_NAME_SLASH = '/'; - public static final char CLASS_NAME_DOLLAR = '$'; - public static final char CLASS_NAME_POINT = '.'; - - /** - * "" - the name of the constructor methods. - */ - public static final String INIT = ""; - - /** - * "" - the name of the class initialization method. - */ - public static final String CLINIT = ""; - public static final char B_BYTE = 'B'; - public static final char C_CHAR = 'C'; - public static final char D_DOUBLE = 'D'; - public static final char F_FLOAT = 'F'; - public static final char I_INT = 'I'; - public static final char J_LONG = 'J'; - public static final char S_SHORT = 'S'; - public static final char Z_BOOLEAN = 'Z'; - public static final char L_REFERENCE = 'L'; - public static final char REFERENCE_TERMINATING_SEMICOLON = ';'; - public static final char ARRAY_BEGINNING_BRACKET = '['; - public static final char V_VOID = 'V'; - public static final char METHOD_DESCRIPTOR_LEFT_PARENTHESIS = '('; - public static final char METHOD_DESCRIPTOR_RIGHT_PARENTHESIS = ')'; - - - - public static final String[] OPCODE_MNEMONICS; - public static final String[] CONSTANT_POOL_TAG_MNEMONICS; - public static final String[] OPCODE_OPERANDSTACK_DESCR; - - static { - - OPCODE_MNEMONICS = new String[256]; - - OPCODE_MNEMONICS[OPCODE_NOP] = "nop"; - OPCODE_MNEMONICS[OPCODE_ACONST_NULL] = "aconst_null"; - OPCODE_MNEMONICS[OPCODE_ICONST_M1] = "iconst_m1"; - OPCODE_MNEMONICS[OPCODE_ICONST_0] = "iconst_0"; - OPCODE_MNEMONICS[OPCODE_ICONST_1] = "iconst_1"; - OPCODE_MNEMONICS[OPCODE_ICONST_2] = "iconst_2"; - OPCODE_MNEMONICS[OPCODE_ICONST_3] = "iconst_3"; - OPCODE_MNEMONICS[OPCODE_ICONST_4] = "iconst_4"; - OPCODE_MNEMONICS[OPCODE_ICONST_5] = "iconst_5"; - OPCODE_MNEMONICS[OPCODE_LCONST_0] = "lconst_0"; - OPCODE_MNEMONICS[OPCODE_LCONST_1] = "lconst_1"; - OPCODE_MNEMONICS[OPCODE_FCONST_0] = "fconst_0"; - OPCODE_MNEMONICS[OPCODE_FCONST_1] = "fconst_1"; - OPCODE_MNEMONICS[OPCODE_FCONST_2] = "fconst_2"; - OPCODE_MNEMONICS[OPCODE_DCONST_0] = "dconst_0"; - OPCODE_MNEMONICS[OPCODE_DCONST_1] = "dconst_1"; - OPCODE_MNEMONICS[OPCODE_BIPUSH] = "bipush"; - OPCODE_MNEMONICS[OPCODE_SIPUSH] = "sipush"; - OPCODE_MNEMONICS[OPCODE_LDC] = "ldc"; - OPCODE_MNEMONICS[OPCODE_LDC_W] = "ldc_w"; - OPCODE_MNEMONICS[OPCODE_LDC2_W] = "ldc2_w"; - OPCODE_MNEMONICS[OPCODE_ILOAD] = "iload"; - OPCODE_MNEMONICS[OPCODE_LLOAD] = "lload"; - OPCODE_MNEMONICS[OPCODE_FLOAD] = "fload"; - OPCODE_MNEMONICS[OPCODE_DLOAD] = "dload"; - OPCODE_MNEMONICS[OPCODE_ALOAD] = "aload"; - OPCODE_MNEMONICS[OPCODE_ILOAD_0] = "iload_0"; - OPCODE_MNEMONICS[OPCODE_ILOAD_1] = "iload_1"; - OPCODE_MNEMONICS[OPCODE_ILOAD_2] = "iload_2"; - OPCODE_MNEMONICS[OPCODE_ILOAD_3] = "iload_3"; - OPCODE_MNEMONICS[OPCODE_LLOAD_0] = "lload_0"; - OPCODE_MNEMONICS[OPCODE_LLOAD_1] = "lload_1"; - OPCODE_MNEMONICS[OPCODE_LLOAD_2] = "lload_2"; - OPCODE_MNEMONICS[OPCODE_LLOAD_3] = "lload_3"; - OPCODE_MNEMONICS[OPCODE_FLOAD_0] = "fload_0"; - OPCODE_MNEMONICS[OPCODE_FLOAD_1] = "fload_1"; - OPCODE_MNEMONICS[OPCODE_FLOAD_2] = "fload_2"; - OPCODE_MNEMONICS[OPCODE_FLOAD_3] = "fload_3"; - OPCODE_MNEMONICS[OPCODE_DLOAD_0] = "dload_0"; - OPCODE_MNEMONICS[OPCODE_DLOAD_1] = "dload_1"; - OPCODE_MNEMONICS[OPCODE_DLOAD_2] = "dload_2"; - OPCODE_MNEMONICS[OPCODE_DLOAD_3] = "dload_3"; - OPCODE_MNEMONICS[OPCODE_ALOAD_0] = "aload_0"; - OPCODE_MNEMONICS[OPCODE_ALOAD_1] = "aload_1"; - OPCODE_MNEMONICS[OPCODE_ALOAD_2] = "aload_2"; - OPCODE_MNEMONICS[OPCODE_ALOAD_3] = "aload_3"; - OPCODE_MNEMONICS[OPCODE_IALOAD] = "iaload"; - OPCODE_MNEMONICS[OPCODE_LALOAD] = "laload"; - OPCODE_MNEMONICS[OPCODE_FALOAD] = "faload"; - OPCODE_MNEMONICS[OPCODE_DALOAD] = "daload"; - OPCODE_MNEMONICS[OPCODE_AALOAD] = "aaload"; - OPCODE_MNEMONICS[OPCODE_BALOAD] = "baload"; - OPCODE_MNEMONICS[OPCODE_CALOAD] = "caload"; - OPCODE_MNEMONICS[OPCODE_SALOAD] = "saload"; - OPCODE_MNEMONICS[OPCODE_ISTORE] = "istore"; - OPCODE_MNEMONICS[OPCODE_LSTORE] = "lstore"; - OPCODE_MNEMONICS[OPCODE_FSTORE] = "fstore"; - OPCODE_MNEMONICS[OPCODE_DSTORE] = "dstore"; - OPCODE_MNEMONICS[OPCODE_ASTORE] = "astore"; - OPCODE_MNEMONICS[OPCODE_ISTORE_0] = "istore_0"; - OPCODE_MNEMONICS[OPCODE_ISTORE_1] = "istore_1"; - OPCODE_MNEMONICS[OPCODE_ISTORE_2] = "istore_2"; - OPCODE_MNEMONICS[OPCODE_ISTORE_3] = "istore_3"; - OPCODE_MNEMONICS[OPCODE_LSTORE_0] = "lstore_0"; - OPCODE_MNEMONICS[OPCODE_LSTORE_1] = "lstore_1"; - OPCODE_MNEMONICS[OPCODE_LSTORE_2] = "lstore_2"; - OPCODE_MNEMONICS[OPCODE_LSTORE_3] = "lstore_3"; - OPCODE_MNEMONICS[OPCODE_FSTORE_0] = "fstore_0"; - OPCODE_MNEMONICS[OPCODE_FSTORE_1] = "fstore_1"; - OPCODE_MNEMONICS[OPCODE_FSTORE_2] = "fstore_2"; - OPCODE_MNEMONICS[OPCODE_FSTORE_3] = "fstore_3"; - OPCODE_MNEMONICS[OPCODE_DSTORE_0] = "dstore_0"; - OPCODE_MNEMONICS[OPCODE_DSTORE_1] = "dstore_1"; - OPCODE_MNEMONICS[OPCODE_DSTORE_2] = "dstore_2"; - OPCODE_MNEMONICS[OPCODE_DSTORE_3] = "dstore_3"; - OPCODE_MNEMONICS[OPCODE_ASTORE_0] = "astore_0"; - OPCODE_MNEMONICS[OPCODE_ASTORE_1] = "astore_1"; - OPCODE_MNEMONICS[OPCODE_ASTORE_2] = "astore_2"; - OPCODE_MNEMONICS[OPCODE_ASTORE_3] = "astore_3"; - OPCODE_MNEMONICS[OPCODE_IASTORE] = "iastore"; - OPCODE_MNEMONICS[OPCODE_LASTORE] = "lastore"; - OPCODE_MNEMONICS[OPCODE_FASTORE] = "fastore"; - OPCODE_MNEMONICS[OPCODE_DASTORE] = "dastore"; - OPCODE_MNEMONICS[OPCODE_AASTORE] = "aastore"; - OPCODE_MNEMONICS[OPCODE_BASTORE] = "bastore"; - OPCODE_MNEMONICS[OPCODE_CASTORE] = "castore"; - OPCODE_MNEMONICS[OPCODE_SASTORE] = "sastore"; - OPCODE_MNEMONICS[OPCODE_POP] = "pop"; - OPCODE_MNEMONICS[OPCODE_POP2] = "pop2"; - OPCODE_MNEMONICS[OPCODE_DUP] = "dup"; - OPCODE_MNEMONICS[OPCODE_DUP_X1] = "dup_x1"; - OPCODE_MNEMONICS[OPCODE_DUP_X2] = "dup_x2"; - OPCODE_MNEMONICS[OPCODE_DUP2] = "dup2"; - OPCODE_MNEMONICS[OPCODE_DUP2_X1] = "dup2_x1"; - OPCODE_MNEMONICS[OPCODE_DUP2_X2] = "dup2_x2"; - OPCODE_MNEMONICS[OPCODE_SWAP] = "swap"; - OPCODE_MNEMONICS[OPCODE_IADD] = "iadd"; - OPCODE_MNEMONICS[OPCODE_LADD] = "ladd"; - OPCODE_MNEMONICS[OPCODE_FADD] = "fadd"; - OPCODE_MNEMONICS[OPCODE_DADD] = "dadd"; - OPCODE_MNEMONICS[OPCODE_ISUB] = "isub"; - OPCODE_MNEMONICS[OPCODE_LSUB] = "lsub"; - OPCODE_MNEMONICS[OPCODE_FSUB] = "fsub"; - OPCODE_MNEMONICS[OPCODE_DSUB] = "dsub"; - OPCODE_MNEMONICS[OPCODE_IMUL] = "imul"; - OPCODE_MNEMONICS[OPCODE_LMUL] = "lmul"; - OPCODE_MNEMONICS[OPCODE_FMUL] = "fmul"; - OPCODE_MNEMONICS[OPCODE_DMUL] = "dmul"; - OPCODE_MNEMONICS[OPCODE_IDIV] = "idiv"; - OPCODE_MNEMONICS[OPCODE_LDIV] = "ldiv"; - OPCODE_MNEMONICS[OPCODE_FDIV] = "fdiv"; - OPCODE_MNEMONICS[OPCODE_DDIV] = "ddiv"; - OPCODE_MNEMONICS[OPCODE_IREM] = "irem"; - OPCODE_MNEMONICS[OPCODE_LREM] = "lrem"; - OPCODE_MNEMONICS[OPCODE_FREM] = "frem"; - OPCODE_MNEMONICS[OPCODE_DREM] = "drem"; - OPCODE_MNEMONICS[OPCODE_INEG] = "ineg"; - OPCODE_MNEMONICS[OPCODE_LNEG] = "lneg"; - OPCODE_MNEMONICS[OPCODE_FNEG] = "fneg"; - OPCODE_MNEMONICS[OPCODE_DNEG] = "dneg"; - OPCODE_MNEMONICS[OPCODE_ISHL] = "ishl"; - OPCODE_MNEMONICS[OPCODE_LSHL] = "lshl"; - OPCODE_MNEMONICS[OPCODE_ISHR] = "ishr"; - OPCODE_MNEMONICS[OPCODE_LSHR] = "lshr"; - OPCODE_MNEMONICS[OPCODE_IUSHR] = "iushr"; - OPCODE_MNEMONICS[OPCODE_LUSHR] = "lushr"; - OPCODE_MNEMONICS[OPCODE_IAND] = "iand"; - OPCODE_MNEMONICS[OPCODE_LAND] = "land"; - OPCODE_MNEMONICS[OPCODE_IOR] = "ior"; - OPCODE_MNEMONICS[OPCODE_LOR] = "lor"; - OPCODE_MNEMONICS[OPCODE_IXOR] = "ixor"; - OPCODE_MNEMONICS[OPCODE_LXOR] = "lxor"; - OPCODE_MNEMONICS[OPCODE_IINC] = "iinc"; - OPCODE_MNEMONICS[OPCODE_I2L] = "i2l"; - OPCODE_MNEMONICS[OPCODE_I2F] = "i2f"; - OPCODE_MNEMONICS[OPCODE_I2D] = "i2d"; - OPCODE_MNEMONICS[OPCODE_L2I] = "l2i"; - OPCODE_MNEMONICS[OPCODE_L2F] = "l2f"; - OPCODE_MNEMONICS[OPCODE_L2D] = "l2d"; - OPCODE_MNEMONICS[OPCODE_F2I] = "f2i"; - OPCODE_MNEMONICS[OPCODE_F2L] = "f2l"; - OPCODE_MNEMONICS[OPCODE_F2D] = "f2d"; - OPCODE_MNEMONICS[OPCODE_D2I] = "d2i"; - OPCODE_MNEMONICS[OPCODE_D2L] = "d2l"; - OPCODE_MNEMONICS[OPCODE_D2F] = "d2f"; - OPCODE_MNEMONICS[OPCODE_I2B] = "i2b"; - OPCODE_MNEMONICS[OPCODE_I2C] = "i2c"; - OPCODE_MNEMONICS[OPCODE_I2S] = "i2s"; - OPCODE_MNEMONICS[OPCODE_LCMP] = "lcmp"; - OPCODE_MNEMONICS[OPCODE_FCMPL] = "fcmpl"; - OPCODE_MNEMONICS[OPCODE_FCMPG] = "fcmpg"; - OPCODE_MNEMONICS[OPCODE_DCMPL] = "dcmpl"; - OPCODE_MNEMONICS[OPCODE_DCMPG] = "dcmpg"; - OPCODE_MNEMONICS[OPCODE_IFEQ] = "ifeq"; - OPCODE_MNEMONICS[OPCODE_IFNE] = "ifne"; - OPCODE_MNEMONICS[OPCODE_IFLT] = "iflt"; - OPCODE_MNEMONICS[OPCODE_IFGE] = "ifge"; - OPCODE_MNEMONICS[OPCODE_IFGT] = "ifgt"; - OPCODE_MNEMONICS[OPCODE_IFLE] = "ifle"; - OPCODE_MNEMONICS[OPCODE_IF_ICMPEQ] = "if_icmpeq"; - OPCODE_MNEMONICS[OPCODE_IF_ICMPNE] = "if_icmpne"; - OPCODE_MNEMONICS[OPCODE_IF_ICMPLT] = "if_icmplt"; - OPCODE_MNEMONICS[OPCODE_IF_ICMPGE] = "if_icmpge"; - OPCODE_MNEMONICS[OPCODE_IF_ICMPGT] = "if_icmpgt"; - OPCODE_MNEMONICS[OPCODE_IF_ICMPLE] = "if_icmple"; - OPCODE_MNEMONICS[OPCODE_IF_ACMPEQ] = "if_acmpeq"; - OPCODE_MNEMONICS[OPCODE_IF_ACMPNE] = "if_acmpne"; - OPCODE_MNEMONICS[OPCODE_GOTO] = "goto"; - OPCODE_MNEMONICS[OPCODE_JSR] = "jsr"; - OPCODE_MNEMONICS[OPCODE_RET] = "ret"; - OPCODE_MNEMONICS[OPCODE_TABLESWITCH] = "tableswitch"; - OPCODE_MNEMONICS[OPCODE_LOOKUPSWITCH] = "lookupswitch"; - OPCODE_MNEMONICS[OPCODE_IRETURN] = "ireturn"; - OPCODE_MNEMONICS[OPCODE_LRETURN] = "lreturn"; - OPCODE_MNEMONICS[OPCODE_FRETURN] = "freturn"; - OPCODE_MNEMONICS[OPCODE_DRETURN] = "dreturn"; - OPCODE_MNEMONICS[OPCODE_ARETURN] = "areturn"; - OPCODE_MNEMONICS[OPCODE_RETURN] = "return"; - OPCODE_MNEMONICS[OPCODE_GETSTATIC] = "getstatic"; - OPCODE_MNEMONICS[OPCODE_PUTSTATIC] = "putstatic"; - OPCODE_MNEMONICS[OPCODE_GETFIELD] = "getfield"; - OPCODE_MNEMONICS[OPCODE_PUTFIELD] = "putfield"; - OPCODE_MNEMONICS[OPCODE_INVOKEVIRTUAL] = "invokevirtual"; - OPCODE_MNEMONICS[OPCODE_INVOKESPECIAL] = "invokespecial"; - OPCODE_MNEMONICS[OPCODE_INVOKESTATIC] = "invokestatic"; - OPCODE_MNEMONICS[OPCODE_INVOKEINTERFACE] = "invokeinterface"; - OPCODE_MNEMONICS[OPCODE_INVOKEDYNAMIC] = "invokedynamic"; - OPCODE_MNEMONICS[OPCODE_NEW] = "new"; - OPCODE_MNEMONICS[OPCODE_NEWARRAY] = "newarray"; - OPCODE_MNEMONICS[OPCODE_ANEWARRAY] = "anewarray"; - OPCODE_MNEMONICS[OPCODE_ARRAYLENGTH] = "arraylength"; - OPCODE_MNEMONICS[OPCODE_ATHROW] = "athrow"; - OPCODE_MNEMONICS[OPCODE_CHECKCAST] = "checkcast"; - OPCODE_MNEMONICS[OPCODE_INSTANCEOF] = "instanceof"; - OPCODE_MNEMONICS[OPCODE_MONITORENTER] = "monitorenter"; - OPCODE_MNEMONICS[OPCODE_MONITOREXIT] = "monitorexit"; - OPCODE_MNEMONICS[OPCODE_WIDE] = "wide"; - OPCODE_MNEMONICS[OPCODE_MULTIANEWARRAY] = "multianewarray"; - OPCODE_MNEMONICS[OPCODE_IFNULL] = "ifnull"; - OPCODE_MNEMONICS[OPCODE_IFNONNULL] = "ifnonnull"; - OPCODE_MNEMONICS[OPCODE_GOTO_W] = "goto_w"; - OPCODE_MNEMONICS[OPCODE_JSR_W] = "jsr_w"; - OPCODE_MNEMONICS[OPCODE_BREAKPOINT] = "breakpoint"; - OPCODE_MNEMONICS[OPCODE_IMPDEP1] = "impdep1"; - OPCODE_MNEMONICS[OPCODE_IMPDEP2] = "impdep2"; - - - CONSTANT_POOL_TAG_MNEMONICS = new String[19]; - CONSTANT_POOL_TAG_MNEMONICS[ConstantPoolTags.CONSTANT_CLASS] = "CONSTANT_Class"; - CONSTANT_POOL_TAG_MNEMONICS[ConstantPoolTags.CONSTANT_FIELDREF] = "CONSTANT_Fieldref"; - CONSTANT_POOL_TAG_MNEMONICS[ConstantPoolTags.CONSTANT_METHODREF] = "CONSTANT_Methodref"; - CONSTANT_POOL_TAG_MNEMONICS[ConstantPoolTags.CONSTANT_INTERFACE_METHODREF] = "CONSTANT_InterfaceMethodref"; - CONSTANT_POOL_TAG_MNEMONICS[ConstantPoolTags.CONSTANT_STRING] = "CONSTANT_String"; - CONSTANT_POOL_TAG_MNEMONICS[ConstantPoolTags.CONSTANT_INTEGER] = "CONSTANT_Integer"; - CONSTANT_POOL_TAG_MNEMONICS[ConstantPoolTags.CONSTANT_FLOAT] = "CONSTANT_Float"; - CONSTANT_POOL_TAG_MNEMONICS[ConstantPoolTags.CONSTANT_LONG] = "CONSTANT_Long"; - CONSTANT_POOL_TAG_MNEMONICS[ConstantPoolTags.CONSTANT_DOUBLE] = "CONSTANT_Double"; - CONSTANT_POOL_TAG_MNEMONICS[ConstantPoolTags.CONSTANT_NAME_AND_TYPE] = "CONSTANT_NameAndType"; - CONSTANT_POOL_TAG_MNEMONICS[ConstantPoolTags.CONSTANT_UTF8] = "CONSTANT_Utf8"; - CONSTANT_POOL_TAG_MNEMONICS[ConstantPoolTags.CONSTANT_METHOD_HANDLE] = "CONSTANT_MethodHandle"; - CONSTANT_POOL_TAG_MNEMONICS[ConstantPoolTags.CONSTANT_METHOD_TYPE] = "CONSTANT_MethodType"; - CONSTANT_POOL_TAG_MNEMONICS[ConstantPoolTags.CONSTANT_INVOKE_DYNAMIC] = "CONSTANT_InvokeDynamic"; - - - OPCODE_OPERANDSTACK_DESCR = new String[256]; - - OPCODE_OPERANDSTACK_DESCR[OPCODE_NOP] = "do nothing"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_ACONST_NULL] = "Push a null object reference onto the stack"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_ICONST_M1] = "push an int constant -1"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_ICONST_0] = "push an int constant 0"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_ICONST_1] = "push an int constant 1"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_ICONST_2] = "push an int constant 2"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_ICONST_3] = "push an int constant 3"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_ICONST_4] = "push an int constant 4"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_ICONST_5] = "push an int constant 5"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_LCONST_0] = "push a long constant 0L"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_LCONST_1] = "push a long constant 1L"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_FCONST_0] = "push a float constant 0.0f"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_FCONST_1] = "push a float constant 1.0f"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_FCONST_2] = "push a float constant 2.0f"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_DCONST_0] = "push a double constant 0.0"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_DCONST_1] = "push a double constant 1.0"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_BIPUSH] = "push an int value, to which the immediate byte is sign-extended"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_SIPUSH] = "push an int value, to which the immediate short is sign-extended"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_LDC] = "push a constant #index from a constant pool (String, int or float)"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_LDC_W] = "push a constant #index from a constant pool (String, int or float)"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_LDC2_W] = "push a constant #index from a constant pool (double or long)"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_ILOAD] = "push an int value from a local variable #index"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_LLOAD] = "push a long value from a local variable #index"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_FLOAD] = "push a float value from a local variable #index"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_DLOAD] = "push a double value from a local variable #index"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_ALOAD] = "push an object reference onto the stack from a local variable #index"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_ILOAD_0] = "push an int value from the local variable 0"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_ILOAD_1] = "push an int value from the local variable 1"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_ILOAD_2] = "push an int value from the local variable 2"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_ILOAD_3] = "push an int value from the local variable 3"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_LLOAD_0] = "push a long value from the local variable 0"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_LLOAD_1] = "push a long value from the local variable 1"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_LLOAD_2] = "push a long value from the local variable 2"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_LLOAD_3] = "push a long value from the local variable 3"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_FLOAD_0] = "push a float value from the local variable 0"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_FLOAD_1] = "push a float value from the local variable 1"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_FLOAD_2] = "push a float value from the local variable 2"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_FLOAD_3] = "push a float value from the local variable 3"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_DLOAD_0] = "push a double from the local variable 0"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_DLOAD_1] = "push a double from the local variable 1"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_DLOAD_2] = "push a double from the local variable 2"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_DLOAD_3] = "push a double from the local variable 3"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_ALOAD_0] = "push an object reference onto the stack from the local variable 0"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_ALOAD_1] = "push an object reference onto the stack from the local variable 1"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_ALOAD_2] = "push an object reference onto the stack from the local variable 2"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_ALOAD_3] = "push an object reference onto the stack from the local variable 3"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_IALOAD] = "push an int from an array"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_LALOAD] = "push a long from an array"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_FALOAD] = "push a float from an array"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_DALOAD] = "push a double from an array"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_AALOAD] = "push an object reference from an array"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_BALOAD] = "push a byte or Boolean value from an array"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_CALOAD] = "push a char from an array"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_SALOAD] = "push a short from an array"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_ISTORE] = "pop an int value into variable #index"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_LSTORE] = "pop a long value in a local variable #index"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_FSTORE] = "pop a float value into a local variable #index"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_DSTORE] = "pop a double value into a local variable #index"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_ASTORE] = "pop a reference into a local variable #index"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_ISTORE_0] = "pop int value into local variable 0"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_ISTORE_1] = "pop int value into local variable 1"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_ISTORE_2] = "pop int value into local variable 2"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_ISTORE_3] = "pop int value into local variable 3"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_LSTORE_0] = "pop long value into local variable 0"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_LSTORE_1] = "pop long value into local variable 1"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_LSTORE_2] = "pop long value into local variable 2"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_LSTORE_3] = "pop long value into local variable 3"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_FSTORE_0] = "pop float value into local variable 0"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_FSTORE_1] = "pop float value into local variable 1"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_FSTORE_2] = "pop float value into local variable 2"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_FSTORE_3] = "pop float value into local variable 3"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_DSTORE_0] = "pop double value into local variable 0"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_DSTORE_1] = "pop double value into local variable 1"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_DSTORE_2] = "pop double value into local variable 2"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_DSTORE_3] = "pop double value into local variable 3"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_ASTORE_0] = "pop a reference into local variable 0"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_ASTORE_1] = "pop a reference into local variable 1"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_ASTORE_2] = "pop a reference into local variable 2"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_ASTORE_3] = "pop a reference into local variable 3"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_IASTORE] = "pop an int into an array"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_LASTORE] = "pop a long to an array"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_FASTORE] = "pop a float in an array"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_DASTORE] = "pop a double into an array"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_AASTORE] = "pop into a reference in an array"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_BASTORE] = "pop a byte or Boolean value into an array"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_CASTORE] = "pop a char into an array"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_SASTORE] = "pop short to array"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_POP] = "discard the top value on the stack"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_POP2] = "discard the top two values on the stack (or one value, if it is a double or long)"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_DUP] = "duplicate the value on top of the stack"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_DUP_X1] = "Duplicate the top value on the operand stack and insert the duplicated value two values down in the stack"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_DUP_X2] = "duplicate the top value on the operand stack and insert the duplicated value two or three values down in the stack"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_DUP2] = "duplicate the top one or two values on the stack and push the duplicated value or values back onto the stack in the original order"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_DUP2_X1] = "duplicate the top one or two values on the stack and insert the duplicated values, in the original order, one value beneath the original value or values in the stack"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_DUP2_X2] = "duplicate the top one or two values on the stack and insert the duplicated values, in the original order, into the stack"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_SWAP] = "swaps two top words on the stack"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_IADD] = "add two ints"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_LADD] = "add two longs"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_FADD] = "add two floats"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_DADD] = "add two doubles"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_ISUB] = "int subtract"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_LSUB] = "subtract two longs"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_FSUB] = "subtract two floats"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_DSUB] = "subtract two doubles"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_IMUL] = "multiply two integers"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_LMUL] = "multiply two longs"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_FMUL] = "multiply two floats"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_DMUL] = "multiply two doubles"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_IDIV] = "divide two integers"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_LDIV] = "divide two longs"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_FDIV] = "divide two floats"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_DDIV] = "divide two doubles"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_IREM] = "logical int remainder"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_LREM] = "remainder of division of two longs"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_FREM] = "get the remainder from a division between two floats"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_DREM] = "get the remainder from a division between two doubles"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_INEG] = "negate an int"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_LNEG] = "negate a long"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_FNEG] = "negate a float"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_DNEG] = "negate a double"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_ISHL] = "int shift left"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_LSHL] = "bitwise shift left of a long value1 by value2 positions"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_ISHR] = "int arithmetic shift right"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_LSHR] = "bitwise shift right of a long value1 by value2 positions"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_IUSHR] = "int logical shift right"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_LUSHR] = "bitwise shift right of a long value1 by value2 positions, unsigned"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_IAND] = "perform a bitwise and on two integers"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_LAND] = "bitwise and of two longs"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_IOR] = "bitwise int or"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_LOR] = "bitwise or of two longs"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_IXOR] = "bitwise exclusive or of two ints"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_LXOR] = "bitwise exclusive or of two longs"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_IINC] = "increment local variable #index by signed byte const"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_I2L] = "convert an int into a long"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_I2F] = "convert an int into a float"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_I2D] = "convert an int into a double"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_L2I] = "convert a long to an int"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_L2F] = "convert a long to a float"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_L2D] = "convert a long to a double"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_F2I] = "convert a float to an int"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_F2L] = "convert a float to a long"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_F2D] = "convert a float to a double"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_D2I] = "convert a double to an int"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_D2L] = "convert a double to a long"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_D2F] = "convert a double to a float"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_I2B] = "convert an int into a byte"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_I2C] = "convert an int into a character"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_I2S] = "convert an int into a short"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_LCMP] = "compare two longs values"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_FCMPL] = "compare two floats (lower)"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_FCMPG] = "compare two floats (greater)"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_DCMPL] = "compare two doubles (lower)"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_DCMPG] = "compare two doubles (greater)"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_IFEQ] = "if value is 0, branch to instruction at branchoffset"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_IFNE] = "if value is not 0, branch to instruction at branchoffset"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_IFLT] = "if value is less than 0, branch to instruction at branchoffset"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_IFGE] = "if value is greater than or equal to 0, branch to instruction at branchoffset"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_IFGT] = "if value is greater than 0, branch to instruction at branchoffset"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_IFLE] = "if value is less than or equal to 0, branch to instruction at branchoffset"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_IF_ICMPEQ] = "if ints are equal, branch to instruction at branchoffset"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_IF_ICMPNE] = "if ints are not equal, branch to instruction at branchoffset"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_IF_ICMPLT] = "if value1 is less than value2, branch to instruction at branchoffset"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_IF_ICMPGE] = "if value1 is greater than or equal to value2, branch to instruction at branchoffset"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_IF_ICMPGT] = "if value1 is greater than value2, branch to instruction at branchoffset"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_IF_ICMPLE] = "if value1 is less than or equal to value2, branch to instruction at branchoffset"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_IF_ACMPEQ] = "if references are equal, branch to instruction at branchoffset"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_IF_ACMPNE] = "if references are not equal, branch to instruction at branchoffset"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_GOTO] = "goes to another instruction at branchoffset"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_JSR] = "jump to subroutine at branchoffset"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_RET] = "continue execution from address taken from a local variable #index (the asymmetry with jsr is intentional)"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_TABLESWITCH] = "continue execution from an address in the table at offset index"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_LOOKUPSWITCH] = "a target address is looked up from a table using a key and execution continues from the instruction at that address"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_IRETURN] = "return an integer from a method"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_LRETURN] = "return a long value"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_FRETURN] = "return a float"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_DRETURN] = "return a double from a method"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_ARETURN] = "return a reference from a method"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_RETURN] = "return void from method"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_GETSTATIC] = "get a static field value of a class, where the field is identified by field reference in the constant pool"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_PUTSTATIC] = "set static field to value in a class, where the field is identified by a field reference index in constant pool"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_GETFIELD] = "get a field value of an object objectref, where the field is identified by field reference in the constant pool"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_PUTFIELD] = "set field to value in an object objectref, where the field is identified by a field reference index in constant pool"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_INVOKEVIRTUAL] = "invoke virtual method on object objectref, where the method is identified by method reference index in constant pool"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_INVOKESPECIAL] = "invoke instance method on object objectref, where the method is identified by method reference index in constant pool"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_INVOKESTATIC] = "invoke a static method, where the method is identified by method reference index in constant pool"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_INVOKEINTERFACE] = "invokes an interface method on object objectref, where the interface method is identified by method reference index in constant pool"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_INVOKEDYNAMIC] = "invokes a dynamic method identified by method reference index in constant pool"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_NEW] = "create new object of type identified by class reference in constant pool"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_NEWARRAY] = "create new array with count elements of primitive type identified by atype"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_ANEWARRAY] = "create a new array of references of length count and component type identified by the class reference in the constant pool"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_ARRAYLENGTH] = "get the length of an array"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_ATHROW] = "throws an error or exception (notice that the rest of the stack is cleared, leaving only a reference to the Throwable)"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_CHECKCAST] = "checks whether an objectref is of a certain type, the class reference of which is in the constant pool"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_INSTANCEOF] = "determines if an object objectref is of a given type, identified by class reference index in constant pool"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_MONITORENTER] = "enter monitor for object (\"grab the lock\" - start of synchronized() section)"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_MONITOREXIT] = "exit monitor for object (\"release the lock\" - end of synchronized() section)"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_WIDE] = "execute opcode"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_MULTIANEWARRAY] = "create a new array of dimensions dimensions with elements of type identified by class reference in constant pool"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_IFNULL] = "if value is null, branch to instruction at branchoffset"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_IFNONNULL] = "if value is not null, branch to instruction at branchoffset"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_GOTO_W] = "goes to another instruction at branchoffset"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_JSR_W] = "jump to subroutine at branchoffset"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_BREAKPOINT] = "reserved for breakpoints in Java debuggers; should not appear in any class file"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_IMPDEP1] = "reserved for implementation-dependent operations within debuggers; should not appear in any class file"; - OPCODE_OPERANDSTACK_DESCR[OPCODE_IMPDEP2] = "reserved for implementation-dependent operations within debuggers; should not appear in any class file"; - - } - - public static final int INVALID_OFFSET = -1; - public static final String JAVA = "java"; - public static final String NULL = "null"; - - public static final String JAVA_LANG_OBJECT = "java/lang/Object"; - public static final String DEBUG_INFO = "debug info"; - public static final String JAVA_LANG_DEPRECATED = "java/lang/Deprecated"; - public static final String BRIDGE_METHOD_GENERATED_BY_THE_COMPILER = "bridge method generated by the compiler"; - public static final String ARG = "arg"; - public static final String SOURCE_LINE = "source line"; - public static final byte TAG_CLASS = 7; - public static final byte TAG_FIELDREF = 9; - public static final byte TAG_METHODREF = 10; - public static final byte TAG_INTERFACE_METHODREF = 11; - public static final byte TAG_STRING = 8; - public static final byte TAG_INTEGER = 3; - public static final byte TAG_FLOAT = 4; - public static final byte TAG_LONG = 5; - public static final byte TAG_DOUBLE = 6; - public static final byte TAG_NAME_AND_TYPE = 12; - public static final byte TAG_UTF8 = 1; - public static final byte TAG_METHOD_HANDLE = 15; - public static final byte TAG_METHOD_TYPE = 16; - public static final byte TAG_INVOKE_DYNAMIC = 18; - public static final String COVERS_BYTES_X_TO_Y = "covers bytes {0} to {1}"; - public static final String INNER_CLASS = "inner class"; - public static final String LINE_NUMBER_TABLE = "LineNumberTable"; - public static final String LINE_NUMBER_TABLE_NOT_AVAILABLE = "LineNumberTable not available"; - public static final String LOCAL_VARIABLE_TABLE = "LocalVariableTable"; - public static final String LOCAL_VARIABLE_TYPE_TABLE = "LocalVariableTypeTable"; - public static final String EXCEPTION_TABLE = "ExceptionTable"; - public static final String EXCEPTION_TABLE_NOT_AVAILABLE = "ExceptionTable not available"; - public static final String EXCEPTION_TABLE_EMPTY = "ExceptionTable (empty)"; - public static final String ANY_EXCEPTION = "any"; - public static final String MAX_STACK = "max_stack"; - public static final String MAX_LOCALS = "max_locals"; - public static final String CODE = "Code"; - - public static final String START_PC = "start_pc"; - public static final String END_PC = "end_pc"; - public static final String HANDLER_PC = "handler_pc"; - public static final String CATCH_TYPE = "catch_type"; - public static final String LINE = "line"; - public static final Object LOCAL_VARIABLE_TABLE_NOT_AVAILABLE = "LocalVariableTable not available"; - public static final Object LOCAL_VARIABLE_TABLE_EMPTY = "LocalVariableTable (empty)"; - public static final Object LOCAL_VARIABLE_TYPE_TABLE_NOT_AVAILABLE = "LocalVariableTypeTable not available"; - public static final String LENGTH = "length"; - public static final String NAME_INDEX = "name_index"; - public static final String DESCRIPTOR_INDEX = "descriptor_index"; - public static final String INDEX = "index"; - public static final String NAME = "name"; - public static final String DESCRIPTOR = "descriptor"; - public static final String LINE_NUMBER = "line_number"; - public static final String CLINIT_MNEMONICS = "{...}"; - public static final String OUTER_CLASS = "outer class"; - public static final String IN_METHOD = "in method"; - public static final String VISIBLE = "visible"; - public static final String INVISIBLE = "invisible"; - public static final String ANNOTATION = "annotation"; - public static final String ATTRIBUTE = "attribute"; - public static final int INVALID_LINE = -1; - public static final String JDI = "JDI"; - public static final String Filesystem = "Filesystem"; - public static final String TYPE_AND_NAME = "type and name"; - public static final String VARARGS = "varargs"; - public static final String LOADED_INNER_TYPES = "Loaded inner types:"; - public static final String Debug_target = "Debug target"; - public static final String Retrieved_on = "Retrieved on"; - public static final String ID = "id"; - public static final String CONSTANT_POOL_NOT_AVAILABLE = "Constant Pool not available"; - public static final String CONSTANT_POOL = "Constant Pool"; - public static final String CONSTANT_POOL_EMPTY = "Constant Pool (empty)"; - public static final String TAG = "tag"; - public static final String INFO = "info"; - public static final String CLASS_INDEX = "class_index"; - public static final String name_and_type_index = "name_and_type_index"; - public static final String string_index = "string_index"; - public static final String bytes = "bytes"; - public static final char L_LINE = 'L'; - public static final String METHOD_HANDLE_REF_KIND = "reference_kind"; - public static final String METHOD_HANDLE_INDEX = "reference_index"; - public static final String INVOKE_DYNAMIC_BOOTSTRAP_METHOD_ATTR_INDEX = "bootstrap_method_attr_index"; - public static final String INVOKE_DYNAMIC_NAME_AND_TYPE_INDEX = "name_and_type_index"; - - public static enum Align {LEFT, CENTER, RIGHT}; - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/ByteCodeOutputStream.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/ByteCodeOutputStream.java deleted file mode 100644 index 197eedfa..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/ByteCodeOutputStream.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode; - -import java.io.DataOutputStream; -import java.io.OutputStream; - -/** - * DataOutputStream which extends CountedOutput. - * - */ -public class ByteCodeOutputStream extends DataOutputStream - implements CountedOutput -{ - - /** - Constructor. - @param out the output stream. - */ - public ByteCodeOutputStream(OutputStream out) { - super(new CountedOutputStream(out)); - } - - public int getByteCount() { - return ((CountedOutputStream)out).getByteCount(); - } -} \ No newline at end of file diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/BytecodeUtils.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/BytecodeUtils.java deleted file mode 100644 index afab7f85..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/BytecodeUtils.java +++ /dev/null @@ -1,398 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode; - -import java.io.IOException; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jdt.core.IClassFile; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import com.drgarbage.asm.MethodVisitor; -import com.drgarbage.asm.Opcodes; -import com.drgarbage.asm.render.intf.ILocalVariableTable; -import com.drgarbage.bytecode.constant_pool.AbstractConstantPoolEntry; -import com.drgarbage.bytecode.constant_pool.ConstantClassInfo; -import com.drgarbage.bytecode.constant_pool.ConstantUtf8Info; -import com.drgarbage.javasrc.JavaKeywords; -import com.drgarbage.javasrc.JavaLexicalConstants; - -public class BytecodeUtils { - public static int getMinor(int classFileFormatVersion) { - return classFileFormatVersion >>> 16; - } - - public static int getMajor(int classFileFormatVersion) { - return classFileFormatVersion & 0xFFFF; - } - - public static String getLowestJavaPlatformVersion(int major, int minor) { - if (major < 45) { - return null; - } else if (major == 45 && minor >= 0 && minor <= 3) { - return "1.0.2"; - } else if (major == 45 && minor >= 0 && minor <= 65535) { - return "1.1"; - } else { - StringBuilder sb = new StringBuilder(); - sb.append("1."); - sb.append(major - 44); - return sb.toString(); - } - } - - public static String toJavaSrcName(String byteCodeName) { - return byteCodeName.replace(ByteCodeConstants.CLASS_NAME_SLASH, - JavaLexicalConstants.DOT).replace( - ByteCodeConstants.CLASS_NAME_DOLLAR, JavaLexicalConstants.DOT); - } - - public static String getSimpleName(String byteCodeName) { - if (byteCodeName != null) { - int i = byteCodeName - .lastIndexOf(ByteCodeConstants.CLASS_NAME_SLASH); - if (i >= 0) { - return byteCodeName.substring(i + 1); - } - } - return byteCodeName; - } - - public static String getPackage(String thisClassName) { - if (thisClassName != null) { - int i = thisClassName - .lastIndexOf(ByteCodeConstants.CLASS_NAME_SLASH); - if (i >= 0) { - return thisClassName.substring(0, i); - } - } - return null; - } - - /** - * @see MethodVisitor#visitIntInsn(int, int) - * - * @param operand - * @return java keyword as a string - */ - public static String getJavaTypeName(int operand) { - switch (operand) { - case Opcodes.T_BOOLEAN: - return JavaKeywords.BOOLEAN; - case Opcodes.T_CHAR: - return JavaKeywords.CHAR; - case Opcodes.T_FLOAT: - return JavaKeywords.FLOAT; - case Opcodes.T_DOUBLE: - return JavaKeywords.DOUBLE; - case Opcodes.T_BYTE: - return JavaKeywords.BYTE; - case Opcodes.T_SHORT: - return JavaKeywords.SHORT; - case Opcodes.T_INT: - return JavaKeywords.INT; - case Opcodes.T_LONG: - return JavaKeywords.LONG; - default: - throw new IllegalArgumentException("Unexpected option '" + operand - + "';"); - } - } - - public static int appendMethodDescriptor(String methodName, - boolean isConstructor, boolean isStatic, String descr, int offset, - ILocalVariableTable localVariableTable, - AbstractConstantPoolEntry[] constantPool, Appendable doc) - throws IOException { - - /* - * parse the method arguments first and save them in a temporarary - * StringBuilder - */ - StringBuilder sb = new StringBuilder(); - int i = offset; - switch (descr.charAt(i++)) { - case ByteCodeConstants.METHOD_DESCRIPTOR_LEFT_PARENTHESIS: - break; - default: - i--; - throw new IllegalArgumentException( - "could not parse the descriptor '" + descr - + "'. '(' expected, found '" + descr.charAt(i) - + "' at the position " + i + "."); - } - int argi = 0; - while ((descr.charAt(i)) != ByteCodeConstants.METHOD_DESCRIPTOR_RIGHT_PARENTHESIS) { - if (argi != 0) { - sb.append(JavaLexicalConstants.COMMA); - sb.append(JavaLexicalConstants.SPACE); - } - i = appendFieldDescriptor(descr, i, sb); - sb.append(JavaLexicalConstants.SPACE); - - String argName = null; - - if (localVariableTable != null) { - argName = localVariableTable.findArgName(isStatic ? argi - : argi + 1, 0, isConstructor, isStatic); - } - if (argName != null) { - sb.append(argName); - } else { - sb.append(ByteCodeConstants.ARG); - sb.append(argi); - } - argi++; - } - /* consume the right parenthesis */ - i++; - - /* - * now parse the return type; and append it directly to the doc - */ - if (!isConstructor) { - /* constructors do not have return types */ - i = appendFieldDescriptor(descr, i, doc); - doc.append(JavaLexicalConstants.SPACE); - } - - doc.append(methodName); - doc.append(JavaLexicalConstants.LEFT_PARENTHESIS); - - /* append the arguments stored in the sb */ - doc.append(sb.toString()); - doc.append(JavaLexicalConstants.RIGHT_PARENTHESIS); - - return i; - } - - public static int appendArrayDescriptor(String descr, int offset, - Appendable doc) throws IOException { - int i = offset; - switch (descr.charAt(i++)) { - case ByteCodeConstants.ARRAY_BEGINNING_BRACKET: - int dims = 1; - while (descr.charAt(i) == ByteCodeConstants.ARRAY_BEGINNING_BRACKET) { - i++; - dims++; - } - i = appendFieldDescriptor(descr, i, doc); - for (int j = 0; j < dims; j++) { - doc.append(JavaLexicalConstants.LEFT_SQUARE_BRACKET); - doc.append(JavaLexicalConstants.RIGHT_SQUARE_BRACKET); - } - break; - default: - i--; - throw new IllegalArgumentException( - "could not parse the descriptor '" + descr - + "'. Unexpected character '" + descr.charAt(i) - + "' at the position " + i); - } - - return i; - } - - public static int appendFieldDescriptor(String descr, int offset, - Appendable doc) throws IOException { - - int i = offset; - switch (descr.charAt(i++)) { - case ByteCodeConstants.ARRAY_BEGINNING_BRACKET: - i = appendArrayDescriptor(descr, i - 1, doc); - break; - case ByteCodeConstants.L_REFERENCE: - char c; - while ((c = descr.charAt(i++)) != ByteCodeConstants.REFERENCE_TERMINATING_SEMICOLON) { - if (c == ByteCodeConstants.CLASS_NAME_SLASH) { - doc.append(JavaLexicalConstants.DOT); - } else { - doc.append(c); - } - } - break; - case ByteCodeConstants.B_BYTE: - doc.append(JavaKeywords.BYTE); - break; - case ByteCodeConstants.C_CHAR: - doc.append(JavaKeywords.CHAR); - break; - case ByteCodeConstants.D_DOUBLE: - doc.append(JavaKeywords.DOUBLE); - break; - case ByteCodeConstants.F_FLOAT: - doc.append(JavaKeywords.FLOAT); - break; - case ByteCodeConstants.I_INT: - doc.append(JavaKeywords.INT); - break; - case ByteCodeConstants.J_LONG: - doc.append(JavaKeywords.LONG); - break; - case ByteCodeConstants.S_SHORT: - doc.append(JavaKeywords.SHORT); - break; - case ByteCodeConstants.Z_BOOLEAN: - doc.append(JavaKeywords.BOOLEAN); - break; - case ByteCodeConstants.V_VOID: - doc.append(JavaKeywords.VOID); - break; - default: - i--; - throw new IllegalArgumentException( - "could not parse the descriptor '" + descr - + "'. Unexpected character '" + descr.charAt(i) - + "' at the position " + i); - } - - return i; - - } - - public static void padd(String s, int length, char ch, Appendable sb) - throws IOException { - int toPadd = length - s.length(); - while (toPadd-- > 0) { - sb.append(ch); - } - sb.append(s); - } - - /** - * Appends a quoted string to a given buffer. - * - * @param buf - * the buffer where the string must be added. - * @param s - * the string to be added. - */ - public static void appendString(final StringBuffer buf, final String s) { - buf.append(JavaLexicalConstants.QUOTE); - for (int i = 0; i < s.length(); ++i) { - char c = s.charAt(i); - if (c == '\n') { - buf.append("\\n"); - } else if (c == '\r') { - buf.append("\\r"); - } else if (c == '\\') { - buf.append("\\\\"); - } else if (c == '"') { - buf.append("\\\""); - } else if (c < 0x20 || c > 0x7f) { - buf.append("\\u"); - if (c < 0x10) { - buf.append("000"); - } else if (c < 0x100) { - buf.append("00"); - } else if (c < 0x1000) { - buf.append('0'); - } - buf.append(Integer.toString(c, 16)); - } else { - buf.append(c); - } - } - buf.append(JavaLexicalConstants.QUOTE); - } - - public static boolean isSourceOf(IResource srcFile, IClassFile classFile) { - - if (srcFile == null || classFile == null) { - return false; - } - - IResource resource = classFile.getResource(); - if(resource == null){ - return false; - } - - String classFileTypeName = toFullyQualifiedTypeName(resource); - - if (classFileTypeName == null) { - return false; - } - - String srcPath = srcFile.getFullPath().removeFileExtension().toString(); - srcPath = toJavaSrcName(srcPath); - - return srcPath.endsWith(classFileTypeName); - } - - /** - * Returns the fully qualified type name for a given {@link IResource}. - * For resources which are not included in the project's build path - * returns always null. - * - * @param classFileResource - * @return the fully qualified name as a string or null - */ - public static String toFullyQualifiedTypeName(IResource classFileResource) { - IProject project = classFileResource.getProject(); - - /* create java project */ - IJavaProject javaProject = JavaCore.create(project); - - IPath wspacePath = classFileResource.getFullPath(); - IPath outputDir = null; - - try { - outputDir = javaProject.getOutputLocation(); - } catch (JavaModelException e) { - throw new RuntimeException(e); - } - - IPath classToFind = null; - if (outputDir.matchingFirstSegments(wspacePath) == outputDir - .segmentCount()) { - /* - * if we are in the output directory strip the output directory as - * we want the project relative path - */ - classToFind = wspacePath.removeFirstSegments(outputDir - .segmentCount()); - } - - if (classToFind != null) { - classToFind = classToFind.removeFileExtension(); - String typeToFind = classToFind.toString(); - - typeToFind = toJavaSrcName(typeToFind); - - return typeToFind; - - } - return null; - } - - /** - * returns the type name of the given {@link ConstantClassInfo} - * @param constantClassInfo the {@link ConstantClassInfo} to check - * @param constantPool the associated ConstantPool - * @return type name as a string - */ - public static String resolveConstantPoolTypeName( - ConstantClassInfo constantClassInfo, - AbstractConstantPoolEntry[] constantPool) { - - return ((ConstantUtf8Info)constantPool[constantClassInfo.getNameIndex()]).getString(); - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/ConstantPoolParser.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/ConstantPoolParser.java deleted file mode 100644 index 5fbbbe3c..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/ConstantPoolParser.java +++ /dev/null @@ -1,176 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode; - -import java.io.ByteArrayInputStream; -import java.io.DataInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.List; - -import com.drgarbage.bytecode.constant_pool.AbstractConstantPoolEntry; -import com.drgarbage.bytecode.constant_pool.ConstantClassInfo; -import com.drgarbage.bytecode.constant_pool.ConstantDoubleInfo; -import com.drgarbage.bytecode.constant_pool.ConstantFieldrefInfo; -import com.drgarbage.bytecode.constant_pool.ConstantFloatInfo; -import com.drgarbage.bytecode.constant_pool.ConstantIntegerInfo; -import com.drgarbage.bytecode.constant_pool.ConstantInterfaceMethodrefInfo; -import com.drgarbage.bytecode.constant_pool.ConstantInvokeDynamicInfo; -import com.drgarbage.bytecode.constant_pool.ConstantLargeNumeric; -import com.drgarbage.bytecode.constant_pool.ConstantLongInfo; -import com.drgarbage.bytecode.constant_pool.ConstantMethodHandleInfo; -import com.drgarbage.bytecode.constant_pool.ConstantMethodTypeInfo; -import com.drgarbage.bytecode.constant_pool.ConstantMethodrefInfo; -import com.drgarbage.bytecode.constant_pool.ConstantNameAndTypeInfo; -import com.drgarbage.bytecode.constant_pool.ConstantStringInfo; -import com.drgarbage.bytecode.constant_pool.ConstantUtf8Info; -import com.drgarbage.bytecode.instructions.AbstractInstruction; - -/** - * Converts code to a list of instructions. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision: 187 $ $Id: InstructionParser.java 164 2008-01-06 - * 13:00:25Z sa $ - */ -public class ConstantPoolParser { - - /** - * The input stream - */ - private DataInputStream in; - - /** - * NUmebr of byte to read from {@link #in}. - */ - private int length; - - /** - * @param code - * a byte array containing instruction. - * @param offset - * number of bytes from the beginning of the byte-array where the - * parsing should start. - * @param length - * number of byte to parse. - */ - public ConstantPoolParser(byte[] code, int offset, int length) { - super(); - this.length = length; - InputStream tmp = new ByteArrayInputStream(code); - if (offset != 0) { - /* - * only risk that the stream does not support seek if there is - * something to skip - */ - try { - /* skip the bytes we do not want to count */ - tmp.skip(offset); - } catch (IOException e) { - /* should not happen with ByteArrayInputStream */ - throw new RuntimeException(e); - } - } - in = new DataInputStream(tmp); - } - - /** - * @param code - */ - public ConstantPoolParser(byte[] code) { - this(code, 0, code.length); - } - - /** - * Parses the underlying byte array int a {@link List} of - * {@link AbstractInstruction}s. - * - * @return the java.util.List with the instructions - */ - public AbstractConstantPoolEntry[] parse() { - AbstractConstantPoolEntry[] result = new AbstractConstantPoolEntry[length]; - - try { - for (int i = 1; i < length; i++) { - AbstractConstantPoolEntry entry; - - int int_ = in.readUnsignedByte(); - byte tag = (byte)int_; - - switch (tag) { - case ByteCodeConstants.TAG_CLASS: - entry = new ConstantClassInfo(result); - break; - case ByteCodeConstants.TAG_FIELDREF: - entry = new ConstantFieldrefInfo(result); - break; - case ByteCodeConstants.TAG_METHODREF: - entry = new ConstantMethodrefInfo(result); - break; - case ByteCodeConstants.TAG_INTERFACE_METHODREF: - entry = new ConstantInterfaceMethodrefInfo(result); - break; - case ByteCodeConstants.TAG_STRING: - entry = new ConstantStringInfo(result); - break; - case ByteCodeConstants.TAG_INTEGER: - entry = new ConstantIntegerInfo(result); - break; - case ByteCodeConstants.TAG_FLOAT: - entry = new ConstantFloatInfo(result); - break; - case ByteCodeConstants.TAG_LONG: - entry = new ConstantLongInfo(result); - break; - case ByteCodeConstants.TAG_DOUBLE: - entry = new ConstantDoubleInfo(result); - break; - case ByteCodeConstants.TAG_NAME_AND_TYPE: - entry = new ConstantNameAndTypeInfo(result); - break; - case ByteCodeConstants.TAG_UTF8: - entry = new ConstantUtf8Info(result); - break; - case ByteCodeConstants.TAG_METHOD_HANDLE: - entry = new ConstantMethodHandleInfo(result); - break; - case ByteCodeConstants.TAG_METHOD_TYPE: - entry = new ConstantMethodTypeInfo(result); - break; - case ByteCodeConstants.TAG_INVOKE_DYNAMIC: - entry = new ConstantInvokeDynamicInfo(result); - break; - default: - throw new IllegalStateException( - "Unexpected constant pool entry tag '" + tag + "'"); - } - entry.read(in); - result[i] = entry; - - if (result[i] instanceof ConstantLargeNumeric) { - /* some entries are wider */ - i++; - } - - } - } catch (IOException e) { - throw new RuntimeException(e); - } - - return result; - } -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/CountedDataInput.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/CountedDataInput.java deleted file mode 100644 index 3c8d7e17..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/CountedDataInput.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode; - -import java.io.DataInput; - -/** - * {@link DataInput} plus a getter method for retrieving - * the number of bytes that have been retrieved so far. - */ -public interface CountedDataInput extends DataInput { - - /** - Returns the number of bytes that have been retrieved so far. - @return number of bytes - */ - public int getByteCount(); - -} \ No newline at end of file diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/CountedDataInputStream.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/CountedDataInputStream.java deleted file mode 100644 index d8d20067..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/CountedDataInputStream.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode; - -import java.io.DataInputStream; -import java.io.FilterInputStream; -import java.io.IOException; -import java.io.InputStream; - - -/** - * A {@link DataInputStream} implementing {@link CountedDataInput}. - * - */ -public class CountedDataInputStream extends DataInputStream - implements CountedDataInput -{ - - /** - * InputStream which counts the number of bytes read. - * - * @version $Revision: 187 $ - * $Id: CountedDataInputStream.java 187 2013-06-03 05:47:37Z salekseev $ - */ - static class CountedInputStream extends FilterInputStream { - - private int byteCount = 0; - - /** - Constructor. - @param in the input stream. - */ - public CountedInputStream(InputStream in) { - super(in); - } - - public int read() throws IOException { - int b = in.read(); - byteCount++; - return b; - } - - public int read(byte[] b) throws IOException { - return read(b, 0, b.length); - } - - public int read(byte[] b, int offset, int len) throws IOException { - int readCount = in.read(b, 0, b.length); - byteCount += readCount; - return readCount; - - } - - public long skip(long n) throws IOException { - long skipCount = in.skip(n); - byteCount += (int)skipCount; - return skipCount; - } - - // Marking invalidates byteCount - public boolean markSupported() { - return false; - } - - /** - Get the number of bytes read. - @return the number of bytes - */ - public int getByteCount() { - return byteCount; - } - } - - /** - A constructor. - @param in an {@link InputStream} to read from. - */ - public CountedDataInputStream(InputStream in) { - super(new CountedInputStream(in)); - } - - /* (non-Javadoc) - * @see com.drgarbage.bytecode.InstructionParser.CountedInput#getByteCount() - */ - public int getByteCount() { - return ((CountedInputStream)in).getByteCount(); - } - -} \ No newline at end of file diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/CountedOutput.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/CountedOutput.java deleted file mode 100644 index 49f3ca1c..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/CountedOutput.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode; - -import java.io.DataOutput; - -/** - * {@link DataOutput} plus a getter method for retrieving - * the number of bytes that have been retrieved so far. - * - */ -public interface CountedOutput extends DataOutput { - - /** - Returns the number of bytes that have been written so far. - @return the number of bytes - */ - public int getByteCount(); - -} \ No newline at end of file diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/CountedOutputStream.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/CountedOutputStream.java deleted file mode 100644 index f1486817..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/CountedOutputStream.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode; - -import java.io.FilterOutputStream; -import java.io.IOException; -import java.io.OutputStream; - -/** - * OutputStream which counts the number of bytes written. - * - */ -public class CountedOutputStream extends FilterOutputStream { - - private int byteCount = 0; - - /** - * Constructor. - * - * @param out the output stream. - */ - public CountedOutputStream(OutputStream out) { - super(out); - } - - public void write(int b) throws IOException { - out.write(b); - byteCount++; - } - - /** - * Get the number of bytes written. - * - * @return the number of bytes - */ - public int getByteCount() { - return byteCount; - } -} \ No newline at end of file diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/ExceptionTableEntry.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/ExceptionTableEntry.java deleted file mode 100644 index 1056588e..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/ExceptionTableEntry.java +++ /dev/null @@ -1,157 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; - -/** - * Describes an exception table entry in a Code attribute structure. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision: 187 $ - * $Id: ExceptionTableEntry.java 187 2013-06-03 05:47:37Z salekseev $ - */ -public class ExceptionTableEntry { - - /** - * Length in bytes of an exception table entry. - */ - public static final int LENGTH = 8; - - private int startPc; - private int endPc; - private int handlerPc; - private int catchType; - - /** - * Constructor. - */ - public ExceptionTableEntry() { - } - - /** - * Constructor. - * - * @param startPc the start_pc - * @param endPc the end_pc - * @param handlerPc the handler_pc - * @param catchType the constant pool index for the catch type of this exception table entry - */ - public ExceptionTableEntry(int startPc, int endPc, int handlerPc, int catchType) { - this.startPc = startPc; - this.endPc = endPc; - this.handlerPc = handlerPc; - this.catchType = catchType; - } - - /** - * Get the start_pc of this exception table entry. - * - * @return the start_pc - */ - public int getStartPc() { - return startPc; - } - - /** - * Set the start_pc of this exception table entry. - * - * @param startPc the start_pc - */ - public void setStartPc(int startPc) { - this.startPc = startPc; - } - - /** - * Get the end_pc of this exception table entry. - * - * @return the end_pc - */ - public int getEndPc() { - return endPc; - } - - /** - * Set the end_pc of this exception table entry. - * - * @param endPc the end_pc - */ - public void setEndPc(int endPc) { - this.endPc = endPc; - } - - /** - * Get the handler_pc of this exception table entry. - * - * @return the handler_pc - */ - public int getHandlerPc() { - return handlerPc; - } - - /** - * Set the handler_pc of this exception table entry. - * - * @param handlerPc the handler_pc - */ - public void setHandlerPc(int handlerPc) { - this.handlerPc = handlerPc; - } - - /** - * Get the constant pool index for the catch type of this exception table entry. - * - * @return the index - */ - public int getCatchType() { - return catchType; - } - - /** - * Set the constant pool index for the catch type of this exception table entry. - * - * @param catchType the index - */ - public void setCatchType(int catchType) { - this.catchType = catchType; - } - - public void read(DataInput in) throws IOException { - - startPc = in.readUnsignedShort(); - endPc = in.readUnsignedShort(); - handlerPc = in.readUnsignedShort(); - catchType = in.readUnsignedShort(); - } - - public void write(DataOutput out) throws IOException { - - out.writeShort(startPc); - out.writeShort(endPc); - out.writeShort(handlerPc); - out.writeShort(catchType); - } - - protected String printAccessFlagsVerbose(int accessFlags) { - if (accessFlags != 0) - throw new RuntimeException("Access flags should be zero: " + Integer.toHexString(accessFlags)); - return ""; - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/InstructionParser.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/InstructionParser.java deleted file mode 100644 index 671e7d1c..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/InstructionParser.java +++ /dev/null @@ -1,618 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.drgarbage.bytecode.constant_pool.AbstractConstantPoolEntry; -import com.drgarbage.bytecode.constant_pool.ConstantUtf8Info; -import com.drgarbage.bytecode.instructions.AbstractInstruction; -import com.drgarbage.bytecode.instructions.BranchInstruction; -import com.drgarbage.bytecode.instructions.BranchWInstruction; -import com.drgarbage.bytecode.instructions.ConstantPoolByteIndexInstruction; -import com.drgarbage.bytecode.instructions.ConstantPoolShortIndexInstruction; -import com.drgarbage.bytecode.instructions.ImmediateByteInstruction; -import com.drgarbage.bytecode.instructions.ImmediateShortInstruction; -import com.drgarbage.bytecode.instructions.IncrementInstruction; -import com.drgarbage.bytecode.instructions.InvokeInterfaceInstruction; -import com.drgarbage.bytecode.instructions.LookupSwitchInstruction; -import com.drgarbage.bytecode.instructions.MultianewarrayInstruction; -import com.drgarbage.bytecode.instructions.NewArrayInstruction; -import com.drgarbage.bytecode.instructions.Opcodes; -import com.drgarbage.bytecode.instructions.RetInstruction; -import com.drgarbage.bytecode.instructions.SimpleInstruction; -import com.drgarbage.bytecode.instructions.TableSwitchInstruction; -import com.drgarbage.bytecode.instructions.XLoadStoreNInstruction.XLoadInstruction; -import com.drgarbage.bytecode.instructions.XLoadStoreNInstruction.XLoadNInstruction; -import com.drgarbage.bytecode.instructions.XLoadStoreNInstruction.XStoreInstruction; -import com.drgarbage.bytecode.instructions.XLoadStoreNInstruction.XStoreNInstruction; - -/** - * Converts code to a list of instructions. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision: 187 $ - * $Id: InstructionParser.java 187 2013-06-03 05:47:37Z salekseev $ - */ -public class InstructionParser implements Opcodes { - - /** - * The input stream - */ - private CountedDataInputStream in; - - /** - * NUmebr of byte to read from {@link #in}. - */ - private int length; - private int offset; - - private byte[] code; - - /** - * @param code a byte array containing instruction. - * @param offset number of bytes from the beginning of the byte-array where the parsing should start. - * @param length number of byte to parse. - */ - public InstructionParser(byte[] code, int offset, int length) { - super(); - this.length = length; - this.code = code; - this.offset = offset; - InputStream tmp = new ByteArrayInputStream(code); - if (offset != 0) { - /* only risk that the stream does not support seek if there is something to skip */ - try { - /* skip the bytes we do not want to count */ - tmp.skip(offset); - } catch (IOException e) { - /* should not happen with ByteArrayInputStream */ - throw new RuntimeException(e); - } - } - in = new CountedDataInputStream(tmp); - } - - /** - * @param code - */ - public InstructionParser(byte[] code) { - this(code, 0, code.length); - } - - public Map parseAttributes(Set attributeNames, AbstractConstantPoolEntry[] constantPool) { - HashMap result = new HashMap(); - if (in.getByteCount() < code.length - offset) { - /* there is still something to read in the code array */ - try { - int attrCount = in.readUnsignedShort(); - int attrsRead = 0; - for (int i = 0; i < attrCount; i++) { - - int nameIndex = in.readUnsignedShort(); - String attrName = ((ConstantUtf8Info)constantPool[nameIndex]).getString(); - int attrLen = in.readInt(); - if (attributeNames.contains(attrName)) { - /* read */ - if (attrName.equals(ByteCodeConstants.LINE_NUMBER_TABLE)) { - result.put(attrName, parseLineNumberTable(constantPool)); - } - else if (attrName.equals(ByteCodeConstants.LOCAL_VARIABLE_TABLE)) { - //FIXME there may be more than one LocalVariableTable; return them all rather than merging them - result.put(attrName, parseLocalVariableTable(constantPool, (LocalVariableTableEntry[]) result.get(attrName))); - } - else if (attrName.equals(ByteCodeConstants.LOCAL_VARIABLE_TYPE_TABLE)) { - result.put(attrName, parseLocalVariableTypeTable(constantPool)); - } - - attrsRead++; - if (attrsRead == attributeNames.size()) { - /* we have read everything we wanted skip other attributes */ - break; - } - } - else { - /* skip */ - in.skipBytes(attrLen); - } - - - } - } catch (IOException e) { - throw new RuntimeException(e); - } - } - return result; - } - - private LocalVariableTableEntry[] parseLocalVariableTable(AbstractConstantPoolEntry[] constantPool, LocalVariableTableEntry[] result) throws IOException { - if (in.getByteCount() < code.length - offset) { - int len = in.readUnsignedShort(); - int j = 0; - if (result == null) { - result = new LocalVariableTableEntry[len]; - } - else { - /* allocate more space for the table */ - LocalVariableTableEntry[] newResult = new LocalVariableTableEntry[len + result.length]; - System.arraycopy(result, 0, newResult, 0, result.length); - j = result.length; - result = newResult; - } - for (; j < len; j++) { - LocalVariableTableEntry en = new LocalVariableTableEntry(); - en.read(in); - result[j] = en; - } - } - return result; - } - private Object parseLocalVariableTypeTable(AbstractConstantPoolEntry[] constantPool) throws IOException { - if (in.getByteCount() < code.length - offset) { - int len = in.readUnsignedShort(); - LocalVariableTypeTableEntry[] result = new LocalVariableTypeTableEntry[len]; - for (int j = 0; j < len; j++) { - LocalVariableTypeTableEntry en = new LocalVariableTypeTableEntry(); - en.read(in); - result[j] = en; - } - return result; - } - else { - return new LocalVariableTypeTableEntry[0]; - } - } - - private LineNumberTableEntry[] parseLineNumberTable(AbstractConstantPoolEntry[] constantPool) throws IOException { - if (in.getByteCount() < code.length - offset) { - int len = in.readUnsignedShort(); - LineNumberTableEntry[] result = new LineNumberTableEntry[len]; - for (int j = 0; j < len; j++) { - LineNumberTableEntry en = new LineNumberTableEntry(); - en.read(in); - result[j] = en; - } - return result; - } - else { - return new LineNumberTableEntry[0]; - } - } - - public ExceptionTableEntry[] parseExceptionTable() { - ExceptionTableEntry[] result = null; - if (in.getByteCount() < code.length - offset) { - /* only if there is something to read */ - try { - int len = in.readUnsignedShort(); - result = new ExceptionTableEntry[len]; - for (int i = 0; i < len; i++) { - ExceptionTableEntry en = new ExceptionTableEntry(); - en.read(in); - result[i] = en; - } - } catch (IOException e) { - throw new RuntimeException(e); - } - } - return result; - } - - - /** - Parses the underlying byte array int a {@link List} of {@link AbstractInstruction}s. - @return the java.util.List with the instructions - */ - public List parse() { - - List instructions = new LinkedList(); - - boolean wide = false; - AbstractInstruction currentInstruction; - try { - while (in.getByteCount() < length) { - currentInstruction = parseNextInstruction(wide); - wide = (currentInstruction.getOpcode() == OPCODE_WIDE); - instructions.add(currentInstruction); - } - } catch (IOException e) { - /* should not happen with ByteArrayInputStream */ - throw new RuntimeException(e); - } - - return instructions; - } - - protected AbstractInstruction parseNextInstruction(boolean wide) - throws IOException { - - AbstractInstruction instruction; - - int opcode = in.readUnsignedByte(); - - switch (opcode) { - - case OPCODE_NOP: - case OPCODE_ACONST_NULL: - case OPCODE_ICONST_M1: - case OPCODE_ICONST_0: - case OPCODE_ICONST_1: - case OPCODE_ICONST_2: - case OPCODE_ICONST_3: - case OPCODE_ICONST_4: - case OPCODE_ICONST_5: - case OPCODE_LCONST_0: - case OPCODE_LCONST_1: - case OPCODE_FCONST_0: - case OPCODE_FCONST_1: - case OPCODE_FCONST_2: - case OPCODE_DCONST_0: - case OPCODE_DCONST_1: - - case OPCODE_IALOAD: - case OPCODE_LALOAD: - case OPCODE_FALOAD: - case OPCODE_DALOAD: - case OPCODE_AALOAD: - case OPCODE_BALOAD: - case OPCODE_CALOAD: - case OPCODE_SALOAD: - - - case OPCODE_IASTORE: - case OPCODE_LASTORE: - case OPCODE_FASTORE: - case OPCODE_DASTORE: - case OPCODE_AASTORE: - case OPCODE_BASTORE: - case OPCODE_CASTORE: - case OPCODE_SASTORE: - case OPCODE_POP: - case OPCODE_POP2: - case OPCODE_DUP: - case OPCODE_DUP_X1: - case OPCODE_DUP_X2: - case OPCODE_DUP2: - case OPCODE_DUP2_X1: - case OPCODE_DUP2_X2: - case OPCODE_SWAP: - case OPCODE_IADD: - case OPCODE_LADD: - case OPCODE_FADD: - case OPCODE_DADD: - case OPCODE_ISUB: - case OPCODE_LSUB: - case OPCODE_FSUB: - case OPCODE_DSUB: - case OPCODE_IMUL: - case OPCODE_LMUL: - case OPCODE_FMUL: - case OPCODE_DMUL: - case OPCODE_IDIV: - case OPCODE_LDIV: - case OPCODE_FDIV: - case OPCODE_DDIV: - case OPCODE_IREM: - case OPCODE_LREM: - case OPCODE_FREM: - case OPCODE_DREM: - case OPCODE_INEG: - case OPCODE_LNEG: - case OPCODE_FNEG: - case OPCODE_DNEG: - case OPCODE_ISHL: - case OPCODE_LSHL: - case OPCODE_ISHR: - case OPCODE_LSHR: - case OPCODE_IUSHR: - case OPCODE_LUSHR: - case OPCODE_IAND: - case OPCODE_LAND: - case OPCODE_IOR: - case OPCODE_LOR: - case OPCODE_IXOR: - case OPCODE_LXOR: - case OPCODE_I2L: - case OPCODE_I2F: - case OPCODE_I2D: - case OPCODE_L2I: - case OPCODE_L2F: - case OPCODE_L2D: - case OPCODE_F2I: - case OPCODE_F2L: - case OPCODE_F2D: - case OPCODE_D2I: - case OPCODE_D2L: - case OPCODE_D2F: - case OPCODE_I2B: - case OPCODE_I2C: - case OPCODE_I2S: - case OPCODE_LCMP: - case OPCODE_FCMPL: - case OPCODE_FCMPG: - case OPCODE_DCMPL: - case OPCODE_DCMPG: - case OPCODE_IRETURN: - case OPCODE_LRETURN: - case OPCODE_FRETURN: - case OPCODE_DRETURN: - case OPCODE_ARETURN: - case OPCODE_RETURN: -// case OPCODE_XXXUNUSEDXXX: - case OPCODE_ARRAYLENGTH: - case OPCODE_ATHROW: - case OPCODE_MONITORENTER: - case OPCODE_MONITOREXIT: - case OPCODE_BREAKPOINT: - case OPCODE_IMPDEP1: - case OPCODE_IMPDEP2: - case OPCODE_WIDE: - - instruction = new SimpleInstruction(opcode); - break; - - case OPCODE_LDC: - instruction = new ConstantPoolByteIndexInstruction(opcode, wide); - break; - case OPCODE_LDC_W: - case OPCODE_LDC2_W: - instruction = new ConstantPoolShortIndexInstruction(opcode); - break; - - - /* load local variable */ - case OPCODE_ILOAD: // subject to wide - case OPCODE_LLOAD: // subject to wide - case OPCODE_FLOAD: // subject to wide - case OPCODE_DLOAD: // subject to wide - case OPCODE_ALOAD: // subject to wide - instruction = new XLoadInstruction(opcode, wide); - break; - case OPCODE_ILOAD_0: - instruction = new XLoadNInstruction(opcode, 0); - break; - case OPCODE_ILOAD_1: - instruction = new XLoadNInstruction(opcode, 1); - break; - case OPCODE_ILOAD_2: - instruction = new XLoadNInstruction(opcode, 2); - break; - case OPCODE_ILOAD_3: - instruction = new XLoadNInstruction(opcode, 3); - break; - case OPCODE_LLOAD_0: - instruction = new XLoadNInstruction(opcode, 0); - break; - case OPCODE_LLOAD_1: - instruction = new XLoadNInstruction(opcode, 1); - break; - case OPCODE_LLOAD_2: - instruction = new XLoadNInstruction(opcode, 2); - break; - case OPCODE_LLOAD_3: - instruction = new XLoadNInstruction(opcode, 3); - break; - case OPCODE_FLOAD_0: - instruction = new XLoadNInstruction(opcode, 0); - break; - case OPCODE_FLOAD_1: - instruction = new XLoadNInstruction(opcode, 1); - break; - case OPCODE_FLOAD_2: - instruction = new XLoadNInstruction(opcode, 2); - break; - case OPCODE_FLOAD_3: - instruction = new XLoadNInstruction(opcode, 3); - break; - case OPCODE_DLOAD_0: - instruction = new XLoadNInstruction(opcode, 0); - break; - case OPCODE_DLOAD_1: - instruction = new XLoadNInstruction(opcode, 1); - break; - case OPCODE_DLOAD_2: - instruction = new XLoadNInstruction(opcode, 2); - break; - case OPCODE_DLOAD_3: - instruction = new XLoadNInstruction(opcode, 3); - break; - case OPCODE_ALOAD_0: - instruction = new XLoadNInstruction(opcode, 0); - break; - case OPCODE_ALOAD_1: - instruction = new XLoadNInstruction(opcode, 1); - break; - case OPCODE_ALOAD_2: - instruction = new XLoadNInstruction(opcode, 2); - break; - case OPCODE_ALOAD_3: - instruction = new XLoadNInstruction(opcode, 3); - break; - - /* store into local variable */ - case OPCODE_ISTORE: // subject to wide - case OPCODE_LSTORE: // subject to wide - case OPCODE_FSTORE: // subject to wide - case OPCODE_DSTORE: // subject to wide - case OPCODE_ASTORE: // subject to wide - instruction = new XStoreInstruction(opcode, wide); - break; - case OPCODE_ISTORE_0: - instruction = new XStoreNInstruction(opcode, 0); - break; - case OPCODE_ISTORE_1: - instruction = new XStoreNInstruction(opcode, 1); - break; - case OPCODE_ISTORE_2: - instruction = new XStoreNInstruction(opcode, 2); - break; - case OPCODE_ISTORE_3: - instruction = new XStoreNInstruction(opcode, 3); - break; - case OPCODE_LSTORE_0: - instruction = new XStoreNInstruction(opcode, 0); - break; - case OPCODE_LSTORE_1: - instruction = new XStoreNInstruction(opcode, 1); - break; - case OPCODE_LSTORE_2: - instruction = new XStoreNInstruction(opcode, 2); - break; - case OPCODE_LSTORE_3: - instruction = new XStoreNInstruction(opcode, 3); - break; - case OPCODE_FSTORE_0: - instruction = new XStoreNInstruction(opcode, 0); - break; - case OPCODE_FSTORE_1: - instruction = new XStoreNInstruction(opcode, 1); - break; - case OPCODE_FSTORE_2: - instruction = new XStoreNInstruction(opcode, 2); - break; - case OPCODE_FSTORE_3: - instruction = new XStoreNInstruction(opcode, 3); - break; - case OPCODE_DSTORE_0: - instruction = new XStoreNInstruction(opcode, 0); - break; - case OPCODE_DSTORE_1: - instruction = new XStoreNInstruction(opcode, 1); - break; - case OPCODE_DSTORE_2: - instruction = new XStoreNInstruction(opcode, 2); - break; - case OPCODE_DSTORE_3: - instruction = new XStoreNInstruction(opcode, 3); - break; - case OPCODE_ASTORE_0: - instruction = new XStoreNInstruction(opcode, 0); - break; - case OPCODE_ASTORE_1: - instruction = new XStoreNInstruction(opcode, 1); - break; - case OPCODE_ASTORE_2: - instruction = new XStoreNInstruction(opcode, 2); - break; - case OPCODE_ASTORE_3: - instruction = new XStoreNInstruction(opcode, 3); - break; - - case OPCODE_RET: // subject to wide - instruction = new RetInstruction(opcode, wide); - break; - - case OPCODE_BIPUSH: - instruction = new ImmediateByteInstruction(opcode, wide); - break; - - case OPCODE_GETSTATIC: - case OPCODE_PUTSTATIC: - case OPCODE_GETFIELD: - case OPCODE_PUTFIELD: - case OPCODE_INVOKEVIRTUAL: - case OPCODE_INVOKESPECIAL: - case OPCODE_INVOKESTATIC: - case OPCODE_INVOKEDYNAMIC: - case OPCODE_NEW: - case OPCODE_ANEWARRAY: - case OPCODE_CHECKCAST: - case OPCODE_INSTANCEOF: - instruction = new ConstantPoolShortIndexInstruction(opcode); - break; - - case OPCODE_NEWARRAY: - instruction = new NewArrayInstruction(opcode, wide); - break; - - - - case OPCODE_SIPUSH: // the only immediate short instruction that does - // not have an immediate constant pool reference - - instruction = new ImmediateShortInstruction(opcode); - break; - - case OPCODE_IFEQ: - case OPCODE_IFNE: - case OPCODE_IFLT: - case OPCODE_IFGE: - case OPCODE_IFGT: - case OPCODE_IFLE: - case OPCODE_IF_ICMPEQ: - case OPCODE_IF_ICMPNE: - case OPCODE_IF_ICMPLT: - case OPCODE_IF_ICMPGE: - case OPCODE_IF_ICMPGT: - case OPCODE_IF_ICMPLE: - case OPCODE_IF_ACMPEQ: - case OPCODE_IF_ACMPNE: - case OPCODE_GOTO: - case OPCODE_JSR: - case OPCODE_IFNULL: - case OPCODE_IFNONNULL: - - instruction = new BranchInstruction(opcode); - break; - - case OPCODE_GOTO_W: - case OPCODE_JSR_W: - - instruction = new BranchWInstruction(opcode); - break; - - case OPCODE_IINC: // subject to wide - - instruction = new IncrementInstruction(opcode, wide); - break; - - case OPCODE_TABLESWITCH: - - instruction = new TableSwitchInstruction(opcode); - break; - - case OPCODE_LOOKUPSWITCH: - - instruction = new LookupSwitchInstruction(opcode); - break; - - case OPCODE_INVOKEINTERFACE: - - instruction = new InvokeInterfaceInstruction(opcode); - break; - - case OPCODE_MULTIANEWARRAY: - - instruction = new MultianewarrayInstruction(opcode); - break; - - default: - throw new IOException("invalid opcode 0x" + Integer.toHexString(opcode)); - } - - instruction.read(in); - return instruction; - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/LineNumberTableEntry.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/LineNumberTableEntry.java deleted file mode 100644 index 909d5381..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/LineNumberTableEntry.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; - -/** - * Describes an entry in a LineNumberTable attribute structure. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision: 187 $ - * $Id: LineNumberTableEntry.java 187 2013-06-03 05:47:37Z salekseev $ - */ -public class LineNumberTableEntry { - - /** - * Length in bytes of a line number association. - */ - public static final int LENGTH = 4; - - private int startPc; - private int lineNumber; - - /** - * Get the start_pc of this line number association. - * - * @return the start_pc - */ - public int getStartPc() { - return startPc; - } - - /** - * Set the start_pc of this line number association. - * - * @param startPc the start_pc - */ - public void setStartPc(int startPc) { - this.startPc = startPc; - } - - /** - * Get the line number of this line number association. - * - * @return the line number - */ - public int getLineNumber() { - return lineNumber; - } - - /** - * Set the line number of this line number association. - * - * @param lineNumber the line number - */ - public void setLineNumber(int lineNumber) { - this.lineNumber = lineNumber; - } - - public void read(DataInput in) throws IOException { - - startPc = in.readUnsignedShort(); - lineNumber = in.readUnsignedShort(); - } - - public void write(DataOutput out) throws IOException { - - out.writeShort(startPc); - out.writeShort(lineNumber); - } - - protected String printAccessFlagsVerbose(int accessFlags) { - if (accessFlags != 0) - throw new RuntimeException("Access flags should be zero: " + Integer.toHexString(accessFlags)); - return ""; - } - - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/LocalVariableCommonEntry.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/LocalVariableCommonEntry.java deleted file mode 100644 index 5c907cbd..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/LocalVariableCommonEntry.java +++ /dev/null @@ -1,162 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; - -/** - * Contains common attributes to a local variable table entry structure. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision: 187 $ - * $Id: LocalVariableCommonEntry.java 187 2013-06-03 05:47:37Z salekseev $ - */ -public abstract class LocalVariableCommonEntry { - - /** - * Length in bytes of a local variable association. - */ - public static final int LENGTH = 10; - - protected int startPc; - protected int length; - protected int nameIndex; - protected int descriptorOrSignatureIndex; - protected int index; - - /** - * Get the start_pc of this local variable association. - * - * @return the start_pc - */ - final public int getStartPc() { - return startPc; - } - - /** - * Set the start_pc of this local variable association. - * - * @param startPc the start_pc - */ - final public void setStartPc(int startPc) { - this.startPc = startPc; - } - - /** - * Get the length in bytes of this local variable association. - * - * @return the length - */ - final public int getLength() { - return length; - } - - /** - * Set the length in bytes of this local variable association. - * - * @param length the length - */ - final public void setLength(int length) { - this.length = length; - } - - /** - * Get the index of the constant pool entry containing the name of this - * local variable. - * - * @return the index - */ - final public int getNameIndex() { - return nameIndex; - } - - /** - * Set the index of the constant pool entry containing the name of this - * local variable. - * - * @param nameIndex the index - */ - final public void setNameIndex(int nameIndex) { - this.nameIndex = nameIndex; - } - - /** - * Get the index of the constant pool entry containing the descriptor of this - * local variable. - * - * @return the index - */ - final public int getDescriptorOrSignatureIndex() { - return descriptorOrSignatureIndex; - } - - /** - * Get the index of the constant pool entry containing the descriptor of this - * local variable. - * - * @param descriptorIndex the index - */ - final public void setDescriptorOrSignatureIndex(int descriptorIndex) { - this.descriptorOrSignatureIndex = descriptorIndex; - } - - /** - * Get the index of this local variable. - * - * @return the index - */ - final public int getIndex() { - return index; - } - - /** - * Set the index of this local variable. - * Set the index of this local variable. - */ - final public void setIndex(int index) { - this.index = index; - } - - final public void read(DataInput in) throws IOException { - - startPc = in.readUnsignedShort(); - length = in.readUnsignedShort(); - nameIndex = in.readUnsignedShort(); - descriptorOrSignatureIndex = in.readUnsignedShort(); - index = in.readUnsignedShort(); - - } - - final public void write(DataOutput out) throws IOException { - - out.writeShort(startPc); - out.writeShort(length); - out.writeShort(nameIndex); - out.writeShort(descriptorOrSignatureIndex); - out.writeShort(index); - - } - - protected String printAccessFlagsVerbose(int accessFlags) { - if (accessFlags != 0) - throw new RuntimeException("Access flags should be zero: " + - Integer.toHexString(accessFlags)); - return ""; - } -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/LocalVariableTableEntry.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/LocalVariableTableEntry.java deleted file mode 100644 index 89d03ac6..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/LocalVariableTableEntry.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode; - -/** - * Describes an entry in a LocalVariableTableEntry attribute structure. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision: 187 $ - * $Id: LocalVariableTableEntry.java 187 2013-06-03 05:47:37Z salekseev $ - */ -public class LocalVariableTableEntry extends LocalVariableCommonEntry { - - - /** - * Get the index of the constant pool entry containing the descriptor of this - * local variable. - * - * @return the index - */ - public int getDescriptorIndex() { - return descriptorOrSignatureIndex; - } - - /** - * Get the index of the constant pool entry containing the descriptor of this - * local variable. - * - * @param descriptorIndex the index - */ - public void setDescriptorIndex(int descriptorIndex) { - setDescriptorOrSignatureIndex(descriptorIndex); - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/LocalVariableTableParser.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/LocalVariableTableParser.java deleted file mode 100644 index ebd2173c..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/LocalVariableTableParser.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.List; - -import com.drgarbage.bytecode.instructions.AbstractInstruction; - -/** - * Converts code to a list of instructions. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision: 187 $ $Id: InstructionParser.java 164 2008-01-06 - * 13:00:25Z sa $ - */ -public class LocalVariableTableParser { - - /** - * The input stream - */ - private CountedDataInputStream in; - - /** - * NUmebr of byte to read from {@link #in}. - */ - private int length; - - /** - * @param code - * a byte array containing instruction. - * @param offset - * number of bytes from the beginning of the byte-array where the - * parsing should start. - * @param length - * number of byte to parse. - */ - public LocalVariableTableParser(byte[] code, int offset, int length) { - super(); - this.length = length; - InputStream tmp = new ByteArrayInputStream(code); - if (offset != 0) { - /* - * only risk that the stream does not support seek if there is - * something to skip - */ - try { - /* skip the bytes we do not want to count */ - tmp.skip(offset); - } catch (IOException e) { - /* should not happen with ByteArrayInputStream */ - throw new RuntimeException(e); - } - } - in = new CountedDataInputStream(tmp); - } - - /** - * @param code - */ - public LocalVariableTableParser(byte[] code) { - this(code, 0, code.length); - } - - /** - * Parses the underlying byte array int a {@link List} of - * {@link AbstractInstruction}s. - * - * @return the java.util.List with the instructions - */ - public LocalVariableTableEntry[] parse() { - LocalVariableTableEntry[] result = new LocalVariableTableEntry[length]; - - try { - for (int i = 0; i < length; i++) { - LocalVariableTableEntry entry = new LocalVariableTableEntry(); - entry.read(in); - result[i] = entry; - } - } catch (IOException e) { - throw new RuntimeException(e); - } - - return result; - } -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/LocalVariableTypeTableEntry.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/LocalVariableTypeTableEntry.java deleted file mode 100644 index b612f9b9..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/LocalVariableTypeTableEntry.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode; - -/** - * Describes an LocalVariableTypeTableEntry attribute structure. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision: 187 $ - * $Id: LocalVariableTypeTableEntry.java 187 2013-06-03 05:47:37Z salekseev $ - */ -public class LocalVariableTypeTableEntry extends LocalVariableCommonEntry { - - /** - * Get the index of the constant pool entry containing the signature of - * this local variable. - * - * @return the index - */ - public int getSignatureIndex() { - return descriptorOrSignatureIndex; - } - - /** - * Get the index of the constant pool entry containing the signature of - * this local variable. - * - * @param signatureIndex the index - */ - public void setSignatureIndex(int signatureIndex) { - this.descriptorOrSignatureIndex = signatureIndex; - } -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/AbstractConstantPoolEntry.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/AbstractConstantPoolEntry.java deleted file mode 100644 index 657c59e6..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/AbstractConstantPoolEntry.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package com.drgarbage.bytecode.constant_pool; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; - -import com.drgarbage.bytecode.ByteCodeConstants; - - -/** - * Base class for all constant pool entries in the constants package. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision:395 $ - * $Id:AbstractConstantPoolEntry.java 395 2008-04-03 15:08:14Z Peter Palaga $ - */ -public abstract class AbstractConstantPoolEntry implements ConstantPoolTags { - - protected AbstractConstantPoolEntry[] constantPool; - protected byte tag; - - public AbstractConstantPoolEntry(byte tag, AbstractConstantPoolEntry[] constantPool) { - super(); - this.constantPool = constantPool; - this.tag = tag; - } - - /** - * Get the value of the tag field of the cp_info structure. - * - * @return the tag - */ - public final byte getTag() { - return tag; - } - - /** - * Gets the tag field's mnemonics - * - * @return tag mnemonics - * - * @see ByteCodeConstants#CONSTANT_POOL_TAG_MNEMONICS - */ - public final String getTagMnemonics() { - return ByteCodeConstants.CONSTANT_POOL_TAG_MNEMONICS[tag]; - } - - - public boolean equals(Object object) { - return object instanceof AbstractConstantPoolEntry; - } - - public int hashCode() { - return 0; - } - - public abstract void read(DataInput in) throws IOException; - public abstract void write(DataOutput out) throws IOException; - - public abstract String getInfo(); - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantClassInfo.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantClassInfo.java deleted file mode 100644 index 5a4b58f8..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantClassInfo.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode.constant_pool; - -import com.drgarbage.bytecode.ByteCodeConstants; -import com.drgarbage.javasrc.JavaLexicalConstants; - -import java.io.*; - -/** - * Describes a CONSTANT_Class_info constant pool data structure. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision:395 $ - * $Id:ConstantClassInfo.java 395 2008-04-03 15:08:14Z Peter Palaga $ - */ -public class ConstantClassInfo extends AbstractConstantPoolEntry { - - public ConstantClassInfo(AbstractConstantPoolEntry[] constantPool) { - super(CONSTANT_CLASS, constantPool); - } - - /** Length of the constant pool data structure in bytes. */ - public static final int SIZE = 2; - - private int nameIndex; - - /** - Get the index of the constant pool entry containing the name of the class. - @return the index - */ - public int getNameIndex() { - return nameIndex; - } - - /** - Set the index of the constant pool entry containing the name of the class. - @param nameIndex the index - */ - public void setNameIndex(int nameIndex) { - this.nameIndex = nameIndex; - } - - /** - Get the name of the class. - @return name of the class - */ - public String getName() { - return ((ConstantUtf8Info)constantPool[nameIndex]).getString(); - } - - public void read(DataInput in) throws IOException { - - nameIndex = in.readUnsignedShort(); - } - - public void write(DataOutput out) throws IOException { - - out.writeByte(ByteCodeConstants.TAG_CLASS); - out.writeShort(nameIndex); - } - - public boolean equals(Object object) { - if (!(object instanceof ConstantClassInfo)) { - return false; - } - ConstantClassInfo constantClassInfo = (ConstantClassInfo)object; - return super.equals(object) && constantClassInfo.nameIndex == nameIndex; - } - - public int hashCode() { - return super.hashCode() ^ nameIndex; - } - - @Override - public String getInfo() { - return ByteCodeConstants.NAME_INDEX + JavaLexicalConstants.EQUALS + String.valueOf(nameIndex); - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantDoubleInfo.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantDoubleInfo.java deleted file mode 100644 index 2216c43d..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantDoubleInfo.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode.constant_pool; - -import com.drgarbage.bytecode.ByteCodeConstants; -import com.drgarbage.javasrc.JavaLexicalConstants; - -import java.io.*; - -/** - * Describes a CONSTANT_Double_info constant pool data structure. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision:395 $ - * $Id:ConstantDoubleInfo.java 395 2008-04-03 15:08:14Z Peter Palaga $ - */ -public class ConstantDoubleInfo extends ConstantLargeNumeric { - - public ConstantDoubleInfo(AbstractConstantPoolEntry[] constantPool) { - super(CONSTANT_DOUBLE, constantPool); - } - - /** - Get the double value of this constant pool entry. - @return the value - */ - public double getDouble() { - long longBits = (long)highBytes << 32 | (long)lowBytes & 0xFFFFFFFFL; - return Double.longBitsToDouble(longBits); - } - - /** - Set the double value of this constant pool entry. - @param number the value - */ - public void setDouble(double number) { - long longBits = Double.doubleToLongBits(number); - highBytes = (int)(longBits >>> 32 & 0xFFFFFFFFL); - lowBytes = (int)(longBits & 0xFFFFFFFFL); - } - - public void read(DataInput in) throws IOException { - - super.read(in); - } - - public void write(DataOutput out) throws IOException { - - out.writeByte(ByteCodeConstants.TAG_DOUBLE); - super.write(out); - } - - @Override - public String getInfo() { - return ByteCodeConstants.bytes + JavaLexicalConstants.EQUALS + String.valueOf(getDouble()); - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantFieldrefInfo.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantFieldrefInfo.java deleted file mode 100644 index 32ea55d5..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantFieldrefInfo.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode.constant_pool; - -import com.drgarbage.bytecode.ByteCodeConstants; - -import java.io.*; - -/** - * Describes a CONSTANT_Fieldref_info constant pool data structure. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision:395 $ - * $Id:ConstantFieldrefInfo.java 395 2008-04-03 15:08:14Z Peter Palaga $ - */ -public class ConstantFieldrefInfo extends ConstantReference { - - public ConstantFieldrefInfo(AbstractConstantPoolEntry[] constantPool) { - super(CONSTANT_FIELDREF, constantPool); - } - - public void read(DataInput in) throws IOException { - - super.read(in); - } - - public void write(DataOutput out) - throws IOException { - - out.writeByte(ByteCodeConstants.TAG_FIELDREF); - super.write(out); - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantFloatInfo.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantFloatInfo.java deleted file mode 100644 index 98400c04..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantFloatInfo.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode.constant_pool; - -import com.drgarbage.bytecode.ByteCodeConstants; -import com.drgarbage.javasrc.JavaLexicalConstants; - -import java.io.*; - -/** - * Describes a CONSTANT_Float_info constant pool data structure. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision:395 $ - * $Id:ConstantFloatInfo.java 395 2008-04-03 15:08:14Z Peter Palaga $ - */ -public class ConstantFloatInfo extends ConstantNumeric { - - public ConstantFloatInfo(AbstractConstantPoolEntry[] constantPool) { - super(CONSTANT_FLOAT, constantPool); - } - - /** - Get the float value of this constant pool entry. - @return the value - */ - public float getFloat() { - return Float.intBitsToFloat(bytes); - } - - /** - Set the float value of this constant pool entry. - @param number the value - */ - public void setFloat(float number) { - bytes = Float.floatToIntBits(number); - } - - public void read(DataInput in) throws IOException { - - super.read(in); - } - - public void write(DataOutput out) - throws IOException { - - out.writeByte(ByteCodeConstants.TAG_FLOAT); - super.write(out); - } - - @Override - public String getInfo() { - return ByteCodeConstants.bytes + JavaLexicalConstants.EQUALS + String.valueOf(getFloat()); - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantIntegerInfo.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantIntegerInfo.java deleted file mode 100644 index 50c96efc..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantIntegerInfo.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode.constant_pool; - -import com.drgarbage.bytecode.ByteCodeConstants; -import com.drgarbage.javasrc.JavaLexicalConstants; - -import java.io.*; - -/** - * Describes a CONSTANT_Integer_info constant pool data structure. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision:395 $ - * $Id:ConstantIntegerInfo.java 395 2008-04-03 15:08:14Z Peter Palaga $ - */ -public class ConstantIntegerInfo extends ConstantNumeric { - - public ConstantIntegerInfo(AbstractConstantPoolEntry[] constantPool) { - super(CONSTANT_INTEGER, constantPool); - } - - /** - Get the int value of this constant pool entry. - @return the value - */ - public int getInt() { - return bytes; - } - - /** - Set the int value of this constant pool entry. - @param number the value - */ - public void setInt(int number) { - bytes = number; - } - - public void read(DataInput in) throws IOException { - - super.read(in); - } - - public void write(DataOutput out) - throws IOException { - - out.writeByte(ByteCodeConstants.TAG_INTEGER); - super.write(out); - } - - @Override - public String getInfo() { - return ByteCodeConstants.bytes + JavaLexicalConstants.EQUALS + String.valueOf(getInt()); - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantInterfaceMethodrefInfo.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantInterfaceMethodrefInfo.java deleted file mode 100644 index 49688040..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantInterfaceMethodrefInfo.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode.constant_pool; - -import com.drgarbage.bytecode.ByteCodeConstants; - -import java.io.*; - -/** - * Describes a CONSTANT_InterfaceMethodref_info constant pool data structure. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision:395 $ - * $Id:ConstantInterfaceMethodrefInfo.java 395 2008-04-03 15:08:14Z Peter Palaga $ - */ -public class ConstantInterfaceMethodrefInfo extends ConstantReference { - - public ConstantInterfaceMethodrefInfo( - AbstractConstantPoolEntry[] constantPool) { - super(CONSTANT_INTERFACE_METHODREF, constantPool); - } - - public void read(DataInput in) throws IOException { - - super.read(in); - } - - public void write(DataOutput out) - throws IOException { - - out.writeByte(ByteCodeConstants.TAG_INTERFACE_METHODREF); - super.write(out); - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantInvokeDynamicInfo.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantInvokeDynamicInfo.java deleted file mode 100644 index 058af030..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantInvokeDynamicInfo.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode.constant_pool; - -import com.drgarbage.bytecode.ByteCodeConstants; -import com.drgarbage.javasrc.JavaLexicalConstants; - -import java.io.*; - -/** - * Describes a CONSTANT_InvokeDynamic_info constant pool data structure. - * - * @author Sergej Alekseev - * @version $Revision: 187 $ - * $Id: ConstantInvokeDynamicInfo.java 187 2013-06-03 05:47:37Z salekseev $ - */ -public class ConstantInvokeDynamicInfo extends AbstractConstantPoolEntry { - - public ConstantInvokeDynamicInfo(AbstractConstantPoolEntry[] constantPool) { - super(CONSTANT_INVOKE_DYNAMIC, constantPool); - } - - /** Length of the constant pool data structure in bytes. */ - public static final int SIZE = 4; - - private int bootstrapMethodAttrIndex; - private int nameAndTypeIndex; - - /** - * Get the index of the constant pool entry containing the - * bootstrapMethodAttr of this entry. - * @return the index - */ - public int getBootstrapMethodAttrIndex() { - return bootstrapMethodAttrIndex; - } - - /** - * Set the index of the constant pool entry containing the - * bootstrapMethodAttr of this entry. - * @param bootstrapMethodAttrIndex the index - */ - public void setBootstrapMethodAttrIndex(int bootstrapMethodAttrIndex) { - this.bootstrapMethodAttrIndex = bootstrapMethodAttrIndex; - } - - /** - * Get the index of the constant pool entry containing the - * nameAndType of this entry. - * @return the index - */ - public int getNameAndTypeIndex() { - return nameAndTypeIndex; - } - - - /** - * Set the index of the constant pool entry containing the - * nameAndType of this entry. - * @param nameAndTypeIndex the index - */ - public void setNameAndTypeIndex(int nameAndTypeIndex) { - this.nameAndTypeIndex = nameAndTypeIndex; - } - - public void read(DataInput in) throws IOException { - bootstrapMethodAttrIndex = in.readUnsignedShort(); - nameAndTypeIndex = in.readUnsignedShort(); - } - - public void write(DataOutput out) - throws IOException { - - out.writeByte(ByteCodeConstants.TAG_STRING); - out.writeShort(bootstrapMethodAttrIndex); - out.writeShort(nameAndTypeIndex); - } - - public boolean equals(Object object) { - if (!(object instanceof ConstantInvokeDynamicInfo)) { - return false; - } - ConstantInvokeDynamicInfo constantInvokeDynamicInfo = (ConstantInvokeDynamicInfo)object; - return super.equals(object) && - constantInvokeDynamicInfo.bootstrapMethodAttrIndex == bootstrapMethodAttrIndex && - constantInvokeDynamicInfo.nameAndTypeIndex == nameAndTypeIndex; - } - - public int hashCode() { - return super.hashCode() ^ bootstrapMethodAttrIndex ^ nameAndTypeIndex; - } - - @Override - public String getInfo() { - return ByteCodeConstants.INVOKE_DYNAMIC_BOOTSTRAP_METHOD_ATTR_INDEX + JavaLexicalConstants.EQUALS + bootstrapMethodAttrIndex - + JavaLexicalConstants.SEMICOLON + JavaLexicalConstants.SPACE - + ByteCodeConstants.INVOKE_DYNAMIC_NAME_AND_TYPE_INDEX + JavaLexicalConstants.EQUALS + nameAndTypeIndex; - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantLargeNumeric.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantLargeNumeric.java deleted file mode 100644 index fada1af5..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantLargeNumeric.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode.constant_pool; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; - -/** - * Base class for large numeric constant pool data structures. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision:395 $ - * $Id:ConstantLargeNumeric.java 395 2008-04-03 15:08:14Z Peter Palaga $ - */ -public abstract class ConstantLargeNumeric extends AbstractConstantPoolEntry { - - public ConstantLargeNumeric(byte tag, AbstractConstantPoolEntry[] constantPool) { - super(tag, constantPool); - } - - /** Length of the constant pool data structure in bytes. */ - public static final int SIZE = 8; - - /** high_bytes field. */ - protected int highBytes; - /** low_bytes field. */ - protected int lowBytes; - - /** - Get the high_bytes field of this constant pool entry. - @return the high_bytes field - */ - public int getHighBytes() { - return highBytes; - } - - /** - Set the high_bytes field of this constant pool entry. - @param highBytes the high_bytes field - */ - public void setHighBytes(int highBytes) { - this.highBytes = highBytes; - } - - /** - Get the low_bytes field of this constant pool entry. - @return the low_bytes field - */ - public int getLowBytes() { - return lowBytes; - } - - /** - Set the low_bytes field of this constant pool entry. - @param lowBytes the low_bytes field - */ - public void setLowBytes(int lowBytes) { - this.lowBytes = lowBytes; - } - - public void read(DataInput in) throws IOException { - - highBytes = in.readInt(); - lowBytes = in.readInt(); - } - - public void write(DataOutput out) throws IOException { - - out.writeInt(highBytes); - out.writeInt(lowBytes); - } - - public boolean equals(Object object) { - if (!(object instanceof ConstantLargeNumeric)) { - return false; - } - ConstantLargeNumeric constantLargeNumeric = (ConstantLargeNumeric)object; - return super.equals(object) && - constantLargeNumeric.highBytes == highBytes && - constantLargeNumeric.lowBytes == lowBytes; - } - - public int hashCode() { - return super.hashCode() ^ highBytes ^ lowBytes; - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantLongInfo.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantLongInfo.java deleted file mode 100644 index d8c40554..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantLongInfo.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode.constant_pool; - -import com.drgarbage.bytecode.ByteCodeConstants; -import com.drgarbage.javasrc.JavaLexicalConstants; - -import java.io.*; - -/** - * Describes a CONSTANT_Long_info constant pool data structure. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision:395 $ - * $Id:ConstantLongInfo.java 395 2008-04-03 15:08:14Z Peter Palaga $ - */ -public class ConstantLongInfo extends ConstantLargeNumeric { - - public ConstantLongInfo(AbstractConstantPoolEntry[] constantPool) { - super(CONSTANT_LONG, constantPool); - } - - /** - Get the long value of this constant pool entry. - @return the value - */ - public long getLong() { - return (long)highBytes << 32 | ((long)lowBytes & 0x7FFFFFFF); - } - - /** - Set the long value of this constant pool entry. - @param number the value - */ - public void setLong(long number) { - highBytes = (int)(number >>> 32); - lowBytes = (int)(number & 0x0000FFFF); - } - - public void read(DataInput in) throws IOException { - - super.read(in); - } - - public void write(DataOutput out) - throws IOException { - - out.writeByte(ByteCodeConstants.TAG_LONG); - super.write(out); - } - - @Override - public String getInfo() { - return ByteCodeConstants.bytes + JavaLexicalConstants.EQUALS + String.valueOf(getLong()); - } - - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantMethodHandleInfo.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantMethodHandleInfo.java deleted file mode 100644 index 849d7f3e..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantMethodHandleInfo.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode.constant_pool; - -import com.drgarbage.bytecode.ByteCodeConstants; -import com.drgarbage.javasrc.JavaLexicalConstants; - -import java.io.*; - -/** - * Describes a CONSTANT_MethodHandle_info constant pool data structure. - * - * @author Sergej Alekseev - * @version $Revision: 187 $ - * $Id: ConstantMethodHandleInfo.java 187 2013-06-03 05:47:37Z salekseev $ - */ -public class ConstantMethodHandleInfo extends AbstractConstantPoolEntry { - - public ConstantMethodHandleInfo(AbstractConstantPoolEntry[] constantPool) { - super(CONSTANT_METHOD_HANDLE, constantPool); - } - - /** Length of the constant pool data structure in bytes. */ - public static final int SIZE = 3; - - private byte referenceKind; - private int referenceIndex; - - /** - * Get the value in the range 1 to 9. - * @return the kind - */ - public byte getReferenceKind() { - return referenceKind; - } - - /** - * Set the value in the range 1 to 9. The value denotes - * the kind of this method handle, which characterizes - * its bytecode behavior - * @param referenceKind the kind of the reference - */ - public void setReferenceKind(byte referenceKind) { - this.referenceKind = referenceKind; - } - - /** - * Get the index of the constant pool entry containing the - * reference of this entry. - * @return the index - */ - public int getReferenceIndex() { - return referenceIndex; - } - - /** - * Set the index of the constant pool entry containing the - * reference of this entry. - * @param referenceIndex the index - */ - public void setReferenceIndex(int referenceIndex) { - this.referenceIndex = referenceIndex; - } - - public void read(DataInput in) throws IOException { - referenceKind = in.readByte(); - referenceIndex = in.readUnsignedShort(); - } - - public void write(DataOutput out) - throws IOException { - - out.writeByte(ByteCodeConstants.TAG_STRING); - out.writeByte(referenceKind); - out.writeShort(referenceIndex); - } - - public boolean equals(Object object) { - if (!(object instanceof ConstantMethodHandleInfo)) { - return false; - } - ConstantMethodHandleInfo constantMethodHandleInfo = (ConstantMethodHandleInfo)object; - return super.equals(object) && - constantMethodHandleInfo.referenceKind == referenceKind && - constantMethodHandleInfo.referenceIndex == referenceIndex; - } - - public int hashCode() { - return super.hashCode() ^ referenceKind ^ referenceIndex; - } - - @Override - public String getInfo() { - return ByteCodeConstants.METHOD_HANDLE_REF_KIND + JavaLexicalConstants.EQUALS + referenceKind - + JavaLexicalConstants.SEMICOLON + JavaLexicalConstants.SPACE - + ByteCodeConstants.METHOD_HANDLE_INDEX + JavaLexicalConstants.EQUALS + referenceIndex; - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantMethodTypeInfo.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantMethodTypeInfo.java deleted file mode 100644 index a14fd63a..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantMethodTypeInfo.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode.constant_pool; - -import com.drgarbage.bytecode.ByteCodeConstants; -import com.drgarbage.javasrc.JavaLexicalConstants; - -import java.io.*; - -/** - * Describes a CONSTANT_MethodType_info constant pool data structure. - * - * @author Sergej Alekseev - * @version $Revision: 187 $ - * $Id: ConstantMethodTypeInfo.java 187 2013-06-03 05:47:37Z salekseev $ - */ -public class ConstantMethodTypeInfo extends AbstractConstantPoolEntry { - - public ConstantMethodTypeInfo(AbstractConstantPoolEntry[] constantPool) { - super(CONSTANT_METHOD_TYPE, constantPool); - } - - /** Length of the constant pool data structure in bytes. */ - public static final int SIZE = 2; - - private int descriptorIndex; - - /** - * Get the index of the constant pool entry containing the - * descriptor of this entry. - * @return the index - */ - public int getDescriptorIndex() { - return descriptorIndex; - } - - /** - * Set the index of the constant pool entry containing the - * descriptor of this entry. - * @param descriptorIndex the index - */ - public void setDescriptorIndex(int descriptorIndex) { - this.descriptorIndex = descriptorIndex; - } - - public void read(DataInput in) throws IOException { - descriptorIndex = in.readUnsignedShort(); - } - - public void write(DataOutput out) - throws IOException { - - out.writeByte(ByteCodeConstants.TAG_STRING); - out.writeShort(descriptorIndex); - } - - public boolean equals(Object object) { - if (!(object instanceof ConstantMethodTypeInfo)) { - return false; - } - ConstantMethodTypeInfo constantMethodTypeInfo = (ConstantMethodTypeInfo)object; - return super.equals(object) && - constantMethodTypeInfo.descriptorIndex == descriptorIndex; - } - - public int hashCode() { - return super.hashCode() ^ descriptorIndex; - } - - @Override - public String getInfo() { - return ByteCodeConstants.DESCRIPTOR_INDEX + JavaLexicalConstants.EQUALS + descriptorIndex; - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantMethodrefInfo.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantMethodrefInfo.java deleted file mode 100644 index 5944a511..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantMethodrefInfo.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode.constant_pool; - -import com.drgarbage.bytecode.ByteCodeConstants; - -import java.io.*; - -/** - * Describes a CONSTANT_Methodref_info constant pool data structure. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision:395 $ - * $Id:ConstantMethodrefInfo.java 395 2008-04-03 15:08:14Z Peter Palaga $ - */ -public class ConstantMethodrefInfo extends ConstantReference { - - public ConstantMethodrefInfo(AbstractConstantPoolEntry[] constantPool) { - super(CONSTANT_METHODREF, constantPool); - } - - public void read(DataInput in) throws IOException { - - super.read(in); - } - - public void write(DataOutput out) - throws IOException { - - out.writeByte(ByteCodeConstants.TAG_METHODREF); - super.write(out); - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantNameAndTypeInfo.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantNameAndTypeInfo.java deleted file mode 100644 index 72f34120..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantNameAndTypeInfo.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode.constant_pool; - -import com.drgarbage.bytecode.ByteCodeConstants; -import com.drgarbage.javasrc.JavaLexicalConstants; - -import java.io.*; - -/** - * Describes a CONSTANT_NameAndType_info constant pool data structure. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision:395 $ - * $Id:ConstantNameAndTypeInfo.java 395 2008-04-03 15:08:14Z Peter Palaga $ - */ -public class ConstantNameAndTypeInfo extends AbstractConstantPoolEntry { - - public ConstantNameAndTypeInfo(AbstractConstantPoolEntry[] constantPool) { - super(CONSTANT_NAME_AND_TYPE, constantPool); - } - - /** Length of the constant pool data structure in bytes. */ - public static final int SIZE = 4; - - private int nameIndex; - private int descriptorIndex; - - /** - Get the index of the constant pool entry containing the name of this entry. - @return the index - */ - public int getNameIndex() { - return nameIndex; - } - - /** - Set the index of the constant pool entry containing the name of this entry. - @param nameIndex the index - */ - public void setNameIndex(int nameIndex) { - this.nameIndex = nameIndex; - } - - /** - Get the index of the constant pool entry containing the descriptor of this entry. - @return the index - */ - public int getDescriptorIndex() { - return descriptorIndex; - } - - /** - Set the index of the constant pool entry containing the descriptor of this entry. - @param descriptorIndex the index - */ - public void setDescriptorIndex(int descriptorIndex) { - this.descriptorIndex = descriptorIndex; - } - - /** - Get the name. - @return the name. - */ - public String getName() { - return ((ConstantUtf8Info)constantPool[nameIndex]).getString(); - } - - /** - Get the descriptor string. - @return the string. - */ - public String getDescriptor() { - return ((ConstantUtf8Info)constantPool[descriptorIndex]).getString(); - } - - public void read(DataInput in) throws IOException { - - nameIndex = in.readUnsignedShort(); - descriptorIndex = in.readUnsignedShort(); - - } - - public void write(DataOutput out) - throws IOException { - - out.writeByte(ByteCodeConstants.TAG_NAME_AND_TYPE); - out.writeShort(nameIndex); - out.writeShort(descriptorIndex); - } - - public boolean equals(Object object) { - if (!(object instanceof ConstantNameAndTypeInfo)) { - return false; - } - ConstantNameAndTypeInfo constantNameAndTypeInfo = (ConstantNameAndTypeInfo)object; - return super.equals(object) && - constantNameAndTypeInfo.nameIndex == nameIndex && - constantNameAndTypeInfo.descriptorIndex == descriptorIndex; - } - - public int hashCode() { - return super.hashCode() ^ nameIndex ^ descriptorIndex; - } - - @Override - public String getInfo() { - return ByteCodeConstants.NAME_INDEX + JavaLexicalConstants.EQUALS + nameIndex - + JavaLexicalConstants.SEMICOLON + JavaLexicalConstants.SPACE - + ByteCodeConstants.DESCRIPTOR_INDEX + JavaLexicalConstants.EQUALS + descriptorIndex; - } - - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantNumeric.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantNumeric.java deleted file mode 100644 index 8115da58..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantNumeric.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode.constant_pool; - - -import java.io.*; - -/** - * Base class for numeric constant pool data structures. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision:395 $ - * $Id:ConstantNumeric.java 395 2008-04-03 15:08:14Z Peter Palaga $ - */ -public abstract class ConstantNumeric extends AbstractConstantPoolEntry { - - public ConstantNumeric(byte tag, AbstractConstantPoolEntry[] constantPool) { - super(tag, constantPool); - } - - /** Length of the constant pool data structure in bytes. */ - public static final int SIZE = 4; - - /** bytes field. */ - protected int bytes; - - /** - Get the bytes field of this constant pool entry. - @return the bytes field - */ - public int getBytes() { - return bytes; - } - - /** - Set the bytes field of this constant pool entry. - @param bytes the bytes field - */ - public void setBytes(int bytes) { - this.bytes = bytes; - } - - public void read(DataInput in) throws IOException { - bytes = in.readInt(); - } - - public void write(DataOutput out) - throws IOException { - - out.writeInt(bytes); - } - - public boolean equals(Object object) { - if (!(object instanceof ConstantNumeric)) { - return false; - } - ConstantNumeric constantNumeric = (ConstantNumeric)object; - return super.equals(object) && constantNumeric.bytes == bytes; - } - - public int hashCode() { - return super.hashCode() ^ bytes; - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantPoolTags.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantPoolTags.java deleted file mode 100644 index 4519ae23..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantPoolTags.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode.constant_pool; - -public interface ConstantPoolTags { - public static final byte CONSTANT_CLASS = 7; - public static final byte CONSTANT_FIELDREF = 9; - public static final byte CONSTANT_METHODREF = 10; - public static final byte CONSTANT_INTERFACE_METHODREF = 11; - public static final byte CONSTANT_STRING = 8; - public static final byte CONSTANT_INTEGER = 3; - public static final byte CONSTANT_FLOAT = 4; - public static final byte CONSTANT_LONG = 5; - public static final byte CONSTANT_DOUBLE = 6; - public static final byte CONSTANT_NAME_AND_TYPE = 12; - public static final byte CONSTANT_UTF8 = 1; - public static final byte CONSTANT_METHOD_HANDLE = 15; - public static final byte CONSTANT_METHOD_TYPE = 16; - public static final byte CONSTANT_INVOKE_DYNAMIC = 18; - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantReference.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantReference.java deleted file mode 100644 index aa3b9d63..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantReference.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode.constant_pool; - - -import java.io.*; - -import com.drgarbage.bytecode.ByteCodeConstants; -import com.drgarbage.javasrc.JavaLexicalConstants; - -/** - * Base class for constant pool data structures which reference class members. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision:395 $ - * $Id:ConstantReference.java 395 2008-04-03 15:08:14Z Peter Palaga $ - */ -public abstract class ConstantReference extends AbstractConstantPoolEntry { - - public ConstantReference(byte tag, AbstractConstantPoolEntry[] constantPool) { - super(tag, constantPool); - } - - /** Length of the constant pool data structure in bytes. */ - public static final int SIZE = 4; - - /** class_index field. */ - protected int classIndex; - /** name_and_type_index field. */ - protected int nameAndTypeIndex; - - /** - Get the index of the constant pool entry containing the - CONSTANT_Class_info of this entry. - @return the index - */ - public int getClassIndex() { - return classIndex; - } - - /** - Set the index of the constant pool entry containing the - CONSTANT_Class_info of this entry. - @param classIndex the index - */ - public void setClassIndex(int classIndex) { - this.classIndex = classIndex; - } - - /** - Get the index of the constant pool entry containing the - CONSTANT_NameAndType_info of this entry. - @return the index - */ - public int getNameAndTypeIndex() { - return nameAndTypeIndex; - } - - /** - Set the index of the constant pool entry containing the - CONSTANT_NameAndType_info of this entry. - @param nameAndTypeIndex the index - */ - public void setNameAndTypeIndex(int nameAndTypeIndex) { - this.nameAndTypeIndex = nameAndTypeIndex; - } - - public void read(DataInput in) throws IOException { - - classIndex = in.readUnsignedShort(); - nameAndTypeIndex = in.readUnsignedShort(); - } - - public void write(DataOutput out) - throws IOException { - - out.writeShort(classIndex); - out.writeShort(nameAndTypeIndex); - } - - public boolean equals(Object object) { - if (!(object instanceof ConstantReference)) { - return false; - } - ConstantReference constantReference = (ConstantReference)object; - return super.equals(object) && - constantReference.classIndex == classIndex && - constantReference.nameAndTypeIndex == nameAndTypeIndex; - } - - public int hashCode() { - return super.hashCode() ^ classIndex ^ nameAndTypeIndex; - } - - @Override - public String getInfo() { - return ByteCodeConstants.CLASS_INDEX + JavaLexicalConstants.EQUALS + classIndex - + JavaLexicalConstants.SEMICOLON + JavaLexicalConstants.SPACE - + ByteCodeConstants.name_and_type_index + JavaLexicalConstants.EQUALS + nameAndTypeIndex; - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantStringInfo.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantStringInfo.java deleted file mode 100644 index 30b1ac9e..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantStringInfo.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode.constant_pool; - -import com.drgarbage.bytecode.ByteCodeConstants; -import com.drgarbage.javasrc.JavaLexicalConstants; - -import java.io.*; - -/** - * Describes a CONSTANT_String_info constant pool data structure. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision:395 $ - * $Id:ConstantStringInfo.java 395 2008-04-03 15:08:14Z Peter Palaga $ - */ -public class ConstantStringInfo extends AbstractConstantPoolEntry { - - public ConstantStringInfo(AbstractConstantPoolEntry[] constantPool) { - super(CONSTANT_STRING, constantPool); - } - - /** Length of the constant pool data structure in bytes. */ - public static final int SIZE = 2; - - private int stringIndex; - - /** - Get the index of the constant pool entry containing the - string of this entry. - @return the index - */ - public int getStringIndex() { - return stringIndex; - } - - /** - Set the index of the constant pool entry containing the - string of this entry. - @param stringIndex the index - */ - public void setStringIndex(int stringIndex) { - this.stringIndex = stringIndex; - } - - public void read(DataInput in) throws IOException { - - stringIndex = in.readUnsignedShort(); - } - - public void write(DataOutput out) - throws IOException { - - out.writeByte(ByteCodeConstants.TAG_STRING); - out.writeShort(stringIndex); - } - - public boolean equals(Object object) { - if (!(object instanceof ConstantStringInfo)) { - return false; - } - ConstantStringInfo constantStringInfo = (ConstantStringInfo)object; - return super.equals(object) && constantStringInfo.stringIndex == stringIndex; - } - - public int hashCode() { - return super.hashCode() ^ stringIndex; - } - - @Override - public String getInfo() { - return ByteCodeConstants.string_index + JavaLexicalConstants.EQUALS + String.valueOf(stringIndex); - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantUtf8Info.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantUtf8Info.java deleted file mode 100644 index ea79fb16..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/constant_pool/ConstantUtf8Info.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode.constant_pool; - -import com.drgarbage.bytecode.ByteCodeConstants; -import com.drgarbage.bytecode.BytecodeUtils; -import com.drgarbage.javasrc.JavaLexicalConstants; - -import java.io.*; - -/** - * Describes a CONSTANT_Utf8_info constant pool data structure. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision:395 $ - * $Id:ConstantUtf8Info.java 395 2008-04-03 15:08:14Z Peter Palaga $ - */ -public class ConstantUtf8Info extends AbstractConstantPoolEntry { - - public ConstantUtf8Info(AbstractConstantPoolEntry[] constantPool) { - super(CONSTANT_UTF8, constantPool); - } - - private String string; - private int length = ByteCodeConstants.INVALID_OFFSET; - - /** - * Get the string in this entry. - * - * @return the string - */ - public String getString() { - return string; - } - - /** - * Set the string in this entry. - * - * @param string the string - */ - public void setString(String string) { - this.string = string; - length = ByteCodeConstants.INVALID_OFFSET; - } - - public void read(DataInput in) throws IOException { - - string = in.readUTF(); - length = ByteCodeConstants.INVALID_OFFSET; - - } - - public void write(DataOutput out) - throws IOException { - - out.writeByte(ByteCodeConstants.TAG_UTF8); - out.writeUTF(string); - } - - public boolean equals(Object object) { - if (!(object instanceof ConstantUtf8Info)) { - return false; - } - ConstantUtf8Info constantUtf8Info = (ConstantUtf8Info)object; - return super.equals(object) && constantUtf8Info.string.equals(string); - } - - public int hashCode() { - return super.hashCode() ^ string.hashCode(); - } - - public int getLength() { - if (length == ByteCodeConstants.INVALID_OFFSET) { - try { - length = string.getBytes("utf-8").length; - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e); - } - } - return length; - } - - @Override - public String getInfo() { - - StringBuffer sb = new StringBuffer() - .append(ByteCodeConstants.LENGTH) - .append(JavaLexicalConstants.EQUALS) - .append(getLength()) - .append(JavaLexicalConstants.SEMICOLON) - .append(JavaLexicalConstants.SPACE) - .append(ByteCodeConstants.bytes) - .append(JavaLexicalConstants.EQUALS) - ; - BytecodeUtils.appendString(sb, string); - return sb.toString(); - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/AbstractInstruction.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/AbstractInstruction.java deleted file mode 100644 index 8c69f189..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/AbstractInstruction.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode.instructions; - -import java.io.IOException; - -import com.drgarbage.bytecode.ByteCodeConstants; -import com.drgarbage.bytecode.CountedDataInput; -import com.drgarbage.bytecode.CountedOutput; - -/** - * Abstract superclass for all other instructions. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision:395 $ - * $Id:AbstractInstruction.java 395 2008-04-03 15:08:14Z Peter Palaga $ - */ -public abstract class AbstractInstruction implements Opcodes { - - private int offset; - private int opcode; - /** - Constructor. - @param opcode the opcode. - */ - protected AbstractInstruction(int opcode) { - this.opcode = opcode; - } - - /** - Byte length of this instruction. - @return length in bytes - */ - public int getLength() { - return 1; - } - - /** - Returns the offset in bytes, actualy the distance - from the beginning of the first instruction of the given method. - @return offset in bytes. - */ - public int getOffset() { - return offset; - } - - /** - * Returns the opcode of this instruction. - * - * @see Opcodes - * @see ByteCodeConstants#OPCODE_MNEMONICS - * @return the opcode - */ - public int getOpcode() { - return opcode; - } - - /** - * Returns the opcode mnemonic of this instruction. - * @see Opcodes - * @see ByteCodeConstants#OPCODE_MNEMONICS - * @return the opcode mnemonic - */ - public String getOpcodeMnemonic() { - return ByteCodeConstants.OPCODE_MNEMONICS[opcode]; - } - - /** - Reads this instruction from a {@link CountedDataInput}. - Does not read the {@link #opcode}. The {@link #opcode} should be - read in the calling method, just before this instruction is constructed - with {@link #AbstractInstruction(int)}. - - @param in an input. - @throws IOException - */ - public void read(CountedDataInput in) throws IOException { - /* The opcode has already been read - * in the calling method and passed in through the - * constructor */ - offset = in.getByteCount() - 1; - } - - /** - Sets the offset of this instruction. - This method is thought rather for bytecode instrumentation, - e.g. when inserting instructions at positions before this instruction. - In cases when the instructions are read from some kind of InputStream - the {@link #offset} attribute is set within the {@link #read(CountedDataInput)} method - - @see #getOffset() - @see #read(CountedDataInput) - @param offset in bytes. - */ - public void setOffset(int offset) { - this.offset = offset; - } - - /** - Writes this instruction into a {@link CountedOutput}. - @param out an output - @throws IOException - */ - public void write(CountedOutput out) throws IOException { - out.writeByte(opcode); - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/BranchInstruction.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/BranchInstruction.java deleted file mode 100644 index 776f4df5..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/BranchInstruction.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package com.drgarbage.bytecode.instructions; - -import java.io.IOException; - -import com.drgarbage.bytecode.CountedDataInput; -import com.drgarbage.bytecode.CountedOutput; - -/** - * Describes an instruction that branches to a different offset. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision:81 $ - * $Id:BranchInstruction.java 81 2007-05-10 08:38:47Z Peter Palaga $ - */ -public class BranchInstruction extends AbstractInstruction { - - protected int branchOffset; - - /** - Constructor. - @param opcode the opcode. - */ - public BranchInstruction(int opcode) { - super(opcode); - } - - /** - Constructor. - @param opcode the opcode. - @param branchOffset the branch offset. - */ - public BranchInstruction(int opcode, int branchOffset) { - super(opcode); - this.branchOffset = branchOffset; - } - - public int getLength() { - return super.getLength() + 2; - } - - /** - Get the relative offset of the branch of this instruction. - @return the offset - */ - public int getBranchOffset() { - return branchOffset; - } - - /** - Set the relative offset of the branch of this instruction. - @param branchOffset the offset - */ - public void setBranchOffset(int branchOffset) { - this.branchOffset = branchOffset; - } - - public void read(CountedDataInput in) throws IOException { - super.read(in); - - branchOffset = in.readShort(); - } - - public void write(CountedOutput out) throws IOException { - super.write(out); - - out.writeShort(branchOffset); - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/BranchWInstruction.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/BranchWInstruction.java deleted file mode 100644 index 6f9f6c67..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/BranchWInstruction.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode.instructions; - -import java.io.IOException; - -import com.drgarbage.bytecode.CountedDataInput; -import com.drgarbage.bytecode.CountedOutput; - -public class BranchWInstruction extends BranchInstruction { - - public BranchWInstruction(int opcode) { - super(opcode); - } - - public BranchWInstruction(int opcode, int branchOffset) { - super(opcode, branchOffset); - } - - public void read(CountedDataInput in) throws IOException { - super.read(in); - - branchOffset = in.readInt(); - } - - public void write(CountedOutput out) throws IOException { - super.write(out); - - out.writeInt(branchOffset); - } - - - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/ConstantPoolByteIndexInstruction.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/ConstantPoolByteIndexInstruction.java deleted file mode 100644 index b1fbda99..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/ConstantPoolByteIndexInstruction.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode.instructions; - -public class ConstantPoolByteIndexInstruction extends ImmediateByteInstruction implements IConstantPoolIndexProvider { - - public ConstantPoolByteIndexInstruction(int opcode, boolean wide) { - super(opcode, wide); - } - - public ConstantPoolByteIndexInstruction(int opcode, boolean wide, - int immediateByte) { - super(opcode, wide, immediateByte); - } - - public int getConstantPoolIndex() { - return getImmediateByte(); - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/ConstantPoolShortIndexInstruction.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/ConstantPoolShortIndexInstruction.java deleted file mode 100644 index 6cd3a87f..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/ConstantPoolShortIndexInstruction.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode.instructions; - -public class ConstantPoolShortIndexInstruction extends ImmediateShortInstruction implements IConstantPoolIndexProvider { - - public ConstantPoolShortIndexInstruction(int opcode) { - super(opcode); - } - - public ConstantPoolShortIndexInstruction(int opcode, int immediateShort) { - super(opcode, immediateShort); - } - - public int getConstantPoolIndex() { - return getImmediateShort(); - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/IConstantPoolIndexProvider.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/IConstantPoolIndexProvider.java deleted file mode 100644 index 3fc0996b..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/IConstantPoolIndexProvider.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode.instructions; - -public interface IConstantPoolIndexProvider { - public int getConstantPoolIndex(); -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/ILocalVariableIndexProvider.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/ILocalVariableIndexProvider.java deleted file mode 100644 index d612dc7a..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/ILocalVariableIndexProvider.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode.instructions; - - -/** - * Implemented by instructions, which load from or store into a local variable. - * The index can be looked up in the the local variable table (if available), of the - * Code attribute. - * - * @author Peter Palaga - * - */ -public interface ILocalVariableIndexProvider { - - /** - * A constant experssing an invalid index which can be returned by {@link getLocalVariableIndex()}. - */ - public static final int INVALID_INDEX = -1; - - /** - * Returns an index of of a local variable in the local variables array. - * - * @return An index of the local variables array - */ - public int getLocalVariableIndex(); -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/ImmediateByteInstruction.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/ImmediateByteInstruction.java deleted file mode 100644 index 7afff70a..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/ImmediateByteInstruction.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package com.drgarbage.bytecode.instructions; - -import com.drgarbage.bytecode.CountedDataInput; -import com.drgarbage.bytecode.CountedOutput; - -import java.io.IOException; - -/** - * Describes an instruction that is followed by an immediate unsigned byte. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision:395 $ - * $Id:ImmediateByteInstruction.java 395 2008-04-03 15:08:14Z Peter Palaga $ - */ -public class ImmediateByteInstruction extends AbstractInstruction { - - /** Indicates whether the instuction is subject to a wide instruction or not. */ - protected boolean wide; - - private int immediateByte; - - /** - Constructor. - @param opcode the opcode - @param wide whether the instruction is a wide instruction. - */ - public ImmediateByteInstruction(int opcode, boolean wide) { - super(opcode); - this.wide = wide; - } - - /** - Constructor. - @param opcode the opcode - @param wide whether the instruction is a wide instruction. - @param immediateByte the immediate byte value. - */ - public ImmediateByteInstruction(int opcode, boolean wide, int immediateByte) { - this(opcode, wide); - this.immediateByte = immediateByte; - } - - public int getLength() { - return super.getLength() + (wide ? 2 : 1); - } - - /** - Get the immediate unsigned byte of this instruction. - @return the byte - */ - public int getImmediateByte() { - return immediateByte; - } - - /** - Set the immediate unsigned byte of this instruction. - @param immediateByte the byte - */ - public void setImmediateByte(int immediateByte) { - this.immediateByte = immediateByte; - } - - /** - Check whether the instuction is subject to a wide instruction or not. - @return wide or not - */ - public boolean isWide() { - return wide; - } - - /** - Set whether the instuction is subject to a wide instruction or not. - @param wide wide or not - */ - public void setWide(boolean wide) { - this.wide = wide; - } - - public void read(CountedDataInput in) throws IOException { - super.read(in); - - if (wide) { - immediateByte = in.readUnsignedShort(); - } else { - immediateByte = in.readUnsignedByte(); - } - } - - public void write(CountedOutput out) throws IOException { - super.write(out); - - if (wide) { - out.writeShort(immediateByte); - } else { - out.writeByte(immediateByte); - } - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/ImmediateIntInstruction.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/ImmediateIntInstruction.java deleted file mode 100644 index 2fe22203..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/ImmediateIntInstruction.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package com.drgarbage.bytecode.instructions; - -import com.drgarbage.bytecode.CountedDataInput; -import com.drgarbage.bytecode.CountedOutput; - -import java.io.IOException; - -/** - * Describes an instruction that is followed by an immediate int. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision:395 $ - * $Id:ImmediateIntInstruction.java 395 2008-04-03 15:08:14Z Peter Palaga $ - */ -public class ImmediateIntInstruction extends AbstractInstruction { - - private int immediateInt; - - /** - Constructor. - @param opcode the opcode. - */ - public ImmediateIntInstruction(int opcode) { - super(opcode); - } - - /** - Constructor. - @param opcode the opcode. - @param immediateInt the immediate int value. - */ - public ImmediateIntInstruction(int opcode, int immediateInt) { - super(opcode); - this.immediateInt = immediateInt; - } - - public int getLength() { - return super.getLength() + 4; - } - - /** - Get the immediate int of this instruction. - @return the int - */ - public int getImmediateInt() { - return immediateInt; - } - - /** - Set the immediate int of this instruction. - @param immediateInt the int - */ - public void setImmediateInt(int immediateInt) { - this.immediateInt = immediateInt; - } - - public void read(CountedDataInput in) throws IOException { - super.read(in); - - immediateInt = in.readInt(); - } - - public void write(CountedOutput out) throws IOException { - super.write(out); - - out.writeInt(immediateInt); - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/ImmediateShortInstruction.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/ImmediateShortInstruction.java deleted file mode 100644 index d97efee7..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/ImmediateShortInstruction.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package com.drgarbage.bytecode.instructions; - -import com.drgarbage.bytecode.CountedDataInput; -import com.drgarbage.bytecode.CountedOutput; - -import java.io.IOException; - -/** - * Describes an instruction that is followed by an immediate unsigned short. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision:395 $ - * $Id:ImmediateShortInstruction.java 395 2008-04-03 15:08:14Z Peter Palaga $ - */ -public class ImmediateShortInstruction extends AbstractInstruction { - - private int immediateShort; - - public int getLength() { - return super.getLength() + 2; - } - - /** - Constructor. - @param opcode the opcode. - */ - public ImmediateShortInstruction(int opcode) { - super(opcode); - } - - /** - Constructor. - @param opcode the opcode. - @param immediateShort the immediate short value. - */ - public ImmediateShortInstruction(int opcode, int immediateShort) { - super(opcode); - this.immediateShort = immediateShort; - } - - /** - Get the immediate unsigned short of this instruction. - @return the short - */ - public int getImmediateShort() { - return immediateShort; - } - - /** - Set the immediate unsigned short of this instruction. - @param immediateShort the short - */ - public void setImmediateShort(int immediateShort) { - this.immediateShort = immediateShort; - } - - public void read(CountedDataInput in) throws IOException { - super.read(in); - - immediateShort = in.readUnsignedShort(); - } - - public void write(CountedOutput out) throws IOException { - super.write(out); - - out.writeShort(immediateShort); - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/IncrementInstruction.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/IncrementInstruction.java deleted file mode 100644 index 53ea91c1..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/IncrementInstruction.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode.instructions; - -import com.drgarbage.bytecode.CountedDataInput; -import com.drgarbage.bytecode.CountedOutput; - -import java.io.IOException; - -/** - * Describes the iinc instruction. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision:81 $ - * $Id:IncrementInstruction.java 81 2007-05-10 08:38:47Z Peter Palaga $ - */ -public class IncrementInstruction extends ImmediateByteInstruction implements ILocalVariableIndexProvider { - - private int incrementConst; - - /** - Constructor. - @param opcode the opcode - @param wide whether the instruction is a wide instruction. - */ - public IncrementInstruction(int opcode, boolean wide) { - super(opcode, wide); - } - - /** - Constructor. - @param opcode the opcode - @param wide whether the instruction is a wide instruction. - @param immediateByte the immediate byte value. - @param incrementConst the increment. - */ - public IncrementInstruction(int opcode, boolean wide, int immediateByte, int incrementConst) { - super(opcode, wide, immediateByte); - this.incrementConst = incrementConst; - } - - - public int getLength() { - return super.getLength() + (wide ? 2 : 1); - } - - /** - Get the increment of this instruction. - @return the increment - */ - public int getIncrementConst() { - return incrementConst; - } - - /** - Set the increment of this instruction. - @param incrementConst the increment - */ - public void setIncrementConst(int incrementConst) { - this.incrementConst = incrementConst; - } - - public void read(CountedDataInput in) throws IOException { - super.read(in); - - if (wide) { - incrementConst = in.readShort(); - } else { - incrementConst = in.readByte(); - } - } - - public void write(CountedOutput out) throws IOException { - super.write(out); - - if (wide) { - out.writeShort(incrementConst); - } else { - out.writeByte(incrementConst); - } - } - - public int getLocalVariableIndex() { - return getImmediateByte(); - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/InvokeInterfaceInstruction.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/InvokeInterfaceInstruction.java deleted file mode 100644 index 6a5c292e..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/InvokeInterfaceInstruction.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode.instructions; - -import com.drgarbage.bytecode.CountedDataInput; -import com.drgarbage.bytecode.CountedOutput; - -import java.io.IOException; - -/** - * Describes the invokeinterface instruction. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision:81 $ - * $Id:InvokeInterfaceInstruction.java 81 2007-05-10 08:38:47Z Peter Palaga $ - */ -public class InvokeInterfaceInstruction extends ImmediateShortInstruction implements IConstantPoolIndexProvider { - - private int count; - - /** - Constructor. - @param opcode the opcode. - */ - public InvokeInterfaceInstruction(int opcode) { - super(opcode); - } - - /** - Constructor. - @param opcode the opcode - @param immediateShort the immediate short value. - @param count the argument count. - */ - public InvokeInterfaceInstruction(int opcode, int immediateShort, int count) { - super(opcode, immediateShort); - this.count = count; - } - - - public int getLength() { - return super.getLength() + 2; - } - - /** - Get the argument count of this instruction. - @return the argument count - */ - public int getCount() { - return count; - } - - /** - Set the argument count of this instruction. - @param count the argument count - */ - public void setCount(int count) { - this.count = count; - } - - public void read(CountedDataInput in) throws IOException { - super.read(in); - - count = in.readUnsignedByte(); - // Next byte is always 0 and thus discarded - in.readByte(); - } - - public void write(CountedOutput out) throws IOException { - super.write(out); - - out.writeByte(count); - out.writeByte(0); - } - - public int getConstantPoolIndex() { - return getImmediateShort(); - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/LookupSwitchInstruction.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/LookupSwitchInstruction.java deleted file mode 100644 index 69736bfe..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/LookupSwitchInstruction.java +++ /dev/null @@ -1,175 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package com.drgarbage.bytecode.instructions; - -import com.drgarbage.bytecode.CountedDataInput; -import com.drgarbage.bytecode.CountedOutput; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -/** - * Describes the lookupswitch instruction. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision:81 $ - * $Id:LookupSwitchInstruction.java 81 2007-05-10 08:38:47Z Peter Palaga $ - */ -public class LookupSwitchInstruction extends PaddedInstruction { - - /** - * An entry of the match-offset table. - * - */ - public static class MatchOffsetEntry { - - private int match; - private int offset; - - /** - * Constructor. - * @param match the match value. - * @param offset the branch offset. - */ - public MatchOffsetEntry(int match, int offset) { - this.match = match; - this.offset = offset; - } - - /** - Get the match value of this match-offset pair. - @return the value - */ - public int getMatch() { - return match; - } - - /** - Set the match value of this match-offset pair. - @param match the value - */ - public void setMatch(int match) { - this.match = match; - } - - /** - Get the offset of the branch for this match-offset pair. - @return the offset - */ - public int getOffset() { - return offset; - } - - /** - Set the offset of the branch for this match-offset pair. - @param offset the offset - */ - public void setOffset(int offset) { - this.offset = offset; - } - - } - - private int defaultOffset; - private List matchOffsetPairs = new ArrayList(); - - /** - Constructor. - @param opcode the opcode. - */ - public LookupSwitchInstruction(int opcode) { - super(opcode); - } - - public int getLength() { - return super.getLength() + 8 + 8 * matchOffsetPairs.size(); - } - - /** - Get the default offset of the branch of this instruction. - @return the offset - */ - public int getDefaultOffset() { - return defaultOffset; - } - - /** - Set the default offset of the branch of this instruction. - @param defaultOffset the offset - */ - public void setDefaultOffset(int defaultOffset) { - this.defaultOffset = defaultOffset; - } - - /** - Get the match-offset pairs of the branch of this instruction as - a java.util.List of MatchOffsetPair - elements. - @return the list - */ - public List getMatchOffsetPairs() { - return matchOffsetPairs; - } - - /** - Set the match-offset pairs of the branch of this instruction as - a java.util.List of LookupSwitchInstruction.MatchOffsetPair - elements. - @param matchOffsetPairs the list - */ - public void setMatchOffsetPairs(List matchOffsetPairs) { - this.matchOffsetPairs = matchOffsetPairs; - } - - public void read(CountedDataInput in) throws IOException { - super.read(in); - - matchOffsetPairs.clear(); - - defaultOffset = in.readInt(); - int numberOfPairs = in.readInt(); - - int match, offset; - for (int i = 0; i < numberOfPairs; i++) { - match = in.readInt(); - offset = in.readInt(); - - matchOffsetPairs.add(new MatchOffsetEntry(match, offset)); - } - - } - - public void write(CountedOutput out) throws IOException { - super.write(out); - - out.writeInt(defaultOffset); - - int numberOfPairs = matchOffsetPairs.size(); - out.writeInt(numberOfPairs); - - MatchOffsetEntry currentMatchOffsetPair; - for (int i = 0; i < numberOfPairs; i++) { - currentMatchOffsetPair = (MatchOffsetEntry)matchOffsetPairs.get(i); - out.writeInt(currentMatchOffsetPair.getMatch()); - out.writeInt(currentMatchOffsetPair.getOffset()); - } - } - - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/MultianewarrayInstruction.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/MultianewarrayInstruction.java deleted file mode 100644 index d37fc332..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/MultianewarrayInstruction.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode.instructions; - -import com.drgarbage.bytecode.CountedDataInput; -import com.drgarbage.bytecode.CountedOutput; - -import java.io.IOException; - -/** - * Describes the multianewarray instruction. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision:81 $ - * $Id:MultianewarrayInstruction.java 81 2007-05-10 08:38:47Z Peter Palaga $ - */ -public class MultianewarrayInstruction extends ConstantPoolShortIndexInstruction { - - private int dimensions; - - /** - Constructor. - @param opcode the opcode. - */ - public MultianewarrayInstruction(int opcode) { - super(opcode); - } - - public int getLength() { - return super.getLength() + 1; - } - - /** - Get the number of dimensions for the new array. - @return the number of dimensions - */ - public int getDimensions() { - return dimensions; - } - - /** - Set the number of dimensions for the new array. - @param dimensions the number of dimensions - */ - public void setDimensions(int dimensions) { - this.dimensions = dimensions; - } - - public void read(CountedDataInput in) throws IOException { - super.read(in); - - dimensions = in.readUnsignedByte(); - } - - public void write(CountedOutput out) throws IOException { - super.write(out); - - out.writeByte(dimensions); - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/NewArrayInstruction.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/NewArrayInstruction.java deleted file mode 100644 index 68b19163..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/NewArrayInstruction.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode.instructions; - -import com.drgarbage.javasrc.JavaKeywords; - -public class NewArrayInstruction extends ImmediateByteInstruction { - - public static final int T_BOOLEAN = 4; - public static final int T_CHAR = 5; - public static final int T_FLOAT = 6; - public static final int T_DOUBLE = 7; - public static final int T_BYTE = 8; - public static final int T_SHORT = 9; - public static final int T_INT = 10; - public static final int T_LONG = 11; - - public static final String resolveType(int t) { - switch (t) { - case T_BOOLEAN: - return JavaKeywords.BOOLEAN; - case T_CHAR: - return JavaKeywords.CHAR; - case T_FLOAT: - return JavaKeywords.FLOAT; - case T_DOUBLE: - return JavaKeywords.DOUBLE; - case T_BYTE: - return JavaKeywords.BYTE; - case T_SHORT: - return JavaKeywords.SHORT; - case T_INT: - return JavaKeywords.INT; - case T_LONG: - return JavaKeywords.LONG; - default: - throw new RuntimeException("invalid type "+ t); - } - } - - public NewArrayInstruction(int opcode, boolean wide) { - super(opcode, wide); - } - - public NewArrayInstruction(int opcode, boolean wide, int immediateByte) { - super(opcode, wide, immediateByte); - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/Opcodes.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/Opcodes.java deleted file mode 100644 index f5cd2ec2..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/Opcodes.java +++ /dev/null @@ -1,239 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode.instructions; - -import com.drgarbage.bytecode.ByteCodeConstants; - -/** - * Opcode constants. Use the {@link ByteCodeConstants#OPCODE_MNEMONICS} to map - * the numeric opcodes to their textual mnemonics. - * - * @see ByteCodeConstants#OPCODE_MNEMONICS - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision:81 $ - * $Id:Opcodes.java 81 2007-05-10 08:38:47Z Peter Palaga $ - */ -public interface Opcodes { - - public static final int OPCODE_NOP = 0x00; - public static final int OPCODE_ACONST_NULL = 0x01; - public static final int OPCODE_ICONST_M1 = 0x02; - public static final int OPCODE_ICONST_0 = 0x03; - public static final int OPCODE_ICONST_1 = 0x04; - public static final int OPCODE_ICONST_2 = 0x05; - public static final int OPCODE_ICONST_3 = 0x06; - public static final int OPCODE_ICONST_4 = 0x07; - public static final int OPCODE_ICONST_5 = 0x08; - public static final int OPCODE_LCONST_0 = 0x09; - public static final int OPCODE_LCONST_1 = 0x0a; - public static final int OPCODE_FCONST_0 = 0x0b; - public static final int OPCODE_FCONST_1 = 0x0c; - public static final int OPCODE_FCONST_2 = 0x0d; - public static final int OPCODE_DCONST_0 = 0x0e; - public static final int OPCODE_DCONST_1 = 0x0f; - public static final int OPCODE_BIPUSH = 0x10; - public static final int OPCODE_SIPUSH = 0x11; - public static final int OPCODE_LDC = 0x12; - public static final int OPCODE_LDC_W = 0x13; - public static final int OPCODE_LDC2_W = 0x14; - public static final int OPCODE_ILOAD = 0x15; - public static final int OPCODE_LLOAD = 0x16; - public static final int OPCODE_FLOAD = 0x17; - public static final int OPCODE_DLOAD = 0x18; - public static final int OPCODE_ALOAD = 0x19; - public static final int OPCODE_ILOAD_0 = 0x1a; - public static final int OPCODE_ILOAD_1 = 0x1b; - public static final int OPCODE_ILOAD_2 = 0x1c; - public static final int OPCODE_ILOAD_3 = 0x1d; - public static final int OPCODE_LLOAD_0 = 0x1e; - public static final int OPCODE_LLOAD_1 = 0x1f; - public static final int OPCODE_LLOAD_2 = 0x20; - public static final int OPCODE_LLOAD_3 = 0x21; - public static final int OPCODE_FLOAD_0 = 0x22; - public static final int OPCODE_FLOAD_1 = 0x23; - public static final int OPCODE_FLOAD_2 = 0x24; - public static final int OPCODE_FLOAD_3 = 0x25; - public static final int OPCODE_DLOAD_0 = 0x26; - public static final int OPCODE_DLOAD_1 = 0x27; - public static final int OPCODE_DLOAD_2 = 0x28; - public static final int OPCODE_DLOAD_3 = 0x29; - public static final int OPCODE_ALOAD_0 = 0x2a; - public static final int OPCODE_ALOAD_1 = 0x2b; - public static final int OPCODE_ALOAD_2 = 0x2c; - public static final int OPCODE_ALOAD_3 = 0x2d; - public static final int OPCODE_IALOAD = 0x2e; - public static final int OPCODE_LALOAD = 0x2f; - public static final int OPCODE_FALOAD = 0x30; - public static final int OPCODE_DALOAD = 0x31; - public static final int OPCODE_AALOAD = 0x32; - public static final int OPCODE_BALOAD = 0x33; - public static final int OPCODE_CALOAD = 0x34; - public static final int OPCODE_SALOAD = 0x35; - public static final int OPCODE_ISTORE = 0x36; - public static final int OPCODE_LSTORE = 0x37; - public static final int OPCODE_FSTORE = 0x38; - public static final int OPCODE_DSTORE = 0x39; - public static final int OPCODE_ASTORE = 0x3a; - public static final int OPCODE_ISTORE_0 = 0x3b; - public static final int OPCODE_ISTORE_1 = 0x3c; - public static final int OPCODE_ISTORE_2 = 0x3d; - public static final int OPCODE_ISTORE_3 = 0x3e; - public static final int OPCODE_LSTORE_0 = 0x3f; - public static final int OPCODE_LSTORE_1 = 0x40; - public static final int OPCODE_LSTORE_2 = 0x41; - public static final int OPCODE_LSTORE_3 = 0x42; - public static final int OPCODE_FSTORE_0 = 0x43; - public static final int OPCODE_FSTORE_1 = 0x44; - public static final int OPCODE_FSTORE_2 = 0x45; - public static final int OPCODE_FSTORE_3 = 0x46; - public static final int OPCODE_DSTORE_0 = 0x47; - public static final int OPCODE_DSTORE_1 = 0x48; - public static final int OPCODE_DSTORE_2 = 0x49; - public static final int OPCODE_DSTORE_3 = 0x4a; - public static final int OPCODE_ASTORE_0 = 0x4b; - public static final int OPCODE_ASTORE_1 = 0x4c; - public static final int OPCODE_ASTORE_2 = 0x4d; - public static final int OPCODE_ASTORE_3 = 0x4e; - public static final int OPCODE_IASTORE = 0x4f; - public static final int OPCODE_LASTORE = 0x50; - public static final int OPCODE_FASTORE = 0x51; - public static final int OPCODE_DASTORE = 0x52; - public static final int OPCODE_AASTORE = 0x53; - public static final int OPCODE_BASTORE = 0x54; - public static final int OPCODE_CASTORE = 0x55; - public static final int OPCODE_SASTORE = 0x56; - public static final int OPCODE_POP = 0x57; - public static final int OPCODE_POP2 = 0x58; - public static final int OPCODE_DUP = 0x59; - public static final int OPCODE_DUP_X1 = 0x5a; - public static final int OPCODE_DUP_X2 = 0x5b; - public static final int OPCODE_DUP2 = 0x5c; - public static final int OPCODE_DUP2_X1 = 0x5d; - public static final int OPCODE_DUP2_X2 = 0x5e; - public static final int OPCODE_SWAP = 0x5f; - public static final int OPCODE_IADD = 0x60; - public static final int OPCODE_LADD = 0x61; - public static final int OPCODE_FADD = 0x62; - public static final int OPCODE_DADD = 0x63; - public static final int OPCODE_ISUB = 0x64; - public static final int OPCODE_LSUB = 0x65; - public static final int OPCODE_FSUB = 0x66; - public static final int OPCODE_DSUB = 0x67; - public static final int OPCODE_IMUL = 0x68; - public static final int OPCODE_LMUL = 0x69; - public static final int OPCODE_FMUL = 0x6a; - public static final int OPCODE_DMUL = 0x6b; - public static final int OPCODE_IDIV = 0x6c; - public static final int OPCODE_LDIV = 0x6d; - public static final int OPCODE_FDIV = 0x6e; - public static final int OPCODE_DDIV = 0x6f; - public static final int OPCODE_IREM = 0x70; - public static final int OPCODE_LREM = 0x71; - public static final int OPCODE_FREM = 0x72; - public static final int OPCODE_DREM = 0x73; - public static final int OPCODE_INEG = 0x74; - public static final int OPCODE_LNEG = 0x75; - public static final int OPCODE_FNEG = 0x76; - public static final int OPCODE_DNEG = 0x77; - public static final int OPCODE_ISHL = 0x78; - public static final int OPCODE_LSHL = 0x79; - public static final int OPCODE_ISHR = 0x7a; - public static final int OPCODE_LSHR = 0x7b; - public static final int OPCODE_IUSHR = 0x7c; - public static final int OPCODE_LUSHR = 0x7d; - public static final int OPCODE_IAND = 0x7e; - public static final int OPCODE_LAND = 0x7f; - public static final int OPCODE_IOR = 0x80; - public static final int OPCODE_LOR = 0x81; - public static final int OPCODE_IXOR = 0x82; - public static final int OPCODE_LXOR = 0x83; - public static final int OPCODE_IINC = 0x84; - public static final int OPCODE_I2L = 0x85; - public static final int OPCODE_I2F = 0x86; - public static final int OPCODE_I2D = 0x87; - public static final int OPCODE_L2I = 0x88; - public static final int OPCODE_L2F = 0x89; - public static final int OPCODE_L2D = 0x8a; - public static final int OPCODE_F2I = 0x8b; - public static final int OPCODE_F2L = 0x8c; - public static final int OPCODE_F2D = 0x8d; - public static final int OPCODE_D2I = 0x8e; - public static final int OPCODE_D2L = 0x8f; - public static final int OPCODE_D2F = 0x90; - public static final int OPCODE_I2B = 0x91; - public static final int OPCODE_I2C = 0x92; - public static final int OPCODE_I2S = 0x93; - public static final int OPCODE_LCMP = 0x94; - public static final int OPCODE_FCMPL = 0x95; - public static final int OPCODE_FCMPG = 0x96; - public static final int OPCODE_DCMPL = 0x97; - public static final int OPCODE_DCMPG = 0x98; - public static final int OPCODE_IFEQ = 0x99; - public static final int OPCODE_IFNE = 0x9a; - public static final int OPCODE_IFLT = 0x9b; - public static final int OPCODE_IFGE = 0x9c; - public static final int OPCODE_IFGT = 0x9d; - public static final int OPCODE_IFLE = 0x9e; - public static final int OPCODE_IF_ICMPEQ = 0x9f; - public static final int OPCODE_IF_ICMPNE = 0xa0; - public static final int OPCODE_IF_ICMPLT = 0xa1; - public static final int OPCODE_IF_ICMPGE = 0xa2; - public static final int OPCODE_IF_ICMPGT = 0xa3; - public static final int OPCODE_IF_ICMPLE = 0xa4; - public static final int OPCODE_IF_ACMPEQ = 0xa5; - public static final int OPCODE_IF_ACMPNE = 0xa6; - public static final int OPCODE_GOTO = 0xa7; - public static final int OPCODE_JSR = 0xa8; - public static final int OPCODE_RET = 0xa9; - public static final int OPCODE_TABLESWITCH = 0xaa; - public static final int OPCODE_LOOKUPSWITCH = 0xab; - public static final int OPCODE_IRETURN = 0xac; - public static final int OPCODE_LRETURN = 0xad; - public static final int OPCODE_FRETURN = 0xae; - public static final int OPCODE_DRETURN = 0xaf; - public static final int OPCODE_ARETURN = 0xb0; - public static final int OPCODE_RETURN = 0xb1; - public static final int OPCODE_GETSTATIC = 0xb2; - public static final int OPCODE_PUTSTATIC = 0xb3; - public static final int OPCODE_GETFIELD = 0xb4; - public static final int OPCODE_PUTFIELD = 0xb5; - public static final int OPCODE_INVOKEVIRTUAL = 0xb6; - public static final int OPCODE_INVOKESPECIAL = 0xb7; - public static final int OPCODE_INVOKESTATIC = 0xb8; - public static final int OPCODE_INVOKEINTERFACE = 0xb9; - public static final int OPCODE_INVOKEDYNAMIC = 0xba; - public static final int OPCODE_NEW = 0xbb; - public static final int OPCODE_NEWARRAY = 0xbc; - public static final int OPCODE_ANEWARRAY = 0xbd; - public static final int OPCODE_ARRAYLENGTH = 0xbe; - public static final int OPCODE_ATHROW = 0xbf; - public static final int OPCODE_CHECKCAST = 0xc0; - public static final int OPCODE_INSTANCEOF = 0xc1; - public static final int OPCODE_MONITORENTER = 0xc2; - public static final int OPCODE_MONITOREXIT = 0xc3; - public static final int OPCODE_WIDE = 0xc4; - public static final int OPCODE_MULTIANEWARRAY = 0xc5; - public static final int OPCODE_IFNULL = 0xc6; - public static final int OPCODE_IFNONNULL = 0xc7; - public static final int OPCODE_GOTO_W = 0xc8; - public static final int OPCODE_JSR_W = 0xc9; - public static final int OPCODE_BREAKPOINT = 0xca; - public static final int OPCODE_IMPDEP1 = 0xfe; - public static final int OPCODE_IMPDEP2 = 0xff; - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/PaddedInstruction.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/PaddedInstruction.java deleted file mode 100644 index 02e32059..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/PaddedInstruction.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode.instructions; - -import com.drgarbage.bytecode.CountedDataInput; -import com.drgarbage.bytecode.CountedOutput; - -import java.io.IOException; - -/** - * Base class for intstructions which need a four byte padding relative - * to the start of the enclosing code of the parent Code - * attribute before reading immediate arguments. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision:395 $ - * $Id:PaddedInstruction.java 395 2008-04-03 15:08:14Z Peter Palaga $ - */ -public class PaddedInstruction extends AbstractInstruction { - - /** - Constructor. - @param opcode the opcode. - */ - public PaddedInstruction(int opcode) { - super(opcode); - } - - /** - Get the padded size in bytes of this instruction. - @param offset the offset at which this instruction is found. - @return the padded size in bytes - */ - public int getPaddedSize(int offset) { - return getLength() + paddingBytes(offset + 1); - } - - public void read(CountedDataInput in) throws IOException { - super.read(in); - - int bytesToRead = paddingBytes(in.getByteCount()); - for (int i = 0; i < bytesToRead; i++) { - in.readByte(); - } - } - - public void write(CountedOutput out) throws IOException { - super.write(out); - - int bytesToWrite = paddingBytes(out.getByteCount()); - for (int i = 0; i < bytesToWrite; i++) { - out.writeByte(0); - } - } - - private int paddingBytes(int bytesCount) { - - int bytesToPad = 4 - bytesCount % 4; - return (bytesToPad == 4) ? 0 : bytesToPad; - } -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/RetInstruction.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/RetInstruction.java deleted file mode 100644 index 97e6b0ba..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/RetInstruction.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode.instructions; - -public class RetInstruction extends ImmediateByteInstruction implements ILocalVariableIndexProvider { - - public RetInstruction(int opcode, boolean wide) { - super(opcode, wide); - } - - public RetInstruction(int opcode, boolean wide, int immediateByte) { - super(opcode, wide, immediateByte); - } - - public int getLocalVariableIndex() { - return getImmediateByte(); - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/SimpleInstruction.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/SimpleInstruction.java deleted file mode 100644 index c613009a..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/SimpleInstruction.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode.instructions; - -/** - * Describes an instructions with no immediate arguments. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision: 187 $ - * $Id: SimpleInstruction.java 187 2013-06-03 05:47:37Z salekseev $ - */ -public class SimpleInstruction extends AbstractInstruction { - - /** - Constructor. - @param opcode the opcode. - */ - public SimpleInstruction(int opcode) { - super(opcode); - } - - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/TableSwitchInstruction.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/TableSwitchInstruction.java deleted file mode 100644 index 6b2f8222..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/TableSwitchInstruction.java +++ /dev/null @@ -1,144 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode.instructions; - -import com.drgarbage.bytecode.CountedDataInput; -import com.drgarbage.bytecode.CountedOutput; - -import java.io.IOException; - -/** - * Describes the tableswitch instruction. - * - * @author Sergej Alekseev and Peter Palaga - * @version $Revision:81 $ - * $Id:TableSwitchInstruction.java 81 2007-05-10 08:38:47Z Peter Palaga $ - */ -public class TableSwitchInstruction extends PaddedInstruction { - - private int defaultOffset; - private int low; - private int high; - private int[] jumpOffsets; - - /** - Constructor. - @param opcode the opcode. - */ - public TableSwitchInstruction(int opcode) { - super(opcode); - } - - public int getLength() { - return super.getLength() + 12 + 4 * jumpOffsets.length; - } - - /** - Get the default offset of the branch of this instruction. - @return the offset - */ - public int getDefaultOffset() { - return defaultOffset; - } - - /** - Set the default offset of the branch of this instruction. - @param defaultOffset the offset - */ - public void setDefaultOffset(int defaultOffset) { - this.defaultOffset = defaultOffset; - } - - /** - Get the lower bound for the table switch. - @return the lower bound - */ - public int getLow() { - return low; - } - - /** - Set the lower bound for the table switch. - @param low the lower bound - */ - public void setLow(int low) { - this.low = low; - } - - /** - Get the upper bound for the table switch. - @return the upper bound - */ - public int getHigh() { - return high; - } - - /** - Set the upper bound for the table switch. - @param high the upper bound - */ - public void setHigh(int high) { - this.high = high; - } - - /** - Get the array of relative jump offsets for the table switch. - @return the array - */ - public int[] getJumpOffsets() { - return jumpOffsets; - } - - /** - Set the array of relative jump offsets for the table switch. - @param jumpOffsets the array - */ - public void setJumpOffsets(int[] jumpOffsets) { - this.jumpOffsets = jumpOffsets; - } - - public void read(CountedDataInput in) throws IOException { - super.read(in); - - defaultOffset = in.readInt(); - low = in.readInt(); - high = in.readInt(); - - int numberOfOffsets = high - low + 1; - jumpOffsets = new int[numberOfOffsets]; - - for (int i = 0; i < numberOfOffsets; i++) { - jumpOffsets[i] = in.readInt(); - } - - } - - public void write(CountedOutput out) throws IOException { - super.write(out); - - out.writeInt(defaultOffset); - out.writeInt(low); - out.writeInt(high); - - int numberOfOffsets = jumpOffsets.length; - - for (int i = 0; i < numberOfOffsets; i++) { - out.writeInt(jumpOffsets[i]); - } - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/XLoadStoreNInstruction.java b/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/XLoadStoreNInstruction.java deleted file mode 100644 index 3205effa..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/bytecode/instructions/XLoadStoreNInstruction.java +++ /dev/null @@ -1,138 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.bytecode.instructions; - - -/** - * Used for -iload -lload -fload -dload -aload -iload_0 -iload_1 -iload_2 -iload_3 -lload_0 -lload_1 -lload_2 -lload_3 -fload_0 -fload_1 -fload_2 -fload_3 -dload_0 -dload_1 -dload_2 -dload_3 -aload_0 -aload_1 -aload_2 -aload_3 -iaload -laload -faload -daload -aaload -baload -caload -saload - - * - * @author Peter Palaga - * - */ - -public class XLoadStoreNInstruction extends AbstractInstruction implements ILocalVariableIndexProvider { - - - public static class XLoadInstruction extends ImmediateByteInstruction implements ILocalVariableIndexProvider { - - public XLoadInstruction(int opcode, boolean wide, int immediateByte) { - super(opcode, wide, immediateByte); - } - - public XLoadInstruction(int opcode, boolean wide) { - super(opcode, wide); - } - - public int getLocalVariableIndex() { - return getImmediateByte(); - } - - } - public static class XStoreInstruction extends ImmediateByteInstruction implements ILocalVariableIndexProvider { - - public XStoreInstruction(int opcode, boolean wide, int immediateByte) { - super(opcode, wide, immediateByte); - } - - public XStoreInstruction(int opcode, boolean wide) { - super(opcode, wide); - } - - public int getLocalVariableIndex() { - return getImmediateByte(); - } - - } - public static class XLoadNInstruction extends XLoadStoreNInstruction { - - public XLoadNInstruction(int opcode) { - super(opcode); - } - - public XLoadNInstruction(int opcode, int localVariableIndex) { - super(opcode, localVariableIndex); - } - - } - public static class XStoreNInstruction extends XLoadStoreNInstruction { - - public XStoreNInstruction(int opcode) { - super(opcode); - } - - public XStoreNInstruction(int opcode, int localVariableIndex) { - super(opcode, localVariableIndex); - } - - } - - protected int localVariableIndex = INVALID_INDEX; - - /** - * @param opcode - */ - public XLoadStoreNInstruction(int opcode) { - super(opcode); - } - - public XLoadStoreNInstruction(int opcode, int localVariableIndex) { - super(opcode); - this.localVariableIndex = localVariableIndex; - } - - /* (non-Javadoc) - * @see com.drgarbage.classfile.opcodes.LocalVariableIndexProvider#getLocalVariableIndex() - */ - public int getLocalVariableIndex() { - return localVariableIndex; - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/classfile/editors/ClassFileParser.java b/org.sf.feeling.decompiler/src/com/drgarbage/classfile/editors/ClassFileParser.java deleted file mode 100644 index 8bc2cf75..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/classfile/editors/ClassFileParser.java +++ /dev/null @@ -1,916 +0,0 @@ -/** - * Copyright (c) 2008-2013, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.classfile.editors; - -import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.text.ParseException; - -import com.drgarbage.asm.ClassReader; -import com.drgarbage.asm_ext.IConstantPoolVisitor; -import com.drgarbage.bytecode.BytecodeUtils; -import com.drgarbage.bytecode.ConstantPoolParser; -import com.drgarbage.bytecode.constant_pool.AbstractConstantPoolEntry; -import com.drgarbage.bytecode.constant_pool.ConstantUtf8Info; - -/** - * The class file parser to generate a readable representation from the class file. - * - * @author Sergej Alekseev - * @version $Revision: 515 $ $Id: ClassFileParser.java 515 2014-02-05 07:54:26Z - * salekseev $ - */ -public class ClassFileParser -{ - /** bytes of the class file */ - private byte[] bytes = null; - - /** global offset of the current position in the byte array */ - private int offset = -1; - - /** Array of the constant pool entries */ - private AbstractConstantPoolEntry[] constantPool; - - private String _12_BYTES = " "; - private String _14_BYTES = " "; - private String _16_BYTES = " "; - - /** - * Creates a class file representation. - * - * @param bytes - * @return the text representation of the class file - * @throws ParseException - */ - public String parseClassFile( byte[] bytes ) throws ParseException - { - this.bytes = bytes; - StringBuffer buf = new StringBuffer( ); - try - { - ClassReader cr = new ClassReader( bytes, 0, bytes.length, new ConstantPoolVisitor( ) ); - /* - * ClassFile { u4 magic; u2 minor_version; u2 major_version; u2 - * constant_pool_count; cp_info - * constant_pool[constant_pool_count-1]; u2 access_flags; u2 - * this_class; u2 super_class; u2 interfaces_count; u2 - * interfaces[interfaces_count]; u2 fields_count; field_info - * fields[fields_count]; u2 methods_count; method_info - * methods[methods_count]; u2 attributes_count; attribute_info - * attributes[attributes_count]; } - */ - offset = 0; - - buf.append( appendBytes( offset, offset + 4 ) ); - offset = offset + 4; - buf.append( _12_BYTES ); - buf.append( "/* u4 magic */" ); - buf.append( '\n' ); - - buf.append( appendBytes( offset, offset + 2 ) ); - int minor = cr.readUnsignedShort( offset ); - offset = offset + 2; - buf.append( _14_BYTES ); - buf.append( "/* u2 minor_version=" ); - buf.append( minor ); - buf.append( " */" ); - buf.append( '\n' ); - - buf.append( appendBytes( offset, offset + 2 ) ); - int major = cr.readUnsignedShort( offset ); - offset = offset + 2; - buf.append( _14_BYTES ); - buf.append( "/* u2 major_version=" ); - buf.append( major ); - buf.append( " */" ); - buf.append( '\n' ); - - buf.append( _16_BYTES ); - buf.append( "/* java " ); - buf.append( BytecodeUtils.getLowestJavaPlatformVersion( major, minor ) ); - buf.append( " */" ); - buf.append( '\n' ); - buf.append( '\n' ); - - buf.append( appendBytes( offset, offset + 2 ) ); - offset = offset + 2; - buf.append( _14_BYTES ); - buf.append( "/* u2 constant_pool_count=" ); - buf.append( cr.getItemCount( ) ); - buf.append( " */" ); - buf.append( '\n' ); - - buf.append( constantPoolToString( ) ); - buf.append( '\n' ); - - buf.append( appendBytes( offset, offset + 2 ) ); - offset = offset + 2; - buf.append( _14_BYTES ); - buf.append( "/* u2 access_flags: " ); - buf.append( cr.getAccess( ) ); - buf.append( " */" ); - buf.append( '\n' ); - - buf.append( appendBytes( offset, offset + 2 ) ); - offset = offset + 2; - buf.append( _14_BYTES ); - buf.append( "/* u2 this_class: " ); - buf.append( cr.getClassName( ) ); - buf.append( " */" ); - buf.append( '\n' ); - - buf.append( appendBytes( offset, offset + 2 ) ); - offset = offset + 2; - buf.append( _14_BYTES ); - buf.append( "/* u2 super_class: " ); - buf.append( cr.getSuperName( ) ); - buf.append( " */" ); - buf.append( '\n' ); - - /* interfaces */ - buf.append( '\n' ); - buf.append( _16_BYTES ); - buf.append( "/* Interfaces: */" ); - buf.append( '\n' ); - - buf.append( appendBytes( offset, offset + 2 ) ); - offset = offset + 2; - buf.append( _14_BYTES ); - buf.append( "/* u2 interfaces_count=" ); - buf.append( cr.getInterfaces( ).length ); - buf.append( " */" ); - buf.append( '\n' ); - - buf.append( appendInterfaces( cr.getInterfaces( ) ) ); - buf.append( '\n' ); - buf.append( '\n' ); - - /* fields */ - buf.append( _16_BYTES ); - buf.append( "/* Fields: */" ); - buf.append( '\n' ); - - buf.append( appendBytes( offset, offset + 2 ) ); - int count = cr.readUnsignedShort( offset ); - offset = offset + 2; - buf.append( _14_BYTES ); - buf.append( "/* u2 fields_count=" ); - buf.append( count ); - buf.append( " */" ); - buf.append( '\n' ); - - /* - * field_info { u2 access_flags; u2 name_index; u2 descriptor_index; - * u2 attributes_count; attribute_info attributes[attributes_count]; - * } - */ - - for ( int i = 0; i < count; i++ ) - { - buf.append( _16_BYTES ); - buf.append( "/* Field[" ); - buf.append( i ); - buf.append( ']' ); - buf.append( " */" ); - buf.append( '\n' ); - - buf.append( appendBytes( offset, offset + 2 ) ); - int access_flags = cr.readUnsignedShort( offset ); - offset += 2; - buf.append( _14_BYTES ); - buf.append( "/* u2 access_flags=" ); - buf.append( access_flags ); - buf.append( " */" ); - buf.append( '\n' ); - - buf.append( appendBytes( offset, offset + 2 ) ); - int name_index = cr.readUnsignedShort( offset ); - offset += 2; - buf.append( _14_BYTES ); - buf.append( "/* u2 name_index=" ); - buf.append( name_index ); - buf.append( ", " ); - buf.append( constantPool[name_index].getInfo( ) ); - buf.append( " */" ); - buf.append( '\n' ); - - buf.append( appendBytes( offset, offset + 2 ) ); - int descriptor_index = cr.readUnsignedShort( offset ); - offset += 2; - buf.append( _14_BYTES ); - buf.append( "/* u2 descriptor_index=" ); - buf.append( descriptor_index ); - buf.append( ", " ); - buf.append( constantPool[descriptor_index].getInfo( ) ); - buf.append( " */" ); - buf.append( '\n' ); - - buf.append( appendBytes( offset, offset + 2 ) ); - int attributes_count = cr.readUnsignedShort( offset ); - offset += 2; - buf.append( _14_BYTES ); - buf.append( "/* u2 attributes_count=" ); - buf.append( attributes_count ); - buf.append( " */" ); - buf.append( '\n' ); - - /* - * attribute_info { u2 attribute_name_index; u4 - * attribute_length; u1 info[attribute_length]; } - */ - for ( int j = 0; j < attributes_count; j++ ) - { - buf.append( appendBytes( offset, offset + 2 ) ); - int attribute_name_index = cr.readUnsignedShort( offset ); - offset += 2; - buf.append( _14_BYTES ); - buf.append( "/* u2 attribute_name_index=" ); - buf.append( attribute_name_index ); - buf.append( ", " ); - buf.append( constantPool[attribute_name_index].getInfo( ) ); - buf.append( " */" ); - buf.append( '\n' ); - - buf.append( appendBytes( offset, offset + 4 ) ); - int attribute_length = cr.readInt( offset ); - offset += 4; - buf.append( _12_BYTES ); - buf.append( "/* u4 attribute_length=" ); - buf.append( attribute_length ); - buf.append( " */" ); - buf.append( '\n' ); - - buf.append( _16_BYTES ); - buf.append( "/* Attribute bytes: */" ); - buf.append( '\n' ); - buf.append( appendBytes( offset, offset + attribute_length ) ); - offset += attribute_length; - buf.append( '\n' ); - } - } - buf.append( '\n' ); - - /* methods */ - buf.append( _16_BYTES ); - buf.append( "/* Methods: */" ); - buf.append( '\n' ); - - buf.append( appendBytes( offset, offset + 2 ) ); - int methods_count = cr.readUnsignedShort( offset ); - offset = offset + 2; - buf.append( _14_BYTES ); - buf.append( "/* u2 methods_count=" ); - buf.append( methods_count ); - buf.append( " */" ); - buf.append( '\n' ); - - /* - * method_info { u2 access_flags; u2 name_index; u2 - * descriptor_index; u2 attributes_count; attribute_info - * attributes[attributes_count]; } - */ - - for ( int i = 0; i < methods_count; i++ ) - { - buf.append( _16_BYTES ); - buf.append( "/* Method[" ); - buf.append( i ); - buf.append( ']' ); - buf.append( " */" ); - buf.append( '\n' ); - - buf.append( appendBytes( offset, offset + 2 ) ); - int access_flags = cr.readUnsignedShort( offset ); - offset += 2; - buf.append( _14_BYTES ); - buf.append( "/* u2 access_flags=" ); - buf.append( access_flags ); - buf.append( " */" ); - buf.append( '\n' ); - - buf.append( appendBytes( offset, offset + 2 ) ); - int name_index = cr.readUnsignedShort( offset ); - offset += 2; - buf.append( _14_BYTES ); - buf.append( "/* u2 name_index=" ); - buf.append( name_index ); - buf.append( ", " ); - buf.append( constantPool[name_index].getInfo( ) ); - buf.append( " */" ); - buf.append( '\n' ); - - buf.append( appendBytes( offset, offset + 2 ) ); - int descriptor_index = cr.readUnsignedShort( offset ); - offset += 2; - buf.append( _14_BYTES ); - buf.append( "/* u2 descriptor_index=" ); - buf.append( descriptor_index ); - buf.append( ", " ); - buf.append( constantPool[descriptor_index].getInfo( ) ); - buf.append( " */" ); - buf.append( '\n' ); - - buf.append( appendBytes( offset, offset + 2 ) ); - int attributes_count = cr.readUnsignedShort( offset ); - offset += 2; - buf.append( _14_BYTES ); - buf.append( "/* u2 attributes_count=" ); - buf.append( attributes_count ); - buf.append( " */" ); - buf.append( '\n' ); - - /* - * attribute_info { u2 attribute_name_index; u4 - * attribute_length; u1 info[attribute_length]; } - */ - for ( int j = 0; j < attributes_count; j++ ) - { - buf.append( _16_BYTES ); - buf.append( "/* Attribute[" ); - buf.append( j ); - buf.append( ']' ); - buf.append( " */" ); - buf.append( '\n' ); - - buf.append( appendBytes( offset, offset + 2 ) ); - int attribute_name_index = cr.readUnsignedShort( offset ); - offset += 2; - buf.append( _14_BYTES ); - buf.append( "/* u2 attribute_name_index=" ); - buf.append( attribute_name_index ); - buf.append( ", " ); - boolean codeAttribute = false; - if ( constantPool[attribute_name_index] instanceof ConstantUtf8Info ) - { - String utf8String = ( (ConstantUtf8Info) constantPool[attribute_name_index] ).getString( ); - if ( utf8String.equals( "Code" ) ) - { - codeAttribute = true; - } - } - buf.append( constantPool[attribute_name_index].getInfo( ) ); - buf.append( " */" ); - buf.append( '\n' ); - - buf.append( appendBytes( offset, offset + 4 ) ); - int attribute_length = cr.readInt( offset ); - offset += 4; - buf.append( _12_BYTES ); - buf.append( "/* u4 attribute_length=" ); - buf.append( attribute_length ); - buf.append( " */" ); - buf.append( '\n' ); - buf.append( _16_BYTES ); - buf.append( "/* Attribute bytes: */" ); - buf.append( '\n' ); - - if ( codeAttribute ) - { - /* - * Code_attribute { u2 attribute_name_index; u4 - * attribute_length; u2 max_stack; u2 max_locals; u4 - * code_length; u1 code[code_length]; u2 - * exception_table_length; { u2 start_pc; u2 end_pc; u2 - * handler_pc; u2 catch_type; } - * exception_table[exception_table_length]; u2 - * attributes_count; attribute_info - * attributes[attributes_count]; } - */ - buf.append( _16_BYTES ); - buf.append( "/* Code_attribute: */" ); - buf.append( '\n' ); - - buf.append( appendBytes( offset, offset + 2 ) ); - int max_stack = cr.readUnsignedShort( offset ); - offset += 2; - buf.append( _14_BYTES ); - buf.append( "/* u2 max_stack=" ); - buf.append( max_stack ); - buf.append( " */" ); - buf.append( '\n' ); - - buf.append( appendBytes( offset, offset + 2 ) ); - int max_locals = cr.readUnsignedShort( offset ); - offset += 2; - buf.append( _14_BYTES ); - buf.append( "/* u2 max_locals=" ); - buf.append( max_locals ); - buf.append( " */" ); - buf.append( '\n' ); - - buf.append( appendBytes( offset, offset + 4 ) ); - int code_length = cr.readInt( offset ); - offset += 4; - buf.append( _12_BYTES ); - buf.append( "/* u4 code_length=" ); - buf.append( code_length ); - buf.append( " */" ); - buf.append( '\n' ); - - buf.append( _16_BYTES ); - buf.append( "/* Code instructions: */" ); - buf.append( '\n' ); - - buf.append( appendBytes( offset, offset + code_length ) ); - offset += code_length; - buf.append( '\n' ); - - /* exception_table */ - buf.append( appendBytes( offset, offset + 2 ) ); - int exception_table_length = cr.readUnsignedShort( offset ); - offset += 2; - buf.append( _14_BYTES ); - buf.append( "/* u2 exception_table_length=" ); - buf.append( exception_table_length ); - buf.append( " */" ); - buf.append( '\n' ); - - for ( int e = 0; e < exception_table_length; e++ ) - { - /* - * u2 start_pc; u2 end_pc; u2 handler_pc; u2 - * catch_type; - */ - buf.append( appendBytes( offset, offset + 4 ) ); - int start_pc = cr.readUnsignedShort( offset ); - offset += 2; - int end_pc = cr.readUnsignedShort( offset ); - offset += 2; - buf.append( _12_BYTES ); - buf.append( "/* u2 start_pc=" ); - buf.append( start_pc ); - buf.append( " u2 end_pc=" ); - buf.append( end_pc ); - buf.append( " */" ); - buf.append( '\n' ); - - buf.append( appendBytes( offset, offset + 4 ) ); - int handler_pc = cr.readUnsignedShort( offset ); - offset += 2; - int catch_type = cr.readUnsignedShort( offset ); - offset += 2; - buf.append( _12_BYTES ); - buf.append( "/* u2 handler_pc=" ); - buf.append( handler_pc ); - buf.append( " u2 catch_type=" ); - buf.append( catch_type ); - buf.append( " */" ); - buf.append( '\n' ); - } - - buf.append( appendBytes( offset, offset + 2 ) ); - int code_attributes_count = cr.readUnsignedShort( offset ); - offset += 2; - buf.append( _14_BYTES ); - buf.append( "/* u2 attributes_count=" ); - buf.append( code_attributes_count ); - buf.append( " */" ); - buf.append( '\n' ); - - /* - * attribute_info { u2 attribute_name_index; u4 - * attribute_length; u1 info[attribute_length]; } - */ - for ( int cj = 0; cj < code_attributes_count; cj++ ) - { - buf.append( appendBytes( offset, offset + 2 ) ); - int code_attribute_name_index = cr.readUnsignedShort( offset ); - offset += 2; - buf.append( _14_BYTES ); - buf.append( "/* u2 attribute_name_index=" ); - buf.append( code_attribute_name_index ); - buf.append( ", " ); - buf.append( constantPool[code_attribute_name_index].getInfo( ) ); - buf.append( " */" ); - buf.append( '\n' ); - - buf.append( appendBytes( offset, offset + 4 ) ); - int code_attribute_length = cr.readInt( offset ); - offset += 4; - buf.append( _12_BYTES ); - buf.append( "/* u4 attribute_length=" ); - buf.append( code_attribute_length ); - buf.append( " */" ); - buf.append( '\n' ); - - buf.append( _16_BYTES ); - buf.append( "/* Attribute bytes: */" ); - buf.append( '\n' ); - buf.append( appendBytes( offset, offset + code_attribute_length ) ); - offset += code_attribute_length; - buf.append( '\n' ); - } - codeAttribute = false; - } - else - { - buf.append( appendBytes( offset, offset + attribute_length ) ); - offset += attribute_length; - } - buf.append( '\n' ); - } - } - buf.append( '\n' ); - - /* class attrinutes */ - buf.append( appendBytes( offset, offset + 2 ) ); - int class_attributes_count = cr.readUnsignedShort( offset ); - offset += 2; - buf.append( _14_BYTES ); - buf.append( "/* u2 attributes_count=" ); - buf.append( class_attributes_count ); - buf.append( " */" ); - buf.append( '\n' ); - - /* - * attribute_info { u2 attribute_name_index; u4 attribute_length; u1 - * info[attribute_length]; } - */ - for ( int j = 0; j < class_attributes_count; j++ ) - { - buf.append( appendBytes( offset, offset + 2 ) ); - int attribute_name_index = cr.readUnsignedShort( offset ); - offset += 2; - buf.append( _14_BYTES ); - buf.append( "/* u2 attribute_name_index=" ); - buf.append( attribute_name_index ); - buf.append( ", " ); - buf.append( constantPool[attribute_name_index].getInfo( ) ); - buf.append( " */" ); - buf.append( '\n' ); - - buf.append( appendBytes( offset, offset + 4 ) ); - int attribute_length = cr.readInt( offset ); - offset += 4; - buf.append( _12_BYTES ); - buf.append( "/* u4 attribute_length=" ); - buf.append( attribute_length ); - buf.append( " */" ); - buf.append( '\n' ); - - buf.append( _16_BYTES ); - buf.append( "/* Attribute bytes: */" ); - buf.append( '\n' ); - buf.append( appendBytes( offset, offset + attribute_length ) ); - offset += attribute_length; - buf.append( '\n' ); - } - - buf.append( "/* end of the class file */" ); - - /* rest - should always be empty */ - buf.append( appendBytes( offset, bytes.length ) ); - } - catch ( ArrayIndexOutOfBoundsException e ) - { - buf.append( '\n' ); - buf.append( e ); - buf.append( '\n' ); - StackTraceElement[] stackTraceElement = e.getStackTrace( ); - for ( StackTraceElement ste : stackTraceElement ) - { - buf.append( ste ); - buf.append( '\n' ); - } - buf.append( '\n' ); - } - - return buf.toString( ); - } - - /** - * Creates a string as a representation of the constant pool bytes. - * - * @return the string represented the constant pool bytes - * @throws ParseException - */ - private String constantPoolToString( ) throws ParseException - { - StringBuffer buf = new StringBuffer( ); - for ( int i = 0; i < constantPool.length; i++ ) - { - AbstractConstantPoolEntry en = constantPool[i]; - boolean appendConstantPoolinfo = true; - if ( en != null ) - { - try - { - ByteArrayOutputStream os = new ByteArrayOutputStream( ); - DataOutputStream dos = new DataOutputStream( os ); - en.write( dos ); - - byte byteArray[] = os.toByteArray( ); - int j = 1; - for ( ; j <= byteArray.length; j++ ) - { - buf.append( String.format( "%02X", byteArray[( j - 1 )] ) ); - if ( ( j % 16 ) == 0 ) - { - if ( appendConstantPoolinfo ) - { - buf.append( ' ' ); - appendConstantPoolEntryInfo( buf, en, i ); - appendConstantPoolinfo = false; - } - buf.append( '\n' ); - } - else - { - buf.append( ' ' ); - } - } - int rest = j % 16; - if ( rest != 0 ) - { - for ( j = 0; j < ( 16 - rest + 1 ) * 3; j++ ) - { - buf.append( ' ' ); - } - } - else - { - buf.append( " " ); - } - - offset = offset + byteArray.length; - - if ( appendConstantPoolinfo ) - { - appendConstantPoolEntryInfo( buf, en, i ); - appendConstantPoolinfo = false; - } - buf.append( '\n' ); - - } - catch ( IOException e ) - { - throw new ParseException( "Constant pool entry could not be parsed.", i ); - } - } - } - - return buf.toString( ); - } - - private void appendConstantPoolEntryInfo( StringBuffer buf, AbstractConstantPoolEntry en, int i ) - { - buf.append( " /* [" ); - buf.append( String.valueOf( i ) ); - buf.append( "] " ); - buf.append( en.getTagMnemonics( ) ); - buf.append( ' ' ); - buf.append( en.getInfo( ) ); - buf.append( ' ' ); - buf.append( "*/" ); - } - - /** - * Creates a string representation of interface bytes. - * - * @param interafaces - * @return string - */ - private String appendInterfaces( String[] interafaces ) - { - StringBuffer buf = new StringBuffer( ); - for ( String i : interafaces ) - { - buf.append( appendBytes( offset, offset + 2 ) ); - offset = offset + 2; - - buf.append( _14_BYTES ); - buf.append( "/* " ); - buf.append( i ); - buf.append( " */ " ); - } - - return buf.toString( ); - } - - /** - * Creates a string representation of bytes. - * - * @param start - * offset - * @param end - * offset - * @return string - */ - private String appendBytes( int start, int end ) - { - StringBuffer buf = new StringBuffer( ); - for ( int i = start, c = 1; i < end; i++, c++ ) - { - String s = String.format( "%02X", bytes[i] ); - buf.append( s ); - if ( ( c % 16 ) == 0 ) - { - buf.append( '\n' ); - } - else - { - buf.append( ' ' ); - } - } - - return buf.toString( ); - } - - /** - * Simple constant pool visitor. - */ - class ConstantPoolVisitor implements IConstantPoolVisitor - { - - /* - * (non-Javadoc) - * - * @see - * com.drgarbage.asm_ext.IConstantPoolVisitor#visitConstantPool(byte[], - * int, int) - */ - public void visitConstantPool( final byte[] bytes, int offset, int entryCount ) - { - if ( bytes == null || entryCount == 0 ) - { - constantPool = null; - } - else - { - ConstantPoolParser cpp = new ConstantPoolParser( bytes, offset, entryCount ); - constantPool = cpp.parse( ); - } - } - } - - /** - * Converts the content of the string to a byte array. The multiline - * comments are ignored. - * - * @param s - * string - * @return byte array - * @throws ParseException - */ - public static byte[] getClasFileBytesFromString( String s ) throws ParseException - { - char charArray[] = s.toCharArray( ); - char charArray2[] = new char[charArray.length + 1]; - int j = 0; - for ( int i = 0; i < charArray.length; i++ ) - { - if ( charArray[i] == '/' ) - { - if ( charArray[i + 1] == '/' ) - { /* line comment */ - i++; - i++; - for ( ; i < charArray.length; i++ ) - { /* loop until the end of the line */ - if ( charArray[i] == '\n' ) - { - break; - } - } - } - else if ( charArray[i + 1] == '*' ) - { /* line comment */ - i++; - i++; - for ( ; i < charArray.length; i++ ) - { /* loop until the end of the comment */ - if ( charArray[i] == '*' ) - { - if ( charArray[i + 1] == '/' ) - { - i++; - break; - } - } - } - } - else - { /* unexpected character */ - throw new ParseException( "Unexpected character.", i ); - } - } - - if ( ( charArray[i] >= '0' && charArray[i] <= '9' ) /* - * only - * numerical - * characters - */ - || ( charArray[i] >= 'A' && charArray[i] <= 'F' ) /* - * A, B, - * C, D, - * E, F - */ - || ( charArray[i] >= 'a' - && charArray[i] <= 'f' ) /* a, b, c , d, f */ - ) - { - charArray2[j] = charArray[i]; - j++; - } - } - - /* the number of characters has to be always an even number */ - if ( j % 2 != 0 ) - { - throw new ParseException( "The number of byte characters is not an even number.", j ); - } - - charArray2[j++] = '\0'; /* set the end of the string */ - - /* copy the character array to the byte array */ - byte bytes[] = new byte[( j - 1 ) / 2]; - int b = 0; - for ( int i = 0; i < charArray2.length; i++ ) - { - if ( charArray2[i] == '\0' ) - { - break; - } - - char c1 = convertCharToDec( charArray2[i] ); - char c2 = convertCharToDec( charArray2[++i] ); - - byte bb = (byte) ( ( c1 << 4 ) + c2 ); - bytes[b] = bb; - b++; - } - - return bytes; - } - - /** - * Convert a character into byte. - * - * @param c - * is a character one of 0 ... 9, A ... F - * @return decimal value - */ - public static char convertCharToDec( char c ) - { - - switch ( c ) - { - case '0' : - return 0; - case '1' : - return 1; - case '2' : - return 2; - case '3' : - return 3; - case '4' : - return 4; - case '5' : - return 5; - case '6' : - return 6; - case '7' : - return 7; - case '8' : - return 8; - case '9' : - return 9; - case 'A' : - case 'a' : - return 10; - case 'B' : - case 'b' : - return 11; - case 'C' : - case 'c' : - return 12; - case 'D' : - case 'd' : - return 13; - case 'E' : - case 'e' : - return 14; - case 'F' : - case 'f' : - return 15; - } - - return 0; - } - -} \ No newline at end of file diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/javalang/JavaLangUtils.java b/org.sf.feeling.decompiler/src/com/drgarbage/javalang/JavaLangUtils.java deleted file mode 100644 index 93fcc8ac..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/javalang/JavaLangUtils.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * Copyright (c) 2008-2013, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.javalang; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.launching.JavaRuntime; - -/** - * The collection of java utility methods. - * - * @author Sergej Alekseev - * @version $Revision: 426 $ - * $Id: JavaLangUtils.java 426 2013-11-29 14:47:54Z salekseev $ - */ -public class JavaLangUtils { - - public static File findFileResource(String[] classPath, String packageName, String className) throws IOException { - if(packageName == null){ - packageName= ""; - } - String relativePath = packageName.replace('.', File.separatorChar) + (packageName.length() == 0 ? "" : File.separator) + className + ".class"; - for (int i = 0; i < classPath.length; i++) { - File currentClassPathEntry = new File(classPath[i]); - if (!currentClassPathEntry.exists()) { - continue; - } - if (currentClassPathEntry.isDirectory()) { - File file = new File(currentClassPathEntry, relativePath); - if (file.exists()) { - return file; - } - } else if (currentClassPathEntry.isFile()) { - /* not supported, just ignore */ - } - } - return null; - } - - public static InputStream findResource(String[] classPath, String packageName, String className) throws IOException { - if(packageName == null){ - packageName= ""; - } - String relativePath = packageName.replace('.', File.separatorChar) + (packageName.length() == 0 ? "" : File.separator) + className + ".class"; - String jarRelativePath = relativePath.replace(File.separatorChar, '/'); - for (int i = 0; i < classPath.length; i++) { - File currentClassPathEntry = new File(classPath[i]); - if (!currentClassPathEntry.exists()) { - continue; - } - if (currentClassPathEntry.isDirectory()) { - File file = new File(currentClassPathEntry, relativePath); - if (file.exists()) { - return new FileInputStream(file); - } - } else if (currentClassPathEntry.isFile()) { - JarFile jarFile = null; - jarFile = new JarFile(currentClassPathEntry); - JarEntry jarEntry = jarFile.getJarEntry(jarRelativePath); - if (jarEntry != null) { - return jarFile.getInputStream(jarEntry); - } - else { - if (jarFile != null) { - jarFile.close(); - } - } - } - } - return null; - } - - public static String[] computeRuntimeClassPath(IJavaProject jp) throws CoreException{ - if(jp == null){ - return null; - } - - String[] classpath = JavaRuntime.computeDefaultRuntimeClassPath(jp); - return classpath; - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/javalang/JavalangConstants.java b/org.sf.feeling.decompiler/src/com/drgarbage/javalang/JavalangConstants.java deleted file mode 100644 index 0eb7880d..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/javalang/JavalangConstants.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.javalang; - -public interface JavalangConstants { - public static final String UTF_8 = "UTF-8"; -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/javasrc/JavaAnnotations.java b/org.sf.feeling.decompiler/src/com/drgarbage/javasrc/JavaAnnotations.java deleted file mode 100644 index 359a7432..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/javasrc/JavaAnnotations.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.javasrc; - -/** - * Java Annotations. - * - * @author Peter Palaga - * @version $Revision: 187 $ - * $Id: JavaAnnotations.java 187 2013-06-03 05:47:37Z salekseev $ - */ -public class JavaAnnotations { - public static final String DEPRECATED = "Deprecated"; -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/javasrc/JavaCodeAttributes.java b/org.sf.feeling.decompiler/src/com/drgarbage/javasrc/JavaCodeAttributes.java deleted file mode 100644 index 57a085d5..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/javasrc/JavaCodeAttributes.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.javasrc; - -/** - * Java Code Attributes. - * - * @author Sergej Alekseev - * @version $Revision: 187 $ - * $Id: JavaCodeAttributes.java 187 2013-06-03 05:47:37Z salekseev $ - */ -public class JavaCodeAttributes { - public static final String LINE_NUMBER_TABLE = "LineNumberTable"; - public static final String START_PC = "start_pc"; - public static final String LINE_NUMBER = "line"; - public static final String LOCAL_VARIABLE_TABLE = "LocalVariableTable"; - public static final String INDEX = "index"; - public static final String LENGTH = "length"; - public static final String NAME = "name"; - public static final String TYPE = "type"; - public static final String UNAVAILABLE = "unavailable"; -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/javasrc/JavaKeywords.java b/org.sf.feeling.decompiler/src/com/drgarbage/javasrc/JavaKeywords.java deleted file mode 100644 index 6cd7e175..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/javasrc/JavaKeywords.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.javasrc; - -/** - * Java Keywords. - * - * @author Peter Palaga - * @version $Revision: 187 $ - * $Id: JavaKeywords.java 187 2013-06-03 05:47:37Z salekseev $ - */ -public interface JavaKeywords { - public static final String ABSTRACT = "abstract"; - public static final String ASSERT = "assert"; - public static final String BOOLEAN = "boolean"; - public static final String BREAK = "break"; - public static final String BYTE = "byte"; - public static final String CASE = "case"; - public static final String CATCH = "catch"; - public static final String CHAR = "char"; - public static final String CLASS = "class"; - public static final String CONST = "const"; - public static final String CONTINUE = "continue"; - public static final String DEFAULT = "default"; - public static final String DO = "do"; - public static final String DOUBLE = "double"; - public static final String ELSE = "else"; - public static final String ENUM = "enum"; - public static final String EXTENDS = "extends"; - public static final String FALSE = "false"; - public static final String FINAL = "final"; - public static final String FINALLY = "finally"; - public static final String FLOAT = "float"; - public static final String FOR = "for"; - public static final String GOTO = "goto"; - public static final String IF = "if"; - public static final String IMPLEMENTS = "implements"; - public static final String IMPORT = "import"; - public static final String INSTANCEOF = "instanceof"; - public static final String INT = "int"; - public static final String INTERFACE = "interface"; - public static final String LONG = "long"; - public static final String NATIVE = "native"; - public static final String NEW = "new"; - public static final String NULL = "null"; - public static final String PACKAGE = "package"; - public static final String PRIVATE = "private"; - public static final String PROTECTED = "protected"; - public static final String PUBLIC = "public"; - public static final String RETURN = "return"; - public static final String SHORT = "short"; - public static final String STATIC = "static"; - public static final String STRICTFP = "strictfp"; - public static final String SUPER = "super"; - public static final String SWITCH = "switch"; - public static final String SYNCHRONIZED = "synchronized"; - public static final String THIS = "this"; - public static final String THROW = "throw"; - public static final String THROWS = "throws"; - public static final String TRANSIENT = "transient"; - public static final String TRUE = "true"; - public static final String TRY = "try"; - public static final String VOID = "void"; - public static final String VOLATILE = "volatile"; - public static final String WHILE = "while"; - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/javasrc/JavaLexicalConstants.java b/org.sf.feeling.decompiler/src/com/drgarbage/javasrc/JavaLexicalConstants.java deleted file mode 100644 index 38ee5284..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/javasrc/JavaLexicalConstants.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.javasrc; - -/** - * Lexical Constants. - * - * @author Peter Palaga - * @version $Revision: 187 $ - * $Id: JavaLexicalConstants.java 187 2013-06-03 05:47:37Z salekseev $ - */ -public interface JavaLexicalConstants { - - public static final char DOT = '.'; - public static final char SEMICOLON = ';'; - public static final char COLON = ':'; - public static final char SPACE = ' '; - public static final char NEWLINE = '\n'; - public static final char LEFT_BRACE = '{'; - public static final char RIGHT_BRACE = '}'; - public static final char LEFT_PARENTHESIS = '('; - public static final char RIGHT_PARENTHESIS = ')'; - public static final char COMMA = ','; - public static final char QUESTION_MARK = '?'; - public static final char EXCLAMATION_MARK = '!'; - public static final char PIPE = '|'; - public static final char AMPERSAND = '&'; - public static final char TILDE = '~'; - public static final char CARET = '^'; - public static final char PERCENT = '&'; - - - - public static char SLASH = '/'; - public static char BACKSLASH = '\\'; - public static char PLUS = '+'; - public static char MINUS = '-'; - public static char ASTERISK = '*'; - public static char LT = '<'; - public static char GT = '>'; - - public static final char AT = '@'; - public static final String COMMENT_BEGIN = "/*"; - public static final String COMMENT_BEGIN_JAVA_DOC = "/**"; - public static final String COMMENT_END = "*/"; - public static final char EQUALS = '='; - public static final char LEFT_SQUARE_BRACKET = '['; - public static final char RIGHT_SQUARE_BRACKET = ']'; - public static final char QUOTE = '"'; -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/javasrc/JavaSourceConstants.java b/org.sf.feeling.decompiler/src/com/drgarbage/javasrc/JavaSourceConstants.java deleted file mode 100644 index 5ccebc8d..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/javasrc/JavaSourceConstants.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.javasrc; - -public interface JavaSourceConstants { - public static final String JAVA_LANG_OBJECT = "java.lang.Object"; - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/javasrc/JavaSourceUtils.java b/org.sf.feeling.decompiler/src/com/drgarbage/javasrc/JavaSourceUtils.java deleted file mode 100644 index e5618e08..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/javasrc/JavaSourceUtils.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.javasrc; - -public class JavaSourceUtils { - - - public static String getSimpleName(String fullName) { - if (fullName != null) { - int i = fullName.lastIndexOf(JavaLexicalConstants.DOT); - if (i >= 0) { - return fullName.substring(i+1); - } - } - return fullName; - } - - public static String getPackage(String fullClassName) { - if (fullClassName != null) { - int i = fullClassName.lastIndexOf(JavaLexicalConstants.DOT); - if (i >= 0) { - return fullClassName.substring(0, i); - } - } - return null; - } - -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/utils/ActionUtils.java b/org.sf.feeling.decompiler/src/com/drgarbage/utils/ActionUtils.java deleted file mode 100644 index a1276af2..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/utils/ActionUtils.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Copyright (c) 2008-2012, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.utils; - -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.Signature; - -/** - * Utils for control flow factory actions. - * - * @author Sergej Alekseev - * @version $Revision: 187 $ - * $Id: ActionUtils.java 187 2013-06-03 05:47:37Z salekseev $ - */ -public class ActionUtils { - - /** - * Resolves a type name in the context of the declaring type. - * - * @param refTypeSig the type name in signature notation (for example 'QVector') this can also be an array type, but dimensions will be ignored. - * @param declaringType the context for resolving (type where the reference was made in) - * @return returns the fully qualified type name or build-in-type name. if a unresolved type couldn't be resolved null is returned - */ - public static String getResolvedTypeName(String refTypeSig, IType declaringType) throws JavaModelException, IllegalArgumentException { - int arrayCount= Signature.getArrayCount(refTypeSig); - - /* - * use the last element for resolving the type - * For example: QString [QString or [[QString - * The last element is always 'Q' - */ - char type= refTypeSig.charAt(arrayCount); - if (type == Signature.C_UNRESOLVED) { - String name= ""; //$NON-NLS-1$ - int bracket= refTypeSig.indexOf(Signature.C_GENERIC_START, arrayCount + 1); - if (bracket > 0) - name= refTypeSig.substring(arrayCount + 1, bracket); - else { - int semi= refTypeSig.indexOf(Signature.C_SEMICOLON, arrayCount + 1); - if (semi == -1) { - throw new IllegalArgumentException(); - } - name= refTypeSig.substring(arrayCount + 1, semi); - } - String[][] resolvedNames= declaringType.resolveType(name); - if (resolvedNames != null && resolvedNames.length > 0) { - StringBuffer res=new StringBuffer(); - for(int i=0; i null. - */ - public static String concatenateName(String name1, String name2) { - StringBuffer buf= new StringBuffer("L"); - if (name1 != null && name1.length() > 0) { - buf.append(name1.replace('.', '/')); - } - if (name2 != null && name2.length() > 0) { - if (buf.length() > 0) { - buf.append('/'); - } - buf.append(name2); - } - - buf.append(";"); - return buf.toString(); - } -} diff --git a/org.sf.feeling.decompiler/src/com/drgarbage/utils/ClassFileDocumentsUtils.java b/org.sf.feeling.decompiler/src/com/drgarbage/utils/ClassFileDocumentsUtils.java deleted file mode 100644 index ef8a8fcc..00000000 --- a/org.sf.feeling.decompiler/src/com/drgarbage/utils/ClassFileDocumentsUtils.java +++ /dev/null @@ -1,278 +0,0 @@ -/** - * Copyright (c) 2008-2013, Dr. Garbage Community - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.drgarbage.utils; - -import java.io.BufferedInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IMethod; -import org.eclipse.jdt.core.IPackageDeclaration; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.launching.JavaRuntime; -import org.sf.feeling.decompiler.util.Logger; - -import com.drgarbage.bytecode.ByteCodeConstants; -import com.drgarbage.javalang.JavaLangUtils; - -/** - * Some utility methods for class file objects. - * - * @author Sergej Alekseev - * @version $Revision: 516 $ $Id: ClassFileDocumentsUtils.java 516 2014-02-05 - * 09:17:35Z salekseev $ - */ -public class ClassFileDocumentsUtils -{ - - /** - * Returns a method object for the given type by the method name and the - * method signature. - * - * @param type - * type representing a class - * @param methodName - * method name - * @param methodSignature - * method signature in java class file format - * @return m the method object {@link IMethod} - * @throws JavaModelException - * @see IType - */ - public static IMethod findMethod( IType type, String methodName, String methodSignature ) throws JavaModelException - { - if ( type == null ) - { - return null; - } - - if ( methodName.equals( ByteCodeConstants.INIT ) ) - { - methodName = type.getElementName( ); - } - - IMethod[] methods = type.getMethods( ); - for ( IMethod m : methods ) - { - String sig = resolveMethodSignature( m ); - if ( m.getElementName( ).equals( methodName ) && sig.equals( methodSignature ) ) - { - - return m; - } - } - - return null; - } - - /** - * Returns the method signature string. - * - * @param iMethod - * method object - * @return method signature string - * - * @see IMethod - */ - public static String resolveMethodSignature( IMethod iMethod ) - { - - String mMethodSignature = null; - try - { - /* - * Method Signature: NOTE: if class file is selected then the method - * signature is resolved. - */ - if ( iMethod.isBinary( ) ) - { - mMethodSignature = iMethod.getSignature( ); - } - else - { - - /* resolve parameter signature */ - StringBuffer buf = new StringBuffer( "(" ); - String[] parameterTypes = iMethod.getParameterTypes( ); - String res = null; - for ( int i = 0; i < parameterTypes.length; i++ ) - { - res = ActionUtils.getResolvedTypeName( parameterTypes[i], iMethod.getDeclaringType( ) ); - buf.append( res ); - } - buf.append( ")" ); - - res = ActionUtils.getResolvedTypeName( iMethod.getReturnType( ), iMethod.getDeclaringType( ) ); - buf.append( res ); - - mMethodSignature = buf.toString( ); - } - - } - catch ( IllegalArgumentException e ) - { - Logger.debug( e ); - return null; - } - catch ( JavaModelException e ) - { - Logger.debug( e ); - return null; - } - - return mMethodSignature; - } - - /** - * Returns the package name as a string for the given compilation unit. - * - * @param unit - * compilation unit - * @return package name - * @throws JavaModelException - */ - public static String getPackageNameFromCompilationUnit( ICompilationUnit unit ) throws JavaModelException - { - IPackageDeclaration[] p = unit.getPackageDeclarations( ); - if ( p.length > 0 ) - { - return p[0].getElementName( ); - } - - return null; - } - - /** - * Collects recursively nested classes in the compilation unit. The nested - * class names are type-qualified. The classes are stored in the class list - * given as argument. For example: - * - *

      -	 *      HEllo
      -	 *      HEllo$C1
      -	 *      HEllo$C1$C3
      -	 * 
      - * - * @param t - * type representing a class - * @param classList - * class list to store nested classes - * @throws JavaModelException - * @see IType#getTypeQualifiedName() - */ - public static void collectNestedClasses( IType t, List classList ) throws JavaModelException - { - classList.add( t.getTypeQualifiedName( ) ); - - /* start recursion */ - IType[] types = t.getTypes( ); - for ( IType e : types ) - { - collectNestedClasses( e, classList ); - } - } - - /** - * Returns the list of InputStreams for the given list of classes. - * - * @param classList - * list of classes - * @param classPath - * classpath - * @param packageName - * package name - * @return list if InputStreams - */ - public static List getInputStreams( List classList, String[] classPath, String packageName ) - { - List streams = new ArrayList( ); - for ( String l : classList ) - { - InputStream in; - try - { - in = JavaLangUtils.findResource( classPath, packageName, l ); - - if ( in == null ) - { - String err = "Resource '" + packageName + " " + l + "' not found."; - Logger.info( err ); - } - - if ( !( in instanceof BufferedInputStream ) ) - { - /* buffer only if necessary */ - in = new BufferedInputStream( in ); - } - - streams.add( in ); - } - catch ( IOException e ) - { - Logger.debug( e ); - } - } - - return streams; - } - - /** - * Returns the list of InputStreams for all classes defined in the - * compilation unit including nested classes. - * - * @param unit - * compilation unit - * @param jp - * java project - * @return list if InputStreams - */ - public static List findClasses( ICompilationUnit unit, IJavaProject jp ) - { - try - { - List classList = new ArrayList( ); - IType[] types = unit.getTypes( ); - for ( IType t : types ) - { - ClassFileDocumentsUtils.collectNestedClasses( t, classList ); - } - - String[] classpath = JavaRuntime.computeDefaultRuntimeClassPath( jp ); - String packageName = getPackageNameFromCompilationUnit( unit ); - - return getInputStreams( classList, classpath, packageName ); - - } - catch ( JavaModelException e ) - { - Logger.debug( e ); - } - catch ( CoreException e ) - { - Logger.debug( e ); - } - - return null; - - } -} 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 070a9d0d..75cc5177 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 @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler; @@ -14,26 +11,19 @@ import java.io.File; import java.net.MalformedURLException; import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.util.Arrays; import java.util.Collection; -import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeMap; import java.util.concurrent.ConcurrentSkipListSet; -import java.util.concurrent.atomic.AtomicInteger; -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.resources.IMarkerDelta; -import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; -import org.eclipse.debug.core.DebugPlugin; -import org.eclipse.debug.core.IBreakpointListener; -import org.eclipse.debug.core.IBreakpointManager; -import org.eclipse.debug.core.model.IBreakpoint; import org.eclipse.jdt.core.IPackageFragmentRoot; import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.jface.resource.ImageDescriptor; @@ -43,556 +33,315 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; -import org.sf.feeling.decompiler.actions.DebugModeAction; -import org.sf.feeling.decompiler.editor.DecompilerType; import org.sf.feeling.decompiler.editor.IDecompilerDescriptor; import org.sf.feeling.decompiler.editor.JavaDecompilerBufferManager; -import org.sf.feeling.decompiler.editor.JavaDecompilerClassFileEditor; import org.sf.feeling.decompiler.extension.DecompilerAdapterManager; -import org.sf.feeling.decompiler.extension.IDecompilerExtensionHandler; -import org.sf.feeling.decompiler.i18n.Messages; import org.sf.feeling.decompiler.source.attach.IAttachSourceHandler; -import org.sf.feeling.decompiler.util.DecompilerOutputUtil; +import org.sf.feeling.decompiler.util.DefaultDecompilerDescriptorComparator; import org.sf.feeling.decompiler.util.FileUtil; import org.sf.feeling.decompiler.util.Logger; -import org.sf.feeling.decompiler.util.MarkUtil; import org.sf.feeling.decompiler.util.SortMemberUtil; -import org.sf.feeling.decompiler.util.UIUtil; - -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 DECOMPILE_COUNT = "decompile.count"; //$NON-NLS-1$ - public static final String ADCLICK_COUNT = "adclick.count"; //$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$ + +public class JavaDecompilerPlugin extends AbstractUIPlugin implements IPropertyChangeListener { + + 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; private IPreferenceStore preferenceStore; - private TreeMap decompilerDescriptorMap = new TreeMap( ); - private AtomicInteger decompileCount = new AtomicInteger( 0 ); - private AtomicInteger adClickCount = new AtomicInteger( 0 ); + private TreeMap decompilerDescriptorMap = new TreeMap<>(); 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; - private boolean enableExtension = false; - - private IBreakpointListener breakpintListener = new IBreakpointListener( ) { - - @Override - public void breakpointRemoved( IBreakpoint breakpoint, IMarkerDelta delta ) - { - // TODO Auto-generated method stub - - } - - @Override - public void breakpointChanged( IBreakpoint breakpoint, IMarkerDelta delta ) - { - // TODO Auto-generated method stub - - } - - @Override - public void breakpointAdded( final IBreakpoint breakpoint ) - { - JavaDecompilerClassFileEditor editor = UIUtil.getActiveDecompilerEditor( ); - if ( editor != null && breakpoint != null ) - { - String source = editor.getDocumentProvider( ).getDocument( editor.getEditorInput( ) ).get( ); - - if ( source != null && MarkUtil.containsMark( source ) ) - { - - try - { - if ( UIUtil.isDebug( ) - && breakpoint.getMarker( ) != null - && breakpoint.getMarker( ).getAttribute( IMarker.LINE_NUMBER ) != null ) - { - int lineNumber = (Integer) breakpoint.getMarker( ).getAttribute( IMarker.LINE_NUMBER ); - String[] lines = source.split( "\n" ); //$NON-NLS-1$ - if ( lineNumber - 1 < lines.length ) - { - String line = lines[lineNumber - 1]; - int number = DecompilerOutputUtil.parseJavaLineNumber( line ); - if ( number == -1 ) - { - Display.getDefault( ).asyncExec( new Runnable( ) { - - @Override - public void run( ) - { - MessageDialog.openInformation( Display.getDefault( ).getActiveShell( ), - Messages.getString( - "JavaDecompilerPlugin.BreakpoingWithNumberDialog.Title" ), //$NON-NLS-1$ - Messages.getString( - "JavaDecompilerPlugin.BreakpoingWithNumberDialog.Message" ) ); //$NON-NLS-1$ - try - { - breakpoint.delete( ); - } - catch ( CoreException e ) - { - Logger.debug( e ); - } - } - } ); - - } - } - } - else if ( !UIUtil.isDebug( ) ) - { - - Display.getDefault( ).asyncExec( new Runnable( ) { - - @Override - public void run( ) - { - boolean setDebug = MessageDialog.openConfirm( - Display.getDefault( ).getActiveShell( ), - Messages.getString( "JavaDecompilerPlugin.BreakpoingDialog.Title" ), //$NON-NLS-1$ - Messages.getString( "JavaDecompilerPlugin.BreakpoingDialog.Message" ) ); //$NON-NLS-1$ - try - { - breakpoint.delete( ); - } - catch ( CoreException e ) - { - Logger.debug( e ); - } - if ( setDebug ) - { - new DebugModeAction( ).run( ); - } - } - } ); - } - } - catch ( CoreException e ) - { - Logger.debug( e ); - } - } - } - } - }; - - private IBreakpointManager manager = DebugPlugin.getDefault( ).getBreakpointManager( ); - - public AtomicInteger getDecompileCount( ) - { - return decompileCount; - } - - public AtomicInteger getAdClickCount( ) - { - return adClickCount; - } - public Map getDecompilerDescriptorMap( ) - { + public Map getDecompilerDescriptorMap() { return decompilerDescriptorMap; } - public String[] getDecompilerDescriptorTypes( ) - { - return decompilerDescriptorMap.keySet( ).toArray( new String[0] ); + public String[] getDecompilerDescriptorTypes() { + return decompilerDescriptorMap.keySet().toArray(new String[0]); } - public IDecompilerDescriptor getDecompilerDescriptor( String decompilerType ) - { - return decompilerDescriptorMap.get( decompilerType ); + public IDecompilerDescriptor getDecompilerDescriptor(String decompilerType) { + return decompilerDescriptorMap.get(decompilerType); } - public static JavaDecompilerPlugin getDefault( ) - { + public static JavaDecompilerPlugin getDefault() { return plugin; } - public static void logError( Throwable t, String message ) - { - JavaDecompilerPlugin.getDefault( ).getLog( ).log( new Status( IStatus.ERROR, PLUGIN_ID, 0, message, t ) ); + public static void logError(Throwable t, String message) { + 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 ) ); + public static void logWarn(Throwable t, String message) { + JavaDecompilerPlugin.getDefault().getLog() + .log(new Status(IStatus.WARNING, JavaDecompilerConstants.PLUGIN_ID, 0, message, t)); } - public static void log( int severity, Throwable t, String message ) - { - JavaDecompilerPlugin.getDefault( ).getLog( ).log( new Status( severity, PLUGIN_ID, 0, message, t ) ); + public static void logInfo(String message) { + JavaDecompilerPlugin.getDefault().getLog() + .log(new Status(IStatus.INFO, JavaDecompilerConstants.PLUGIN_ID, 0, message, null)); } - public static ImageDescriptor getImageDescriptor( String path ) - { - URL base = JavaDecompilerPlugin.getDefault( ).getBundle( ).getEntry( "/" ); //$NON-NLS-1$ + /** + * + * @param severity severity constant see {@link IStatus#INFO} + * {@link IStatus#WARNING} {@link IStatus#ERROR} + * @param t + * @param message + */ + public static void log(int severity, Throwable t, String message) { + JavaDecompilerPlugin.getDefault().getLog() + .log(new Status(severity, JavaDecompilerConstants.PLUGIN_ID, 0, message, t)); + } + + public static ImageDescriptor getImageDescriptor(String path) { + URL base = JavaDecompilerPlugin.getDefault().getBundle().getEntry("/"); //$NON-NLS-1$ URL url = null; - try - { - url = new URL( base, path ); // $NON-NLS-1$ - } - catch ( MalformedURLException e ) - { - Logger.debug( e ); + try { + url = new URL(base, path); // $NON-NLS-1$ + } catch (MalformedURLException e) { + Logger.debug(e); } ImageDescriptor actionIcon = null; - if ( url != null ) - actionIcon = ImageDescriptor.createFromURL( url ); + if (url != null) { + actionIcon = ImageDescriptor.createFromURL(url); + } return actionIcon; } - public JavaDecompilerPlugin( ) - { + public JavaDecompilerPlugin() { plugin = this; } @Override - protected void initializeDefaultPreferences( IPreferenceStore store ) - { - store.setDefault( 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, true ); - store.setDefault( DECOMPILE_COUNT, 0 ); - store.setDefault( ADCLICK_COUNT, 0 ); - store.setDefault( EXPORT_ENCODING, "UTF-8" ); //$NON-NLS-1$ - - 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 ); - } - - private void setDefaultDecompiler( IPreferenceStore store ) - { - if ( isEnableExtension( ) ) - { - Object[] decompilerAdapters = DecompilerAdapterManager.getAdapters( this, IDecompilerDescriptor.class ); - - if ( decompilerAdapters != null ) - { - for ( int i = 0; i < decompilerAdapters.length; i++ ) - { - Object adapter = decompilerAdapters[i]; - if ( adapter instanceof IDecompilerDescriptor ) - { - IDecompilerDescriptor descriptor = (IDecompilerDescriptor) adapter; - if ( descriptor.isEnabled( ) ) - { - decompilerDescriptorMap.put( descriptor.getDecompilerType( ), descriptor ); + protected void initializeDefaultPreferences(IPreferenceStore store) { + 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(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) { + List decompilerAdapters = DecompilerAdapterManager.getAdapterList(this, + 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); + } } } - store.setDefault( DECOMPILER_TYPE, getDefalutDecompilerType( ) ); } @Override - public void propertyChange( PropertyChangeEvent event ) - { - if ( event.getProperty( ).equals( IGNORE_EXISTING ) ) - JavaDecompilerBufferManager.closeDecompilerBuffers( false ); - } - - @Override - public void start( BundleContext context ) throws Exception - { - super.start( context ); - checkEnableExtension( ); - setDefaultDecompiler( getPreferenceStore( ) ); - getPreferenceStore( ).addPropertyChangeListener( this ); - SortMemberUtil.deleteDecompilerProject( ); - decompileCount.set( getPreferenceStore( ).getInt( DECOMPILE_COUNT ) ); - adClickCount.set( getPreferenceStore( ).getInt( ADCLICK_COUNT ) ); - Display.getDefault( ).asyncExec( new SetupRunnable( ) ); - - manager.addBreakpointListener( breakpintListener ); - } - - private void checkEnableExtension( ) - { - final Object extensionAdapter = DecompilerAdapterManager.getAdapter( JavaDecompilerPlugin.getDefault( ), - IDecompilerExtensionHandler.class ); - - if ( extensionAdapter instanceof IDecompilerExtensionHandler ) - { - enableExtension = true; - } - else - { - enableExtension = false; + public void propertyChange(PropertyChangeEvent event) { + if (event.getProperty().equals(JavaDecompilerConstants.IGNORE_EXISTING)) { + JavaDecompilerBufferManager.closeDecompilerBuffers(false); } } - public boolean isEnableExtension( ) - { - return enableExtension; + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + initializeDecompilerDescriptorMap(getPreferenceStore()); + initializeDefaultDecompilerType(); + getPreferenceStore().addPropertyChangeListener(this); + SortMemberUtil.deleteDecompilerProject(); + Display.getDefault().asyncExec(new SetupRunnable()); } @Override - public IPreferenceStore getPreferenceStore( ) - { - if ( preferenceStore == null ) - { - preferenceStore = super.getPreferenceStore( ); - - String decompilerType = preferenceStore.getString( DECOMPILER_TYPE ); - if ( !DecompilerType.FernFlower.equals( decompilerType ) ) - { - IDecompilerDescriptor descriptor = getDecompilerDescriptor( decompilerType ); - if ( descriptor == null ) - { - preferenceStore.setDefault( DECOMPILER_TYPE, getDefalutDecompilerType( ) ); + public IPreferenceStore getPreferenceStore() { + if (preferenceStore == null) { + preferenceStore = super.getPreferenceStore(); + + String decompilerType = preferenceStore.getString(JavaDecompilerConstants.DECOMPILER_TYPE); + IDecompilerDescriptor descriptor = getDecompilerDescriptor(decompilerType); + if (descriptor == null) { + String defaultDecompiler = getDefaultDecompilerType(); + if (defaultDecompiler != null) { + preferenceStore.setDefault(JavaDecompilerConstants.DECOMPILER_TYPE, defaultDecompiler); } } - } return preferenceStore; } - @Override - public void stop( BundleContext context ) throws Exception - { - FileUtil.deltree( new File( getPreferenceStore( ).getString( JavaDecompilerPlugin.TEMP_DIR ) ) ); - - manager.removeBreakpointListener( breakpintListener ); + public void initializeDefaultDecompilerType() { + String decompilerType = preferenceStore.getString(JavaDecompilerConstants.DECOMPILER_TYPE); + IDecompilerDescriptor descriptor = getDecompilerDescriptor(decompilerType); + if (descriptor != null) { + return; + } + Collection descriptorColl = JavaDecompilerPlugin.getDefault() + .getDecompilerDescriptorMap().values(); + if (!descriptorColl.isEmpty()) { + String defaultDecompiler = getDefaultDecompilerType(); + if (defaultDecompiler != null) { + preferenceStore.setDefault(JavaDecompilerConstants.DECOMPILER_TYPE, defaultDecompiler); + } + } + } - getPreferenceStore( ).setValue( DECOMPILE_COUNT, decompileCount.get( ) ); - getPreferenceStore( ).setValue( ADCLICK_COUNT, adClickCount.get( ) ); + @Override + public void stop(BundleContext context) throws Exception { + FileUtil.deltree(new File(getPreferenceStore().getString(JavaDecompilerConstants.TEMP_DIR))); - super.stop( context ); + super.stop(context); - getPreferenceStore( ).removePropertyChangeListener( this ); + getPreferenceStore().removePropertyChangeListener(this); plugin = null; } - public Boolean isDisplayLineNumber( ) - { - return Boolean.valueOf( getPreferenceStore( ).getBoolean( PREF_DISPLAY_LINE_NUMBERS ) ); + public Boolean isDisplayLineNumber() { + return Boolean.valueOf(getPreferenceStore().getBoolean(JavaDecompilerConstants.PREF_DISPLAY_LINE_NUMBERS)); } - public Boolean isDebug( ) - { - return Boolean.valueOf( getPreferenceStore( ).getBoolean( ALIGN ) ); + public Boolean isDebug() { + return Boolean.valueOf(getPreferenceStore().getBoolean(JavaDecompilerConstants.ALIGN)); } - public void displayLineNumber( Boolean display ) - { - getPreferenceStore( ).setValue( PREF_DISPLAY_LINE_NUMBERS, display.booleanValue( ) ); + public void displayLineNumber(Boolean display) { + getPreferenceStore().setValue(JavaDecompilerConstants.PREF_DISPLAY_LINE_NUMBERS, display.booleanValue()); } - public void setExportEncoding( String encoding ) - { - getPreferenceStore( ).setValue( EXPORT_ENCODING, encoding ); + public void setExportEncoding(String encoding) { + getPreferenceStore().setValue(JavaDecompilerConstants.EXPORT_ENCODING, encoding); } - public String getExportEncoding( ) - { - return getPreferenceStore( ).getString( EXPORT_ENCODING ); + public String getExportEncoding() { + return getPreferenceStore().getString(JavaDecompilerConstants.EXPORT_ENCODING); } - public boolean enableAttachSourceSetting( ) - { - if ( isEnableExtension( ) ) - { - Object attachSourceAdapter = DecompilerAdapterManager.getAdapter( this, IAttachSourceHandler.class ); - if ( attachSourceAdapter instanceof IAttachSourceHandler ) - { - return true; - } + public boolean enableAttachSourceSetting() { + Object attachSourceAdapter = DecompilerAdapterManager.getAdapter(this, IAttachSourceHandler.class); + if (attachSourceAdapter instanceof IAttachSourceHandler) { + return true; } + return false; } - private Set librarys = new ConcurrentSkipListSet( ); + private final Set libraries = new ConcurrentSkipListSet<>(); - public void attachSource( IPackageFragmentRoot library, boolean force ) - { - if ( isEnableExtension( ) ) - { - Object attachSourceAdapter = DecompilerAdapterManager.getAdapter( this, IAttachSourceHandler.class ); - if ( attachSourceAdapter instanceof IAttachSourceHandler ) - { - if ( !librarys.contains( library.getPath( ).toOSString( ) ) || force ) - { - librarys.add( library.getPath( ).toOSString( ) ); - ( (IAttachSourceHandler) attachSourceAdapter ).execute( library, force ); - } + public void attachSource(IPackageFragmentRoot library, boolean force) { + Object attachSourceAdapter = DecompilerAdapterManager.getAdapter(this, IAttachSourceHandler.class); + if (attachSourceAdapter instanceof IAttachSourceHandler) { + if (!libraries.contains(library.getPath().toOSString()) || force) { + libraries.add(library.getPath().toOSString()); + ((IAttachSourceHandler) attachSourceAdapter).execute(library, force); } } } - public void syncLibrarySource( IPackageFragmentRoot library ) - { - if ( isEnableExtension( ) ) - { - try - { - if ( library.getPath( ) != null - && library.getSourceAttachmentPath( ) != null - && !librarys.contains( library.getPath( ).toOSString( ) ) ) - { - final IPreferenceStore prefs = JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ); - if ( prefs.getBoolean( JavaDecompilerPlugin.DEFAULT_EDITOR ) ) - { - final Object attachSourceAdapter = DecompilerAdapterManager - .getAdapter( JavaDecompilerPlugin.getDefault( ), IAttachSourceHandler.class ); - if ( attachSourceAdapter instanceof IAttachSourceHandler ) - { - librarys.add( library.getPath( ).toOSString( ) ); - if ( !( (IAttachSourceHandler) attachSourceAdapter ).syncAttachSource( library ) ) - { - librarys.remove( library.getPath( ).toOSString( ) ); - } ; + public void syncLibrarySource(IPackageFragmentRoot library) { + try { + if (library.getPath() != null && library.getSourceAttachmentPath() != null + && !libraries.contains(library.getPath().toOSString())) { + final IPreferenceStore prefs = JavaDecompilerPlugin.getDefault().getPreferenceStore(); + if (prefs.getBoolean(JavaDecompilerConstants.DEFAULT_EDITOR)) { + final Object attachSourceAdapter = DecompilerAdapterManager + .getAdapter(JavaDecompilerPlugin.getDefault(), IAttachSourceHandler.class); + if (attachSourceAdapter instanceof IAttachSourceHandler) { + libraries.add(library.getPath().toOSString()); + if (!((IAttachSourceHandler) attachSourceAdapter).syncAttachSource(library)) { + libraries.remove(library.getPath().toOSString()); } } } } - catch ( JavaModelException e ) - { - Logger.debug( e ); - } + } catch (JavaModelException e) { + Logger.debug(e); } } - public boolean isAutoAttachSource( ) - { - if ( isEnableExtension( ) ) - { - if ( !enableAttachSourceSetting( ) ) - { - return false; - } - - return getPreferenceStore( ).getBoolean( ATTACH_SOURCE ); - } - else - { + public boolean isAutoAttachSource() { + if (!enableAttachSourceSetting()) { return false; } + + return getPreferenceStore().getBoolean(JavaDecompilerConstants.ATTACH_SOURCE); } - public String getDefalutDecompilerType( ) - { - Collection descriptors = JavaDecompilerPlugin.getDefault( ) - .getDecompilerDescriptorMap( ) - .values( ); - if ( descriptors != null ) - { - for ( Iterator iterator = descriptors.iterator( ); iterator.hasNext( ); ) - { - IDecompilerDescriptor iDecompilerDescriptor = (IDecompilerDescriptor) iterator.next( ); - if ( iDecompilerDescriptor.isDefault( ) ) - { - return iDecompilerDescriptor.getDecompilerType( ); - } - } + public String getDefaultDecompilerType() { + Collection descriptorColl = JavaDecompilerPlugin.getDefault() + .getDecompilerDescriptorMap().values(); + if (!descriptorColl.isEmpty()) { + IDecompilerDescriptor defaultDecompilerDescr = descriptorColl.stream() + .sorted(new DefaultDecompilerDescriptorComparator()).findFirst().get(); + return defaultDecompilerDescr.getDecompilerType(); } - return DecompilerType.FernFlower; + return null; } - public boolean isDebugMode( ) - { + public boolean isDebugMode() { return isDebugMode; } - public void setDebugMode( boolean isDebugMode ) - { + public void setDebugMode(boolean isDebugMode) { this.isDebugMode = isDebugMode; } - public int getSourceMode( ) - { + public int getSourceMode() { return sourceMode; } - public void setSourceMode( int sourceMode ) - { + public void setSourceMode(int sourceMode) { this.sourceMode = sourceMode; } - public void resetCount( ) - { - decompileCount.set( 0 ); - getPreferenceStore( ).setValue( DECOMPILE_COUNT, decompileCount.get( ) ); - - adClickCount.set( 0 ); - getPreferenceStore( ).setValue( ADCLICK_COUNT, adClickCount.get( ) ); - } - - public String getDefaultExportEncoding( ) - { - return getPreferenceStore( ).getDefaultString( JavaDecompilerPlugin.EXPORT_ENCODING ); + public String getDefaultExportEncoding() { + 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 dcdcb559..7ebed230 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 @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler; @@ -32,332 +29,251 @@ import org.eclipse.ui.internal.registry.FileEditorMapping; import org.sf.feeling.decompiler.actions.DecompileAction; import org.sf.feeling.decompiler.editor.JavaDecompilerClassFileEditor; -import org.sf.feeling.decompiler.extension.DecompilerAdapterManager; -import org.sf.feeling.decompiler.extension.IDecompilerExtensionHandler; import org.sf.feeling.decompiler.util.ClassUtil; import org.sf.feeling.decompiler.util.Logger; -import org.sf.feeling.decompiler.util.MarkUtil; import org.sf.feeling.decompiler.util.ReflectionUtils; import org.sf.feeling.decompiler.util.UIUtil; -public class SetupRunnable implements Runnable -{ +public class SetupRunnable implements Runnable { @Override - public void run( ) - { - try - { - if ( PlatformUI.getWorkbench( ) == null - || PlatformUI.getWorkbench( ).getActiveWorkbenchWindow( ) == null - || PlatformUI.getWorkbench( ).getActiveWorkbenchWindow( ).getActivePage( ) == null ) - { - Display.getDefault( ).timerExec( 1000, new Runnable( ) { - - public void run( ) - { - SetupRunnable.this.run( ); + public void run() { + try { + if (PlatformUI.getWorkbench() == null || PlatformUI.getWorkbench().getActiveWorkbenchWindow() == null + || PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() == null) { + Display.getDefault().timerExec(1000, new Runnable() { + + public void run() { + SetupRunnable.this.run(); } - } ); - } - else - { - checkClassFileAssociation( ); - setupPartListener( ); - checkDecompilerExtension( ); + }); + } else { + checkClassFileAssociation(); + setupPartListener(); } - } - catch ( Throwable e ) - { - Logger.debug( e ); + } catch (Throwable e) { + Logger.debug(e); } } - private void checkDecompilerExtension( ) - { - final Object extensionAdapter = DecompilerAdapterManager.getAdapter( JavaDecompilerPlugin.getDefault( ), - IDecompilerExtensionHandler.class ); - - if ( extensionAdapter instanceof IDecompilerExtensionHandler ) - { - final IDecompilerExtensionHandler extensionHandler = (IDecompilerExtensionHandler) extensionAdapter; - extensionHandler.execute( ); - } - } - - private void setupPartListener( ) - { - final IPerspectiveListener perspectiveListener = new IPerspectiveListener( ) { + private void setupPartListener() { + final IPerspectiveListener perspectiveListener = new IPerspectiveListener() { @Override - public void perspectiveChanged( IWorkbenchPage page, IPerspectiveDescriptor perspective, String changeId ) - { + public void perspectiveChanged(IWorkbenchPage page, IPerspectiveDescriptor perspective, String changeId) { } @Override - public void perspectiveActivated( IWorkbenchPage page, IPerspectiveDescriptor perspective ) - { - if ( UIUtil.isDebugPerspective( ) ) - { - new DecompileAction( ).run( ); + public void perspectiveActivated(IWorkbenchPage page, IPerspectiveDescriptor perspective) { + if (UIUtil.isDebugPerspective()) { + new DecompileAction().run(); } } }; - final IPartListener partListener = new IPartListener( ) { + final IPartListener partListener = new IPartListener() { @Override - public void partOpened( IWorkbenchPart part ) - { + public void partOpened(IWorkbenchPart part) { } @Override - public void partDeactivated( IWorkbenchPart part ) - { + public void partDeactivated(IWorkbenchPart part) { } @Override - public void partClosed( IWorkbenchPart part ) - { + public void partClosed(IWorkbenchPart part) { } @Override - public void partBroughtToTop( IWorkbenchPart part ) - { - if ( part instanceof JavaDecompilerClassFileEditor ) - { - ( (JavaDecompilerClassFileEditor) part ).notifyPropertiesChange( ); - String code = ( (JavaDecompilerClassFileEditor) part ).getViewer( ).getDocument( ).get( ); - if ( !MarkUtil.containsSourceMark( code ) - && ClassUtil.isDebug( ) != JavaDecompilerClassFileEditor.isDebug( code ) ) - { - ( (JavaDecompilerClassFileEditor) part ).doSetInput( false ); + public void partBroughtToTop(IWorkbenchPart part) { + if (part instanceof JavaDecompilerClassFileEditor) { + String code = ((JavaDecompilerClassFileEditor) part).getViewer().getDocument().get(); + if (ClassUtil.isDebug() != JavaDecompilerClassFileEditor.isDebug(code)) { + ((JavaDecompilerClassFileEditor) part).doSetInput(false); } - ( (JavaDecompilerClassFileEditor) part ).showSource( ); } } @Override - public void partActivated( IWorkbenchPart part ) - { + public void partActivated(IWorkbenchPart part) { } }; - final IPageListener pageListener = new IPageListener( ) { + final IPageListener pageListener = new IPageListener() { @Override - public void pageOpened( IWorkbenchPage page ) - { - page.removePartListener( partListener ); - page.addPartListener( partListener ); + public void pageOpened(IWorkbenchPage page) { + page.removePartListener(partListener); + page.addPartListener(partListener); } @Override - public void pageClosed( IWorkbenchPage page ) - { - page.removePartListener( partListener ); + public void pageClosed(IWorkbenchPage page) { + page.removePartListener(partListener); } @Override - public void pageActivated( IWorkbenchPage page ) - { - page.removePartListener( partListener ); - page.addPartListener( partListener ); + public void pageActivated(IWorkbenchPage page) { + page.removePartListener(partListener); + page.addPartListener(partListener); } }; - IWindowListener windowListener = new IWindowListener( ) { + IWindowListener windowListener = new IWindowListener() { @Override - public void windowOpened( IWorkbenchWindow window ) - { - window.removePageListener( pageListener ); - window.addPageListener( pageListener ); - window.removePerspectiveListener( perspectiveListener ); - window.addPerspectiveListener( perspectiveListener ); - IWorkbenchPage[] pages = window.getPages( ); - if ( pages != null ) - { - for ( int i = 0; i < pages.length; i++ ) - { - pages[i].removePartListener( partListener ); - pages[i].addPartListener( partListener ); + public void windowOpened(IWorkbenchWindow window) { + window.removePageListener(pageListener); + window.addPageListener(pageListener); + window.removePerspectiveListener(perspectiveListener); + window.addPerspectiveListener(perspectiveListener); + IWorkbenchPage[] pages = window.getPages(); + if (pages != null) { + for (int i = 0; i < pages.length; i++) { + pages[i].removePartListener(partListener); + pages[i].addPartListener(partListener); } } } @Override - public void windowDeactivated( IWorkbenchWindow window ) - { - window.removePageListener( pageListener ); - window.removePerspectiveListener( perspectiveListener ); + public void windowDeactivated(IWorkbenchWindow window) { + window.removePageListener(pageListener); + window.removePerspectiveListener(perspectiveListener); } @Override - public void windowClosed( IWorkbenchWindow window ) - { - window.removePageListener( pageListener ); - window.removePerspectiveListener( perspectiveListener ); + public void windowClosed(IWorkbenchWindow window) { + window.removePageListener(pageListener); + window.removePerspectiveListener(perspectiveListener); } @Override - public void windowActivated( IWorkbenchWindow window ) - { - window.removePageListener( pageListener ); - window.addPageListener( pageListener ); - window.removePerspectiveListener( perspectiveListener ); - window.addPerspectiveListener( perspectiveListener ); - IWorkbenchPage[] pages = window.getPages( ); - if ( pages != null ) - { - for ( int i = 0; i < pages.length; i++ ) - { - pages[i].removePartListener( partListener ); - pages[i].addPartListener( partListener ); + public void windowActivated(IWorkbenchWindow window) { + window.removePageListener(pageListener); + window.addPageListener(pageListener); + window.removePerspectiveListener(perspectiveListener); + window.addPerspectiveListener(perspectiveListener); + IWorkbenchPage[] pages = window.getPages(); + if (pages != null) { + for (int i = 0; i < pages.length; i++) { + pages[i].removePartListener(partListener); + pages[i].addPartListener(partListener); } } } }; - if ( PlatformUI.getWorkbench( ) == null ) - { + if (PlatformUI.getWorkbench() == null) { return; } - PlatformUI.getWorkbench( ).removeWindowListener( windowListener ); - PlatformUI.getWorkbench( ).addWindowListener( windowListener ); + PlatformUI.getWorkbench().removeWindowListener(windowListener); + PlatformUI.getWorkbench().addWindowListener(windowListener); - if ( PlatformUI.getWorkbench( ).getActiveWorkbenchWindow( ) == null ) - { + if (PlatformUI.getWorkbench().getActiveWorkbenchWindow() == null) { return; } - PlatformUI.getWorkbench( ).getActiveWorkbenchWindow( ).removePageListener( pageListener ); - PlatformUI.getWorkbench( ).getActiveWorkbenchWindow( ).addPageListener( pageListener ); + PlatformUI.getWorkbench().getActiveWorkbenchWindow().removePageListener(pageListener); + PlatformUI.getWorkbench().getActiveWorkbenchWindow().addPageListener(pageListener); - PlatformUI.getWorkbench( ).getActiveWorkbenchWindow( ).removePerspectiveListener( perspectiveListener ); - PlatformUI.getWorkbench( ).getActiveWorkbenchWindow( ).addPerspectiveListener( perspectiveListener ); + PlatformUI.getWorkbench().getActiveWorkbenchWindow().removePerspectiveListener(perspectiveListener); + PlatformUI.getWorkbench().getActiveWorkbenchWindow().addPerspectiveListener(perspectiveListener); - IWorkbenchPage page = PlatformUI.getWorkbench( ).getActiveWorkbenchWindow( ).getActivePage( ); - if ( page == null ) - { + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + if (page == null) { return; } - page.removePartListener( partListener ); - page.addPartListener( partListener ); + page.removePartListener(partListener); + page.addPartListener(partListener); } - private void checkClassFileAssociation( ) - { - IPreferenceStore prefs = JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ); - if ( prefs.getBoolean( JavaDecompilerPlugin.DEFAULT_EDITOR ) ) - { - updateClassDefaultEditor( ); + private void checkClassFileAssociation() { + IPreferenceStore prefs = JavaDecompilerPlugin.getDefault().getPreferenceStore(); + if (prefs.getBoolean(JavaDecompilerConstants.DEFAULT_EDITOR)) { + updateClassDefaultEditor(); - IPreferenceStore store = WorkbenchPlugin.getDefault( ).getPreferenceStore( ); - store.addPropertyChangeListener( new IPropertyChangeListener( ) { + IPreferenceStore store = WorkbenchPlugin.getDefault().getPreferenceStore(); + store.addPropertyChangeListener(new IPropertyChangeListener() { @Override - public void propertyChange( PropertyChangeEvent event ) - { - if ( IPreferenceConstants.RESOURCES.equals( event.getProperty( ) ) ) - { - updateClassDefaultEditor( ); + public void propertyChange(PropertyChangeEvent event) { + if (IPreferenceConstants.RESOURCES.equals(event.getProperty())) { + updateClassDefaultEditor(); } } - } ); + }); } } - protected void updateClassDefaultEditor( ) - { - EditorRegistry registry = (EditorRegistry) PlatformUI.getWorkbench( ).getEditorRegistry( ); + protected void updateClassDefaultEditor() { + EditorRegistry registry = (EditorRegistry) PlatformUI.getWorkbench().getEditorRegistry(); - IFileEditorMapping[] mappings = registry.getFileEditorMappings( ); + IFileEditorMapping[] mappings = registry.getFileEditorMappings(); IFileEditorMapping classNoSource = null; IFileEditorMapping classPlain = null; - for ( int i = 0; i < mappings.length; i++ ) - { + for (int i = 0; i < mappings.length; i++) { IFileEditorMapping mapping = mappings[i]; - if ( mapping.getExtension( ).equals( "class without source" ) ) //$NON-NLS-1$ + if (mapping.getExtension().equals("class without source")) //$NON-NLS-1$ { classNoSource = mapping; - } - else if ( mapping.getExtension( ).equals( "class" ) ) //$NON-NLS-1$ + } else if (mapping.getExtension().equals("class")) //$NON-NLS-1$ { classPlain = mapping; } } - IFileEditorMapping[] classMappings = new IFileEditorMapping[]{ - classNoSource, classPlain - }; + IFileEditorMapping[] classMappings = new IFileEditorMapping[] { classNoSource, classPlain }; - boolean needUpdate = checkDefaultEditor( classMappings ); - if ( needUpdate ) - { - for ( int i = 0; i < classMappings.length; i++ ) - { + boolean needUpdate = checkDefaultEditor(classMappings); + if (needUpdate) { + for (int i = 0; i < classMappings.length; i++) { 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 ) ) - { - try - { - ReflectionUtils.invokeMethod( mapping, - "setDefaultEditor", //$NON-NLS-1$ - new Class[]{ - Class.forName( "org.eclipse.ui.IEditorDescriptor" ) //$NON-NLS-1$ - }, - new Object[]{ - editor - } ); - } - catch ( ClassNotFoundException e ) - { + for (int j = 0; j < mapping.getEditors().length; j++) { + IEditorDescriptor editor = mapping.getEditors()[j]; + if (editor.getId().equals(JavaDecompilerConstants.EDITOR_ID)) { + try { + // org.eclipse.ui.internal.registry.FileEditorMapping.setDefaultEditor(IEditorDescriptor) + // Eclipse Photon: method exists + ReflectionUtils.invokeMethod(mapping, "setDefaultEditor", //$NON-NLS-1$ + new Class[] { Class.forName("org.eclipse.ui.IEditorDescriptor") //$NON-NLS-1$ + }, new Object[] { editor }); + } catch (ClassNotFoundException e) { } - try - { - ReflectionUtils.invokeMethod( mapping, - "setDefaultEditor", //$NON-NLS-1$ - new Class[]{ - Class.forName( "org.eclipse.ui.internal.registry.EditorDescriptor" ) //$NON-NLS-1$ - }, - new Object[]{ - editor - } ); - } - catch ( ClassNotFoundException e ) - { + try { + // Unknown - may be required on old Eclipse versions? + ReflectionUtils.invokeMethod(mapping, "setDefaultEditor", //$NON-NLS-1$ + new Class[] { Class.forName("org.eclipse.ui.internal.registry.EditorDescriptor") //$NON-NLS-1$ + }, new Object[] { editor }); + } catch (ClassNotFoundException e) { } } } } - registry.setFileEditorMappings( (FileEditorMapping[]) mappings ); - registry.saveAssociations( ); + registry.setFileEditorMappings((FileEditorMapping[]) mappings); + registry.saveAssociations(); } } - protected boolean checkDefaultEditor( IFileEditorMapping[] classMappings ) - { - for ( int i = 0; i < classMappings.length; i++ ) - { + 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 ) ) + if (mapping.getDefaultEditor() != null + && !mapping.getDefaultEditor().getId().equals(JavaDecompilerConstants.EDITOR_ID)) { return true; + } } return false; } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/Startup.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/Startup.java index f628a909..458e4396 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/Startup.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/Startup.java @@ -1,23 +1,18 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler; import org.eclipse.ui.IStartup; -public class Startup implements IStartup -{ +public class Startup implements IStartup { @Override - public void earlyStartup( ) - { + public void earlyStartup() { } } 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 8b450cfe..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 @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.actions; @@ -16,40 +13,30 @@ 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; -public class BaseDecompilerHandler extends DecompileHandler -{ +public class BaseDecompilerHandler extends DecompileHandler { - 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 ); - if ( editorDescriptor == null ) - { - JavaDecompilerClassFileEditor editor = UIUtil.getActiveEditor( ); - if ( editor != null ) - { - if ( editor != null ) - editor.doSetInput( decompilerType, true ); + protected Object handleDecompile(String decompilerType) { + final List classes = UIUtil.getActiveSelection(); + if (classes != null && !classes.isEmpty()) { + IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry(); + IEditorDescriptor editorDescriptor = registry.findEditor(JavaDecompilerConstants.EDITOR_ID); + if (editorDescriptor == null) { + JavaDecompilerClassFileEditor editor = UIUtil.getActiveEditor(); + if (editor != null) { + editor.doSetInput(decompilerType, true); } + } else { + new OpenClassesAction(editorDescriptor, classes, decompilerType).run(); } - else - new OpenClassesAction( editorDescriptor, classes, decompilerType ).run( ); - } - else - { - JavaDecompilerClassFileEditor editor = UIUtil.getActiveEditor( ); - if ( editor != null ) - { - if ( editor != null ) - editor.doSetInput( decompilerType, true ); + } else { + JavaDecompilerClassFileEditor editor = UIUtil.getActiveEditor(); + if (editor != null) { + editor.doSetInput(decompilerType, true); } } return 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 d7e93d90..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 @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.actions; @@ -14,56 +11,49 @@ 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; import org.sf.feeling.decompiler.util.UIUtil; -public class ByteCodeAction extends Action implements IUpdate -{ +public class ByteCodeAction extends Action implements IUpdate { public static final String ID = "ByteCode"; //$NON-NLS-1$ - public ByteCodeAction( ) - { - super( Messages.getString( "JavaDecompilerActionBarContributor.Action.ByteCode" ), AS_CHECK_BOX ); //$NON-NLS-1$ + public ByteCodeAction() { + super(Messages.getString("JavaDecompilerActionBarContributor.Action.ByteCode"), AS_CHECK_BOX); //$NON-NLS-1$ } @Override - public void run( ) - { - JavaDecompilerPlugin.getDefault( ).setSourceMode( JavaDecompilerPlugin.BYTE_CODE_MODE ); - setChecked( true ); - final JavaDecompilerClassFileEditor editor = UIUtil.getActiveEditor( ); - if ( editor != null ) - { - editor.showSource( ); - editor.notifyPropertiesChange( ); - Display.getDefault( ).asyncExec( new Runnable( ) { - - public void run( ) - { - editor.setFocus( ); + public void run() { + JavaDecompilerPlugin.getDefault().setSourceMode(JavaDecompilerConstants.BYTE_CODE_MODE); + setChecked(true); + final JavaDecompilerClassFileEditor editor = UIUtil.getActiveEditor(); + if (editor != null) { + editor.showSource(); + editor.notifyPropertiesChange(); + Display.getDefault().asyncExec(new Runnable() { + + public void run() { + editor.setFocus(); } - } ); + }); } } @Override - public boolean isEnabled( ) - { - JavaDecompilerClassFileEditor editor = UIUtil.getActiveEditor( ); + public boolean isEnabled() { + JavaDecompilerClassFileEditor editor = UIUtil.getActiveEditor(); return editor != null; } - public boolean isChecked( ) - { - return JavaDecompilerPlugin.getDefault( ).getSourceMode( ) == JavaDecompilerPlugin.BYTE_CODE_MODE; + public boolean isChecked() { + return JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.BYTE_CODE_MODE; } @Override - public void update( ) - { - setChecked( isChecked( ) ); + public void update() { + setChecked(isChecked()); } } \ No newline at end of file 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 547bd994..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 @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.actions; @@ -16,34 +13,29 @@ 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; -public class ByteCodeActionDelegate extends ActionDelegate implements IEditorActionDelegate -{ +public class ByteCodeActionDelegate extends ActionDelegate implements IEditorActionDelegate { JavaDecompilerClassFileEditor editor; @Override - public void setActiveEditor( IAction action, IEditorPart targetEditor ) - { - if ( targetEditor instanceof JavaDecompilerClassFileEditor ) - { + 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); } } @Override - public void run( IAction action ) - { - new ByteCodeAction( ).run( ); + public void run(IAction action) { + new ByteCodeAction().run(); } @Override - public void selectionChanged( IAction action, ISelection selection ) - { - action.setChecked( JavaDecompilerPlugin.getDefault( ).getSourceMode( ) == JavaDecompilerPlugin.BYTE_CODE_MODE ); + public void selectionChanged(IAction action, ISelection selection) { + action.setChecked(JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.BYTE_CODE_MODE); } } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/ByteCodeHandler.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/ByteCodeHandler.java index 9d3f6e46..96fd1315 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/ByteCodeHandler.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/ByteCodeHandler.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.actions; @@ -15,13 +12,11 @@ import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; -public class ByteCodeHandler extends AbstractHandler -{ +public class ByteCodeHandler extends AbstractHandler { @Override - public Object execute( ExecutionEvent event ) throws ExecutionException - { - new ByteCodeAction( ).run( ); + public Object execute(ExecutionEvent event) throws ExecutionException { + new ByteCodeAction().run(); return null; } 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 59cc2297..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 @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.actions; @@ -18,47 +15,40 @@ 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 -{ +public class ByteCodeMenuItemAction implements IWorkbenchWindowPulldownDelegate, IWorkbenchWindowPulldownDelegate2 { - public ByteCodeMenuItemAction( ) - { - super( ); + public ByteCodeMenuItemAction() { + super(); } @Override - public Menu getMenu( Control parent ) - { + public Menu getMenu(Control parent) { return null; } @Override - public Menu getMenu( Menu parent ) - { + public Menu getMenu(Menu parent) { return null; } @Override - public void init( IWorkbenchWindow window ) - { + public void init(IWorkbenchWindow window) { } @Override - public void dispose( ) - { + public void dispose() { } @Override - public void run( IAction action ) - { - new ByteCodeAction( ).run( ); + public void run(IAction action) { + new ByteCodeAction().run(); } @Override - public void selectionChanged( IAction action, ISelection selection ) - { - action.setChecked( JavaDecompilerPlugin.getDefault( ).getSourceMode( ) == JavaDecompilerPlugin.BYTE_CODE_MODE ); + public void selectionChanged(IAction action, ISelection selection) { + 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/DebugModeAction.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DebugModeAction.java index 571a4eeb..c2e8e106 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DebugModeAction.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DebugModeAction.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.actions; @@ -18,39 +15,33 @@ import org.sf.feeling.decompiler.i18n.Messages; import org.sf.feeling.decompiler.util.UIUtil; -public class DebugModeAction extends Action -{ +public class DebugModeAction extends Action { - public DebugModeAction( ) - { - super( Messages.getString( "DebugModeAction.Action.Text" ), //$NON-NLS-1$ - AS_CHECK_BOX ); + public DebugModeAction() { + super(Messages.getString("DebugModeAction.Action.Text"), //$NON-NLS-1$ + AS_CHECK_BOX); } @Override - public void run( ) - { - JavaDecompilerPlugin.getDefault( ).setDebugMode( !isChecked( ) ); - new DecompileAction( ).run( ); - final JavaDecompilerClassFileEditor editor = UIUtil.getActiveEditor( ); - if ( editor != null ) - { - editor.showSource( ); - editor.notifyPropertiesChange( ); - Display.getDefault( ).asyncExec( new Runnable( ) { - - public void run( ) - { - editor.setFocus( ); + public void run() { + JavaDecompilerPlugin.getDefault().setDebugMode(!isChecked()); + new DecompileAction().run(); + final JavaDecompilerClassFileEditor editor = UIUtil.getActiveEditor(); + if (editor != null) { + editor.showSource(); + editor.notifyPropertiesChange(); + Display.getDefault().asyncExec(new Runnable() { + + public void run() { + editor.setFocus(); } - } ); + }); } } @Override - public boolean isChecked( ) - { - return JavaDecompilerPlugin.getDefault( ).isDebugMode( ); + public boolean isChecked() { + return JavaDecompilerPlugin.getDefault().isDebugMode(); } } \ No newline at end of file diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DebugModeActionDelegate.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DebugModeActionDelegate.java index 8b5abf21..2320b5a7 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DebugModeActionDelegate.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DebugModeActionDelegate.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.actions; @@ -19,30 +16,25 @@ import org.sf.feeling.decompiler.JavaDecompilerPlugin; import org.sf.feeling.decompiler.editor.JavaDecompilerClassFileEditor; -public class DebugModeActionDelegate extends ActionDelegate implements IEditorActionDelegate -{ +public class DebugModeActionDelegate extends ActionDelegate implements IEditorActionDelegate { JavaDecompilerClassFileEditor editor; @Override - public void setActiveEditor( IAction action, IEditorPart targetEditor ) - { - if ( targetEditor instanceof JavaDecompilerClassFileEditor ) - { + public void setActiveEditor(IAction action, IEditorPart targetEditor) { + if (targetEditor instanceof JavaDecompilerClassFileEditor) { editor = (JavaDecompilerClassFileEditor) targetEditor; - action.setChecked( JavaDecompilerPlugin.getDefault( ).isDebugMode( ) ); + action.setChecked(JavaDecompilerPlugin.getDefault().isDebugMode()); } } @Override - public void run( IAction action ) - { - new DebugModeAction( ).run( ); + public void run(IAction action) { + new DebugModeAction().run(); } @Override - public void selectionChanged( IAction action, ISelection selection ) - { - action.setChecked( JavaDecompilerPlugin.getDefault( ).isDebugMode( ) ); + public void selectionChanged(IAction action, ISelection selection) { + action.setChecked(JavaDecompilerPlugin.getDefault().isDebugMode()); } } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DebugModeHandler.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DebugModeHandler.java index fc0339f8..5aaebb94 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DebugModeHandler.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DebugModeHandler.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.actions; @@ -15,13 +12,11 @@ import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; -public class DebugModeHandler extends AbstractHandler -{ +public class DebugModeHandler extends AbstractHandler { @Override - public Object execute( ExecutionEvent event ) throws ExecutionException - { - new DebugModeAction( ).run( ); + public Object execute(ExecutionEvent event) throws ExecutionException { + new DebugModeAction().run(); return null; } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DebugModeMenuItemAction.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DebugModeMenuItemAction.java index ec1e7fe4..5b861b3d 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DebugModeMenuItemAction.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DebugModeMenuItemAction.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.actions; @@ -20,45 +17,37 @@ import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2; import org.sf.feeling.decompiler.JavaDecompilerPlugin; -public class DebugModeMenuItemAction implements IWorkbenchWindowPulldownDelegate, IWorkbenchWindowPulldownDelegate2 -{ +public class DebugModeMenuItemAction implements IWorkbenchWindowPulldownDelegate, IWorkbenchWindowPulldownDelegate2 { - public DebugModeMenuItemAction( ) - { - super( ); + public DebugModeMenuItemAction() { + super(); } @Override - public Menu getMenu( Control parent ) - { + public Menu getMenu(Control parent) { return null; } @Override - public Menu getMenu( Menu parent ) - { + public Menu getMenu(Menu parent) { return null; } @Override - public void init( IWorkbenchWindow window ) - { + public void init(IWorkbenchWindow window) { } @Override - public void dispose( ) - { + public void dispose() { } @Override - public void run( IAction action ) - { - new DebugModeAction( ).run( ); + public void run(IAction action) { + new DebugModeAction().run(); } @Override - public void selectionChanged( IAction action, ISelection selection ) - { - action.setChecked( JavaDecompilerPlugin.getDefault( ).isDebugMode( ) ); + public void selectionChanged(IAction action, ISelection selection) { + action.setChecked(JavaDecompilerPlugin.getDefault().isDebugMode()); } } \ No newline at end of file diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DecompileAction.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DecompileAction.java index 0b89de43..29bcc6a7 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DecompileAction.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DecompileAction.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.actions; @@ -17,35 +14,27 @@ import org.sf.feeling.decompiler.i18n.Messages; import org.sf.feeling.decompiler.util.UIUtil; -public class DecompileAction extends Action -{ +public class DecompileAction extends Action { - public DecompileAction( ) - { - super( Messages.getString( "JavaDecompilerActionBarContributor.Action.Decompile" ) ); //$NON-NLS-1$ + public DecompileAction() { + super(Messages.getString("JavaDecompilerActionBarContributor.Action.Decompile")); //$NON-NLS-1$ } - public DecompileAction( ImageDescriptor actionIcon ) - { - super( Messages.getString( "JavaDecompilerActionBarContributor.Action.Decompile" ), //$NON-NLS-1$ - actionIcon ); + public DecompileAction(ImageDescriptor actionIcon) { + super(Messages.getString("JavaDecompilerActionBarContributor.Action.Decompile"), //$NON-NLS-1$ + actionIcon); } @Override - public void run( ) - { - try - { - new DecompileHandler( ).execute( null ); - } - catch ( ExecutionException e ) - { + public void run() { + try { + new DecompileHandler().execute(null); + } catch (ExecutionException e) { } } @Override - public boolean isEnabled( ) - { - return UIUtil.getActiveEditor( ) != null || UIUtil.getActiveSelection( ) != null; + public boolean isEnabled() { + return UIUtil.getActiveEditor() != null || UIUtil.getActiveSelection() != null; } } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DecompileActionGroup.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DecompileActionGroup.java index cd969dd6..0e78e72e 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DecompileActionGroup.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DecompileActionGroup.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.actions; @@ -35,8 +32,7 @@ import org.sf.feeling.decompiler.editor.JavaDecompilerClassFileEditor; import org.sf.feeling.decompiler.i18n.Messages; -public class DecompileActionGroup extends ActionGroup -{ +public class DecompileActionGroup extends ActionGroup { public static final String MENU_MAIN = "org.sf.feeling.decompiler.main"; //$NON-NLS-1$ @@ -52,123 +48,104 @@ public class DecompileActionGroup extends ActionGroup private JavaDecompilerClassFileEditor fEditor; - public DecompileActionGroup( IViewPart part ) - { - this( part.getSite( ), null ); + public DecompileActionGroup(IViewPart part) { + this(part.getSite(), null); } - public DecompileActionGroup( Page page ) - { - this( page.getSite( ), null ); + public DecompileActionGroup(Page page) { + this(page.getSite(), null); } - public DecompileActionGroup( JavaDecompilerClassFileEditor editor, String groupName, boolean binary ) - { + public DecompileActionGroup(JavaDecompilerClassFileEditor editor, String groupName, boolean binary) { - final PerformanceStats stats = PerformanceStats.getStats( PERF_DECOMPILE_ACTION_GROUP, this ); - stats.startRun( ); + final PerformanceStats stats = PerformanceStats.getStats(PERF_DECOMPILE_ACTION_GROUP, this); + stats.startRun(); fEditor = editor; fGroupName = groupName; - stats.endRun( ); + stats.endRun(); } - public DecompileActionGroup( IWorkbenchSite site, ISelectionProvider selectionProvider ) - { - final PerformanceStats stats = PerformanceStats.getStats( PERF_DECOMPILE_ACTION_GROUP, this ); - stats.startRun( ); + public DecompileActionGroup(IWorkbenchSite site, ISelectionProvider selectionProvider) { + final PerformanceStats stats = PerformanceStats.getStats(PERF_DECOMPILE_ACTION_GROUP, this); + stats.startRun(); - stats.endRun( ); + stats.endRun(); } @Override - public void fillContextMenu( IMenuManager menu ) - { - super.fillContextMenu( menu ); - addSourceSubmenu( menu ); - addMainSubmenu( menu ); + public void fillContextMenu(IMenuManager menu) { + super.fillContextMenu(menu); + addSourceSubmenu(menu); + addMainSubmenu(menu); } /* * @see ActionGroup#dispose() */ @Override - public void dispose( ) - { - super.dispose( ); + public void dispose() { + super.dispose(); } - private void addMainSubmenu( IMenuManager menu ) - { + private void addMainSubmenu(IMenuManager menu) { MenuManager mainSubmenu = new MenuManager( - Messages.getString( "JavaDecompilerActionBarContributor.Menu.Decompiler" ), //$NON-NLS-1$ - MENU_MAIN ); - mainSubmenu.setActionDefinitionId( QUICK_MENU_MAIN ); - if ( fEditor != null ) - { - final ITypeRoot element = getEditorInput( ); - if ( element != null && ActionUtil.isOnBuildPath( element ) ) - { - mainSubmenu.addMenuListener( new IMenuListener( ) { + Messages.getString("JavaDecompilerActionBarContributor.Menu.Decompiler"), //$NON-NLS-1$ + MENU_MAIN); + mainSubmenu.setActionDefinitionId(QUICK_MENU_MAIN); + if (fEditor != null) { + final ITypeRoot element = getEditorInput(); + if (element != null && ActionUtil.isOnBuildPath(element)) { + mainSubmenu.addMenuListener(new IMenuListener() { @Override - public void menuAboutToShow( IMenuManager manager ) - { - showMenu( manager ); + public void menuAboutToShow(IMenuManager manager) { + showMenu(manager); } - } ); - menu.appendToGroup( fGroupName, new Separator( ) ); - menu.appendToGroup( fGroupName, mainSubmenu ); - menu.appendToGroup( fGroupName, new Separator( ) ); + }); + menu.appendToGroup(fGroupName, new Separator()); + menu.appendToGroup(fGroupName, mainSubmenu); + menu.appendToGroup(fGroupName, new Separator()); } } } - private void addSourceSubmenu( IMenuManager menu ) - { + private void addSourceSubmenu(IMenuManager menu) { MenuManager sourceSubmenu = new MenuManager( - Messages.getString( "JavaDecompilerActionBarContributor.Menu.Source" ), //$NON-NLS-1$ - MENU_SOURCE ); - sourceSubmenu.setActionDefinitionId( QUICK_MENU_SOURCE ); - if ( fEditor != null ) - { - final ITypeRoot element = getEditorInput( ); - if ( element != null && ActionUtil.isOnBuildPath( element ) ) - { - sourceSubmenu.addMenuListener( new IMenuListener( ) { + Messages.getString("JavaDecompilerActionBarContributor.Menu.Source"), //$NON-NLS-1$ + MENU_SOURCE); + sourceSubmenu.setActionDefinitionId(QUICK_MENU_SOURCE); + if (fEditor != null) { + final ITypeRoot element = getEditorInput(); + if (element != null && ActionUtil.isOnBuildPath(element)) { + sourceSubmenu.addMenuListener(new IMenuListener() { @Override - public void menuAboutToShow( IMenuManager manager ) - { - showMenu( manager ); + public void menuAboutToShow(IMenuManager manager) { + showMenu(manager); } - } ); - menu.appendToGroup( fGroupName, new Separator( ) ); - menu.appendToGroup( fGroupName, sourceSubmenu ); - menu.appendToGroup( fGroupName, new Separator( ) ); + }); + menu.appendToGroup(fGroupName, new Separator()); + menu.appendToGroup(fGroupName, sourceSubmenu); + menu.appendToGroup(fGroupName, new Separator()); } } } - private void showMenu( IMenuManager submenu ) - { - for ( Iterator iter = Arrays.asList( submenu.getItems( ) ).iterator( ); iter.hasNext( ); ) - { - IContributionItem item = iter.next( ); - if ( item instanceof ActionContributionItem ) - { - IAction action = ( (ActionContributionItem) item ).getAction( ); - if ( action instanceof IUpdate ) - { - ( (IUpdate) action ).update( ); + private void showMenu(IMenuManager submenu) { + for (Iterator iter = Arrays.asList(submenu.getItems()).iterator(); iter.hasNext();) { + IContributionItem item = iter.next(); + if (item instanceof ActionContributionItem) { + IAction action = ((ActionContributionItem) item).getAction(); + if (action instanceof IUpdate) { + ((IUpdate) action).update(); } } } } - private ITypeRoot getEditorInput( ) - { - return JavaUI.getEditorInputTypeRoot( fEditor.getEditorInput( ) ); + private ITypeRoot getEditorInput() { + return JavaUI.getEditorInputTypeRoot(fEditor.getEditorInput()); } } 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 0a367af0..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 @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.actions; @@ -20,33 +17,27 @@ 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; import org.sf.feeling.decompiler.util.UIUtil; -public class DecompileHandler extends AbstractHandler -{ +public class DecompileHandler extends AbstractHandler { @Override - 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 ); - IPreferenceStore prefs = JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ); - String decompilerType = prefs.getString( JavaDecompilerPlugin.DECOMPILER_TYPE ); - new OpenClassesAction( editor, classes, decompilerType ).run( ); - } - else - { - JavaDecompilerClassFileEditor editor = UIUtil.getActiveEditor( ); - if ( editor != null ) - { - if ( editor != null ) - editor.doSetInput( true ); + 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(JavaDecompilerConstants.EDITOR_ID); + IPreferenceStore prefs = JavaDecompilerPlugin.getDefault().getPreferenceStore(); + String decompilerType = prefs.getString(JavaDecompilerConstants.DECOMPILER_TYPE); + new OpenClassesAction(editor, classes, decompilerType).run(); + } else { + JavaDecompilerClassFileEditor editor = UIUtil.getActiveEditor(); + if (editor != null) { + editor.doSetInput(true); } } return null; diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DecompileWithFernFlowerAction.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DecompileWithFernFlowerAction.java deleted file mode 100644 index 1033fdbf..00000000 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DecompileWithFernFlowerAction.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.actions; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.jface.action.Action; -import org.sf.feeling.decompiler.JavaDecompilerPlugin; -import org.sf.feeling.decompiler.i18n.Messages; -import org.sf.feeling.decompiler.util.UIUtil; - -public class DecompileWithFernFlowerAction extends Action -{ - - public DecompileWithFernFlowerAction( ) - { - super( Messages.getString( "JavaDecompilerActionBarContributor.Action.DecompileWithFernFlower" ) ); //$NON-NLS-1$ - this.setImageDescriptor( JavaDecompilerPlugin.getImageDescriptor( "icons/fernflower_16.png" ) ); //$NON-NLS-1$ - } - - @Override - public void run( ) - { - try - { - new DecompileWithFernFlowerHandler( ).execute( null ); - } - catch ( ExecutionException e ) - { - } - } - - @Override - public boolean isEnabled( ) - { - return UIUtil.getActiveEditor( ) != null || UIUtil.getActiveSelection( ) != null; - } -} \ No newline at end of file diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DecompilerMenuItemAction.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DecompilerMenuItemAction.java index 374e0778..178b8e94 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DecompilerMenuItemAction.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DecompilerMenuItemAction.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.actions; @@ -19,51 +16,42 @@ import org.eclipse.ui.IWorkbenchWindowPulldownDelegate; import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2; -public class DecompilerMenuItemAction implements IWorkbenchWindowPulldownDelegate, IWorkbenchWindowPulldownDelegate2 -{ +public class DecompilerMenuItemAction implements IWorkbenchWindowPulldownDelegate, IWorkbenchWindowPulldownDelegate2 { - public DecompilerMenuItemAction( ) - { - super( ); + public DecompilerMenuItemAction() { + super(); } @Override - public Menu getMenu( Control parent ) - { - return new SubMenuCreator( ).getMenu( parent ); + public Menu getMenu(Control parent) { + return new SubMenuCreator().getMenu(parent); } @Override - public Menu getMenu( Menu parent ) - { - return new SubMenuCreator( ).getMenu( parent ); + public Menu getMenu(Menu parent) { + return new SubMenuCreator().getMenu(parent); } @Override - public void init( IWorkbenchWindow window ) - { + public void init(IWorkbenchWindow window) { } @Override - public void dispose( ) - { + public void dispose() { } @Override - public void run( IAction action ) - { - new DecompileAction( ).run( ); + public void run(IAction action) { + new DecompileAction().run(); } @Override - public void selectionChanged( IAction action, ISelection selection ) - { - action.setEnabled( isEnable( ) ); + public void selectionChanged(IAction action, ISelection selection) { + action.setEnabled(isEnable()); } - private boolean isEnable( ) - { + private boolean isEnable() { return true; } } \ No newline at end of file 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 640306be..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 @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.actions; @@ -14,59 +11,43 @@ 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; import org.sf.feeling.decompiler.util.UIUtil; -public class DecompilerPeferenceAction extends Action -{ +public class DecompilerPeferenceAction extends Action { - public DecompilerPeferenceAction( ) - { - super( Messages.getString( "JavaDecompilerActionBarContributor.Action.Preferences" ) ); //$NON-NLS-1$ + public DecompilerPeferenceAction() { + super(Messages.getString("JavaDecompilerActionBarContributor.Action.Preferences")); //$NON-NLS-1$ } @Override - public void run( ) - { - JavaDecompilerClassFileEditor editor = UIUtil.getActiveDecompilerEditor( ); + 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$ } - if ( editor != null ) - { - PreferencesUtil.createPreferenceDialogOn( Display.getDefault( ).getActiveShell( ), - showId, // $NON-NLS-1$ - editor.collectContextMenuPreferencePages( ), - null ).open( ); - } - else - { - PreferencesUtil.createPreferenceDialogOn( Display.getDefault( ).getActiveShell( ), - showId, // $NON-NLS-1$ - new String[]{ - showId // $NON-NLS-1$ - }, - null ).open( ); + if (editor != null) { + PreferencesUtil.createPreferenceDialogOn(Display.getDefault().getActiveShell(), showId, // $NON-NLS-1$ + editor.collectContextMenuPreferencePages(), null).open(); + } else { + PreferencesUtil.createPreferenceDialogOn(Display.getDefault().getActiveShell(), showId, // $NON-NLS-1$ + new String[] { showId // $NON-NLS-1$ + }, null).open(); } } @Override - public boolean isEnabled( ) - { + public boolean isEnabled() { return true; } } \ No newline at end of file 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 fbd0f25f..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 @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.actions; @@ -14,55 +11,48 @@ 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; import org.sf.feeling.decompiler.util.UIUtil; -public class DisassemblerAction extends Action implements IUpdate -{ +public class DisassemblerAction extends Action implements IUpdate { public static final String ID = "Disassembler"; //$NON-NLS-1$ - public DisassemblerAction( ) - { - super( Messages.getString( "JavaDecompilerActionBarContributor.Action.Disassembler" ), AS_CHECK_BOX ); //$NON-NLS-1$ + public DisassemblerAction() { + super(Messages.getString("JavaDecompilerActionBarContributor.Action.Disassembler"), AS_CHECK_BOX); //$NON-NLS-1$ } @Override - public void run( ) - { - JavaDecompilerPlugin.getDefault( ).setSourceMode( JavaDecompilerPlugin.DISASSEMBLER_MODE ); - setChecked( true ); - final JavaDecompilerClassFileEditor editor = UIUtil.getActiveEditor( ); - if ( editor != null ) - { - editor.showSource( ); - editor.notifyPropertiesChange( ); - Display.getDefault( ).asyncExec( new Runnable( ) { - - public void run( ) - { - editor.setFocus( ); + public void run() { + JavaDecompilerPlugin.getDefault().setSourceMode(JavaDecompilerConstants.DISASSEMBLER_MODE); + setChecked(true); + final JavaDecompilerClassFileEditor editor = UIUtil.getActiveEditor(); + if (editor != null) { + editor.showSource(); + editor.notifyPropertiesChange(); + Display.getDefault().asyncExec(new Runnable() { + + public void run() { + editor.setFocus(); } - } ); + }); } } @Override - public boolean isEnabled( ) - { - JavaDecompilerClassFileEditor editor = UIUtil.getActiveEditor( ); + public boolean isEnabled() { + JavaDecompilerClassFileEditor editor = UIUtil.getActiveEditor(); return editor != null; } - public boolean isChecked( ) - { - return JavaDecompilerPlugin.getDefault( ).getSourceMode( ) == JavaDecompilerPlugin.DISASSEMBLER_MODE; + public boolean isChecked() { + return JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.DISASSEMBLER_MODE; } - public void update( ) - { - setChecked( isChecked( ) ); + public void update() { + setChecked(isChecked()); } } \ No newline at end of file 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 68b2cfec..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 @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.actions; @@ -16,35 +13,30 @@ 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; -public class DisassemblerActionDelegate extends ActionDelegate implements IEditorActionDelegate -{ +public class DisassemblerActionDelegate extends ActionDelegate implements IEditorActionDelegate { JavaDecompilerClassFileEditor editor; @Override - public void setActiveEditor( IAction action, IEditorPart targetEditor ) - { - if ( targetEditor instanceof JavaDecompilerClassFileEditor ) - { + 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); } } @Override - public void run( IAction action ) - { - new DisassemblerAction( ).run( ); + public void run(IAction action) { + new DisassemblerAction().run(); } @Override - public void selectionChanged( IAction action, ISelection selection ) - { - action.setChecked( - JavaDecompilerPlugin.getDefault( ).getSourceMode( ) == JavaDecompilerPlugin.DISASSEMBLER_MODE ); + public void selectionChanged(IAction action, ISelection selection) { + action.setChecked(JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.DISASSEMBLER_MODE); } } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DisassemblerHandler.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DisassemblerHandler.java index e753460f..400decd9 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DisassemblerHandler.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/DisassemblerHandler.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.actions; @@ -15,13 +12,11 @@ import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; -public class DisassemblerHandler extends AbstractHandler -{ +public class DisassemblerHandler extends AbstractHandler { @Override - public Object execute( ExecutionEvent event ) throws ExecutionException - { - new DisassemblerAction( ).run( ); + public Object execute(ExecutionEvent event) throws ExecutionException { + new DisassemblerAction().run(); return null; } 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 431625ad..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 @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.actions; @@ -18,48 +15,40 @@ 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 -{ +public class DisassemblerMenuItemAction implements IWorkbenchWindowPulldownDelegate, IWorkbenchWindowPulldownDelegate2 { - public DisassemblerMenuItemAction( ) - { - super( ); + public DisassemblerMenuItemAction() { + super(); } @Override - public Menu getMenu( Control parent ) - { + public Menu getMenu(Control parent) { return null; } @Override - public Menu getMenu( Menu parent ) - { + public Menu getMenu(Menu parent) { return null; } @Override - public void init( IWorkbenchWindow window ) - { + public void init(IWorkbenchWindow window) { } @Override - public void dispose( ) - { + public void dispose() { } @Override - public void run( IAction action ) - { - new DisassemblerAction( ).run( ); + public void run(IAction action) { + new DisassemblerAction().run(); } @Override - public void selectionChanged( IAction action, ISelection selection ) - { - action.setChecked( - JavaDecompilerPlugin.getDefault( ).getSourceMode( ) == JavaDecompilerPlugin.DISASSEMBLER_MODE ); + public void selectionChanged(IAction action, ISelection selection) { + 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/ExportEditorSourceAction.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/ExportEditorSourceAction.java index 3815ba07..683ed905 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/ExportEditorSourceAction.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/ExportEditorSourceAction.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.actions; @@ -26,61 +23,48 @@ import org.sf.feeling.decompiler.util.FileUtil; import org.sf.feeling.decompiler.util.UIUtil; -public class ExportEditorSourceAction extends Action -{ +public class ExportEditorSourceAction extends Action { - public ExportEditorSourceAction( ) - { - super( Messages.getString( "JavaDecompilerActionBarContributor.Action.ExportSource" ) ); //$NON-NLS-1$ - this.setImageDescriptor( JavaDecompilerPlugin.getImageDescriptor( "icons/etool16/export_wiz.png" ) ); //$NON-NLS-1$ - this.setDisabledImageDescriptor( JavaDecompilerPlugin.getImageDescriptor( "icons/dtool16/export_wiz.png" ) ); //$NON-NLS-1$ + public ExportEditorSourceAction() { + super(Messages.getString("JavaDecompilerActionBarContributor.Action.ExportSource")); //$NON-NLS-1$ + this.setImageDescriptor(JavaDecompilerPlugin.getImageDescriptor("icons/etool16/export_wiz.png")); //$NON-NLS-1$ + this.setDisabledImageDescriptor(JavaDecompilerPlugin.getImageDescriptor("icons/dtool16/export_wiz.png")); //$NON-NLS-1$ } @Override - public void run( ) - { + public void run() { JavaDecompilerClassFileEditor classEditor = null; - JavaDecompilerClassFileEditor editor = UIUtil.getActiveEditor( ); - if ( editor != null ) + JavaDecompilerClassFileEditor editor = UIUtil.getActiveEditor(); + if (editor != null) classEditor = editor; - if ( classEditor != null ) - { - IClassFile cf = ( (IClassFileEditorInput) classEditor.getEditorInput( ) ).getClassFile( ); + if (classEditor != null) { + IClassFile cf = ((IClassFileEditorInput) classEditor.getEditorInput()).getClassFile(); - FileDialog dialog = new FileDialog( classEditor.getEditorSite( ).getShell( ), SWT.SAVE | SWT.SHEET ); - dialog.setFileName( cf.getElementName( ).replaceAll( "\\..+", //$NON-NLS-1$ - "" ) ); //$NON-NLS-1$ - dialog.setFilterExtensions( new String[]{ - "*.java" //$NON-NLS-1$ - } ); - String file = dialog.open( ); - if ( file != null && file.trim( ).length( ) > 0 ) - { - String projectFile = file.trim( ); - try - { + FileDialog dialog = new FileDialog(classEditor.getEditorSite().getShell(), SWT.SAVE | SWT.SHEET); + dialog.setFileName(cf.getElementName().replaceAll("\\..+", //$NON-NLS-1$ + "")); //$NON-NLS-1$ + dialog.setFilterExtensions(new String[] { "*.java" //$NON-NLS-1$ + }); + String file = dialog.open(); + if (file != null && file.trim().length() > 0) { + String projectFile = file.trim(); + try { - FileUtil.writeToFile( new File( projectFile ), cf.getSource( ) ); + FileUtil.writeToFile(new File(projectFile), cf.getSource()); + } catch (CoreException e) { + ExceptionHandler.handle(e, + Messages.getString("JavaDecompilerActionBarContributor.ErrorDialog.Title"), //$NON-NLS-1$ + Messages.getString("JavaDecompilerActionBarContributor.ErrorDialog.Message.ExportFailed")); //$NON-NLS-1$ } - catch ( CoreException e ) - { - ExceptionHandler.handle( e, - Messages.getString( "JavaDecompilerActionBarContributor.ErrorDialog.Title" ), //$NON-NLS-1$ - Messages.getString( - "JavaDecompilerActionBarContributor.ErrorDialog.Message.ExportFailed" ) ); //$NON-NLS-1$ - } - } - else - { + } else { return; } } } @Override - public boolean isEnabled( ) - { - JavaDecompilerClassFileEditor editor = UIUtil.getActiveEditor( ); + public boolean isEnabled() { + JavaDecompilerClassFileEditor editor = UIUtil.getActiveEditor(); return editor != null; } } \ 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 a758dc40..4c300939 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 @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.actions; @@ -17,6 +14,7 @@ import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -43,6 +41,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; @@ -50,468 +49,349 @@ import org.sf.feeling.decompiler.util.Logger; import org.sf.feeling.decompiler.util.UIUtil; -public class ExportSourceAction extends Action -{ +public class ExportSourceAction extends Action { + + private static final String[] ZIP_FILTER = new String[] { "*.zip" }; private List selection = null; private boolean isFlat = false; - public ExportSourceAction( List selection ) - { - super( Messages.getString( "ExportSourceAction.Action.Text" ) ); //$NON-NLS-1$ - this.setImageDescriptor( JavaDecompilerPlugin.getImageDescriptor( "icons/etool16/export_wiz.png" ) ); //$NON-NLS-1$ - this.setDisabledImageDescriptor( JavaDecompilerPlugin.getImageDescriptor( "icons/dtool16/export_wiz.png" ) ); //$NON-NLS-1$ + public ExportSourceAction(List selection) { + super(Messages.getString("ExportSourceAction.Action.Text")); //$NON-NLS-1$ + this.setImageDescriptor(JavaDecompilerPlugin.getImageDescriptor("icons/etool16/export_wiz.png")); //$NON-NLS-1$ + this.setDisabledImageDescriptor(JavaDecompilerPlugin.getImageDescriptor("icons/dtool16/export_wiz.png")); //$NON-NLS-1$ this.selection = selection; - this.isFlat = UIUtil.isPackageFlat( ); + this.isFlat = UIUtil.isPackageFlat(); } @Override - public void run( ) - { - if ( selection == null || selection.isEmpty( ) ) + public void run() { + if (selection == null || selection.isEmpty()) { 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 ); + IPreferenceStore prefs = JavaDecompilerPlugin.getDefault().getPreferenceStore(); + 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 ) - { + Object firstElement = selection.get(0); + if (selection.size() == 1 && firstElement instanceof IClassFile) { IClassFile cf = (IClassFile) firstElement; - exportClass( decompilerType, reuseBuf, always, cf ); - } - else if ( selection.size( ) == 1 && firstElement instanceof IPackageFragmentRoot ) - { + exportClass(decompilerType, reuseBuf, always, cf); + } else if (selection.size() == 1 && firstElement instanceof IPackageFragmentRoot) { IPackageFragmentRoot root = (IPackageFragmentRoot) firstElement; - FileDialog dialog = new FileDialog( Display.getDefault( ).getActiveShell( ), SWT.SAVE | SWT.SHEET ); - String fileName = root.getElementName( ); - int index = fileName.lastIndexOf( '.' ); - if ( index != -1 ) - { - fileName = fileName.substring( 0, index ); + FileDialog dialog = new FileDialog(Display.getDefault().getActiveShell(), SWT.SAVE | SWT.SHEET); + String fileName = root.getElementName(); + int index = fileName.lastIndexOf('.'); + if (index != -1) { + fileName = fileName.substring(0, index); } - dialog.setFileName( fileName + "-src" ); //$NON-NLS-1$ - dialog.setFilterExtensions( new String[]{ - "*.zip" //$NON-NLS-1$ - } ); - String file = dialog.open( ); - if ( file != null && file.trim( ).length( ) > 0 ) - { - final String projectFile = file.trim( ); - try - { - final IJavaElement[] children = root.getChildren( ); - exportPackagesSource( decompilerType, reuseBuf, always, projectFile, children ); - } - catch ( CoreException e ) - { - ExceptionHandler.handle( e, - Messages.getString( "ExportSourceAction.ErrorDialog.Title" ), //$NON-NLS-1$ - Messages.getString( "ExportSourceAction.ErrorDialog.Message.CollectClassInfo" ) ); //$NON-NLS-1$ + dialog.setFileName(fileName + "-src"); //$NON-NLS-1$ + dialog.setFilterExtensions(ZIP_FILTER); + String file = dialog.open(); + if (file != null && file.trim().length() > 0) { + final String projectFile = file.trim(); + try { + final IJavaElement[] children = root.getChildren(); + exportPackagesSource(decompilerType, reuseBuf, always, projectFile, children); + } catch (CoreException e) { + ExceptionHandler.handle(e, Messages.getString("ExportSourceAction.ErrorDialog.Title"), //$NON-NLS-1$ + Messages.getString("ExportSourceAction.ErrorDialog.Message.CollectClassInfo")); //$NON-NLS-1$ } - } - else - { + } else { return; } - } - else - { + } else { IPackageFragmentRoot root = null; - if ( firstElement instanceof IClassFile ) - { - root = (IPackageFragmentRoot) ( (IClassFile) firstElement ).getParent( ).getParent( ); - } - else if ( firstElement instanceof IPackageFragment ) - { - root = (IPackageFragmentRoot) ( (IPackageFragment) firstElement ).getParent( ); + if (firstElement instanceof IClassFile) { + root = (IPackageFragmentRoot) ((IClassFile) firstElement).getParent().getParent(); + } else if (firstElement instanceof IPackageFragment) { + root = (IPackageFragmentRoot) ((IPackageFragment) firstElement).getParent(); } - if ( root == null ) + if (root == null) return; - FileDialog dialog = new FileDialog( Display.getDefault( ).getActiveShell( ), SWT.SAVE | SWT.SHEET ); - String fileName = root.getElementName( ); - int index = fileName.lastIndexOf( '.' ); - if ( index != -1 ) - { - fileName = fileName.substring( 0, index ); + FileDialog dialog = new FileDialog(Display.getDefault().getActiveShell(), SWT.SAVE | SWT.SHEET); + String fileName = root.getElementName(); + int index = fileName.lastIndexOf('.'); + if (index != -1) { + fileName = fileName.substring(0, index); } - dialog.setFileName( fileName + "-src" ); //$NON-NLS-1$ - dialog.setFilterExtensions( new String[]{ - "*.zip" //$NON-NLS-1$ - } ); - String file = dialog.open( ); - if ( file != null && file.trim( ).length( ) > 0 ) - { - final String projectFile = file.trim( ); - - exportPackagesSource( decompilerType, - reuseBuf, - always, - projectFile, - (IJavaElement[]) selection.toArray( new IJavaElement[0] ) ); - } - else - { + dialog.setFileName(fileName + "-src"); //$NON-NLS-1$ + dialog.setFilterExtensions(ZIP_FILTER); + String file = dialog.open(); + if (file != null && file.trim().length() > 0) { + final String projectFile = file.trim(); + + exportPackagesSource(decompilerType, reuseBuf, always, projectFile, + (IJavaElement[]) selection.toArray(new IJavaElement[0])); + } else { return; } } } - private void exportPackagesSource( final String decompilerType, final boolean reuseBuf, final boolean always, - final String projectFile, final IJavaElement[] children ) - { - try - { - final List exceptions = new ArrayList( ); - ProgressMonitorDialog dialog = new ProgressMonitorDialog( Display.getDefault( ).getActiveShell( ) ); - dialog.run( true, true, new IRunnableWithProgress( ) { + private void exportPackagesSource(final String decompilerType, final boolean reuseBuf, final boolean always, + final String projectFile, final IJavaElement[] children) { + try { + final List exceptions = new ArrayList(); + ProgressMonitorDialog dialog = new ProgressMonitorDialog(Display.getDefault().getActiveShell()); + dialog.run(true, true, new IRunnableWithProgress() { @Override - public void run( final IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException - { - exportPackageSources( monitor, - decompilerType, - reuseBuf, - always, - projectFile, - children, - exceptions ); - - final File workingDir = new File( - JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ).getString( - JavaDecompilerPlugin.TEMP_DIR ) );// $NON-NLS-1$ - - if ( workingDir != null && workingDir.exists( ) ) - { - try - { - FileUtil.deleteDirectory( null, workingDir, 0 ); - } - catch ( IOException e ) - { - Logger.debug( e ); + public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + exportPackageSources(monitor, decompilerType, reuseBuf, always, projectFile, children, exceptions); + + final File workingDir = new File(JavaDecompilerPlugin.getDefault().getPreferenceStore() + .getString(JavaDecompilerConstants.TEMP_DIR));// $NON-NLS-1$ + + if (workingDir != null && workingDir.exists()) { + try { + FileUtil.deleteDirectory(null, workingDir, 0); + } catch (IOException e) { + Logger.debug(e); } } } - } ); + }); - if ( dialog.getProgressMonitor( ).isCanceled( ) ) - { - MessageDialog.openInformation( Display.getDefault( ).getActiveShell( ), - 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, - ( exceptions.size( ) <= 1 - ? Messages.getFormattedString( "ExportSourceAction.WarningDialog.Message.Failed", //$NON-NLS-1$ - new String[]{ - "" + exceptions.size( ) //$NON-NLS-1$ - } ) - : Messages.getFormattedString( "ExportSourceAction.WarningDialog.Message.Failed.Multi", //$NON-NLS-1$ - new String[]{ - "" + exceptions.size( ) //$NON-NLS-1$ - } ) ), - null ) { + if (dialog.getProgressMonitor().isCanceled()) { + MessageDialog.openInformation(Display.getDefault().getActiveShell(), + 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(JavaDecompilerConstants.PLUGIN_ID, IStatus.WARNING, + (exceptions.size() <= 1 + ? Messages.getFormattedString("ExportSourceAction.WarningDialog.Message.Failed", //$NON-NLS-1$ + new String[] { "" + exceptions.size() //$NON-NLS-1$ + }) + : Messages.getFormattedString("ExportSourceAction.WarningDialog.Message.Failed.Multi", //$NON-NLS-1$ + new String[] { "" + exceptions.size() //$NON-NLS-1$ + })), null) { @Override - public void add( IStatus status ) - { - super.add( status ); - setSeverity( IStatus.WARNING ); + public void add(IStatus status) { + super.add(status); + setSeverity(IStatus.WARNING); } }; - for ( int i = 0; i < exceptions.size( ); i++ ) - { - Status exception = (Status) exceptions.get( i ); - status.add( exception ); + for (int i = 0; i < exceptions.size(); i++) { + Status exception = (Status) exceptions.get(i); + status.add(exception); } - JavaDecompilerPlugin.getDefault( ).getLog( ).log( status ); - ErrorDialog.openError( Display.getDefault( ).getActiveShell( ), - Messages.getString( "ExportSourceAction.WarningDialog.Title" ), //$NON-NLS-1$ - Messages.getString( "ExportSourceAction.WarningDialog.Message.Success" ), //$NON-NLS-1$ - status ); + JavaDecompilerPlugin.getDefault().getLog().log(status); + ErrorDialog.openError(Display.getDefault().getActiveShell(), + Messages.getString("ExportSourceAction.WarningDialog.Title"), //$NON-NLS-1$ + Messages.getString("ExportSourceAction.WarningDialog.Message.Success"), //$NON-NLS-1$ + status); + } else { + MessageDialog.openInformation(Display.getDefault().getActiveShell(), + Messages.getString("ExportSourceAction.InfoDialog.Title"), //$NON-NLS-1$ + Messages.getString("ExportSourceAction.InfoDialog.Message.Success")); //$NON-NLS-1$ } - else - { - MessageDialog.openInformation( Display.getDefault( ).getActiveShell( ), - Messages.getString( "ExportSourceAction.InfoDialog.Title" ), //$NON-NLS-1$ - Messages.getString( "ExportSourceAction.InfoDialog.Message.Success" ) ); //$NON-NLS-1$ - } - } - catch ( Exception e ) - { - IStatus status = new Status( IStatus.ERROR, - JavaDecompilerPlugin.PLUGIN_ID, - Messages.getString( "ExportSourceAction.Status.Error.DecompileAndExport" ), //$NON-NLS-1$ - e ); - ExceptionHandler.handle( status, - Messages.getString( "ExportSourceAction.ErrorDialog.Title" ), //$NON-NLS-1$ - status.getMessage( ) ); + } catch (Exception e) { + 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$ + status.getMessage()); } } - private void exportPackageSources( IProgressMonitor monitor, final String decompilerType, final boolean reuseBuf, - final boolean always, final String projectFile, final IJavaElement[] children, List exceptions ) - throws InvocationTargetException, InterruptedException - { - monitor.beginTask( Messages.getString( "ExportSourceAction.Task.Begin" ), //$NON-NLS-1$ - 1000000 ); + private void exportPackageSources(IProgressMonitor monitor, final String decompilerType, final boolean reuseBuf, + final boolean always, final String projectFile, final IJavaElement[] children, List exceptions) + throws InvocationTargetException, InterruptedException { + monitor.beginTask(Messages.getString("ExportSourceAction.Task.Begin"), //$NON-NLS-1$ + 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( ) ); + + System.currentTimeMillis()); - Map classes = new HashMap( ); - for ( int i = 0; i < children.length; i++ ) - { - if ( monitor.isCanceled( ) ) + Map> classesMap = new HashMap(); + for (IJavaElement child : children) { + if (monitor.isCanceled()) { return; - IJavaElement child = children[i]; - try - { - collectClasses( child, classes, monitor ); } - catch ( JavaModelException e ) - { - IStatus status = new Status( IStatus.ERROR, - JavaDecompilerPlugin.PLUGIN_ID, - Messages.getString( "ExportSourceAction.Status.Error.CollectPackage" ), //$NON-NLS-1$ - e ); - exceptions.add( status ); + try { + collectClasses(child, classesMap, monitor); + } catch (JavaModelException e) { + IStatus status = new Status(IStatus.ERROR, JavaDecompilerConstants.PLUGIN_ID, + Messages.getString("ExportSourceAction.Status.Error.CollectPackage"), //$NON-NLS-1$ + e); + exceptions.add(status); } } - monitor.worked( 20000 ); + monitor.worked(20000); - IPackageFragment[] pkgs = (IPackageFragment[]) classes.keySet( ).toArray( new IPackageFragment[0] ); + IPackageFragment[] pkgs = classesMap.keySet().toArray(new IPackageFragment[0]); int step = 880000 / pkgs.length; - for ( int i = 0; i < pkgs.length; i++ ) - { - if ( monitor.isCanceled( ) ) + for (IPackageFragment pkg : pkgs) { + if (monitor.isCanceled()) { return; - IPackageFragment pkg = pkgs[i]; - List clazzs = (List) classes.get( pkg ); - if ( clazzs.size( ) == 0 ) - { - monitor.worked( step ); + } + List clazzList = classesMap.get(pkg); + if (clazzList.isEmpty()) { + monitor.worked(step); continue; } int total = 0; - int classStep = step / clazzs.size( ); - for ( int j = 0; j < clazzs.size( ); j++ ) - { - if ( monitor.isCanceled( ) ) + int classStep = step / clazzList.size(); + for (IJavaElement clazz : clazzList) { + if (monitor.isCanceled()) { return; - IJavaElement clazz = (IJavaElement) clazzs.get( j ); - if ( clazz instanceof IClassFile && clazz.getParent( ) instanceof IPackageFragment ) - { - String className = pkg.getElementName( ); - if ( pkg.getElementName( ).length( ) > 0 ) - { - className += ( "." + clazz.getElementName( ) ); //$NON-NLS-1$ + } + if (clazz instanceof IClassFile && clazz.getParent() instanceof IPackageFragment) { + String className = pkg.getElementName(); + if (pkg.getElementName().length() > 0) { + className += ("." + clazz.getElementName()); //$NON-NLS-1$ } - monitor.subTask( className ); - try - { + monitor.subTask(className); + try { IClassFile cf = (IClassFile) clazz; - if ( cf.getElementName( ).indexOf( '$' ) != -1 ) + if (cf.getElementName().indexOf('$') != -1) { continue; - String result = DecompileUtil.decompile( cf, decompilerType, always, reuseBuf, true ); - if ( result != null ) - { - String packageName = pkg.getElementName( ).replace( '.', '/' ); - if ( packageName.length( ) > 0 ) + } + String result = DecompileUtil.decompile(cf, decompilerType, always, reuseBuf, true); + if (result != null) { + String packageName = pkg.getElementName().replace('.', '/'); + if (packageName.length() > 0) { packageName += "/"; //$NON-NLS-1$ + } FileUtil.writeToFile( - new File( workingDir, - packageName - + cf.getElementName( ).replaceAll( "\\..+", "" ) //$NON-NLS-1$ //$NON-NLS-2$ - + ".java" ), //$NON-NLS-1$ - result ); + new File(workingDir, packageName + cf.getElementName().replaceAll("\\..+", "") //$NON-NLS-1$ //$NON-NLS-2$ + + ".java"), //$NON-NLS-1$ + result); + } else { + 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); } - else - { - IStatus status = new Status( IStatus.ERROR, - JavaDecompilerPlugin.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, - Messages.getFormattedString( "ExportSourceAction.Status.Error.DecompileFailed", //$NON-NLS-1$ - new String[]{ - className - } ) ); - exceptions.add( status ); + } catch (Exception e) { + IStatus status = new Status(IStatus.ERROR, JavaDecompilerConstants.PLUGIN_ID, + Messages.getFormattedString("ExportSourceAction.Status.Error.DecompileFailed", //$NON-NLS-1$ + new String[] { className })); + exceptions.add(status); } } total += classStep; - monitor.worked( classStep ); + monitor.worked(classStep); } - if ( total < step ) - { - monitor.worked( step - total ); + if (total < step) { + monitor.worked(step - total); } } - try - { + try { int exportStep = 80000 / pkgs.length; - monitor.setTaskName( Messages.getString( "ExportSourceAction.Task.ExportSource" ) ); //$NON-NLS-1$ - monitor.subTask( "" ); //$NON-NLS-1$ - ZipOutputStream zos = new ZipOutputStream( - new BufferedOutputStream( new FileOutputStream( projectFile ) ) ); - zos.setLevel( Deflater.BEST_SPEED ); - FileUtil.recursiveZip( monitor, - zos, - workingDir, - "", //$NON-NLS-1$ - null, - exportStep ); - monitor.subTask( "" ); //$NON-NLS-1$ - zos.close( ); + monitor.setTaskName(Messages.getString("ExportSourceAction.Task.ExportSource")); //$NON-NLS-1$ + monitor.subTask(""); //$NON-NLS-1$ + try (ZipOutputStream zos = new ZipOutputStream( + new BufferedOutputStream(new FileOutputStream(projectFile)))) { + zos.setLevel(Deflater.BEST_SPEED); + FileUtil.recursiveZip(monitor, zos, workingDir, "", //$NON-NLS-1$ + null, exportStep); + monitor.subTask(""); //$NON-NLS-1$ + } int total = exportStep * pkgs.length; - if ( total < 80000 ) - { - monitor.worked( 80000 - total ); + if (total < 80000) { + monitor.worked(80000 - total); } int deleteStep = 20000 / pkgs.length; - monitor.setTaskName( Messages.getString( "ExportSourceAction.Task.Clean" ) ); //$NON-NLS-1$ - monitor.subTask( "" ); //$NON-NLS-1$ - FileUtil.deleteDirectory( monitor, workingDir.getParentFile( ), deleteStep ); + monitor.setTaskName(Messages.getString("ExportSourceAction.Task.Clean")); //$NON-NLS-1$ + monitor.subTask(""); //$NON-NLS-1$ + FileUtil.deleteDirectory(monitor, workingDir.getParentFile(), deleteStep); total = deleteStep * pkgs.length; - if ( total < 20000 ) - { - monitor.worked( 20000 - total ); + if (total < 20000) { + monitor.worked(20000 - total); } - } - catch ( Exception e ) - { - final IStatus status = new Status( IStatus.ERROR, - JavaDecompilerPlugin.PLUGIN_ID, - Messages.getString( "ExportSourceAction.Status.Error.ExportFailed" ), //$NON-NLS-1$ - e ); - exceptions.add( status ); + } catch (Exception e) { + final IStatus status = new Status(IStatus.ERROR, JavaDecompilerConstants.PLUGIN_ID, + Messages.getString("ExportSourceAction.Status.Error.ExportFailed"), //$NON-NLS-1$ + e); + exceptions.add(status); } } - private void collectClasses( IJavaElement element, Map classes, IProgressMonitor monitor ) throws JavaModelException - { - if ( element instanceof IPackageFragment ) - { + private void collectClasses(IJavaElement element, Map> classesMap, + IProgressMonitor monitor) throws JavaModelException { + if (element instanceof IPackageFragment) { IPackageFragment pkg = (IPackageFragment) element; - if ( !classes.containsKey( pkg ) ) - { - monitor.subTask( pkg.getElementName( ) ); - List list = new ArrayList( ); - IJavaElement[] children = pkg.getChildren( ); - for ( int i = 0; i < children.length; i++ ) - { - list.add( children[i] ); - } - classes.put( pkg, list ); + if (!classesMap.containsKey(pkg)) { + monitor.subTask(pkg.getElementName()); + List list = new ArrayList<>(); + Collections.addAll(list, pkg.getChildren()); + classesMap.put(pkg, list); } - if ( !isFlat ) - { - IPackageFragmentRoot root = (IPackageFragmentRoot) pkg.getParent( ); - IJavaElement[] children = root.getChildren( ); - for ( int i = 0; i < root.getChildren( ).length; i++ ) - { + if (!isFlat) { + IPackageFragmentRoot root = (IPackageFragmentRoot) pkg.getParent(); + IJavaElement[] children = root.getChildren(); + for (int i = 0; i < root.getChildren().length; i++) { IPackageFragment child = (IPackageFragment) children[i]; - if ( child.getElementName( ).startsWith( pkg.getElementName( ) + "." ) //$NON-NLS-1$ - && !classes.containsKey( child ) ) - { - collectClasses( child, classes, monitor ); + if (child.getElementName().startsWith(pkg.getElementName() + ".") //$NON-NLS-1$ + && !classesMap.containsKey(child)) { + collectClasses(child, classesMap, monitor); } } } - } - else if ( element instanceof IClassFile ) - { - IPackageFragment pkg = (IPackageFragment) ( (IClassFile) element ).getParent( ); - if ( !classes.containsKey( pkg ) ) - { - monitor.subTask( pkg.getElementName( ) ); - List list = new ArrayList( ); - list.add( element ); - classes.put( pkg, list ); - } - else - { - ( (List) classes.get( pkg ) ).add( element ); + } else if (element instanceof IClassFile) { + IClassFile classFile = (IClassFile) element; + IPackageFragment pkg = (IPackageFragment) classFile.getParent(); + if (!classesMap.containsKey(pkg)) { + monitor.subTask(pkg.getElementName()); + List list = new ArrayList<>(); + list.add(element); + classesMap.put(pkg, list); + } else { + classesMap.get(pkg).add(element); } } } - private void exportClass( String decompilerType, boolean reuseBuf, boolean always, IClassFile cf ) - { - FileDialog dialog = new FileDialog( Display.getDefault( ).getActiveShell( ), SWT.SAVE | SWT.SHEET ); - dialog.setFileName( cf.getElementName( ).replaceAll( "\\..+", "" ) ); //$NON-NLS-1$ //$NON-NLS-2$ - dialog.setFilterExtensions( new String[]{ - "*.java" //$NON-NLS-1$ - } ); - String file = dialog.open( ); - if ( file != null && file.trim( ).length( ) > 0 ) - { - IPackageFragment pkg = (IPackageFragment) cf.getParent( ); - String className = pkg.getElementName( ); - if ( pkg.getElementName( ).length( ) > 0 ) - { - className += ( "." + cf.getElementName( ) ); //$NON-NLS-1$ + private void exportClass(String decompilerType, boolean reuseBuf, boolean always, IClassFile cf) { + FileDialog dialog = new FileDialog(Display.getDefault().getActiveShell(), SWT.SAVE | SWT.SHEET); + dialog.setFileName(cf.getElementName().replaceAll("\\..+", "")); //$NON-NLS-1$ //$NON-NLS-2$ + dialog.setFilterExtensions(new String[] { "*.java" //$NON-NLS-1$ + }); + String file = dialog.open(); + if (file != null && file.trim().length() > 0) { + IPackageFragment pkg = (IPackageFragment) cf.getParent(); + String className = pkg.getElementName(); + if (pkg.getElementName().length() > 0) { + className += ("." + cf.getElementName()); //$NON-NLS-1$ } - String projectFile = file.trim( ); - try - { - String result = DecompileUtil.decompile( cf, decompilerType, always, reuseBuf, true ); - if ( result != null ) - FileUtil.writeToFile( new File( projectFile ), result ); - else - { - IStatus status = new Status( IStatus.ERROR, - JavaDecompilerPlugin.PLUGIN_ID, - Messages.getFormattedString( "ExportSourceAction.Status.Error.DecompileFailed", //$NON-NLS-1$ - new String[]{ - className - } ) ); - throw new CoreException( status ); + String projectFile = file.trim(); + try { + String result = DecompileUtil.decompile(cf, decompilerType, always, reuseBuf, true); + if (result != null) { + FileUtil.writeToFile(new File(projectFile), result); + } else { + 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 (CoreException e) { + MessageDialog.openError(Display.getDefault().getActiveShell(), + Messages.getString("ExportSourceAction.ErrorDialog.Title"), //$NON-NLS-1$ + Messages.getFormattedString("ExportSourceAction.Status.Error.DecompileFailed", //$NON-NLS-1$ + new String[] { className })); } - catch ( CoreException e ) - { - MessageDialog.openError( Display.getDefault( ).getActiveShell( ), - Messages.getString( "ExportSourceAction.ErrorDialog.Title" ), //$NON-NLS-1$ - Messages.getFormattedString( "ExportSourceAction.Status.Error.DecompileFailed", //$NON-NLS-1$ - new String[]{ - className - } ) ); - } - } - else - { + } else { return; } } @Override - public boolean isEnabled( ) - { + public boolean isEnabled() { return selection != null; } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/ExportSourceActionDelegate.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/ExportSourceActionDelegate.java index ad7cb77c..5b32a350 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/ExportSourceActionDelegate.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/ExportSourceActionDelegate.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.actions; @@ -17,24 +14,20 @@ import org.eclipse.ui.actions.ActionDelegate; import org.sf.feeling.decompiler.editor.JavaDecompilerClassFileEditor; -public class ExportSourceActionDelegate extends ActionDelegate implements IEditorActionDelegate -{ +public class ExportSourceActionDelegate extends ActionDelegate implements IEditorActionDelegate { JavaDecompilerClassFileEditor editor; @Override - public void setActiveEditor( IAction action, IEditorPart targetEditor ) - { - if ( targetEditor instanceof JavaDecompilerClassFileEditor ) - { + public void setActiveEditor(IAction action, IEditorPart targetEditor) { + if (targetEditor instanceof JavaDecompilerClassFileEditor) { editor = (JavaDecompilerClassFileEditor) targetEditor; } } @Override - public void run( IAction action ) - { - new ExportEditorSourceAction( ).run( ); + public void run(IAction action) { + new ExportEditorSourceAction().run(); } } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/ExportSourceContributionFactory.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/ExportSourceContributionFactory.java index 7c0a1167..404d84c6 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/ExportSourceContributionFactory.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/ExportSourceContributionFactory.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.actions; @@ -30,116 +27,96 @@ import org.eclipse.ui.menus.IContributionRoot; import org.eclipse.ui.services.IServiceLocator; -public class ExportSourceContributionFactory extends ExtensionContributionFactory -{ +public class ExportSourceContributionFactory extends ExtensionContributionFactory { @Override - public void createContributionItems( IServiceLocator serviceLocator, IContributionRoot additions ) - { - final ISelectionService selService = (ISelectionService)serviceLocator.getService( ISelectionService.class ); - final List selectedJars = getSelectedElements( selService, IPackageFragmentRoot.class ); - boolean exportRoot = ( selectedJars.size( ) == 1 ); - if ( exportRoot ) - { - additions.addContributionItem( new ActionContributionItem( new ExportSourceAction( selectedJars ) ), - new Expression( ) { + public void createContributionItems(IServiceLocator serviceLocator, IContributionRoot additions) { + final ISelectionService selService = (ISelectionService) serviceLocator.getService(ISelectionService.class); + final List selectedJars = getSelectedElements(selService, IPackageFragmentRoot.class); + boolean exportRoot = (selectedJars.size() == 1); + if (exportRoot) { + additions.addContributionItem(new ActionContributionItem(new ExportSourceAction(selectedJars)), + new Expression() { @Override - public EvaluationResult evaluate( IEvaluationContext context ) throws CoreException - { + public EvaluationResult evaluate(IEvaluationContext context) throws CoreException { return EvaluationResult.TRUE; } - } ); + }); return; } - if ( selectedJars.size( ) > 1 ) + if (selectedJars.size() > 1) return; - final List selectedPackages = getSelectedElements( selService, IPackageFragment.class ); - final List selectedClasses = getSelectedElements( selService, IClassFile.class ); - selectedClasses.addAll( selectedPackages ); - boolean exportClasses = ( !selectedClasses.isEmpty( ) ); - if ( exportClasses ) - { - additions.addContributionItem( new ActionContributionItem( new ExportSourceAction( selectedClasses ) ), - new Expression( ) { + final List selectedPackages = getSelectedElements(selService, IPackageFragment.class); + final List selectedClasses = getSelectedElements(selService, IClassFile.class); + selectedClasses.addAll(selectedPackages); + boolean exportClasses = (!selectedClasses.isEmpty()); + if (exportClasses) { + additions.addContributionItem(new ActionContributionItem(new ExportSourceAction(selectedClasses)), + new Expression() { @Override - public EvaluationResult evaluate( IEvaluationContext context ) throws CoreException - { - boolean menuVisible = isMenuVisible( selectedClasses ); + public EvaluationResult evaluate(IEvaluationContext context) throws CoreException { + boolean menuVisible = isMenuVisible(selectedClasses); - if ( menuVisible ) + if (menuVisible) return EvaluationResult.TRUE; return EvaluationResult.FALSE; } - } ); + }); return; } } - private boolean isMenuVisible( List selection ) - { + private boolean isMenuVisible(List selection) { IPackageFragmentRoot root = null; - for ( int i = 0; i < selection.size( ); i++ ) - { + for (int i = 0; i < selection.size(); i++) { IPackageFragmentRoot packRoot = null; - Object obj = selection.get( i ); - if ( obj instanceof IPackageFragment ) - { + Object obj = selection.get(i); + if (obj instanceof IPackageFragment) { IPackageFragment packageFragment = (IPackageFragment) obj; - packRoot = (IPackageFragmentRoot) packageFragment.getParent( ); - } - else if ( obj instanceof IClassFile ) - { + packRoot = (IPackageFragmentRoot) packageFragment.getParent(); + } else if (obj instanceof IClassFile) { IClassFile classFile = (IClassFile) obj; - packRoot = (IPackageFragmentRoot) classFile.getParent( ).getParent( ); - } - else + packRoot = (IPackageFragmentRoot) classFile.getParent().getParent(); + } else return false; - if ( root == null ) - { + if (root == null) { root = packRoot; - } - else - { - if ( root != packRoot ) + } else { + if (root != packRoot) return false; } } return true; } - private List getSelectedElements( ISelectionService selService, Class eleClass ) - { + private List getSelectedElements(ISelectionService selService, Class eleClass) { - Iterator selections = getSelections( selService ); - List elements = new ArrayList( ); + Iterator selections = getSelections(selService); + List elements = new ArrayList<>(); - while ( ( selections != null ) && selections.hasNext( ) ) - { - Object select = selections.next( ); + while ((selections != null) && selections.hasNext()) { + Object select = selections.next(); - if ( eleClass.isInstance( select ) ) - elements.add( select ); + if (eleClass.isInstance(select)) + elements.add(select); } return elements; } - private Iterator getSelections( ISelectionService selService ) - { - ISelection selection = selService.getSelection( ); + private Iterator getSelections(ISelectionService selService) { + ISelection selection = selService.getSelection(); - if ( selection != null ) - { - if ( selection instanceof IStructuredSelection ) - { + if (selection != null) { + if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; - return structuredSelection.iterator( ); + return structuredSelection.iterator(); } } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/ExportSourceMenuItemAction.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/ExportSourceMenuItemAction.java index 39d30989..f169a274 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/ExportSourceMenuItemAction.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/ExportSourceMenuItemAction.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.actions; @@ -22,64 +19,51 @@ import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2; import org.sf.feeling.decompiler.util.UIUtil; -public class ExportSourceMenuItemAction implements IWorkbenchWindowPulldownDelegate, IWorkbenchWindowPulldownDelegate2 -{ +public class ExportSourceMenuItemAction implements IWorkbenchWindowPulldownDelegate, IWorkbenchWindowPulldownDelegate2 { - public ExportSourceMenuItemAction( ) - { - super( ); + public ExportSourceMenuItemAction() { + super(); } @Override - public Menu getMenu( Control parent ) - { + public Menu getMenu(Control parent) { return null; } @Override - public Menu getMenu( Menu parent ) - { + public Menu getMenu(Menu parent) { return null; } @Override - public void init( IWorkbenchWindow window ) - { + public void init(IWorkbenchWindow window) { } @Override - public void dispose( ) - { + public void dispose() { } @Override - public void run( IAction action ) - { - if ( UIUtil.getActiveEditor( ) != null ) - { - new ExportEditorSourceAction( ).run( );; - } - else - { - List list = UIUtil.getExportSelections( ); - if ( list != null ) - { - new ExportSourceAction( list ).run( ); + public void run(IAction action) { + if (UIUtil.getActiveEditor() != null) { + new ExportEditorSourceAction().run(); + ; + } else { + List list = UIUtil.getExportSelections(); + if (list != null) { + new ExportSourceAction(list).run(); } } } @Override - public void selectionChanged( IAction action, ISelection selection ) - { - action.setEnabled( isEnable( ) ); + public void selectionChanged(IAction action, ISelection selection) { + action.setEnabled(isEnable()); } - private boolean isEnable( ) - { - return UIUtil.getActiveEditor( ) != null - || UIUtil.getActiveSelection( ) != null - || UIUtil.getExportSelections( ) != null; + private boolean isEnable() { + return UIUtil.getActiveEditor() != null || UIUtil.getActiveSelection() != null + || UIUtil.getExportSelections() != null; } } \ No newline at end of file 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 9db88ebf..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 @@ -1,19 +1,18 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.actions; import java.util.ArrayList; +import java.util.Collections; import java.util.Iterator; import java.util.List; +import java.util.TreeSet; import org.eclipse.core.expressions.EvaluationResult; import org.eclipse.core.expressions.Expression; @@ -45,225 +44,177 @@ 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; import org.sf.feeling.decompiler.editor.JavaDecompilerClassFileEditor; import org.sf.feeling.decompiler.i18n.Messages; -public class OpenClassWithContributionFactory extends ExtensionContributionFactory -{ +public class OpenClassWithContributionFactory extends ExtensionContributionFactory { - public static final class OpenClassesAction extends Action - { + public static final class OpenClassesAction extends Action { private final IEditorDescriptor classEditor; private final List classes; private String decompilerType; - public OpenClassesAction( IEditorDescriptor classEditor, List classes, String decompilerType ) - { + public OpenClassesAction(IEditorDescriptor classEditor, List classes, String decompilerType) { this.classEditor = classEditor; this.classes = classes; this.decompilerType = decompilerType; } @Override - public String getText( ) - { - if ( DecompilerType.FernFlower.equals( decompilerType ) ) - return Messages.getString( "JavaDecompilerActionBarContributor.Action.DecompileWithFernFlower" ); //$NON-NLS-1$ - else - { - IDecompilerDescriptor decompilerDescriptor = JavaDecompilerPlugin.getDefault( ) - .getDecompilerDescriptor( decompilerType ); - if ( decompilerDescriptor != null ) - return decompilerDescriptor.getDecompileAction( ).getText( ); - + public String getText() { + IDecompilerDescriptor decompilerDescriptor = JavaDecompilerPlugin.getDefault() + .getDecompilerDescriptor(decompilerType); + if (decompilerDescriptor != null) { + return decompilerDescriptor.getDecompileAction().getText(); } - return classEditor.getLabel( ); + return classEditor.getLabel(); } @Override - public ImageDescriptor getImageDescriptor( ) - { - if ( DecompilerType.FernFlower.equals( decompilerType ) ) - { - return JavaDecompilerPlugin.getImageDescriptor( "icons/fernflower_16.png" ); //$NON-NLS-1$ - } - else - return JavaDecompilerPlugin.getDefault( ) - .getDecompilerDescriptor( decompilerType ) - .getDecompilerIcon( ); + public ImageDescriptor getImageDescriptor() { + return JavaDecompilerPlugin.getDefault().getDecompilerDescriptor(decompilerType).getDecompilerIcon(); } @Override - public void run( ) - { + public void run() { // Get UI refs - IWorkbenchWindow window = PlatformUI.getWorkbench( ).getActiveWorkbenchWindow( ); - if ( window == null ) + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window == null) { return; - IWorkbenchPage page = window.getActivePage( ); - if ( page == null ) + } + IWorkbenchPage page = window.getActivePage(); + if (page == null) { return; + } // Load each IClassFile into the selected editor - for ( int i = 0; i < classes.size( ); i++ ) - { - IClassFile classfile = (IClassFile) classes.get( i ); + for (int i = 0; i < classes.size(); i++) { + IClassFile classfile = (IClassFile) classes.get(i); // Convert the IClassFile to an IEditorInput - IEditorInput input = EditorUtility.getEditorInput( classfile ); + IEditorInput input = EditorUtility.getEditorInput(classfile); - try - { - IEditorPart openEditor = page.openEditor( input, classEditor.getId( ), true ); + try { + IEditorPart openEditor = page.openEditor(input, classEditor.getId(), true); - if ( ( openEditor != null ) - && ( !classEditor.getId( ).equals( openEditor.getEditorSite( ).getId( ) ) ) ) - { + if ((openEditor != null) && (!classEditor.getId().equals(openEditor.getEditorSite().getId()))) { // An existing editor already has this class open. Close // it // and re-open in the correct editor - if ( !openEditor.isDirty( ) ) - { - openEditor.getSite( ).getPage( ).closeEditor( openEditor, false ); - page.openEditor( input, classEditor.getId( ), true ); + if (!openEditor.isDirty()) { + openEditor.getSite().getPage().closeEditor(openEditor, false); + page.openEditor(input, classEditor.getId(), true); } } - if ( openEditor instanceof JavaDecompilerClassFileEditor ) - { + if (openEditor instanceof JavaDecompilerClassFileEditor) { JavaDecompilerClassFileEditor editor = (JavaDecompilerClassFileEditor) openEditor; - editor.doSetInput( decompilerType, true ); + editor.doSetInput(decompilerType, true); } - } - catch ( PartInitException e ) - { - JavaDecompilerPlugin.getDefault( ).getLog( ).log( - new Status( IStatus.ERROR, JavaDecompilerPlugin.PLUGIN_ID, 0, e.getMessage( ), e ) ); + } catch (PartInitException e) { + JavaDecompilerPlugin.getDefault().getLog() + .log(new Status(IStatus.ERROR, JavaDecompilerConstants.PLUGIN_ID, 0, e.getMessage(), e)); } } } } @Override - public void createContributionItems( IServiceLocator serviceLocator, IContributionRoot additions ) - { + public void createContributionItems(IServiceLocator serviceLocator, IContributionRoot additions) { - final ISelectionService selService = (ISelectionService)serviceLocator.getService( ISelectionService.class ); + final ISelectionService selService = (ISelectionService) serviceLocator.getService(ISelectionService.class); // Define a dynamic set of submenu entries String dynamicMenuId = "org.sf.feeling.decompiler.openwith.items"; //$NON-NLS-1$ - IContributionItem dynamicItems = new CompoundContributionItem( dynamicMenuId ) { + IContributionItem dynamicItems = new CompoundContributionItem(dynamicMenuId) { @Override - protected IContributionItem[] getContributionItems( ) - { + protected IContributionItem[] getContributionItems() { // Get the list of editors that can open a class file - IEditorRegistry registry = PlatformUI.getWorkbench( ).getEditorRegistry( ); + IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry(); // Get the current selections and return if nothing is selected - Iterator selections = getSelections( selService ); - if ( selections == null ) + Iterator selections = getSelections(selService); + if (selections == null) { return new IContributionItem[0]; + } - final List classes = getSelectedElements( selService, IClassFile.class ); + List classes = getSelectedElements(selService, IClassFile.class); // List of menu items - List list = new ArrayList( ); - - if ( classes.size( ) == 1 ) - { - IEditorDescriptor editor = registry.findEditor( JavaDecompilerPlugin.EDITOR_ID ); - - boolean isAddFernFlower = false; - - for ( int i = 0; i < DecompilerType.getDecompilerTypes( ).length; i++ ) - { - if ( DecompilerType.getDecompilerTypes( )[i] - .compareToIgnoreCase( DecompilerType.FernFlower ) > 0 && !isAddFernFlower ) - { - list.add( new ActionContributionItem( - new OpenClassesAction( editor, classes, DecompilerType.FernFlower ) ) ); - isAddFernFlower = true; - } + List list = new ArrayList<>(); - list.add( new ActionContributionItem( - new OpenClassesAction( editor, classes, DecompilerType.getDecompilerTypes( )[i] ) ) ); - } + if (classes.size() == 1) { + IEditorDescriptor editor = registry.findEditor(JavaDecompilerConstants.EDITOR_ID); + + TreeSet decompilerTypes = new TreeSet<>(); + Collections.addAll(decompilerTypes, DecompilerType.getDecompilerTypes()); - if ( !isAddFernFlower ) - { - list.add( new ActionContributionItem( - new OpenClassesAction( editor, classes, DecompilerType.FernFlower ) ) ); + for (String decompilerType : decompilerTypes) { + list.add(new ActionContributionItem(new OpenClassesAction(editor, classes, decompilerType))); } } - return (IContributionItem[]) list.toArray( new IContributionItem[list.size( )] ); + return (IContributionItem[]) list.toArray(new IContributionItem[list.size()]); } }; // Determine menu name - List selectedClasses = getSelectedElements( selService, IClassFile.class ); - boolean openClassWith = ( selectedClasses.size( ) == 1 ); - if ( openClassWith ) - { + List selectedClasses = getSelectedElements(selService, IClassFile.class); + boolean openClassWith = (selectedClasses.size() == 1); + if (openClassWith) { // Define dynamic submenu MenuManager submenu = new MenuManager( - Messages.getString( "JavaDecompilerActionBarContributor.Menu.OpenClassWith" ), //$NON-NLS-1$ - dynamicMenuId ); - submenu.add( dynamicItems ); + Messages.getString("JavaDecompilerActionBarContributor.Menu.OpenClassWith"), //$NON-NLS-1$ + dynamicMenuId); + submenu.add(dynamicItems); // Add the submenu and show it when classes are selected - additions.addContributionItem( submenu, new Expression( ) { + additions.addContributionItem(submenu, new Expression() { @Override - public EvaluationResult evaluate( IEvaluationContext context ) throws CoreException - { - boolean menuVisible = isMenuVisible( selService ); + public EvaluationResult evaluate(IEvaluationContext context) throws CoreException { + boolean menuVisible = isMenuVisible(selService); - if ( menuVisible ) + if (menuVisible) { return EvaluationResult.TRUE; - + } return EvaluationResult.FALSE; } - } ); + }); } } - private boolean isMenuVisible( ISelectionService selService ) - { + private boolean isMenuVisible(ISelectionService selService) { - Iterator selections = getSelections( selService ); + Iterator selections = getSelections(selService); boolean atLeastOneSelection = false; boolean allClasses = true; boolean singlePackageOrRoot = false; - while ( ( selections != null ) && selections.hasNext( ) ) - { + while ((selections != null) && selections.hasNext()) { atLeastOneSelection = true; - Object select = selections.next( ); + Object select = selections.next(); - if ( !( select instanceof IClassFile ) ) - { + if (!(select instanceof IClassFile)) { allClasses = false; } - if ( ( ( select instanceof IPackageFragment ) - || ( select instanceof IPackageFragmentRoot ) && ( !selections.hasNext( ) ) ) ) - { + if (((select instanceof IPackageFragment) + || (select instanceof IPackageFragmentRoot) && (!selections.hasNext()))) { singlePackageOrRoot = true; } } - if ( atLeastOneSelection ) - { - if ( allClasses || singlePackageOrRoot ) - { + if (atLeastOneSelection) { + if (allClasses || singlePackageOrRoot) { return true; } } @@ -271,33 +222,29 @@ private boolean isMenuVisible( ISelectionService selService ) return false; } - private List getSelectedElements( ISelectionService selService, Class eleClass ) - { + private List getSelectedElements(ISelectionService selService, Class eleClass) { - Iterator selections = getSelections( selService ); - List elements = new ArrayList( ); + Iterator selections = getSelections(selService); + List elements = new ArrayList<>(); - while ( ( selections != null ) && selections.hasNext( ) ) - { - Object select = selections.next( ); + while ((selections != null) && selections.hasNext()) { + Object select = selections.next(); - if ( eleClass.isInstance( select ) ) - elements.add( select ); + if (eleClass.isInstance(select)) { + elements.add((T) select); + } } return elements; } - private Iterator getSelections( ISelectionService selService ) - { - ISelection selection = selService.getSelection( ); + private Iterator getSelections(ISelectionService selService) { + ISelection selection = selService.getSelection(); - if ( selection != null ) - { - if ( selection instanceof IStructuredSelection ) - { + if (selection != null) { + if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; - return structuredSelection.iterator( ); + return structuredSelection.iterator(); } } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/PreferenceMenuItemAction.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/PreferenceMenuItemAction.java index d89dab59..f7bcfeed 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/PreferenceMenuItemAction.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/PreferenceMenuItemAction.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.actions; @@ -19,47 +16,39 @@ import org.eclipse.ui.IWorkbenchWindowPulldownDelegate; import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2; -public class PreferenceMenuItemAction implements IWorkbenchWindowPulldownDelegate, IWorkbenchWindowPulldownDelegate2 -{ +public class PreferenceMenuItemAction implements IWorkbenchWindowPulldownDelegate, IWorkbenchWindowPulldownDelegate2 { - public PreferenceMenuItemAction( ) - { - super( ); + public PreferenceMenuItemAction() { + super(); } @Override - public Menu getMenu( Control parent ) - { + public Menu getMenu(Control parent) { return null; } @Override - public Menu getMenu( Menu parent ) - { + public Menu getMenu(Menu parent) { return null; } @Override - public void init( IWorkbenchWindow window ) - { + public void init(IWorkbenchWindow window) { } @Override - public void dispose( ) - { + public void dispose() { } @Override - public void run( IAction action ) - { - new DecompilerPeferenceAction( ).run( ); + public void run(IAction action) { + new DecompilerPeferenceAction().run(); } @Override - public void selectionChanged( IAction action, ISelection selection ) - { + public void selectionChanged(IAction action, ISelection selection) { } } \ No newline at end of file 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 411d370a..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 @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.actions; @@ -14,56 +11,49 @@ 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; import org.sf.feeling.decompiler.util.UIUtil; -public class SourceCodeAction extends Action implements IUpdate -{ +public class SourceCodeAction extends Action implements IUpdate { public static final String ID = "SourceCode"; //$NON-NLS-1$ - public SourceCodeAction( ) - { - super( Messages.getString( "JavaDecompilerActionBarContributor.Action.SourceCode" ), AS_CHECK_BOX ); //$NON-NLS-1$ + public SourceCodeAction() { + super(Messages.getString("JavaDecompilerActionBarContributor.Action.SourceCode"), AS_CHECK_BOX); //$NON-NLS-1$ } @Override - public void run( ) - { - JavaDecompilerPlugin.getDefault( ).setSourceMode( JavaDecompilerPlugin.SOURCE_MODE ); - setChecked( true ); - final JavaDecompilerClassFileEditor editor = UIUtil.getActiveEditor( ); - if ( editor != null ) - { - editor.showSource( ); - editor.notifyPropertiesChange( ); - Display.getDefault( ).asyncExec( new Runnable( ) { - - public void run( ) - { - editor.setFocus( ); + public void run() { + JavaDecompilerPlugin.getDefault().setSourceMode(JavaDecompilerConstants.SOURCE_MODE); + setChecked(true); + final JavaDecompilerClassFileEditor editor = UIUtil.getActiveEditor(); + if (editor != null) { + editor.showSource(); + editor.notifyPropertiesChange(); + Display.getDefault().asyncExec(new Runnable() { + + public void run() { + editor.setFocus(); } - } ); + }); } } @Override - public boolean isEnabled( ) - { - JavaDecompilerClassFileEditor editor = UIUtil.getActiveEditor( ); + public boolean isEnabled() { + JavaDecompilerClassFileEditor editor = UIUtil.getActiveEditor(); return editor != null; } - public boolean isChecked( ) - { - return JavaDecompilerPlugin.getDefault( ).getSourceMode( ) == JavaDecompilerPlugin.SOURCE_MODE; + public boolean isChecked() { + return JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.SOURCE_MODE; } @Override - public void update( ) - { - setChecked( isChecked( ) ); + public void update() { + setChecked(isChecked()); } } \ No newline at end of file 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 90f792a0..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 @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.actions; @@ -16,34 +13,29 @@ 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; -public class SourceCodeActionDelegate extends ActionDelegate implements IEditorActionDelegate -{ +public class SourceCodeActionDelegate extends ActionDelegate implements IEditorActionDelegate { JavaDecompilerClassFileEditor editor; @Override - public void setActiveEditor( IAction action, IEditorPart targetEditor ) - { - if ( targetEditor instanceof JavaDecompilerClassFileEditor ) - { + 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); } } @Override - public void run( IAction action ) - { - new ByteCodeAction( ).run( ); + public void run(IAction action) { + new ByteCodeAction().run(); } @Override - public void selectionChanged( IAction action, ISelection selection ) - { - action.setChecked( JavaDecompilerPlugin.getDefault( ).getSourceMode( ) == JavaDecompilerPlugin.SOURCE_MODE ); + public void selectionChanged(IAction action, ISelection selection) { + action.setChecked(JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.SOURCE_MODE); } } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/SourceCodeHandler.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/SourceCodeHandler.java index acda03b9..dc9eb010 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/SourceCodeHandler.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/SourceCodeHandler.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.actions; @@ -15,13 +12,11 @@ import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; -public class SourceCodeHandler extends AbstractHandler -{ +public class SourceCodeHandler extends AbstractHandler { @Override - public Object execute( ExecutionEvent event ) throws ExecutionException - { - new SourceCodeAction( ).run( ); + public Object execute(ExecutionEvent event) throws ExecutionException { + new SourceCodeAction().run(); return null; } 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 b97fc874..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 @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.actions; @@ -18,47 +15,40 @@ 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 -{ +public class SourceCodeMenuItemAction implements IWorkbenchWindowPulldownDelegate, IWorkbenchWindowPulldownDelegate2 { - public SourceCodeMenuItemAction( ) - { - super( ); + public SourceCodeMenuItemAction() { + super(); } @Override - public Menu getMenu( Control parent ) - { + public Menu getMenu(Control parent) { return null; } @Override - public Menu getMenu( Menu parent ) - { + public Menu getMenu(Menu parent) { return null; } @Override - public void init( IWorkbenchWindow window ) - { + public void init(IWorkbenchWindow window) { } @Override - public void dispose( ) - { + public void dispose() { } @Override - public void run( IAction action ) - { - new SourceCodeAction( ).run( ); + public void run(IAction action) { + new SourceCodeAction().run(); } @Override - public void selectionChanged( IAction action, ISelection selection ) - { - action.setChecked( JavaDecompilerPlugin.getDefault( ).getSourceMode( ) == JavaDecompilerPlugin.SOURCE_MODE ); + public void selectionChanged(IAction action, ISelection selection) { + 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/actions/SubMenuCreator.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/SubMenuCreator.java index f95f2428..a7e7530b 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/SubMenuCreator.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/actions/SubMenuCreator.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.actions; @@ -25,155 +22,109 @@ import org.eclipse.swt.widgets.Menu; import org.sf.feeling.decompiler.JavaDecompilerPlugin; import org.sf.feeling.decompiler.editor.DecompilerType; +import org.sf.feeling.decompiler.editor.IDecompilerDescriptor; import org.sf.feeling.decompiler.util.UIUtil; -public class SubMenuCreator implements IMenuCreator -{ +public class SubMenuCreator implements IMenuCreator { private MenuManager dropDownMenuMgr; @Override - public Menu getMenu( final Menu parent ) - { - final Menu menu = new Menu( parent ); - fillMenu( menu ); - menu.addMenuListener( new MenuAdapter( ) { + public Menu getMenu(final Menu parent) { + final Menu menu = new Menu(parent); + fillMenu(menu); + menu.addMenuListener(new MenuAdapter() { @Override - public void menuShown( MenuEvent e ) - { - while ( menu.getItemCount( ) > 0 ) - { - menu.getItem( 0 ).dispose( ); + public void menuShown(MenuEvent e) { + while (menu.getItemCount() > 0) { + menu.getItem(0).dispose(); } - fillMenu( menu ); + fillMenu(menu); } - } ); + }); return menu; } - private void fillMenu( final Menu menu ) - { - final MenuManager menuMgr = new MenuManager( ); + private void fillMenu(final Menu menu) { + final MenuManager menuMgr = new MenuManager(); - boolean isAddFernFlower = false; + String[] decompilerTypeArray = DecompilerType.getDecompilerTypes(); - for ( int i = 0; i < DecompilerType.getDecompilerTypes( ).length; i++ ) - { - if ( DecompilerType.getDecompilerTypes( )[i].compareToIgnoreCase( DecompilerType.FernFlower ) > 0 - && !isAddFernFlower ) - { - menuMgr.add( new DecompileWithFernFlowerAction( ) ); - isAddFernFlower = true; - } - menuMgr.add( JavaDecompilerPlugin.getDefault( ) - .getDecompilerDescriptor( DecompilerType.getDecompilerTypes( )[i] ) - .getDecompileAction( ) ); - } - - if ( !isAddFernFlower ) - { - menuMgr.add( new DecompileWithFernFlowerAction( ) ); + for (String decompilerType : decompilerTypeArray) { + IDecompilerDescriptor decompilerDescriptor = JavaDecompilerPlugin.getDefault() + .getDecompilerDescriptor(decompilerType); + menuMgr.add(decompilerDescriptor.getDecompileAction()); } - IContributionItem[] items = menuMgr.getItems( ); - for ( int i = 0; i < items.length; i++ ) - { - IContributionItem item = items[i]; + IContributionItem[] items = menuMgr.getItems(); + for (IContributionItem item : items) { IContributionItem newItem = item; - if ( item instanceof ActionContributionItem ) - { - newItem = new ActionContributionItem( ( (ActionContributionItem) item ).getAction( ) ); + if (item instanceof ActionContributionItem) { + newItem = new ActionContributionItem(((ActionContributionItem) item).getAction()); } - newItem.fill( menu, -1 ); + newItem.fill(menu, -1); } } @Override - public Menu getMenu( Control parent ) - { - createDropDownMenuMgr( ); - return dropDownMenuMgr.createContextMenu( parent ); + public Menu getMenu(Control parent) { + createDropDownMenuMgr(); + return dropDownMenuMgr.createContextMenu(parent); } @Override - public void dispose( ) - { - if ( null != dropDownMenuMgr ) - { - dropDownMenuMgr.dispose( ); + public void dispose() { + if (null != dropDownMenuMgr) { + dropDownMenuMgr.dispose(); dropDownMenuMgr = null; } } - class PreferenceActionContributionItem extends ActionContributionItem - { + private static class PreferenceActionContributionItem extends ActionContributionItem { - public PreferenceActionContributionItem( IAction action ) - { - super( action ); + public PreferenceActionContributionItem(IAction action) { + super(action); } @Override - public boolean isEnabledAllowed( ) - { + public boolean isEnabledAllowed() { return true; } } - private void createDropDownMenuMgr( ) - { - if ( dropDownMenuMgr == null ) - { - dropDownMenuMgr = new MenuManager( ); - - boolean isAddFernFlower = false; - - for ( int i = 0; i < DecompilerType.getDecompilerTypes( ).length; i++ ) - { - if ( DecompilerType.getDecompilerTypes( )[i].compareToIgnoreCase( DecompilerType.FernFlower ) > 0 - && !isAddFernFlower ) - { - dropDownMenuMgr.add( new DecompileWithFernFlowerAction( ) ); - isAddFernFlower = true; - } + private void createDropDownMenuMgr() { + if (dropDownMenuMgr == null) { + dropDownMenuMgr = new MenuManager(); - dropDownMenuMgr.add( JavaDecompilerPlugin.getDefault( ) - .getDecompilerDescriptor( DecompilerType.getDecompilerTypes( )[i] ) - .getDecompileAction( ) ); + for (String decompilerType : DecompilerType.getDecompilerTypes()) { + dropDownMenuMgr.add( + JavaDecompilerPlugin.getDefault().getDecompilerDescriptor(decompilerType).getDecompileAction()); } - if ( !isAddFernFlower ) - { - dropDownMenuMgr.add( new DecompileWithFernFlowerAction( ) ); - } + dropDownMenuMgr.add(new Separator()); - dropDownMenuMgr.add( new Separator( ) ); + dropDownMenuMgr.add(new SourceCodeAction()); - dropDownMenuMgr.add( new SourceCodeAction( ) ); - - dropDownMenuMgr.add( new ByteCodeAction( ) ); + dropDownMenuMgr.add(new ByteCodeAction()); - dropDownMenuMgr.add( new DisassemblerAction( ) ); + dropDownMenuMgr.add(new DisassemblerAction()); - dropDownMenuMgr.add( new Separator( ) ); + dropDownMenuMgr.add(new Separator()); - dropDownMenuMgr.add( new DebugModeAction( ) ); + dropDownMenuMgr.add(new DebugModeAction()); - dropDownMenuMgr.add( new Separator( ) ); + dropDownMenuMgr.add(new Separator()); - List list = UIUtil.getExportSelections( ); - if ( list != null ) - { - dropDownMenuMgr.add( new ExportSourceAction( list ) ); - } - else - { - dropDownMenuMgr.add( new ExportEditorSourceAction( ) ); + List list = UIUtil.getExportSelections(); + if (list != null) { + dropDownMenuMgr.add(new ExportSourceAction(list)); + } else { + dropDownMenuMgr.add(new ExportEditorSourceAction()); } - dropDownMenuMgr.add( new Separator( ) ); - dropDownMenuMgr.add( new PreferenceActionContributionItem( new DecompilerPeferenceAction( ) ) ); + dropDownMenuMgr.add(new Separator()); + dropDownMenuMgr.add(new PreferenceActionContributionItem(new DecompilerPeferenceAction())); } } } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/BaseDecompiler.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/BaseDecompiler.java new file mode 100644 index 00000000..02393b91 --- /dev/null +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/BaseDecompiler.java @@ -0,0 +1,29 @@ +package org.sf.feeling.decompiler.editor; + +import java.util.LinkedList; +import java.util.List; + +public abstract class BaseDecompiler implements IDecompiler { + + protected final List exceptions = new LinkedList<>(); + + public void addException(Exception ex) { + exceptions.add(ex); + } + + @Override + public List getExceptions() { + return exceptions; + } + + @Override + public void clearExceptions() { + exceptions.clear(); + } + + @Override + public LineNumberOutputType getLineNumberOutputType() { + return null; // not supported or not required + } + +} 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 e2cc39c4..15a73db4 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 @@ -1,564 +1,456 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.editor; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.util.Collection; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.Map; - -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.debug.core.DebugPlugin; -import org.eclipse.debug.core.IBreakpointManager; -import org.eclipse.debug.core.model.IBreakpoint; -import org.eclipse.jdt.core.IClassFile; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.debug.core.IJavaLineBreakpoint; -import org.eclipse.jdt.internal.compiler.env.IBinaryType; -import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; -import org.eclipse.jdt.internal.core.ClassFile; -import org.eclipse.jdt.internal.core.ExternalPackageFragmentRoot; -import org.eclipse.jdt.internal.core.PackageFragmentRoot; -import org.eclipse.jdt.internal.core.SourceMapper; -import org.eclipse.jdt.internal.debug.core.JDIDebugPlugin; -import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput; -import org.eclipse.jface.preference.IPreferenceStore; -import org.sf.feeling.decompiler.JavaDecompilerPlugin; -import org.sf.feeling.decompiler.fernflower.FernFlowerDecompiler; -import org.sf.feeling.decompiler.util.ClassUtil; -import org.sf.feeling.decompiler.util.DecompileUtil; -import org.sf.feeling.decompiler.util.DecompilerOutputUtil; -import org.sf.feeling.decompiler.util.Logger; -import org.sf.feeling.decompiler.util.MarkUtil; -import org.sf.feeling.decompiler.util.ReflectionUtils; -import org.sf.feeling.decompiler.util.SortMemberUtil; -import org.sf.feeling.decompiler.util.UIUtil; - -public abstract class BaseDecompilerSourceMapper extends DecompilerSourceMapper -{ - - protected IDecompiler origionalDecompiler; - private IDecompiler usedDecompiler; - private String classLocation; - - private static Map options = new HashMap( ); - static - { - CompilerOptions option = new CompilerOptions( ); - options = option.getMap( ); - options.put( CompilerOptions.OPTION_Compliance, DecompilerOutputUtil.getMaxDecompileLevel( ) ); // $NON-NLS-1$ - options.put( CompilerOptions.OPTION_Source, DecompilerOutputUtil.getMaxDecompileLevel( ) ); // $NON-NLS-1$ - } - - public BaseDecompilerSourceMapper( IPath sourcePath, String rootPath ) - { - - this( sourcePath, rootPath, options ); - } - - public BaseDecompilerSourceMapper( IPath sourcePath, String rootPath, Map options ) - { - super( sourcePath, rootPath, options ); - } - - @Override - public char[] findSource( IType type, IBinaryType info ) - { - IPreferenceStore prefs = JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ); - boolean always = prefs.getBoolean( JavaDecompilerPlugin.IGNORE_EXISTING ); - - Collection exceptions = new LinkedList( ); - IPackageFragment pkgFrag = type.getPackageFragment( ); - IPackageFragmentRoot root = (IPackageFragmentRoot) pkgFrag.getParent( ); - - JavaDecompilerPlugin.getDefault( ).syncLibrarySource( root ); - char[] attachedSource = null; - - if ( UIUtil.requestFromJavadocHover( ) && !fromInput( type ) && always ) - { - sourceRanges.remove( type ); - attachedSource = originalSourceMapper.get( root ).findSource( type, info ); - return attachedSource; - } - - if ( originalSourceMapper.containsKey( root ) ) - { - attachedSource = originalSourceMapper.get( root ).findSource( type, info ); - - if ( attachedSource != null && !always ) - { - attachedSource = DecompileUtil.getCopyRightContent( type.getClassFile( ), new String( attachedSource ) ) - .toCharArray( ); - updateSourceRanges( type, attachedSource ); - isAttachedSource = true; - updateBreakPointStatus( type, new String( attachedSource ) ); - mapSource( type, attachedSource, true ); - ( (PackageFragmentRoot) root ).getSourceMapper( ).mapSource( type, attachedSource, info ); - return attachedSource; - } - } - - if ( info == null ) - { - if ( always ) - return null; - return attachedSource; - } - - try - { - if ( root instanceof PackageFragmentRoot ) - { - PackageFragmentRoot pfr = (PackageFragmentRoot) root; - - SourceMapper sourceMapper = pfr.getSourceMapper( ); - - if ( !originalSourceMapper.containsKey( root ) ) - { - ReflectionUtils.setFieldValue( this, - "options", //$NON-NLS-1$ - ReflectionUtils.getFieldValue( sourceMapper, "options" ) ); //$NON-NLS-1$ - originalSourceMapper.put( root, sourceMapper ); - } - - if ( sourceMapper != null && !always && !( sourceMapper instanceof DecompilerSourceMapper ) ) - { - attachedSource = sourceMapper.findSource( type, info ); - if ( attachedSource != null ) - { - attachedSource = DecompileUtil - .getCopyRightContent( type.getClassFile( ), new String( attachedSource ) ) - .toCharArray( ); - updateSourceRanges( type, attachedSource ); - isAttachedSource = true; - updateBreakPointStatus( type, new String( attachedSource ) ); - mapSource( type, attachedSource, true ); - ( (PackageFragmentRoot) root ).getSourceMapper( ).mapSource( type, attachedSource, info ); - return attachedSource; - } - } - - if ( sourceMapper != this ) - { - pfr.setSourceMapper( this ); - } - } - } - catch ( JavaModelException e ) - { - JavaDecompilerPlugin.logError( e, "Could not set source mapper." ); //$NON-NLS-1$ - } - - isAttachedSource = false; - - if ( JavaDecompilerPlugin.getDefault( ).isAutoAttachSource( ) ) - { - JavaDecompilerPlugin.getDefault( ).attachSource( root, false ); - } - - String className = new String( info.getName( ) ); - String fullName = new String( info.getFileName( ) ); - className = fullName.substring( fullName.lastIndexOf( className ) ); - - int index = className.lastIndexOf( '/' ); - className = className.substring( index + 1 ); - - classLocation = ""; //$NON-NLS-1$ - - usedDecompiler = decompile( null, type, exceptions, root, className ); - - if ( usedDecompiler == null - || usedDecompiler.getSource( ) == null - || usedDecompiler.getSource( ).length( ) == 0 ) - { - if ( usedDecompiler == null || !DecompilerType.FernFlower.equals( usedDecompiler.getDecompilerType( ) ) ) - { - usedDecompiler = decompile( new FernFlowerDecompiler( ), type, exceptions, root, className ); - if ( usedDecompiler == null - || usedDecompiler.getSource( ) == null - || usedDecompiler.getSource( ).length( ) == 0 ) - { - return null; - } - } - } - - String code = MarkUtil.getRandomMark( type.getClassFile( ) ) - + "\r\n" //$NON-NLS-1$ - + usedDecompiler.getSource( ); - - boolean showReport = prefs.getBoolean( JavaDecompilerPlugin.PREF_DISPLAY_METADATA ); - if ( !showReport ) - { - code = usedDecompiler.removeComment( code ); - } - - boolean showLineNumber = prefs.getBoolean( JavaDecompilerPlugin.PREF_DISPLAY_LINE_NUMBERS ); - boolean align = prefs.getBoolean( JavaDecompilerPlugin.ALIGN ); - if ( ( showLineNumber && align ) - || UIUtil.isDebugPerspective( ) - || JavaDecompilerPlugin.getDefault( ).isDebugMode( ) ) - { - if ( showReport ) - code = usedDecompiler.removeComment( code ); - DecompilerOutputUtil decompilerOutputUtil = new DecompilerOutputUtil( type.getClassFile( ), - usedDecompiler.getDecompilerType( ), - code ); - code = decompilerOutputUtil.realign( ); - } - - StringBuffer source = new StringBuffer( ); - - if ( !( UIUtil.isDebugPerspective( ) || JavaDecompilerPlugin.getDefault( ).isDebugMode( ) ) ) - { - boolean useSorter = prefs.getBoolean( JavaDecompilerPlugin.USE_ECLIPSE_SORTER ); - if ( useSorter ) - { - className = new String( info.getName( ) ); - fullName = new String( info.getFileName( ) ); - if ( fullName.lastIndexOf( className ) != -1 ) - { - className = fullName.substring( fullName.lastIndexOf( className ) ); - } - - code = SortMemberUtil.sortMember( type.getPackageFragment( ).getElementName( ), className, code ); - } - - source.append( formatSource( code ) ); - - if ( showReport ) - { - printDecompileReport( source, classLocation, exceptions, usedDecompiler.getDecompilationTime( ) ); - } - } - else - { - source.append( code ); - } - - updateBreakPointStatus( type, source.toString( ) ); - - if ( originalSourceMapper.containsKey( root ) ) - { - if ( originalSourceMapper.get( root ).findSource( type, info ) == null ) - { - originalSourceMapper.get( root ).mapSource( type, source.toString( ).toCharArray( ), null ); - } - } - - updateSourceRanges( type, source.toString( ).toCharArray( ) ); - return source.toString( ).toCharArray( ); - } - - private void updateSourceRanges( IType type, char[] attachedSource ) - { - if ( type.getParent( ) instanceof ClassFile ) - { - try - { - DecompileUtil.updateSourceRanges( ( (ClassFile) type.getParent( ) ), new String( attachedSource ) ); - } - catch ( JavaModelException e ) - { - Logger.debug( e ); - } - } - } - - private void updateBreakPointStatus( IType type, String source ) - { - if ( MarkUtil.containsSourceMark( source ) ) - { - IBreakpointManager manager = DebugPlugin.getDefault( ).getBreakpointManager( ); - String modelId = JDIDebugPlugin.getUniqueIdentifier( ); - IBreakpoint[] breakpoints = manager.getBreakpoints( modelId ); - for ( int i = 0; i < breakpoints.length; i++ ) - { - if ( !( breakpoints[i] instanceof IJavaLineBreakpoint ) ) - continue; - try - { - IJavaLineBreakpoint breakPoint = (IJavaLineBreakpoint) breakpoints[i]; - String breakpointTypeName = breakPoint.getTypeName( ); - if ( type != null - && breakpointTypeName != null - && breakpointTypeName.equals( type.getFullyQualifiedName( ) ) ) - { - int lineNumber = (Integer) breakPoint.getMarker( ).getAttribute( IMarker.LINE_NUMBER ); - - String[] lines = source.split( "\n" ); //$NON-NLS-1$ - - int charStart = getCharStart( lines, lineNumber - 1 ); - int charEnd = getCharEnd( lines, lineNumber - 1 ); - - breakPoint.getMarker( ).setAttribute( IMarker.CHAR_START, new Integer( charStart ) ); - breakPoint.getMarker( ).setAttribute( IMarker.CHAR_END, new Integer( charEnd - 1 ) ); - } - } - catch ( CoreException e ) - { - Logger.debug( e ); - } - } - } - else if ( MarkUtil.containsMark( source ) && UIUtil.isDebug( ) ) - { - IBreakpointManager manager = DebugPlugin.getDefault( ).getBreakpointManager( ); - String modelId = JDIDebugPlugin.getUniqueIdentifier( ); - IBreakpoint[] breakpoints = manager.getBreakpoints( modelId ); - for ( int i = 0; i < breakpoints.length; i++ ) - { - if ( !( breakpoints[i] instanceof IJavaLineBreakpoint ) ) - continue; - try - { - IJavaLineBreakpoint breakPoint = (IJavaLineBreakpoint) breakpoints[i]; - String breakpointTypeName = breakPoint.getTypeName( ); - if ( type != null - && breakpointTypeName != null - && breakpointTypeName.equals( type.getFullyQualifiedName( ) ) ) - { - int lineNumber = (Integer) breakPoint.getMarker( ).getAttribute( IMarker.LINE_NUMBER ); - - String[] lines = source.split( "\n" ); //$NON-NLS-1$ - - int charStart = getCharStart( lines, lineNumber - 1 ); - int charEnd = getCharEnd( lines, lineNumber - 1 ); - - breakPoint.getMarker( ).setAttribute( IMarker.CHAR_START, new Integer( charStart ) ); - breakPoint.getMarker( ).setAttribute( IMarker.CHAR_END, new Integer( charEnd - 1 ) ); - } - } - catch ( CoreException e ) - { - Logger.debug( e ); - } - } - } - } - - private int getCharEnd( String[] lines, int lineNumber ) - { - int end = 0; - if ( lineNumber > -1 && lineNumber < lines.length ) - { - for ( int i = 0; i <= lineNumber; i++ ) - { - end += lines[i].length( ) + 1; - } - } - return end; - } - - private int getCharStart( String[] lines, int lineNumber ) - { - int start = 0; - if ( lineNumber > -1 && lineNumber < lines.length ) - { - for ( int i = 0; i < lineNumber; i++ ) - { - start += lines[i].length( ) + 1; - } - } - return start; - } - - private boolean fromInput( IType type ) - { - JavaDecompilerClassFileEditor editor = UIUtil.getActiveEditor( ); - if ( editor != null && editor.getEditorInput( ) instanceof IClassFileEditorInput ) - { - IClassFile input = ( (IClassFileEditorInput) editor.getEditorInput( ) ).getClassFile( ); - IType inputType = (IType) ReflectionUtils.invokeMethod( input, - "getOuterMostEnclosingType", //$NON-NLS-1$ - new Class[0], - new Object[0] ); - return type.equals( inputType ); - } - return false; - } - - private IDecompiler decompile( IDecompiler decompiler, IType type, Collection exceptions, IPackageFragmentRoot root, - String className ) - { - IDecompiler result = decompiler; - - String pkg = type.getPackageFragment( ).getElementName( ).replace( '.', '/' ); - - Boolean displayNumber = null; - if ( UIUtil.isDebugPerspective( ) || JavaDecompilerPlugin.getDefault( ).isDebugMode( ) ) - { - displayNumber = JavaDecompilerPlugin.getDefault( ).isDisplayLineNumber( ); - JavaDecompilerPlugin.getDefault( ).displayLineNumber( Boolean.TRUE ); - } - - try - { - if ( root.isArchive( ) ) - { - String archivePath = getArchivePath( root ); - classLocation += archivePath; - - if ( result == null ) - { - try - { - result = ClassUtil.checkAvailableDecompiler( origionalDecompiler, - new ByteArrayInputStream( type.getClassFile( ).getBytes( ) ) ); - } - catch ( JavaModelException e ) - { - result = origionalDecompiler; - } - } - result.decompileFromArchive( archivePath, pkg, className ); - } - else - { - String rootLocation = null; - try - { - if ( root.getUnderlyingResource( ) != null ) - { - rootLocation = root.getUnderlyingResource( ).getLocation( ).toOSString( ); - classLocation += rootLocation - + "/" //$NON-NLS-1$ - + pkg - + "/" //$NON-NLS-1$ - + className; - } - else if ( root instanceof ExternalPackageFragmentRoot ) - { - rootLocation = ( (ExternalPackageFragmentRoot) root ).getPath( ).toOSString( ); - classLocation += rootLocation - + "/" //$NON-NLS-1$ - + pkg - + "/" //$NON-NLS-1$ - + className; - } - else - { - rootLocation = root.getPath( ).toOSString( ); - classLocation += rootLocation - + "/" //$NON-NLS-1$ - + pkg - + "/" //$NON-NLS-1$ - + className; - } - - if ( result == null ) - { - result = ClassUtil.checkAvailableDecompiler( origionalDecompiler, new File( classLocation ) ); - } - result.decompile( rootLocation, pkg, className ); - } - catch ( JavaModelException e ) - { - exceptions.add( e ); - } - } - } - catch ( Exception e ) - { - exceptions.add( e ); - } - - if ( displayNumber != null ) - { - JavaDecompilerPlugin.getDefault( ).displayLineNumber( displayNumber ); - } - return result; - } - - @Override - public String decompile( String decompilerType, File file ) - { - IPreferenceStore prefs = JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ); - - Boolean displayNumber = null; - if ( UIUtil.isDebugPerspective( ) || JavaDecompilerPlugin.getDefault( ).isDebugMode( ) ) - { - displayNumber = JavaDecompilerPlugin.getDefault( ).isDisplayLineNumber( ); - JavaDecompilerPlugin.getDefault( ).displayLineNumber( Boolean.TRUE ); - } - - IDecompiler currentDecompiler = ClassUtil.checkAvailableDecompiler( origionalDecompiler, file ); - - currentDecompiler.decompile( file.getParentFile( ).getAbsolutePath( ), - "", //$NON-NLS-1$ - file.getName( ) ); - - if ( displayNumber != null ) - { - JavaDecompilerPlugin.getDefault( ).displayLineNumber( displayNumber ); - } - - if ( currentDecompiler.getSource( ) == null || currentDecompiler.getSource( ).length( ) == 0 ) - return null; - - String code = MarkUtil.getRandomMark( file.getAbsolutePath( ) ) - + "\r\n" //$NON-NLS-1$ - + currentDecompiler.getSource( ); - - boolean showReport = prefs.getBoolean( JavaDecompilerPlugin.PREF_DISPLAY_METADATA ); - if ( !showReport ) - { - code = currentDecompiler.removeComment( code ); - } - - boolean showLineNumber = prefs.getBoolean( JavaDecompilerPlugin.PREF_DISPLAY_LINE_NUMBERS ); - boolean align = prefs.getBoolean( JavaDecompilerPlugin.ALIGN ); - if ( ( showLineNumber && align ) - || UIUtil.isDebugPerspective( ) - || JavaDecompilerPlugin.getDefault( ).isDebugMode( ) ) - { - if ( showReport ) - code = currentDecompiler.removeComment( code ); - DecompilerOutputUtil decompilerOutputUtil = new DecompilerOutputUtil( currentDecompiler - .getDecompilerType( ), currentDecompiler.getDecompilerType( ), code ); - code = decompilerOutputUtil.realign( ); - } - - StringBuffer source = new StringBuffer( ); - - if ( !( UIUtil.isDebugPerspective( ) || JavaDecompilerPlugin.getDefault( ).isDebugMode( ) ) ) - { - source.append( formatSource( code ) ); - - if ( showReport ) - { - Collection exceptions = new LinkedList( ); - exceptions.addAll( currentDecompiler.getExceptions( ) ); - printDecompileReport( source, - file.getAbsolutePath( ), - exceptions, - currentDecompiler.getDecompilationTime( ) ); - } - } - else - { - source.append( code ); - } - - return source.toString( ); - } - - protected abstract void printDecompileReport( StringBuffer source, String location, Collection exceptions, - long decompilationTime ); -} +/******************************************************************************* + * Copyright (c) 2017 Chen Chao and other ECD project contributors. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.sf.feeling.decompiler.editor; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.InputStream; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.Map; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.jdt.core.IClassFile; +import org.eclipse.jdt.core.IPackageFragment; +import org.eclipse.jdt.core.IPackageFragmentRoot; +import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.jdt.internal.compiler.env.IBinaryType; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; +import org.eclipse.jdt.internal.core.ClassFile; +import org.eclipse.jdt.internal.core.ExternalPackageFragmentRoot; +import org.eclipse.jdt.internal.core.PackageFragmentRoot; +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.postprocessing.CharacterEscaper; +import org.sf.feeling.decompiler.postprocessing.LineReformatter; +import org.sf.feeling.decompiler.util.ClassUtil; +import org.sf.feeling.decompiler.util.DecompileUtil; +import org.sf.feeling.decompiler.util.EclipseUtils; +import org.sf.feeling.decompiler.util.Logger; +import org.sf.feeling.decompiler.util.ReflectionUtils; +import org.sf.feeling.decompiler.util.SortMemberUtil; +import org.sf.feeling.decompiler.util.SourceMapperUtil; +import org.sf.feeling.decompiler.util.UIUtil; + +public abstract class BaseDecompilerSourceMapper extends DecompilerSourceMapper { + + private static Map options = new HashMap<>(); + + static { + CompilerOptions option = new CompilerOptions(); + options = option.getMap(); + options.put(CompilerOptions.OPTION_Compliance, EclipseUtils.getMaxDecompileLevel()); // $NON-NLS-1$ + options.put(CompilerOptions.OPTION_Source, EclipseUtils.getMaxDecompileLevel()); // $NON-NLS-1$ + } + + protected IDecompiler originalDecompiler; + private IDecompiler usedDecompiler; + private String classLocation; + + public BaseDecompilerSourceMapper(IPath sourcePath, String rootPath) { + this(sourcePath, rootPath, options); + } + + public BaseDecompilerSourceMapper(IPath sourcePath, String rootPath, Map options) { + super(sourcePath, rootPath, options); + } + + @Override + public char[] findSource(IType type, IBinaryType info) { + IPreferenceStore prefs = JavaDecompilerPlugin.getDefault().getPreferenceStore(); + boolean ignoreExistingSource = prefs.getBoolean(JavaDecompilerConstants.IGNORE_EXISTING); + + Collection exceptions = new LinkedList<>(); + IPackageFragment pkgFrag = type.getPackageFragment(); + IPackageFragmentRoot root = (IPackageFragmentRoot) pkgFrag.getParent(); + + JavaDecompilerPlugin.getDefault().syncLibrarySource(root); + char[] attachedSource = null; + + if (UIUtil.requestFromJavadocHover() && !fromInput(type) && ignoreExistingSource) { + sourceRanges.remove(type); + attachedSource = originalSourceMapper.get(root).findSource(type, info); + return attachedSource; + } + + if (originalSourceMapper.containsKey(root)) { + attachedSource = originalSourceMapper.get(root).findSource(type, info); + + if (attachedSource != null && !ignoreExistingSource) { + updateSourceRanges(type, attachedSource); + isAttachedSource = true; + mapSourceSwitch(type, attachedSource, true); + SourceMapperUtil.mapSource(((PackageFragmentRoot) root).getSourceMapper(), type, attachedSource, info); + return attachedSource; + } + } + + if (info == null) { + if (ignoreExistingSource) { + return null; + } + return attachedSource; + } + + try { + if (root instanceof PackageFragmentRoot) { + PackageFragmentRoot pfr = (PackageFragmentRoot) root; + + SourceMapper sourceMapper = pfr.getSourceMapper(); + + if (!originalSourceMapper.containsKey(root)) { + ReflectionUtils.setFieldValue(this, "options", //$NON-NLS-1$ + ReflectionUtils.getFieldValue(sourceMapper, "options")); //$NON-NLS-1$ + originalSourceMapper.put(root, sourceMapper); + } + + if (sourceMapper != null && !ignoreExistingSource + && !(sourceMapper instanceof DecompilerSourceMapper)) { + attachedSource = sourceMapper.findSource(type, info); + if (attachedSource != null) { + updateSourceRanges(type, attachedSource); + isAttachedSource = true; + mapSourceSwitch(type, attachedSource, true); + SourceMapperUtil.mapSource(((PackageFragmentRoot) root).getSourceMapper(), type, attachedSource, + info); + return attachedSource; + } + } + + if (sourceMapper != this) { + pfr.setSourceMapper(this); + } + } + } catch (JavaModelException e) { + JavaDecompilerPlugin.logError(e, "Could not set source mapper."); //$NON-NLS-1$ + } + + isAttachedSource = false; + + if (JavaDecompilerPlugin.getDefault().isAutoAttachSource()) { + JavaDecompilerPlugin.getDefault().attachSource(root, false); + } + + String className = new String(info.getName()); + String fullName = new String(info.getFileName()); + int classNameIndex = fullName.lastIndexOf(className); + if (classNameIndex < 0) { + String msg = String.format("Unable to find className \"%s\" in fullName \"%s\"", className, fullName); //$NON-NLS-1$ + JavaDecompilerPlugin.logError(null, msg); + return messageWithExceptionsAsSourceCode(msg, exceptions); + } + className = fullName.substring(classNameIndex); + + int index = className.lastIndexOf('/'); + className = className.substring(index + 1); + + classLocation = ""; //$NON-NLS-1$ + + usedDecompiler = decompile(type, exceptions, root, className); + + if (noDecompiledSourceCodeAvailable(usedDecompiler)) { + if (usedDecompiler == null) { + String msg = String.format("Failed to decompile using %s", getDecompilerName()); + exceptions.add(new RuntimeException(msg)); + return messageWithExceptionsAsSourceCode(msg, exceptions); + } + } + + String code = usedDecompiler.getSource(); + + boolean showReport = prefs.getBoolean(JavaDecompilerConstants.PREF_DISPLAY_METADATA); + if (!showReport) { + code = usedDecompiler.removeComment(code); + } + + 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) { + code = usedDecompiler.removeComment(code); + } + LineReformatter decompilerOutputUtil = new LineReformatter(usedDecompiler, code); + code = decompilerOutputUtil.realign(); + } + + StringBuffer source = new StringBuffer(); + + if (!(UIUtil.isDebugPerspective() || JavaDecompilerPlugin.getDefault().isDebugMode())) { + boolean useSorter = prefs.getBoolean(JavaDecompilerConstants.USE_ECLIPSE_SORTER); + if (useSorter) { + className = new String(info.getName()); + fullName = new String(info.getFileName()); + if (fullName.lastIndexOf(className) != -1) { + className = fullName.substring(fullName.lastIndexOf(className)); + } + + code = SortMemberUtil.sortMember(type.getPackageFragment().getElementName(), className, code); + } + + source.append(formatSource(code)); + + if (showReport) { + printDecompileReport(source, classLocation, exceptions); + } + } else { + source.append(code); + } + + char[] sourceAsCharArray = source.toString().toCharArray(); + if (originalSourceMapper.containsKey(root)) { + SourceMapper rootSourceMapper = originalSourceMapper.get(root); + if (rootSourceMapper.findSource(type, info) == null) { + SourceMapperUtil.mapSource(rootSourceMapper, type, sourceAsCharArray, info); + } + } + + updateSourceRanges(type, sourceAsCharArray); + return sourceAsCharArray; + } + + private boolean noDecompiledSourceCodeAvailable(IDecompiler decompiler) { + return usedDecompiler == null || usedDecompiler.getSource() == null || usedDecompiler.getSource().isEmpty(); + } + + private char[] messageWithExceptionsAsSourceCode(String message, Collection exceptions) { + StringBuffer source = new StringBuffer(1024); + source.append("/*"); //$NON-NLS-1$ + source.append(message.replaceAll("\\/\\*", "\\*")); + if (exceptions != null && !exceptions.isEmpty()) { + source.append("\n\n"); + logExceptions(exceptions, source); + } + source.append("*/"); //$NON-NLS-1$ + + return source.toString().toCharArray(); + } + + private void updateSourceRanges(IType type, char[] attachedSource) { + if (type.getParent() instanceof ClassFile) { + try { + DecompileUtil.updateSourceRanges(((ClassFile) type.getParent()), new String(attachedSource)); + } catch (JavaModelException e) { + throw new RuntimeException(e); + } + } + } + + private boolean fromInput(IType type) { + JavaDecompilerClassFileEditor editor = UIUtil.getActiveEditor(); + if (editor != null && editor.getEditorInput() instanceof IClassFileEditorInput) { + IClassFile input = ((IClassFileEditorInput) editor.getEditorInput()).getClassFile(); + IType inputType = (IType) ReflectionUtils.invokeMethod(input, "getOuterMostEnclosingType", //$NON-NLS-1$ + new Class[0], new Object[0]); + return type.equals(inputType); + } + return false; + } + + private IDecompiler decompile(IType type, Collection exceptions, IPackageFragmentRoot root, + String className) { + + originalDecompiler.clearExceptions(); + + IDecompiler result = null; + + String pkg = type.getPackageFragment().getElementName().replace('.', '/'); + + Boolean displayNumber = null; + if (UIUtil.isDebugPerspective() || JavaDecompilerPlugin.getDefault().isDebugMode()) { + displayNumber = JavaDecompilerPlugin.getDefault().isDisplayLineNumber(); + JavaDecompilerPlugin.getDefault().displayLineNumber(Boolean.TRUE); + } + + try { + if (root.isArchive()) { + String archivePath = getArchivePath(root); + classLocation += archivePath; + + try (InputStream in = new ByteArrayInputStream(type.getClassFile().getBytes())) { + result = ClassUtil.checkAvailableDecompiler(originalDecompiler, in); + } catch (JavaModelException e) { + Logger.error(e.toString()); + result = originalDecompiler; + } + result.decompileFromArchive(archivePath, pkg, className); + } else { + String rootLocation = null; + try { + if (root.getUnderlyingResource() != null) { + rootLocation = root.getUnderlyingResource().getLocation().toOSString(); + classLocation += rootLocation + "/" //$NON-NLS-1$ + + pkg + "/" //$NON-NLS-1$ + + className; + } else if (root instanceof ExternalPackageFragmentRoot) { + rootLocation = ((ExternalPackageFragmentRoot) root).getPath().toOSString(); + classLocation += rootLocation + "/" //$NON-NLS-1$ + + pkg + "/" //$NON-NLS-1$ + + className; + } else { + rootLocation = root.getPath().toOSString(); + classLocation += rootLocation + "/" //$NON-NLS-1$ + + pkg + "/" //$NON-NLS-1$ + + className; + } + + result = ClassUtil.checkAvailableDecompiler(originalDecompiler, new File(classLocation)); + result.decompile(rootLocation, pkg, className); + } catch (JavaModelException e) { + exceptions.add(e); + } + } + } catch (Exception e) { + exceptions.add(e); + } + + if (displayNumber != null) { + JavaDecompilerPlugin.getDefault().displayLineNumber(displayNumber); + } + return result; + } + + @Override + public String decompileFile(String decompilerType, File file) { + IPreferenceStore prefs = JavaDecompilerPlugin.getDefault().getPreferenceStore(); + + Boolean displayNumber = null; + if (UIUtil.isDebugPerspective() || JavaDecompilerPlugin.getDefault().isDebugMode()) { + displayNumber = JavaDecompilerPlugin.getDefault().isDisplayLineNumber(); + JavaDecompilerPlugin.getDefault().displayLineNumber(Boolean.TRUE); + } + + IDecompiler currentDecompiler = ClassUtil.checkAvailableDecompiler(originalDecompiler, file); + usedDecompiler = currentDecompiler; + + currentDecompiler.decompile(file.getParentFile().getAbsolutePath(), "", //$NON-NLS-1$ + file.getName()); + + if (displayNumber != null) { + JavaDecompilerPlugin.getDefault().displayLineNumber(displayNumber); + } + + if (currentDecompiler.getSource() == null || currentDecompiler.getSource().length() == 0) { + return null; + } + + String code = currentDecompiler.getSource(); + + code = CharacterEscaper.process(code); + + boolean showReport = prefs.getBoolean(JavaDecompilerConstants.PREF_DISPLAY_METADATA); + if (!showReport) { + code = currentDecompiler.removeComment(code); + } + + 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) { + code = currentDecompiler.removeComment(code); + } + LineReformatter decompilerOutputUtil = new LineReformatter(currentDecompiler, code); + code = decompilerOutputUtil.realign(); + } + + StringBuffer source = new StringBuffer(); + + if (!(UIUtil.isDebugPerspective() || JavaDecompilerPlugin.getDefault().isDebugMode())) { + source.append(formatSource(code)); + + if (showReport) { + Collection exceptions = new LinkedList<>(); + exceptions.addAll(currentDecompiler.getExceptions()); + printDecompileReport(source, file.getAbsolutePath(), exceptions); + } + } else { + source.append(code); + } + return source.toString(); + } + + protected void logExceptions(Collection exceptions, StringBuffer buffer) { + if (exceptions.isEmpty()) { + return; + } + buffer.append("\n\tCaught exceptions:"); //$NON-NLS-1$ + if (exceptions == null || exceptions.isEmpty()) { + return; // nothing to do + } + buffer.append("\n"); //$NON-NLS-1$ + StringWriter stackTraces = new StringWriter(); + try (PrintWriter stackTracesP = new PrintWriter(stackTraces)) { + + Iterator i = exceptions.iterator(); + while (i.hasNext()) { + Exception ex = i.next(); + if (ex instanceof NoStackTraceException) { + stackTracesP.append("\t"); + stackTracesP.println(ex.getMessage()); + continue; + } + ex.printStackTrace(stackTracesP); + stackTracesP.println(""); //$NON-NLS-1$ + } + stackTracesP.flush(); + } + buffer.append(stackTraces.toString()); + } + + protected abstract String getDecompilerName(); + + protected abstract String getDecompilerVersion(); + + protected void printDecompileReport(StringBuffer source, String fileLocation, Collection exceptions) { + String log = usedDecompiler.getLog(); + String logMsg = log.replaceAll("\t", "") //$NON-NLS-1$ //$NON-NLS-2$ + .replaceAll("\n\\s*", "\n\t"); //$NON-NLS-1$ //$NON-NLS-2$ + + source.append("\n\n/*"); //$NON-NLS-1$ + source.append("\n\tDECOMPILATION REPORT\n"); //$NON-NLS-1$ + if (usedDecompiler != originalDecompiler) { + source.append("\n\tWARNING: used decompiler was changed from "); + source.append(originalDecompiler.getDecompilerName()); + source.append(" to "); + source.append(usedDecompiler.getDecompilerName()); + logExceptions(originalDecompiler.getExceptions(), source); + } + + source.append("\n\tDecompiled from: "); //$NON-NLS-1$ + source.append(fileLocation); + source.append("\n\tTotal time: "); //$NON-NLS-1$ + source.append(usedDecompiler.getDecompilationTime()); + source.append(" ms\n\t"); //$NON-NLS-1$ + source.append(logMsg); + exceptions.addAll(usedDecompiler.getExceptions()); + logExceptions(exceptions, source); + String decompiler = usedDecompiler.getDecompilerName(); + String ver = usedDecompiler.getDecompilerVersion(); + if (decompiler != null) { + source.append("\n\tDecompiled with "); //$NON-NLS-1$ + source.append(decompiler); + if (ver != null) { + source.append(" version "); //$NON-NLS-1$ + source.append(ver); + } + source.append(".\n"); //$NON-NLS-1$ + } + source.append("*/"); //$NON-NLS-1$ + } + +} diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/ByteCodeDocument.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/ByteCodeDocument.java index b49c8a25..eff09ade 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/ByteCodeDocument.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/ByteCodeDocument.java @@ -3,19 +3,16 @@ import org.eclipse.jface.text.Document; -public class ByteCodeDocument extends Document -{ +public class ByteCodeDocument extends Document { private ByteCodeSourceViewer editor; - public ByteCodeSourceViewer getEditor( ) - { + public ByteCodeSourceViewer getEditor() { return editor; } - public ByteCodeDocument( ByteCodeSourceViewer editor ) - { - super( ); + public ByteCodeDocument(ByteCodeSourceViewer editor) { + super(); this.editor = editor; } 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 c938f284..6323a9da 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 @@ -40,8 +40,6 @@ import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.text.Region; import org.eclipse.jface.text.TextSelection; -import org.eclipse.jface.text.hyperlink.IHyperlink; -import org.eclipse.jface.text.hyperlink.URLHyperlinkDetector; import org.eclipse.jface.text.source.CompositeRuler; import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jface.text.source.IVerticalRuler; @@ -53,7 +51,6 @@ import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.StyleRange; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeListener; @@ -71,20 +68,19 @@ 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; import org.sf.feeling.decompiler.actions.SourceCodeAction; import org.sf.feeling.decompiler.util.Logger; -import org.sf.feeling.decompiler.util.MarkUtil; import org.sf.feeling.decompiler.util.ReflectionUtils; import org.sf.feeling.decompiler.util.UIUtil; import com.drgarbage.classfile.editors.ClassFileParser; import com.drgarbage.utils.ClassFileDocumentsUtils; -public class ByteCodeSourceViewer extends AbstractDecoratedTextEditor -{ +public class ByteCodeSourceViewer extends AbstractDecoratedTextEditor { private JavaDecompilerClassFileEditor editor; @@ -92,197 +88,148 @@ public class ByteCodeSourceViewer extends AbstractDecoratedTextEditor private Composite container; - public ByteCodeSourceViewer( JavaDecompilerClassFileEditor editor ) - { + public ByteCodeSourceViewer(JavaDecompilerClassFileEditor editor) { this.editor = editor; } - public StyledText getTextWidget( ) - { - return getSourceViewer( ).getTextWidget( ); + public StyledText getTextWidget() { + return getSourceViewer().getTextWidget(); } - private IPreferenceStore createCombinedPreferenceStore( ) - { - List stores = new ArrayList( 3 ); + private IPreferenceStore createCombinedPreferenceStore() { + List stores = new ArrayList(3); - stores.add( JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ) ); - stores.add( JavaPlugin.getDefault( ).getPreferenceStore( ) ); - stores.add( EditorsUI.getPreferenceStore( ) ); + stores.add(JavaDecompilerPlugin.getDefault().getPreferenceStore()); + stores.add(JavaPlugin.getDefault().getPreferenceStore()); + stores.add(EditorsUI.getPreferenceStore()); - return new ChainedPreferenceStore( - (IPreferenceStore[]) stores.toArray( new IPreferenceStore[stores.size( )] ) ); + return new ChainedPreferenceStore((IPreferenceStore[]) stores.toArray(new IPreferenceStore[stores.size()])); } - public Composite createControl( Composite parent ) - { - setSite( editor.getSite( ) ); + public Composite createControl(Composite parent) { + setSite(editor.getSite()); - String classContent = editor.getDocumentProvider( ).getDocument( editor.getEditorInput( ) ).get( ); - String mark = MarkUtil.getMark( classContent ); - DisassemblerDocumentProvider provider = new DisassemblerDocumentProvider( mark ); - setDocumentProvider( provider ); - setInput( editor.getEditorInput( ) ); + DisassemblerDocumentProvider provider = new DisassemblerDocumentProvider(); + setDocumentProvider(provider); + setInput(editor.getEditorInput()); - container = new Composite( parent, SWT.NONE ); - container.setLayout( new FillLayout( ) ); - IPreferenceStore store = createCombinedPreferenceStore( ); - setPreferenceStore( store ); + container = new Composite(parent, SWT.NONE); + container.setLayout(new FillLayout()); + IPreferenceStore store = createCombinedPreferenceStore(); + setPreferenceStore(store); int styles = SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION; - IVerticalRuler fVerticalRuler = createVerticalRuler( ); - ReflectionUtils.setFieldValue( this, "fVerticalRuler", fVerticalRuler ); //$NON-NLS-1$ + IVerticalRuler fVerticalRuler = createVerticalRuler(); + ReflectionUtils.setFieldValue(this, "fVerticalRuler", fVerticalRuler); //$NON-NLS-1$ - SourceViewer fSourceViewer = new JavaSourceViewer( container, fVerticalRuler, null, false, styles, store ); - ReflectionUtils.setFieldValue( this, "fSourceViewer", fSourceViewer ); //$NON-NLS-1$ - getSourceViewerDecorationSupport( fSourceViewer ); + SourceViewer fSourceViewer = new JavaSourceViewer(container, fVerticalRuler, null, false, styles, store); + ReflectionUtils.setFieldValue(this, "fSourceViewer", fSourceViewer); //$NON-NLS-1$ + getSourceViewerDecorationSupport(fSourceViewer); - createActions( ); + createActions(); - ReflectionUtils.invokeMethod( this, "initializeSourceViewer", new Class[]{ //$NON-NLS-1$ - IEditorInput.class - }, new Object[]{ - getEditorInput( ) - } ); + ReflectionUtils.invokeMethod(this, "initializeSourceViewer", new Class[] { //$NON-NLS-1$ + IEditorInput.class }, new Object[] { getEditorInput() }); - if ( fSourceViewerDecorationSupport != null ) - fSourceViewerDecorationSupport.install( getPreferenceStore( ) ); + if (fSourceViewerDecorationSupport != null) { + fSourceViewerDecorationSupport.install(getPreferenceStore()); + } - StyledText styledText = fSourceViewer.getTextWidget( ); - styledText.addMouseListener( getCursorListener( ) ); - styledText.addKeyListener( getCursorListener( ) ); + StyledText styledText = fSourceViewer.getTextWidget(); + styledText.addMouseListener(getCursorListener()); + styledText.addKeyListener(getCursorListener()); - ReflectionUtils.setFieldValue( this, "fEditorContextMenuId", "#TextEditorContext" ); //$NON-NLS-1$ //$NON-NLS-2$ + ReflectionUtils.setFieldValue(this, "fEditorContextMenuId", "#TextEditorContext"); //$NON-NLS-1$ //$NON-NLS-2$ String id = "#TextEditorContext"; //$NON-NLS-1$ - MenuManager manager = new MenuManager( id, id ); - manager.setRemoveAllWhenShown( true ); - manager.addMenuListener( getContextMenuListener( ) ); - Menu fTextContextMenu = manager.createContextMenu( styledText ); - styledText.setMenu( fTextContextMenu ); + MenuManager manager = new MenuManager(id, id); + manager.setRemoveAllWhenShown(true); + manager.addMenuListener(getContextMenuListener()); + Menu fTextContextMenu = manager.createContextMenu(styledText); + styledText.setMenu(fTextContextMenu); - ReflectionUtils.setFieldValue( this, "fRulerContextMenuId", "#TextRulerContext" ); //$NON-NLS-1$ //$NON-NLS-2$ + ReflectionUtils.setFieldValue(this, "fRulerContextMenuId", "#TextRulerContext"); //$NON-NLS-1$ //$NON-NLS-2$ id = "#TextRulerContext"; //$NON-NLS-1$ - manager = new MenuManager( id, id ); - manager.setRemoveAllWhenShown( true ); - manager.addMenuListener( getContextMenuListener( ) ); - - Control rulerControl = fVerticalRuler.getControl( ); - Menu fRulerContextMenu = manager.createContextMenu( rulerControl ); - rulerControl.setMenu( fRulerContextMenu ); - rulerControl.addMouseListener( getRulerMouseListener( ) ); - - createOverviewRulerContextMenu( ); - - JavaTextTools textTools = JavaPlugin.getDefault( ).getJavaTextTools( ); - IColorManager colorManager = textTools.getColorManager( ); - JavaSourceViewerConfiguration classFileConfiguration = new JavaSourceViewerConfiguration( colorManager, - store, - editor, - IJavaPartitions.JAVA_PARTITIONING ); - fSourceViewer.configure( classFileConfiguration ); - setSourceViewerConfiguration( classFileConfiguration ); - getSourceViewerDecorationSupport( fSourceViewer ).install( getPreferenceStore( ) ); - initializeViewerColors( fSourceViewer ); - ReflectionUtils.invokeMethod( this, "initializeViewerFont", new Class[]{ //$NON-NLS-1$ - ISourceViewer.class - }, new Object[]{ - fSourceViewer - } ); - - IClassFile cf = (ClassFile) ( (IClassFileEditorInput) editor.getEditorInput( ) ).getClassFile( ); - - byteCodeDocument = new ByteCodeDocument( this ); - - JavaTextTools tools = JavaPlugin.getDefault( ).getJavaTextTools( ); - tools.setupJavaDocumentPartitioner( byteCodeDocument, IJavaPartitions.JAVA_PARTITIONING ); - - try - { - ClassFileParser parser = new ClassFileParser( ); - String content = parser.parseClassFile( cf.getBytes( ) ); - byteCodeDocument.set( mark + "\n\n" + ( content == null ? "" : content ) ); //$NON-NLS-1$ //$NON-NLS-2$ - } - catch ( Exception e ) - { - ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler( ); - try - { - String content = disassembler.disassemble( cf.getBytes( ), "\n", ClassFileBytesDisassembler.DETAILED ); //$NON-NLS-1$ - byteCodeDocument.set( mark + "\n\n" + ( content == null ? "" : content ) ); //$NON-NLS-1$ //$NON-NLS-2$ - } - catch ( Exception ex ) - { - Logger.debug( e ); + manager = new MenuManager(id, id); + manager.setRemoveAllWhenShown(true); + manager.addMenuListener(getContextMenuListener()); + + Control rulerControl = fVerticalRuler.getControl(); + Menu fRulerContextMenu = manager.createContextMenu(rulerControl); + rulerControl.setMenu(fRulerContextMenu); + rulerControl.addMouseListener(getRulerMouseListener()); + + createOverviewRulerContextMenu(); + + JavaTextTools textTools = JavaPlugin.getDefault().getJavaTextTools(); + IColorManager colorManager = textTools.getColorManager(); + JavaSourceViewerConfiguration classFileConfiguration = new JavaSourceViewerConfiguration(colorManager, store, + editor, IJavaPartitions.JAVA_PARTITIONING); + fSourceViewer.configure(classFileConfiguration); + setSourceViewerConfiguration(classFileConfiguration); + getSourceViewerDecorationSupport(fSourceViewer).install(getPreferenceStore()); + initializeViewerColors(fSourceViewer); + ReflectionUtils.invokeMethod(this, "initializeViewerFont", new Class[] { //$NON-NLS-1$ + ISourceViewer.class }, new Object[] { fSourceViewer }); + + IClassFile cf = (ClassFile) ((IClassFileEditorInput) editor.getEditorInput()).getClassFile(); + + byteCodeDocument = new ByteCodeDocument(this); + + JavaTextTools tools = JavaPlugin.getDefault().getJavaTextTools(); + tools.setupJavaDocumentPartitioner(byteCodeDocument, IJavaPartitions.JAVA_PARTITIONING); + + try { + ClassFileParser parser = new ClassFileParser(); + String content = parser.parseClassFile(cf.getBytes()); + byteCodeDocument.set((content == null ? "" : content)); //$NON-NLS-1$ //$NON-NLS-2$ + } catch (Exception e) { + ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); + try { + String content = disassembler.disassemble(cf.getBytes(), "\n", ClassFileBytesDisassembler.DETAILED); //$NON-NLS-1$ + byteCodeDocument.set((content == null ? "" : content)); //$NON-NLS-1$ //$NON-NLS-2$ + } catch (Exception ex) { + Logger.debug(e); } } - final EditorSelectionChangedListener fEditorSelectionChangedListener = new EditorSelectionChangedListener( ); - fEditorSelectionChangedListener.install( getSelectionProvider( ) ); - - fSourceViewer.setDocument( byteCodeDocument ); + final EditorSelectionChangedListener fEditorSelectionChangedListener = new EditorSelectionChangedListener(); + fEditorSelectionChangedListener.install(getSelectionProvider()); - provider.setDocument( byteCodeDocument ); + fSourceViewer.setDocument(byteCodeDocument); - IVerticalRuler ruler = getVerticalRuler( ); - if ( ruler instanceof CompositeRuler ) - updateContributedRulerColumns( (CompositeRuler) ruler ); + provider.setDocument(byteCodeDocument); - IColumnSupport columnSupport = (IColumnSupport) getAdapter( IColumnSupport.class ); + IVerticalRuler ruler = getVerticalRuler(); + if (ruler instanceof CompositeRuler) + updateContributedRulerColumns((CompositeRuler) ruler); - RulerColumnDescriptor lineNumberColumnDescriptor = RulerColumnRegistry.getDefault( ) - .getColumnDescriptor( LineNumberColumn.ID ); - if ( lineNumberColumnDescriptor != null ) - columnSupport.setColumnVisible( lineNumberColumnDescriptor, isLineNumberRulerVisible( ) ); + IColumnSupport columnSupport = (IColumnSupport) getAdapter(IColumnSupport.class); + RulerColumnDescriptor lineNumberColumnDescriptor = RulerColumnRegistry.getDefault() + .getColumnDescriptor(LineNumberColumn.ID); + if (lineNumberColumnDescriptor != null) { + columnSupport.setColumnVisible(lineNumberColumnDescriptor, isLineNumberRulerVisible()); + } IPropertyChangeListener fFontPropertyChangeListener = (IPropertyChangeListener) ReflectionUtils - .getFieldValue( this, "fFontPropertyChangeListener" ); //$NON-NLS-1$ - JFaceResources.getFontRegistry( ).addListener( fFontPropertyChangeListener ); + .getFieldValue(this, "fFontPropertyChangeListener"); //$NON-NLS-1$ + JFaceResources.getFontRegistry().addListener(fFontPropertyChangeListener); - parent.addDisposeListener( new DisposeListener( ) { + parent.addDisposeListener(new DisposeListener() { @Override - public void widgetDisposed( DisposeEvent e ) - { - ByteCodeSourceViewer.this.dispose( ); + public void widgetDisposed(DisposeEvent e) { + ByteCodeSourceViewer.this.dispose(); } - } ); - - String ad = mark.replaceAll( "/(\\*)+", "" ) //$NON-NLS-1$ //$NON-NLS-2$ - .replaceAll( "(\\*)+/", "" ) //$NON-NLS-1$ //$NON-NLS-2$ - .trim( ); - int length = ad.length( ); - int offset = mark.indexOf( ad ); - - StyleRange textRange = UIUtil.getAdTextStyleRange( styledText, offset, length ); - if ( textRange != null ) - { - styledText.setStyleRange( textRange ); - } - - URLHyperlinkDetector detector = new URLHyperlinkDetector( ); - final int index = mark.indexOf( "://" ); //$NON-NLS-1$ - final IHyperlink[] links = detector.detectHyperlinks( getSourceViewer( ), new Region( index, 0 ), true ); - for ( int j = 0; j < links.length; j++ ) - { - IHyperlink link = links[j]; - StyleRange linkRange = UIUtil.getAdLinkStyleRange( styledText, - link.getHyperlinkRegion( ).getOffset( ), - link.getHyperlinkRegion( ).getLength( ) ); - if ( linkRange != null ) - { - styledText.setStyleRange( linkRange ); - } - } + }); return container; } - class JdtSelectionProvider extends SelectionProvider - { + class JdtSelectionProvider extends SelectionProvider { - private List fSelectionListeners = new ArrayList( ); - private List fPostSelectionListeners = new ArrayList( ); + private List fSelectionListeners = new ArrayList(); + private List fPostSelectionListeners = new ArrayList(); private ITextSelection fInvalidSelection; private ISelection fValidSelection; @@ -291,22 +238,22 @@ class JdtSelectionProvider extends SelectionProvider * addSelectionChangedListener(ISelectionChangedListener) */ @Override - public void addSelectionChangedListener( ISelectionChangedListener listener ) - { - super.addSelectionChangedListener( listener ); - if ( getSourceViewer( ) != null ) - fSelectionListeners.add( listener ); + public void addSelectionChangedListener(ISelectionChangedListener listener) { + super.addSelectionChangedListener(listener); + if (getSourceViewer() != null) { + fSelectionListeners.add(listener); + } } /* * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection() */ @Override - public ISelection getSelection( ) - { - if ( fInvalidSelection != null ) + public ISelection getSelection() { + if (fInvalidSelection != null) { return fInvalidSelection; - return super.getSelection( ); + } + return super.getSelection(); } /* @@ -314,48 +261,37 @@ public ISelection getSelection( ) * removeSelectionChangedListener(ISelectionChangedListener) */ @Override - public void removeSelectionChangedListener( ISelectionChangedListener listener ) - { - super.removeSelectionChangedListener( listener ); - if ( getSourceViewer( ) != null ) - fSelectionListeners.remove( listener ); + public void removeSelectionChangedListener(ISelectionChangedListener listener) { + super.removeSelectionChangedListener(listener); + if (getSourceViewer() != null) { + fSelectionListeners.remove(listener); + } } /* - * @see - * org.eclipse.jface.viewers.ISelectionProvider#setSelection(ISelection) + * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(ISelection) */ @Override - public void setSelection( ISelection selection ) - { - if ( selection instanceof ITextSelection ) - { - if ( fInvalidSelection != null ) - { + public void setSelection(ISelection selection) { + if (selection instanceof ITextSelection) { + if (fInvalidSelection != null) { fInvalidSelection = null; ITextSelection newSelection = (ITextSelection) selection; - ITextSelection oldSelection = (ITextSelection) getSelection( ); + ITextSelection oldSelection = (ITextSelection) getSelection(); - if ( newSelection.getOffset( ) == oldSelection.getOffset( ) - && newSelection.getLength( ) == oldSelection.getLength( ) ) - { - markValid( ); - } - else - { - super.setSelection( selection ); + if (newSelection.getOffset() == oldSelection.getOffset() + && newSelection.getLength() == oldSelection.getLength()) { + markValid(); + } else { + super.setSelection(selection); } + } else { + super.setSelection(selection); } - else - { - super.setSelection( selection ); - } - } - else if ( selection instanceof IStructuredSelection - && ( (IStructuredSelection) selection ).getFirstElement( ) instanceof EditorBreadcrumb ) - { - markInvalid( ); + } else if (selection instanceof IStructuredSelection + && ((IStructuredSelection) selection).getFirstElement() instanceof EditorBreadcrumb) { + markInvalid(); } } @@ -365,12 +301,12 @@ else if ( selection instanceof IStructuredSelection * ISelectionChangedListener) */ @Override - public void addPostSelectionChangedListener( ISelectionChangedListener listener ) - { - super.addPostSelectionChangedListener( listener ); - if ( getSourceViewer( ) != null - && getSourceViewer( ).getSelectionProvider( ) instanceof IPostSelectionProvider ) - fPostSelectionListeners.add( listener ); + public void addPostSelectionChangedListener(ISelectionChangedListener listener) { + super.addPostSelectionChangedListener(listener); + if (getSourceViewer() != null + && getSourceViewer().getSelectionProvider() instanceof IPostSelectionProvider) { + fPostSelectionListeners.add(listener); + } } /* @@ -379,176 +315,151 @@ && getSourceViewer( ).getSelectionProvider( ) instanceof IPostSelectionProvider * ISelectionChangedListener) */ @Override - public void removePostSelectionChangedListener( ISelectionChangedListener listener ) - { - super.removePostSelectionChangedListener( listener ); - if ( getSourceViewer( ) != null ) - fPostSelectionListeners.remove( listener ); + public void removePostSelectionChangedListener(ISelectionChangedListener listener) { + super.removePostSelectionChangedListener(listener); + if (getSourceViewer() != null) { + fPostSelectionListeners.remove(listener); + } } /* * @see org.eclipse.jface.text.IPostSelectionValidator#isValid() */ @Override - public boolean isValid( ISelection postSelection ) - { - return fInvalidSelection == null && super.isValid( postSelection ); + public boolean isValid(ISelection postSelection) { + return fInvalidSelection == null && super.isValid(postSelection); } /** * Marks this selection provider as currently being invalid. An invalid * selection is one which can not be selected in the source viewer. */ - private void markInvalid( ) - { - fValidSelection = getSelection( ); - fInvalidSelection = new TextSelection( 0, 0 ); + private void markInvalid() { + fValidSelection = getSelection(); + fInvalidSelection = new TextSelection(0, 0); - SelectionChangedEvent event = new SelectionChangedEvent( this, fInvalidSelection ); + SelectionChangedEvent event = new SelectionChangedEvent(this, fInvalidSelection); - for ( ISelectionChangedListener listener : fSelectionListeners ) - { - listener.selectionChanged( event ); + for (ISelectionChangedListener listener : fSelectionListeners) { + listener.selectionChanged(event); } - for ( ISelectionChangedListener listener : fPostSelectionListeners ) - { - listener.selectionChanged( event ); + for (ISelectionChangedListener listener : fPostSelectionListeners) { + listener.selectionChanged(event); } } /** * Marks this selection provider as being valid. */ - private void markValid( ) - { + private void markValid() { fInvalidSelection = null; - SelectionChangedEvent event = new SelectionChangedEvent( this, fValidSelection ); + SelectionChangedEvent event = new SelectionChangedEvent(this, fValidSelection); - for ( ISelectionChangedListener listener : fSelectionListeners ) - { - listener.selectionChanged( event ); + for (ISelectionChangedListener listener : fSelectionListeners) { + listener.selectionChanged(event); } - for ( ISelectionChangedListener listener : fPostSelectionListeners ) - { - listener.selectionChanged( event ); + for (ISelectionChangedListener listener : fPostSelectionListeners) { + listener.selectionChanged(event); } } } - private class EditorSelectionChangedListener extends AbstractSelectionChangedListener - { + private class EditorSelectionChangedListener extends AbstractSelectionChangedListener { - public void selectionChanged( SelectionChangedEvent event ) - { - doHandleCursorPositionChanged( ); + public void selectionChanged(SelectionChangedEvent event) { + doHandleCursorPositionChanged(); } } - private void doHandleCursorPositionChanged( ) - { - StyledText byteCodeText = getSourceViewer( ).getTextWidget( ); - String byteCode = byteCodeText.getText( ); - int selectedRange = byteCodeText.getSelectionRange( ).x; - IJavaElement element = getJavaElement( byteCode, selectedRange ); - if ( element != null ) - { - editor.setSelection( element ); + private void doHandleCursorPositionChanged() { + StyledText byteCodeText = getSourceViewer().getTextWidget(); + String byteCode = byteCodeText.getText(); + int selectedRange = byteCodeText.getSelectionRange().x; + IJavaElement element = getJavaElement(byteCode, selectedRange); + if (element != null) { + editor.setSelection(element); } } - public IJavaElement getJavaElement( String byteCode, int index ) - { - if ( byteCode.lastIndexOf( "/* Methods: */" ) != -1 ) //$NON-NLS-1$ + public IJavaElement getJavaElement(String byteCode, int index) { + if (byteCode.lastIndexOf("/* Methods: */") != -1) //$NON-NLS-1$ { - int methodStartIndex = byteCode.substring( 0, byteCode.lastIndexOf( "/* Methods: */" ) ).lastIndexOf( "\n" ) //$NON-NLS-1$ //$NON-NLS-2$ + int methodStartIndex = byteCode.substring(0, byteCode.lastIndexOf("/* Methods: */")).lastIndexOf("\n") //$NON-NLS-1$ //$NON-NLS-2$ + 1; - int methodEndIndex = byteCode.substring( 0, byteCode.lastIndexOf( "attributes_count" ) ) //$NON-NLS-1$ - .lastIndexOf( "\n" ); //$NON-NLS-1$ - if ( index >= methodStartIndex && index <= methodEndIndex ) - { - return getMethod( byteCode.substring( methodStartIndex, methodEndIndex ), index - methodStartIndex ); + int methodEndIndex = byteCode.substring(0, byteCode.lastIndexOf("attributes_count")) //$NON-NLS-1$ + .lastIndexOf("\n"); //$NON-NLS-1$ + if (index >= methodStartIndex && index <= methodEndIndex) { + return getMethod(byteCode.substring(methodStartIndex, methodEndIndex), index - methodStartIndex); } - if ( byteCode.lastIndexOf( "/* Fields: */" ) != -1 ) //$NON-NLS-1$ + if (byteCode.lastIndexOf("/* Fields: */") != -1) //$NON-NLS-1$ { - int fieldStartIndex = byteCode.substring( 0, byteCode.lastIndexOf( "/* Fields: */" ) ).lastIndexOf( //$NON-NLS-1$ - "\n" ) + 1; //$NON-NLS-1$ + int fieldStartIndex = byteCode.substring(0, byteCode.lastIndexOf("/* Fields: */")).lastIndexOf( //$NON-NLS-1$ + "\n") + 1; //$NON-NLS-1$ int fieldEndIndex = methodStartIndex - 1; - if ( index >= fieldStartIndex && index <= fieldEndIndex ) - { - return getField( byteCode.substring( fieldStartIndex, fieldEndIndex ), index - fieldStartIndex ); + if (index >= fieldStartIndex && index <= fieldEndIndex) { + return getField(byteCode.substring(fieldStartIndex, fieldEndIndex), index - fieldStartIndex); } } - } - else if ( byteCode.lastIndexOf( "/* Fields: */" ) != -1 ) //$NON-NLS-1$ + } else if (byteCode.lastIndexOf("/* Fields: */") != -1) //$NON-NLS-1$ { - int fieldStartIndex = byteCode.substring( 0, byteCode.lastIndexOf( "/* Fields: */" ) ).lastIndexOf( "\n" ) //$NON-NLS-1$ //$NON-NLS-2$ + int fieldStartIndex = byteCode.substring(0, byteCode.lastIndexOf("/* Fields: */")).lastIndexOf("\n") //$NON-NLS-1$ //$NON-NLS-2$ + 1; - int fieldEndIndex = byteCode.substring( 0, byteCode.lastIndexOf( "attributes_count" ) ).lastIndexOf( "\n" ); //$NON-NLS-1$ //$NON-NLS-2$ - if ( index >= fieldStartIndex && index <= fieldEndIndex ) - { - return getField( byteCode.substring( fieldStartIndex, fieldEndIndex ), index - fieldStartIndex ); + int fieldEndIndex = byteCode.substring(0, byteCode.lastIndexOf("attributes_count")).lastIndexOf("\n"); //$NON-NLS-1$ //$NON-NLS-2$ + if (index >= fieldStartIndex && index <= fieldEndIndex) { + return getField(byteCode.substring(fieldStartIndex, fieldEndIndex), index - fieldStartIndex); } } - ClassFile cf = (ClassFile) ( (IClassFileEditorInput) getEditorInput( ) ).getClassFile( ); - return cf.getType( ); + ClassFile cf = (ClassFile) ((IClassFileEditorInput) getEditorInput()).getClassFile(); + return cf.getType(); } - private IField getField( String text, int index ) - { - Pattern pattern = Pattern.compile( "Field\\[\\d+\\].+?Field\\[\\d+\\]", Pattern.DOTALL ); //$NON-NLS-1$ - Matcher matcher = pattern.matcher( text ); + private IField getField(String text, int index) { + Pattern pattern = Pattern.compile("Field\\[\\d+\\].+?Field\\[\\d+\\]", Pattern.DOTALL); //$NON-NLS-1$ + Matcher matcher = pattern.matcher(text); - int fieldStartIndex = text.substring( 0, index ).lastIndexOf( "\n" ) + 1; //$NON-NLS-1$ + int fieldStartIndex = text.substring(0, index).lastIndexOf("\n") + 1; //$NON-NLS-1$ int findIndex = 0; - while ( matcher.find( findIndex ) ) - { - int start = text.substring( 0, matcher.start( ) ).lastIndexOf( "\n" ) + 1; //$NON-NLS-1$ - int end = text.substring( 0, matcher.end( ) ).lastIndexOf( "\n" ); //$NON-NLS-1$ - if ( fieldStartIndex >= start && fieldStartIndex <= end ) - { - String field = text.substring( start, end ); - return getField( field ); + while (matcher.find(findIndex)) { + int start = text.substring(0, matcher.start()).lastIndexOf("\n") + 1; //$NON-NLS-1$ + int end = text.substring(0, matcher.end()).lastIndexOf("\n"); //$NON-NLS-1$ + if (fieldStartIndex >= start && fieldStartIndex <= end) { + String field = text.substring(start, end); + return getField(field); } findIndex = end; } - if ( text.lastIndexOf( "Field[" ) != -1 ) //$NON-NLS-1$ + if (text.lastIndexOf("Field[") != -1) //$NON-NLS-1$ { - int start = text.substring( 0, text.lastIndexOf( "Field[" ) ).lastIndexOf( "\n" ) + 1; //$NON-NLS-1$ //$NON-NLS-2$ - int end = text.length( ); - if ( fieldStartIndex >= start && fieldStartIndex <= end ) - { - String field = text.substring( start, end ); - return getField( field ); + int start = text.substring(0, text.lastIndexOf("Field[")).lastIndexOf("\n") + 1; //$NON-NLS-1$ //$NON-NLS-2$ + int end = text.length(); + if (fieldStartIndex >= start && fieldStartIndex <= end) { + String field = text.substring(start, end); + return getField(field); } } return null; } - private IField getField( String field ) - { - ClassFile cf = (ClassFile) ( (IClassFileEditorInput) getEditorInput( ) ).getClassFile( ); - int nameIndex = field.indexOf( "name_index" ); //$NON-NLS-1$ - if ( nameIndex != -1 ) - { - String startText = field.substring( nameIndex ); - int firstIndex = startText.indexOf( '"' ); - if ( firstIndex != -1 ) - { - int lastIndex = startText.indexOf( '"', firstIndex + 1 ); - if ( lastIndex != -1 ) - { - String fieldName = startText.substring( firstIndex + 1, lastIndex ); - IField f = cf.getType( ).getField( fieldName ); - if ( f != null ) - { + private IField getField(String field) { + ClassFile cf = (ClassFile) ((IClassFileEditorInput) getEditorInput()).getClassFile(); + int nameIndex = field.indexOf("name_index"); //$NON-NLS-1$ + if (nameIndex != -1) { + String startText = field.substring(nameIndex); + int firstIndex = startText.indexOf('"'); + if (firstIndex != -1) { + int lastIndex = startText.indexOf('"', firstIndex + 1); + if (lastIndex != -1) { + String fieldName = startText.substring(firstIndex + 1, lastIndex); + IField f = cf.getType().getField(fieldName); + if (f != null) { return f; } } @@ -557,287 +468,231 @@ private IField getField( String field ) return null; } - private IMethod getMethod( String text, int index ) - { - Pattern pattern = Pattern.compile( "Method\\[\\d+\\].+?Method\\[\\d+\\]", Pattern.DOTALL ); //$NON-NLS-1$ - Matcher matcher = pattern.matcher( text ); + private IMethod getMethod(String text, int index) { + Pattern pattern = Pattern.compile("Method\\[\\d+\\].+?Method\\[\\d+\\]", Pattern.DOTALL); //$NON-NLS-1$ + Matcher matcher = pattern.matcher(text); - int methodStartIndex = text.substring( 0, index ).lastIndexOf( "\n" ) + 1; //$NON-NLS-1$ + int methodStartIndex = text.substring(0, index).lastIndexOf("\n") + 1; //$NON-NLS-1$ int findIndex = 0; - while ( matcher.find( findIndex ) ) - { - int start = text.substring( 0, matcher.start( ) ).lastIndexOf( "\n" ) + 1; //$NON-NLS-1$ - int end = text.substring( 0, matcher.end( ) ).lastIndexOf( "\n" ); //$NON-NLS-1$ - if ( methodStartIndex >= start && methodStartIndex <= end ) - { - String method = text.substring( start, end ); - return getMethod( method ); + while (matcher.find(findIndex)) { + int start = text.substring(0, matcher.start()).lastIndexOf("\n") + 1; //$NON-NLS-1$ + int end = text.substring(0, matcher.end()).lastIndexOf("\n"); //$NON-NLS-1$ + if (methodStartIndex >= start && methodStartIndex <= end) { + String method = text.substring(start, end); + return getMethod(method); } findIndex = end; } - if ( text.lastIndexOf( "Method[" ) != -1 ) //$NON-NLS-1$ + if (text.lastIndexOf("Method[") != -1) //$NON-NLS-1$ { - int start = text.substring( 0, text.lastIndexOf( "Method[" ) ).lastIndexOf( "\n" ) + 1; //$NON-NLS-1$ //$NON-NLS-2$ - int end = text.length( ); - if ( methodStartIndex >= start && methodStartIndex <= end ) - { - String method = text.substring( start, end ); - return getMethod( method ); + int start = text.substring(0, text.lastIndexOf("Method[")).lastIndexOf("\n") + 1; //$NON-NLS-1$ //$NON-NLS-2$ + int end = text.length(); + if (methodStartIndex >= start && methodStartIndex <= end) { + String method = text.substring(start, end); + return getMethod(method); } } return null; } - private IMethod getMethod( String method ) - { - ClassFile cf = (ClassFile) ( (IClassFileEditorInput) getEditorInput( ) ).getClassFile( ); + private IMethod getMethod(String method) { + ClassFile cf = (ClassFile) ((IClassFileEditorInput) getEditorInput()).getClassFile(); String methodName = null; String descriptor = null; - int nameIndex = method.indexOf( "name_index" ); //$NON-NLS-1$ - if ( nameIndex != -1 ) - { + int nameIndex = method.indexOf("name_index"); //$NON-NLS-1$ + if (nameIndex != -1) { - String startText = method.substring( nameIndex ); - int firstIndex = startText.indexOf( '"' ); - if ( firstIndex != -1 ) - { - int lastIndex = startText.indexOf( '"', firstIndex + 1 ); - if ( lastIndex != -1 ) - { - methodName = startText.substring( firstIndex + 1, lastIndex ); + String startText = method.substring(nameIndex); + int firstIndex = startText.indexOf('"'); + if (firstIndex != -1) { + int lastIndex = startText.indexOf('"', firstIndex + 1); + if (lastIndex != -1) { + methodName = startText.substring(firstIndex + 1, lastIndex); } } } - if ( methodName == null ) + if (methodName == null) return null; - if ( "".equals( methodName ) ) //$NON-NLS-1$ + if ("".equals(methodName)) //$NON-NLS-1$ { - methodName = cf.getTypeName( ); + methodName = cf.getTypeName(); } - int descriptorIndex = method.indexOf( "descriptor_index" ); //$NON-NLS-1$ - if ( descriptorIndex != -1 ) - { - String startText = method.substring( descriptorIndex ); - int firstIndex = startText.indexOf( '"' ); - if ( firstIndex != -1 ) - { - int lastIndex = startText.indexOf( '"', firstIndex + 1 ); - if ( lastIndex != -1 ) - { - descriptor = startText.substring( firstIndex + 1, lastIndex ); + int descriptorIndex = method.indexOf("descriptor_index"); //$NON-NLS-1$ + if (descriptorIndex != -1) { + String startText = method.substring(descriptorIndex); + int firstIndex = startText.indexOf('"'); + if (firstIndex != -1) { + int lastIndex = startText.indexOf('"', firstIndex + 1); + if (lastIndex != -1) { + descriptor = startText.substring(firstIndex + 1, lastIndex); } } } - if ( descriptor == null ) + if (descriptor == null) return null; - try - { - IMethod m = ClassFileDocumentsUtils.findMethod( cf.getType( ), methodName, descriptor ); - if ( m != null ) - { + try { + IMethod m = ClassFileDocumentsUtils.findMethod(cf.getType(), methodName, descriptor); + if (m != null) { return m; } - } - catch ( JavaModelException e ) - { - Logger.debug( e ); + } catch (JavaModelException e) { + Logger.debug(e); } return null; } - protected void editorContextMenuAboutToShow( IMenuManager menu ) - { - super.editorContextMenuAboutToShow( menu ); - String text = (String) ReflectionUtils.invokeMethod( this, "getShowInMenuLabel" ); //$NON-NLS-1$ - for ( int i = 0; i < menu.getItems( ).length; i++ ) - { - if ( menu.getItems( )[i] instanceof MenuManager ) - { - if ( ( (MenuManager) menu.getItems( )[i] ).getMenuText( ).equals( text ) ) - { - menu.remove( menu.getItems( )[i] ); + protected void editorContextMenuAboutToShow(IMenuManager menu) { + super.editorContextMenuAboutToShow(menu); + String text = (String) ReflectionUtils.invokeMethod(this, "getShowInMenuLabel"); //$NON-NLS-1$ + for (int i = 0; i < menu.getItems().length; i++) { + if (menu.getItems()[i] instanceof MenuManager) { + if (((MenuManager) menu.getItems()[i]).getMenuText().equals(text)) { + menu.remove(menu.getItems()[i]); } } } - menu.appendToGroup( ITextEditorActionConstants.GROUP_OPEN, getAction( SourceCodeAction.ID ) ); - menu.appendToGroup( ITextEditorActionConstants.GROUP_OPEN, getAction( ByteCodeAction.ID ) ); - menu.appendToGroup( ITextEditorActionConstants.GROUP_OPEN, getAction( DisassemblerAction.ID ) ); - menu.addMenuListener( new IMenuListener( ) { + menu.appendToGroup(ITextEditorActionConstants.GROUP_OPEN, getAction(SourceCodeAction.ID)); + menu.appendToGroup(ITextEditorActionConstants.GROUP_OPEN, getAction(ByteCodeAction.ID)); + menu.appendToGroup(ITextEditorActionConstants.GROUP_OPEN, getAction(DisassemblerAction.ID)); + menu.addMenuListener(new IMenuListener() { @Override - public void menuAboutToShow( IMenuManager manager ) - { - showMenu( manager ); + public void menuAboutToShow(IMenuManager manager) { + showMenu(manager); } - } ); + }); } - private void showMenu( IMenuManager submenu ) - { - for ( Iterator iter = Arrays.asList( submenu.getItems( ) ).iterator( ); iter.hasNext( ); ) - { - IContributionItem item = iter.next( ); - if ( item instanceof ActionContributionItem ) - { - IAction action = ( (ActionContributionItem) item ).getAction( ); - if ( action instanceof IUpdate ) - { - ( (IUpdate) action ).update( ); + private void showMenu(IMenuManager submenu) { + for (Iterator iter = Arrays.asList(submenu.getItems()).iterator(); iter.hasNext();) { + IContributionItem item = iter.next(); + if (item instanceof ActionContributionItem) { + IAction action = ((ActionContributionItem) item).getAction(); + if (action instanceof IUpdate) { + ((IUpdate) action).update(); } } } } @Override - protected void createActions( ) - { - super.createActions( ); - setAction( SourceCodeAction.ID, new SourceCodeAction( ) ); - setAction( ByteCodeAction.ID, new ByteCodeAction( ) ); - setAction( DisassemblerAction.ID, new DisassemblerAction( ) ); + protected void createActions() { + super.createActions(); + setAction(SourceCodeAction.ID, new SourceCodeAction()); + setAction(ByteCodeAction.ID, new ByteCodeAction()); + setAction(DisassemblerAction.ID, new DisassemblerAction()); } @Override - public String[] collectContextMenuPreferencePages( ) - { - return editor.collectContextMenuPreferencePages( ); + public String[] collectContextMenuPreferencePages() { + return editor.collectContextMenuPreferencePages(); } - public boolean isEditorInputModifiable( ) - { + public boolean isEditorInputModifiable() { return false; } - public Control getControl( ) - { + public Control getControl() { return container; } - public void setSelectionElement( ISourceReference selectedElement ) - { - setSelectionElement( selectedElement, false ); + public void setSelectionElement(ISourceReference selectedElement) { + setSelectionElement(selectedElement, false); } - public void setSelectionElement( ISourceReference selectedElement, boolean force ) - { - final StyledText byteCodeText = getSourceViewer( ).getTextWidget( ); - if ( JavaDecompilerPlugin.getDefault( ).getSourceMode( ) == JavaDecompilerPlugin.BYTE_CODE_MODE - && byteCodeText != null - && !byteCodeText.isDisposed( ) ) - { - if ( !force ) - { - if ( UIUtil.requestFromDisassemblerSelection( ) ) + public void setSelectionElement(ISourceReference selectedElement, boolean force) { + final StyledText byteCodeText = getSourceViewer().getTextWidget(); + if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.BYTE_CODE_MODE + && byteCodeText != null && !byteCodeText.isDisposed()) { + if (!force) { + if (UIUtil.requestFromDisassemblerSelection()) return; - if ( !UIUtil.requestFromLinkToSelection( ) ) + if (!UIUtil.requestFromLinkToSelection()) return; } - if ( selectedElement instanceof IMethod - || selectedElement instanceof IField - || selectedElement instanceof BinaryType ) - { - try - { - IRegion element = searchElement( byteCodeText, selectedElement ); - if ( element != null ) - { - selectElement( byteCodeText, element ); + if (selectedElement instanceof IMethod || selectedElement instanceof IField + || selectedElement instanceof BinaryType) { + try { + IRegion element = searchElement(byteCodeText, selectedElement); + if (element != null) { + selectElement(byteCodeText, element); } - } - catch ( Exception e ) - { - Logger.debug( e ); + } catch (Exception e) { + Logger.debug(e); } } } } - private IRegion searchElement( StyledText byteCodeText, ISourceReference reference ) throws CoreException - { - ClassFile cf = (ClassFile) ( (IClassFileEditorInput) getEditorInput( ) ).getClassFile( ); - if ( reference instanceof BinaryType ) - { - String byteCode = byteCodeText.getText( ); - String className = ( (BinaryType) reference ).getElementName( ); - Pattern pattern = Pattern.compile( "this_class.+?\\*", Pattern.DOTALL ); //$NON-NLS-1$ - Matcher matcher = pattern.matcher( byteCode ); - while ( matcher.find( ) ) - { - String text = matcher.group( ); - int classIndex = text.indexOf( className ); - if ( classIndex != -1 ) - { - return new Region( matcher.start( ) + classIndex, className.length( ) ); + private IRegion searchElement(StyledText byteCodeText, ISourceReference reference) throws CoreException { + ClassFile cf = (ClassFile) ((IClassFileEditorInput) getEditorInput()).getClassFile(); + if (reference instanceof BinaryType) { + String byteCode = byteCodeText.getText(); + String className = ((BinaryType) reference).getElementName(); + Pattern pattern = Pattern.compile("this_class.+?\\*", Pattern.DOTALL); //$NON-NLS-1$ + Matcher matcher = pattern.matcher(byteCode); + while (matcher.find()) { + String text = matcher.group(); + int classIndex = text.indexOf(className); + if (classIndex != -1) { + return new Region(matcher.start() + classIndex, className.length()); } } - } - else if ( reference instanceof IField ) - { - BinaryType jdtType = (BinaryType) ( (IField) reference ).getParent( ); - if ( jdtType.equals( cf.getType( ) ) ) - { - String byteCode = byteCodeText.getText( ); - int index = byteCode.indexOf( "/* Fields: */" ); //$NON-NLS-1$ - if ( index != -1 ) - { - String fieldName = ( (IField) reference ).getElementName( ); + } else if (reference instanceof IField) { + BinaryType jdtType = (BinaryType) ((IField) reference).getParent(); + if (jdtType.equals(cf.getType())) { + String byteCode = byteCodeText.getText(); + int index = byteCode.indexOf("/* Fields: */"); //$NON-NLS-1$ + if (index != -1) { + String fieldName = ((IField) reference).getElementName(); String fieldByteCode = "bytes=\"" + fieldName + "\""; //$NON-NLS-1$ //$NON-NLS-2$ - Pattern pattern = Pattern.compile( "Field\\[\\d+\\].+?attributes_count", Pattern.DOTALL ); //$NON-NLS-1$ - Matcher matcher = pattern.matcher( byteCode ); - while ( matcher.find( ) ) - { - String text = matcher.group( ); - int fieldIndex = text.indexOf( fieldByteCode ); - if ( fieldIndex != -1 ) - { - return new Region( matcher.start( ) + fieldIndex + "bytes=\"".length( ), //$NON-NLS-1$ - fieldName.length( ) ); + Pattern pattern = Pattern.compile("Field\\[\\d+\\].+?attributes_count", Pattern.DOTALL); //$NON-NLS-1$ + Matcher matcher = pattern.matcher(byteCode); + while (matcher.find()) { + String text = matcher.group(); + int fieldIndex = text.indexOf(fieldByteCode); + if (fieldIndex != -1) { + return new Region(matcher.start() + fieldIndex + "bytes=\"".length(), //$NON-NLS-1$ + fieldName.length()); } } } } - } - else if ( reference instanceof IMethod ) - { - BinaryType jdtType = (BinaryType) ( (IMethod) reference ).getParent( ); - if ( jdtType.equals( cf.getType( ) ) ) - { - String byteCode = byteCodeText.getText( ); - int index = byteCode.indexOf( "/* Methods: */" ); //$NON-NLS-1$ - if ( index != -1 ) - { - String methodName = ( (IMethod) reference ).getElementName( ); - if ( ( (IMethod) reference ).isConstructor( ) ) - { + } else if (reference instanceof IMethod) { + BinaryType jdtType = (BinaryType) ((IMethod) reference).getParent(); + if (jdtType.equals(cf.getType())) { + String byteCode = byteCodeText.getText(); + int index = byteCode.indexOf("/* Methods: */"); //$NON-NLS-1$ + if (index != -1) { + String methodName = ((IMethod) reference).getElementName(); + if (((IMethod) reference).isConstructor()) { methodName = ""; //$NON-NLS-1$ } String methodByteCode = "bytes=\"" + methodName + "\""; //$NON-NLS-1$ //$NON-NLS-2$ - String methodSignature = ( (IMethod) reference ).getSignature( ); - Pattern pattern = Pattern.compile( "Method\\[\\d+\\].+?attributes_count", Pattern.DOTALL ); //$NON-NLS-1$ - Matcher matcher = pattern.matcher( byteCode ); - while ( matcher.find( ) ) - { - String text = matcher.group( ); - int methodIndex = text.indexOf( methodByteCode ); - int methodSignatureIndex = text.indexOf( methodSignature ); - if ( methodIndex != -1 && methodSignatureIndex != -1 ) - { - return new Region( matcher.start( ) + methodIndex + "bytes=\"".length( ), //$NON-NLS-1$ - methodName.length( ) ); + String methodSignature = ((IMethod) reference).getSignature(); + Pattern pattern = Pattern.compile("Method\\[\\d+\\].+?attributes_count", Pattern.DOTALL); //$NON-NLS-1$ + Matcher matcher = pattern.matcher(byteCode); + while (matcher.find()) { + String text = matcher.group(); + int methodIndex = text.indexOf(methodByteCode); + int methodSignatureIndex = text.indexOf(methodSignature); + if (methodIndex != -1 && methodSignatureIndex != -1) { + return new Region(matcher.start() + methodIndex + "bytes=\"".length(), //$NON-NLS-1$ + methodName.length()); } } } @@ -846,38 +701,31 @@ else if ( reference instanceof IMethod ) return null; } - private void selectElement( StyledText byteCodeText, IRegion region ) - { - if ( region != null && region.getOffset( ) != -1 ) - { - byteCodeText.setSelection( region.getOffset( ), region.getOffset( ) + region.getLength( ) ); + private void selectElement(StyledText byteCodeText, IRegion region) { + if (region != null && region.getOffset() != -1) { + byteCodeText.setSelection(region.getOffset(), region.getOffset() + region.getLength()); } } - protected IConfigurationElement getConfigurationElement( ) - { - return (IConfigurationElement) ReflectionUtils.invokeMethod( editor, "getConfigurationElement" ); //$NON-NLS-1$ + protected IConfigurationElement getConfigurationElement() { + return (IConfigurationElement) ReflectionUtils.invokeMethod(editor, "getConfigurationElement"); //$NON-NLS-1$ } @Override - public boolean isDirty( ) - { + public boolean isDirty() { return false; } - public boolean isEditable( ) - { + public boolean isEditable() { return false; } @Override - public boolean isEditorInputReadOnly( ) - { + public boolean isEditorInputReadOnly() { return true; } - protected void handleCursorPositionChanged( ) - { - ReflectionUtils.invokeMethod( editor, "handleCursorPositionChanged" ); //$NON-NLS-1$ + protected void handleCursorPositionChanged() { + ReflectionUtils.invokeMethod(editor, "handleCursorPositionChanged"); //$NON-NLS-1$ } } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/ClassFileSourceMap.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/ClassFileSourceMap.java index dbbf0845..fd8fa873 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/ClassFileSourceMap.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/ClassFileSourceMap.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.editor; @@ -21,60 +18,57 @@ import org.eclipse.jdt.internal.core.BufferManager; import org.eclipse.jdt.internal.core.ClassFile; import org.eclipse.jdt.internal.core.SourceMapper; +import org.sf.feeling.decompiler.util.EclipseCompatibilityHelper; +import org.sf.feeling.decompiler.util.SourceMapperUtil; -public class ClassFileSourceMap -{ +public class ClassFileSourceMap { - private static IType getOuterMostEnclosingType( ClassFile cf ) - { - IType type = cf.getType( ); - IType enclosingType = type.getDeclaringType( ); - while ( enclosingType != null ) - { + private static IType getOuterMostEnclosingType(ClassFile cf) { + IType type = cf.getType(); + IType enclosingType = type.getDeclaringType(); + while (enclosingType != null) { type = enclosingType; - enclosingType = type.getDeclaringType( ); + enclosingType = type.getDeclaringType(); } return type; } - private static void mapSource( JavaDecompilerBufferManager bufferManager, ClassFile cf, SourceMapper mapper, - IBinaryType info, IClassFile bufferOwner, char[] markedSrc ) - { - char[] contents = mapper.findSource( cf.getType( ), info ); - if ( Arrays.equals( markedSrc, contents ) ) + private static void mapSource(JavaDecompilerBufferManager bufferManager, ClassFile cf, SourceMapper mapper, + IBinaryType info, IClassFile bufferOwner, char[] markedSrc) { + char[] contents = mapper.findSource(cf.getType(), info); + if (Arrays.equals(markedSrc, contents)) { return; + } contents = markedSrc; - if ( contents != null ) - { + if (contents != null) { // create buffer - IBuffer buffer = BufferManager.createBuffer( bufferOwner ); - if ( buffer == null ) + IBuffer buffer = BufferManager.createBuffer(bufferOwner); + if (buffer == null) { return; + } JavaDecompilerBufferManager bufManager = bufferManager; - bufManager.addBuffer( buffer ); + bufManager.addBuffer(buffer); // set the buffer source - if ( buffer.getCharacters( ) == null ) - { - buffer.setContents( contents ); + if (buffer.getCharacters() == null) { + buffer.setContents(contents); } // listen to buffer changes // buffer.addBufferChangedListener( cf ); // do the source mapping - mapper.mapSource( getOuterMostEnclosingType( cf ), contents, info ); + SourceMapperUtil.mapSource(mapper, getOuterMostEnclosingType(cf), contents, info); return; - } - else - { + } else { // create buffer - IBuffer buffer = BufferManager.createNullBuffer( bufferOwner ); - if ( buffer == null ) + IBuffer buffer = BufferManager.createNullBuffer(bufferOwner); + if (buffer == null) { return; + } JavaDecompilerBufferManager bufManager = bufferManager; - bufManager.addBuffer( buffer ); + bufManager.addBuffer(buffer); // listen to buffer changes // buffer.addBufferChangedListener( cf ); @@ -82,27 +76,23 @@ private static void mapSource( JavaDecompilerBufferManager bufferManager, ClassF } } - public static void updateSource( JavaDecompilerBufferManager bufferManager, ClassFile cf, char[] markedSrc ) - throws JavaModelException - { - IType type = cf.getType( ); - if ( !type.isBinary( ) ) - { + public static void updateSource(JavaDecompilerBufferManager bufferManager, ClassFile cf, char[] markedSrc) + throws JavaModelException { + IType type = cf.getType(); + if (!type.isBinary()) { return; } - Object info = cf.getElementInfo( ); - IType enclosingType = type.getDeclaringType( ); - while ( enclosingType != null ) - { + Object info = EclipseCompatibilityHelper.javaElementGetElementInfo(cf); + IType enclosingType = type.getDeclaringType(); + while (enclosingType != null) { type = enclosingType; - enclosingType = type.getDeclaringType( ); + enclosingType = type.getDeclaringType(); } IType outerMostEnclosingType = type; - SourceMapper mapper = cf.getSourceMapper( ); + SourceMapper mapper = cf.getSourceMapper(); IBinaryType typeInfo = info instanceof IBinaryType ? (IBinaryType) info : null; - if ( mapper != null ) - { - mapSource( bufferManager, cf, mapper, typeInfo, outerMostEnclosingType.getClassFile( ), markedSrc ); + if (mapper != null) { + mapSource(bufferManager, cf, mapper, typeInfo, outerMostEnclosingType.getClassFile(), markedSrc); } } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/ClassImportContainer.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/ClassImportContainer.java deleted file mode 100644 index fa27aac9..00000000 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/ClassImportContainer.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.editor; - -import org.eclipse.jdt.internal.core.ClassFile; -import org.eclipse.jdt.internal.core.ImportContainer; - -public class ClassImportContainer extends ImportContainer -{ - - protected ClassImportContainer( ClassFile parent ) - { - super( null ); - this.parent = parent; - } -} diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/DecompilerClassEditorInput.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/DecompilerClassEditorInput.java index b8795a67..e0bec618 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/DecompilerClassEditorInput.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/DecompilerClassEditorInput.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.editor; @@ -14,27 +11,23 @@ import org.eclipse.core.filesystem.IFileStore; import org.eclipse.ui.ide.FileStoreEditorInput; -public class DecompilerClassEditorInput extends FileStoreEditorInput -{ +public class DecompilerClassEditorInput extends FileStoreEditorInput { private String toolTipText = null; - public DecompilerClassEditorInput( IFileStore fileStore ) - { - super( fileStore ); + public DecompilerClassEditorInput(IFileStore fileStore) { + super(fileStore); } @Override - public String getToolTipText( ) - { - if ( toolTipText != null ) + public String getToolTipText() { + if (toolTipText != null) { return toolTipText; - else - return super.getToolTipText( ); + } + return super.getToolTipText(); } - public void setToolTipText( String toolTipText ) - { + public void setToolTipText(String toolTipText) { this.toolTipText = toolTipText; } 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 c8635b46..35232873 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 @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.editor; @@ -35,169 +32,147 @@ 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; +import org.sf.feeling.decompiler.util.EclipseUtils; +import org.sf.feeling.decompiler.util.SourceMapperUtil; -public abstract class DecompilerSourceMapper extends SourceMapper -{ +public abstract class DecompilerSourceMapper extends SourceMapper { - protected static Map originalSourceMapper = new ConcurrentHashMap( ); + protected static Map originalSourceMapper = new ConcurrentHashMap<>(); protected boolean isAttachedSource; - public DecompilerSourceMapper( IPath sourcePath, String rootPath, Map options ) - { - super( sourcePath, rootPath, options ); + public DecompilerSourceMapper(IPath sourcePath, String rootPath, Map options) { + super(sourcePath, rootPath, options); } - public char[] findSource( IType type ) throws JavaModelException - { - if ( !type.isBinary( ) ) - { + public char[] findSource(IType type) throws JavaModelException { + if (!type.isBinary()) { return null; } - BinaryType parent = (BinaryType) type.getDeclaringType( ); + BinaryType parent = (BinaryType) type.getDeclaringType(); BinaryType declType = (BinaryType) type; - while ( parent != null ) - { + while (parent != null) { declType = parent; - parent = (BinaryType) declType.getDeclaringType( ); + parent = (BinaryType) declType.getDeclaringType(); } - IBinaryType info = null; - - info = (IBinaryType) declType.getElementInfo( ); - - if ( info == null ) - { + IBinaryType info = EclipseCompatibilityHelper.binaryTypeGetElementInfo(declType); + if (info == null) { return null; } - return findSource( type, info ); + return findSource(type, info); } /** - * @see org.eclipse.jdt.internal.core.SourceMapper#mapSource(IType, char[], - * IBinaryType) + * With the time this API has changed and the original method which accepted + * {@link IType} as first parameter has been superseded and replaced by the + * which does accept {@link NamedParameter} as first parameter. + *

      + * But we do need to support both APIs here so we will try to invoke the correct + * method using reflection instead of a hard coded reference. */ - public void mapSource( IType type, char[] contents, boolean force ) - { - if ( force ) - { - sourceRanges.remove( type ); + public void mapSourceSwitch(IType type, char[] contents, boolean force) { + if (force) { + sourceRanges.remove(type); + } + + try { + SourceMapperUtil.mapSource(this, type, contents, null); + } catch (Exception e) { + // Method was found but invocation failed, this shouldn't happen. } - super.mapSource( type, contents, null ); } /** - * @return Does the source returned by - * {@link #findSource(IType, IBinaryType)} originate from a source - * attachment? + * @return Does the source returned by {@link #findSource(IType, IBinaryType)} + * originate from a source attachment? */ - public boolean isAttachedSource( ) - { + public boolean isAttachedSource() { return isAttachedSource; } - protected String formatSource( String source ) - { + protected String formatSource(String source) { String result = null; - IPreferenceStore prefs = JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ); - boolean useFormatter = prefs.getBoolean( JavaDecompilerPlugin.USE_ECLIPSE_FORMATTER ); - - if ( source != null && useFormatter ) - { - CompilerOptions option = new CompilerOptions( ); - Map options = option.getMap( ); - options.put( CompilerOptions.OPTION_Compliance, DecompilerOutputUtil.getMaxDecompileLevel( ) ); // $NON-NLS-1$ - options.put( CompilerOptions.OPTION_Source, DecompilerOutputUtil.getMaxDecompileLevel( ) ); // $NON-NLS-1$ - CodeFormatter formatter = ToolFactory.createCodeFormatter( options ); - TextEdit textEdit = formatter - .format( CodeFormatter.K_COMPILATION_UNIT, source, 0, source.length( ), 0, null ); - if ( textEdit != null ) - { - IDocument document = new Document( source ); - try - { - textEdit.apply( document ); - } - catch ( BadLocationException e ) - { - JavaDecompilerPlugin.log( IStatus.WARNING, e, "Unable to apply text formatting." ); //$NON-NLS-1$ + IPreferenceStore prefs = JavaDecompilerPlugin.getDefault().getPreferenceStore(); + boolean useFormatter = prefs.getBoolean(JavaDecompilerConstants.USE_ECLIPSE_FORMATTER); + + if (source != null && useFormatter) { + CompilerOptions option = new CompilerOptions(); + Map options = option.getMap(); + options.put(CompilerOptions.OPTION_Compliance, EclipseUtils.getMaxDecompileLevel()); // $NON-NLS-1$ + options.put(CompilerOptions.OPTION_Source, EclipseUtils.getMaxDecompileLevel()); // $NON-NLS-1$ + CodeFormatter formatter = ToolFactory.createCodeFormatter(options); + TextEdit textEdit = formatter.format(CodeFormatter.K_COMPILATION_UNIT, source, 0, source.length(), 0, null); + if (textEdit != null) { + IDocument document = new Document(source); + try { + textEdit.apply(document); + } catch (BadLocationException e) { + JavaDecompilerPlugin.log(IStatus.WARNING, e, "Unable to apply text formatting."); //$NON-NLS-1$ } - result = document.get( ); + result = document.get(); } - if ( result == null ) - { - JavaDecompilerPlugin.log( IStatus.WARNING, null, "Could not format code, it will remain unformatted." ); //$NON-NLS-1$ + if (result == null) { + JavaDecompilerPlugin.log(IStatus.WARNING, null, "Could not format code, it will remain unformatted."); //$NON-NLS-1$ result = source; } - } - else - { + } else { result = source; } - return result.trim( ); + return result.trim(); } - protected String getArchivePath( IPackageFragmentRoot root ) - { + protected String getArchivePath(IPackageFragmentRoot root) { String archivePath = null; IResource resource; - try - { - if ( ( resource = root.getUnderlyingResource( ) ) != null ) + try { + if ((resource = root.getUnderlyingResource()) != null) { // jar in workspace - archivePath = resource.getLocation( ).toOSString( ); - else + archivePath = resource.getLocation().toOSString(); + } else { // external jar - archivePath = root.getPath( ).toOSString( ); - } - catch ( JavaModelException e ) - { - throw new RuntimeException( "Unexpected Java model exception: " //$NON-NLS-1$ - + e.toString( ) ); + archivePath = root.getPath().toOSString(); + } + } catch (JavaModelException e) { + throw new RuntimeException("Unexpected Java model exception: " //$NON-NLS-1$ + + e.toString()); } return archivePath; } /** * Finds the deepest IJavaElement in the hierarchy of - * elt's children (including elt itself) which has - * a source range that encloses position according to + * elt's children (including elt itself) which has a + * source range that encloses position according to * mapper. * * Code mostly taken from 'org.eclipse.jdt.internal.core.ClassFile' */ - protected IJavaElement findElement( IJavaElement elt, int position ) - { - ISourceRange range = getSourceRange( elt ); - if ( range == null || position < range.getOffset( ) || range.getOffset( ) + range.getLength( ) - 1 < position ) - { + protected IJavaElement findElement(IJavaElement elt, int position) { + ISourceRange range = getSourceRange(elt); + if (range == null || position < range.getOffset() || range.getOffset() + range.getLength() - 1 < position) { return null; } - if ( elt instanceof IParent ) - { - try - { - IJavaElement[] children = ( (IParent) elt ).getChildren( ); - for ( int i = 0; i < children.length; i++ ) - { - IJavaElement match = findElement( children[i], position ); - if ( match != null ) - { + if (elt instanceof IParent) { + try { + IJavaElement[] children = ((IParent) elt).getChildren(); + for (int i = 0; i < children.length; i++) { + IJavaElement match = findElement(children[i], position); + if (match != null) { return match; } } - } - catch ( JavaModelException npe ) - { + } catch (JavaModelException npe) { } } return elt; } - public abstract String decompile( String decompilerType, File file ); + public abstract String decompileFile(String decompilerType, File file); } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/DecompilerType.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/DecompilerType.java index aa0b1fa2..e0babe76 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/DecompilerType.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/DecompilerType.java @@ -1,30 +1,22 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.editor; import org.sf.feeling.decompiler.JavaDecompilerPlugin; -public class DecompilerType -{ +public class DecompilerType { - public static final String FernFlower = "FernFlower";//$NON-NLS-1$ + private static String[] decompilerTypes = null; - public static String[] decompilerTypes = null; - - public static String[] getDecompilerTypes( ) - { - if ( decompilerTypes == null ) - { - decompilerTypes = JavaDecompilerPlugin.getDefault( ).getDecompilerDescriptorTypes( ); + public static String[] getDecompilerTypes() { + if (decompilerTypes == null) { + decompilerTypes = JavaDecompilerPlugin.getDefault().getDecompilerDescriptorTypes(); } return decompilerTypes; } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/DisassemblerConfiguration.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/DisassemblerConfiguration.java index a7878a7b..57d2695c 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/DisassemblerConfiguration.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/DisassemblerConfiguration.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.editor; @@ -48,6 +45,7 @@ import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.ui.editors.text.TextSourceViewerConfiguration; import org.eclipse.ui.texteditor.ITextEditor; +import org.sf.feeling.decompiler.util.ReflectionUtils; import com.drgarbage.asm.render.intf.IFieldSection; import com.drgarbage.asm.render.intf.IInstructionLine; @@ -55,8 +53,7 @@ import com.drgarbage.bytecode.ByteCodeConstants; import com.drgarbage.bytecode.instructions.BranchInstruction; -public class DisassemblerConfiguration extends TextSourceViewerConfiguration -{ +public class DisassemblerConfiguration extends TextSourceViewerConfiguration { /** * The Java source code scanner. @@ -95,53 +92,46 @@ public class DisassemblerConfiguration extends TextSourceViewerConfiguration */ private ITextEditor fTextEditor; - public DisassemblerConfiguration( IColorManager colorManager, IPreferenceStore preferenceStore, ITextEditor editor, - String partitioning ) - { - super( preferenceStore ); + public DisassemblerConfiguration(IColorManager colorManager, IPreferenceStore preferenceStore, ITextEditor editor, + String partitioning) { + super(preferenceStore); fColorManager = colorManager; fTextEditor = editor; fDocumentPartitioning = partitioning; - initializeScanners( ); + initializeScanners(); } - public int[] getConfiguredTextHoverStateMasks( ISourceViewer sourceViewer, String contentType ) - { - JavaEditorTextHoverDescriptor[] hoverDescs = JavaPlugin.getDefault( ).getJavaEditorTextHoverDescriptors( ); + public int[] getConfiguredTextHoverStateMasks(ISourceViewer sourceViewer, String contentType) { + JavaEditorTextHoverDescriptor[] hoverDescs = JavaPlugin.getDefault().getJavaEditorTextHoverDescriptors(); int stateMasks[] = new int[hoverDescs.length]; int stateMasksLength = 0; - for ( int i = 0; i < hoverDescs.length; i++ ) - { - if ( hoverDescs[i].isEnabled( ) ) - { + for (int i = 0; i < hoverDescs.length; i++) { + if (hoverDescs[i].isEnabled()) { int j = 0; - int stateMask = hoverDescs[i].getStateMask( ); - while ( j < stateMasksLength ) - { - if ( stateMasks[j] == stateMask ) + int stateMask = hoverDescs[i].getStateMask(); + while (j < stateMasksLength) { + if (stateMasks[j] == stateMask) break; j++; } - if ( j == stateMasksLength ) + if (j == stateMasksLength) stateMasks[stateMasksLength++] = stateMask; } } - if ( stateMasksLength == hoverDescs.length ) + if (stateMasksLength == hoverDescs.length) return stateMasks; int[] shortenedStateMasks = new int[stateMasksLength]; - System.arraycopy( stateMasks, 0, shortenedStateMasks, 0, stateMasksLength ); + System.arraycopy(stateMasks, 0, shortenedStateMasks, 0, stateMasksLength); return shortenedStateMasks; } - public ITextHover getTextHover( ISourceViewer sourceViewer, String contentType, int stateMask ) - { - JavaEditorTextHoverDescriptor[] hoverDescs = JavaPlugin.getDefault( ).getJavaEditorTextHoverDescriptors( ); + public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType, int stateMask) { + JavaEditorTextHoverDescriptor[] hoverDescs = JavaPlugin.getDefault().getJavaEditorTextHoverDescriptors(); int i = 0; - while ( i < hoverDescs.length ) - { - if ( hoverDescs[i].isEnabled( ) && hoverDescs[i].getStateMask( ) == stateMask ) - return new JavaEditorTextHoverProxy( hoverDescs[i], fTextEditor ); + while (i < hoverDescs.length) { + if (hoverDescs[i].isEnabled() && hoverDescs[i].getStateMask() == stateMask) + return new JavaEditorTextHoverProxy(hoverDescs[i], fTextEditor); i++; } @@ -153,8 +143,7 @@ public ITextHover getTextHover( ISourceViewer sourceViewer, String contentType, * * @return the Java source code scanner */ - protected RuleBasedScanner getCodeScanner( ) - { + protected RuleBasedScanner getCodeScanner() { return fCodeScanner; } @@ -163,21 +152,14 @@ protected RuleBasedScanner getCodeScanner( ) * * @return the color manager */ - protected IColorManager getColorManager( ) - { + protected IColorManager getColorManager() { return fColorManager; } - public String[] getConfiguredContentTypes( ISourceViewer sourceViewer ) - { - return new String[]{ - IDocument.DEFAULT_CONTENT_TYPE, - IJavaPartitions.JAVA_MULTI_LINE_COMMENT, - IJavaPartitions.JAVA_SINGLE_LINE_COMMENT, - IJavaPartitions.JAVA_STRING, - IJavaPartitions.JAVA_CHARACTER, - IJavaPartitions.JAVA_DOC - }; + public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) { + return new String[] { IDocument.DEFAULT_CONTENT_TYPE, IJavaPartitions.JAVA_MULTI_LINE_COMMENT, + IJavaPartitions.JAVA_SINGLE_LINE_COMMENT, IJavaPartitions.JAVA_STRING, IJavaPartitions.JAVA_CHARACTER, + IJavaPartitions.JAVA_DOC }; } /* @@ -187,32 +169,34 @@ public String[] getConfiguredContentTypes( ISourceViewer sourceViewer ) * * @since 3.0 */ - public String getConfiguredDocumentPartitioning( ISourceViewer sourceViewer ) - { - if ( fDocumentPartitioning != null ) + public String getConfiguredDocumentPartitioning(ISourceViewer sourceViewer) { + if (fDocumentPartitioning != null) { return fDocumentPartitioning; - return super.getConfiguredDocumentPartitioning( sourceViewer ); + } + return super.getConfiguredDocumentPartitioning(sourceViewer); } - public ITextDoubleClickStrategy getDoubleClickStrategy( ISourceViewer sourceViewer, String contentType ) - { + public ITextDoubleClickStrategy getDoubleClickStrategy(ISourceViewer sourceViewer, String contentType) { /* - * FIX: bug#115 Nicolas F. Rouquette: Problems with the DrGarbage - * plugins with the DLTK 1.0.0M4 build (Galileo) + * FIX: bug#115 Nicolas F. Rouquette: Problems with the DrGarbage plugins with + * the DLTK 1.0.0M4 build (Galileo) */ // if (IJavaPartitions.JAVA_DOC.equals(contentType)) // return new JavadocDoubleClickStrategy(); - if ( IJavaPartitions.JAVA_MULTI_LINE_COMMENT.equals( contentType ) - || IJavaPartitions.JAVA_SINGLE_LINE_COMMENT.equals( contentType ) ) - return new DefaultTextDoubleClickStrategy( ); + if (IJavaPartitions.JAVA_MULTI_LINE_COMMENT.equals(contentType) + || IJavaPartitions.JAVA_SINGLE_LINE_COMMENT.equals(contentType)) + return new DefaultTextDoubleClickStrategy(); // else if (IJavaPartitions.JAVA_STRING.equals(contentType) || // IJavaPartitions.JAVA_CHARACTER.equals(contentType)) // return new // JavaStringDoubleClickSelector(getConfiguredDocumentPartitioning(sourceViewer)); - if ( fJavaDoubleClickSelector == null ) - { - fJavaDoubleClickSelector = new JavaDoubleClickSelector( ); - fJavaDoubleClickSelector.setSourceVersion( fPreferenceStore.getString( JavaCore.COMPILER_SOURCE ) ); + if (fJavaDoubleClickSelector == null) { + fJavaDoubleClickSelector = new JavaDoubleClickSelector(); + String sourceVersion = fPreferenceStore.getString(JavaCore.COMPILER_SOURCE); + // JavaDoubleClickSelector.setSourceVersion(String) is only available on Eclipse + // versions prior to Eclipse 2025-06 + ReflectionUtils.invokeMethod(JavaDoubleClickSelector.class, "setSourceVersion", + new Class[] { String.class }, new Object[] { sourceVersion }); } return fJavaDoubleClickSelector; } @@ -223,11 +207,8 @@ public ITextDoubleClickStrategy getDoubleClickStrategy( ISourceViewer sourceView * * @since 3.1 */ - public IHyperlinkDetector[] getHyperlinkDetectors( ISourceViewer sourceViewer ) - { - return new IHyperlinkDetector[]{ - new ClassFileHyperlinkDetector( ), new URLHyperlinkDetector( ) - }; + public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) { + return new IHyperlinkDetector[] { new ClassFileHyperlinkDetector(), new URLHyperlinkDetector() }; } /** @@ -236,43 +217,41 @@ public IHyperlinkDetector[] getHyperlinkDetectors( ISourceViewer sourceViewer ) * @return the Java multi-line comment scanner * @since 2.0 */ - protected RuleBasedScanner getMultilineCommentScanner( ) - { + protected RuleBasedScanner getMultilineCommentScanner() { return fMultilineCommentScanner; } /* * @see SourceViewerConfiguration#getPresentationReconciler(ISourceViewer) */ - public IPresentationReconciler getPresentationReconciler( ISourceViewer sourceViewer ) - { + public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) { - PresentationReconciler reconciler = new JavaPresentationReconciler( ); - reconciler.setDocumentPartitioning( getConfiguredDocumentPartitioning( sourceViewer ) ); + PresentationReconciler reconciler = new JavaPresentationReconciler(); + reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer)); - DefaultDamagerRepairer dr = new DefaultDamagerRepairer( getCodeScanner( ) ); - reconciler.setDamager( dr, IDocument.DEFAULT_CONTENT_TYPE ); - reconciler.setRepairer( dr, IDocument.DEFAULT_CONTENT_TYPE ); + DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getCodeScanner()); + reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE); + reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE); - dr = new DefaultDamagerRepairer( getMultilineCommentScanner( ) ); - reconciler.setDamager( dr, IJavaPartitions.JAVA_MULTI_LINE_COMMENT ); - reconciler.setRepairer( dr, IJavaPartitions.JAVA_MULTI_LINE_COMMENT ); + dr = new DefaultDamagerRepairer(getMultilineCommentScanner()); + reconciler.setDamager(dr, IJavaPartitions.JAVA_MULTI_LINE_COMMENT); + reconciler.setRepairer(dr, IJavaPartitions.JAVA_MULTI_LINE_COMMENT); - dr = new DefaultDamagerRepairer( getSinglelineCommentScanner( ) ); - reconciler.setDamager( dr, IJavaPartitions.JAVA_SINGLE_LINE_COMMENT ); - reconciler.setRepairer( dr, IJavaPartitions.JAVA_SINGLE_LINE_COMMENT ); + dr = new DefaultDamagerRepairer(getSinglelineCommentScanner()); + reconciler.setDamager(dr, IJavaPartitions.JAVA_SINGLE_LINE_COMMENT); + reconciler.setRepairer(dr, IJavaPartitions.JAVA_SINGLE_LINE_COMMENT); - dr = new DefaultDamagerRepairer( getStringScanner( ) ); - reconciler.setDamager( dr, IJavaPartitions.JAVA_STRING ); - reconciler.setRepairer( dr, IJavaPartitions.JAVA_STRING ); + dr = new DefaultDamagerRepairer(getStringScanner()); + reconciler.setDamager(dr, IJavaPartitions.JAVA_STRING); + reconciler.setRepairer(dr, IJavaPartitions.JAVA_STRING); - dr = new DefaultDamagerRepairer( getStringScanner( ) ); - reconciler.setDamager( dr, IJavaPartitions.JAVA_CHARACTER ); - reconciler.setRepairer( dr, IJavaPartitions.JAVA_CHARACTER ); + dr = new DefaultDamagerRepairer(getStringScanner()); + reconciler.setDamager(dr, IJavaPartitions.JAVA_CHARACTER); + reconciler.setRepairer(dr, IJavaPartitions.JAVA_CHARACTER); - dr = new DefaultDamagerRepairer( getStringScanner( ) ); - reconciler.setDamager( dr, IJavaPartitions.JAVA_DOC ); - reconciler.setRepairer( dr, IJavaPartitions.JAVA_DOC ); + dr = new DefaultDamagerRepairer(getStringScanner()); + reconciler.setDamager(dr, IJavaPartitions.JAVA_DOC); + reconciler.setRepairer(dr, IJavaPartitions.JAVA_DOC); return reconciler; } @@ -283,8 +262,7 @@ public IPresentationReconciler getPresentationReconciler( ISourceViewer sourceVi * @return the Java single-line comment scanner * @since 2.0 */ - protected RuleBasedScanner getSinglelineCommentScanner( ) - { + protected RuleBasedScanner getSinglelineCommentScanner() { return fSinglelineCommentScanner; } @@ -294,8 +272,7 @@ protected RuleBasedScanner getSinglelineCommentScanner( ) * @return the Java string scanner * @since 2.0 */ - protected RuleBasedScanner getStringScanner( ) - { + protected RuleBasedScanner getStringScanner() { return fStringScanner; } @@ -303,45 +280,38 @@ protected RuleBasedScanner getStringScanner( ) * Initializes the scanners. * */ - private void initializeScanners( ) - { - fCodeScanner = new RenderedBytecodeScanner( getColorManager( ), fPreferenceStore ); - fMultilineCommentScanner = new JavaCommentScanner( getColorManager( ), - fPreferenceStore, - IJavaColorConstants.JAVA_MULTI_LINE_COMMENT ); - fSinglelineCommentScanner = new JavaCommentScanner( getColorManager( ), - fPreferenceStore, - IJavaColorConstants.JAVA_SINGLE_LINE_COMMENT ); - fStringScanner = new SingleTokenJavaScanner( getColorManager( ), - fPreferenceStore, - IJavaColorConstants.JAVA_STRING ); + private void initializeScanners() { + fCodeScanner = new RenderedBytecodeScanner(getColorManager(), fPreferenceStore); + fMultilineCommentScanner = new JavaCommentScanner(getColorManager(), fPreferenceStore, + IJavaColorConstants.JAVA_MULTI_LINE_COMMENT); + fSinglelineCommentScanner = new JavaCommentScanner(getColorManager(), fPreferenceStore, + IJavaColorConstants.JAVA_SINGLE_LINE_COMMENT); + fStringScanner = new SingleTokenJavaScanner(getColorManager(), fPreferenceStore, + IJavaColorConstants.JAVA_STRING); } /** - * Adapts the behavior of the contained components to the change encoded in - * the given event. + * Adapts the behavior of the contained components to the change encoded in the + * given event. */ - public void adaptToPreferenceChange( PropertyChangeEvent event ) - { - if ( fCodeScanner.affectsBehavior( event ) ) - fCodeScanner.adaptToPreferenceChange( event ); - if ( fMultilineCommentScanner.affectsBehavior( event ) ) - fMultilineCommentScanner.adaptToPreferenceChange( event ); - if ( fSinglelineCommentScanner.affectsBehavior( event ) ) - fSinglelineCommentScanner.adaptToPreferenceChange( event ); - if ( fStringScanner.affectsBehavior( event ) ) - fStringScanner.adaptToPreferenceChange( event ); + public void adaptToPreferenceChange(PropertyChangeEvent event) { + if (fCodeScanner.affectsBehavior(event)) + fCodeScanner.adaptToPreferenceChange(event); + if (fMultilineCommentScanner.affectsBehavior(event)) + fMultilineCommentScanner.adaptToPreferenceChange(event); + if (fSinglelineCommentScanner.affectsBehavior(event)) + fSinglelineCommentScanner.adaptToPreferenceChange(event); + if (fStringScanner.affectsBehavior(event)) + fStringScanner.adaptToPreferenceChange(event); } /* * (non-Javadoc) * - * @see - * org.eclipse.ui.editors.text.TextSourceViewerConfiguration#getReconciler( + * @see org.eclipse.ui.editors.text.TextSourceViewerConfiguration#getReconciler( * org.eclipse.jface.text.source.ISourceViewer) */ - public IReconciler getReconciler( ISourceViewer sourceViewer ) - { + public IReconciler getReconciler(ISourceViewer sourceViewer) { /* overwrite the implementation to deactivate spelling check */ return null; } @@ -349,73 +319,54 @@ public IReconciler getReconciler( ISourceViewer sourceViewer ) /** * HyperLink Detector for BYtecode Visualizer Documnts. */ - class ClassFileHyperlinkDetector implements IHyperlinkDetector - { + class ClassFileHyperlinkDetector implements IHyperlinkDetector { /* * (non-Javadoc) * - * @see - * org.eclipse.jface.text.hyperlink.IHyperlinkDetector#detectHyperlinks( - * org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion, - * boolean) + * @see org.eclipse.jface.text.hyperlink.IHyperlinkDetector#detectHyperlinks( + * org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion, boolean) */ - public IHyperlink[] detectHyperlinks( ITextViewer textViewer, IRegion region, - boolean canShowMultipleHyperlinks ) - { + public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, + boolean canShowMultipleHyperlinks) { - IDocument document = fTextEditor.getDocumentProvider( ).getDocument( fTextEditor.getEditorInput( ) ); + IDocument document = fTextEditor.getDocumentProvider().getDocument(fTextEditor.getEditorInput()); IRegion lineInfo = null; String lineText = null; int lineNumber = -1; - try - { - lineInfo = document.getLineInformationOfOffset( region.getOffset( ) ); - lineText = document.get( lineInfo.getOffset( ), lineInfo.getLength( ) ); - lineNumber = document.getLineOfOffset( region.getOffset( ) ); - } - catch ( BadLocationException ex ) - { + try { + lineInfo = document.getLineInformationOfOffset(region.getOffset()); + lineText = document.get(lineInfo.getOffset(), lineInfo.getLength()); + lineNumber = document.getLineOfOffset(region.getOffset()); + } catch (BadLocationException ex) { return null; } - if ( lineText.contains( "goto" ) || lineText.contains( "if" ) ) //$NON-NLS-1$ //$NON-NLS-2$ + if (lineText.contains("goto") || lineText.contains("if")) //$NON-NLS-1$ //$NON-NLS-2$ { /* - * mark a complete instruction as hyperlink "12 goto 23;" ->goto - * 23 + * mark a complete instruction as hyperlink "12 goto 23;" ->goto 23 */ - int begin = lineText.indexOf( " ", 7 ); //$NON-NLS-1$ - int end = lineText.indexOf( ";" ); //$NON-NLS-1$ - if ( end < 0 - || begin < 0 - || end == begin + 1 - || region.getOffset( ) < lineInfo.getOffset( ) + begin + 1 ) + int begin = lineText.indexOf(" ", 7); //$NON-NLS-1$ + int end = lineText.indexOf(";"); //$NON-NLS-1$ + if (end < 0 || begin < 0 || end == begin + 1 || region.getOffset() < lineInfo.getOffset() + begin + 1) return null; - String linkText = lineText.substring( begin + 1, end ); + String linkText = lineText.substring(begin + 1, end); - IRegion r2 = new Region( lineInfo.getOffset( ) + begin + 1, linkText.length( ) ); - return new IHyperlink[]{ - new ClassFileLocalHyperLink( r2, linkText, lineNumber ) - }; - } - else if ( lineText.contains( "/* ." ) ) //$NON-NLS-1$ + IRegion r2 = new Region(lineInfo.getOffset() + begin + 1, linkText.length()); + return new IHyperlink[] { new ClassFileLocalHyperLink(r2, linkText, lineNumber) }; + } else if (lineText.contains("/* .")) //$NON-NLS-1$ { - int begin = lineText.indexOf( "/* ." ) + 2; //$NON-NLS-1$ - int end = lineText.indexOf( "*/" ) - 1; //$NON-NLS-1$ - if ( end < 0 - || begin < 0 - || end == begin + 1 - || region.getOffset( ) < lineInfo.getOffset( ) + begin + 1 ) + int begin = lineText.indexOf("/* .") + 2; //$NON-NLS-1$ + int end = lineText.indexOf("*/") - 1; //$NON-NLS-1$ + if (end < 0 || begin < 0 || end == begin + 1 || region.getOffset() < lineInfo.getOffset() + begin + 1) return null; - String linkText = lineText.substring( begin + 2, end ); + String linkText = lineText.substring(begin + 2, end); - IRegion r2 = new Region( lineInfo.getOffset( ) + begin + 1, linkText.length( ) ); - return new IHyperlink[]{ - new ClassFileFieldLocalHyperLink( r2, linkText, lineNumber ) - }; + IRegion r2 = new Region(lineInfo.getOffset() + begin + 1, linkText.length()); + return new IHyperlink[] { new ClassFileFieldLocalHyperLink(r2, linkText, lineNumber) }; } // else{ @@ -441,8 +392,7 @@ else if ( lineText.contains( "/* ." ) ) //$NON-NLS-1$ /** * Local Hyperlink class for bytecode visualizer document. */ - class ClassFileLocalHyperLink implements IHyperlink - { + class ClassFileLocalHyperLink implements IHyperlink { /** * LInk region. @@ -466,9 +416,8 @@ class ClassFileLocalHyperLink implements IHyperlink * @param text * @param lineNumber */ - public ClassFileLocalHyperLink( IRegion region, String text, int lineNumber ) - { - super( ); + public ClassFileLocalHyperLink(IRegion region, String text, int lineNumber) { + super(); this.region = region; this.text = text; this.lineNumber = lineNumber; @@ -479,8 +428,7 @@ public ClassFileLocalHyperLink( IRegion region, String text, int lineNumber ) * * @see org.eclipse.jface.text.hyperlink.IHyperlink#getHyperlinkRegion() */ - public IRegion getHyperlinkRegion( ) - { + public IRegion getHyperlinkRegion() { return region; } @@ -489,8 +437,7 @@ public IRegion getHyperlinkRegion( ) * * @see org.eclipse.jface.text.hyperlink.IHyperlink#getHyperlinkText() */ - public String getHyperlinkText( ) - { + public String getHyperlinkText() { return text; } @@ -499,8 +446,7 @@ public String getHyperlinkText( ) * * @see org.eclipse.jface.text.hyperlink.IHyperlink#getTypeLabel() */ - public String getTypeLabel( ) - { + public String getTypeLabel() { return null; } @@ -509,24 +455,20 @@ public String getTypeLabel( ) * * @see org.eclipse.jface.text.hyperlink.IHyperlink#open() */ - public void open( ) - { + public void open() { - DisassemblerDocumentProvider bdp = (DisassemblerDocumentProvider) fTextEditor.getDocumentProvider( ); - IMethodSection method = bdp.getClassFileDocument( ).findMethodSection( lineNumber ); - List instructions = method.getInstructionLines( ); + DisassemblerDocumentProvider bdp = (DisassemblerDocumentProvider) fTextEditor.getDocumentProvider(); + IMethodSection method = bdp.getClassFileDocument().findMethodSection(lineNumber); + List instructions = method.getInstructionLines(); /* find selected instruction */ int targetOffset = ByteCodeConstants.INVALID_OFFSET; - for ( IInstructionLine i : instructions ) - { - if ( i.getLine( ) == lineNumber ) - { - if ( i.getInstruction( ) instanceof BranchInstruction ) - { - BranchInstruction bi = (BranchInstruction) i.getInstruction( ); + for (IInstructionLine i : instructions) { + if (i.getLine() == lineNumber) { + if (i.getInstruction() instanceof BranchInstruction) { + BranchInstruction bi = (BranchInstruction) i.getInstruction(); - targetOffset = bi.getBranchOffset( ) + bi.getOffset( ); + targetOffset = bi.getBranchOffset() + bi.getOffset(); break; } @@ -535,24 +477,18 @@ public void open( ) } /* find target instruction */ - for ( IInstructionLine i : instructions ) - { - if ( i.getInstruction( ).getOffset( ) == targetOffset ) - { - IDocument document = fTextEditor.getDocumentProvider( ) - .getDocument( fTextEditor.getEditorInput( ) ); + for (IInstructionLine i : instructions) { + if (i.getInstruction().getOffset() == targetOffset) { + IDocument document = fTextEditor.getDocumentProvider().getDocument(fTextEditor.getEditorInput()); int destOffset, destLength; - try - { - destOffset = document.getLineOffset( i.getLine( ) ); - destLength = document.getLineLength( i.getLine( ) ); - } - catch ( BadLocationException e ) - { + try { + destOffset = document.getLineOffset(i.getLine()); + destLength = document.getLineLength(i.getLine()); + } catch (BadLocationException e) { return; } - fTextEditor.selectAndReveal( destOffset, destLength - 1 ); + fTextEditor.selectAndReveal(destOffset, destLength - 1); break; } } @@ -562,11 +498,10 @@ public void open( ) } /** - * Local Hyperlink class for bytecode visualizer document. The field within - * a class file document is assigned to the link. + * Local Hyperlink class for bytecode visualizer document. The field within a + * class file document is assigned to the link. */ - class ClassFileFieldLocalHyperLink implements IHyperlink - { + class ClassFileFieldLocalHyperLink implements IHyperlink { /** * LInk region. @@ -584,9 +519,8 @@ class ClassFileFieldLocalHyperLink implements IHyperlink @SuppressWarnings("unused") private int lineNumber; - public ClassFileFieldLocalHyperLink( IRegion region, String text, int lineNumber ) - { - super( ); + public ClassFileFieldLocalHyperLink(IRegion region, String text, int lineNumber) { + super(); this.region = region; this.text = text; this.lineNumber = lineNumber; @@ -597,8 +531,7 @@ public ClassFileFieldLocalHyperLink( IRegion region, String text, int lineNumber * * @see org.eclipse.jface.text.hyperlink.IHyperlink#getHyperlinkRegion() */ - public IRegion getHyperlinkRegion( ) - { + public IRegion getHyperlinkRegion() { return region; } @@ -607,8 +540,7 @@ public IRegion getHyperlinkRegion( ) * * @see org.eclipse.jface.text.hyperlink.IHyperlink#getHyperlinkText() */ - public String getHyperlinkText( ) - { + public String getHyperlinkText() { return text; } @@ -617,8 +549,7 @@ public String getHyperlinkText( ) * * @see org.eclipse.jface.text.hyperlink.IHyperlink#getTypeLabel() */ - public String getTypeLabel( ) - { + public String getTypeLabel() { return null; } @@ -627,39 +558,34 @@ public String getTypeLabel( ) * * @see org.eclipse.jface.text.hyperlink.IHyperlink#open() */ - public void open( ) - { + public void open() { - DisassemblerDocumentProvider bdp = (DisassemblerDocumentProvider) fTextEditor.getDocumentProvider( ); - IFieldSection field = bdp.getClassFileDocument( ).findFieldSection( text ); + DisassemblerDocumentProvider bdp = (DisassemblerDocumentProvider) fTextEditor.getDocumentProvider(); + IFieldSection field = bdp.getClassFileDocument().findFieldSection(text); - IDocument document = fTextEditor.getDocumentProvider( ).getDocument( fTextEditor.getEditorInput( ) ); + IDocument document = fTextEditor.getDocumentProvider().getDocument(fTextEditor.getEditorInput()); - int destOffset, destLength, elementIndex, elementLength;; + int destOffset, destLength, elementIndex, elementLength; - try - { - destOffset = document.getLineOffset( field.getBytecodeDocumentLine( ) ); - destLength = document.getLineLength( field.getBytecodeDocumentLine( ) ); + try { + destOffset = document.getLineOffset(field.getBytecodeDocumentLine()); + destLength = document.getLineLength(field.getBytecodeDocumentLine()); - String lineString = document.get( destOffset, destLength ); - elementIndex = lineString.indexOf( " " + text + ";" ) + 1; //$NON-NLS-1$ //$NON-NLS-2$ - elementLength = text.length( ); + String lineString = document.get(destOffset, destLength); + elementIndex = lineString.indexOf(" " + text + ";") + 1; //$NON-NLS-1$ //$NON-NLS-2$ + elementLength = text.length(); - } - catch ( BadLocationException e ) - { + } catch (BadLocationException e) { return; } - fTextEditor.selectAndReveal( destOffset + elementIndex, elementLength ); + fTextEditor.selectAndReveal(destOffset + elementIndex, elementLength); } } - protected Map getHyperlinkDetectorTargets( ISourceViewer sourceViewer ) - { - Map targets = super.getHyperlinkDetectorTargets( sourceViewer ); - targets.put( "org.eclipse.jdt.ui.javaCode", fTextEditor ); //$NON-NLS-1$ + protected Map getHyperlinkDetectorTargets(ISourceViewer sourceViewer) { + Map targets = super.getHyperlinkDetectorTargets(sourceViewer); + targets.put("org.eclipse.jdt.ui.javaCode", fTextEditor); //$NON-NLS-1$ return targets; } } \ No newline at end of file diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/DisassemblerDocument.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/DisassemblerDocument.java index 3f13e634..61f4dab9 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/DisassemblerDocument.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/DisassemblerDocument.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0.html * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -32,27 +32,22 @@ * @version $Revision: 203 $ $Id: BytecodeDocument.java 203 2013-06-07 09:27:41Z * salekseev $ */ -public class DisassemblerDocument extends Document -{ +public class DisassemblerDocument extends Document { private DisassemblerDocumentProvider documentProvider; private JavaDecompilerClassFileEditor editor; - - public JavaDecompilerClassFileEditor getEditor( ) - { + public JavaDecompilerClassFileEditor getEditor() { return editor; } - public DisassemblerDocument( DisassemblerDocumentProvider documentProvider, JavaDecompilerClassFileEditor editor ) - { - super( ); + public DisassemblerDocument(DisassemblerDocumentProvider documentProvider, JavaDecompilerClassFileEditor editor) { + super(); this.documentProvider = documentProvider; this.editor = editor; } - public DisassemblerDocumentProvider getDocumentProvider( ) - { + public DisassemblerDocumentProvider getDocumentProvider() { return documentProvider; } @@ -61,46 +56,37 @@ public DisassemblerDocumentProvider getDocumentProvider( ) * * @see org.eclipse.jface.text.IDocument#getLineInformation(int) */ - public IRegion getLineInformation( int line ) throws BadLocationException - { + public IRegion getLineInformation(int line) throws BadLocationException { /* to avoid BadLocation exception */ - if ( line < 0 ) - { - return new Region( 0, 0 ); + if (line < 0) { + return new Region(0, 0); } - if ( invokedFromJavaStackTraceHyperlink( 3 ) ) - { + if (invokedFromJavaStackTraceHyperlink(3)) { /* lookup line number table */ - IClassFileDocument doc = documentProvider.getClassFileDocument( ); - if ( doc != null ) - { - IInstructionLine il = doc.findInstructionLine( line ); - if ( il != null ) - { - IRegion result = getTracker( ).getLineInformation( il.getLine( ) ); + IClassFileDocument doc = documentProvider.getClassFileDocument(); + if (doc != null) { + IInstructionLine il = doc.findInstructionLine(line); + if (il != null) { + IRegion result = getTracker().getLineInformation(il.getLine()); return result; } } - } - else - { + } else { /* default handling */ - return getTracker( ).getLineInformation( line ); + return getTracker().getLineInformation(line); } - return new Region( 0, 0 ); + return new Region(0, 0); } - private boolean invokedFromJavaStackTraceHyperlink( int position ) - { - Thread thread = Thread.currentThread( ); + private boolean invokedFromJavaStackTraceHyperlink(int position) { + Thread thread = Thread.currentThread(); - StackTraceElement[] elements = thread.getStackTrace( ); - if ( elements != null && elements.length > position ) - { - return JavaStackTraceHyperlink.class.getName( ).equals( elements[position].getClassName( ) ); + StackTraceElement[] elements = thread.getStackTrace(); + if (elements != null && elements.length > position) { + return JavaStackTraceHyperlink.class.getName().equals(elements[position].getClassName()); } return false; diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/DisassemblerDocumentProvider.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/DisassemblerDocumentProvider.java index 9167e396..5ce4d598 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/DisassemblerDocumentProvider.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/DisassemblerDocumentProvider.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0.html * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -18,7 +18,6 @@ import java.io.BufferedInputStream; import java.io.DataInputStream; -import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Iterator; @@ -39,8 +38,7 @@ import com.drgarbage.asm.render.intf.IClassFileDocument; import com.drgarbage.asm.render.intf.IDocumentUpdateListener; -public class DisassemblerDocumentProvider extends FileDocumentProvider -{ +public class DisassemblerDocumentProvider extends FileDocumentProvider { /** * Reference to the class file document object. @@ -53,33 +51,18 @@ public class DisassemblerDocumentProvider extends FileDocumentProvider private IJavaElement classFileOutlineElement; /** - * List of the document update listeners. - * BytecodeDocumentProvider fires on each update of this - * document an event for all registered listeners. + * List of the document update listeners. BytecodeDocumentProvider + * fires on each update of this document an event for all registered listeners. */ private ArrayList documentUpdateListeners; - private String mark; - private IDocument document; - public String getMark( ) - { - return mark; - } - /** * Constructor. - * - * @param mark - * - * @param part - * bytecode editor */ - public DisassemblerDocumentProvider( String mark ) - { - super( ); - this.mark = mark; + public DisassemblerDocumentProvider() { + super(); } /** @@ -87,8 +70,7 @@ public DisassemblerDocumentProvider( String mark ) * * @return the classfile OutlineElement */ - public IJavaElement getClassFileOutlineElement( ) - { + public IJavaElement getClassFileOutlineElement() { return classFileOutlineElement; } @@ -97,26 +79,22 @@ public IJavaElement getClassFileOutlineElement( ) * * @return the class file document */ - public IClassFileDocument getClassFileDocument( ) - { + public IClassFileDocument getClassFileDocument() { return classFileDocument; } /** - * Adds listener to the list that will be fired on each update - * of this document. + * Adds listener to the list that will be fired on each update of + * this document. * * @param listener */ - public void addDocumentUpdateListener( IDocumentUpdateListener listener ) - { - if ( listener != null ) - { - if ( documentUpdateListeners == null ) - { - documentUpdateListeners = new ArrayList( ); + public void addDocumentUpdateListener(IDocumentUpdateListener listener) { + if (listener != null) { + if (documentUpdateListeners == null) { + documentUpdateListeners = new ArrayList(); } - documentUpdateListeners.add( listener ); + documentUpdateListeners.add(listener); } } @@ -125,17 +103,13 @@ public void addDocumentUpdateListener( IDocumentUpdateListener listener ) * * @param listener */ - public void removeDocumentUpdateListener( IDocumentUpdateListener listener ) - { - if ( listener != null && documentUpdateListeners != null ) - { - Iterator it = documentUpdateListeners.iterator( ); - while ( it.hasNext( ) ) - { - IDocumentUpdateListener l = it.next( ); - if ( l == listener ) - { - it.remove( ); + public void removeDocumentUpdateListener(IDocumentUpdateListener listener) { + if (listener != null && documentUpdateListeners != null) { + Iterator it = documentUpdateListeners.iterator(); + while (it.hasNext()) { + IDocumentUpdateListener l = it.next(); + if (l == listener) { + it.remove(); } } } @@ -144,18 +118,15 @@ public void removeDocumentUpdateListener( IDocumentUpdateListener listener ) /* * (non-Javadoc) * - * @see - * org.eclipse.ui.editors.text.StorageDocumentProvider#createDocument(java. + * @see org.eclipse.ui.editors.text.StorageDocumentProvider#createDocument(java. * lang.Object) */ - protected IDocument createDocument( Object element ) throws CoreException - { - IDocument document = super.createDocument( element ); + protected IDocument createDocument(Object element) throws CoreException { + IDocument document = super.createDocument(element); - if ( document != null ) - { - JavaTextTools tools = JavaPlugin.getDefault( ).getJavaTextTools( ); - tools.setupJavaDocumentPartitioner( document, IJavaPartitions.JAVA_PARTITIONING ); + if (document != null) { + JavaTextTools tools = JavaPlugin.getDefault().getJavaTextTools(); + tools.setupJavaDocumentPartitioner(document, IJavaPartitions.JAVA_PARTITIONING); } return document; } @@ -166,71 +137,46 @@ protected IDocument createDocument( Object element ) throws CoreException * @see * org.eclipse.ui.editors.text.StorageDocumentProvider#createEmptyDocument() */ - protected IDocument createEmptyDocument( ) - { - return new DisassemblerDocument( this, UIUtil.getActiveDecompilerEditor( ) ); + protected IDocument createEmptyDocument() { + return new DisassemblerDocument(this, UIUtil.getActiveDecompilerEditor()); } /* * (non-Javadoc) * - * @see - * org.eclipse.ui.editors.text.StorageDocumentProvider#setDocumentContent( + * @see org.eclipse.ui.editors.text.StorageDocumentProvider#setDocumentContent( * org.eclipse.jface.text.IDocument, java.io.InputStream, java.lang.String) */ - protected void setDocumentContent( IDocument document, InputStream contentStream, String encoding ) - throws CoreException - { - DataInputStream in = null; - try - { - /* buffer only if necessary */ - if ( contentStream instanceof BufferedInputStream ) - { - in = new DataInputStream( contentStream ); - } - else - { - in = new DataInputStream( new BufferedInputStream( contentStream ) ); - } - ClassFileOutlineElement outlineElement = new ClassFileOutlineElement( ); - ClassFileDocument doc = new ClassFileDocument( outlineElement ); - outlineElement.setClassFileDocument( doc ); - ClassReader cr = new ClassReader( in, doc ); - cr.accept( doc, 0 ); + protected void setDocumentContent(IDocument document, InputStream contentStream, String encoding) + throws CoreException { + /* buffer only if necessary */ + if (!(contentStream instanceof BufferedInputStream)) { + contentStream = new BufferedInputStream(contentStream); + } + try (DataInputStream in = new DataInputStream(contentStream)) { + ClassFileOutlineElement outlineElement = new ClassFileOutlineElement(); + ClassFileDocument doc = new ClassFileDocument(outlineElement); + outlineElement.setClassFileDocument(doc); + // Known problem: The used library supports only up to Java 8 (class file + // version 52) + ClassReader cr = new ClassReader(in, doc); + cr.accept(doc, 0); - document.set( mark + "\n\n" + doc.toString( ) ); //$NON-NLS-1$ + document.set(doc.toString()); // $NON-NLS-1$ classFileDocument = doc; classFileOutlineElement = outlineElement; - } - catch ( Exception e ) - { - Logger.debug( e ); - } - finally - { - if ( in != null ) - { - try - { - in.close( ); - } - catch ( IOException e ) - { - } - } + } catch (Exception e) { + Logger.debug(e); } /* fire update document events */ - if ( documentUpdateListeners != null ) - { - Iterator it = documentUpdateListeners.iterator( ); - while ( it.hasNext( ) ) - { - IDocumentUpdateListener l = it.next( ); - l.documentUpdated( classFileDocument ); + if (documentUpdateListeners != null) { + Iterator it = documentUpdateListeners.iterator(); + while (it.hasNext()) { + IDocumentUpdateListener l = it.next(); + l.documentUpdated(classFileDocument); } } } @@ -238,13 +184,11 @@ protected void setDocumentContent( IDocument document, InputStream contentStream /* * (non-Javadoc) * - * @see - * org.eclipse.ui.editors.text.FileDocumentProvider#isModifiable(java.lang. + * @see org.eclipse.ui.editors.text.FileDocumentProvider#isModifiable(java.lang. * Object) */ @Override - public boolean isModifiable( Object element ) - { + public boolean isModifiable(Object element) { return false; } @@ -256,13 +200,11 @@ public boolean isModifiable( Object element ) * Object) */ @Override - public IDocument getDocument( Object element ) - { + public IDocument getDocument(Object element) { return this.document; } - public void setDocument( IDocument document ) - { + public void setDocument(IDocument document) { this.document = document; } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/DisassemblerJavadocHover.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/DisassemblerJavadocHover.java index 56e7caeb..50634062 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/DisassemblerJavadocHover.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/DisassemblerJavadocHover.java @@ -25,266 +25,191 @@ import com.drgarbage.bytecode.ByteCodeConstants; import com.drgarbage.utils.ClassFileDocumentsUtils; -public class DisassemblerJavadocHover extends JavadocHover implements IJavaEditorTextHover -{ - - public Object getHoverInfo2( ITextViewer textViewer, IRegion hoverRegion ) - { - try - { - if ( textViewer.getDocument( ) instanceof DisassemblerDocument ) - { - DisassemblerDocument bytecodeDocument = (DisassemblerDocument) textViewer.getDocument( ); - String text = textViewer.getDocument( ).get( hoverRegion.getOffset( ), hoverRegion.getLength( ) ); - - for ( int i = 0; i < ByteCodeConstants.OPCODE_MNEMONICS.length; i++ ) - { - if ( text.equals( ByteCodeConstants.OPCODE_MNEMONICS[i] ) ) - { - StringBuilder sb = HelpUtils.getOpcodeHelpFor( i ); - if ( sb.length( ) > 0 ) - { +public class DisassemblerJavadocHover extends JavadocHover implements IJavaEditorTextHover { + + public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) { + try { + if (textViewer.getDocument() instanceof DisassemblerDocument) { + DisassemblerDocument bytecodeDocument = (DisassemblerDocument) textViewer.getDocument(); + String text = textViewer.getDocument().get(hoverRegion.getOffset(), hoverRegion.getLength()); + + for (int i = 0; i < ByteCodeConstants.OPCODE_MNEMONICS.length; i++) { + if (text.equals(ByteCodeConstants.OPCODE_MNEMONICS[i])) { + StringBuilder sb = HelpUtils.getOpcodeHelpFor(i); + if (sb.length() > 0) { JavadocBrowserInformationControlInput input = new JavadocBrowserInformationControlInput( - null, - null, - sb.toString( ), - 0 ); + null, null, sb.toString(), 0); return input; } } } - if ( text.indexOf( "$" ) != -1 ) //$NON-NLS-1$ + if (text.indexOf("$") != -1) //$NON-NLS-1$ { - text = text.substring( text.lastIndexOf( "$" ) + 1 ); //$NON-NLS-1$ + text = text.substring(text.lastIndexOf("$") + 1); //$NON-NLS-1$ } - int line = bytecodeDocument.getLineOfOffset( hoverRegion.getOffset( ) ); - DisassemblerDocumentProvider provider = bytecodeDocument.getDocumentProvider( ); - IClassFileDocument disassemblerClassDocument = provider.getClassFileDocument( ); - JavaDecompilerClassFileEditor editor = bytecodeDocument.getEditor( ); - ClassFile cf = (ClassFile) ( (IClassFileEditorInput) editor.getEditorInput( ) ).getClassFile( ); + int line = bytecodeDocument.getLineOfOffset(hoverRegion.getOffset()); + DisassemblerDocumentProvider provider = bytecodeDocument.getDocumentProvider(); + IClassFileDocument disassemblerClassDocument = provider.getClassFileDocument(); + JavaDecompilerClassFileEditor editor = bytecodeDocument.getEditor(); + ClassFile cf = (ClassFile) ((IClassFileEditorInput) editor.getEditorInput()).getClassFile(); int offset = -1; - if ( disassemblerClassDocument.isLineInMethod( line - 2 ) ) - { - IMethodSection method = disassemblerClassDocument.findMethodSection( line - 2 ); + if (disassemblerClassDocument.isLineInMethod(line - 2)) { + IMethodSection method = disassemblerClassDocument.findMethodSection(line - 2); - if ( method != null ) - { - IMethod m = ClassFileDocumentsUtils - .findMethod( cf.getType( ), method.getName( ), method.getDescriptor( ) ); - if ( m != null ) - { - ISourceRange range = m.getSourceRange( ); - if ( m.getJavadocRange( ) != null ) - { + if (method != null) { + IMethod m = ClassFileDocumentsUtils.findMethod(cf.getType(), method.getName(), + method.getDescriptor()); + if (m != null) { + ISourceRange range = m.getSourceRange(); + if (m.getJavadocRange() != null) { range = new SourceRange( - m.getJavadocRange( ).getOffset( ) + m.getJavadocRange( ).getLength( ), - range.getLength( ) - m.getJavadocRange( ).getLength( ) ); + m.getJavadocRange().getOffset() + m.getJavadocRange().getLength(), + range.getLength() - m.getJavadocRange().getLength()); } - if ( range != null && range.getOffset( ) != -1 ) - { - offset = m.getClassFile( ) - .getBuffer( ) - .getText( range.getOffset( ), range.getLength( ) ) - .indexOf( text ); - if ( offset != -1 ) - { - hoverRegion = new Region( range.getOffset( ) + offset, text.length( ) ); + if (range != null && range.getOffset() != -1) { + offset = m.getClassFile().getBuffer().getText(range.getOffset(), range.getLength()) + .indexOf(text); + if (offset != -1) { + hoverRegion = new Region(range.getOffset() + offset, text.length()); } } } } - } - else if ( disassemblerClassDocument.isLineInField( line - 2 ) ) - { - IFieldSection field = disassemblerClassDocument.findFieldSection( line - 2 ); - if ( field != null ) - { - IField f = cf.getType( ).getField( field.getName( ) ); - if ( f != null ) - { - ISourceRange range = f.getSourceRange( ); - if ( f.getJavadocRange( ) != null ) - { + } else if (disassemblerClassDocument.isLineInField(line - 2)) { + IFieldSection field = disassemblerClassDocument.findFieldSection(line - 2); + if (field != null) { + IField f = cf.getType().getField(field.getName()); + if (f != null) { + ISourceRange range = f.getSourceRange(); + if (f.getJavadocRange() != null) { range = new SourceRange( - f.getJavadocRange( ).getOffset( ) + f.getJavadocRange( ).getLength( ), - range.getLength( ) - f.getJavadocRange( ).getLength( ) ); + f.getJavadocRange().getOffset() + f.getJavadocRange().getLength(), + range.getLength() - f.getJavadocRange().getLength()); } - if ( range != null && range.getOffset( ) != -1 ) - { - offset = f.getClassFile( ) - .getBuffer( ) - .getText( range.getOffset( ), range.getLength( ) ) - .indexOf( text ); - if ( offset != -1 ) - { - hoverRegion = new Region( range.getOffset( ) + offset, text.length( ) ); + if (range != null && range.getOffset() != -1) { + offset = f.getClassFile().getBuffer().getText(range.getOffset(), range.getLength()) + .indexOf(text); + if (offset != -1) { + hoverRegion = new Region(range.getOffset() + offset, text.length()); } } - if ( offset == -1 ) - { - range = cf.getType( ).getSourceRange( ); - offset = cf.getType( ) - .getClassFile( ) - .getBuffer( ) - .getText( 0, range.getOffset( ) + range.getLength( ) ) - .indexOf( text ); - if ( offset != -1 ) - { - hoverRegion = new Region( offset, text.length( ) ); + if (offset == -1) { + range = cf.getType().getSourceRange(); + offset = cf.getType().getClassFile().getBuffer() + .getText(0, range.getOffset() + range.getLength()).indexOf(text); + if (offset != -1) { + hoverRegion = new Region(offset, text.length()); } } } } } - if ( offset == -1 ) - { - ISourceRange range = cf.getType( ).getSourceRange( ); - if ( range != null && range.getOffset( ) + range.getLength( ) > -1 ) - { - offset = cf.getType( ) - .getClassFile( ) - .getBuffer( ) - .getText( 0, range.getOffset( ) + range.getLength( ) ) - .indexOf( text ); - if ( offset != -1 ) - { - hoverRegion = new Region( offset, text.length( ) ); + if (offset == -1) { + ISourceRange range = cf.getType().getSourceRange(); + if (range != null && range.getOffset() + range.getLength() > -1) { + offset = cf.getType().getClassFile().getBuffer() + .getText(0, range.getOffset() + range.getLength()).indexOf(text); + if (offset != -1) { + hoverRegion = new Region(offset, text.length()); } } } - IJavaElement[] elements = getJavaElementsAt( textViewer, hoverRegion ); - if ( elements == null || elements.length == 0 ) - { + IJavaElement[] elements = getJavaElementsAt(textViewer, hoverRegion); + if (elements == null || elements.length == 0) { return null; } - return ReflectionUtils.invokeMethod( this, "getHoverInfo", new Class[]{ //$NON-NLS-1$ - IJavaElement[].class, - ITypeRoot.class, - IRegion.class, - JavadocBrowserInformationControlInput.class - }, new Object[]{ - elements, getEditorInputJavaElement( ), hoverRegion, null - } ); - } - else if ( textViewer.getDocument( ) instanceof ByteCodeDocument ) - { + // Method is directly accessible, no need to use reflection + return JavadocHover.getHoverInfo(elements, getEditorInputJavaElement(), hoverRegion, null); + /* + * return ReflectionUtils.invokeMethod(this, "getHoverInfo", new Class[] { + * //$NON-NLS-1$ IJavaElement[].class, ITypeRoot.class, IRegion.class, + * JavadocBrowserInformationControlInput.class }, new Object[] { elements, + * getEditorInputJavaElement(), hoverRegion, null }); + */ + } else if (textViewer.getDocument() instanceof ByteCodeDocument) { int offset = -1; - String text = textViewer.getDocument( ).get( hoverRegion.getOffset( ), hoverRegion.getLength( ) ); - ClassFile cf = (ClassFile) ( (IClassFileEditorInput) ( (ByteCodeDocument) textViewer.getDocument( ) ) - .getEditor( ) - .getEditorInput( ) ).getClassFile( ); - if ( hoverRegion.getOffset( ) > -1 ) - { - IJavaElement element = ( (ByteCodeDocument) textViewer.getDocument( ) ).getEditor( ) - .getJavaElement( textViewer.getDocument( ).get( ), hoverRegion.getOffset( ) ); - if ( element != null ) - { - if ( element instanceof IMethod ) - { + String text = textViewer.getDocument().get(hoverRegion.getOffset(), hoverRegion.getLength()); + ClassFile cf = (ClassFile) ((IClassFileEditorInput) ((ByteCodeDocument) textViewer.getDocument()) + .getEditor().getEditorInput()).getClassFile(); + if (hoverRegion.getOffset() > -1) { + IJavaElement element = ((ByteCodeDocument) textViewer.getDocument()).getEditor() + .getJavaElement(textViewer.getDocument().get(), hoverRegion.getOffset()); + if (element != null) { + if (element instanceof IMethod) { IMethod m = (IMethod) element; - if ( m.isConstructor( ) && "init".equals( text ) ) // $NON-NLS-1$ //$NON-NLS-1$ + if (m.isConstructor() && "init".equals(text)) // $NON-NLS-1$ //$NON-NLS-1$ { - text = cf.getTypeName( ); + text = cf.getTypeName(); } - ISourceRange range = m.getSourceRange( ); - if ( m.getJavadocRange( ) != null ) - { + ISourceRange range = m.getSourceRange(); + if (m.getJavadocRange() != null) { range = new SourceRange( - m.getJavadocRange( ).getOffset( ) + m.getJavadocRange( ).getLength( ), - range.getLength( ) - m.getJavadocRange( ).getLength( ) ); + m.getJavadocRange().getOffset() + m.getJavadocRange().getLength(), + range.getLength() - m.getJavadocRange().getLength()); } - if ( range != null && range.getOffset( ) != -1 ) - { - offset = m.getClassFile( ) - .getBuffer( ) - .getText( range.getOffset( ), range.getLength( ) ) - .indexOf( text ); - if ( offset != -1 ) - { - hoverRegion = new Region( range.getOffset( ) + offset, text.length( ) ); + if (range != null && range.getOffset() != -1) { + offset = m.getClassFile().getBuffer().getText(range.getOffset(), range.getLength()) + .indexOf(text); + if (offset != -1) { + hoverRegion = new Region(range.getOffset() + offset, text.length()); } } - } - else if ( element instanceof IField ) - { + } else if (element instanceof IField) { IField f = (IField) element; - ISourceRange range = f.getSourceRange( ); - if ( f.getJavadocRange( ) != null ) - { + ISourceRange range = f.getSourceRange(); + if (f.getJavadocRange() != null) { range = new SourceRange( - f.getJavadocRange( ).getOffset( ) + f.getJavadocRange( ).getLength( ), - range.getLength( ) - f.getJavadocRange( ).getLength( ) ); + f.getJavadocRange().getOffset() + f.getJavadocRange().getLength(), + range.getLength() - f.getJavadocRange().getLength()); } - if ( range != null && range.getOffset( ) != -1 ) - { - offset = f.getClassFile( ) - .getBuffer( ) - .getText( range.getOffset( ), range.getLength( ) ) - .indexOf( text ); - if ( offset != -1 ) - { - hoverRegion = new Region( range.getOffset( ) + offset, text.length( ) ); + if (range != null && range.getOffset() != -1) { + offset = f.getClassFile().getBuffer().getText(range.getOffset(), range.getLength()) + .indexOf(text); + if (offset != -1) { + hoverRegion = new Region(range.getOffset() + offset, text.length()); } } - if ( offset == -1 ) - { - range = cf.getType( ).getSourceRange( ); - offset = cf.getType( ) - .getClassFile( ) - .getBuffer( ) - .getText( 0, range.getOffset( ) + range.getLength( ) ) - .indexOf( text ); - if ( offset != -1 ) - { - hoverRegion = new Region( offset, text.length( ) ); + if (offset == -1) { + range = cf.getType().getSourceRange(); + offset = cf.getType().getClassFile().getBuffer() + .getText(0, range.getOffset() + range.getLength()).indexOf(text); + if (offset != -1) { + hoverRegion = new Region(offset, text.length()); } } } } - if ( offset == -1 ) - { - ISourceRange range = cf.getType( ).getSourceRange( ); - if ( range != null && range.getOffset( ) + range.getLength( ) > -1 ) - { - offset = cf.getType( ) - .getClassFile( ) - .getBuffer( ) - .getText( 0, range.getOffset( ) + range.getLength( ) ) - .indexOf( text ); - if ( offset != -1 ) - { - hoverRegion = new Region( offset, text.length( ) ); + if (offset == -1) { + ISourceRange range = cf.getType().getSourceRange(); + if (range != null && range.getOffset() + range.getLength() > -1) { + offset = cf.getType().getClassFile().getBuffer() + .getText(0, range.getOffset() + range.getLength()).indexOf(text); + if (offset != -1) { + hoverRegion = new Region(offset, text.length()); } } } - IJavaElement[] elements = getJavaElementsAt( textViewer, hoverRegion ); - if ( elements == null || elements.length == 0 ) - { + IJavaElement[] elements = getJavaElementsAt(textViewer, hoverRegion); + if (elements == null || elements.length == 0) { return null; } - return ReflectionUtils.invokeMethod( this, "getHoverInfo", new Class[]{ //$NON-NLS-1$ - IJavaElement[].class, - ITypeRoot.class, - IRegion.class, - JavadocBrowserInformationControlInput.class - }, new Object[]{ - elements, getEditorInputJavaElement( ), hoverRegion, null - } ); + return ReflectionUtils.invokeMethod(this, "getHoverInfo", new Class[] { //$NON-NLS-1$ + IJavaElement[].class, ITypeRoot.class, IRegion.class, + JavadocBrowserInformationControlInput.class }, + new Object[] { elements, getEditorInputJavaElement(), hoverRegion, null }); } } - } - catch ( Exception e ) - { - Logger.debug( e ); + } catch (Exception e) { + Logger.debug(e); } return null; 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 8fe6239c..9f42d647 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 @@ -37,10 +37,7 @@ import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITextSelection; -import org.eclipse.jface.text.Region; import org.eclipse.jface.text.TextSelection; -import org.eclipse.jface.text.hyperlink.IHyperlink; -import org.eclipse.jface.text.hyperlink.URLHyperlinkDetector; import org.eclipse.jface.text.source.CompositeRuler; import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jface.text.source.IVerticalRuler; @@ -54,7 +51,6 @@ import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.StyleRange; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeListener; @@ -73,12 +69,12 @@ 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; import org.sf.feeling.decompiler.actions.SourceCodeAction; import org.sf.feeling.decompiler.util.Logger; -import org.sf.feeling.decompiler.util.MarkUtil; import org.sf.feeling.decompiler.util.ReflectionUtils; import org.sf.feeling.decompiler.util.UIUtil; @@ -92,10 +88,9 @@ import com.drgarbage.asm.render.intf.IOutlineElementField; import com.drgarbage.utils.ClassFileDocumentsUtils; -public class DisassemblerSourceViewer extends AbstractDecoratedTextEditor implements IPropertyChangeListener -{ +public class DisassemblerSourceViewer extends AbstractDecoratedTextEditor implements IPropertyChangeListener { - private SelectionProvider fSelectionProvider = new JdtSelectionProvider( ); + private SelectionProvider fSelectionProvider = new JdtSelectionProvider(); private JavaDecompilerClassFileEditor editor; @@ -103,216 +98,161 @@ public class DisassemblerSourceViewer extends AbstractDecoratedTextEditor implem private Composite container; - public StyledText getTextWidget( ) - { - return getSourceViewer( ).getTextWidget( ); + public StyledText getTextWidget() { + return getSourceViewer().getTextWidget(); } @Override - public ISelectionProvider getSelectionProvider( ) - { + public ISelectionProvider getSelectionProvider() { return fSelectionProvider; } - public DisassemblerSourceViewer( JavaDecompilerClassFileEditor editor ) - { + public DisassemblerSourceViewer(JavaDecompilerClassFileEditor editor) { this.editor = editor; } - private IPreferenceStore createCombinedPreferenceStore( ) - { - List stores = new ArrayList( 3 ); + private IPreferenceStore createCombinedPreferenceStore() { + List stores = new ArrayList(3); - stores.add( JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ) ); - stores.add( JavaPlugin.getDefault( ).getPreferenceStore( ) ); - stores.add( EditorsUI.getPreferenceStore( ) ); + stores.add(JavaDecompilerPlugin.getDefault().getPreferenceStore()); + stores.add(JavaPlugin.getDefault().getPreferenceStore()); + stores.add(EditorsUI.getPreferenceStore()); - return new ChainedPreferenceStore( - (IPreferenceStore[]) stores.toArray( new IPreferenceStore[stores.size( )] ) ); + return new ChainedPreferenceStore((IPreferenceStore[]) stores.toArray(new IPreferenceStore[stores.size()])); } - public Composite createControl( Composite parent ) - { - setSite( editor.getSite( ) ); + public Composite createControl(Composite parent) { + setSite(editor.getSite()); - String classContent = editor.getDocumentProvider( ).getDocument( editor.getEditorInput( ) ).get( ); - String mark = MarkUtil.getMark( classContent ); - DisassemblerDocumentProvider provider = new DisassemblerDocumentProvider( mark ); - setDocumentProvider( provider ); - setInput( editor.getEditorInput( ) ); + DisassemblerDocumentProvider provider = new DisassemblerDocumentProvider(); + setDocumentProvider(provider); + setInput(editor.getEditorInput()); - container = new Composite( parent, SWT.NONE ); - container.setLayout( new FillLayout( ) ); - IPreferenceStore store = createCombinedPreferenceStore( ); - setPreferenceStore( store ); + container = new Composite(parent, SWT.NONE); + container.setLayout(new FillLayout()); + IPreferenceStore store = createCombinedPreferenceStore(); + setPreferenceStore(store); int styles = SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION; - IVerticalRuler fVerticalRuler = createVerticalRuler( ); - ReflectionUtils.setFieldValue( this, "fVerticalRuler", fVerticalRuler ); //$NON-NLS-1$ + IVerticalRuler fVerticalRuler = createVerticalRuler(); + ReflectionUtils.setFieldValue(this, "fVerticalRuler", fVerticalRuler); //$NON-NLS-1$ - SourceViewer fSourceViewer = new JavaSourceViewer( container, fVerticalRuler, null, false, styles, store ); - ReflectionUtils.setFieldValue( this, "fSourceViewer", fSourceViewer ); //$NON-NLS-1$ - getSourceViewerDecorationSupport( fSourceViewer ); + SourceViewer fSourceViewer = new JavaSourceViewer(container, fVerticalRuler, null, false, styles, store); + ReflectionUtils.setFieldValue(this, "fSourceViewer", fSourceViewer); //$NON-NLS-1$ + getSourceViewerDecorationSupport(fSourceViewer); - createActions( ); + createActions(); - ReflectionUtils.invokeMethod( this, "initializeSourceViewer", new Class[]{ //$NON-NLS-1$ - IEditorInput.class - }, new Object[]{ - getEditorInput( ) - } ); + ReflectionUtils.invokeMethod(this, "initializeSourceViewer", new Class[] { //$NON-NLS-1$ + IEditorInput.class }, new Object[] { getEditorInput() }); - if ( fSourceViewerDecorationSupport != null ) - fSourceViewerDecorationSupport.install( getPreferenceStore( ) ); + if (fSourceViewerDecorationSupport != null) { + fSourceViewerDecorationSupport.install(getPreferenceStore()); + } - StyledText styledText = fSourceViewer.getTextWidget( ); + StyledText styledText = fSourceViewer.getTextWidget(); styledText.addMouseListener(getCursorListener()); styledText.addKeyListener(getCursorListener()); - ReflectionUtils.setFieldValue( this, "fEditorContextMenuId", "#TextEditorContext" ); //$NON-NLS-1$ //$NON-NLS-2$ + ReflectionUtils.setFieldValue(this, "fEditorContextMenuId", "#TextEditorContext"); //$NON-NLS-1$ //$NON-NLS-2$ String id = "#TextEditorContext"; //$NON-NLS-1$ - MenuManager manager = new MenuManager( id, id ); - manager.setRemoveAllWhenShown( true ); - manager.addMenuListener( getContextMenuListener( ) ); - Menu fTextContextMenu = manager.createContextMenu( styledText ); - styledText.setMenu( fTextContextMenu ); + MenuManager manager = new MenuManager(id, id); + manager.setRemoveAllWhenShown(true); + manager.addMenuListener(getContextMenuListener()); + Menu fTextContextMenu = manager.createContextMenu(styledText); + styledText.setMenu(fTextContextMenu); - ReflectionUtils.setFieldValue( this, "fRulerContextMenuId", "#TextRulerContext" ); //$NON-NLS-1$ //$NON-NLS-2$ + ReflectionUtils.setFieldValue(this, "fRulerContextMenuId", "#TextRulerContext"); //$NON-NLS-1$ //$NON-NLS-2$ id = "#TextRulerContext"; //$NON-NLS-1$ - manager = new MenuManager( id, id ); - manager.setRemoveAllWhenShown( true ); - manager.addMenuListener( getContextMenuListener( ) ); - - Control rulerControl = fVerticalRuler.getControl( ); - Menu fRulerContextMenu = manager.createContextMenu( rulerControl ); - rulerControl.setMenu( fRulerContextMenu ); - rulerControl.addMouseListener( getRulerMouseListener( ) ); - - createOverviewRulerContextMenu( ); - - JavaTextTools textTools = JavaPlugin.getDefault( ).getJavaTextTools( ); - IColorManager colorManager = textTools.getColorManager( ); - DisassemblerConfiguration classFileConfiguration = new DisassemblerConfiguration( colorManager, - store, - editor, - IJavaPartitions.JAVA_PARTITIONING ); - fSourceViewer.configure( classFileConfiguration ); - setSourceViewerConfiguration( classFileConfiguration ); - getSourceViewerDecorationSupport( fSourceViewer ).install( getPreferenceStore( ) ); - initializeViewerColors( fSourceViewer ); - ReflectionUtils.invokeMethod( this, "initializeViewerFont", new Class[]{ //$NON-NLS-1$ - ISourceViewer.class - }, new Object[]{ - fSourceViewer - } ); - - final EditorSelectionChangedListener fEditorSelectionChangedListener = new EditorSelectionChangedListener( ); - fEditorSelectionChangedListener.install( getSelectionProvider( ) ); - - updateDocument( provider, fSourceViewer ); - - IVerticalRuler ruler = getVerticalRuler( ); - if ( ruler instanceof CompositeRuler ) - updateContributedRulerColumns( (CompositeRuler) ruler ); - - IColumnSupport columnSupport = (IColumnSupport) getAdapter( IColumnSupport.class ); - - RulerColumnDescriptor lineNumberColumnDescriptor = RulerColumnRegistry.getDefault( ) - .getColumnDescriptor( LineNumberColumn.ID ); - if ( lineNumberColumnDescriptor != null ) - columnSupport.setColumnVisible( lineNumberColumnDescriptor, isLineNumberRulerVisible( ) ); + manager = new MenuManager(id, id); + manager.setRemoveAllWhenShown(true); + manager.addMenuListener(getContextMenuListener()); + + Control rulerControl = fVerticalRuler.getControl(); + Menu fRulerContextMenu = manager.createContextMenu(rulerControl); + rulerControl.setMenu(fRulerContextMenu); + rulerControl.addMouseListener(getRulerMouseListener()); + + createOverviewRulerContextMenu(); + + JavaTextTools textTools = JavaPlugin.getDefault().getJavaTextTools(); + IColorManager colorManager = textTools.getColorManager(); + DisassemblerConfiguration classFileConfiguration = new DisassemblerConfiguration(colorManager, store, editor, + IJavaPartitions.JAVA_PARTITIONING); + fSourceViewer.configure(classFileConfiguration); + setSourceViewerConfiguration(classFileConfiguration); + getSourceViewerDecorationSupport(fSourceViewer).install(getPreferenceStore()); + initializeViewerColors(fSourceViewer); + ReflectionUtils.invokeMethod(this, "initializeViewerFont", new Class[] { //$NON-NLS-1$ + ISourceViewer.class }, new Object[] { fSourceViewer }); + + final EditorSelectionChangedListener fEditorSelectionChangedListener = new EditorSelectionChangedListener(); + fEditorSelectionChangedListener.install(getSelectionProvider()); + + updateDocument(provider, fSourceViewer); + + IVerticalRuler ruler = getVerticalRuler(); + if (ruler instanceof CompositeRuler) { + updateContributedRulerColumns((CompositeRuler) ruler); + } + + IColumnSupport columnSupport = (IColumnSupport) getAdapter(IColumnSupport.class); + + RulerColumnDescriptor lineNumberColumnDescriptor = RulerColumnRegistry.getDefault() + .getColumnDescriptor(LineNumberColumn.ID); + if (lineNumberColumnDescriptor != null) { + columnSupport.setColumnVisible(lineNumberColumnDescriptor, isLineNumberRulerVisible()); + } IPropertyChangeListener fFontPropertyChangeListener = (IPropertyChangeListener) ReflectionUtils - .getFieldValue( this, "fFontPropertyChangeListener" ); //$NON-NLS-1$ - JFaceResources.getFontRegistry( ).addListener( fFontPropertyChangeListener ); + .getFieldValue(this, "fFontPropertyChangeListener"); //$NON-NLS-1$ + JFaceResources.getFontRegistry().addListener(fFontPropertyChangeListener); - JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ).addPropertyChangeListener( this ); + JavaDecompilerPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this); - parent.addDisposeListener( new DisposeListener( ) { + parent.addDisposeListener(new DisposeListener() { @Override - public void widgetDisposed( DisposeEvent e ) - { - JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ).removePropertyChangeListener( - DisassemblerSourceViewer.this ); - fEditorSelectionChangedListener.uninstall( getSelectionProvider( ) ); + public void widgetDisposed(DisposeEvent e) { + JavaDecompilerPlugin.getDefault().getPreferenceStore() + .removePropertyChangeListener(DisassemblerSourceViewer.this); + fEditorSelectionChangedListener.uninstall(getSelectionProvider()); - DisassemblerSourceViewer.this.dispose( ); + DisassemblerSourceViewer.this.dispose(); } - } ); - - updateLinkStyle( ); + }); return container; } - private void updateLinkStyle( ) - { - String mark = ( (DisassemblerDocumentProvider) getDocumentProvider( ) ).getMark( ); - String ad = mark.replaceAll( "/(\\*)+", "" ) //$NON-NLS-1$ //$NON-NLS-2$ - .replaceAll( "(\\*)+/", "" ) //$NON-NLS-1$ //$NON-NLS-2$ - .trim( ); - int length = ad.length( ); - int offset = mark.indexOf( ad ); - - StyleRange textRange = UIUtil.getAdTextStyleRange( getTextWidget( ), offset, length ); - if ( textRange != null ) - { - getTextWidget( ).setStyleRange( textRange ); - } - - URLHyperlinkDetector detector = new URLHyperlinkDetector( ); - final int index = mark.indexOf( "://" ); //$NON-NLS-1$ - final IHyperlink[] links = detector.detectHyperlinks( getSourceViewer( ), new Region( index, 0 ), true ); - for ( int j = 0; j < links.length; j++ ) - { - IHyperlink link = links[j]; - StyleRange linkRange = UIUtil.getAdLinkStyleRange( getTextWidget( ), - link.getHyperlinkRegion( ).getOffset( ), - link.getHyperlinkRegion( ).getLength( ) ); - if ( linkRange != null ) - { - getTextWidget( ).setStyleRange( linkRange ); - } - } - } + private void updateDocument(DisassemblerDocumentProvider provider, ISourceViewer fSourceViewer) { + IClassFile cf = (ClassFile) ((IClassFileEditorInput) editor.getEditorInput()).getClassFile(); - private void updateDocument( DisassemblerDocumentProvider provider, ISourceViewer fSourceViewer ) - { - IClassFile cf = (ClassFile) ( (IClassFileEditorInput) editor.getEditorInput( ) ).getClassFile( ); + disassemblerDocument = new DisassemblerDocument(provider, editor); + provider.setDocument(disassemblerDocument); - disassemblerDocument = new DisassemblerDocument( provider, editor ); - provider.setDocument( disassemblerDocument ); + JavaTextTools tools = JavaPlugin.getDefault().getJavaTextTools(); + tools.setupJavaDocumentPartitioner(disassemblerDocument, IJavaPartitions.JAVA_PARTITIONING); - JavaTextTools tools = JavaPlugin.getDefault( ).getJavaTextTools( ); - tools.setupJavaDocumentPartitioner( disassemblerDocument, IJavaPartitions.JAVA_PARTITIONING ); - - try - { - provider.setDocumentContent( disassemblerDocument, new ByteArrayInputStream( cf.getBytes( ) ), null ); - } - catch ( CoreException e ) - { - ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler( ); - try - { - String content = disassembler.disassemble( cf.getBytes( ), "\n", ClassFileBytesDisassembler.DETAILED ); //$NON-NLS-1$ - disassemblerDocument.set( provider.getMark( ) + "\n\n" + ( content == null ? "" : content ) ); //$NON-NLS-1$ //$NON-NLS-2$ - } - catch ( Exception ex ) - { - Logger.debug( e ); + try { + provider.setDocumentContent(disassemblerDocument, new ByteArrayInputStream(cf.getBytes()), null); + } catch (CoreException e) { + ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); + try { + String content = disassembler.disassemble(cf.getBytes(), "\n", ClassFileBytesDisassembler.DETAILED); //$NON-NLS-1$ + disassemblerDocument.set((content == null ? "" : content)); //$NON-NLS-1$ //$NON-NLS-2$ + } catch (Exception ex) { + Logger.debug(e); } } - fSourceViewer.setDocument( disassemblerDocument ); + fSourceViewer.setDocument(disassemblerDocument); } - class JdtSelectionProvider extends SelectionProvider - { + class JdtSelectionProvider extends SelectionProvider { - private List fSelectionListeners = new ArrayList( ); - private List fPostSelectionListeners = new ArrayList( ); + private List fSelectionListeners = new ArrayList(); + private List fPostSelectionListeners = new ArrayList(); private ITextSelection fInvalidSelection; private ISelection fValidSelection; @@ -321,22 +261,22 @@ class JdtSelectionProvider extends SelectionProvider * addSelectionChangedListener(ISelectionChangedListener) */ @Override - public void addSelectionChangedListener( ISelectionChangedListener listener ) - { - super.addSelectionChangedListener( listener ); - if ( getSourceViewer( ) != null ) - fSelectionListeners.add( listener ); + public void addSelectionChangedListener(ISelectionChangedListener listener) { + super.addSelectionChangedListener(listener); + if (getSourceViewer() != null) { + fSelectionListeners.add(listener); + } } /* * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection() */ @Override - public ISelection getSelection( ) - { - if ( fInvalidSelection != null ) + public ISelection getSelection() { + if (fInvalidSelection != null) { return fInvalidSelection; - return super.getSelection( ); + } + return super.getSelection(); } /* @@ -344,48 +284,37 @@ public ISelection getSelection( ) * removeSelectionChangedListener(ISelectionChangedListener) */ @Override - public void removeSelectionChangedListener( ISelectionChangedListener listener ) - { - super.removeSelectionChangedListener( listener ); - if ( getSourceViewer( ) != null ) - fSelectionListeners.remove( listener ); + public void removeSelectionChangedListener(ISelectionChangedListener listener) { + super.removeSelectionChangedListener(listener); + if (getSourceViewer() != null) { + fSelectionListeners.remove(listener); + } } /* - * @see - * org.eclipse.jface.viewers.ISelectionProvider#setSelection(ISelection) + * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(ISelection) */ @Override - public void setSelection( ISelection selection ) - { - if ( selection instanceof ITextSelection ) - { - if ( fInvalidSelection != null ) - { + public void setSelection(ISelection selection) { + if (selection instanceof ITextSelection) { + if (fInvalidSelection != null) { fInvalidSelection = null; ITextSelection newSelection = (ITextSelection) selection; - ITextSelection oldSelection = (ITextSelection) getSelection( ); + ITextSelection oldSelection = (ITextSelection) getSelection(); - if ( newSelection.getOffset( ) == oldSelection.getOffset( ) - && newSelection.getLength( ) == oldSelection.getLength( ) ) - { - markValid( ); - } - else - { - super.setSelection( selection ); + if (newSelection.getOffset() == oldSelection.getOffset() + && newSelection.getLength() == oldSelection.getLength()) { + markValid(); + } else { + super.setSelection(selection); } + } else { + super.setSelection(selection); } - else - { - super.setSelection( selection ); - } - } - else if ( selection instanceof IStructuredSelection - && ( (IStructuredSelection) selection ).getFirstElement( ) instanceof EditorBreadcrumb ) - { - markInvalid( ); + } else if (selection instanceof IStructuredSelection + && ((IStructuredSelection) selection).getFirstElement() instanceof EditorBreadcrumb) { + markInvalid(); } } @@ -395,12 +324,12 @@ else if ( selection instanceof IStructuredSelection * ISelectionChangedListener) */ @Override - public void addPostSelectionChangedListener( ISelectionChangedListener listener ) - { - super.addPostSelectionChangedListener( listener ); - if ( getSourceViewer( ) != null - && getSourceViewer( ).getSelectionProvider( ) instanceof IPostSelectionProvider ) - fPostSelectionListeners.add( listener ); + public void addPostSelectionChangedListener(ISelectionChangedListener listener) { + super.addPostSelectionChangedListener(listener); + if (getSourceViewer() != null + && getSourceViewer().getSelectionProvider() instanceof IPostSelectionProvider) { + fPostSelectionListeners.add(listener); + } } /* @@ -409,481 +338,376 @@ && getSourceViewer( ).getSelectionProvider( ) instanceof IPostSelectionProvider * ISelectionChangedListener) */ @Override - public void removePostSelectionChangedListener( ISelectionChangedListener listener ) - { - super.removePostSelectionChangedListener( listener ); - if ( getSourceViewer( ) != null ) - fPostSelectionListeners.remove( listener ); + public void removePostSelectionChangedListener(ISelectionChangedListener listener) { + super.removePostSelectionChangedListener(listener); + if (getSourceViewer() != null) { + fPostSelectionListeners.remove(listener); + } } /* * @see org.eclipse.jface.text.IPostSelectionValidator#isValid() */ @Override - public boolean isValid( ISelection postSelection ) - { - return fInvalidSelection == null && super.isValid( postSelection ); + public boolean isValid(ISelection postSelection) { + return fInvalidSelection == null && super.isValid(postSelection); } /** * Marks this selection provider as currently being invalid. An invalid * selection is one which can not be selected in the source viewer. */ - private void markInvalid( ) - { - fValidSelection = getSelection( ); - fInvalidSelection = new TextSelection( 0, 0 ); + private void markInvalid() { + fValidSelection = getSelection(); + fInvalidSelection = new TextSelection(0, 0); - SelectionChangedEvent event = new SelectionChangedEvent( this, fInvalidSelection ); + SelectionChangedEvent event = new SelectionChangedEvent(this, fInvalidSelection); - for ( ISelectionChangedListener listener : fSelectionListeners ) - { - listener.selectionChanged( event ); + for (ISelectionChangedListener listener : fSelectionListeners) { + listener.selectionChanged(event); } - for ( ISelectionChangedListener listener : fPostSelectionListeners ) - { - listener.selectionChanged( event ); + for (ISelectionChangedListener listener : fPostSelectionListeners) { + listener.selectionChanged(event); } } /** * Marks this selection provider as being valid. */ - private void markValid( ) - { + private void markValid() { fInvalidSelection = null; - SelectionChangedEvent event = new SelectionChangedEvent( this, fValidSelection ); + SelectionChangedEvent event = new SelectionChangedEvent(this, fValidSelection); - for ( ISelectionChangedListener listener : fSelectionListeners ) - { - listener.selectionChanged( event ); + for (ISelectionChangedListener listener : fSelectionListeners) { + listener.selectionChanged(event); } - for ( ISelectionChangedListener listener : fPostSelectionListeners ) - { - listener.selectionChanged( event ); + for (ISelectionChangedListener listener : fPostSelectionListeners) { + listener.selectionChanged(event); } } } - private class EditorSelectionChangedListener extends AbstractSelectionChangedListener - { + private class EditorSelectionChangedListener extends AbstractSelectionChangedListener { - public void selectionChanged( SelectionChangedEvent event ) - { - doHandleCursorPositionChanged( ); + public void selectionChanged(SelectionChangedEvent event) { + doHandleCursorPositionChanged(); } } - private void doHandleCursorPositionChanged( ) - { - IClassFileDocument disassemblerClassDocument = ( (DisassemblerDocumentProvider) getDocumentProvider( ) ) - .getClassFileDocument( ); - if ( disassemblerClassDocument != null ) - { + private void doHandleCursorPositionChanged() { + IClassFileDocument disassemblerClassDocument = ((DisassemblerDocumentProvider) getDocumentProvider()) + .getClassFileDocument(); + if (disassemblerClassDocument != null) { /* set selection in the outline */ - final StyledText disassemblerText = getSourceViewer( ).getTextWidget( ); - int selectedRange = disassemblerText.getSelectionRange( ).x; + final StyledText disassemblerText = getSourceViewer().getTextWidget(); + int selectedRange = disassemblerText.getSelectionRange().x; - try - { - int line = disassemblerDocument.getLineOfOffset( selectedRange ); - ClassFile cf = (ClassFile) ( (IClassFileEditorInput) getEditorInput( ) ).getClassFile( ); + try { + int line = disassemblerDocument.getLineOfOffset(selectedRange); + ClassFile cf = (ClassFile) ((IClassFileEditorInput) getEditorInput()).getClassFile(); - if ( disassemblerClassDocument.isLineInMethod( line - 2 ) ) - { - IMethodSection method = disassemblerClassDocument.findMethodSection( line - 2 ); + if (disassemblerClassDocument.isLineInMethod(line - 2)) { + IMethodSection method = disassemblerClassDocument.findMethodSection(line - 2); - if ( method != null ) - { - IMethod m = ClassFileDocumentsUtils - .findMethod( cf.getType( ), method.getName( ), method.getDescriptor( ) ); - if ( m != null ) - { - editor.setSelection( m ); + if (method != null) { + IMethod m = ClassFileDocumentsUtils.findMethod(cf.getType(), method.getName(), + method.getDescriptor()); + if (m != null) { + editor.setSelection(m); } } - } - else if ( disassemblerClassDocument.isLineInField( line - 2 ) ) - { - IFieldSection field = disassemblerClassDocument.findFieldSection( line - 2 ); - if ( field != null ) - { - IField f = cf.getType( ).getField( field.getName( ) ); - if ( f != null ) - { - editor.setSelection( f ); + } else if (disassemblerClassDocument.isLineInField(line - 2)) { + IFieldSection field = disassemblerClassDocument.findFieldSection(line - 2); + if (field != null) { + IField f = cf.getType().getField(field.getName()); + if (f != null) { + editor.setSelection(f); } } + } else { + editor.setSelection(cf.getType()); } - else - { - editor.setSelection( cf.getType( ) ); - } - } - catch ( Exception e ) - { - Logger.debug( e ); + } catch (Exception e) { + Logger.debug(e); } } } - protected void editorContextMenuAboutToShow( IMenuManager menu ) - { - super.editorContextMenuAboutToShow( menu ); - String text = (String) ReflectionUtils.invokeMethod( this, "getShowInMenuLabel" ); //$NON-NLS-1$ - for ( int i = 0; i < menu.getItems( ).length; i++ ) - { - if ( menu.getItems( )[i] instanceof MenuManager ) - { - if ( ( (MenuManager) menu.getItems( )[i] ).getMenuText( ).equals( text ) ) - { - menu.remove( menu.getItems( )[i] ); + protected void editorContextMenuAboutToShow(IMenuManager menu) { + super.editorContextMenuAboutToShow(menu); + // private method + // org.eclipse.ui.texteditor.AbstractDecoratedTextEditor.getShowInMenuLabel() + String text = (String) ReflectionUtils.invokeMethod(this, "getShowInMenuLabel"); //$NON-NLS-1$ + for (int i = 0; i < menu.getItems().length; i++) { + IContributionItem item = menu.getItems()[i]; + if (item instanceof MenuManager) { + if (((MenuManager) item).getMenuText().equals(text)) { + menu.remove(item); } } } - menu.appendToGroup( ITextEditorActionConstants.GROUP_OPEN, getAction( SourceCodeAction.ID ) ); - menu.appendToGroup( ITextEditorActionConstants.GROUP_OPEN, getAction( ByteCodeAction.ID ) ); - menu.appendToGroup( ITextEditorActionConstants.GROUP_OPEN, getAction( DisassemblerAction.ID ) ); + menu.appendToGroup(ITextEditorActionConstants.GROUP_OPEN, getAction(SourceCodeAction.ID)); + menu.appendToGroup(ITextEditorActionConstants.GROUP_OPEN, getAction(ByteCodeAction.ID)); + menu.appendToGroup(ITextEditorActionConstants.GROUP_OPEN, getAction(DisassemblerAction.ID)); - menu.addMenuListener( new IMenuListener( ) { + menu.addMenuListener(new IMenuListener() { @Override - public void menuAboutToShow( IMenuManager manager ) - { - showMenu( manager ); + public void menuAboutToShow(IMenuManager manager) { + showMenu(manager); } - } ); + }); } - private void showMenu( IMenuManager submenu ) - { - for ( Iterator iter = Arrays.asList( submenu.getItems( ) ).iterator( ); iter.hasNext( ); ) - { - IContributionItem item = iter.next( ); - if ( item instanceof ActionContributionItem ) - { - IAction action = ( (ActionContributionItem) item ).getAction( ); - if ( action instanceof IUpdate ) - { - ( (IUpdate) action ).update( ); + private void showMenu(IMenuManager submenu) { + for (Iterator iter = Arrays.asList(submenu.getItems()).iterator(); iter.hasNext();) { + IContributionItem item = iter.next(); + if (item instanceof ActionContributionItem) { + IAction action = ((ActionContributionItem) item).getAction(); + if (action instanceof IUpdate) { + ((IUpdate) action).update(); } } } } @Override - protected void createActions( ) - { - super.createActions( ); - setAction( SourceCodeAction.ID, new SourceCodeAction( ) ); - setAction( ByteCodeAction.ID, new ByteCodeAction( ) ); - setAction( DisassemblerAction.ID, new DisassemblerAction( ) ); + protected void createActions() { + super.createActions(); + setAction(SourceCodeAction.ID, new SourceCodeAction()); + setAction(ByteCodeAction.ID, new ByteCodeAction()); + setAction(DisassemblerAction.ID, new DisassemblerAction()); } @Override - public String[] collectContextMenuPreferencePages( ) - { - return editor.collectContextMenuPreferencePages( ); + public String[] collectContextMenuPreferencePages() { + return editor.collectContextMenuPreferencePages(); } - public boolean isEditorInputModifiable( ) - { + public boolean isEditorInputModifiable() { return false; } - public Control getControl( ) - { + public Control getControl() { return container; } - public void setSelectionElement( ISourceReference selectedElement ) - { - setSelectionElement( selectedElement, false ); + public void setSelectionElement(ISourceReference selectedElement) { + setSelectionElement(selectedElement, false); } - 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 - && disassemblerText != null - && !disassemblerText.isDisposed( ) - && disassemblerRootElement != null ) - { - if ( !force ) - { - if ( UIUtil.requestFromDisassemblerSelection( ) ) + public void setSelectionElement(ISourceReference selectedElement, boolean force) { + final StyledText disassemblerText = getSourceViewer().getTextWidget(); + OutlineElement disassemblerRootElement = (OutlineElement) ((DisassemblerDocumentProvider) getDocumentProvider()) + .getClassFileOutlineElement(); + if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.DISASSEMBLER_MODE + && disassemblerText != null && !disassemblerText.isDisposed() && disassemblerRootElement != null) { + if (!force) { + if (UIUtil.requestFromDisassemblerSelection()) { return; + } - if ( !UIUtil.requestFromLinkToSelection( ) ) + if (!UIUtil.requestFromLinkToSelection()) { return; + } } - if ( selectedElement instanceof IMethod - || selectedElement instanceof IField - || selectedElement instanceof BinaryType ) - { - try - { - OutlineElement element = searchElement( disassemblerRootElement, selectedElement ); - if ( element != null ) - { - selectElement( disassemblerText, element ); + if (selectedElement instanceof IMethod || selectedElement instanceof IField + || selectedElement instanceof BinaryType) { + try { + OutlineElement element = searchElement(disassemblerRootElement, selectedElement); + if (element != null) { + selectElement(disassemblerText, element); } - } - catch ( Exception e ) - { - Logger.debug( e ); + } catch (Exception e) { + Logger.debug(e); } } } } - public void selectBytecodeLineAndReveal( StyledText disassemblerText, int bytecodeDocumentLine, String elementName, - int elementType ) - { - try - { + public void selectBytecodeLineAndReveal(StyledText disassemblerText, int bytecodeDocumentLine, String elementName, + int elementType) { + try { /* get line information */ - IRegion region = disassemblerDocument.getLineInformation( bytecodeDocumentLine + 2 ); - int lineStartOffset = region.getOffset( ); - int lineLenght = region.getLength( ); - String lineString = disassemblerDocument.get( lineStartOffset, lineLenght ); - - if ( elementName == null ) - { - disassemblerText.setSelection( lineStartOffset ); + IRegion region = disassemblerDocument.getLineInformation(bytecodeDocumentLine + 2); + int lineStartOffset = region.getOffset(); + int lineLenght = region.getLength(); + String lineString = disassemblerDocument.get(lineStartOffset, lineLenght); + + if (elementName == null) { + disassemblerText.setSelection(lineStartOffset); } int elementIndex, elementLength; - switch ( elementType ) - { - case IJavaElement.CLASS_FILE : - lineStartOffset = 0; - String header = disassemblerDocument.get( ).substring( 0, - disassemblerDocument.get( ).indexOf( "{" ) ); //$NON-NLS-1$ - int startIndex = 0; - if ( ( startIndex = header.indexOf( "class" ) ) != -1 //$NON-NLS-1$ - || ( startIndex = header.indexOf( "enum" ) ) != -1 //$NON-NLS-1$ - || ( startIndex = header.indexOf( "interface" ) ) != -1 ) //$NON-NLS-1$ - { - elementIndex = startIndex + header.substring( startIndex ).indexOf( elementName ); - } - else - { - elementIndex = header.indexOf( elementName ); - } - break; - case IJavaElement.FIELD : - elementIndex = lineString.indexOf( " " + elementName + ";" ) + 1; //$NON-NLS-1$ //$NON-NLS-2$ - break; - case IJavaElement.METHOD : - elementIndex = lineString.indexOf( " " + elementName + "(" ) + 1; //$NON-NLS-1$ //$NON-NLS-2$ - break; - default : - elementIndex = 0; - elementLength = 0; + switch (elementType) { + case IJavaElement.CLASS_FILE: + lineStartOffset = 0; + String header = disassemblerDocument.get().substring(0, disassemblerDocument.get().indexOf("{")); //$NON-NLS-1$ + int startIndex = 0; + if ((startIndex = header.indexOf("class")) != -1 //$NON-NLS-1$ + || (startIndex = header.indexOf("enum")) != -1 //$NON-NLS-1$ + || (startIndex = header.indexOf("interface")) != -1) //$NON-NLS-1$ + { + elementIndex = startIndex + header.substring(startIndex).indexOf(elementName); + } else { + elementIndex = header.indexOf(elementName); + } + break; + case IJavaElement.FIELD: + elementIndex = lineString.indexOf(" " + elementName + ";") + 1; //$NON-NLS-1$ //$NON-NLS-2$ + break; + case IJavaElement.METHOD: + elementIndex = lineString.indexOf(" " + elementName + "(") + 1; //$NON-NLS-1$ //$NON-NLS-2$ + break; + default: + elementIndex = 0; + elementLength = 0; } /* name not found */ - if ( elementIndex == 0 ) - { + if (elementIndex == 0) { elementLength = 0; - } - else - { - elementLength = elementName.length( ); + } else { + elementLength = elementName.length(); } - disassemblerText.setSelection( lineStartOffset + elementIndex, - lineStartOffset + elementIndex + elementLength ); - } - catch ( BadLocationException e ) - { + disassemblerText.setSelection(lineStartOffset + elementIndex, + lineStartOffset + elementIndex + elementLength); + } catch (BadLocationException e) { /* nothing to do */ } } - private void selectElement( StyledText disassemblerText, OutlineElement element ) - { - int bytecodeDocumentLine = element.getBytecodeDocumentLine( ); - if ( ( element instanceof IType ) ) - { + private void selectElement(StyledText disassemblerText, OutlineElement element) { + int bytecodeDocumentLine = element.getBytecodeDocumentLine(); + if ((element instanceof IType)) { IType type = (IType) element; - String name = type.getElementName( ); - selectBytecodeLineAndReveal( disassemblerText, bytecodeDocumentLine, name, IJavaElement.CLASS_FILE ); - } - else if ( ( element instanceof IOutlineElementField ) ) - { + String name = type.getElementName(); + selectBytecodeLineAndReveal(disassemblerText, bytecodeDocumentLine, name, IJavaElement.CLASS_FILE); + } else if ((element instanceof IOutlineElementField)) { IOutlineElementField field = (IOutlineElementField) element; - String name = field.getFieldSection( ).getName( ); - selectBytecodeLineAndReveal( disassemblerText, bytecodeDocumentLine, name, IJavaElement.FIELD ); - } - else if ( ( element instanceof IMethod ) ) - { + String name = field.getFieldSection().getName(); + selectBytecodeLineAndReveal(disassemblerText, bytecodeDocumentLine, name, IJavaElement.FIELD); + } else if ((element instanceof IMethod)) { IMethod method = (IMethod) element; - String name = method.getElementName( ); - selectBytecodeLineAndReveal( disassemblerText, bytecodeDocumentLine, name, IJavaElement.METHOD ); - } - else - { - selectLineAndRevaluate( disassemblerText, bytecodeDocumentLine ); + String name = method.getElementName(); + selectBytecodeLineAndReveal(disassemblerText, bytecodeDocumentLine, name, IJavaElement.METHOD); + } else { + selectLineAndRevaluate(disassemblerText, bytecodeDocumentLine); } } - public void selectLineAndRevaluate( StyledText disassemblerText, int bytecodeLine ) - { - try - { - String mark = MarkUtil.getMark( disassemblerText.getText( ) ); - int offset = mark.length( ) + 2; - - int lineStartOffset = disassemblerDocument.getLineOffset( bytecodeLine ); - disassemblerText.setSelection( lineStartOffset + offset ); + public void selectLineAndRevaluate(StyledText disassemblerText, int bytecodeLine) { + try { + int lineStartOffset = disassemblerDocument.getLineOffset(bytecodeLine); + disassemblerText.setSelection(lineStartOffset); - } - catch ( BadLocationException e ) - { + } catch (BadLocationException e) { /* nothing to do */ } } - private OutlineElement searchElement( OutlineElement element, ISourceReference reference ) throws CoreException - { - if ( reference instanceof BinaryType ) - { - if ( element instanceof OutlineElementType ) - { + private OutlineElement searchElement(OutlineElement element, ISourceReference reference) throws CoreException { + if (reference instanceof BinaryType) { + if (element instanceof OutlineElementType) { OutlineElementType asmType = (OutlineElementType) element; BinaryType jdtType = (BinaryType) reference; - String asmTypeName = asmType.getElementName( ); - if ( asmTypeName.indexOf( '$' ) != -1 ) - { - asmTypeName = asmTypeName.substring( asmTypeName.lastIndexOf( '$' ) + 1 ); - if ( asmTypeName.matches( "\\d+" ) ) //$NON-NLS-1$ + String asmTypeName = asmType.getElementName(); + if (asmTypeName.indexOf('$') != -1) { + asmTypeName = asmTypeName.substring(asmTypeName.lastIndexOf('$') + 1); + if (asmTypeName.matches("\\d+")) //$NON-NLS-1$ { asmTypeName = ""; //$NON-NLS-1$ } } - if ( asmTypeName.equals( jdtType.getElementName( ) ) ) - { + if (asmTypeName.equals(jdtType.getElementName())) { return element; } - } - else - { - IJavaElement[] children = element.getChildren( ); - for ( int i = 0; i < children.length; i++ ) - { + } else { + IJavaElement[] children = element.getChildren(); + for (int i = 0; i < children.length; i++) { IJavaElement child = children[i]; - if ( child instanceof OutlineElement ) - { - OutlineElement result = searchElement( (OutlineElement) child, reference ); - if ( result != null ) - { + if (child instanceof OutlineElement) { + OutlineElement result = searchElement((OutlineElement) child, reference); + if (result != null) { return result; } } } } - } - else if ( reference instanceof IField ) - { - if ( element instanceof OutlineElementField ) - { + } else if (reference instanceof IField) { + if (element instanceof OutlineElementField) { OutlineElementField asmField = (OutlineElementField) element; IField jdtField = (IField) reference; - String asmFieldName = (String) ReflectionUtils.getFieldValue( asmField, "elementName" ); //$NON-NLS-1$ - if ( asmFieldName.indexOf( '$' ) != -1 ) - { - asmFieldName = asmFieldName.substring( asmFieldName.lastIndexOf( '$' ) + 1 ); + String asmFieldName = (String) ReflectionUtils.getFieldValue(asmField, "elementName"); //$NON-NLS-1$ + if (asmFieldName.indexOf('$') != -1) { + asmFieldName = asmFieldName.substring(asmFieldName.lastIndexOf('$') + 1); } - if ( asmFieldName.equals( jdtField.getElementName( ) ) ) - { - String jdtType = jdtField.getTypeSignature( ).replaceAll( "<.*>", "" ); //$NON-NLS-1$ //$NON-NLS-2$ - String asmType = asmField.getTypeSignature( ).replace( '/', '.' ); - if ( jdtType.equals( asmType ) ) + if (asmFieldName.equals(jdtField.getElementName())) { + String jdtType = jdtField.getTypeSignature().replaceAll("<.*>", ""); //$NON-NLS-1$ //$NON-NLS-2$ + String asmType = asmField.getTypeSignature().replace('/', '.'); + if (jdtType.equals(asmType)) return element; } - } - else - { - IJavaElement[] children = element.getChildren( ); - for ( int i = 0; i < children.length; i++ ) - { + } else { + IJavaElement[] children = element.getChildren(); + for (int i = 0; i < children.length; i++) { IJavaElement child = children[i]; - if ( child instanceof OutlineElement ) - { - OutlineElement result = searchElement( (OutlineElement) child, reference ); - if ( result != null ) - { + if (child instanceof OutlineElement) { + OutlineElement result = searchElement((OutlineElement) child, reference); + if (result != null) { return result; } } } } - } - else if ( reference instanceof IMethod ) - { - if ( element instanceof OutlineElementMethod ) - { + } else if (reference instanceof IMethod) { + if (element instanceof OutlineElementMethod) { OutlineElementMethod asmMethod = (OutlineElementMethod) element; IMethod jdtMethod = (IMethod) reference; - String asmMethodName = asmMethod.getElementName( ); - if ( asmMethodName.indexOf( '$' ) != -1 ) - { - asmMethodName = asmMethodName.substring( asmMethodName.lastIndexOf( '$' ) + 1 ); - if ( asmMethodName.matches( "\\d+" ) ) //$NON-NLS-1$ + String asmMethodName = asmMethod.getElementName(); + if (asmMethodName.indexOf('$') != -1) { + asmMethodName = asmMethodName.substring(asmMethodName.lastIndexOf('$') + 1); + if (asmMethodName.matches("\\d+")) //$NON-NLS-1$ { asmMethodName = ""; //$NON-NLS-1$ } } - if ( asmMethodName.equals( jdtMethod.getElementName( ) ) - && asmMethod.getSignature( ).equals( jdtMethod.getSignature( ) ) ) - { - if ( jdtMethod.getParent( ) instanceof BinaryType ) - { - BinaryType jdtType = (BinaryType) jdtMethod.getParent( ); - OutlineElementType asmType = (OutlineElementType) asmMethod.getDeclaringType( ); - String asmTypeName = asmType.getElementName( ); - if ( asmTypeName.indexOf( '$' ) != -1 ) - { - asmTypeName = asmTypeName.substring( asmTypeName.lastIndexOf( '$' ) + 1 ); - if ( asmTypeName.matches( "\\d+" ) ) //$NON-NLS-1$ + if (asmMethodName.equals(jdtMethod.getElementName()) + && asmMethod.getSignature().equals(jdtMethod.getSignature())) { + if (jdtMethod.getParent() instanceof BinaryType) { + BinaryType jdtType = (BinaryType) jdtMethod.getParent(); + OutlineElementType asmType = (OutlineElementType) asmMethod.getDeclaringType(); + String asmTypeName = asmType.getElementName(); + if (asmTypeName.indexOf('$') != -1) { + asmTypeName = asmTypeName.substring(asmTypeName.lastIndexOf('$') + 1); + if (asmTypeName.matches("\\d+")) //$NON-NLS-1$ { asmTypeName = ""; //$NON-NLS-1$ } } - if ( asmTypeName.equals( jdtType.getElementName( ) ) ) - { + if (asmTypeName.equals(jdtType.getElementName())) { return element; } - } - else + } else return asmMethod; } - } - else - { - IJavaElement[] children = element.getChildren( ); - for ( int i = 0; i < children.length; i++ ) - { - IJavaElement child = children[i]; - if ( child instanceof OutlineElement ) - { - OutlineElement result = searchElement( (OutlineElement) child, reference ); - if ( result != null ) - { + } else { + IJavaElement[] children = element.getChildren(); + for (IJavaElement child : children) { + if (child instanceof OutlineElement) { + OutlineElement result = searchElement((OutlineElement) child, reference); + if (result != null) { return result; } } @@ -893,76 +717,61 @@ else if ( reference instanceof IMethod ) return null; } - protected IConfigurationElement getConfigurationElement( ) - { - return (IConfigurationElement) ReflectionUtils.invokeMethod( editor, "getConfigurationElement" ); //$NON-NLS-1$ + @Override + protected IConfigurationElement getConfigurationElement() { + return (IConfigurationElement) ReflectionUtils.invokeMethod(editor, "getConfigurationElement"); //$NON-NLS-1$ } private volatile boolean docChanged = false; private volatile boolean styleChanged = false; @Override - public void propertyChange( PropertyChangeEvent event ) - { - if ( event.getProperty( ).startsWith( JavaDecompilerPlugin.bytecodeMnemonicPreferencesPrefix ) ) - { - ( (DisassemblerConfiguration) getSourceViewerConfiguration( ) ).adaptToPreferenceChange( event ); - if ( styleChanged == false ) - { + public void propertyChange(PropertyChangeEvent event) { + if (event.getProperty().startsWith(JavaDecompilerConstants.bytecodeMnemonicPreferencesPrefix)) { + ((DisassemblerConfiguration) getSourceViewerConfiguration()).adaptToPreferenceChange(event); + if (styleChanged == false) { styleChanged = true; - Display.getDefault( ).timerExec( 10, new Runnable( ) { + Display.getDefault().timerExec(10, new Runnable() { - public void run( ) - { - getSourceViewer( ).invalidateTextPresentation( ); - updateLinkStyle( ); + public void run() { + getSourceViewer().invalidateTextPresentation(); styleChanged = false; } - } ); + }); } - } - else if ( event.getProperty( ).startsWith( JavaDecompilerPlugin.classFileAttributePreferencesPrefix ) - || event.getProperty( ).equals( JavaDecompilerPlugin.BRANCH_TARGET_ADDRESS_RENDERING ) ) - { - if ( docChanged == false ) - { + } 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( ) { + Display.getDefault().timerExec(10, new Runnable() { - public void run( ) - { - updateDocument( (DisassemblerDocumentProvider) getDocumentProvider( ), getSourceViewer( ) ); - if ( editor.getSelectedElement( ) != null ) - { - setSelectionElement( editor.getSelectedElement( ), true ); + public void run() { + updateDocument((DisassemblerDocumentProvider) getDocumentProvider(), getSourceViewer()); + if (editor.getSelectedElement() != null) { + setSelectionElement(editor.getSelectedElement(), true); } - updateLinkStyle( ); docChanged = false; } - } ); + }); } } } @Override - public boolean isDirty( ) - { + public boolean isDirty() { return false; } - public boolean isEditable( ) - { + public boolean isEditable() { return false; } @Override - public boolean isEditorInputReadOnly( ) - { + public boolean isEditorInputReadOnly() { return true; } - protected void handleCursorPositionChanged( ) - { - ReflectionUtils.invokeMethod( editor, "handleCursorPositionChanged" ); //$NON-NLS-1$ + protected void handleCursorPositionChanged() { + ReflectionUtils.invokeMethod(editor, "handleCursorPositionChanged"); //$NON-NLS-1$ } } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/IDecompiler.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/IDecompiler.java index 3266be1b..6c813df2 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/IDecompiler.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/IDecompiler.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.editor; @@ -21,65 +18,74 @@ * a IDecompiler instance: root = /bar packege = com/acme className * = Foo.class */ -public interface IDecompiler -{ +public interface IDecompiler { /** * Decompiles a class file located in file system (not in archive) * - * @param root - * path to the directory which is root for this class package - * hierarchy - * @param packege - * file path like package name - * @param className - * file name of the class file + * @param root path to the directory which is root for this class package + * hierarchy + * @param packege file path like package name + * @param className file name of the class file */ - public void decompile( String root, String packege, String className ); + void decompile(String root, String packege, String className); /** * Decompiles a class file located in archive. * - * @param archivePath - * path to archive that contains the class to be decompiled - * @param packege - * file path like package name - * @param className - * file name of the class file + * @param archivePath path to archive that contains the class to be decompiled + * @param packege file path like package name + * @param className file name of the class file */ - public void decompileFromArchive( String archivePath, String packege, String className ); + void decompileFromArchive(String archivePath, String packege, String className); /** * @return time taken by decompilation */ - public long getDecompilationTime( ); + long getDecompilationTime(); /** - * If any exceptions occured during decompilation thaey should be included - * into the List returned by this method. + * If any exceptions occurred during decompilation they should be included into + * the List returned by this method. * * @return non-null value which is a list containing * java.lang.Exception's */ - public List getExceptions( ); + List getExceptions(); + + void clearExceptions(); /** * @return decompilation log specific to physical decompiler */ - public String getLog( ); + String getLog(); /** * @return Class file source which is the result of decompilation. */ - public String getSource( ); + String getSource(); + + String getDecompilerType(); + + /** + * Get the way the decompiler uses for printing source code line numbers in the + * decompiled source code. Required for post-formatting the source code + * according to the printed line numbers to make the source code suitable for + * debugging. + * + * @return line number output type or null if reformatting is not + * needed or supported + */ + LineNumberOutputType getLineNumberOutputType(); + + String removeComment(String source); - public String getDecompilerType( ); + boolean supportDebugLevel(int level); - public String removeComment( String source ); + boolean supportLevel(int level); - public boolean supportDebugLevel( int level ); + String getDecompilerName(); - public boolean supportLevel( int level ); + String getDecompilerVersion(); - public boolean supportDebug( ); } \ No newline at end of file diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/IDecompilerDescriptor.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/IDecompilerDescriptor.java index fa3f5a0e..cacfb084 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/IDecompilerDescriptor.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/IDecompilerDescriptor.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.editor; @@ -14,22 +11,26 @@ import org.eclipse.jface.action.Action; import org.eclipse.jface.resource.ImageDescriptor; -public interface IDecompilerDescriptor -{ +public interface IDecompilerDescriptor { - String getDecompilerType( ); + String getDecompilerType(); - String getDecompilerPreferenceLabel( ); + String getDecompilerPreferenceLabel(); - IDecompiler getDecompiler( ); + IDecompiler getDecompiler(); - BaseDecompilerSourceMapper getDecompilerSourceMapper( ); + BaseDecompilerSourceMapper getDecompilerSourceMapper(); - Action getDecompileAction( ); + Action getDecompileAction(); - boolean isEnabled( ); + boolean isEnabled(); - boolean isDefault( ); + /** + * Allows to specify a priority which is used when no default decompiler is set. + * + * @return + */ + int getDefaultPriority(); - ImageDescriptor getDecompilerIcon( ); + ImageDescriptor getDecompilerIcon(); } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/ImportSourceMapper.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/ImportSourceMapper.java deleted file mode 100644 index efe87f17..00000000 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/ImportSourceMapper.java +++ /dev/null @@ -1,216 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.editor; - -import java.lang.reflect.Constructor; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Stack; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.ISourceRange; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.compiler.CharOperation; -import org.eclipse.jdt.internal.compiler.env.IBinaryType; -import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; -import org.eclipse.jdt.internal.core.BinaryType; -import org.eclipse.jdt.internal.core.ClassFile; -import org.eclipse.jdt.internal.core.ImportContainer; -import org.eclipse.jdt.internal.core.ImportContainerInfo; -import org.eclipse.jdt.internal.core.ImportDeclaration; -import org.eclipse.jdt.internal.core.ImportDeclarationElementInfo; -import org.eclipse.jdt.internal.core.JavaElement; -import org.eclipse.jdt.internal.core.JavaModelManager; -import org.eclipse.jdt.internal.core.OpenableElementInfo; -import org.eclipse.jdt.internal.core.SourceMapper; -import org.sf.feeling.decompiler.util.DecompilerOutputUtil; -import org.sf.feeling.decompiler.util.Logger; -import org.sf.feeling.decompiler.util.ReflectionUtils; - -public class ImportSourceMapper extends SourceMapper -{ - - private static Map options = new HashMap( ); - static - { - CompilerOptions option = new CompilerOptions( ); - options = option.getMap( ); - options.put( CompilerOptions.OPTION_Compliance, DecompilerOutputUtil.getMaxDecompileLevel( ) ); // $NON-NLS-1$ - options.put( CompilerOptions.OPTION_Source, DecompilerOutputUtil.getMaxDecompileLevel( ) ); // $NON-NLS-1$ - } - - public ImportSourceMapper( IPath sourcePath, String rootPath ) - { - - this( sourcePath, rootPath, options ); - } - - public ImportSourceMapper( IPath sourcePath, String rootPath, Map options ) - { - super( sourcePath, rootPath, options ); - } - - protected Stack infoStack; - protected HashMap children; - protected Stack handleStack; - protected ClassFile unit; - protected OpenableElementInfo unitInfo; - protected ImportContainerInfo importContainerInfo = null; - protected ImportContainer importContainer; - - private JavaModelManager manager = JavaModelManager.getJavaModelManager( ); - - @Override - public void enterCompilationUnit( ) - { - this.infoStack = new Stack( ); - this.children = new HashMap( ); - this.handleStack = new Stack( ); - this.infoStack.push( this.unitInfo ); - this.handleStack.push( this.unit ); - } - - @Override - public synchronized ISourceRange mapSource( IType type, char[] contents, IBinaryType info, - IJavaElement elementToFind ) - { - this.binaryType = (BinaryType) type; - this.unit = (ClassFile) binaryType.getClassFile( ); - try - { - this.unitInfo = (OpenableElementInfo) this.unit.getElementInfo( ); - } - catch ( JavaModelException e ) - { - Logger.debug( e ); - } - - return super.mapSource( type, contents, info, elementToFind ); - } - - @Override - public void exitCompilationUnit( int declarationEnd ) - { - IJavaElement[] oldChildren = (IJavaElement[]) ReflectionUtils.getFieldValue( this.unitInfo, "children" ); //$NON-NLS-1$ - - if ( this.importContainerInfo != null ) - { - ReflectionUtils - .setFieldValue( this.importContainerInfo, "children", getChildren( this.importContainerInfo ) ); //$NON-NLS-1$ - } - - List children = new ArrayList( ); - - for ( int i = 0; i < oldChildren.length; i++ ) - { - IJavaElement child = oldChildren[i]; - if ( child instanceof ImportContainer ) - continue; - children.add( child ); - } - - children.addAll( Arrays.asList( getChildren( this.unitInfo ) ) ); - - ReflectionUtils.setFieldValue( this.unitInfo, "children", children.toArray( new IJavaElement[0] ) ); //$NON-NLS-1$ - - if ( this.importContainer != null ) - { - manager.getTemporaryCache( ).put( this.importContainer, this.importContainerInfo ); - } - ReflectionUtils.invokeMethod( manager, "putInfos", new Class[]{ //$NON-NLS-1$ - IJavaElement.class, Object.class, boolean.class, Map.class - }, new Object[]{ - unit, unitInfo, false, manager.getTemporaryCache( ) - } ); - } - - private IJavaElement[] getChildren( Object info ) - { - ArrayList childrenList = (ArrayList) this.children.get( info ); - if ( childrenList != null ) - { - return (IJavaElement[]) childrenList.toArray( new IJavaElement[childrenList.size( )] ); - } - return new JavaElement[0]; - } - - protected ImportContainer createImportContainer( ClassFile parent ) - { - return new ClassImportContainer( parent ); - } - - private void addToChildren( Object parentInfo, JavaElement handle ) - { - ArrayList childrenList = (ArrayList) this.children.get( parentInfo ); - if ( childrenList == null ) - this.children.put( parentInfo, childrenList = new ArrayList( ) ); - childrenList.add( handle ); - } - - protected ImportDeclaration createImportDeclaration( ImportContainer parent, String name, boolean onDemand ) - { - try - { - Constructor c = ImportDeclaration.class - .getDeclaredConstructor( ImportContainer.class, String.class, boolean.class ); - c.setAccessible( true ); - ImportDeclaration dec = (ImportDeclaration) c.newInstance( parent, name, onDemand ); - return dec; - } - catch ( Exception e ) - { - Logger.debug( e ); - } - return null; - } - - @Override - public void acceptImport( int declarationStart, int declarationEnd, int nameSourceStart, int nameSourceEnd, - char[][] tokens, boolean onDemand, int modifiers ) - { - JavaElement parentHandle = (JavaElement) this.handleStack.peek( ); - if ( !( parentHandle.getElementType( ) == IJavaElement.CLASS_FILE ) ) - { - Assert.isTrue( false ); // Should not happen - } - - ClassFile parentCU = (ClassFile) parentHandle; - // create the import container and its info - if ( this.importContainer == null ) - { - this.importContainer = createImportContainer( parentCU ); - this.importContainerInfo = new ImportContainerInfo( ); - Object parentInfo = this.infoStack.peek( ); - addToChildren( parentInfo, this.importContainer ); - } - - String elementName = JavaModelManager.getJavaModelManager( ) - .intern( new String( CharOperation.concatWith( tokens, '.' ) ) ); - ImportDeclaration handle = createImportDeclaration( this.importContainer, elementName, onDemand ); - - ImportDeclarationElementInfo info = new ImportDeclarationElementInfo( ); - ReflectionUtils.invokeMethod( info, "setSourceRangeStart", int.class, declarationStart ); //$NON-NLS-1$ - ReflectionUtils.invokeMethod( info, "setSourceRangeEnd", int.class, declarationEnd ); //$NON-NLS-1$ - ReflectionUtils.invokeMethod( info, "setNameSourceStart", int.class, nameSourceStart ); //$NON-NLS-1$ - ReflectionUtils.invokeMethod( info, "setNameSourceEnd", int.class, nameSourceEnd ); //$NON-NLS-1$ - ReflectionUtils.invokeMethod( info, "setFlags", int.class, modifiers ); //$NON-NLS-1$ - - addToChildren( this.importContainerInfo, handle ); - manager.getTemporaryCache( ).put( handle, info ); - } -} diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/JavaDecompilerBufferManager.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/JavaDecompilerBufferManager.java index d956eee6..3a838208 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/JavaDecompilerBufferManager.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/JavaDecompilerBufferManager.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.editor; @@ -22,157 +19,119 @@ import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput; import org.eclipse.swt.widgets.Display; import org.sf.feeling.decompiler.util.Logger; -import org.sf.feeling.decompiler.util.MarkUtil; import org.sf.feeling.decompiler.util.UIUtil; /** * This class is a hack that replaces JDT BufferManager in order to * make addBuffer() and removeBuffer() accessible. */ -public class JavaDecompilerBufferManager extends BufferManager -{ - - public static void closeDecompilerBuffers( boolean all ) - { - BufferManager manager = BufferManager.getDefaultBufferManager( ); - if ( manager instanceof JavaDecompilerBufferManager ) - { - Enumeration enumeration = manager.getOpenBuffers( ); - while ( enumeration.hasMoreElements( ) ) - { - IBuffer buffer = (IBuffer) enumeration.nextElement( ); - ( (JavaDecompilerBufferManager) manager ).removeBuffer( buffer ); +public class JavaDecompilerBufferManager extends BufferManager { + + public static void closeDecompilerBuffers(boolean all) { + BufferManager manager = BufferManager.getDefaultBufferManager(); + if (manager instanceof JavaDecompilerBufferManager) { + Enumeration enumeration = manager.getOpenBuffers(); + while (enumeration.hasMoreElements()) { + IBuffer buffer = (IBuffer) enumeration.nextElement(); + ((JavaDecompilerBufferManager) manager).removeBuffer(buffer); } } } - public JavaDecompilerBufferManager( BufferManager manager ) - { - super( ); - synchronized ( BufferManager.class ) - { - Enumeration enumeration = manager.getOpenBuffers( ); - while ( enumeration.hasMoreElements( ) ) - { - IBuffer buffer = (IBuffer) enumeration.nextElement( ); - addBuffer( buffer ); + public JavaDecompilerBufferManager(BufferManager manager) { + super(); + synchronized (BufferManager.class) { + Enumeration enumeration = manager.getOpenBuffers(); + while (enumeration.hasMoreElements()) { + IBuffer buffer = (IBuffer) enumeration.nextElement(); + addBuffer(buffer); } BufferManager.DEFAULT_BUFFER_MANAGER = this; } } @Override - public void addBuffer( final IBuffer buffer ) - { - if ( buffer == null || buffer.getContents( ) == null ) - { - if ( buffer != null ) - { - delayAddBuffer( buffer ); + public void addBuffer(final IBuffer buffer) { + if (buffer == null || buffer.getContents() == null) { + if (buffer != null) { + delayAddBuffer(buffer); } return; } - super.addBuffer( buffer ); + super.addBuffer(buffer); } - private void delayAddBuffer( final IBuffer buffer ) - { - new Thread( ) { + private void delayAddBuffer(final IBuffer buffer) { + new Thread() { @Override - public void run( ) - { - if ( buffer.getContents( ) != null ) - { - try - { - Thread.sleep( 1 ); + public void run() { + if (buffer.getContents() != null) { + try { + Thread.sleep(1); + } catch (InterruptedException e) { + Logger.debug(e); } - catch ( InterruptedException e ) - { - Logger.debug( e ); - } - addBuffer( buffer ); + addBuffer(buffer); } } - }.start( ); + }.start(); } @Override - public void removeBuffer( IBuffer buffer ) - { - super.removeBuffer( buffer ); + public void removeBuffer(IBuffer buffer) { + super.removeBuffer(buffer); } @Override - public IBuffer getBuffer( final IOpenable owner ) - { - IBuffer buffer = super.getBuffer( owner ); - final IBuffer[] buffers = new IBuffer[]{ - buffer - }; - - if ( UIUtil.requestFromJavadocHover( ) ) - { - - if ( buffers[0] == null - || buffers[0].getContents( ) == null - || MarkUtil.containsMark( buffers[0].getContents( ) ) ) - { + public IBuffer getBuffer(final IOpenable owner) { + IBuffer buffer = super.getBuffer(owner); + final IBuffer[] buffers = new IBuffer[] { buffer }; + + if (UIUtil.requestFromJavadocHover()) { + + if (buffers[0] == null || buffers[0].getContents() == null) { buffers[0] = null; - Display.getDefault( ).asyncExec( new Runnable( ) { + Display.getDefault().asyncExec(new Runnable() { @Override - public void run( ) - { - JavaDecompilerClassFileEditor editor = UIUtil.getActiveEditor( ); - if ( editor != null && editor.getEditorInput( ) instanceof IClassFileEditorInput ) - { - IClassFile input = ( (IClassFileEditorInput) editor.getEditorInput( ) ).getClassFile( ); - if ( owner.equals( input ) ) - { - buffers[0] = editor.getClassBuffer( ); - JavaDecompilerBufferManager.this.addBuffer( buffers[0] ); + public void run() { + JavaDecompilerClassFileEditor editor = UIUtil.getActiveEditor(); + if (editor != null && editor.getEditorInput() instanceof IClassFileEditorInput) { + IClassFile input = ((IClassFileEditorInput) editor.getEditorInput()).getClassFile(); + if (owner.equals(input)) { + buffers[0] = editor.getClassBuffer(); + JavaDecompilerBufferManager.this.addBuffer(buffers[0]); } } } - } ); + }); } - } - else if ( UIUtil.requestCreateBuffer( ) ) - { - - JavaDecompilerClassFileEditor editor = UIUtil.getActiveEditor( ); - if ( editor != null && editor.getEditorInput( ) instanceof IClassFileEditorInput ) - { - IClassFile input = ( (IClassFileEditorInput) editor.getEditorInput( ) ).getClassFile( ); - if ( owner.equals( input ) ) - { - String content = editor.getDocumentProvider( ).getDocument( editor.getEditorInput( ) ).get( ); - if ( buffers[0] != null ) - { - if ( !content.equals( buffers[0].getContents( ) ) ) - buffers[0].setContents( content ); - } - else - { + } else if (UIUtil.requestCreateBuffer()) { + + JavaDecompilerClassFileEditor editor = UIUtil.getActiveEditor(); + if (editor != null && editor.getEditorInput() instanceof IClassFileEditorInput) { + IClassFile input = ((IClassFileEditorInput) editor.getEditorInput()).getClassFile(); + if (owner.equals(input)) { + String content = editor.getDocumentProvider().getDocument(editor.getEditorInput()).get(); + if (buffers[0] != null) { + if (!content.equals(buffers[0].getContents())) + buffers[0].setContents(content); + } else { ClassFile cf = (ClassFile) input; - IBuffer classBuffer = BufferManager.createBuffer( cf ); - classBuffer.setContents( content ); - editor.getBufferManager( ).addBuffer( classBuffer ); - - try - { - ClassFileSourceMap.updateSource( editor.getBufferManager( ), cf, content.toCharArray( ) ); - } - catch ( JavaModelException e ) - { - Logger.debug( e ); + IBuffer classBuffer = BufferManager.createBuffer(cf); + classBuffer.setContents(content); + editor.getBufferManager().addBuffer(classBuffer); + + try { + ClassFileSourceMap.updateSource(editor.getBufferManager(), cf, content.toCharArray()); + } catch (JavaModelException e) { + Logger.debug(e); } buffers[0] = classBuffer; - JavaDecompilerBufferManager.this.addBuffer( buffers[0] ); + JavaDecompilerBufferManager.this.addBuffer(buffers[0]); } } } 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 b399fbc5..4bffc423 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 @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.editor; @@ -39,7 +36,9 @@ import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IFindReplaceTarget; +import org.eclipse.jface.text.ITextViewerExtension5; import org.eclipse.jface.text.Region; import org.eclipse.jface.text.hyperlink.HyperlinkManager; import org.eclipse.jface.text.hyperlink.IHyperlink; @@ -55,7 +54,6 @@ import org.eclipse.search2.internal.ui.text.EditorAnnotationManager; import org.eclipse.search2.internal.ui.text.WindowAnnotationManager; import org.eclipse.swt.custom.StackLayout; -import org.eclipse.swt.custom.StyleRange; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseEvent; @@ -76,24 +74,24 @@ import org.eclipse.ui.texteditor.FindReplaceAction; import org.eclipse.ui.texteditor.GotoLineAction; import org.eclipse.ui.texteditor.IAbstractTextEditorHelpContextIds; +import org.eclipse.ui.texteditor.IDocumentProvider; import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.ui.texteditor.ITextEditorActionConstants; 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.postprocessing.LineReformatter; import org.sf.feeling.decompiler.util.ClassUtil; import org.sf.feeling.decompiler.util.DecompileUtil; -import org.sf.feeling.decompiler.util.DecompilerOutputUtil; import org.sf.feeling.decompiler.util.FileUtil; import org.sf.feeling.decompiler.util.Logger; -import org.sf.feeling.decompiler.util.MarkUtil; import org.sf.feeling.decompiler.util.ReflectionUtils; import org.sf.feeling.decompiler.util.UIUtil; -public class JavaDecompilerClassFileEditor extends ClassFileEditor -{ +public class JavaDecompilerClassFileEditor extends ClassFileEditor { public static final String ID = "org.sf.feeling.decompiler.ClassFileEditor"; //$NON-NLS-1$ @@ -103,667 +101,498 @@ public class JavaDecompilerClassFileEditor extends ClassFileEditor private int currentSourceMode = -1; private boolean selectionChange = false; private ISourceReference selectedElement = null; + private String decompilerType = null; - public ISourceReference getSelectedElement( ) - { + public ISourceReference getSelectedElement() { return selectedElement; } private DisassemblerSourceViewer fDisassemblerSourceViewer; private ByteCodeSourceViewer fByteCodeSourceViewer; - public JavaDecompilerClassFileEditor( ) - { - super( ); + public JavaDecompilerClassFileEditor() { + super(); } @Override - public ISelectionProvider getSelectionProvider( ) - { - if ( UIUtil.requestFromCopyOperation( ) ) - { - if ( JavaDecompilerPlugin.getDefault( ).getSourceMode( ) == JavaDecompilerPlugin.DISASSEMBLER_MODE - && fDisassemblerSourceViewer != null ) - { - return fDisassemblerSourceViewer.getSelectionProvider( ); - } - else if ( JavaDecompilerPlugin.getDefault( ).getSourceMode( ) == JavaDecompilerPlugin.BYTE_CODE_MODE - && fByteCodeSourceViewer != null ) - { - return fByteCodeSourceViewer.getSelectionProvider( ); + public ISelectionProvider getSelectionProvider() { + if (UIUtil.requestFromCopyOperation()) { + if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.DISASSEMBLER_MODE + && fDisassemblerSourceViewer != null) { + return fDisassemblerSourceViewer.getSelectionProvider(); + } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.BYTE_CODE_MODE + && fByteCodeSourceViewer != null) { + return fByteCodeSourceViewer.getSelectionProvider(); } } - return super.getSelectionProvider( ); + return super.getSelectionProvider(); } - private boolean doOpenBuffer( IEditorInput input, boolean force ) throws JavaModelException - { - IPreferenceStore prefs = JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ); - String decompilerType = prefs.getString( JavaDecompilerPlugin.DECOMPILER_TYPE ); - return doOpenBuffer( input, decompilerType, force ); + private boolean doOpenBuffer(IEditorInput input, boolean force) throws JavaModelException { + IPreferenceStore prefs = JavaDecompilerPlugin.getDefault().getPreferenceStore(); + 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 ); - return doOpenBuffer( input, type, force, reuseBuf, always ); + private boolean doOpenBuffer(IEditorInput input, String type, boolean force) throws JavaModelException { + IPreferenceStore prefs = JavaDecompilerPlugin.getDefault().getPreferenceStore(); + boolean reuseBuf = prefs.getBoolean(JavaDecompilerConstants.REUSE_BUFFER); + boolean always = prefs.getBoolean(JavaDecompilerConstants.IGNORE_EXISTING); + return doOpenBuffer(input, type, force, reuseBuf, always); } - private boolean doOpenBuffer( IEditorInput input, String type, boolean force, boolean reuseBuf, boolean always ) - throws JavaModelException - { - if ( UIUtil.isDebugPerspective( ) || JavaDecompilerPlugin.getDefault( ).isDebugMode( ) ) + private boolean doOpenBuffer(IEditorInput input, String type, boolean force, boolean reuseBuf, boolean always) + throws JavaModelException { + if (UIUtil.isDebugPerspective() || JavaDecompilerPlugin.getDefault().isDebugMode()) { reuseBuf = false; + } - if ( input instanceof IClassFileEditorInput ) - { + if (input instanceof IClassFileEditorInput) { boolean opened = false; - IClassFile cf = ( (IClassFileEditorInput) input ).getClassFile( ); - - String decompilerType = type; - String origSrc = cf.getSource( ); - if ( origSrc == null - || ( origSrc != null - && always - && ( !MarkUtil.containsMark( origSrc ) - || ( MarkUtil.containsMark( origSrc ) && !reuseBuf ) ) ) - || ( origSrc != null && !always && !MarkUtil.containsMark( origSrc ) && !reuseBuf ) - || debugOptionChange( origSrc ) - || force ) - { - DecompilerSourceMapper sourceMapper = SourceMapperFactory.getSourceMapper( decompilerType ); - char[] src = sourceMapper == null ? null : sourceMapper.findSource( cf.getType( ) ); - if ( src == null ) - { - if ( DecompilerType.FernFlower.equals( decompilerType ) ) - { - src = SourceMapperFactory.getSourceMapper( DecompilerType.FernFlower ) - .findSource( cf.getType( ) ); - } - else - { - IDecompilerDescriptor decompilerDescriptor = JavaDecompilerPlugin.getDefault( ) - .getDecompilerDescriptor( decompilerType ); - if ( decompilerDescriptor != null ) - { - src = decompilerDescriptor.getDecompilerSourceMapper( ).findSource( cf.getType( ) ); - } + IClassFile cf = ((IClassFileEditorInput) input).getClassFile(); + + this.decompilerType = type; + String origSrc = cf.getSource(); + if (origSrc == null || (origSrc != null && always) || (origSrc != null && !always && !reuseBuf) + || debugOptionChange(origSrc) || force) { + DecompilerSourceMapper sourceMapper = SourceMapperFactory.getSourceMapper(decompilerType); + char[] src = sourceMapper == null ? null : sourceMapper.findSource(cf.getType()); + if (src == null) { + IDecompilerDescriptor decompilerDescriptor = JavaDecompilerPlugin.getDefault() + .getDecompilerDescriptor(decompilerType); + if (decompilerDescriptor != null) { + src = decompilerDescriptor.getDecompilerSourceMapper().findSource(cf.getType()); } } - if ( src == null ) - { + if (src == null) { return false; } char[] markedSrc = src; - classBuffer = BufferManager.createBuffer( cf ); - classBuffer.setContents( markedSrc ); - getBufferManager( ).addBuffer( classBuffer ); + classBuffer = BufferManager.createBuffer(cf); + classBuffer.setContents(markedSrc); + getBufferManager().addBuffer(classBuffer); - sourceMapper.mapSource( cf.getType( ), markedSrc, true ); + sourceMapper.mapSourceSwitch(cf.getType(), markedSrc, true); - ClassFileSourceMap.updateSource( getBufferManager( ), (ClassFile) cf, markedSrc ); - - String content = new String( markedSrc ); - if ( MarkUtil.containsMark( content ) ) - { - if ( getSourceViewer( ) != null - && getSourceViewer( ).getTextWidget( ) != null - && !getSourceViewer( ).getTextWidget( ).isDisposed( ) ) - { - - if ( !getSourceViewer( ).getTextWidget( ).getText( ).equals( content ) ) - { - clearSelection( ); - } - } - } + ClassFileSourceMap.updateSource(getBufferManager(), (ClassFile) cf, markedSrc); opened = true; } - else - { - DecompileUtil.checkAndUpdateCopyright( this, cf, origSrc ); - } return opened; } return false; } - public void clearSelection( ) - { - if ( getSourceViewer( ) != null - && getSourceViewer( ).getTextWidget( ) != null - && !getSourceViewer( ).getTextWidget( ).isDisposed( ) ) - { - getSourceViewer( ).getTextWidget( ).setSelectionRange( 0, 0 ); + public void clearSelection() { + ISourceViewer sv = getSourceViewer(); + if (sv != null && sv.getTextWidget() != null && !sv.getTextWidget().isDisposed()) { + sv.getTextWidget().setSelectionRange(0, 0); } } @Override - public boolean isDirty( ) - { + public boolean isDirty() { return false; } @Override - protected void selectionChanged( ) - { + protected void selectionChanged() { selectionChange = true; - super.selectionChanged( ); + super.selectionChanged(); selectionChange = false; } - protected void setSelection( ISourceReference reference, boolean moveCursor ) - { - super.setSelection( reference, moveCursor ); + protected void setSelection(ISourceReference reference, boolean moveCursor) { + super.setSelection(reference, moveCursor); this.selectedElement = reference; - if ( fByteCodeSourceViewer != null ) - { - fByteCodeSourceViewer.setSelectionElement( reference ); + if (fByteCodeSourceViewer != null) { + fByteCodeSourceViewer.setSelectionElement(reference); } - if ( fDisassemblerSourceViewer != null ) - { - fDisassemblerSourceViewer.setSelectionElement( reference ); + if (fDisassemblerSourceViewer != null) { + fDisassemblerSourceViewer.setSelectionElement(reference); } } @Override - public void setHighlightRange( int offset, int length, boolean moveCursor ) - { - super.setHighlightRange( offset, length, moveCursor ); + public void setHighlightRange(int offset, int length, boolean moveCursor) { + super.setHighlightRange(offset, length, moveCursor); - if ( selectionChange ) + if (selectionChange) { return; + } - IClassFileEditorInput classFileEditorInput = (IClassFileEditorInput) getEditorInput( ); - final IClassFile file = classFileEditorInput.getClassFile( ); + IClassFileEditorInput classFileEditorInput = (IClassFileEditorInput) getEditorInput(); + final IClassFile file = classFileEditorInput.getClassFile(); - Display.getDefault( ).asyncExec( new Runnable( ) { + Display.getDefault().asyncExec(new Runnable() { @Override - public void run( ) - { - try - { - DecompileUtil.updateBuffer( file, file.getBuffer( ).getContents( ) ); - } - catch ( JavaModelException e ) - { - Logger.debug( e ); + public void run() { + try { + DecompileUtil.updateBuffer(file, file.getBuffer().getContents()); + } catch (JavaModelException e) { + Logger.debug(e); } } - } ); + }); - final StyledText widget = getSourceViewer( ).getTextWidget( ); - widget.getDisplay( ).asyncExec( new Runnable( ) { + final StyledText widget = getSourceViewer().getTextWidget(); + widget.getDisplay().asyncExec(new Runnable() { @Override - public void run( ) - { - if ( !widget.isDisposed( ) ) - { - if ( widget.getVerticalBar( ) != null ) - { - int selection = widget.getVerticalBar( ).getSelection( ); - - if ( selection > 0 - && selection < widget.getBounds( ).height / 2 - && widget.getLocationAtOffset( widget.getSelection( ).x ).y - + selection - + widget.getLineHeight( ) * 2 < widget.getBounds( ).height ) - { - ReflectionUtils.invokeMethod( widget, "scrollVertical", new Class[]{ //$NON-NLS-1$ - int.class, boolean.class - }, new Object[]{ - -selection, true - } ); + public void run() { + if (!widget.isDisposed()) { + if (widget.getVerticalBar() != null) { + int selection = widget.getVerticalBar().getSelection(); + + if (selection > 0 && selection < widget.getBounds().height / 2 + && widget.getLocationAtOffset(widget.getSelection().x).y + selection + + widget.getLineHeight() * 2 < widget.getBounds().height) { + ReflectionUtils.invokeMethod(widget, "scrollVertical", new Class[] { //$NON-NLS-1$ + int.class, boolean.class }, new Object[] { -selection, true }); } } } }; - } ); - } - - @Override - public void selectAndReveal( int start, int length ) - { - if ( UIUtil.requestFromShowMatch( ) ) - { - String src = this.getDocumentProvider( ).getDocument( this.getEditorInput( ) ).get( ); - if ( MarkUtil.containsSourceMark( src ) ) - { - if ( src.indexOf( "\r\n" ) != -1 ) //$NON-NLS-1$ - { - super.selectAndReveal( start + MarkUtil.getMark( src ).length( ) - 1, length ); - } - else - { - super.selectAndReveal( start + MarkUtil.getMark( src ).length( ), length ); - } - } - else - { - super.selectAndReveal( start, length ); - } - } - else - { - super.selectAndReveal( start, length ); - } + }); } - public static boolean debugOptionChange( String source ) - { - return isDebug( source ) != ClassUtil.isDebug( ); + public static boolean debugOptionChange(String source) { + return isDebug(source) != ClassUtil.isDebug(); } - public static boolean isDebug( String source ) - { - if ( source == null ) + /** + * Checks if the decompiled source code contains line numbers as comment. + * + * @param source + * @return + */ + public static boolean isDebug(String source) { + if (source == null) { return false; - Pattern pattern = Pattern.compile( "/\\*\\s*\\d+\\s*\\*/" ); //$NON-NLS-1$ - Matcher matcher = pattern.matcher( source ); - return matcher.find( ) || source.indexOf( DecompilerOutputUtil.NO_LINE_NUMBER ) != -1; + } + + // Scan for line number comments at the beginning of the line in this + // format: /* 146 */ + Pattern pattern = Pattern.compile("/\\*\\s*\\d+\\s*\\*/"); //$NON-NLS-1$ + Matcher matcher = pattern.matcher(source); + return matcher.find() || source.indexOf(LineReformatter.NO_LINE_NUMBER) != -1; } - public IBuffer getClassBuffer( ) - { + public IBuffer getClassBuffer() { return classBuffer; } /** - * Sets edditor input only if buffer was actually opened. + * Sets editor input only if buffer was actually opened. * - * @param force - * if true initialize no matter what + * @param force if true initialize no matter what */ - public void doSetInput( boolean force ) - { - IEditorInput input = getEditorInput( ); - try - { - if ( doOpenBuffer( input, force ) ) - { - super.doSetInput( input ); + public void doSetInput(boolean force) { + IEditorInput input = getEditorInput(); + try { + if (doOpenBuffer(input, force)) { + super.doSetInput(input); } - } - catch ( Exception e ) - { - JavaDecompilerPlugin.logError( e, "" ); //$NON-NLS-1$ + } catch (Exception e) { + JavaDecompilerPlugin.logError(e, ""); //$NON-NLS-1$ } - handleMarkLink( ); + handleMarkLink(); } - public void doSetInput( String type, boolean force ) - { - IEditorInput input = getEditorInput( ); - try - { - if ( doOpenBuffer( input, type, force ) ) - { - super.doSetInput( input ); + public void doSetInput(String type, boolean force) { + IEditorInput input = getEditorInput(); + try { + if (doOpenBuffer(input, type, force)) { + super.doSetInput(input); } - } - catch ( Exception e ) - { - JavaDecompilerPlugin.logError( e, "" ); //$NON-NLS-1$ + } catch (Exception e) { + JavaDecompilerPlugin.logError(e, ""); //$NON-NLS-1$ } - handleMarkLink( ); + handleMarkLink(); } @Override - protected void doSetInput( IEditorInput input ) throws CoreException - { - JavaDecompilerPlugin.getDefault( ).getDecompileCount( ).getAndIncrement( ); - if ( input instanceof IFileEditorInput ) - { - String filePath = UIUtil.getPathLocation( ( (IFileEditorInput) input ).getStorage( ).getFullPath( ) ); - if ( filePath == null || !new File( filePath ).exists( ) ) - { - super.doSetInput( input ); - } - else - { - doSetInput( - new DecompilerClassEditorInput( EFS.getLocalFileSystem( ).getStore( new Path( filePath ) ) ) ); + protected void doSetInput(IEditorInput input) throws CoreException { + if (input instanceof IFileEditorInput) { + String filePath = UIUtil.getPathLocation(((IFileEditorInput) input).getStorage().getFullPath()); + if (filePath == null || !new File(filePath).exists()) { + super.doSetInput(input); + } else { + doSetInput(new DecompilerClassEditorInput(EFS.getLocalFileSystem().getStore(new Path(filePath)))); } - } - else if ( input instanceof FileStoreEditorInput ) - { + } else if (input instanceof FileStoreEditorInput) { FileStoreEditorInput storeInput = (FileStoreEditorInput) input; - IPreferenceStore prefs = JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ); - String decompilerType = prefs.getString( JavaDecompilerPlugin.DECOMPILER_TYPE ); - String source = DecompileUtil.decompiler( storeInput, decompilerType ); - - if ( source != null ) - { - String packageName = DecompileUtil.getPackageName( source ); - String classFullName = packageName == null ? storeInput.getName( ) - : packageName - + "." //$NON-NLS-1$ - + storeInput.getName( ).replaceAll( "(?i)\\.class", //$NON-NLS-1$ - "" ); //$NON-NLS-1$ - - File file = new File( System.getProperty( "java.io.tmpdir" ), //$NON-NLS-1$ - storeInput.getName( ).replaceAll( "(?i)\\.class", //$NON-NLS-1$ - System.currentTimeMillis( ) + ".java" ) ); //$NON-NLS-1$ - FileUtil.writeToFile( file, source, ResourcesPlugin.getEncoding( ) ); - file.deleteOnExit( ); + IPreferenceStore prefs = JavaDecompilerPlugin.getDefault().getPreferenceStore(); + String decompilerType = prefs.getString(JavaDecompilerConstants.DECOMPILER_TYPE); + String source = DecompileUtil.decompileInput(storeInput, decompilerType); + + if (source != null) { + String packageName = DecompileUtil.getPackageName(source); + String classFullName; + if (packageName == null) { + classFullName = storeInput.getName(); + } else { + classFullName = packageName + "." //$NON-NLS-1$ + + storeInput.getName().replaceAll("(?i)\\.class", ""); //$NON-NLS-1$ $NON-NLS-2$ + } + + File file = new File(System.getProperty("java.io.tmpdir"), //$NON-NLS-1$ + storeInput.getName().replaceAll("(?i)\\.class", //$NON-NLS-1$ + System.currentTimeMillis() + ".java")); //$NON-NLS-1$ + FileUtil.writeToFile(file, source, ResourcesPlugin.getEncoding()); + file.deleteOnExit(); DecompilerClassEditorInput editorInput = new DecompilerClassEditorInput( - EFS.getLocalFileSystem( ).getStore( new Path( file.getAbsolutePath( ) ) ) ); - editorInput.setToolTipText( classFullName ); - - IEditorPart editor = PlatformUI.getWorkbench( ).getActiveWorkbenchWindow( ).getActivePage( ).openEditor( - editorInput, - "org.eclipse.jdt.ui.CompilationUnitEditor" ); //$NON-NLS-1$ - try - { - ReflectionUtils.invokeMethod( editor, - "setPartName", //$NON-NLS-1$ - new Class[]{ - String.class - }, - new String[]{ - storeInput.getName( ) - } ); - - ReflectionUtils.invokeMethod( editor, - "setTitleImage", //$NON-NLS-1$ - new Class[]{ - Image.class - }, - new Object[]{ - JavaDecompilerPlugin.getImageDescriptor( "icons/decompiler.png" ) //$NON-NLS-1$ - .createImage( ) - } ); - - ReflectionUtils.setFieldValue( editor, - "fIsEditingDerivedFileAllowed", //$NON-NLS-1$ - Boolean.valueOf( false ) ); - } - catch ( Exception e ) - { - JavaDecompilerPlugin.logError( e, "" ); //$NON-NLS-1$ + EFS.getLocalFileSystem().getStore(new Path(file.getAbsolutePath()))); + editorInput.setToolTipText(classFullName); + + IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() + .openEditor(editorInput, "org.eclipse.jdt.ui.CompilationUnitEditor"); //$NON-NLS-1$ + try { + ReflectionUtils.invokeMethod(editor, "setPartName", //$NON-NLS-1$ + new Class[] { String.class }, new String[] { getPartTitle(storeInput.getName()) }); + + ReflectionUtils.invokeMethod(editor, "setTitleImage", //$NON-NLS-1$ + new Class[] { Image.class }, + new Object[] { JavaDecompilerPlugin.getImageDescriptor("icons/decompiler.png") //$NON-NLS-1$ + .createImage() }); + + ReflectionUtils.setFieldValue(editor, "fIsEditingDerivedFileAllowed", //$NON-NLS-1$ + Boolean.valueOf(false)); + } catch (Exception e) { + JavaDecompilerPlugin.logError(e, ""); //$NON-NLS-1$ } } - Display.getDefault( ).asyncExec( new Runnable( ) { + Display.getDefault().asyncExec(new Runnable() { @Override - public void run( ) - { - JavaDecompilerClassFileEditor.this.getEditorSite( ) - .getPage( ) - .closeEditor( JavaDecompilerClassFileEditor.this, false ); + public void run() { + JavaDecompilerClassFileEditor.this.getEditorSite().getPage() + .closeEditor(JavaDecompilerClassFileEditor.this, false); } - } ); + }); - throw new CoreException( new Status( 8, - JavaDecompilerPlugin.PLUGIN_ID, - 1, - "", //$NON-NLS-1$ - null ) ); - } - else - { - if ( input instanceof InternalClassFileEditorInput ) - { + throw new CoreException(new Status(8, JavaDecompilerConstants.PLUGIN_ID, 1, "", //$NON-NLS-1$ + null)); + } else { + if (input instanceof InternalClassFileEditorInput) { InternalClassFileEditorInput classInput = (InternalClassFileEditorInput) input; - if ( classInput.getClassFile( ).getParent( ) instanceof PackageFragment ) - { - doOpenBuffer( input, false ); - } - else - { - IPath relativePath = classInput.getClassFile( ).getParent( ).getPath( ); - String location = UIUtil.getPathLocation( relativePath ); - if ( !( FileUtil.isZipFile( location ) || FileUtil.isZipFile( relativePath.toOSString( ) ) ) ) - { - String filePath = UIUtil.getPathLocation( classInput.getClassFile( ).getPath( ) ); - if ( filePath != null ) - { + if (classInput.getClassFile().getParent() instanceof PackageFragment) { + doOpenBuffer(input, false); + } else { + IPath relativePath = classInput.getClassFile().getParent().getPath(); + String location = UIUtil.getPathLocation(relativePath); + if (!(FileUtil.isZipFile(location) || FileUtil.isZipFile(relativePath.toOSString()))) { + String filePath = UIUtil.getPathLocation(classInput.getClassFile().getPath()); + if (filePath != null) { DecompilerClassEditorInput editorInput = new DecompilerClassEditorInput( - EFS.getLocalFileSystem( ).getStore( new Path( filePath ) ) ); - doSetInput( editorInput ); - } - else - { - doSetInput( new DecompilerClassEditorInput( - EFS.getLocalFileSystem( ).getStore( classInput.getClassFile( ).getPath( ) ) ) ); + EFS.getLocalFileSystem().getStore(new Path(filePath))); + doSetInput(editorInput); + } else { + doSetInput(new DecompilerClassEditorInput( + EFS.getLocalFileSystem().getStore(classInput.getClassFile().getPath()))); } return; } } } - try - { - doOpenBuffer( input, false ); - } - catch ( JavaModelException e ) - { + try { + doOpenBuffer(input, false); + } catch (JavaModelException e) { IClassFileEditorInput classFileEditorInput = (IClassFileEditorInput) input; - IClassFile file = classFileEditorInput.getClassFile( ); - - 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( ) ); - try - { - FileOutputStream fos = new FileOutputStream( classFile ); - fos.write( file.getBytes( ) ); - fos.close( ); - - doSetInput( new DecompilerClassEditorInput( - EFS.getLocalFileSystem( ).getStore( new Path( classFile.getAbsolutePath( ) ) ) ) ); - classFile.delete( ); + IClassFile file = classFileEditorInput.getClassFile(); + + if (file.getSourceRange() == null && file.getBytes() != null) { + if (ClassUtil.isClassFile(file.getBytes())) { + File classFile = new File(JavaDecompilerPlugin.getDefault().getPreferenceStore() + .getString(JavaDecompilerConstants.TEMP_DIR), file.getElementName()); + try { + try (FileOutputStream fos = new FileOutputStream(classFile)) { + fos.write(file.getBytes()); + } + + doSetInput(new DecompilerClassEditorInput( + EFS.getLocalFileSystem().getStore(new Path(classFile.getAbsolutePath())))); + classFile.delete(); return; - } - catch ( IOException e1 ) - { - JavaDecompilerPlugin.logError( e, "" ); //$NON-NLS-1$ - } - finally - { - if ( classFile != null && classFile.exists( ) ) - classFile.delete( ); + } catch (IOException e1) { + JavaDecompilerPlugin.logError(e1, ""); //$NON-NLS-1$ + } finally { + if (classFile != null && classFile.exists()) { + classFile.delete(); + } } } } } - super.doSetInput( input ); + super.doSetInput(input); } - handleMarkLink( ); + handleMarkLink(); } - public void createPartControl( Composite parent ) - { - super.createPartControl( parent ); - showSource( ); + protected void setPartName(String partName) { + super.setPartName(getPartTitle(partName)); } - private void handleMarkLink( ) - { - final int index = this.getDocumentProvider( ).getDocument( getEditorInput( ) ).get( ).indexOf( "://" ); //$NON-NLS-1$ - if ( index != -1 ) - { - Display.getDefault( ).asyncExec( new Runnable( ) { + private String getPartTitle(String title) { + if (decompilerType == null || title == null) { + return title; + } + if (title.endsWith("]")) { + return title; + } + return title + " [" + decompilerType + "]"; + } - @Override - public void run( ) - { - updateMatchAnnonation( ); - handleMarkLink( index ); - } - } ); + public void createPartControl(Composite parent) { + super.createPartControl(parent); + showSource(); + } + + private void handleMarkLink() { + IDocumentProvider documentProvider = this.getDocumentProvider(); + if (documentProvider != null) { + IDocument doc = documentProvider.getDocument(getEditorInput()); + final int index = doc.get().indexOf("://"); //$NON-NLS-1$ + if (index != -1) { + Display.getDefault().asyncExec(new Runnable() { + + @Override + public void run() { + updateMatchAnnonation(); + handleMarkLink(index); + } + }); + } } } - protected JavaDecompilerBufferManager getBufferManager( ) - { + protected JavaDecompilerBufferManager getBufferManager() { JavaDecompilerBufferManager manager; - BufferManager defManager = BufferManager.getDefaultBufferManager( ); - if ( defManager instanceof JavaDecompilerBufferManager ) + BufferManager defManager = BufferManager.getDefaultBufferManager(); + if (defManager instanceof JavaDecompilerBufferManager) manager = (JavaDecompilerBufferManager) defManager; else - manager = new JavaDecompilerBufferManager( defManager ); + manager = new JavaDecompilerBufferManager(defManager); return manager; } - public void notifyPropertiesChange( ) - { - ReflectionUtils.invokeMethod( this.getViewer( ), - "fireSelectionChanged", //$NON-NLS-1$ - new Class[]{ - SelectionChangedEvent.class - }, - new Object[]{ - new SelectionChangedEvent( (ISelectionProvider) this.getViewer( ), new StructuredSelection( ) ) - } ); + public void notifyPropertiesChange() { + ReflectionUtils.invokeMethod(this.getViewer(), "fireSelectionChanged", //$NON-NLS-1$ + new Class[] { SelectionChangedEvent.class }, new Object[] { + new SelectionChangedEvent((ISelectionProvider) this.getViewer(), new StructuredSelection()) }); } - private void handleMarkLink( final int index ) - { - ISourceViewer sourceViewer = getSourceViewer( ); - if ( sourceViewer == null ) + private void handleMarkLink(final int index) { + ISourceViewer sourceViewer = getSourceViewer(); + if (sourceViewer == null) { return; + } - final StyledText text = sourceViewer.getTextWidget( ); - if ( text.isDisposed( ) ) - { + final StyledText text = sourceViewer.getTextWidget(); + if (text.isDisposed()) { return; } - IHyperlinkDetector[] descriptors = getSourceViewerConfiguration( ).getHyperlinkDetectors( sourceViewer ); - for ( int i = 0; i < descriptors.length; i++ ) - { - final IHyperlink[] links = descriptors[i].detectHyperlinks( sourceViewer, new Region( index, 0 ), true ); + IHyperlinkDetector[] descriptors = getSourceViewerConfiguration().getHyperlinkDetectors(sourceViewer); + for (int i = 0; i < descriptors.length; i++) { + final IHyperlink[] links = descriptors[i].detectHyperlinks(sourceViewer, new Region(index, 0), true); - if ( links != null && links.length > 0 && links[0] instanceof URLHyperlink ) - { + if (links != null && links.length > 0 && links[0] instanceof URLHyperlink) { final IHyperlinkPresenter fHyperlinkPresenter = (IHyperlinkPresenter) ReflectionUtils - .getFieldValue( sourceViewer, "fHyperlinkPresenter" ); //$NON-NLS-1$ + .getFieldValue(sourceViewer, "fHyperlinkPresenter"); //$NON-NLS-1$ final HyperlinkManager fHyperlinkManager = (HyperlinkManager) ReflectionUtils - .getFieldValue( sourceViewer, "fHyperlinkManager" ); //$NON-NLS-1$ + .getFieldValue(sourceViewer, "fHyperlinkManager"); //$NON-NLS-1$ - if ( fHyperlinkPresenter == null || fHyperlinkManager == null ) + if (fHyperlinkPresenter == null || fHyperlinkManager == null) { continue; + } - fHyperlinkPresenter.showHyperlinks( links ); - - updateLinkRanges( links ); + fHyperlinkPresenter.showHyperlinks(links); final boolean[] flags = new boolean[1]; - if ( !text.isDisposed( ) && paintListener != null ) - { - text.removePaintListener( paintListener ); + if (!text.isDisposed() && paintListener != null) { + text.removePaintListener(paintListener); } - paintListener = new PaintListener( ) { + paintListener = new PaintListener() { - private Boolean isActive( final HyperlinkManager fHyperlinkManager ) - { - return (Boolean) ReflectionUtils.getFieldValue( fHyperlinkManager, "fActive" );//$NON-NLS-1$ + private Boolean isActive(final HyperlinkManager fHyperlinkManager) { + return (Boolean) ReflectionUtils.getFieldValue(fHyperlinkManager, "fActive");//$NON-NLS-1$ } - private void updateHyperlinks( final IHyperlink[] links, - final IHyperlinkPresenter fHyperlinkPresenter ) - { - if ( ReflectionUtils.getFieldValue( fHyperlinkPresenter, "fTextViewer" ) != null ) //$NON-NLS-1$ - { - updateLinkRanges( links ); - } - } - - private void addPaintListener( final StyledText text ) - { - Display.getDefault( ).asyncExec( new Runnable( ) { + private void addPaintListener(final StyledText text) { + Display.getDefault().asyncExec(new Runnable() { @Override - public void run( ) - { - if ( !text.isDisposed( ) && paintListener != null ) - { - text.removePaintListener( paintListener ); - text.addPaintListener( paintListener ); + public void run() { + if (!text.isDisposed() && paintListener != null) { + text.removePaintListener(paintListener); + text.addPaintListener(paintListener); } } - } ); + }); } @Override - public void paintControl( PaintEvent e ) - { - if ( flags[0] ) - { + public void paintControl(PaintEvent e) { + if (flags[0]) { return; } flags[0] = true; - Display.getDefault( ).asyncExec( new Runnable( ) { + Display.getDefault().asyncExec(new Runnable() { @Override - public void run( ) - { - boolean fActive = isActive( fHyperlinkManager ); - if ( !fActive && !text.isDisposed( ) ) - { - text.removePaintListener( paintListener ); - updateHyperlinks( links, fHyperlinkPresenter ); - updateMatchAnnonation( ); - addPaintListener( text ); + public void run() { + boolean fActive = isActive(fHyperlinkManager); + if (!fActive && !text.isDisposed()) { + text.removePaintListener(paintListener); + updateMatchAnnonation(); + addPaintListener(text); } flags[0] = false; } - } ); + }); } }; - text.addPaintListener( paintListener ); + text.addPaintListener(paintListener); - if ( mouseAdapter != null ) - { - text.removeMouseListener( mouseAdapter ); + if (mouseAdapter != null) { + text.removeMouseListener(mouseAdapter); } - mouseAdapter = new MouseAdapter( ) { + mouseAdapter = new MouseAdapter() { @Override - public void mouseUp( MouseEvent e ) - { + public void mouseUp(MouseEvent e) { - int offset = text.getCaretOffset( ); - if ( offset == -1 ) + int offset = getCaretModelOffset(text); + if (offset == -1) { return; - for ( int j = 0; j < links.length; j++ ) - { - int linkOffset = links[j].getHyperlinkRegion( ).getOffset( ); - int linkLength = links[j].getHyperlinkRegion( ).getLength( ); - if ( offset >= linkOffset && offset < linkOffset + linkLength ) - { - if ( links[j] instanceof URLHyperlink ) - { - String url = ( (URLHyperlink) links[j] ).getURLString( ); - UIUtil.openBrowser( url ); + } + for (int j = 0; j < links.length; j++) { + int linkOffset = links[j].getHyperlinkRegion().getOffset(); + int linkLength = links[j].getHyperlinkRegion().getLength(); + if (offset >= linkOffset && offset < linkOffset + linkLength) { + if (links[j] instanceof URLHyperlink) { + String url = ((URLHyperlink) links[j]).getURLString(); + UIUtil.openBrowser(url); } return; } @@ -771,467 +600,359 @@ public void mouseUp( MouseEvent e ) } }; - text.addMouseListener( mouseAdapter ); + text.addMouseListener(mouseAdapter); } } } - private void updateLinkRanges( final IHyperlink[] links ) - { - String content = getDocumentProvider( ).getDocument( getEditorInput( ) ).get( ); - - String mark = MarkUtil.getMark( content ); - String ad = mark.replaceAll( "/(\\*)+", "" ) //$NON-NLS-1$ //$NON-NLS-2$ - .replaceAll( "(\\*)+/", "" ) //$NON-NLS-1$ //$NON-NLS-2$ - .trim( ); - int length = ad.length( ); - int offset = mark.indexOf( ad ); - - StyledText textWidget = getViewer( ).getTextWidget( ); - StyleRange textRange = UIUtil.getAdTextStyleRange( textWidget, offset, length ); - if ( textRange != null ) - { - textWidget.setStyleRange( textRange ); - } - - for ( int j = 0; j < links.length; j++ ) - { - IHyperlink link = links[j]; - StyleRange linkRange = UIUtil.getAdLinkStyleRange( textWidget, - link.getHyperlinkRegion( ).getOffset( ), - link.getHyperlinkRegion( ).getLength( ) ); - if ( linkRange != null ) - { - getViewer( ).getTextWidget( ).setStyleRange( linkRange ); - } + /** + * Returns the absolute offset of the caret, which includes all characters in + * collapsed code for the given text. + * + * getCaretOffset returns actual offset that user sees not including characters + * collapsed code. See https://stackoverflow.com/a/42828319 + * + * @param text to get caret position from + * @return model (absolute) offset of caret + */ + private int getCaretModelOffset(final StyledText text) { + int offset; + ISourceViewer sourceViewer = getSourceViewer(); + if (sourceViewer instanceof ITextViewerExtension5) { + ITextViewerExtension5 extension = (ITextViewerExtension5) sourceViewer; + offset = extension.widgetOffset2ModelOffset(text.getCaretOffset()); + } else { + int visibleRegionOffset = sourceViewer.getVisibleRegion().getOffset(); + offset = visibleRegionOffset + text.getCaretOffset(); } + return offset; } - private void updateMatchAnnonation( ) - { - WindowAnnotationManager mgr = (WindowAnnotationManager) ReflectionUtils.invokeMethod( AnnotationManagers.class, + private void updateMatchAnnonation() { + WindowAnnotationManager mgr = (WindowAnnotationManager) ReflectionUtils.invokeMethod(AnnotationManagers.class, "getWindowAnnotationManager", //$NON-NLS-1$ - new Class[]{ - IWorkbenchWindow.class - }, - new Object[]{ - PlatformUI.getWorkbench( ).getActiveWorkbenchWindow( ) - } ); - if ( mgr == null ) + new Class[] { IWorkbenchWindow.class }, + new Object[] { PlatformUI.getWorkbench().getActiveWorkbenchWindow() }); + if (mgr == null) { return; + } Map fAnnotationManagers = (Map) ReflectionUtils - .getFieldValue( mgr, "fAnnotationManagers" ); //$NON-NLS-1$ - if ( fAnnotationManagers == null ) + .getFieldValue(mgr, "fAnnotationManagers"); //$NON-NLS-1$ + if (fAnnotationManagers == null) { return; - EditorAnnotationManager amgr = fAnnotationManagers.get( JavaDecompilerClassFileEditor.this ); - if ( amgr == null ) + } + EditorAnnotationManager amgr = fAnnotationManagers.get(JavaDecompilerClassFileEditor.this); + if (amgr == null) { return; - ReflectionUtils.invokeMethod( amgr, - "removeAllAnnotations", //$NON-NLS-1$ - new Class[0], - new Object[0] ); + } + ReflectionUtils.invokeMethod(amgr, "removeAllAnnotations"); } @Override - public String[] collectContextMenuPreferencePages( ) - { - String[] inheritedPages = super.collectContextMenuPreferencePages( ); + 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 ); + System.arraycopy(inheritedPages, 0, result, length, inheritedPages.length); return result; } @Override - protected void createActions( ) - { - super.createActions( ); + protected void createActions() { + super.createActions(); - setAction( ITextEditorActionConstants.COPY, null ); + setAction(ITextEditorActionConstants.COPY, null); final String BUNDLE_FOR_CONSTRUCTED_KEYS = "org.eclipse.ui.texteditor.ConstructedEditorMessages";//$NON-NLS-1$ - ResourceBundle fgBundleForConstructedKeys = ResourceBundle.getBundle( BUNDLE_FOR_CONSTRUCTED_KEYS ); - final IAction copyAction = new Action( fgBundleForConstructedKeys.getString( "Editor.Copy.label" ) ) { //$NON-NLS-1$ + ResourceBundle fgBundleForConstructedKeys = ResourceBundle.getBundle(BUNDLE_FOR_CONSTRUCTED_KEYS); + final IAction copyAction = new Action(fgBundleForConstructedKeys.getString("Editor.Copy.label")) { //$NON-NLS-1$ @Override - public void run( ) - { - if ( JavaDecompilerPlugin.getDefault( ).getSourceMode( ) == JavaDecompilerPlugin.SOURCE_MODE ) - { - ( (SourceViewer) JavaDecompilerClassFileEditor.this.getSourceViewer( ) ).getTextWidget( ).copy( ); - } - else if ( JavaDecompilerPlugin.getDefault( ).getSourceMode( ) == JavaDecompilerPlugin.DISASSEMBLER_MODE - && fDisassemblerSourceViewer != null - && fDisassemblerSourceViewer.getTextWidget( ) != null ) - { - JavaDecompilerClassFileEditor.this.fDisassemblerSourceViewer.getTextWidget( ).copy( ); - } - else if ( JavaDecompilerPlugin.getDefault( ).getSourceMode( ) == JavaDecompilerPlugin.BYTE_CODE_MODE - && fByteCodeSourceViewer != null - && fByteCodeSourceViewer.getTextWidget( ) != null ) - { - JavaDecompilerClassFileEditor.this.fByteCodeSourceViewer.getTextWidget( ).copy( ); + public void run() { + if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.SOURCE_MODE) { + ((SourceViewer) JavaDecompilerClassFileEditor.this.getSourceViewer()).getTextWidget().copy(); + } else if (JavaDecompilerPlugin.getDefault() + .getSourceMode() == JavaDecompilerConstants.DISASSEMBLER_MODE + && fDisassemblerSourceViewer != null && fDisassemblerSourceViewer.getTextWidget() != null) { + JavaDecompilerClassFileEditor.this.fDisassemblerSourceViewer.getTextWidget().copy(); + } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.BYTE_CODE_MODE + && fByteCodeSourceViewer != null && fByteCodeSourceViewer.getTextWidget() != null) { + JavaDecompilerClassFileEditor.this.fByteCodeSourceViewer.getTextWidget().copy(); } } }; - copyAction.setActionDefinitionId( IWorkbenchCommandConstants.EDIT_COPY ); - setAction( ITextEditorActionConstants.COPY, copyAction ); + copyAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_COPY); + setAction(ITextEditorActionConstants.COPY, copyAction); - setAction( ITextEditorActionConstants.SELECT_ALL, null ); - final IAction selectAllAction = new Action( fgBundleForConstructedKeys.getString( "Editor.SelectAll.label" ) ) { //$NON-NLS-1$ + setAction(ITextEditorActionConstants.SELECT_ALL, null); + final IAction selectAllAction = new Action(fgBundleForConstructedKeys.getString("Editor.SelectAll.label")) { //$NON-NLS-1$ @Override - public void run( ) - { - if ( JavaDecompilerPlugin.getDefault( ).getSourceMode( ) == JavaDecompilerPlugin.SOURCE_MODE ) - { - ( (SourceViewer) JavaDecompilerClassFileEditor.this.getSourceViewer( ) ).getTextWidget( ) - .selectAll( ); - } - else if ( JavaDecompilerPlugin.getDefault( ).getSourceMode( ) == JavaDecompilerPlugin.DISASSEMBLER_MODE - && fDisassemblerSourceViewer != null - && fDisassemblerSourceViewer.getTextWidget( ) != null ) - { - JavaDecompilerClassFileEditor.this.fDisassemblerSourceViewer.getTextWidget( ).selectAll( ); - } - else if ( JavaDecompilerPlugin.getDefault( ).getSourceMode( ) == JavaDecompilerPlugin.BYTE_CODE_MODE - && fByteCodeSourceViewer != null - && fByteCodeSourceViewer.getTextWidget( ) != null ) - { - JavaDecompilerClassFileEditor.this.fByteCodeSourceViewer.getTextWidget( ).selectAll( ); + public void run() { + if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.SOURCE_MODE) { + ((SourceViewer) JavaDecompilerClassFileEditor.this.getSourceViewer()).getTextWidget().selectAll(); + } else if (JavaDecompilerPlugin.getDefault() + .getSourceMode() == JavaDecompilerConstants.DISASSEMBLER_MODE + && fDisassemblerSourceViewer != null && fDisassemblerSourceViewer.getTextWidget() != null) { + JavaDecompilerClassFileEditor.this.fDisassemblerSourceViewer.getTextWidget().selectAll(); + } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.BYTE_CODE_MODE + && fByteCodeSourceViewer != null && fByteCodeSourceViewer.getTextWidget() != null) { + JavaDecompilerClassFileEditor.this.fByteCodeSourceViewer.getTextWidget().selectAll(); } } }; - selectAllAction.setActionDefinitionId( IWorkbenchCommandConstants.EDIT_SELECT_ALL ); - setAction( ITextEditorActionConstants.SELECT_ALL, copyAction ); - - setAction( ITextEditorActionConstants.FIND, null ); - FindReplaceAction findAction = new FindReplaceAction( fgBundleForConstructedKeys, - "Editor.FindReplace.", //$NON-NLS-1$ - this ) { - - public void run( ) - { - if ( JavaDecompilerPlugin.getDefault( ).getSourceMode( ) == JavaDecompilerPlugin.SOURCE_MODE ) - { - ReflectionUtils.setFieldValue( this, - "fTarget", //$NON-NLS-1$ + selectAllAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_SELECT_ALL); + setAction(ITextEditorActionConstants.SELECT_ALL, copyAction); + + setAction(ITextEditorActionConstants.FIND, null); + FindReplaceAction findAction = new FindReplaceAction(fgBundleForConstructedKeys, "Editor.FindReplace.", //$NON-NLS-1$ + this) { + + public void run() { + if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.SOURCE_MODE) { + ReflectionUtils.setFieldValue(this, "fTarget", //$NON-NLS-1$ (IFindReplaceTarget) JavaDecompilerClassFileEditor.this - .getAdapter( IFindReplaceTarget.class ) ); + .getAdapter(IFindReplaceTarget.class)); - } - else if ( JavaDecompilerPlugin.getDefault( ).getSourceMode( ) == JavaDecompilerPlugin.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 - && fByteCodeSourceViewer != null ) - { - ReflectionUtils.setFieldValue( this, - "fTarget", //$NON-NLS-1$ - (IFindReplaceTarget) fByteCodeSourceViewer.getAdapter( IFindReplaceTarget.class ) ); + } 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() == JavaDecompilerConstants.BYTE_CODE_MODE + && fByteCodeSourceViewer != null) { + ReflectionUtils.setFieldValue(this, "fTarget", //$NON-NLS-1$ + (IFindReplaceTarget) fByteCodeSourceViewer.getAdapter(IFindReplaceTarget.class)); } - super.run( ); + super.run(); } }; - findAction.setHelpContextId( IAbstractTextEditorHelpContextIds.FIND_ACTION ); - findAction.setActionDefinitionId( IWorkbenchCommandConstants.EDIT_FIND_AND_REPLACE ); - setAction( ITextEditorActionConstants.FIND, findAction ); - - setAction( ITextEditorActionConstants.FIND_NEXT, null ); - FindNextAction findNextAction = new FindNextAction( fgBundleForConstructedKeys, - "Editor.FindNext.", //$NON-NLS-1$ - this, - true ) { - - public void run( ) - { - if ( JavaDecompilerPlugin.getDefault( ).getSourceMode( ) == JavaDecompilerPlugin.SOURCE_MODE ) - { - ReflectionUtils.setFieldValue( this, - "fTarget", //$NON-NLS-1$ + findAction.setHelpContextId(IAbstractTextEditorHelpContextIds.FIND_ACTION); + findAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_FIND_AND_REPLACE); + setAction(ITextEditorActionConstants.FIND, findAction); + + setAction(ITextEditorActionConstants.FIND_NEXT, null); + FindNextAction findNextAction = new FindNextAction(fgBundleForConstructedKeys, "Editor.FindNext.", //$NON-NLS-1$ + this, true) { + + public void run() { + if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.SOURCE_MODE) { + ReflectionUtils.setFieldValue(this, "fTarget", //$NON-NLS-1$ (IFindReplaceTarget) JavaDecompilerClassFileEditor.this - .getAdapter( IFindReplaceTarget.class ) ); + .getAdapter(IFindReplaceTarget.class)); - } - else if ( JavaDecompilerPlugin.getDefault( ).getSourceMode( ) == JavaDecompilerPlugin.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 - && fByteCodeSourceViewer != null ) - { - ReflectionUtils.setFieldValue( this, - "fTarget", //$NON-NLS-1$ - (IFindReplaceTarget) fByteCodeSourceViewer.getAdapter( IFindReplaceTarget.class ) ); + } 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() == JavaDecompilerConstants.BYTE_CODE_MODE + && fByteCodeSourceViewer != null) { + ReflectionUtils.setFieldValue(this, "fTarget", //$NON-NLS-1$ + (IFindReplaceTarget) fByteCodeSourceViewer.getAdapter(IFindReplaceTarget.class)); } - super.run( ); + super.run(); } }; - findNextAction.setHelpContextId( IAbstractTextEditorHelpContextIds.FIND_NEXT_ACTION ); - findNextAction.setActionDefinitionId( IWorkbenchActionDefinitionIds.FIND_NEXT ); - setAction( ITextEditorActionConstants.FIND_NEXT, findNextAction ); - - setAction( ITextEditorActionConstants.FIND_PREVIOUS, null ); - FindNextAction findPreviousAction = new FindNextAction( fgBundleForConstructedKeys, - "Editor.FindPrevious.", //$NON-NLS-1$ - this, - false ) { - - public void run( ) - { - if ( JavaDecompilerPlugin.getDefault( ).getSourceMode( ) == JavaDecompilerPlugin.SOURCE_MODE ) - { - ReflectionUtils.setFieldValue( this, - "fTarget", //$NON-NLS-1$ + findNextAction.setHelpContextId(IAbstractTextEditorHelpContextIds.FIND_NEXT_ACTION); + findNextAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.FIND_NEXT); + setAction(ITextEditorActionConstants.FIND_NEXT, findNextAction); + + setAction(ITextEditorActionConstants.FIND_PREVIOUS, null); + FindNextAction findPreviousAction = new FindNextAction(fgBundleForConstructedKeys, "Editor.FindPrevious.", //$NON-NLS-1$ + this, false) { + + public void run() { + if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.SOURCE_MODE) { + ReflectionUtils.setFieldValue(this, "fTarget", //$NON-NLS-1$ (IFindReplaceTarget) JavaDecompilerClassFileEditor.this - .getAdapter( IFindReplaceTarget.class ) ); + .getAdapter(IFindReplaceTarget.class)); - } - else if ( JavaDecompilerPlugin.getDefault( ).getSourceMode( ) == JavaDecompilerPlugin.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 - && fByteCodeSourceViewer != null ) - { - ReflectionUtils.setFieldValue( this, - "fTarget", //$NON-NLS-1$ - (IFindReplaceTarget) fByteCodeSourceViewer.getAdapter( IFindReplaceTarget.class ) ); + } 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() == JavaDecompilerConstants.BYTE_CODE_MODE + && fByteCodeSourceViewer != null) { + ReflectionUtils.setFieldValue(this, "fTarget", //$NON-NLS-1$ + (IFindReplaceTarget) fByteCodeSourceViewer.getAdapter(IFindReplaceTarget.class)); } - super.run( ); + super.run(); } }; - findPreviousAction.setHelpContextId( IAbstractTextEditorHelpContextIds.FIND_PREVIOUS_ACTION ); - findPreviousAction.setActionDefinitionId( IWorkbenchActionDefinitionIds.FIND_PREVIOUS ); - setAction( ITextEditorActionConstants.FIND_PREVIOUS, findPreviousAction ); + findPreviousAction.setHelpContextId(IAbstractTextEditorHelpContextIds.FIND_PREVIOUS_ACTION); + findPreviousAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.FIND_PREVIOUS); + setAction(ITextEditorActionConstants.FIND_PREVIOUS, findPreviousAction); - setAction( ITextEditorActionConstants.FIND_INCREMENTAL, null ); - IncrementalFindAction incrementalFindAction = new IncrementalFindAction( fgBundleForConstructedKeys, + setAction(ITextEditorActionConstants.FIND_INCREMENTAL, null); + IncrementalFindAction incrementalFindAction = new IncrementalFindAction(fgBundleForConstructedKeys, "Editor.FindIncremental.", //$NON-NLS-1$ - this, - true ) { - - public void run( ) - { - try - { - Class clazz = Class.forName( "org.eclipse.ui.texteditor.IncrementalFindTarget" ); //$NON-NLS-1$ - if ( JavaDecompilerPlugin.getDefault( ).getSourceMode( ) == JavaDecompilerPlugin.SOURCE_MODE ) - { - ReflectionUtils.setFieldValue( this, - "fTarget", //$NON-NLS-1$ - JavaDecompilerClassFileEditor.this.getAdapter( clazz ) ); - - } - else if ( JavaDecompilerPlugin.getDefault( ) - .getSourceMode( ) == JavaDecompilerPlugin.DISASSEMBLER_MODE - && fDisassemblerSourceViewer != null ) - { - ReflectionUtils.setFieldValue( this, "fTarget", fDisassemblerSourceViewer.getAdapter( clazz ) ); //$NON-NLS-1$ + this, true) { + + public void run() { + try { + Class clazz = Class.forName("org.eclipse.ui.texteditor.IncrementalFindTarget"); //$NON-NLS-1$ + if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.SOURCE_MODE) { + ReflectionUtils.setFieldValue(this, "fTarget", //$NON-NLS-1$ + JavaDecompilerClassFileEditor.this.getAdapter(clazz)); + + } else if (JavaDecompilerPlugin.getDefault() + .getSourceMode() == JavaDecompilerConstants.DISASSEMBLER_MODE + && fDisassemblerSourceViewer != null) { + ReflectionUtils.setFieldValue(this, "fTarget", fDisassemblerSourceViewer.getAdapter(clazz)); //$NON-NLS-1$ + } else if (JavaDecompilerPlugin.getDefault() + .getSourceMode() == JavaDecompilerConstants.BYTE_CODE_MODE + && fByteCodeSourceViewer != null) { + ReflectionUtils.setFieldValue(this, "fTarget", fByteCodeSourceViewer.getAdapter(clazz)); //$NON-NLS-1$ } - else if ( JavaDecompilerPlugin.getDefault( ).getSourceMode( ) == JavaDecompilerPlugin.BYTE_CODE_MODE - && fByteCodeSourceViewer != null ) - { - ReflectionUtils.setFieldValue( this, "fTarget", fByteCodeSourceViewer.getAdapter( clazz ) ); //$NON-NLS-1$ - } - } - catch ( ClassNotFoundException e ) - { - Logger.debug( e ); + } catch (ClassNotFoundException e) { + Logger.debug(e); } - super.run( ); + super.run(); } }; - incrementalFindAction.setHelpContextId( IAbstractTextEditorHelpContextIds.FIND_INCREMENTAL_ACTION ); - incrementalFindAction.setActionDefinitionId( IWorkbenchActionDefinitionIds.FIND_INCREMENTAL ); - setAction( ITextEditorActionConstants.FIND_INCREMENTAL, incrementalFindAction ); + incrementalFindAction.setHelpContextId(IAbstractTextEditorHelpContextIds.FIND_INCREMENTAL_ACTION); + incrementalFindAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.FIND_INCREMENTAL); + setAction(ITextEditorActionConstants.FIND_INCREMENTAL, incrementalFindAction); - setAction( ITextEditorActionConstants.FIND_INCREMENTAL_REVERSE, null ); - IncrementalFindAction incrementalFindReverseAction = new IncrementalFindAction( fgBundleForConstructedKeys, + setAction(ITextEditorActionConstants.FIND_INCREMENTAL_REVERSE, null); + IncrementalFindAction incrementalFindReverseAction = new IncrementalFindAction(fgBundleForConstructedKeys, "Editor.FindIncrementalReverse.", //$NON-NLS-1$ - this, - false ) { - - public void run( ) - { - try - { - Class clazz = Class.forName( "org.eclipse.ui.texteditor.IncrementalFindTarget" ); //$NON-NLS-1$ - if ( JavaDecompilerPlugin.getDefault( ).getSourceMode( ) == JavaDecompilerPlugin.SOURCE_MODE ) - { - ReflectionUtils.setFieldValue( this, - "fTarget", //$NON-NLS-1$ - JavaDecompilerClassFileEditor.this.getAdapter( clazz ) ); - - } - else if ( JavaDecompilerPlugin.getDefault( ) - .getSourceMode( ) == JavaDecompilerPlugin.DISASSEMBLER_MODE - && fDisassemblerSourceViewer != null ) - { - ReflectionUtils.setFieldValue( this, "fTarget", fDisassemblerSourceViewer.getAdapter( clazz ) ); //$NON-NLS-1$ + this, false) { + + public void run() { + try { + Class clazz = Class.forName("org.eclipse.ui.texteditor.IncrementalFindTarget"); //$NON-NLS-1$ + if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.SOURCE_MODE) { + ReflectionUtils.setFieldValue(this, "fTarget", //$NON-NLS-1$ + JavaDecompilerClassFileEditor.this.getAdapter(clazz)); + + } else if (JavaDecompilerPlugin.getDefault() + .getSourceMode() == JavaDecompilerConstants.DISASSEMBLER_MODE + && fDisassemblerSourceViewer != null) { + ReflectionUtils.setFieldValue(this, "fTarget", fDisassemblerSourceViewer.getAdapter(clazz)); //$NON-NLS-1$ + } else if (JavaDecompilerPlugin.getDefault() + .getSourceMode() == JavaDecompilerConstants.BYTE_CODE_MODE + && fByteCodeSourceViewer != null) { + ReflectionUtils.setFieldValue(this, "fTarget", fByteCodeSourceViewer.getAdapter(clazz)); //$NON-NLS-1$ } - else if ( JavaDecompilerPlugin.getDefault( ).getSourceMode( ) == JavaDecompilerPlugin.BYTE_CODE_MODE - && fByteCodeSourceViewer != null ) - { - ReflectionUtils.setFieldValue( this, "fTarget", fByteCodeSourceViewer.getAdapter( clazz ) ); //$NON-NLS-1$ - } - } - catch ( ClassNotFoundException e ) - { - Logger.debug( e ); + } catch (ClassNotFoundException e) { + Logger.debug(e); } - super.run( ); + super.run(); } }; incrementalFindReverseAction - .setHelpContextId( IAbstractTextEditorHelpContextIds.FIND_INCREMENTAL_REVERSE_ACTION ); - incrementalFindReverseAction.setActionDefinitionId( IWorkbenchActionDefinitionIds.FIND_INCREMENTAL_REVERSE ); - setAction( ITextEditorActionConstants.FIND_INCREMENTAL_REVERSE, incrementalFindAction ); + .setHelpContextId(IAbstractTextEditorHelpContextIds.FIND_INCREMENTAL_REVERSE_ACTION); + incrementalFindReverseAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.FIND_INCREMENTAL_REVERSE); + setAction(ITextEditorActionConstants.FIND_INCREMENTAL_REVERSE, incrementalFindAction); - setAction( ITextEditorActionConstants.GOTO_LINE, null ); - GotoLineAction gotoAction = new GotoLineAction( fgBundleForConstructedKeys, "Editor.GotoLine.", this ) { //$NON-NLS-1$ + setAction(ITextEditorActionConstants.GOTO_LINE, null); + GotoLineAction gotoAction = new GotoLineAction(fgBundleForConstructedKeys, "Editor.GotoLine.", this) { //$NON-NLS-1$ - protected ITextEditor getTextEditor( ) - { - if ( JavaDecompilerPlugin.getDefault( ).getSourceMode( ) == JavaDecompilerPlugin.DISASSEMBLER_MODE ) - { + protected ITextEditor getTextEditor() { + 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; }; }; - gotoAction.setHelpContextId( IAbstractTextEditorHelpContextIds.GOTO_LINE_ACTION ); - gotoAction.setActionDefinitionId( ITextEditorActionDefinitionIds.LINE_GOTO ); - setAction( ITextEditorActionConstants.GOTO_LINE, gotoAction ); + gotoAction.setHelpContextId(IAbstractTextEditorHelpContextIds.GOTO_LINE_ACTION); + gotoAction.setActionDefinitionId(ITextEditorActionDefinitionIds.LINE_GOTO); + setAction(ITextEditorActionConstants.GOTO_LINE, gotoAction); - ReflectionUtils.setFieldValue( this, "fSourceCopyAction", copyAction ); //$NON-NLS-1$ - ReflectionUtils.setFieldValue( this, "fSelectAllAction", selectAllAction ); //$NON-NLS-1$ + ReflectionUtils.setFieldValue(this, "fSourceCopyAction", copyAction); //$NON-NLS-1$ + ReflectionUtils.setFieldValue(this, "fSelectAllAction", selectAllAction); //$NON-NLS-1$ - final ActionGroup group = new DecompileActionGroup( this, ITextEditorActionConstants.GROUP_SAVE, true ); - CompositeActionGroup fContextMenuGroup = (CompositeActionGroup) ReflectionUtils.getFieldValue( this, - "fContextMenuGroup" ); //$NON-NLS-1$ - fContextMenuGroup.addGroup( group ); + final ActionGroup group = new DecompileActionGroup(this, ITextEditorActionConstants.GROUP_SAVE, true); + CompositeActionGroup fContextMenuGroup = (CompositeActionGroup) ReflectionUtils.getFieldValue(this, + "fContextMenuGroup"); //$NON-NLS-1$ + fContextMenuGroup.addGroup(group); } - public void showSource( ) - { - if ( getEditorInput( ) instanceof IClassFileEditorInput ) - { - showSource( (IClassFileEditorInput) getEditorInput( ) ); + public void showSource() { + if (getEditorInput() instanceof IClassFileEditorInput) { + showSource((IClassFileEditorInput) getEditorInput()); } } - protected void showSource( IClassFileEditorInput classFileEditorInput ) - { - if ( currentSourceMode == JavaDecompilerPlugin.getDefault( ).getSourceMode( ) ) + protected void showSource(IClassFileEditorInput classFileEditorInput) { + if (currentSourceMode == JavaDecompilerPlugin.getDefault().getSourceMode()) { return; + } - try - { - 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 ( fStackLayout != null && fViewerComposite != null && fParent != null ) - { + try { + 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() == JavaDecompilerConstants.SOURCE_MODE) { + if (fStackLayout != null && fViewerComposite != null && fParent != null) { fStackLayout.topControl = fViewerComposite; - fParent.layout( ); + fParent.layout(); } - } - else if ( JavaDecompilerPlugin.getDefault( ).getSourceMode( ) == JavaDecompilerPlugin.DISASSEMBLER_MODE ) - { - if ( fStackLayout != null && fParent != null ) - { - if ( fDisassemblerSourceViewer == null ) - { - fDisassemblerSourceViewer = new DisassemblerSourceViewer( this ); - fDisassemblerSourceViewer.createControl( fParent ); + } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.DISASSEMBLER_MODE) { + if (fStackLayout != null && fParent != null) { + if (fDisassemblerSourceViewer == null) { + fDisassemblerSourceViewer = new DisassemblerSourceViewer(this); + fDisassemblerSourceViewer.createControl(fParent); } - fDisassemblerSourceViewer.getTextWidget( ).setSelection( 0, 0 ); - fDisassemblerSourceViewer.setSelectionElement( selectedElement ); - fStackLayout.topControl = fDisassemblerSourceViewer.getControl( ); - fParent.layout( ); - } - } - else if ( JavaDecompilerPlugin.getDefault( ).getSourceMode( ) == JavaDecompilerPlugin.BYTE_CODE_MODE ) - { - if ( fStackLayout != null && fParent != null ) - { - if ( fByteCodeSourceViewer == null ) - { - fByteCodeSourceViewer = new ByteCodeSourceViewer( this ); - fByteCodeSourceViewer.createControl( fParent ); + fDisassemblerSourceViewer.getTextWidget().setSelection(0, 0); + fDisassemblerSourceViewer.setSelectionElement(selectedElement); + fStackLayout.topControl = fDisassemblerSourceViewer.getControl(); + fParent.layout(); + } + } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.BYTE_CODE_MODE) { + if (fStackLayout != null && fParent != null) { + if (fByteCodeSourceViewer == null) { + fByteCodeSourceViewer = new ByteCodeSourceViewer(this); + fByteCodeSourceViewer.createControl(fParent); } - fByteCodeSourceViewer.getTextWidget( ).setSelection( 0, 0 ); - fByteCodeSourceViewer.setSelectionElement( selectedElement ); - fStackLayout.topControl = fByteCodeSourceViewer.getControl( ); - fParent.layout( ); + fByteCodeSourceViewer.getTextWidget().setSelection(0, 0); + fByteCodeSourceViewer.setSelectionElement(selectedElement); + fStackLayout.topControl = fByteCodeSourceViewer.getControl(); + fParent.layout(); } } + } catch (Exception e) { + Logger.debug(e); } - catch ( Exception e ) - { - Logger.debug( e ); - } - currentSourceMode = JavaDecompilerPlugin.getDefault( ).getSourceMode( ); + currentSourceMode = JavaDecompilerPlugin.getDefault().getSourceMode(); } - protected String getCursorPosition( ) - { - if ( JavaDecompilerPlugin.getDefault( ).getSourceMode( ) == JavaDecompilerPlugin.DISASSEMBLER_MODE ) - { - if ( fDisassemblerSourceViewer != null && fDisassemblerSourceViewer.getTextWidget( ) != null ) - { - int line = fDisassemblerSourceViewer.getTextWidget( ) - .getLineAtOffset( fDisassemblerSourceViewer.getTextWidget( ).getCaretOffset( ) ); - int column = fDisassemblerSourceViewer.getTextWidget( ).getCaretOffset( ) - - fDisassemblerSourceViewer.getTextWidget( ).getOffsetAtLine( line ); - return ( line + 1 ) + " : " + ( column + 1 ); //$NON-NLS-1$ + protected String getCursorPosition() { + if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.DISASSEMBLER_MODE) { + if (fDisassemblerSourceViewer != null && fDisassemblerSourceViewer.getTextWidget() != null) { + int line = fDisassemblerSourceViewer.getTextWidget() + .getLineAtOffset(fDisassemblerSourceViewer.getTextWidget().getCaretOffset()); + int column = fDisassemblerSourceViewer.getTextWidget().getCaretOffset() + - fDisassemblerSourceViewer.getTextWidget().getOffsetAtLine(line); + return (line + 1) + " : " + (column + 1); //$NON-NLS-1$ } - } - else if ( JavaDecompilerPlugin.getDefault( ).getSourceMode( ) == JavaDecompilerPlugin.BYTE_CODE_MODE ) - { - if ( fByteCodeSourceViewer != null && fByteCodeSourceViewer.getTextWidget( ).getSelection( ) != null ) - { - int line = fByteCodeSourceViewer.getTextWidget( ) - .getLineAtOffset( fByteCodeSourceViewer.getTextWidget( ).getCaretOffset( ) ); - int column = fByteCodeSourceViewer.getTextWidget( ).getCaretOffset( ) - - fByteCodeSourceViewer.getTextWidget( ).getOffsetAtLine( line ); - return ( line + 1 ) + " : " + ( column + 1 ); //$NON-NLS-1$ + } else if (JavaDecompilerPlugin.getDefault().getSourceMode() == JavaDecompilerConstants.BYTE_CODE_MODE) { + if (fByteCodeSourceViewer != null && fByteCodeSourceViewer.getTextWidget().getSelection() != null) { + int line = fByteCodeSourceViewer.getTextWidget() + .getLineAtOffset(fByteCodeSourceViewer.getTextWidget().getCaretOffset()); + int column = fByteCodeSourceViewer.getTextWidget().getCaretOffset() + - fByteCodeSourceViewer.getTextWidget().getOffsetAtLine(line); + return (line + 1) + " : " + (column + 1); //$NON-NLS-1$ } } - return super.getCursorPosition( ); + return super.getCursorPosition(); } } \ No newline at end of file diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/LineNumberOutputType.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/LineNumberOutputType.java new file mode 100644 index 00000000..6dd35749 --- /dev/null +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/LineNumberOutputType.java @@ -0,0 +1,61 @@ +package org.sf.feeling.decompiler.editor; + +import java.util.regex.Pattern; + +import org.sf.feeling.decompiler.postprocessing.LineReformatter; + +/** + * Several decompiler don't support generating decompiled code that is formatted + * according to the line number information contained in the class file. + * + * These decompilers only allow to include the source code line numbers as + * comment in the generated source code. ECD allows to reformat decompiled + * source code according to those line number comments. + * + * There are multiple styles decompiler use for including the source code line + * numbers into the decompiled source code. This enum class lists all supported + * line number styles so that the source code reformatter in + * {@link LineReformatter} can use this information to find and extract the + * line numbers. + */ +public enum LineNumberOutputType { + + /** + * One or more source code line numbers are included as single line comment at + * the end of a source code line. + * + * Capturing group returns the whole comment including the line numbers (for + * removal). + * + * Capturing group 2 returns the source code line number(s) only + * + * for example: + * + *

      +	 * System.out.println(); // 13
      +	 * if (a.condition() && b.condition())) System.out.println(); // 13 14
      +	 * 
      + */ + SINGLE_LINE_COMMENT_END_OF_LINE(// + Pattern.compile("(//\\s+(\\d+(\\s+\\d+)*\\s*))$")// multiple line numbers supported + ), + + BLOCK_COMMENT_BEGIN_OF_LINE(// + Pattern.compile("\\s*(/\\*\\s*(\\d*)\\s*\\*/)")// only one line number supported + ); + + private final Pattern pattern; + + /** + * @param pattern for extracting one or more line numbers. if it matches it has + * to return at least one line number in matcher group(1). + */ + LineNumberOutputType(Pattern pattern) { + this.pattern = pattern; + } + + public Pattern getPattern() { + return pattern; + } + +} diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/NoStackTraceException.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/NoStackTraceException.java new file mode 100644 index 00000000..0182f65e --- /dev/null +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/NoStackTraceException.java @@ -0,0 +1,9 @@ +package org.sf.feeling.decompiler.editor; + +public class NoStackTraceException extends Exception { + + public NoStackTraceException(String message) { + super(message); + } + +} 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 0afbb090..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 @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.editor; @@ -27,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; @@ -36,102 +33,86 @@ /** * A Java code scanner. */ -public final class RenderedBytecodeScanner extends AbstractJavaScanner implements JavaLexicalConstants, JavaKeywords -{ +public final class RenderedBytecodeScanner extends AbstractJavaScanner implements JavaLexicalConstants, JavaKeywords { - private static class WhitespaceDetector implements IWhitespaceDetector - { + private static class WhitespaceDetector implements IWhitespaceDetector { /* * (non-Javadoc) * - * @see - * org.eclipse.jface.text.rules.IWhitespaceDetector#isWhitespace(char) + * @see org.eclipse.jface.text.rules.IWhitespaceDetector#isWhitespace(char) */ - public boolean isWhitespace( char c ) - { - return Character.isWhitespace( c ); + public boolean isWhitespace(char c) { + return Character.isWhitespace(c); } } - private static class WordDetector implements IWordDetector - { + private static class WordDetector implements IWordDetector { /* * @see IWordDetector#isWordStart */ - public boolean isWordStart( char c ) - { - return Character.isJavaIdentifierStart( c ); + public boolean isWordStart(char c) { + return Character.isJavaIdentifierStart(c); } /* * @see IWordDetector#isWordPart */ - public boolean isWordPart( char c ) - { - return Character.isJavaIdentifierPart( c ); + public boolean isWordPart(char c) { + return Character.isJavaIdentifierPart(c); } } - private static class SimpleRule extends WordRule - { + private static class SimpleRule extends WordRule { private IToken token; - private StringBuffer fBuffer = new StringBuffer( ); + private StringBuffer fBuffer = new StringBuffer(); - public SimpleRule( IWordDetector detector, IToken token ) - { - super( detector ); + public SimpleRule(IWordDetector detector, IToken token) { + super(detector); this.token = token; } @Override - public IToken evaluate( ICharacterScanner scanner ) - { - int c = scanner.read( ); - if ( fDetector.isWordStart( (char) c ) ) - { - if ( fColumn == UNDEFINED || ( fColumn == scanner.getColumn( ) - 1 ) ) - { - - fBuffer.setLength( 0 ); - do - { - fBuffer.append( (char) c ); - c = scanner.read( ); - } while ( c != ICharacterScanner.EOF && fDetector.isWordPart( (char) c ) ); - scanner.unread( ); + public IToken evaluate(ICharacterScanner scanner) { + int c = scanner.read(); + if (fDetector.isWordStart((char) c)) { + if (fColumn == UNDEFINED || (fColumn == scanner.getColumn() - 1)) { + + fBuffer.setLength(0); + do { + fBuffer.append((char) c); + c = scanner.read(); + } while (c != ICharacterScanner.EOF && fDetector.isWordPart((char) c)); + scanner.unread(); return token; } } - scanner.unread( ); + scanner.unread(); return Token.UNDEFINED; } } - private static class NumberWordDetector implements IWordDetector - { + private static class NumberWordDetector implements IWordDetector { /* * @see IWordDetector#isWordStart */ - public boolean isWordStart( char c ) - { - return Character.isDigit( c ); + public boolean isWordStart(char c) { + return Character.isDigit(c); } /* * @see IWordDetector#isWordPart */ - public boolean isWordPart( char c ) - { - return Character.isDigit( c ) || c == JavaLexicalConstants.DOT; + public boolean isWordPart(char c) { + return Character.isDigit(c) || c == JavaLexicalConstants.DOT; } } @@ -140,214 +121,130 @@ public boolean isWordPart( char c ) * * @since 3.0 */ - private class OperatorRule implements IRule - { + private class OperatorRule implements IRule { /** Java operators */ - private final char[] JAVA_OPERATORS = { - SEMICOLON, - LEFT_PARENTHESIS, - RIGHT_PARENTHESIS, - LEFT_BRACE, - RIGHT_BRACE, - DOT, - EQUALS, - SLASH, - BACKSLASH, - PLUS, - MINUS, - ASTERISK, - LEFT_SQUARE_BRACKET, - RIGHT_SQUARE_BRACKET, - LT, - GT, - COLON, - QUESTION_MARK, - EXCLAMATION_MARK, - COMMA, - PIPE, - AMPERSAND, - CARET, - PERCENT, - TILDE - }; + private final char[] JAVA_OPERATORS = { SEMICOLON, LEFT_PARENTHESIS, RIGHT_PARENTHESIS, LEFT_BRACE, RIGHT_BRACE, + DOT, EQUALS, SLASH, BACKSLASH, PLUS, MINUS, ASTERISK, LEFT_SQUARE_BRACKET, RIGHT_SQUARE_BRACKET, LT, GT, + COLON, QUESTION_MARK, EXCLAMATION_MARK, COMMA, PIPE, AMPERSAND, CARET, PERCENT, TILDE }; /** Token to return for this rule */ private final IToken fToken; /** * Creates a new operator rule. * - * @param token - * Token to use for this rule + * @param token Token to use for this rule */ - public OperatorRule( IToken token ) - { + public OperatorRule(IToken token) { fToken = token; } /** * Is this character an operator character? * - * @param character - * Character to determine whether it is an operator character + * @param character Character to determine whether it is an operator character * @return true iff the character is an operator, * false otherwise. */ - public boolean isOperator( char character ) - { - for ( int index = 0; index < JAVA_OPERATORS.length; index++ ) - { - if ( JAVA_OPERATORS[index] == character ) + public boolean isOperator(char character) { + for (int index = 0; index < JAVA_OPERATORS.length; index++) { + if (JAVA_OPERATORS[index] == character) return true; } return false; } /* - * @see - * org.eclipse.jface.text.rules.IRule#evaluate(org.eclipse.jface.text. + * @see org.eclipse.jface.text.rules.IRule#evaluate(org.eclipse.jface.text. * rules.ICharacterScanner) */ - public IToken evaluate( ICharacterScanner scanner ) - { - - int character = scanner.read( ); - if ( isOperator( (char) character ) ) - { - do - { - character = scanner.read( ); - } while ( isOperator( (char) character ) ); - scanner.unread( ); + public IToken evaluate(ICharacterScanner scanner) { + + int character = scanner.read(); + if (isOperator((char) character)) { + do { + character = scanner.read(); + } while (isOperator((char) character)); + scanner.unread(); return fToken; - } - else - { - scanner.unread( ); + } else { + scanner.unread(); return Token.UNDEFINED; } } } - private static final String[] RENDERED_BYTECODE_KEYWORDS = { - ABSTRACT, - CATCH, - CLASS, - CONST, - DEFAULT, - EXTENDS, - FINAL, - FINALLY, - IMPLEMENTS, - IMPORT, - INTERFACE, - NATIVE, - PACKAGE, - PRIVATE, - PROTECTED, - PUBLIC, - STATIC, - SUPER, - SYNCHRONIZED, - THIS, - THROWS, - TRANSIENT, - TRY, - VOLATILE, - ENUM, - VOID, - BOOLEAN, - CHAR, - BYTE, - SHORT, - STRICTFP, - INT, - LONG, - FLOAT, - DOUBLE, - FALSE, - NULL, - TRUE - }; - - private static String[] tokenProperties = { - IJavaColorConstants.JAVA_KEYWORD, - IJavaColorConstants.JAVA_STRING, - IJavaColorConstants.JAVA_DEFAULT, - IJavaColorConstants.JAVA_OPERATOR, - JavaDecompilerPlugin.BYTECODE_MNEMONIC - }; + private static final String[] RENDERED_BYTECODE_KEYWORDS = { ABSTRACT, CATCH, CLASS, CONST, DEFAULT, EXTENDS, FINAL, + FINALLY, IMPLEMENTS, IMPORT, INTERFACE, NATIVE, PACKAGE, PRIVATE, PROTECTED, PUBLIC, STATIC, SUPER, + SYNCHRONIZED, THIS, THROWS, TRANSIENT, TRY, VOLATILE, ENUM, VOID, BOOLEAN, CHAR, BYTE, SHORT, STRICTFP, INT, + LONG, FLOAT, DOUBLE, FALSE, NULL, TRUE }; + + private static String[] tokenProperties = { IJavaColorConstants.JAVA_KEYWORD, IJavaColorConstants.JAVA_STRING, + IJavaColorConstants.JAVA_DEFAULT, IJavaColorConstants.JAVA_OPERATOR, + JavaDecompilerConstants.BYTECODE_MNEMONIC }; /** * Creates a Java code scanner * - * @param manager - * the color manager - * @param store - * the preference store + * @param manager the color manager + * @param store the preference store */ - public RenderedBytecodeScanner( IColorManager manager, IPreferenceStore store ) - { - super( manager, store ); - initialize( ); + public RenderedBytecodeScanner(IColorManager manager, IPreferenceStore store) { + super(manager, store); + initialize(); } /* * @see AbstractJavaScanner#getTokenProperties() */ - protected String[] getTokenProperties( ) - { + protected String[] getTokenProperties() { return tokenProperties; } /* * @see AbstractJavaScanner#createRules() */ - protected List createRules( ) - { + protected List createRules() { - List rules = new ArrayList( ); + List rules = new ArrayList(); /* character constants */ - Token token = getToken( IJavaColorConstants.JAVA_STRING ); - rules.add( new SingleLineRule( "'", "'", token, '\\' ) ); //$NON-NLS-1$ //$NON-NLS-2$ + Token token = getToken(IJavaColorConstants.JAVA_STRING); + rules.add(new SingleLineRule("'", "'", token, '\\')); //$NON-NLS-1$ //$NON-NLS-2$ /* whitespace */ - rules.add( new WhitespaceRule( new WhitespaceDetector( ) ) ); + rules.add(new WhitespaceRule(new WhitespaceDetector())); /* operators and brackets */ - token = getToken( IJavaColorConstants.JAVA_OPERATOR ); - rules.add( new OperatorRule( token ) ); + token = getToken(IJavaColorConstants.JAVA_OPERATOR); + rules.add(new OperatorRule(token)); /* keywords */ - WordRule wordRule = new WordRule( new WordDetector( ) ); - token = getToken( IJavaColorConstants.JAVA_KEYWORD ); - for ( int i = 0; i < RENDERED_BYTECODE_KEYWORDS.length; i++ ) - { - wordRule.addWord( RENDERED_BYTECODE_KEYWORDS[i], token ); + WordRule wordRule = new WordRule(new WordDetector()); + token = getToken(IJavaColorConstants.JAVA_KEYWORD); + for (int i = 0; i < RENDERED_BYTECODE_KEYWORDS.length; i++) { + wordRule.addWord(RENDERED_BYTECODE_KEYWORDS[i], token); } - token = getToken( JavaDecompilerPlugin.BYTECODE_MNEMONIC ); - for ( int i = 0; i < ByteCodeConstants.OPCODE_MNEMONICS.length; i++ ) - { + token = getToken(JavaDecompilerConstants.BYTECODE_MNEMONIC); + for (int i = 0; i < ByteCodeConstants.OPCODE_MNEMONICS.length; i++) { String word = ByteCodeConstants.OPCODE_MNEMONICS[i]; - if ( word != null ) - { - wordRule.addWord( word, token ); + if (word != null) { + wordRule.addWord(word, token); } } - rules.add( wordRule ); + rules.add(wordRule); /* identifiers */ - token = getToken( IJavaColorConstants.JAVA_DEFAULT ); - rules.add( new SimpleRule( new WordDetector( ), token ) ); + token = getToken(IJavaColorConstants.JAVA_DEFAULT); + rules.add(new SimpleRule(new WordDetector(), token)); /* numbers */ - token = getToken( IJavaColorConstants.JAVA_STRING ); - rules.add( new SimpleRule( new NumberWordDetector( ), token ) ); + token = getToken(IJavaColorConstants.JAVA_STRING); + rules.add(new SimpleRule(new NumberWordDetector(), token)); - setDefaultReturnToken( getToken( IJavaColorConstants.JAVA_DEFAULT ) ); + setDefaultReturnToken(getToken(IJavaColorConstants.JAVA_DEFAULT)); return rules; } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/SourceMapperFactory.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/SourceMapperFactory.java index baadee5e..854c4287 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/SourceMapperFactory.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/editor/SourceMapperFactory.java @@ -1,40 +1,22 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.editor; import org.sf.feeling.decompiler.JavaDecompilerPlugin; -import org.sf.feeling.decompiler.fernflower.FernFlowerSourceMapper; -public class SourceMapperFactory -{ +public class SourceMapperFactory { - private static DecompilerSourceMapper fernFlowerSourceMapper; + public static DecompilerSourceMapper getSourceMapper(String decompiler) { - public static DecompilerSourceMapper getSourceMapper( String decompiler ) - { - - if ( DecompilerType.FernFlower.equals( decompiler ) ) - { - if ( fernFlowerSourceMapper == null ) - { - fernFlowerSourceMapper = new FernFlowerSourceMapper( ); - } - return fernFlowerSourceMapper; - } - else - { - IDecompilerDescriptor descriptor = JavaDecompilerPlugin.getDefault( ).getDecompilerDescriptor( decompiler ); - if ( descriptor != null ) - return descriptor.getDecompilerSourceMapper( ); + IDecompilerDescriptor descriptor = JavaDecompilerPlugin.getDefault().getDecompilerDescriptor(decompiler); + if (descriptor != null) { + return descriptor.getDecompilerSourceMapper(); } return null; } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/extension/DecompilerAdapter.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/extension/DecompilerAdapter.java index 484f2467..179a4048 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/extension/DecompilerAdapter.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/extension/DecompilerAdapter.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.extension; @@ -20,8 +17,7 @@ /** * DecompilerAdapter */ -public class DecompilerAdapter -{ +public class DecompilerAdapter { /** * Comment for id @@ -70,131 +66,103 @@ public class DecompilerAdapter private Expression expression; // getters and setters - public Class getAdaptableType( ) - { + public Class getAdaptableType() { return adaptableType; } - public void setAdaptableType( Class adaptableType ) - { + public void setAdaptableType(Class adaptableType) { this.adaptableType = adaptableType; } - public IAdapterFactory getFactory( ) - { + public IAdapterFactory getFactory() { return factory; } - public void setFactory( IAdapterFactory factory ) - { + public void setFactory(IAdapterFactory factory) { this.factory = factory; } - public boolean isIncludeWorkbenchContribute( ) - { + public boolean isIncludeWorkbenchContribute() { return includeWorkbenchContribute; } - public void setIncludeWorkbenchContribute( boolean includeWorkbenchContribute ) - { + public void setIncludeWorkbenchContribute(boolean includeWorkbenchContribute) { this.includeWorkbenchContribute = includeWorkbenchContribute; } - public String[] getOverwrite( ) - { + public String[] getOverwrite() { return overwrite; } - public void setOverwrite( String[] overwrite ) - { + public void setOverwrite(String[] overwrite) { this.overwrite = overwrite; } - public int getPriority( ) - { + public int getPriority() { return priority; } - public void setPriority( int priority ) - { + public void setPriority(int priority) { this.priority = priority; } - public Class getAdapterType( ) - { + public Class getAdapterType() { return adapterType; } - public void setAdapterType( Class type ) - { + public void setAdapterType(Class type) { this.adapterType = type; } - public String getId( ) - { + public String getId() { return id; } - public void setId( String id ) - { + public void setId(String id) { this.id = id; } - public Object getAdapterInstance( ) - { + public Object getAdapterInstance() { return adapterInstance; } - public void setAdapterInstance( Object adapterInstance ) - { + public void setAdapterInstance(Object adapterInstance) { this.adapterInstance = adapterInstance; } - public void setAdapterConfig( IConfigurationElement config ) - { + public void setAdapterConfig(IConfigurationElement config) { this.adapterConfig = config; } - public boolean isSingleton( ) - { + public boolean isSingleton() { return isSingleton; } - public void setSingleton( boolean isSingleton ) - { + public void setSingleton(boolean isSingleton) { this.isSingleton = isSingleton; } - public Expression getExpression( ) - { + public Expression getExpression() { return expression; } - public void setExpression( Expression expression ) - { + public void setExpression(Expression expression) { this.expression = expression; } // public methods // FIXME singleton, factory - public Object getAdater( Object adaptableObject ) - { - if ( this.cachedAdapter != null && this.isSingleton ) - { + public Object getAdater(Object adaptableObject) { + if (this.cachedAdapter != null && this.isSingleton) { return this.cachedAdapter; } - if ( this.adapterInstance != null ) - { - if ( !isSingleton && adapterConfig != null ) - { - try - { - return adapterConfig.createExecutableExtension( "class" ); //$NON-NLS-1$ - } - catch ( CoreException e ) - { - e.printStackTrace( ); + if (this.adapterInstance != null) { + if (!isSingleton && adapterConfig != null) { + try { + return adapterConfig.createExecutableExtension("class"); //$NON-NLS-1$ + } catch (CoreException e) { + e.printStackTrace(); } } @@ -203,17 +171,14 @@ public Object getAdater( Object adaptableObject ) Object apt = null; - if ( this.factory != null ) - { - apt = this.factory.getAdapter( adaptableObject, this.adapterType ); + if (this.factory != null) { + apt = this.factory.getAdapter(adaptableObject, this.adapterType); } - if ( apt == null && this.includeWorkbenchContribute ) - { - apt = Platform.getAdapterManager( ).getAdapter( adaptableObject, this.adapterType ); + if (apt == null && this.includeWorkbenchContribute) { + apt = Platform.getAdapterManager().getAdapter(adaptableObject, this.adapterType); } - if ( this.isSingleton ) - { + if (this.isSingleton) { // only when is singleton, we cache the instance this.cachedAdapter = apt; } @@ -222,30 +187,25 @@ public Object getAdater( Object adaptableObject ) } @Override - public boolean equals( Object obj ) - { - if ( obj == this ) - { + public boolean equals(Object obj) { + if (obj == this) { return true; } - if ( !( obj instanceof DecompilerAdapter ) ) - { + if (!(obj instanceof DecompilerAdapter)) { return false; } - return this.getId( ).equals( ( (DecompilerAdapter) obj ).getId( ) ); + return this.getId().equals(((DecompilerAdapter) obj).getId()); } @Override - public int hashCode( ) - { - return this.getId( ).hashCode( ); + public int hashCode() { + return this.getId().hashCode(); } @Override - public String toString( ) - { - return this.getId( ); + public String toString() { + return this.getId(); } } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/extension/DecompilerAdapterInvocationHandler.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/extension/DecompilerAdapterInvocationHandler.java index 1cb06d89..fb0cc459 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/extension/DecompilerAdapterInvocationHandler.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/extension/DecompilerAdapterInvocationHandler.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.extension; @@ -22,78 +19,59 @@ /** * DecompilerAdapterInvocationHandler */ -public class DecompilerAdapterInvocationHandler implements InvocationHandler -{ +public class DecompilerAdapterInvocationHandler implements InvocationHandler { private List adapters; - public DecompilerAdapterInvocationHandler( List adapters ) - { + public DecompilerAdapterInvocationHandler(List adapters) { this.adapters = adapters; } @Override - public Object invoke( Object proxy, Method method, Object[] args ) throws Throwable - { - try - { - if ( adapters != null && adapters.size( ) > 0 ) - { - Class returnType = method.getReturnType( ); - if ( returnType.isArray( ) ) - { - List allResult = new ArrayList( ); - for ( Iterator iter = adapters.iterator( ); iter.hasNext( ); ) - { - Object result = method.invoke( iter.next( ), args ); - if ( result != null ) - allResult.addAll( Arrays.asList( (Object[]) result ) ); + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + try { + if (adapters != null && adapters.size() > 0) { + Class returnType = method.getReturnType(); + if (returnType.isArray()) { + List allResult = new ArrayList(); + for (Iterator iter = adapters.iterator(); iter.hasNext();) { + Object result = method.invoke(iter.next(), args); + if (result != null) { + allResult.addAll(Arrays.asList((Object[]) result)); + } } - Object a = java.lang.reflect.Array.newInstance( returnType.getComponentType( ), allResult.size( ) ); - return allResult.toArray( (Object[]) a ); - } - else if ( returnType == Collection.class ) - { - Collection allResult = new ArrayList( ); - for ( Iterator iter = adapters.iterator( ); iter.hasNext( ); ) - { - Object result = method.invoke( iter.next( ), args ); - allResult.addAll( (Collection) result ); + Object a = java.lang.reflect.Array.newInstance(returnType.getComponentType(), allResult.size()); + return allResult.toArray((Object[]) a); + } else if (returnType == Collection.class) { + Collection allResult = new ArrayList<>(); + for (Iterator iter = adapters.iterator(); iter.hasNext();) { + Object result = method.invoke(iter.next(), args); + allResult.addAll((Collection) result); } return allResult; - } - else if ( returnType == Boolean.class ) - { + } else if (returnType == Boolean.class) { boolean returnValue = false; - for ( Iterator iter = adapters.iterator( ); iter.hasNext( ); ) - { - Boolean result = (Boolean) method.invoke( iter.next( ), args ); - if ( returnValue != result.booleanValue( ) ) - returnValue = returnValue ^ result.booleanValue( ); + for (Iterator iter = adapters.iterator(); iter.hasNext();) { + Boolean result = (Boolean) method.invoke(iter.next(), args); + if (returnValue != result.booleanValue()) { + returnValue = returnValue ^ result.booleanValue(); + } } - return Boolean.valueOf( returnValue ); - } - else if ( returnType == Void.TYPE ) - { - for ( Iterator iter = adapters.iterator( ); iter.hasNext( ); ) - { - method.invoke( iter.next( ), args ); + return Boolean.valueOf(returnValue); + } else if (returnType == Void.TYPE) { + for (Iterator iter = adapters.iterator(); iter.hasNext();) { + method.invoke(iter.next(), args); } - } - else - { - for ( Iterator iter = adapters.iterator( ); iter.hasNext( ); ) - { - return method.invoke( iter.next( ), args ); + } else { + for (Iterator iter = adapters.iterator(); iter.hasNext();) { + return method.invoke(iter.next(), args); // if ( result != null ) // return result; } } } - } - catch ( Exception e ) - { - throw e.getCause( ); + } catch (Exception e) { + throw e.getCause(); } return null; } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/extension/DecompilerAdapterManager.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/extension/DecompilerAdapterManager.java index 8bd92fa1..38de1ce8 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/extension/DecompilerAdapterManager.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/extension/DecompilerAdapterManager.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.extension; @@ -14,13 +11,10 @@ import java.lang.reflect.Proxy; import java.text.MessageFormat; import java.util.ArrayList; -import java.util.Comparator; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.TreeSet; import java.util.logging.Level; import java.util.logging.Logger; @@ -37,190 +31,152 @@ /** * DecompilerAdapterManager */ -public class DecompilerAdapterManager -{ +public class DecompilerAdapterManager { public static final String ADAPTERS_EXTENSION_ID = "org.sf.feeling.decompiler.decompilerAdapters"; //$NON-NLS-1$ - protected static final Logger logger = Logger.getLogger( DecompilerAdapterManager.class.getName( ) ); + protected static final Logger logger = Logger.getLogger(DecompilerAdapterManager.class.getName()); - private static Map adaptersMap = new HashMap( ) { + private static final Map, Set> ADAPTERS_MAP = new HashMap() { private static final long serialVersionUID = 534728316184090251L; @Override - public Object get( Object key ) - { - Object obj = super.get( key ); - if ( obj == null ) - { - obj = new ElementAdapterSet( ); + public Object get(Object key) { + Object obj = super.get(key); + if (obj == null) { + obj = new ElementAdapterSet(); // need sync? // obj = Collections.synchronizedSortedSet( new // ElementAdapterSet( ) ); - put( key, obj ); + put(key, obj); } return obj; } + }; - static - { + static { // initial adaptersMap - IExtensionRegistry registry = Platform.getExtensionRegistry( ); - IExtensionPoint extensionPoint = registry.getExtensionPoint( ADAPTERS_EXTENSION_ID ); - if ( extensionPoint != null ) - { - IConfigurationElement[] elements = extensionPoint.getConfigurationElements( ); - for ( int j = 0; j < elements.length; j++ ) - { - String adaptableClassName = elements[j].getAttribute( "class" ); //$NON-NLS-1$ + IExtensionRegistry registry = Platform.getExtensionRegistry(); + IExtensionPoint extensionPoint = registry.getExtensionPoint(ADAPTERS_EXTENSION_ID); + if (extensionPoint != null) { + IConfigurationElement[] elementArr = extensionPoint.getConfigurationElements(); + for (IConfigurationElement element : elementArr) { + String adaptableClassName = element.getAttribute("class"); //$NON-NLS-1$ Class adaptableType = null; - IConfigurationElement[] adapters = elements[j].getChildren( "adapter" ); //$NON-NLS-1$ - for ( int k = 0; k < adapters.length; k++ ) - { + IConfigurationElement[] adaptersConfigArr = element.getChildren("adapter"); //$NON-NLS-1$ + for (IConfigurationElement adapterConfig : adaptersConfigArr) { String adapterClassName = null; Class adapterType = null; - try - { - DecompilerAdapter adapter = new DecompilerAdapter( ); - adapter.setId( adapters[k].getAttribute( "id" ) ); //$NON-NLS-1$ + try { + DecompilerAdapter adapter = new DecompilerAdapter(); + adapter.setId(adapterConfig.getAttribute("id")); //$NON-NLS-1$ - adapter.setSingleton( !"false".equals( //$NON-NLS-1$ - adapters[k].getAttribute( "singleton" ) ) ); //$NON-NLS-1$ + adapter.setSingleton(!"false".equals( //$NON-NLS-1$ + adapterConfig.getAttribute("singleton"))); //$NON-NLS-1$ - if ( adapters[k].getAttribute( "class" ) != null //$NON-NLS-1$ - && !adapters[k].getAttribute( "class" ) //$NON-NLS-1$ - .equals( "" ) ) //$NON-NLS-1$ + if (adapterConfig.getAttribute("class") != null //$NON-NLS-1$ + && !adapterConfig.getAttribute("class") //$NON-NLS-1$ + .equals("")) //$NON-NLS-1$ { - adapter.setAdapterInstance( adapters[k].createExecutableExtension( "class" ) ); //$NON-NLS-1$ + adapter.setAdapterInstance(adapterConfig.createExecutableExtension("class")); //$NON-NLS-1$ - if ( !adapter.isSingleton( ) ) - { - // cache the config element to create new - // instance - adapter.setAdapterConfig( adapters[k] ); + if (!adapter.isSingleton()) { + // cache the config element to create new instance + adapter.setAdapterConfig(adapterConfig); } - } - else if ( adapters[k].getAttribute( "factory" ) != null //$NON-NLS-1$ - && !adapters[k].getAttribute( "factory" ) //$NON-NLS-1$ - .equals( "" ) ) //$NON-NLS-1$ + } else if (adapterConfig.getAttribute("factory") != null //$NON-NLS-1$ + && !adapterConfig.getAttribute("factory") //$NON-NLS-1$ + .equals("")) //$NON-NLS-1$ { - adapter.setFactory( (IAdapterFactory) adapters[k].createExecutableExtension( "factory" ) ); //$NON-NLS-1$ + adapter.setFactory((IAdapterFactory) adapterConfig.createExecutableExtension("factory")); //$NON-NLS-1$ } - if ( adaptableType == null ) - { - adaptableType = classForName( adaptableClassName, - adapter.getAdapterInstance( ), - adapter.getFactory( ) ); + if (adaptableType == null) { + adaptableType = classForName(adaptableClassName, adapter.getAdapterInstance(), + adapter.getFactory()); } - adapter.setAdaptableType( adaptableType ); + adapter.setAdaptableType(adaptableType); - adapterClassName = adapters[k].getAttribute( "type" ); //$NON-NLS-1$ + adapterClassName = adapterConfig.getAttribute("type"); //$NON-NLS-1$ - adapterType = classForName( adapterClassName, - adapter.getAdapterInstance( ), - adapter.getFactory( ) ); + adapterType = classForName(adapterClassName, adapter.getAdapterInstance(), + adapter.getFactory()); - adapter.setAdapterType( adapterType ); + adapter.setAdapterType(adapterType); - if ( adapters[k].getAttribute( "priority" ) != null //$NON-NLS-1$ - && !adapters[k].getAttribute( "priority" ) //$NON-NLS-1$ - .equals( "" ) ) //$NON-NLS-1$ + if (adapterConfig.getAttribute("priority") != null //$NON-NLS-1$ + && !adapterConfig.getAttribute("priority") //$NON-NLS-1$ + .equals("")) //$NON-NLS-1$ { - try - { - adapter.setPriority( Integer.parseInt( adapters[k].getAttribute( "priority" ) ) ); //$NON-NLS-1$ - } - catch ( NumberFormatException e ) - { + try { + adapter.setPriority(Integer.parseInt(adapterConfig.getAttribute("priority"))); //$NON-NLS-1$ + } catch (NumberFormatException e) { } } - if ( adapters[k].getAttribute( "overwrite" ) != null //$NON-NLS-1$ - && !adapters[k].getAttribute( "overwrite" ) //$NON-NLS-1$ - .equals( "" ) ) //$NON-NLS-1$ + if (adapterConfig.getAttribute("overwrite") != null //$NON-NLS-1$ + && !adapterConfig.getAttribute("overwrite") //$NON-NLS-1$ + .equals("")) //$NON-NLS-1$ { - adapter.setOverwrite( adapters[k].getAttribute( "overwrite" ) //$NON-NLS-1$ - .split( ";" ) ); //$NON-NLS-1$ + adapter.setOverwrite(adapterConfig.getAttribute("overwrite") //$NON-NLS-1$ + .split(";")); //$NON-NLS-1$ } - adapter.setIncludeWorkbenchContribute( "true".equals( adapters[k].getAttribute( //$NON-NLS-1$ - "includeWorkbenchContribute" ) ) ); //$NON-NLS-1$ + adapter.setIncludeWorkbenchContribute("true".equals(adapterConfig.getAttribute( //$NON-NLS-1$ + "includeWorkbenchContribute"))); //$NON-NLS-1$ - IConfigurationElement[] enablements = adapters[k].getChildren( "enablement" ); //$NON-NLS-1$ - if ( enablements != null && enablements.length > 0 ) - adapter.setExpression( ExpressionConverter.getDefault( ).perform( enablements[0] ) ); - registerAdapter( adaptableType, adapter ); - } - catch ( ClassNotFoundException ce ) - { - if ( adaptableType == null ) - { - System.out.println( MessageFormat.format( "Adaptable Type class '{0}' not found!", //$NON-NLS-1$ - new Object[]{ - adaptableClassName - } ) ); - logger.log( Level.SEVERE, ce.getMessage( ), ce ); + IConfigurationElement[] enablements = adapterConfig.getChildren("enablement"); //$NON-NLS-1$ + if (enablements != null && enablements.length > 0) { + adapter.setExpression(ExpressionConverter.getDefault().perform(enablements[0])); } - else - { - System.out.println( MessageFormat.format( "Adapter Type class '{0}' not found!", //$NON-NLS-1$ - new Object[]{ - adapterClassName - } ) ); - logger.log( Level.SEVERE, ce.getMessage( ), ce ); + registerAdapter(adaptableType, adapter); + } catch (ClassNotFoundException ce) { + if (adaptableType == null) { + System.out.println(MessageFormat.format("Adaptable Type class '{0}' not found!", //$NON-NLS-1$ + new Object[] { adaptableClassName })); + logger.log(Level.SEVERE, ce.getMessage(), ce); + } else { + System.out.println(MessageFormat.format("Adapter Type class '{0}' not found!", //$NON-NLS-1$ + new Object[] { adapterClassName })); + logger.log(Level.SEVERE, ce.getMessage(), ce); } - } - catch ( Exception e ) - { - System.out.println( "Register adapter error!" ); //$NON-NLS-1$ - logger.log( Level.SEVERE, e.getMessage( ), e ); + } catch (Exception e) { + System.out.println("Register adapter error!"); //$NON-NLS-1$ + logger.log(Level.SEVERE, e.getMessage(), e); } } } } } - private static Class classForName( String className, Object adapterInstance, IAdapterFactory adapterFacotry ) - throws ClassNotFoundException - { + private static Class classForName(String className, Object adapterInstance, IAdapterFactory adapterFacotry) + throws ClassNotFoundException { Class clazz = null; - if ( adapterInstance != null ) - { - try - { - clazz = adapterInstance.getClass( ).getClassLoader( ).loadClass( className ); - } - catch ( ClassNotFoundException ex ) - { + if (adapterInstance != null) { + try { + clazz = adapterInstance.getClass().getClassLoader().loadClass(className); + } catch (ClassNotFoundException ex) { // fail over } } - if ( clazz == null && adapterFacotry != null ) - { - try - { - clazz = adapterFacotry.getClass( ).getClassLoader( ).loadClass( className ); - } - catch ( ClassNotFoundException ex ) - { + if (clazz == null && adapterFacotry != null) { + try { + clazz = adapterFacotry.getClass().getClassLoader().loadClass(className); + } catch (ClassNotFoundException ex) { // it is possible that the default bundle classloader is unaware // of this class, but the adaptor factory can load it in some // other way. See bug 200068. - Class[] adapterList = adapterFacotry.getAdapterList( ); - if ( adapterList != null && adapterList.length > 0 ) - { - for ( int i = 0; i < adapterList.length; i++ ) - { - if ( className.equals( adapterList[i].getName( ) ) ) - { - clazz = adapterList[i]; + Class[] adapterClassArr = adapterFacotry.getAdapterList(); + if (adapterClassArr != null) { + for (Class adapterClass : adapterClassArr) { + if (className.equals(adapterClass.getName())) { + clazz = adapterClass; break; } } @@ -228,20 +184,17 @@ private static Class classForName( String className, Object adapterInstance, } } - if ( clazz == null ) - { - clazz = Class.forName( className ); + if (clazz == null) { + clazz = Class.forName(className); } return clazz; } - public static void registerAdapter( Class adaptableType, DecompilerAdapter adapter ) - { - synchronized ( adaptersMap ) - { - Set adapterSet = (Set) adaptersMap.get( adaptableType ); - adapterSet.add( adapter ); + public static void registerAdapter(Class adaptableType, DecompilerAdapter adapter) { + synchronized (ADAPTERS_MAP) { + Set adapterSet = ADAPTERS_MAP.get(adaptableType); + adapterSet.add(adapter); // if ( adapterSet.add( adapter ) ) // System.out.println( "Register adapter for " // + adaptableType.getName( ) @@ -255,168 +208,64 @@ public static void registerAdapter( Class adaptableType, DecompilerAdapter adapt } } - public static Object[] getAdapters( Object adaptableObject, Class adatperType ) - { - List adapterObjects = getAdapterList( adaptableObject, adatperType ); - - return ( adapterObjects != null && adapterObjects.size( ) > 0 ) - ? adapterObjects.toArray( new Object[adapterObjects.size( )] ) - : null; - } - - public static Object getAdapter( Object adaptableObject, Class adatperType ) - { - List adapterObjects = getAdapterList( adaptableObject, adatperType ); - if ( adapterObjects == null || adapterObjects.size( ) == 0 ) + public static Object getAdapter(Object adaptableObject, Class adapterType) { + List adapterObjects = getAdapterList(adaptableObject, adapterType); + if (adapterObjects == null || adapterObjects.size() == 0) { return null; - else if ( adapterObjects.size( ) == 1 ) - return adapterObjects.get( 0 ); - else - return Proxy.newProxyInstance( adatperType.getClassLoader( ), new Class[]{ - adatperType - }, new DecompilerAdapterInvocationHandler( adapterObjects ) ); + } + if (adapterObjects.size() == 1) { + return adapterObjects.get(0); + } + return Proxy.newProxyInstance(adapterType.getClassLoader(), new Class[] { adapterType }, + new DecompilerAdapterInvocationHandler(adapterObjects)); } - private static List getAdapterList( Object adaptableObject, Class adatperType ) - { - Set adapters = getAdapters( adaptableObject ); - if ( adapters == null ) + public static List getAdapterList(Object adaptableObject, Class adapterType) { + Set adapters = getAdaptersInternal(adaptableObject); + if (adapters == null) { return null; + } - List adapterObjects = new ArrayList( ); - l: for ( Iterator iter = adapters.iterator( ); iter.hasNext( ); ) - { - DecompilerAdapter adapter = (DecompilerAdapter) iter.next( ); - if ( adapter.getExpression( ) != null ) - { - EvaluationContext context = new EvaluationContext( null, adaptableObject ); - context.setAllowPluginActivation( true ); - try - { - if ( adapter.getExpression( ).evaluate( context ) != EvaluationResult.TRUE ) - continue l; - } - catch ( CoreException e ) - { + List adapterObjects = new ArrayList<>(adapters.size()); + for (DecompilerAdapter adapter : adapters) { + if (adapter.getExpression() != null) { + EvaluationContext context = new EvaluationContext(null, adaptableObject); + context.setAllowPluginActivation(true); + try { + if (adapter.getExpression().evaluate(context) != EvaluationResult.TRUE) { + continue; + } + } catch (CoreException e) { } } - Object obj = adapter.getAdater( adaptableObject ); - if ( obj != null && adatperType.isAssignableFrom( obj.getClass( ) ) ) - { - adapterObjects.add( obj ); + Object obj = adapter.getAdater(adaptableObject); + if (obj != null && adapterType.isAssignableFrom(obj.getClass())) { + adapterObjects.add((T) obj); } } return adapterObjects; } - private static Set getAdapters( Object adaptableObject ) - { - Set keys = adaptersMap.keySet( ); + private static Set getAdaptersInternal(Object adaptableObject) { + Set> keys = ADAPTERS_MAP.keySet(); ElementAdapterSet adapters = null; - for ( Iterator iter = keys.iterator( ); iter.hasNext( ); ) - { - Class clazz = (Class) iter.next( ); + for (Class clazz : keys) { // adaptable is the instance of the key class or its subclass. - if ( clazz.isAssignableFrom( adaptableObject.getClass( ) ) ) - { - if ( adapters == null ) - { - adapters = new ElementAdapterSet( ); + if (clazz.isAssignableFrom(adaptableObject.getClass())) { + if (adapters == null) { + adapters = new ElementAdapterSet(); } - Set set = (Set) adaptersMap.get( clazz ); - for ( Iterator iterator = set.iterator( ); iterator.hasNext( ); ) - { - adapters.add( iterator.next( ) ); + Set set = ADAPTERS_MAP.get(clazz); + for (Object obj : set) { + adapters.add((DecompilerAdapter) obj); } } } - if ( adapters != null ) - adapters.reset( ); - return adapters; - } - -} - -/** - * ElementAdapterSet - */ -class ElementAdapterSet extends TreeSet -{ - - private static final long serialVersionUID = -3451274084543012212L; - - private static Comparator comparator = new Comparator( ) { - - @Override - public int compare( Object o1, Object o2 ) - { - if ( o1 instanceof DecompilerAdapter && o2 instanceof DecompilerAdapter ) - { - DecompilerAdapter adapter1 = (DecompilerAdapter) o1; - DecompilerAdapter adapter2 = (DecompilerAdapter) o2; - if ( adapter1.equals( adapter2 ) ) - return 0; - int value = adapter1.getPriority( ) - adapter2.getPriority( ); - return value == 0 ? 1 : value; - } - return 0; - } - }; - - private List overwriteList; - - private boolean isReset; - - /** - * A TreeSet sorted by ElementAdapter.getPriority( ). - */ - public ElementAdapterSet( ) - { - super( comparator ); - } - - @Override - public boolean add( Object o ) - { - if ( o instanceof DecompilerAdapter ) - { - // cached overwrited adapters - DecompilerAdapter adapter = (DecompilerAdapter) o; - String[] overwriteIds = adapter.getOverwrite( ); - if ( overwriteIds != null && overwriteIds.length > 0 ) - { - if ( this.overwriteList == null ) - { - this.overwriteList = new ArrayList( ); - } - for ( int i = 0; i < overwriteIds.length; i++ ) - { - this.overwriteList.add( overwriteIds[i] ); - } - } - return super.add( o ); + if (adapters != null) { + adapters.removeOverwrittenAdapters(); } - return false; + return adapters; } - /** - * remove overwrited adapters. - */ - public void reset( ) - { - if ( !isReset && this.overwriteList != null ) - { - for ( Iterator iterator = this.iterator( ); iterator.hasNext( ); ) - { - DecompilerAdapter adapter = (DecompilerAdapter) iterator.next( ); - if ( this.overwriteList.contains( adapter.getId( ) ) ) - { - iterator.remove( ); - DecompilerAdapterManager.logger.log( Level.FINE, "<" + adapter.getId( ) + "> is overwritten." ); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - this.isReset = true; - } - } } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/extension/ElementAdapterSet.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/extension/ElementAdapterSet.java new file mode 100644 index 00000000..8d7a88e8 --- /dev/null +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/extension/ElementAdapterSet.java @@ -0,0 +1,78 @@ +package org.sf.feeling.decompiler.extension; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Iterator; +import java.util.List; +import java.util.TreeSet; +import java.util.logging.Level; + +/** + * ElementAdapterSet + */ +class ElementAdapterSet extends TreeSet { + + private static final long serialVersionUID = -3451274084543012212L; + + private static Comparator comparator = new Comparator() { + + @Override + public int compare(Object o1, Object o2) { + if (o1 instanceof DecompilerAdapter && o2 instanceof DecompilerAdapter) { + DecompilerAdapter adapter1 = (DecompilerAdapter) o1; + DecompilerAdapter adapter2 = (DecompilerAdapter) o2; + if (adapter1.equals(adapter2)) { + return 0; + } + int value = adapter1.getPriority() - adapter2.getPriority(); + return value == 0 ? 1 : value; + } + return 0; + } + }; + + private List overwriteList; + + private boolean overWrittenAdaptersRemoved; + + /** + * A TreeSet sorted by ElementAdapter.getPriority( ). + */ + public ElementAdapterSet() { + super(comparator); + } + + @Override + public boolean add(DecompilerAdapter o) { + if (o instanceof DecompilerAdapter) { + // cached overwrited adapters + DecompilerAdapter adapter = (DecompilerAdapter) o; + String[] overwriteIds = adapter.getOverwrite(); + if (overwriteIds != null && overwriteIds.length > 0) { + if (this.overwriteList == null) { + this.overwriteList = new ArrayList<>(); + } + Collections.addAll(overwriteList, overwriteIds); + } + return super.add(o); + } + return false; + } + + /** + * remove overwritten adapters. + */ + public void removeOverwrittenAdapters() { + if (!overWrittenAdaptersRemoved && this.overwriteList != null) { + for (Iterator iterator = this.iterator(); iterator.hasNext();) { + DecompilerAdapter adapter = iterator.next(); + if (this.overwriteList.contains(adapter.getId())) { + iterator.remove(); + DecompilerAdapterManager.logger.log(Level.FINE, "<" + adapter.getId() + "> is overwritten."); //$NON-NLS-1$ //$NON-NLS-2$ + } + } + this.overWrittenAdaptersRemoved = true; + } + } +} \ No newline at end of file diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/extension/IDecompilerExtensionHandler.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/extension/IDecompilerExtensionHandler.java deleted file mode 100644 index 7c8d7228..00000000 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/extension/IDecompilerExtensionHandler.java +++ /dev/null @@ -1,18 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.extension; - -public interface IDecompilerExtensionHandler -{ - - void execute( ); -} diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/fernflower/FernFlowerDecompiler.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/fernflower/FernFlowerDecompiler.java deleted file mode 100644 index 272fc327..00000000 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/fernflower/FernFlowerDecompiler.java +++ /dev/null @@ -1,220 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.fernflower; - -import java.io.File; -import java.io.FilenameFilter; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler; -import org.jetbrains.java.decompiler.main.extern.IFernflowerLogger; -import org.jetbrains.java.decompiler.main.extern.IFernflowerPreferences; -import org.sf.feeling.decompiler.JavaDecompilerPlugin; -import org.sf.feeling.decompiler.editor.DecompilerType; -import org.sf.feeling.decompiler.editor.IDecompiler; -import org.sf.feeling.decompiler.util.ClassUtil; -import org.sf.feeling.decompiler.util.FileUtil; -import org.sf.feeling.decompiler.util.JarClassExtractor; -import org.sf.feeling.decompiler.util.UnicodeUtil; - -public class FernFlowerDecompiler implements IDecompiler -{ - - private String source = ""; // $NON-NLS-1$ //$NON-NLS-1$ - private long time, start; - private String log = ""; //$NON-NLS-1$ - - /** - * Performs a Runtime.exec() on jad executable with selected - * options. - * - * @see IDecompiler#decompile(String, String, String) - */ - @Override - public void decompile( String root, String packege, final String className ) - { - if ( root == null || packege == null || className == null ) - return; - - start = System.currentTimeMillis( ); - log = ""; //$NON-NLS-1$ - source = ""; //$NON-NLS-1$ - File workingDir = new File( root + "/" + packege ); //$NON-NLS-1$ - - Map mapOptions = new HashMap( ); - - mapOptions.put( IFernflowerPreferences.REMOVE_SYNTHETIC, "1" ); //$NON-NLS-1$ - mapOptions.put( IFernflowerPreferences.DECOMPILE_GENERIC_SIGNATURES, "1" ); //$NON-NLS-1$ - mapOptions.put( IFernflowerPreferences.DECOMPILE_INNER, "1" ); //$NON-NLS-1$ - mapOptions.put( IFernflowerPreferences.DECOMPILE_ENUM, "1" ); //$NON-NLS-1$ - mapOptions.put( IFernflowerPreferences.LOG_LEVEL, IFernflowerLogger.Severity.ERROR.name( ) ); - mapOptions.put( IFernflowerPreferences.ASCII_STRING_CHARACTERS, "1" ); //$NON-NLS-1$ - if ( ClassUtil.isDebug( ) ) - { - mapOptions.put( IFernflowerPreferences.DUMP_ORIGINAL_LINES, "1" ); //$NON-NLS-1$ - mapOptions.put( IFernflowerPreferences.BYTECODE_SOURCE_MAPPING, "1" ); //$NON-NLS-1$ - } - - File tmpDir = new File( System.getProperty( "java.io.tmpdir" ), //$NON-NLS-1$ - String.valueOf( System.currentTimeMillis( ) ) ); - - if ( !tmpDir.exists( ) ) - tmpDir.mkdirs( ); - - ConsoleDecompiler decompiler = new ConsoleDecompiler( tmpDir, mapOptions ); - File[] files = workingDir.listFiles( new FilenameFilter( ) { - - @Override - public boolean accept( File dir, String name ) - { - if ( name.toLowerCase( ).indexOf( className.toLowerCase( ) ) != -1 ) - return true; - return false; - } - } ); - if ( files != null ) - { - for ( int j = 0; j < files.length; j++ ) - { - decompiler.addSpace( files[j], true ); - } - } - - decompiler.decompileContext( ); - - File classFile = new File( tmpDir, className.replaceAll( "(?i)\\.class", ".java" ) ); //$NON-NLS-1$ //$NON-NLS-2$ - - source = UnicodeUtil.decode( FileUtil.getContent( classFile ) ); - - classFile.delete( ); - - FileUtil.deltree( tmpDir ); - - Pattern wp = Pattern.compile( "/\\*.+?\\*/", Pattern.DOTALL ); //$NON-NLS-1$ - Matcher m = wp.matcher( source ); - while ( m.find( ) ) - { - if ( m.group( ).matches( "/\\*\\s*\\d*\\s*\\*/" ) ) //$NON-NLS-1$ - continue; - String group = m.group( ); - group = group.replace( "/*", "" ); //$NON-NLS-1$ //$NON-NLS-2$ - group = group.replace( "*/", "" ); //$NON-NLS-1$ //$NON-NLS-2$ - group = group.replace( "*", "" ); //$NON-NLS-1$ //$NON-NLS-2$ - if ( log.length( ) > 0 ) - log += "\n"; //$NON-NLS-1$ - log += group; - - source = source.replace( m.group( ), "" ); //$NON-NLS-1$ - } - - time = System.currentTimeMillis( ) - start; - } - - /** - * Jad doesn't support decompilation from archives. This methods extracts - * request class file from the specified archive into temp directory and - * then calls decompile. - * - * @see IDecompiler#decompileFromArchive(String, String, String) - */ - @Override - 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$ - + System.currentTimeMillis( ) ); - - try - { - workingDir.mkdirs( ); - JarClassExtractor.extract( archivePath, packege, className, true, workingDir.getAbsolutePath( ) ); - decompile( workingDir.getAbsolutePath( ), "", className ); //$NON-NLS-1$ - } - catch ( Exception e ) - { - JavaDecompilerPlugin.logError( e, e.getMessage( ) ); - return; - } - finally - { - FileUtil.deltree( workingDir ); - } - } - - @Override - public long getDecompilationTime( ) - { - return time; - } - - @Override - public List getExceptions( ) - { - return Collections.EMPTY_LIST; - } - - /** - * @see IDecompiler#getLog() - */ - @Override - public String getLog( ) - { - return log; - } - - /** - * @see IDecompiler#getSource() - */ - @Override - public String getSource( ) - { - return source; - } - - @Override - public String getDecompilerType( ) - { - return DecompilerType.FernFlower; - } - - @Override - public String removeComment( String source ) - { - return source; - } - - @Override - public boolean supportLevel( int level ) - { - return true; - } - - @Override - public boolean supportDebugLevel( int level ) - { - return true; - } - - @Override - public boolean supportDebug( ) - { - return true; - } - -} \ No newline at end of file diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/fernflower/FernFlowerSourceMapper.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/fernflower/FernFlowerSourceMapper.java deleted file mode 100644 index 3083ef33..00000000 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/fernflower/FernFlowerSourceMapper.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.fernflower; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Collection; -import java.util.Iterator; - -import org.eclipse.core.runtime.Path; -import org.sf.feeling.decompiler.editor.BaseDecompilerSourceMapper; - -public class FernFlowerSourceMapper extends BaseDecompilerSourceMapper -{ - - public FernFlowerSourceMapper( ) - { - super( new Path( "." ), "" ); //$NON-NLS-1$ //$NON-NLS-2$ - origionalDecompiler = new FernFlowerDecompiler( ); - } - - @Override - protected void printDecompileReport( StringBuffer source, String fileLocation, Collection exceptions, - long decompilationTime ) - { - String location = "\tDecompiled from: " //$NON-NLS-1$ - + fileLocation; - source.append( "\n\n/*" ); //$NON-NLS-1$ - source.append( "\n\tDECOMPILATION REPORT\n\n" ); //$NON-NLS-1$ - source.append( location ).append( "\n" ); //$NON-NLS-1$ - source.append( "\tTotal time: " ) //$NON-NLS-1$ - .append( decompilationTime ) - .append( " ms\n" ); //$NON-NLS-1$ - source.append( "\t" //$NON-NLS-1$ - + origionalDecompiler.getLog( ) - .replaceAll( "\t", "" ) //$NON-NLS-1$ //$NON-NLS-2$ - .replaceAll( "\n\\s*", "\n\t" ) ); //$NON-NLS-1$ //$NON-NLS-2$ - exceptions.addAll( origionalDecompiler.getExceptions( ) ); - logExceptions( exceptions, source ); - source.append( "\n\tDecompiled with FernFlower." ); //$NON-NLS-1$ - source.append( "\n*/" ); //$NON-NLS-1$ - } - - protected void logExceptions( Collection exceptions, StringBuffer buffer ) - { - if ( !exceptions.isEmpty( ) ) - { - buffer.append( "\n\tCaught exceptions:" ); //$NON-NLS-1$ - if ( exceptions == null || exceptions.size( ) == 0 ) - return; // nothing to do - buffer.append( "\n" ); //$NON-NLS-1$ - StringWriter stackTraces = new StringWriter( ); - PrintWriter stackTracesP = new PrintWriter( stackTraces ); - - Iterator i = exceptions.iterator( ); - while ( i.hasNext( ) ) - { - ( (Exception) i.next( ) ).printStackTrace( stackTracesP ); - stackTracesP.println( "" ); //$NON-NLS-1$ - } - - stackTracesP.flush( ); - stackTracesP.close( ); - buffer.append( stackTraces.toString( ) ); - } - } -} \ No newline at end of file diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/i18n/EcdResouceBundle.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/i18n/EcdResouceBundle.java new file mode 100644 index 00000000..5abb17ca --- /dev/null +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/i18n/EcdResouceBundle.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2017 Chen Chao and other ECD project contributors. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.sf.feeling.decompiler.i18n; + +import java.io.UnsupportedEncodingException; +import java.text.MessageFormat; +import java.util.Locale; +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +public class EcdResouceBundle { + + protected final ResourceBundle resourceBundle; + + public EcdResouceBundle(Class messagesClass) { + ClassLoader classLoader = messagesClass.getClassLoader(); + Locale targetLocale = Locale.getDefault(); + // Java 8 workaround for messagesClass.getpackageName() + String messageClassName = messagesClass.getName(); + String packageName = messageClassName.substring(0, messageClassName.lastIndexOf(".")); + String resourceBundleName = packageName + ".messages"; + this.resourceBundle = ResourceBundle.getBundle(resourceBundleName, targetLocale, classLoader); + } + + public String getString(String key) { + try { + String result = resourceBundle.getString(key); + try { + result = new String(result.getBytes("ISO-8859-1"), "utf-8"); //$NON-NLS-1$ //$NON-NLS-2$ + } catch (UnsupportedEncodingException e) { + return '!' + key + '!'; + } + return result; + } catch (MissingResourceException e) { + return '!' + key + '!'; + } + } + + /** + * Gets formatted translation for current local + * + * @param key the key + * @return translated value string + */ + public String getFormattedString(String key, Object[] arguments) { + return MessageFormat.format(getString(key), arguments); + } +} diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/i18n/Messages.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/i18n/Messages.java index 1be549ca..e30a23d0 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/i18n/Messages.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/i18n/Messages.java @@ -1,64 +1,32 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.i18n; -import java.io.UnsupportedEncodingException; -import java.text.MessageFormat; -import java.util.MissingResourceException; -import java.util.ResourceBundle; +public class Messages { -public class Messages -{ + private static final EcdResouceBundle RESOURCE_BUNDLE = new EcdResouceBundle(Messages.class); - private static final String BUNDLE_NAME = "org.sf.feeling.decompiler.i18n.messages"; //$NON-NLS-1$ - - public static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); - - private Messages( ) - { + private Messages() { } - public static String getString( String key ) - { - - try - { - String result = RESOURCE_BUNDLE.getString( key ); - try - { - result = new String( result.getBytes( "ISO-8859-1" ), "utf-8" ); //$NON-NLS-1$ //$NON-NLS-2$ - } - catch ( UnsupportedEncodingException e ) - { - return '!' + key + '!'; - } - return result; - } - catch ( MissingResourceException e ) - { - return '!' + key + '!'; - } + public static String getString(String key) { + return RESOURCE_BUNDLE.getString(key); } /** * Gets formatted translation for current local * - * @param key - * the key + * @param key the key * @return translated value string */ - public static String getFormattedString( String key, Object[] arguments ) - { - return MessageFormat.format( getString( key ), arguments ); + public static String getFormattedString(String key, Object[] arguments) { + return RESOURCE_BUNDLE.getFormattedString(key, arguments); } } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/i18n/messages.properties b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/i18n/messages.properties index 38a1077d..6426f23c 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/i18n/messages.properties +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/i18n/messages.properties @@ -1,12 +1,9 @@ ############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). +# Copyright (c) 2017 Chen Chao and other ECD project contributors. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation +# https://www.eclipse.org/legal/epl-v10.html ############################################################################### DebugModeAction.Action.Text=Debug &Mode@Ctrl+Alt+. @@ -46,7 +43,6 @@ ExportSourceAction.WarningDialog.Title=Waring ExportSourceAction.Action.Text=Export &Source... JavaDecompilerActionBarContributor.Action.ByteCode=Show &Byte Code JavaDecompilerActionBarContributor.Action.Decompile=D&ecompile@Ctrl+Alt+, -JavaDecompilerActionBarContributor.Action.DecompileWithFernFlower=Fe&rnFlower JavaDecompilerActionBarContributor.Action.Disassembler=Show Disassemb&ler JavaDecompilerActionBarContributor.Action.ExportSource=Export &Source... JavaDecompilerActionBarContributor.Action.Preferences=&Preferences @@ -60,10 +56,8 @@ JavaDecompilerPlugin.BreakpoingDialog.Message=Can only set breakpoints in debug JavaDecompilerPlugin.BreakpoingDialog.Title=Confirm JavaDecompilerPlugin.BreakpoingWithNumberDialog.Message=Couldn't set the breakpoint, please set a breakpoint before the line with the line number. JavaDecompilerPlugin.BreakpoingWithNumberDialog.Title=Information -JavaDecompilerPreferencePage.Decompiler.FernFlower=FernFlower (Support JDK8) JavaDecompilerPreferencePage.Label.AlignCode=A&lign code for debugging JavaDecompilerPreferencePage.Label.Attach.Source=Search and attach the li&brary source automatically -JavaDecompilerPreferencePage.Label.CheckForUpdate=Check for &major version updates JavaDecompilerPreferencePage.Label.DebugSettings=Debug Settings JavaDecompilerPreferencePage.Label.DecompilerSettings=Decompiler Settings JavaDecompilerPreferencePage.Label.DefaultClassDecompiler=De&fault Class Decompiler diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/i18n/messages_zh_CN.properties b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/i18n/messages_zh_CN.properties deleted file mode 100644 index 526bcd78..00000000 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/i18n/messages_zh_CN.properties +++ /dev/null @@ -1,79 +0,0 @@ -############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation -############################################################################### - -DebugModeAction.Action.Text=调试模å¼(&M)@Ctrl+Alt+. -DisassemblerPreferencePage.Label.AbsoluteAddress=ç»å¯¹åœ°å€(&E) -DisassemblerPreferencePage.Label.BranchTargetAddressSettings=分支目标寻å€è®¾ç½® -DisassemblerPreferencePage.Label.DisassemblerSettings=åæ±‡ç¼–设置 -DisassemblerPreferencePage.Label.RelativeAddress=相对地å€(&R) -DisassemblerPreferencePage.Label.ShowConstant=æ˜¾ç¤ºå¸¸é‡æ± (&C) -DisassemblerPreferencePage.Label.ShowExceptionTable=显示异常表(&P) -DisassemblerPreferencePage.Label.ShowLineNumberTable=显示行å·è¡¨(&P) -DisassemblerPreferencePage.Label.ShowMaxs=显示max_stackå’Œmax_locals(&M) -DisassemblerPreferencePage.Label.ShowSourceLineNumber=显示代ç è¡Œå·(&L) -DisassemblerPreferencePage.Label.ShowTryCatch=渲染try-catch代ç å—(&T) -DisassemblerPreferencePage.Label.ShowVariableTable=显示局部å˜é‡è¡¨(&V) -DisassemblerPreferencePage.Label.StyleBold=粗体(&B) -DisassemblerPreferencePage.Label.StyleColor=颜色(&O) -DisassemblerPreferencePage.Label.StyleItalic=斜体(&I) -DisassemblerPreferencePage.Label.StyleSettings=æ“ä½œç æ ·å¼è®¾ç½® -DisassemblerPreferencePage.Label.StyleStrikethrough=删除线(&S) -DisassemblerPreferencePage.Label.StyleUnderline=下划线(&U) -ExportSourceAction.ErrorDialog.Title=错误 -ExportSourceAction.ErrorDialog.Message.CollectClassInfo=收集Class文件信æ¯å¤±è´¥ã€‚ -ExportSourceAction.InfoDialog.Message.Success=导出Class文件å编译æºç æˆåŠŸã€‚ -ExportSourceAction.InfoDialog.Title=ä¿¡æ¯ -ExportSourceAction.Status.Error.CollectPackage=收集Class文件包信æ¯å¤±è´¥ã€‚ -ExportSourceAction.Status.Error.DecompileAndExport=导出Class文件å编译æºç å¤±è´¥ã€‚ -ExportSourceAction.Status.Error.ExportFailed=导出Class文件å编译æºç å¤±è´¥ã€‚ -ExportSourceAction.Status.Error.DecompileFailed=å编译Class文件{0}失败。 -ExportSourceAction.Task.Begin=正在å编译Class文件... -ExportSourceAction.Task.Clean=正在清ç†ä¸´æ—¶æ–‡ä»¶... -ExportSourceAction.Task.ExportSource=正在导出Class文件å编译æºç ... -ExportSourceAction.WarningDialog.Message.Success=导出Class文件å编译æºç æˆåŠŸã€‚ -ExportSourceAction.InfoDialog.Message.Canceled=æ“ä½œå·²è¢«ç”¨æˆ·å–æ¶ˆã€‚ -ExportSourceAction.WarningDialog.Message.Failed.Multi=导出Class文件å编译æºç æ—¶å‘生了{0}处错误。 -ExportSourceAction.WarningDialog.Message.Failed=导出Class文件å编译æºç æ—¶å‘生了{0}处错误。 -ExportSourceAction.WarningDialog.Title=警告 -ExportSourceAction.Action.Text=导出å编译æºç (&S)... -JavaDecompilerActionBarContributor.Action.ByteCode=显示字节ç (&B) -JavaDecompilerActionBarContributor.Action.Decompile=å编译(&E)@Ctrl+Alt+, -JavaDecompilerActionBarContributor.Action.DecompileWithFernFlower=Fe&rnFlower -JavaDecompilerActionBarContributor.Action.Disassembler=æ˜¾ç¤ºåæ±‡ç¼–代ç (&L) -JavaDecompilerActionBarContributor.Action.ExportSource=导出å编译æºç (&S)... -JavaDecompilerActionBarContributor.Action.Preferences=首选项(&P) -JavaDecompilerActionBarContributor.Action.SourceCode=显示æºä»£ç (&C) -JavaDecompilerActionBarContributor.ErrorDialog.Message.ExportFailed=导出Class文件å编译æºç å¤±è´¥ã€‚ -JavaDecompilerActionBarContributor.ErrorDialog.Title=错误 -JavaDecompilerActionBarContributor.Action.Tooltip.Decompile=å编译 -JavaDecompilerActionBarContributor.Menu.Decompiler=å编译器(&D) -JavaDecompilerActionBarContributor.Menu.OpenClassWith=Class打开方å¼(&H) -JavaDecompilerPlugin.BreakpoingDialog.Message=åªèƒ½åœ¨è°ƒè¯•模å¼ä¸‹è®¾ç½®æ–­ç‚¹ï¼Œæ˜¯å¦è¦ç«‹å³åˆ‡æ¢åˆ°è°ƒè¯•模å¼ï¼Ÿ -JavaDecompilerPlugin.BreakpoingDialog.Title=æç¤º -JavaDecompilerPlugin.BreakpoingWithNumberDialog.Message=ä¸èƒ½è®¾ç½®æ–­ç‚¹ï¼Œè¯·åœ¨å¸¦è¡Œå·çš„行å‰è®¾ç½®æ–­ç‚¹ã€‚ -JavaDecompilerPlugin.BreakpoingWithNumberDialog.Title=ä¿¡æ¯ -JavaDecompilerPreferencePage.Decompiler.FernFlower=FernFlower (支æŒJDK8) -JavaDecompilerPreferencePage.Label.AlignCode=æ ¹æ®è¡Œå·å¯¹é½ä»£ç ä»¥ä¾¿äºŽè°ƒè¯•(&L) -JavaDecompilerPreferencePage.Label.Attach.Source=自动在线查找并绑定类库æºç (&B) -JavaDecompilerPreferencePage.Label.CheckForUpdate=检查é‡è¦ç‰ˆæœ¬æ›´æ–°(&M) -JavaDecompilerPreferencePage.Label.DebugSettings=调试设置 -JavaDecompilerPreferencePage.Label.DecompilerSettings=å编译器设置 -JavaDecompilerPreferencePage.Label.DefaultClassDecompiler=缺çœClasså编译器(&F) -JavaDecompilerPreferencePage.Label.DefaultEditor=设置Classå编译查看器作为缺çœçš„Class文件编辑器(&C) -JavaDecompilerPreferencePage.Label.Export.Encoding=æºç å¯¼å‡ºç¼–ç è®¾ç½® -JavaDecompilerPreferencePage.Label.FormatSettings=æ ¼å¼åŒ–与排åºè®¾ç½® -JavaDecompilerPreferencePage.Label.IgnoreExistSource=忽略已存在的æºç (&I) -JavaDecompilerPreferencePage.Label.OutputLineNumber=以注释的方å¼è¾“出原始行å·ä¿¡æ¯(&N) -JavaDecompilerPreferencePage.Label.ReuseCodeBuffer=é‡ç”¨ç¼“存代ç (&R) -JavaDecompilerPreferencePage.Label.ShowDecompilerReport=显示å编译器报告(&S) -JavaDecompilerPreferencePage.Label.Startup=å¯åЍ -JavaDecompilerPreferencePage.Label.UseEclipseFormat=使用Ecli&pseä»£ç æ ¼å¼åŒ–工具 -JavaDecompilerPreferencePage.Lable.UseEclipseSorter=使用&Eclipseæˆå‘˜æŽ’åº diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/i18n/messages_zh_HK.properties b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/i18n/messages_zh_HK.properties deleted file mode 100644 index e9f32eef..00000000 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/i18n/messages_zh_HK.properties +++ /dev/null @@ -1,79 +0,0 @@ -############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation -############################################################################### - -DebugModeAction.Action.Text=調試模å¼(&M)@Ctrl+Alt+. -DisassemblerPreferencePage.Label.AbsoluteAddress=絕å°åœ°å€(&E) -DisassemblerPreferencePage.Label.BranchTargetAddressSettings=分支目標尋å€è¨­ç½® -DisassemblerPreferencePage.Label.DisassemblerSettings=å匯編設置 -DisassemblerPreferencePage.Label.RelativeAddress=相å°åœ°å€(&R) -DisassemblerPreferencePage.Label.ShowConstant=é¡¯ç¤ºå¸¸é‡æ± (&C) -DisassemblerPreferencePage.Label.ShowExceptionTable=顯示異常表(&P) -DisassemblerPreferencePage.Label.ShowLineNumberTable=顯示行號表(&P) -DisassemblerPreferencePage.Label.ShowMaxs=顯示max_stackå’Œmax_locals(&M) -DisassemblerPreferencePage.Label.ShowSourceLineNumber=顯示代碼行號(&L) -DisassemblerPreferencePage.Label.ShowTryCatch=渲染try-catch代碼塊(&T) -DisassemblerPreferencePage.Label.ShowVariableTable=顯示局部變é‡è¡¨(&V) -DisassemblerPreferencePage.Label.StyleBold=ç²—é«”(&B) -DisassemblerPreferencePage.Label.StyleColor=é¡è‰²(&O) -DisassemblerPreferencePage.Label.StyleItalic=斜體(&I) -DisassemblerPreferencePage.Label.StyleSettings=æ“作碼樣å¼è¨­ç½® -DisassemblerPreferencePage.Label.StyleStrikethrough=刪除線(&S) -DisassemblerPreferencePage.Label.StyleUnderline=下劃線(&U) -ExportSourceAction.ErrorDialog.Title=錯誤 -ExportSourceAction.ErrorDialog.Message.CollectClassInfo=收集Class文件信æ¯å¤±æ•—。 -ExportSourceAction.InfoDialog.Message.Success=導出Class文件å編譯æºä»£ç¢¼æˆåŠŸã€‚ -ExportSourceAction.InfoDialog.Title=ä¿¡æ¯ -ExportSourceAction.Status.Error.CollectPackage=收集Class文件包信æ¯å¤±æ•—。 -ExportSourceAction.Status.Error.DecompileAndExport=導出Class文件å編譯æºä»£ç¢¼å¤±æ•—。 -ExportSourceAction.Status.Error.ExportFailed=導出Class文件å編譯æºä»£ç¢¼å¤±æ•—。 -ExportSourceAction.Status.Error.DecompileFailed=å編譯Class文件{0}失敗。 -ExportSourceAction.Task.Begin=正在å編譯Class文件... -ExportSourceAction.Task.Clean=正在清ç†è‡¨æ™‚文件... -ExportSourceAction.Task.ExportSource=正在導出Class文件å編譯æºä»£ç¢¼... -ExportSourceAction.WarningDialog.Message.Success=導出Class文件å編譯æºä»£ç¢¼æˆåŠŸã€‚ -ExportSourceAction.InfoDialog.Message.Canceled=æ“ä½œå·²è¢«ç”¨æˆ¶å–æ¶ˆã€‚ -ExportSourceAction.WarningDialog.Message.Failed.Multi=導出Class文件å編譯æºä»£ç¢¼æ™‚發生了{0}處錯誤。 -ExportSourceAction.WarningDialog.Message.Failed=導出Class文件å編譯æºä»£ç¢¼æ™‚發生了{0}處錯誤。 -ExportSourceAction.WarningDialog.Title=警告 -ExportSourceAction.Action.Text=導出å編譯æºä»£ç¢¼(&S)... -JavaDecompilerActionBarContributor.Action.ByteCode=顯示字節碼(&B) -JavaDecompilerActionBarContributor.Action.Decompile=å編譯(&E)@Ctrl+Alt+, -JavaDecompilerActionBarContributor.Action.DecompileWithFernFlower=Fe&rnFlower -JavaDecompilerActionBarContributor.Action.Disassembler=顯示å匯編代碼(&L) -JavaDecompilerActionBarContributor.Action.ExportSource=導出å編譯æºä»£ç¢¼(&S)... -JavaDecompilerActionBarContributor.Action.Preferences=首é¸é …(&P) -JavaDecompilerActionBarContributor.Action.SourceCode=顯示æºä»£ç¢¼(&C) -JavaDecompilerActionBarContributor.ErrorDialog.Message.ExportFailed=導出Class文件å編譯æºä»£ç¢¼å¤±æ•—。 -JavaDecompilerActionBarContributor.ErrorDialog.Title=錯誤 -JavaDecompilerActionBarContributor.Action.Tooltip.Decompile=å編譯 -JavaDecompilerActionBarContributor.Menu.Decompiler=å編譯器(&D) -JavaDecompilerActionBarContributor.Menu.OpenClassWith=Class打開方å¼(&H) -JavaDecompilerPlugin.BreakpoingDialog.Message=åªèƒ½åœ¨èª¿è©¦æ¨¡å¼ä¸‹è¨­ç½®æ–·é»žï¼Œæ˜¯å¦è¦ç«‹å³åˆ‡æ›åˆ°èª¿è©¦æ¨¡å¼ï¼Ÿ -JavaDecompilerPlugin.BreakpoingDialog.Title=æç¤º -JavaDecompilerPlugin.BreakpoingWithNumberDialog.Message=ä¸èƒ½è¨­ç½®æ–·é»žï¼Œè«‹åœ¨å¸¶è¡Œè™Ÿçš„行å‰è¨­ç½®æ–·é»žã€‚ -JavaDecompilerPlugin.BreakpoingWithNumberDialog.Title=ä¿¡æ¯ -JavaDecompilerPreferencePage.Decompiler.FernFlower=FernFlower (支æŒJDK8) -JavaDecompilerPreferencePage.Label.AlignCode=根據行號å°é½Šä»£ç¢¼ä»¥ä¾¿æ–¼èª¿è©¦(&L) -JavaDecompilerPreferencePage.Label.Attach.Source=自動在線查找並ç¶å®šé¡žåº«æºç¢¼(&B) -JavaDecompilerPreferencePage.Label.CheckForUpdate=檢查é‡è¦ç‰ˆæœ¬æ›´æ–°(&M) -JavaDecompilerPreferencePage.Label.DebugSettings=調試設置 -JavaDecompilerPreferencePage.Label.DecompilerSettings=å編譯器設置 -JavaDecompilerPreferencePage.Label.DefaultClassDecompiler=缺çœClasså編譯器(&F) -JavaDecompilerPreferencePage.Label.DefaultEditor=設置Classå編譯查看器作為缺çœçš„Class文件編輯器(&C) -JavaDecompilerPreferencePage.Label.Export.Encoding=æºç¢¼å°Žå‡ºç·¨ç¢¼è¨­ç½® -JavaDecompilerPreferencePage.Label.FormatSettings=æ ¼å¼åŒ–與排åºè¨­ç½® -JavaDecompilerPreferencePage.Label.IgnoreExistSource=忽略已存在的æºä»£ç¢¼(&I) -JavaDecompilerPreferencePage.Label.OutputLineNumber=以註釋的方å¼è¼¸å‡ºåŽŸå§‹è¡Œè™Ÿä¿¡æ¯(&N) -JavaDecompilerPreferencePage.Label.ReuseCodeBuffer=é‡ç”¨ç·©å­˜ä»£ç¢¼(&R) -JavaDecompilerPreferencePage.Label.ShowDecompilerReport=顯示å編譯器報告(&S) -JavaDecompilerPreferencePage.Label.Startup=啟動 -JavaDecompilerPreferencePage.Label.UseEclipseFormat=使用Ecli&pse代碼格å¼åŒ–工具 -JavaDecompilerPreferencePage.Lable.UseEclipseSorter=使用&Eclipseæˆå“¡æŽ’åº \ No newline at end of file diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/i18n/messages_zh_TW.properties b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/i18n/messages_zh_TW.properties deleted file mode 100644 index e9f32eef..00000000 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/i18n/messages_zh_TW.properties +++ /dev/null @@ -1,79 +0,0 @@ -############################################################################### -# Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Chen Chao - initial API and implementation -############################################################################### - -DebugModeAction.Action.Text=調試模å¼(&M)@Ctrl+Alt+. -DisassemblerPreferencePage.Label.AbsoluteAddress=絕å°åœ°å€(&E) -DisassemblerPreferencePage.Label.BranchTargetAddressSettings=分支目標尋å€è¨­ç½® -DisassemblerPreferencePage.Label.DisassemblerSettings=å匯編設置 -DisassemblerPreferencePage.Label.RelativeAddress=相å°åœ°å€(&R) -DisassemblerPreferencePage.Label.ShowConstant=é¡¯ç¤ºå¸¸é‡æ± (&C) -DisassemblerPreferencePage.Label.ShowExceptionTable=顯示異常表(&P) -DisassemblerPreferencePage.Label.ShowLineNumberTable=顯示行號表(&P) -DisassemblerPreferencePage.Label.ShowMaxs=顯示max_stackå’Œmax_locals(&M) -DisassemblerPreferencePage.Label.ShowSourceLineNumber=顯示代碼行號(&L) -DisassemblerPreferencePage.Label.ShowTryCatch=渲染try-catch代碼塊(&T) -DisassemblerPreferencePage.Label.ShowVariableTable=顯示局部變é‡è¡¨(&V) -DisassemblerPreferencePage.Label.StyleBold=ç²—é«”(&B) -DisassemblerPreferencePage.Label.StyleColor=é¡è‰²(&O) -DisassemblerPreferencePage.Label.StyleItalic=斜體(&I) -DisassemblerPreferencePage.Label.StyleSettings=æ“作碼樣å¼è¨­ç½® -DisassemblerPreferencePage.Label.StyleStrikethrough=刪除線(&S) -DisassemblerPreferencePage.Label.StyleUnderline=下劃線(&U) -ExportSourceAction.ErrorDialog.Title=錯誤 -ExportSourceAction.ErrorDialog.Message.CollectClassInfo=收集Class文件信æ¯å¤±æ•—。 -ExportSourceAction.InfoDialog.Message.Success=導出Class文件å編譯æºä»£ç¢¼æˆåŠŸã€‚ -ExportSourceAction.InfoDialog.Title=ä¿¡æ¯ -ExportSourceAction.Status.Error.CollectPackage=收集Class文件包信æ¯å¤±æ•—。 -ExportSourceAction.Status.Error.DecompileAndExport=導出Class文件å編譯æºä»£ç¢¼å¤±æ•—。 -ExportSourceAction.Status.Error.ExportFailed=導出Class文件å編譯æºä»£ç¢¼å¤±æ•—。 -ExportSourceAction.Status.Error.DecompileFailed=å編譯Class文件{0}失敗。 -ExportSourceAction.Task.Begin=正在å編譯Class文件... -ExportSourceAction.Task.Clean=正在清ç†è‡¨æ™‚文件... -ExportSourceAction.Task.ExportSource=正在導出Class文件å編譯æºä»£ç¢¼... -ExportSourceAction.WarningDialog.Message.Success=導出Class文件å編譯æºä»£ç¢¼æˆåŠŸã€‚ -ExportSourceAction.InfoDialog.Message.Canceled=æ“ä½œå·²è¢«ç”¨æˆ¶å–æ¶ˆã€‚ -ExportSourceAction.WarningDialog.Message.Failed.Multi=導出Class文件å編譯æºä»£ç¢¼æ™‚發生了{0}處錯誤。 -ExportSourceAction.WarningDialog.Message.Failed=導出Class文件å編譯æºä»£ç¢¼æ™‚發生了{0}處錯誤。 -ExportSourceAction.WarningDialog.Title=警告 -ExportSourceAction.Action.Text=導出å編譯æºä»£ç¢¼(&S)... -JavaDecompilerActionBarContributor.Action.ByteCode=顯示字節碼(&B) -JavaDecompilerActionBarContributor.Action.Decompile=å編譯(&E)@Ctrl+Alt+, -JavaDecompilerActionBarContributor.Action.DecompileWithFernFlower=Fe&rnFlower -JavaDecompilerActionBarContributor.Action.Disassembler=顯示å匯編代碼(&L) -JavaDecompilerActionBarContributor.Action.ExportSource=導出å編譯æºä»£ç¢¼(&S)... -JavaDecompilerActionBarContributor.Action.Preferences=首é¸é …(&P) -JavaDecompilerActionBarContributor.Action.SourceCode=顯示æºä»£ç¢¼(&C) -JavaDecompilerActionBarContributor.ErrorDialog.Message.ExportFailed=導出Class文件å編譯æºä»£ç¢¼å¤±æ•—。 -JavaDecompilerActionBarContributor.ErrorDialog.Title=錯誤 -JavaDecompilerActionBarContributor.Action.Tooltip.Decompile=å編譯 -JavaDecompilerActionBarContributor.Menu.Decompiler=å編譯器(&D) -JavaDecompilerActionBarContributor.Menu.OpenClassWith=Class打開方å¼(&H) -JavaDecompilerPlugin.BreakpoingDialog.Message=åªèƒ½åœ¨èª¿è©¦æ¨¡å¼ä¸‹è¨­ç½®æ–·é»žï¼Œæ˜¯å¦è¦ç«‹å³åˆ‡æ›åˆ°èª¿è©¦æ¨¡å¼ï¼Ÿ -JavaDecompilerPlugin.BreakpoingDialog.Title=æç¤º -JavaDecompilerPlugin.BreakpoingWithNumberDialog.Message=ä¸èƒ½è¨­ç½®æ–·é»žï¼Œè«‹åœ¨å¸¶è¡Œè™Ÿçš„行å‰è¨­ç½®æ–·é»žã€‚ -JavaDecompilerPlugin.BreakpoingWithNumberDialog.Title=ä¿¡æ¯ -JavaDecompilerPreferencePage.Decompiler.FernFlower=FernFlower (支æŒJDK8) -JavaDecompilerPreferencePage.Label.AlignCode=根據行號å°é½Šä»£ç¢¼ä»¥ä¾¿æ–¼èª¿è©¦(&L) -JavaDecompilerPreferencePage.Label.Attach.Source=自動在線查找並ç¶å®šé¡žåº«æºç¢¼(&B) -JavaDecompilerPreferencePage.Label.CheckForUpdate=檢查é‡è¦ç‰ˆæœ¬æ›´æ–°(&M) -JavaDecompilerPreferencePage.Label.DebugSettings=調試設置 -JavaDecompilerPreferencePage.Label.DecompilerSettings=å編譯器設置 -JavaDecompilerPreferencePage.Label.DefaultClassDecompiler=缺çœClasså編譯器(&F) -JavaDecompilerPreferencePage.Label.DefaultEditor=設置Classå編譯查看器作為缺çœçš„Class文件編輯器(&C) -JavaDecompilerPreferencePage.Label.Export.Encoding=æºç¢¼å°Žå‡ºç·¨ç¢¼è¨­ç½® -JavaDecompilerPreferencePage.Label.FormatSettings=æ ¼å¼åŒ–與排åºè¨­ç½® -JavaDecompilerPreferencePage.Label.IgnoreExistSource=忽略已存在的æºä»£ç¢¼(&I) -JavaDecompilerPreferencePage.Label.OutputLineNumber=以註釋的方å¼è¼¸å‡ºåŽŸå§‹è¡Œè™Ÿä¿¡æ¯(&N) -JavaDecompilerPreferencePage.Label.ReuseCodeBuffer=é‡ç”¨ç·©å­˜ä»£ç¢¼(&R) -JavaDecompilerPreferencePage.Label.ShowDecompilerReport=顯示å編譯器報告(&S) -JavaDecompilerPreferencePage.Label.Startup=啟動 -JavaDecompilerPreferencePage.Label.UseEclipseFormat=使用Ecli&pse代碼格å¼åŒ–工具 -JavaDecompilerPreferencePage.Lable.UseEclipseSorter=使用&Eclipseæˆå“¡æŽ’åº \ No newline at end of file diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/postprocessing/CharacterEscaper.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/postprocessing/CharacterEscaper.java new file mode 100644 index 00000000..750b2808 --- /dev/null +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/postprocessing/CharacterEscaper.java @@ -0,0 +1,14 @@ +package org.sf.feeling.decompiler.postprocessing; + +public class CharacterEscaper { + + public static String process(String code) { + + // Replace null character, see https://github.com/ecd-plugin/ecd/issues/122 + // Hopefully null characters only occur in string constants, otherwise this + // replacement would create invalid Java code. + code = code.replace("\u0000", "\\u0000"); + + return code; + } +} diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/postprocessing/LineReformatter.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/postprocessing/LineReformatter.java new file mode 100644 index 00000000..31d49856 --- /dev/null +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/postprocessing/LineReformatter.java @@ -0,0 +1,748 @@ +/******************************************************************************* + * Copyright (c) 2017 Chen Chao and other ECD project contributors. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.sf.feeling.decompiler.postprocessing; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.eclipse.jdt.core.dom.ASTNode; +import org.eclipse.jdt.core.dom.ASTParser; +import org.eclipse.jdt.core.dom.AbstractTypeDeclaration; +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jdt.core.dom.EnumConstantDeclaration; +import org.eclipse.jdt.core.dom.EnumDeclaration; +import org.eclipse.jdt.core.dom.FieldDeclaration; +import org.eclipse.jdt.core.dom.Initializer; +import org.eclipse.jdt.core.dom.MethodDeclaration; +import org.eclipse.jdt.core.dom.TypeDeclaration; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; +import org.sf.feeling.decompiler.editor.IDecompiler; +import org.sf.feeling.decompiler.util.EclipseUtils; + +/** + * Allows to reformat decompiled source code in a way that the source code line + * numbers are considered and the resulting code can be used for debugging. + * + * The line numbers are extracted from code comments inserted by the + * decompilers. + */ +public class LineReformatter { + + public static final String NO_LINE_NUMBER = "// Warning: No line numbers available in class file"; //$NON-NLS-1$ + + public final static String line_separator = System.getProperty("line.separator", //$NON-NLS-1$ + "\r\n"); //$NON-NLS-1$ + + /** + * Input string + */ + private final String input; + + /** + * Input split into lines + */ + private final List inputLines = new ArrayList<>(); + + /** + * Parsed input + */ + private CompilationUnit unit; + + /** + * Output lines + */ + private final List javaSrcLines = new ArrayList<>(); + + private final IDecompiler decompiler; + + private static class InputLine { + + final String line; + int outputLineNum = -1; + int calculatedNumLineJavaSrc = -1; + + public InputLine(String line) { + super(); + this.line = line; + } + + @Override + public String toString() { + return line; + } + } + + private static class JavaSrcLine { + + private final List inputLines = new ArrayList<>(); + + @Override + public String toString() { + return inputLines.toString(); + } + } + + public LineReformatter(IDecompiler decompiler, String input) { + this.input = input + line_separator; + this.decompiler = decompiler; + } + + public String realign() { + // Handle special cases + if (input == null) { + return null; + } + if (input.isEmpty()) { + return input; + } + + if (decompiler.getLineNumberOutputType() == null) { + return input; + } + + // Compute the string offset of every source line + fillOutputList(); + + // Parse source code into AST + javaSrcLines.add(null); + ASTParser parser = ASTParser.newParser(EclipseUtils.getMaxJSLLevel()); // AST.JLS3 + CompilerOptions option = new CompilerOptions(); + Map options = option.getMap(); + options.put(CompilerOptions.OPTION_Compliance, EclipseUtils.getMaxDecompileLevel()); // $NON-NLS-1$ + options.put(CompilerOptions.OPTION_Source, EclipseUtils.getMaxDecompileLevel()); // $NON-NLS-1$ + parser.setCompilerOptions(options); + + parser.setSource(input.toCharArray()); + + unit = (CompilationUnit) parser.createAST(null); + + // Iterate over types (ignoring enums and annotations) + List types = unit.types(); + for (int i = 0; i < types.size(); i++) { + if (types.get(i) instanceof AbstractTypeDeclaration) { + // Recursively process the elements within this type + processElements((AbstractTypeDeclaration) types.get(i)); + } + } + + // Iterate over types (ignoring enums and annotations) + int firstTypeLine = Integer.MAX_VALUE; + int lastTypeLine = Integer.MIN_VALUE; + for (int i = 0; i < types.size(); i++) { + if (!(types.get(i) instanceof AbstractTypeDeclaration)) { + continue; + } + AbstractTypeDeclaration type = (AbstractTypeDeclaration) types.get(i); + + // Recursively process the types within this type + processTypes(type); + + // Update firstTypeLine/lastTypeLine + int numLine = unit.getLineNumber(type.getStartPosition()); + if (numLine < firstTypeLine) { + firstTypeLine = numLine; + } + numLine = unit.getLineNumber(type.getStartPosition() + type.getLength() - 1); + if (numLine > lastTypeLine) { + lastTypeLine = numLine; + } + } + + // Special case - no source items to handle so just return our input + if (javaSrcLines.size() == 1) { + String warning = "\r\n" + NO_LINE_NUMBER + "\r\n"; //$NON-NLS-1$ //$NON-NLS-2$ + return warning + input; // $NON-NLS-1$ + } + + // Add all the source lines above the first type + if (firstTypeLine != Integer.MAX_VALUE) { + addBelow(firstTypeLine - 1, 0, 0); + } + + // Add all the source lines below the last type + if (lastTypeLine != Integer.MIN_VALUE) { + addBelow(inputLines.size() - 2, lastTypeLine, javaSrcLines.size() - 1); + } + + // Create aligned source + return toString(); + } + + public static boolean isEmpty(String str) { + return str == null || str.isEmpty(); + } + + public static String replace(String text, String searchString, String replacement) { + if (isEmpty(text) || isEmpty(searchString) || replacement == null) { + return text; + } + int start = 0; + int end = text.indexOf(searchString, start); + if (end == -1) { + return text; + } + int replLength = searchString.length(); + int increase = replacement.length() - replLength; + increase = (increase < 0 ? 0 : increase); + increase *= 16; + StringBuffer buf = new StringBuffer(text.length() + increase); + while (end != -1) { + buf.append(text.substring(start, end)).append(replacement); + start = end + replLength; + end = text.indexOf(searchString, 2); + } + buf.append(text.substring(start)); + return buf.toString(); + } + + @Override + public String toString() { + String line; + int numLine; + int lineNumberWidth = String.valueOf(javaSrcLines.size()).length(); + + boolean generateEmptyString = true; + int leftTrimSpace = 0; + + // Search for empty line number comment blocks + Pattern pattern = Pattern.compile("/\\*\\s+\\*/", //$NON-NLS-1$ + Pattern.CASE_INSENSITIVE); + Matcher matcher = pattern.matcher(input); + if (matcher.find()) { + generateEmptyString = false; + + Pattern importPattern = Pattern.compile("([ ]+)import", //$NON-NLS-1$ + Pattern.CASE_INSENSITIVE); + Matcher importMatcher = importPattern.matcher(input); + if (importMatcher.find()) { + leftTrimSpace = importMatcher.group().replace("import", "") //$NON-NLS-1$ //$NON-NLS-2$ + .length(); + } + } else { + Pattern importPattern = Pattern.compile("([ ]+)import", //$NON-NLS-1$ + Pattern.CASE_INSENSITIVE); + Matcher importMatcher = importPattern.matcher(input); + if (importMatcher.find()) { + leftTrimSpace = importMatcher.group().replace("import", "") //$NON-NLS-1$ //$NON-NLS-2$ + .length(); + generateEmptyString = true; + } + } + + int lastBracketIndex = input.lastIndexOf('}'); + if (lastBracketIndex != -1) { + int trimSpace = getLeftPosition(input, input.lastIndexOf('}', lastBracketIndex - 1)) + - getLeftPosition(input, lastBracketIndex); + if (trimSpace > 4) { + leftTrimSpace += trimSpace - 4; + } + } + + StringBuffer realignOutput = new StringBuffer(input.length()); + for (int i = 1; i < javaSrcLines.size(); i++) { + JavaSrcLine javaSrcLine = initJavaSrcListItem(i); + + if (javaSrcLine.inputLines.size() > 0) { + int outputLineNumber = getOutputLineNumber(javaSrcLine); + + if (outputLineNumber != -1) { + List beforeLines = getBeforeLines(javaSrcLine); + if (beforeLines != null && !beforeLines.isEmpty()) { + + int index = realignOutput.lastIndexOf(line_separator); + if (index == realignOutput.length() - line_separator.length()) { + realignOutput.replace(index, index + line_separator.length(), ""); //$NON-NLS-1$ + + for (int j = 0; j < beforeLines.size(); j++) { + numLine = beforeLines.get(j); + line = inputLines.get(numLine).line; + line = removeJavaLineNumber(line.replace("\r\n", "\n") //$NON-NLS-1$ //$NON-NLS-2$ + .replace("\n", ""), //$NON-NLS-1$ //$NON-NLS-2$ + j == 0 && generateEmptyString, leftTrimSpace); + realignOutput.append(line); + } + + realignOutput.append(line_separator); + + javaSrcLine.inputLines.removeAll(beforeLines); + } + } + } + + if (i > 0) { + realignOutput.append("/* " //$NON-NLS-1$ + + getLineNumber(outputLineNumber, lineNumberWidth) + " */ "); //$NON-NLS-1$ + } + + for (int j = 0; j < javaSrcLine.inputLines.size(); j++) { + numLine = javaSrcLine.inputLines.get(j); + line = inputLines.get(numLine).line; + line = line.replace("\r\n", "\n").replace("\n", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + String cleanLine = removeJavaLineNumber(line, j == 0 && generateEmptyString, leftTrimSpace); + realignOutput.append(cleanLine); + } + } else if (i > 1) { + realignOutput.append("/* " //$NON-NLS-1$ + + getLineNumber(-1, lineNumberWidth) + " */ "); //$NON-NLS-1$ + } + realignOutput.append(line_separator); + } + return realignOutput.toString(); + } + + private List getBeforeLines(JavaSrcLine javaSrcLine) { + List lineNumbers = new ArrayList<>(); + for (int num : javaSrcLine.inputLines) { + InputLine line = inputLines.get(num); + if (line != null && line.outputLineNum != -1) { + break; + } else { + lineNumbers.add(num); + } + } + return lineNumbers; + } + + private int getOutputLineNumber(JavaSrcLine javaSrcLine) { + for (int numLine : javaSrcLine.inputLines) { + InputLine inputLine = inputLines.get(numLine); + if (inputLine != null && inputLine.outputLineNum != -1) { + return inputLine.outputLineNum; + } + } + return -1; + } + + private int getLeftPosition(String string, int index) { + if (string == null || string.length() < index) { + return -1; + } + + for (int j = index - 1; j >= 0; j--) { + if (j < 0) { + break; + } + if (string.charAt(j) == '\n') { + return index - j; + } + } + return -1; + } + + private String getLineNumber(int i, int lineNumberWidth) { + String number = String.valueOf(i); + int width = number.length(); + if (i == -1) { + width = 0; + number = ""; //$NON-NLS-1$ + } + if (width < lineNumberWidth) { + for (int j = 0; j < lineNumberWidth - width; j++) { + number = " " + number; //$NON-NLS-1$ + } + } + + return number; + } + + private String generateEmptyString(int length) { + char[] chs = new char[length]; + for (int i = 0; i < chs.length; i++) { + chs[i] = ' '; + } + return new String(chs); + } + + private void fillOutputList() { + int lineStart = 0; + int lineEnd = 0; + inputLines.add(null); + while (lineStart < input.length()) { + // Compute line end + lineEnd = input.indexOf('\n', lineEnd); + if (lineEnd == -1) { + lineEnd = input.length(); + } else { + lineEnd++; + } + + // Build OutputLine object + inputLines.add(new InputLine(input.substring(lineStart, lineEnd))); + + // Next line start is current line end + lineStart = lineEnd; + } + } + + public int parseJavaLineNumber(String line) { + Pattern pattern = decompiler.getLineNumberOutputType().getPattern(); + Matcher matcher = pattern.matcher(line); + if (matcher.find()) { + String lineNumbersStr = matcher.group(2).trim(); + if (!lineNumbersStr.isEmpty()) { + String[] lineNumbersArr = lineNumbersStr.split("\\D+"); // split by non-digits + return Integer.parseInt(lineNumbersArr[0]); + } + } + return -1; + } + + private String removeJavaLineNumber(String line, boolean generateEmptyString, int leftTrimSpace) { + Pattern pattern = decompiler.getLineNumberOutputType().getPattern(); + Matcher matcher = pattern.matcher(line.trim()); + + if (matcher.find()) { + String lineNumberComment = matcher.group(1); + line = line.replace(lineNumberComment, ""); //$NON-NLS-1$ + if (generateEmptyString) { + line = generateEmptyString(lineNumberComment.length()) + line; + } + } + + if (leftTrimSpace > 0 && line.startsWith(generateEmptyString(leftTrimSpace))) { + line = line.substring(leftTrimSpace); + } + return line; + } + + /** + * Make sure {@link #javaSrcLines} is at least outputLineNum entries long + * (adding nulls if necessary). + * + * @param outputLineNum + * @return the {@link JavaSrcLine} at index outputLineNum (creating one if one + * doesn't already exist). + */ + private JavaSrcLine initJavaSrcListItem(int outputLineNum) { + + // Fill in nulls for any previous output line nums which we haven't + // visited yet + if (javaSrcLines.size() <= outputLineNum) { + for (int a = javaSrcLines.size(); a <= outputLineNum; a++) + javaSrcLines.add(null); + } + + // Create an output entry at the outputLineNum index + JavaSrcLine javaSrcLine = javaSrcLines.get(outputLineNum); + if (javaSrcLine == null) { + javaSrcLine = new JavaSrcLine(); + javaSrcLines.set(outputLineNum, javaSrcLine); + } + return javaSrcLine; + } + + private void addAbove(int inputBeginLineNo, int inputLineNo, int outputLineNo) { + if (outputLineNo == 1) { + return; + } + + int offset = 1; + /* + * Example: + * + * 19: / / public static boolean isTranslucencySupported(Translucency + * paramTranslucency) 20: / / { 21: / 105 / switch + * (1.$SwitchMap$com$sun$awt$AWTUtilities$Translucency[paramTranslucency + * .ordinal()]) 22: / / { 23: / / case 1: 24: / 107 / return + * isWindowShapingSupported(); + * + * # addAbove(19, 21, 105) javaSrcLines[105] = [21] is already set when this + * method is called. This method creates the following entries in javaSrcLines: + * javaSrcLines[103] = [19] javaSrcLines[104] = [20] + * + * # addAbove(19, 24, 107) javaSrcLines[107] = [24] is already set when this + * method is called. This method creates the following entries in javaSrcLines: + * javaSrcLines[106] = [23] + * + * javaSrcLines[105] already has an entry so we add input line 22 to + * javaSrcLines[106]: javaSrcLines[105] = [22,23] + * + * The result is the following folding of the code: + * + * 103: / / public static boolean isTranslucencySupported(Translucency + * paramTranslucency) 104: / / { 105: / 105 / switch + * (1.$SwitchMap$com$sun$awt$AWTUtilities$Translucency[paramTranslucency + * .ordinal()]) 106: / / {/ / case 1: 107: / 107 / return + * isWindowShapingSupported(); + */ + + // Iterate backwards through the input lines towards inputBeginLineNo + while (inputBeginLineNo <= (inputLineNo - offset)) { + + int offsetInputLine = inputLineNo - offset; + InputLine inputLine = inputLines.get(offsetInputLine); + + if (inputLine.outputLineNum == -1) { + // Got an InputLine without a corresponding Java source line + JavaSrcLine javaSrcLine = null; + int offsetOutputLine = outputLineNo - offset; + + if (offsetOutputLine > 0) { + javaSrcLine = initJavaSrcListItem(offsetOutputLine); + } + + if (offsetOutputLine == 1 || javaSrcLine.inputLines.size() > 0) { + // We have reached the start of the file OR the current + // javaSrcLine has some output lines + + int offsetOutputLineNext = offsetOutputLine + 1; + + // Get the JavaSrcLine for the output line after the current + // one + JavaSrcLine javaSrcLineNext = initJavaSrcListItem(offsetOutputLineNext); + + // Iterate backwards through the input lines towards + // inputBeginLineNo from the output offset + for (int innerOffset = offset; (inputLineNo - innerOffset) >= inputBeginLineNo; innerOffset++) { + + int innerOffsetInputLine = inputLineNo - innerOffset; + inputLine = inputLines.get(innerOffsetInputLine); + if (inputLine.outputLineNum == -1) { + // Found an input line without a source line number + // - add it to javaSrcLineNext + javaSrcLineNext.inputLines.add(0, innerOffsetInputLine); + inputLine.calculatedNumLineJavaSrc = offsetOutputLineNext; + } else { + // Got an InputLine with a corresponding Java source + // line + // we must already have handled this line and the + // ones above + // it. Time to bail out! + break; + } + } + // Run out of lines to process - bail out + break; + } + + // Add the offsetInputLine to the current javaSrcLine + javaSrcLine.inputLines.add(offsetInputLine); + inputLine.calculatedNumLineJavaSrc = offsetOutputLine; + } else { + // Got an InputLine with a corresponding Java source line + // we must already have handled this line and the ones above + // it. Time to bail out! + break; + } + offset++; + } + } + + private void addBelow(int inputEndLineNo, int inputLineNo, int outputLineNo) { + + int offset = 1; + + // Iterate forwards through the input lines towards inputEndLineNo + while ((inputLineNo + offset) < inputEndLineNo) { + + int offsetInputLine = inputLineNo + offset; + InputLine outputLine = inputLines.get(offsetInputLine); + + if (outputLine.outputLineNum == -1) { + // Got an InputLine without a corresponding Java source line + int offsetOutputLine = outputLineNo + offset; + JavaSrcLine javaSrcLine = initJavaSrcListItem(offsetOutputLine); + + if (javaSrcLine.inputLines.size() > 0) { + // The current javaSrcLine has some output lines + int offsetOutputLinePrev = offsetOutputLine - 1; + + // Get the JavaSrcLine for the output line after the current + // one + JavaSrcLine javaSrcLinePrev = initJavaSrcListItem(offsetOutputLinePrev); + + // Iterate forwards through the input lines towards + // inputEndLineNo from the output offset + for (int innerOffset = offset; (inputLineNo + innerOffset) <= inputEndLineNo; innerOffset++) { + + int innerOffsetInputLine = inputLineNo + innerOffset; + outputLine = inputLines.get(innerOffsetInputLine); + if (outputLine.outputLineNum == -1) { + // Found an input line without a source line number + // - add it to javaSrcLineNext + javaSrcLinePrev.inputLines.add(innerOffsetInputLine); + outputLine.calculatedNumLineJavaSrc = offsetOutputLinePrev; + } else { + // Got an InputLine with a corresponding Java source + // line + // we must already have handled this line and the + // ones above + // it. Time to bail out! + break; + } + } + // Run out of lines to process - bail out + break; + } + javaSrcLine.inputLines.add(offsetInputLine); + outputLine.calculatedNumLineJavaSrc = offsetOutputLine; + } else { + // Got an InputLine with a corresponding Java source line + // we must already have handled this line and the ones above + // it. Time to bail out! + break; + } + offset++; + } + + if (inputLineNo + offset == inputEndLineNo) { + int offsetOutputLine = outputLineNo + offset; + + JavaSrcLine javaSrcLine = initJavaSrcListItem(offsetOutputLine); + javaSrcLine.inputLines.add(inputEndLineNo); + + InputLine outputLine = inputLines.get(inputEndLineNo); + outputLine.calculatedNumLineJavaSrc = offsetOutputLine; + } + } + + private void processTypes(AbstractTypeDeclaration rootType) { + List declarations = rootType.bodyDeclarations(); + for (Object declaration : declarations) { + if (declaration instanceof AbstractTypeDeclaration) { + AbstractTypeDeclaration typeDeclaration = (AbstractTypeDeclaration) declaration; + processTypes(typeDeclaration); + } + } + + int beginTypeLine = Integer.MAX_VALUE; + int endTypeLine = Integer.MIN_VALUE; + int firstMethodLine = Integer.MAX_VALUE; + int lastMethodLine = Integer.MIN_VALUE; + + int beginTypeInputLineNo = unit.getLineNumber(rootType.getStartPosition()); + int endTypeInputLineNo = unit.getLineNumber(rootType.getStartPosition() + rootType.getLength() - 1); + + // Iterate forward through the input line numbers of the type + for (int inputLineNo = beginTypeInputLineNo; inputLineNo <= endTypeInputLineNo; inputLineNo++) { + + // Get the output line number + InputLine inputLine = inputLines.get(inputLineNo); + int numLineJavaSrc = inputLine.outputLineNum; + if (numLineJavaSrc == -1) { + numLineJavaSrc = inputLine.calculatedNumLineJavaSrc; + } + + if (numLineJavaSrc != -1) { + // Update the type begin/end output line numbers + if (beginTypeLine > numLineJavaSrc) { + beginTypeLine = numLineJavaSrc; + } + if (endTypeLine < numLineJavaSrc) { + endTypeLine = numLineJavaSrc; + } + + // Update the type first/last method input line numbers + if (firstMethodLine > inputLineNo) { + firstMethodLine = inputLineNo; + } + if (lastMethodLine < inputLineNo) { + lastMethodLine = inputLineNo; + } + } + } + + // Process the lines above and below this type + if (beginTypeLine != Integer.MAX_VALUE) { + addAbove(beginTypeInputLineNo, firstMethodLine, beginTypeLine); + addBelow(endTypeInputLineNo, lastMethodLine, endTypeLine); + } + } + + private void processMembers(AbstractTypeDeclaration rootType) { + + // Iterate over the declarations in this type + List bodyDeclarations = new ArrayList(); + if (rootType instanceof EnumDeclaration) { + EnumDeclaration enumDeclaration = (EnumDeclaration) rootType; + List enumDeclarations = enumDeclaration.enumConstants(); + + // Iterate over the enum constant declarations + int lastInputLineNo = -1; + for (Object enumDeclObj : enumDeclarations) { + if (enumDeclObj instanceof EnumConstantDeclaration) { + ASTNode element = (ASTNode) enumDeclObj; + int p = element.getStartPosition(); + int inputBeginLine = unit.getLineNumber(p); + + // If this declaration is on a new line add it to the + // bodyDeclarations + if (inputBeginLine != lastInputLineNo) { + bodyDeclarations.add(enumDeclObj); + } + lastInputLineNo = inputBeginLine; + } + } + } + bodyDeclarations.addAll(rootType.bodyDeclarations()); + + for (Object bodyDeclaration : bodyDeclarations) { + if ((bodyDeclaration instanceof MethodDeclaration) || (bodyDeclaration instanceof Initializer) + || (bodyDeclaration instanceof FieldDeclaration) + || (bodyDeclaration instanceof EnumConstantDeclaration)) { + ASTNode element = (ASTNode) bodyDeclaration; + int p = element.getStartPosition(); + int inputBeginLine = unit.getLineNumber(p); + int inputEndLine = unit.getLineNumber(p + element.getLength() - 1); + processMember(inputBeginLine, inputEndLine); + } + } + } + + private void processMember(int inputBeginLine, int inputEndLine) { + int lastOutputLine = -1; + int lastInputLine = -1; + int maxLine = -1; + // Iterate over the lines in this member + for (int inputNumLine = inputBeginLine; inputNumLine <= inputEndLine; inputNumLine++) { + + // Parse the commented line number if available + InputLine inputLine = inputLines.get(inputNumLine); + inputLine.outputLineNum = parseJavaLineNumber(inputLine.line); + + if (inputLine.outputLineNum > 1) { + + // We have a commented line number! + lastOutputLine = inputLine.outputLineNum; + lastInputLine = inputNumLine; + + // Add the input line to the output JavaSrcLine + JavaSrcLine javaSrcLine = initJavaSrcListItem(inputLine.outputLineNum); + javaSrcLine.inputLines.add(inputNumLine); + addAbove(inputBeginLine, inputNumLine, inputLine.outputLineNum); + + if (lastOutputLine > maxLine) { + maxLine = lastOutputLine; + } + } + } + + if (lastInputLine != -1 && lastInputLine < inputEndLine) { + addBelow(inputEndLine, lastInputLine, maxLine); + } + } + + private void processElements(AbstractTypeDeclaration rootType) { + if ((rootType instanceof TypeDeclaration) || (rootType instanceof EnumDeclaration)) { + processMembers(rootType); + } + + // Recurse into inner types and process their methods + List bodyDeclarations = rootType.bodyDeclarations(); + for (Object bodyDeclaration : bodyDeclarations) { + if (bodyDeclaration instanceof AbstractTypeDeclaration) { + processElements((AbstractTypeDeclaration) bodyDeclaration); + } + } + } + +} 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 8b7c9c42..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 @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.preferences; @@ -24,189 +21,169 @@ 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; -public class DisassemblerPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage -{ +public class DisassemblerPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { - class CheckFieldEditor extends BooleanFieldEditor - { + class CheckFieldEditor extends BooleanFieldEditor { - public CheckFieldEditor( String name, String label, Composite parent ) - { - super( name, label, parent ); + public CheckFieldEditor(String name, String label, Composite parent) { + super(name, label, parent); } @Override - protected void fireStateChanged( String property, boolean oldValue, boolean newValue ) - { - fireValueChanged( property, - oldValue ? Boolean.TRUE : Boolean.FALSE, - newValue ? Boolean.TRUE : Boolean.FALSE ); + protected void fireStateChanged(String property, boolean oldValue, boolean newValue) { + fireValueChanged(property, oldValue ? Boolean.TRUE : Boolean.FALSE, + newValue ? Boolean.TRUE : Boolean.FALSE); } - public void handleSelection( Composite parent ) - { - boolean isSelected = getChangeControl( parent ).getSelection( ); - valueChanged( false, isSelected ); + public void handleSelection(Composite parent) { + boolean isSelected = getChangeControl(parent).getSelection(); + valueChanged(false, isSelected); } @Override - protected void valueChanged( boolean oldValue, boolean newValue ) - { - setPresentsDefaultValue( false ); - fireStateChanged( VALUE, oldValue, newValue ); + protected void valueChanged(boolean oldValue, boolean newValue) { + setPresentsDefaultValue(false); + fireStateChanged(VALUE, oldValue, newValue); } @Override - public Button getChangeControl( Composite parent ) - { - return super.getChangeControl( parent ); + public Button getChangeControl(Composite parent) { + return super.getChangeControl(parent); } } private Group basicGroup; private Group styleGroup; - public DisassemblerPreferencePage( ) - { - super( FieldEditorPreferencePage.GRID ); - setPreferenceStore( JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ) ); + public DisassemblerPreferencePage() { + super(FieldEditorPreferencePage.GRID); + setPreferenceStore(JavaDecompilerPlugin.getDefault().getPreferenceStore()); } @Override - public void createControl( Composite parent ) - { - super.createControl( parent ); + public void createControl(Composite parent) { + super.createControl(parent); } @Override - protected void createFieldEditors( ) - { - basicGroup = new Group( getFieldEditorParent( ), SWT.NONE ); - basicGroup.setText( Messages.getString( "DisassemblerPreferencePage.Label.DisassemblerSettings" ) ); //$NON-NLS-1$ - GridData gd = new GridData( GridData.FILL_HORIZONTAL ); - basicGroup.setLayoutData( gd ); + protected void createFieldEditors() { + basicGroup = new Group(getFieldEditorParent(), SWT.NONE); + basicGroup.setText(Messages.getString("DisassemblerPreferencePage.Label.DisassemblerSettings")); //$NON-NLS-1$ + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + basicGroup.setLayoutData(gd); BooleanFieldEditor showConstantPool = new BooleanFieldEditor( - JavaDecompilerPlugin.CLASS_FILE_ATTR_SHOW_CONSTANT_POOL, - Messages.getString( "DisassemblerPreferencePage.Label.ShowConstant" ), //$NON-NLS-1$ - basicGroup ); + 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, - Messages.getString( "DisassemblerPreferencePage.Label.ShowSourceLineNumber" ), //$NON-NLS-1$ - basicGroup ); + 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, - Messages.getString( "DisassemblerPreferencePage.Label.ShowLineNumberTable" ), //$NON-NLS-1$ - basicGroup ); + 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, - Messages.getString( "DisassemblerPreferencePage.Label.ShowVariableTable" ), //$NON-NLS-1$ - basicGroup ); + 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, - Messages.getString( "DisassemblerPreferencePage.Label.ShowExceptionTable" ), //$NON-NLS-1$ - basicGroup ); + 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, - Messages.getString( "DisassemblerPreferencePage.Label.ShowMaxs" ), //$NON-NLS-1$ - basicGroup ); + 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, - Messages.getString( "DisassemblerPreferencePage.Label.ShowTryCatch" ), //$NON-NLS-1$ - basicGroup ); - - addField( showConstantPool ); - addField( showSourceLineNumber ); - addField( showLineNumberTable ); - addField( showVariableTable ); - addField( showExceptionTable ); - addField( showMaxs ); - addField( showTryCatch ); - - GridLayout layout = (GridLayout) basicGroup.getLayout( ); + JavaDecompilerConstants.CLASS_FILE_ATTR_RENDER_TRYCATCH_BLOCKS, + Messages.getString("DisassemblerPreferencePage.Label.ShowTryCatch"), //$NON-NLS-1$ + basicGroup); + + addField(showConstantPool); + addField(showSourceLineNumber); + addField(showLineNumberTable); + addField(showVariableTable); + addField(showExceptionTable); + addField(showMaxs); + addField(showTryCatch); + + GridLayout layout = (GridLayout) basicGroup.getLayout(); layout.marginWidth = layout.marginHeight = 5; - basicGroup.layout( ); - - RadioGroupFieldEditor red = new RadioGroupFieldEditor( JavaDecompilerPlugin.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 - }, { - Messages.getString( "DisassemblerPreferencePage.Label.RelativeAddress" ), //$NON-NLS-1$ - JavaDecompilerPlugin.BRANCH_TARGET_ADDRESS_ABSOLUTE - } - }, - getFieldEditorParent( ), - true ); - addField( red ); - - styleGroup = new Group( getFieldEditorParent( ), SWT.NONE ); - styleGroup.setText( Messages.getString("DisassemblerPreferencePage.Label.StyleSettings") ); //$NON-NLS-1$ - gd = new GridData( GridData.FILL_HORIZONTAL ); - styleGroup.setLayoutData( gd ); - - ColorFieldEditor opcodeColor = new ColorFieldEditor( JavaDecompilerPlugin.BYTECODE_MNEMONIC, + basicGroup.layout(); + + 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$ + JavaDecompilerConstants.BRANCH_TARGET_ADDRESS_RELATIVE }, + { Messages.getString("DisassemblerPreferencePage.Label.RelativeAddress"), //$NON-NLS-1$ + JavaDecompilerConstants.BRANCH_TARGET_ADDRESS_ABSOLUTE } }, + getFieldEditorParent(), true); + addField(red); + + styleGroup = new Group(getFieldEditorParent(), SWT.NONE); + styleGroup.setText(Messages.getString("DisassemblerPreferencePage.Label.StyleSettings")); //$NON-NLS-1$ + gd = new GridData(GridData.FILL_HORIZONTAL); + styleGroup.setLayoutData(gd); + + ColorFieldEditor opcodeColor = new ColorFieldEditor(JavaDecompilerConstants.BYTECODE_MNEMONIC, Messages.getString("DisassemblerPreferencePage.Label.StyleColor"), //$NON-NLS-1$ - styleGroup ); + 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 ); + 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 ); + styleGroup); BooleanFieldEditor opcodeFontStrikethrough = new BooleanFieldEditor( - JavaDecompilerPlugin.BYTECODE_MNEMONIC_STRIKETHROUGH, + JavaDecompilerConstants.BYTECODE_MNEMONIC_STRIKETHROUGH, Messages.getString("DisassemblerPreferencePage.Label.StyleStrikethrough"), //$NON-NLS-1$ - styleGroup ); + 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 ); + styleGroup); - addField( opcodeColor ); - addField( opcodeFontBold ); - addField( opcodeFontItalic ); - addField( opcodeFontStrikethrough ); - addField( showFontUnderline ); + addField(opcodeColor); + addField(opcodeFontBold); + addField(opcodeFontItalic); + addField(opcodeFontStrikethrough); + addField(showFontUnderline); - layout = (GridLayout) styleGroup.getLayout( ); + layout = (GridLayout) styleGroup.getLayout(); layout.marginWidth = layout.marginHeight = 5; layout.numColumns = 2; - styleGroup.layout( ); + styleGroup.layout(); - getFieldEditorParent( ).layout( ); + getFieldEditorParent().layout(); } @Override - public void init( IWorkbench arg0 ) - { + public void init(IWorkbench arg0) { } @Override - protected void performDefaults( ) - { - super.performDefaults( ); + protected void performDefaults() { + super.performDefaults(); } @Override - public void propertyChange( PropertyChangeEvent event ) - { - super.propertyChange( event ); + public void propertyChange(PropertyChangeEvent event) { + super.propertyChange(event); } } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/preferences/EncodingFieldEditor.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/preferences/EncodingFieldEditor.java index f9346d73..c7b40be1 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/preferences/EncodingFieldEditor.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/preferences/EncodingFieldEditor.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.preferences; @@ -16,58 +13,47 @@ import org.eclipse.ui.ide.IDEEncoding; import org.eclipse.ui.ide.dialogs.AbstractEncodingFieldEditor; -public final class EncodingFieldEditor extends AbstractEncodingFieldEditor -{ +public final class EncodingFieldEditor extends AbstractEncodingFieldEditor { - public EncodingFieldEditor( String name, String labelText, String groupTitle, Composite parent ) - { - super( ); - init( name, labelText ); - setGroupTitle( groupTitle ); - createControl( parent ); + public EncodingFieldEditor(String name, String labelText, String groupTitle, Composite parent) { + super(); + init(name, labelText); + setGroupTitle(groupTitle); + createControl(parent); } - public EncodingFieldEditor( String name, String labelText, Composite parent ) - { - super( ); - init( name, labelText ); - createControl( parent ); + public EncodingFieldEditor(String name, String labelText, Composite parent) { + super(); + init(name, labelText); + createControl(parent); } @Override - protected String getStoredValue( ) - { - return getPreferenceStore( ).getString( getPreferenceName( ) ); + protected String getStoredValue() { + return getPreferenceStore().getString(getPreferenceName()); } @Override - protected void doStore( ) - { - String encoding = getSelectedEncoding( ); + protected void doStore() { + String encoding = getSelectedEncoding(); - if ( hasSameEncoding( encoding ) ) - { + if (hasSameEncoding(encoding)) { return; } - IDEEncoding.addIDEEncoding( encoding ); + IDEEncoding.addIDEEncoding(encoding); - if ( encoding.equals( getDefaultEnc( ) ) ) - { - getPreferenceStore( ).setToDefault( getPreferenceName( ) ); - } - else - { - getPreferenceStore( ).setValue( getPreferenceName( ), encoding ); + if (encoding.equals(getDefaultEnc())) { + getPreferenceStore().setToDefault(getPreferenceName()); + } else { + getPreferenceStore().setValue(getPreferenceName(), encoding); } } @Override - public void setPreferenceStore( IPreferenceStore store ) - { - if ( store != null ) - { - super.setPreferenceStore( store ); + public void setPreferenceStore(IPreferenceStore store) { + if (store != null) { + super.setPreferenceStore(store); } } } 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 c2ae07a2..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 @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.preferences; @@ -22,47 +19,40 @@ 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; import org.sf.feeling.decompiler.i18n.Messages; -public class JavaDecompilerPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage -{ +public class JavaDecompilerPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { - class CheckFieldEditor extends BooleanFieldEditor - { + class CheckFieldEditor extends BooleanFieldEditor { - public CheckFieldEditor( String name, String label, Composite parent ) - { - super( name, label, parent ); + public CheckFieldEditor(String name, String label, Composite parent) { + super(name, label, parent); } @Override - protected void fireStateChanged( String property, boolean oldValue, boolean newValue ) - { - fireValueChanged( property, - oldValue ? Boolean.TRUE : Boolean.FALSE, - newValue ? Boolean.TRUE : Boolean.FALSE ); + protected void fireStateChanged(String property, boolean oldValue, boolean newValue) { + fireValueChanged(property, oldValue ? Boolean.TRUE : Boolean.FALSE, + newValue ? Boolean.TRUE : Boolean.FALSE); } - public void handleSelection( Composite parent ) - { - boolean isSelected = getChangeControl( parent ).getSelection( ); - valueChanged( false, isSelected ); + public void handleSelection(Composite parent) { + boolean isSelected = getChangeControl(parent).getSelection(); + valueChanged(false, isSelected); } @Override - protected void valueChanged( boolean oldValue, boolean newValue ) - { - setPresentsDefaultValue( false ); - fireStateChanged( VALUE, oldValue, newValue ); + protected void valueChanged(boolean oldValue, boolean newValue) { + setPresentsDefaultValue(false); + fireStateChanged(VALUE, oldValue, newValue); } @Override - public Button getChangeControl( Composite parent ) - { - return super.getChangeControl( parent ); + public Button getChangeControl(Composite parent) { + return super.getChangeControl(parent); } } @@ -77,259 +67,225 @@ public Button getChangeControl( Composite parent ) private StringChoiceFieldEditor defaultDecompiler; private CheckFieldEditor showReport; - public JavaDecompilerPreferencePage( ) - { - super( FieldEditorPreferencePage.GRID ); - setPreferenceStore( JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ) ); + public JavaDecompilerPreferencePage() { + super(FieldEditorPreferencePage.GRID); + setPreferenceStore(JavaDecompilerPlugin.getDefault().getPreferenceStore()); } @Override - public void createControl( Composite parent ) - { - super.createControl( parent ); + public void createControl(Composite parent) { + super.createControl(parent); } @Override - protected void createFieldEditors( ) - { + protected void createFieldEditors() { - defaultDecompiler = new StringChoiceFieldEditor( JavaDecompilerPlugin.DECOMPILER_TYPE, - Messages.getString( "JavaDecompilerPreferencePage.Label.DefaultClassDecompiler" ), //$NON-NLS-1$ - getFieldEditorParent( ) ) { + defaultDecompiler = new StringChoiceFieldEditor(JavaDecompilerConstants.DECOMPILER_TYPE, + Messages.getString("JavaDecompilerPreferencePage.Label.DefaultClassDecompiler"), //$NON-NLS-1$ + getFieldEditorParent()) { @Override - protected void doFillIntoGrid( Composite parent, int numColumns ) - { - super.doFillIntoGrid( parent, numColumns ); - GridData gd = (GridData) getControl( ).getLayoutData( ); + protected void doFillIntoGrid(Composite parent, int numColumns) { + super.doFillIntoGrid(parent, numColumns); + GridData gd = (GridData) getControl().getLayoutData(); gd.widthHint = 175; gd.grabExcessHorizontalSpace = false; gd.horizontalAlignment = SWT.BEGINNING; - getControl( ).setLayoutData( gd ); + getControl().setLayoutData(gd); } }; - String fernLabel = Messages.getString( "JavaDecompilerPreferencePage.Decompiler.FernFlower" ); //$NON-NLS-1$ - - boolean isAddFernFlower = false; - - for ( int i = 0; i < DecompilerType.getDecompilerTypes( ).length; i++ ) - { - IDecompilerDescriptor descriptor = JavaDecompilerPlugin.getDefault( ) - .getDecompilerDescriptor( DecompilerType.getDecompilerTypes( )[i] ); - String label = descriptor.getDecompilerPreferenceLabel( ).trim( ); - if ( label.compareToIgnoreCase( fernLabel ) > 0 && !isAddFernFlower ) - { - defaultDecompiler.addItem( DecompilerType.FernFlower, fernLabel, DecompilerType.FernFlower ); - isAddFernFlower = true; - } - defaultDecompiler.addItem( descriptor.getDecompilerType( ), label, descriptor.getDecompilerType( ) ); - } - - if ( !isAddFernFlower ) - { - defaultDecompiler.addItem( DecompilerType.FernFlower, fernLabel, DecompilerType.FernFlower ); + JavaDecompilerPlugin javaDecompilerPlugin = JavaDecompilerPlugin.getDefault(); + for (String decompilerType : DecompilerType.getDecompilerTypes()) { + IDecompilerDescriptor descriptor = javaDecompilerPlugin.getDecompilerDescriptor(decompilerType); + String label = descriptor.getDecompilerPreferenceLabel().trim(); + defaultDecompiler.addItem(descriptor.getDecompilerType(), label, descriptor.getDecompilerType()); } - addField( defaultDecompiler ); + addField(defaultDecompiler); - basicGroup = new Group( getFieldEditorParent( ), SWT.NONE ); - basicGroup.setText( Messages.getString( "JavaDecompilerPreferencePage.Label.DecompilerSettings" ) ); //$NON-NLS-1$ - GridData gd = new GridData( GridData.FILL_HORIZONTAL ); - gd.horizontalSpan = defaultDecompiler.getNumberOfControls( ); - basicGroup.setLayoutData( gd ); + basicGroup = new Group(getFieldEditorParent(), SWT.NONE); + basicGroup.setText(Messages.getString("JavaDecompilerPreferencePage.Label.DecompilerSettings")); //$NON-NLS-1$ + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalSpan = defaultDecompiler.getNumberOfControls(); + basicGroup.setLayoutData(gd); - BooleanFieldEditor reusebuf = new BooleanFieldEditor( JavaDecompilerPlugin.REUSE_BUFFER, - Messages.getString( "JavaDecompilerPreferencePage.Label.ReuseCodeBuffer" ), //$NON-NLS-1$ - basicGroup ); - addField( reusebuf ); + BooleanFieldEditor reusebuf = new BooleanFieldEditor(JavaDecompilerConstants.REUSE_BUFFER, + Messages.getString("JavaDecompilerPreferencePage.Label.ReuseCodeBuffer"), //$NON-NLS-1$ + basicGroup); + addField(reusebuf); - if ( JavaDecompilerPlugin.getDefault( ).enableAttachSourceSetting( ) ) - { - createAttachSourceFieldEditor( basicGroup ); + if (JavaDecompilerPlugin.getDefault().enableAttachSourceSetting()) { + createAttachSourceFieldEditor(basicGroup); } - BooleanFieldEditor alwaysUse = new BooleanFieldEditor( JavaDecompilerPlugin.IGNORE_EXISTING, - Messages.getString( "JavaDecompilerPreferencePage.Label.IgnoreExistSource" ), //$NON-NLS-1$ - basicGroup ); - addField( alwaysUse ); + 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, - Messages.getString( "JavaDecompilerPreferencePage.Label.ShowDecompilerReport" ), //$NON-NLS-1$ - basicGroup ); - addField( showReport ); + showReport = new CheckFieldEditor(JavaDecompilerConstants.PREF_DISPLAY_METADATA, + Messages.getString("JavaDecompilerPreferencePage.Label.ShowDecompilerReport"), //$NON-NLS-1$ + basicGroup); + addField(showReport); - GridLayout layout = (GridLayout) basicGroup.getLayout( ); + GridLayout layout = (GridLayout) basicGroup.getLayout(); layout.marginWidth = layout.marginHeight = 5; - basicGroup.layout( ); + basicGroup.layout(); - formatGroup = new Group( getFieldEditorParent( ), SWT.NONE ); - formatGroup.setText( Messages.getString( "JavaDecompilerPreferencePage.Label.FormatSettings" ) ); //$NON-NLS-1$ - gd = new GridData( GridData.FILL_HORIZONTAL ); - gd.horizontalSpan = defaultDecompiler.getNumberOfControls( ); - formatGroup.setLayoutData( gd ); + formatGroup = new Group(getFieldEditorParent(), SWT.NONE); + formatGroup.setText(Messages.getString("JavaDecompilerPreferencePage.Label.FormatSettings")); //$NON-NLS-1$ + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalSpan = defaultDecompiler.getNumberOfControls(); + formatGroup.setLayoutData(gd); - eclipseFormatter = new CheckFieldEditor( JavaDecompilerPlugin.USE_ECLIPSE_FORMATTER, - Messages.getString( "JavaDecompilerPreferencePage.Label.UseEclipseFormat" ), //$NON-NLS-1$ - formatGroup ); - addField( eclipseFormatter ); + 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, - Messages.getString( "JavaDecompilerPreferencePage.Lable.UseEclipseSorter" ), //$NON-NLS-1$ - formatGroup ); - addField( eclipseSorter ); + eclipseSorter = new CheckFieldEditor(JavaDecompilerConstants.USE_ECLIPSE_SORTER, + Messages.getString("JavaDecompilerPreferencePage.Lable.UseEclipseSorter"), //$NON-NLS-1$ + formatGroup); + addField(eclipseSorter); - layout = (GridLayout) formatGroup.getLayout( ); + layout = (GridLayout) formatGroup.getLayout(); layout.marginWidth = layout.marginHeight = 5; - formatGroup.layout( ); + formatGroup.layout(); - debugGroup = new Group( getFieldEditorParent( ), SWT.NONE ); - debugGroup.setText( Messages.getString( "JavaDecompilerPreferencePage.Label.DebugSettings" ) ); //$NON-NLS-1$ - gd = new GridData( GridData.FILL_HORIZONTAL ); - gd.horizontalSpan = defaultDecompiler.getNumberOfControls( ); - debugGroup.setLayoutData( gd ); + debugGroup = new Group(getFieldEditorParent(), SWT.NONE); + debugGroup.setText(Messages.getString("JavaDecompilerPreferencePage.Label.DebugSettings")); //$NON-NLS-1$ + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalSpan = defaultDecompiler.getNumberOfControls(); + debugGroup.setLayoutData(gd); - optionLncEditor = new CheckFieldEditor( JavaDecompilerPlugin.PREF_DISPLAY_LINE_NUMBERS, - Messages.getString( "JavaDecompilerPreferencePage.Label.OutputLineNumber" ), //$NON-NLS-1$ - debugGroup ); - addField( optionLncEditor ); + optionLncEditor = new CheckFieldEditor(JavaDecompilerConstants.PREF_DISPLAY_LINE_NUMBERS, + Messages.getString("JavaDecompilerPreferencePage.Label.OutputLineNumber"), //$NON-NLS-1$ + debugGroup); + addField(optionLncEditor); - alignEditor = new CheckFieldEditor( JavaDecompilerPlugin.ALIGN, - Messages.getString( "JavaDecompilerPreferencePage.Label.AlignCode" ), //$NON-NLS-1$ - debugGroup ); - addField( alignEditor ); + alignEditor = new CheckFieldEditor(JavaDecompilerConstants.ALIGN, + Messages.getString("JavaDecompilerPreferencePage.Label.AlignCode"), //$NON-NLS-1$ + debugGroup); + addField(alignEditor); - layout = (GridLayout) debugGroup.getLayout( ); + layout = (GridLayout) debugGroup.getLayout(); layout.marginWidth = layout.marginHeight = 5; - debugGroup.layout( ); + debugGroup.layout(); - createEncodingFieldEditor( getFieldEditorParent( ) ); + createEncodingFieldEditor(getFieldEditorParent()); - Group startupGroup = new Group( getFieldEditorParent( ), SWT.NONE ); - startupGroup.setText( Messages.getString( "JavaDecompilerPreferencePage.Label.Startup" ) ); //$NON-NLS-1$ ); - gd = new GridData( GridData.FILL_HORIZONTAL ); - gd.horizontalSpan = defaultDecompiler.getNumberOfControls( ); - startupGroup.setLayoutData( gd ); + Group startupGroup = new Group(getFieldEditorParent(), SWT.NONE); + startupGroup.setText(Messages.getString("JavaDecompilerPreferencePage.Label.Startup")); //$NON-NLS-1$ ); + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalSpan = defaultDecompiler.getNumberOfControls(); + startupGroup.setLayoutData(gd); - CheckFieldEditor defaultViewerEditor = new CheckFieldEditor( JavaDecompilerPlugin.DEFAULT_EDITOR, - Messages.getString( "JavaDecompilerPreferencePage.Label.DefaultEditor" ), //$NON-NLS-1$ - startupGroup ); - addField( defaultViewerEditor ); + CheckFieldEditor defaultViewerEditor = new CheckFieldEditor(JavaDecompilerConstants.DEFAULT_EDITOR, + Messages.getString("JavaDecompilerPreferencePage.Label.DefaultEditor"), //$NON-NLS-1$ + startupGroup); + addField(defaultViewerEditor); - layout = (GridLayout) startupGroup.getLayout( ); + layout = (GridLayout) startupGroup.getLayout(); layout.marginWidth = layout.marginHeight = 5; - startupGroup.layout( ); + startupGroup.layout(); - getFieldEditorParent( ).layout( ); + getFieldEditorParent().layout(); } - private void createAttachSourceFieldEditor( Group group ) - { - CheckFieldEditor attachSource = new CheckFieldEditor( JavaDecompilerPlugin.ATTACH_SOURCE, - Messages.getString( "JavaDecompilerPreferencePage.Label.Attach.Source" ), //$NON-NLS-1$ - group ); - addField( attachSource ); + private void createAttachSourceFieldEditor(Group group) { + CheckFieldEditor attachSource = new CheckFieldEditor(JavaDecompilerConstants.ATTACH_SOURCE, + Messages.getString("JavaDecompilerPreferencePage.Label.Attach.Source"), //$NON-NLS-1$ + group); + addField(attachSource); } - private void createEncodingFieldEditor( Composite composite ) - { - Group encodingGroup = new Group( composite, SWT.NONE ); - encodingGroup.setText( Messages.getString( "JavaDecompilerPreferencePage.Label.Export.Encoding" ) ); //$NON-NLS-1$ - GridData gd = new GridData( GridData.FILL_HORIZONTAL ); - gd.horizontalSpan = defaultDecompiler.getNumberOfControls( ); - encodingGroup.setLayoutData( gd ); + private void createEncodingFieldEditor(Composite composite) { + Group encodingGroup = new Group(composite, SWT.NONE); + encodingGroup.setText(Messages.getString("JavaDecompilerPreferencePage.Label.Export.Encoding")); //$NON-NLS-1$ + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + 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 ); + null, encodingGroup); + addField(encodingEditor); - GridLayout layout = (GridLayout) encodingGroup.getLayout( ); + GridLayout layout = (GridLayout) encodingGroup.getLayout(); layout.marginWidth = layout.marginHeight = 5; - encodingGroup.layout( ); + encodingGroup.layout(); } @Override - public void init( IWorkbench arg0 ) - { + public void init(IWorkbench arg0) { } @Override - protected void initialize( ) - { - super.initialize( ); - boolean enabled = getPreferenceStore( ).getBoolean( JavaDecompilerPlugin.PREF_DISPLAY_LINE_NUMBERS ); - alignEditor.setEnabled( enabled, debugGroup ); - - String defaultEncoding = JavaDecompilerPlugin.getDefault( ).getDefaultExportEncoding( ); - String encoding = getPreferenceStore( ).getString( JavaDecompilerPlugin.EXPORT_ENCODING ); - encodingEditor.setPreferenceStore( getPreferenceStore( ) ); - encodingEditor.load( ); - - if ( encoding == null || encoding.equals( defaultEncoding ) || encoding.length( ) == 0 ) - encodingEditor.loadDefault( ); + protected void initialize() { + super.initialize(); + boolean enabled = getPreferenceStore().getBoolean(JavaDecompilerConstants.PREF_DISPLAY_LINE_NUMBERS); + alignEditor.setEnabled(enabled, debugGroup); + + String defaultEncoding = JavaDecompilerPlugin.getDefault().getDefaultExportEncoding(); + String encoding = getPreferenceStore().getString(JavaDecompilerConstants.EXPORT_ENCODING); + encodingEditor.setPreferenceStore(getPreferenceStore()); + encodingEditor.load(); + + if (encoding == null || encoding.equals(defaultEncoding) || encoding.length() == 0) + encodingEditor.loadDefault(); } @Override - protected void performDefaults( ) - { - super.performDefaults( ); - boolean enabled = Boolean.valueOf( optionLncEditor.getBooleanValue( ) ).equals( Boolean.TRUE ); - optionLncEditor.setEnabled( true, debugGroup ); - alignEditor.setEnabled( enabled, debugGroup ); - - encodingEditor.getPreferenceStore( ).setValue( encodingEditor.getPreferenceName( ), - JavaDecompilerPlugin.getDefault( ).getDefaultExportEncoding( ) ); - encodingEditor.load( ); - encodingEditor.loadDefault( ); + protected void performDefaults() { + super.performDefaults(); + boolean enabled = Boolean.valueOf(optionLncEditor.getBooleanValue()).equals(Boolean.TRUE); + optionLncEditor.setEnabled(true, debugGroup); + alignEditor.setEnabled(enabled, debugGroup); + + encodingEditor.getPreferenceStore().setValue(encodingEditor.getPreferenceName(), + JavaDecompilerPlugin.getDefault().getDefaultExportEncoding()); + encodingEditor.load(); + encodingEditor.loadDefault(); } @Override - public void propertyChange( PropertyChangeEvent event ) - { - if ( event.getSource( ) == optionLncEditor ) - { - boolean enabled = event.getNewValue( ).equals( Boolean.TRUE ); - alignEditor.setEnabled( enabled, debugGroup ); - if ( enabled ) - { - eclipseFormatter.getChangeControl( formatGroup ).setSelection( false ); - eclipseSorter.getChangeControl( formatGroup ).setSelection( false ); - eclipseFormatter.handleSelection( formatGroup ); - eclipseSorter.handleSelection( formatGroup ); + public void propertyChange(PropertyChangeEvent event) { + if (event.getSource() == optionLncEditor) { + boolean enabled = event.getNewValue().equals(Boolean.TRUE); + alignEditor.setEnabled(enabled, debugGroup); + if (enabled) { + eclipseFormatter.getChangeControl(formatGroup).setSelection(false); + eclipseSorter.getChangeControl(formatGroup).setSelection(false); + eclipseFormatter.handleSelection(formatGroup); + eclipseSorter.handleSelection(formatGroup); } - if ( !enabled ) - { - alignEditor.getChangeControl( debugGroup ).setSelection( false ); - alignEditor.handleSelection( debugGroup ); + if (!enabled) { + alignEditor.getChangeControl(debugGroup).setSelection(false); + alignEditor.handleSelection(debugGroup); } } - if ( event.getSource( ) == alignEditor ) - { - boolean enabled = event.getNewValue( ).equals( Boolean.TRUE ); - if ( enabled ) - { - eclipseFormatter.getChangeControl( formatGroup ).setSelection( false ); - eclipseSorter.getChangeControl( formatGroup ).setSelection( false ); - eclipseFormatter.handleSelection( formatGroup ); - eclipseSorter.handleSelection( formatGroup ); + if (event.getSource() == alignEditor) { + boolean enabled = event.getNewValue().equals(Boolean.TRUE); + if (enabled) { + eclipseFormatter.getChangeControl(formatGroup).setSelection(false); + eclipseSorter.getChangeControl(formatGroup).setSelection(false); + eclipseFormatter.handleSelection(formatGroup); + eclipseSorter.handleSelection(formatGroup); } } - if ( event.getSource( ) == eclipseFormatter || event.getSource( ) == eclipseSorter ) - { - boolean enabled = event.getNewValue( ).equals( Boolean.TRUE ); - if ( enabled ) - { - alignEditor.getChangeControl( debugGroup ).setSelection( false ); - optionLncEditor.getChangeControl( debugGroup ).setSelection( false ); - alignEditor.setEnabled( !enabled, debugGroup ); - alignEditor.handleSelection( debugGroup ); - optionLncEditor.handleSelection( debugGroup ); + if (event.getSource() == eclipseFormatter || event.getSource() == eclipseSorter) { + boolean enabled = event.getNewValue().equals(Boolean.TRUE); + if (enabled) { + alignEditor.getChangeControl(debugGroup).setSelection(false); + optionLncEditor.getChangeControl(debugGroup).setSelection(false); + alignEditor.setEnabled(!enabled, debugGroup); + alignEditor.handleSelection(debugGroup); + optionLncEditor.handleSelection(debugGroup); } } - super.propertyChange( event ); + super.propertyChange(event); } } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/preferences/StringChoiceFieldEditor.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/preferences/StringChoiceFieldEditor.java index c2254eec..18623b2b 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/preferences/StringChoiceFieldEditor.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/preferences/StringChoiceFieldEditor.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.preferences; @@ -23,145 +20,124 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; -public class StringChoiceFieldEditor extends FieldEditor -{ +public class StringChoiceFieldEditor extends FieldEditor { private Combo fCombo; - private List fKeys = new ArrayList( 5 ); - private List fLabels = new ArrayList( 5 ); + private List fKeys = new ArrayList(5); + private List fLabels = new ArrayList(5); private String fOldKey; private boolean fIsValid; - public StringChoiceFieldEditor( String name, String label, Composite parent ) - { - super( name, label, parent ); - initList( ); + public StringChoiceFieldEditor(String name, String label, Composite parent) { + super(name, label, parent); + initList(); } - public void addItem( String key, String label ) - { - fKeys.add( key ); - fLabels.add( label ); - fCombo.add( label ); + public void addItem(String key, String label) { + fKeys.add(key); + fLabels.add(label); + fCombo.add(label); } - public void addItem( String key, String label, String value ) - { - fKeys.add( key ); - fLabels.add( value ); - fCombo.add( label ); + public void addItem(String key, String label, String value) { + fKeys.add(key); + fLabels.add(value); + fCombo.add(label); } - public Combo getControl( ) - { + public Combo getControl() { return fCombo; } @Override - protected void adjustForNumColumns( int numColumns ) - { - if ( fCombo != null ) - { - GridData gd = (GridData) fCombo.getLayoutData( ); + protected void adjustForNumColumns(int numColumns) { + if (fCombo != null) { + GridData gd = (GridData) fCombo.getLayoutData(); gd.horizontalSpan = numColumns - 1; } } @Override - protected void doFillIntoGrid( Composite parent, int numColumns ) - { - Label l = new Label( parent, SWT.NULL ); - l.setText( getLabelText( ) ); - GridData gd = new GridData( ); - fCombo = new Combo( parent, SWT.READ_ONLY ); - fCombo.addSelectionListener( new SelectionAdapter( ) { + protected void doFillIntoGrid(Composite parent, int numColumns) { + Label l = new Label(parent, SWT.NULL); + l.setText(getLabelText()); + GridData gd = new GridData(); + fCombo = new Combo(parent, SWT.READ_ONLY); + fCombo.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected( SelectionEvent e ) - { - valueChanged( ); + public void widgetSelected(SelectionEvent e) { + valueChanged(); } - } ); - gd = new GridData( GridData.FILL_HORIZONTAL ); + }); + gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = numColumns - 1; - fCombo.setLayoutData( gd ); + fCombo.setLayoutData(gd); } @Override - protected void doLoad( ) - { - String value = getPreferenceStore( ).getString( getPreferenceName( ) ); - int index = fLabels.indexOf( value ); - if ( index >= 0 ) - fCombo.select( index ); + protected void doLoad() { + String value = getPreferenceStore().getString(getPreferenceName()); + int index = fLabels.indexOf(value); + if (index >= 0) + fCombo.select(index); } @Override - protected void doLoadDefault( ) - { - String value = getPreferenceStore( ).getDefaultString( getPreferenceName( ) ); - int index = fLabels.indexOf( value ); - if ( index >= 0 ) - { - fCombo.select( index ); - valueChanged( ); + protected void doLoadDefault() { + String value = getPreferenceStore().getDefaultString(getPreferenceName()); + int index = fLabels.indexOf(value); + if (index >= 0) { + fCombo.select(index); + valueChanged(); } } @Override - protected void doStore( ) - { + protected void doStore() { String value = ""; //$NON-NLS-1$ - if ( fCombo.getSelectionIndex( ) >= 0 ) - { - value = (String) fLabels.get( fCombo.getSelectionIndex( ) ); + if (fCombo.getSelectionIndex() >= 0) { + value = (String) fLabels.get(fCombo.getSelectionIndex()); } - getPreferenceStore( ).setValue( getPreferenceName( ), value ); + getPreferenceStore().setValue(getPreferenceName(), value); } @Override - public int getNumberOfControls( ) - { + public int getNumberOfControls() { return 2; } - protected String getSelectedKey( ) - { - int index = fCombo.getSelectionIndex( ); - if ( index >= 0 ) - return (String) fKeys.get( index ); + protected String getSelectedKey() { + int index = fCombo.getSelectionIndex(); + if (index >= 0) + return (String) fKeys.get(index); return null; } - protected void initList( ) - { - for ( int i = 0; i < fLabels.size( ); i++ ) - fCombo.add( (String) fLabels.get( i ) ); - fOldKey = getSelectedKey( ); + protected void initList() { + for (int i = 0; i < fLabels.size(); i++) + fCombo.add((String) fLabels.get(i)); + fOldKey = getSelectedKey(); } @Override - public boolean isValid( ) - { + public boolean isValid() { return fIsValid; } @Override - protected void refreshValidState( ) - { - fIsValid = fCombo.getSelectionIndex( ) >= 0; - } - - public void removeItem( String key ) - { - int index = fKeys.indexOf( key ); - if ( index >= 0 ) - { - fKeys.remove( index ); - fLabels.remove( index ); - fCombo.remove( index ); + protected void refreshValidState() { + fIsValid = fCombo.getSelectionIndex() >= 0; + } + + public void removeItem(String key) { + int index = fKeys.indexOf(key); + if (index >= 0) { + fKeys.remove(index); + fLabels.remove(index); + fCombo.remove(index); } } @@ -169,27 +145,23 @@ public void removeItem( String key ) * Set the focus to this field editor. */ @Override - public void setFocus( ) - { - if ( fCombo != null ) - { - fCombo.setFocus( ); + public void setFocus() { + if (fCombo != null) { + fCombo.setFocus(); } } - protected void valueChanged( ) - { - setPresentsDefaultValue( false ); + protected void valueChanged() { + setPresentsDefaultValue(false); boolean oldState = fIsValid; - refreshValidState( ); + refreshValidState(); - if ( fIsValid != oldState ) - fireStateChanged( IS_VALID, oldState, fIsValid ); + if (fIsValid != oldState) + fireStateChanged(IS_VALID, oldState, fIsValid); - String newKey = getSelectedKey( ); - if ( newKey == null ? newKey != fOldKey : !newKey.equals( fOldKey ) ) - { - fireValueChanged( VALUE, fOldKey, newKey ); + String newKey = getSelectedKey(); + if (newKey == null ? newKey != fOldKey : !newKey.equals(fOldKey)) { + fireValueChanged(VALUE, fOldKey, newKey); fOldKey = newKey; } } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/source/attach/IAttachSourceHandler.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/source/attach/IAttachSourceHandler.java index b822953a..b0f19968 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/source/attach/IAttachSourceHandler.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/source/attach/IAttachSourceHandler.java @@ -1,23 +1,20 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.source.attach; import org.eclipse.jdt.core.IPackageFragmentRoot; -public interface IAttachSourceHandler -{ +@Deprecated +public interface IAttachSourceHandler { - public void execute( IPackageFragmentRoot library, boolean showUI ); + public void execute(IPackageFragmentRoot library, boolean showUI); - public boolean syncAttachSource( IPackageFragmentRoot root ); + public boolean syncAttachSource(IPackageFragmentRoot root); } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/update/IDecompilerUpdateHandler.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/update/IDecompilerUpdateHandler.java deleted file mode 100644 index e7b7b434..00000000 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/update/IDecompilerUpdateHandler.java +++ /dev/null @@ -1,19 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.update; - -public interface IDecompilerUpdateHandler -{ - - void execute( boolean showUI ); - -} diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/ClassUtil.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/ClassUtil.java index b209db1f..fe17a626 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/ClassUtil.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/ClassUtil.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.util; @@ -15,200 +12,127 @@ import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.util.Collection; -import java.util.Iterator; +import java.util.Optional; +import java.util.stream.Stream; +import org.objectweb.asm.ClassReader; import org.sf.feeling.decompiler.JavaDecompilerPlugin; +import org.sf.feeling.decompiler.editor.BaseDecompiler; import org.sf.feeling.decompiler.editor.IDecompiler; import org.sf.feeling.decompiler.editor.IDecompilerDescriptor; -import org.sf.feeling.decompiler.fernflower.FernFlowerDecompiler; +import org.sf.feeling.decompiler.editor.NoStackTraceException; -public class ClassUtil -{ +public class ClassUtil { - public static IDecompiler checkAvailableDecompiler( IDecompiler decompiler, File file ) - { - FileInputStream fis = null; - try - { - fis = new FileInputStream( file ); - return checkAvailableDecompiler( decompiler, fis ); - } - catch ( FileNotFoundException e ) - { - e.printStackTrace( ); - } - finally - { - if ( fis != null ) - { - try - { - fis.close( ); - } - catch ( IOException e ) - { - e.printStackTrace( ); - } - } + public static IDecompiler checkAvailableDecompiler(IDecompiler decompiler, File file) { + try (FileInputStream fis = new FileInputStream(file)) { + return checkAvailableDecompiler(decompiler, fis); + } catch (IOException e) { + Logger.error(e); } return decompiler; } - public static IDecompiler checkAvailableDecompiler( IDecompiler decompiler, InputStream is ) - { - int classLevel = getLevel( is ); - if ( decompiler.supportLevel( classLevel ) ) - { - if ( isDebug( ) ) - { - if ( !decompiler.supportDebugLevel( classLevel ) ) - { - return getDefaultDecompiler( classLevel, isDebug( ) ); + public static IDecompiler checkAvailableDecompiler(IDecompiler decompiler, InputStream is) { + int classLevel = getLevel(is); + + boolean debug = isDebug(); + IDecompiler defaultDecompiler = getDebugDecompiler(classLevel, debug); + defaultDecompiler.clearExceptions(); + + if (decompiler.supportLevel(classLevel)) { + if (debug) { + if (!decompiler.supportDebugLevel(classLevel)) { + String recommendation = ""; + if (JavaDecompilerPlugin.getDefault().isDebug()) { + recommendation += "Disable the 'Align code for debugging' option. "; + } + if (UIUtil.isDebugPerspective()) { + recommendation += "Switch to the Java perspective. "; + } + if (JavaDecompilerPlugin.getDefault().isDebugMode()) { + recommendation += "Disable the debug Mode. "; + } + String msg = "Could not use " + decompiler.getClass().getSimpleName() + + " for decompilation since the debug view is not supported. " + recommendation + + "Falling back to " + defaultDecompiler.getClass().getSimpleName() + "."; + JavaDecompilerPlugin.logInfo(msg); + ((BaseDecompiler) decompiler).addException(new NoStackTraceException(msg)); + return defaultDecompiler; } } - } - else - { - return getDefaultDecompiler( classLevel, isDebug( ) ); + } else { + String msg = "Could not use " + decompiler.getClass().getSimpleName() + + " for decompilation since the classLevel " + classLevel + " is not supported. " + + "Falling back to " + defaultDecompiler.getClass().getSimpleName() + "."; + JavaDecompilerPlugin.logInfo(msg); + ((BaseDecompiler) decompiler).addException(new NoStackTraceException(msg)); + return defaultDecompiler; } return decompiler; } - public static boolean isDebug( ) - { - return JavaDecompilerPlugin.getDefault( ).isDebug( ) - || UIUtil.isDebugPerspective( ) - || JavaDecompilerPlugin.getDefault( ).isDebugMode( ); - } - - public static boolean greatLevel6( File file ) - { - DataInputStream data = null; - try - { - data = new DataInputStream( new FileInputStream( file ) ); - if ( 0xCAFEBABE != data.readInt( ) ) - { - return false; - } - data.readUnsignedShort( ); - int major = data.readUnsignedShort( ); - data.close( ); - data = null; - return major >= 51; - } - catch ( IOException e ) - { - e.printStackTrace( ); - } - finally - { - if ( data != null ) - { - try - { - data.close( ); - } - catch ( IOException e ) - { - e.printStackTrace( ); - } - } - } - return false; + public static boolean isDebug() { + return JavaDecompilerPlugin.getDefault().isDebug() || UIUtil.isDebugPerspective() + || JavaDecompilerPlugin.getDefault().isDebugMode(); } - public static int getLevel( InputStream is ) - { - DataInputStream data = null; - try - { - data = new DataInputStream( is ); - if ( 0xCAFEBABE != data.readInt( ) ) - { + public static int getLevel(InputStream is) { + try (DataInputStream data = new DataInputStream(is)) { + if (0xCAFEBABE != data.readInt()) { return -1; } - data.readUnsignedShort( ); - int major = data.readUnsignedShort( ); + data.readUnsignedShort(); + int major = data.readUnsignedShort(); return major - 44; - } - catch ( IOException e ) - { - e.printStackTrace( ); + } catch (IOException e) { + Logger.error("Failed to get Class file version", e); } return -1; } - public static boolean isClassFile( byte[] bytes ) - { - ByteArrayInputStream bis = new ByteArrayInputStream( bytes ); - DataInputStream data = null; - try - { - data = new DataInputStream( bis ); - if ( 0xCAFEBABE != data.readInt( ) ) - { + public static boolean isClassFile(byte[] classData) { + try (DataInputStream data = new DataInputStream(new ByteArrayInputStream(classData))) { + if (0xCAFEBABE != data.readInt()) { return false; } - data.readUnsignedShort( ); - data.readUnsignedShort( ); + data.readUnsignedShort(); + data.readUnsignedShort(); return true; - } - catch ( IOException e ) - { - e.printStackTrace( ); - } - finally - { - if ( data != null ) - { - try - { - data.close( ); - } - catch ( IOException e ) - { - e.printStackTrace( ); - } - } + } catch (IOException e) { + Logger.error("Class file test failed", e); } return false; } - public static IDecompiler getDefaultDecompiler( int level, boolean debug ) - { - Collection descriptors = JavaDecompilerPlugin.getDefault( ) - .getDecompilerDescriptorMap( ) - .values( ); - if ( descriptors != null ) - { - for ( Iterator iterator = descriptors.iterator( ); iterator.hasNext( ); ) - { - IDecompilerDescriptor iDecompilerDescriptor = (IDecompilerDescriptor) iterator.next( ); - if ( iDecompilerDescriptor.isDefault( ) ) - { - IDecompiler decompiler = iDecompilerDescriptor.getDecompiler( ); - if ( debug ) - { - if ( decompiler.supportDebug( ) && decompiler.supportDebugLevel( level ) ) - { - return decompiler; - } - } - else - { - if ( decompiler.supportLevel( level ) ) - { - return decompiler; - } - } - } + /** + * Uses FernFlower library to read the class and extract it's qualified name + */ + public static String getClassQualifiedName(byte[] classData) throws IOException { + ClassReader classReader = new ClassReader(classData); + return classReader.getClassName(); + } + + public static IDecompiler getDebugDecompiler(int level, boolean debug) { + Collection descriptors = JavaDecompilerPlugin.getDefault().getDecompilerDescriptorMap() + .values(); + if (descriptors != null) { + Stream stream = descriptors.stream(); + if (debug) { + stream = stream.filter(d -> d.getDecompiler().supportDebugLevel(level)); + } + Optional defaultDecompiler = stream + .sorted(new DefaultDecompilerDescriptorComparator()).findFirst(); + if (!defaultDecompiler.isPresent()) { + return null; } + IDecompiler decompiler = defaultDecompiler.get().getDecompiler(); + decompiler.clearExceptions(); + return decompiler; } - return new FernFlowerDecompiler( ); + return null; } } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/CommentUtil.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/CommentUtil.java new file mode 100644 index 00000000..95c4268a --- /dev/null +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/CommentUtil.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * Copyright (c) 2017 Chen Chao and other ECD project contributors. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.sf.feeling.decompiler.util; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.eclipse.jdt.core.dom.AST; +import org.eclipse.jdt.core.dom.ASTParser; +import org.eclipse.jdt.core.dom.BlockComment; +import org.eclipse.jdt.core.dom.Comment; +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jdt.core.dom.rewrite.ASTRewrite; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.Document; +import org.eclipse.text.edits.DeleteEdit; +import org.eclipse.text.edits.MalformedTreeException; +import org.eclipse.text.edits.TextEdit; +import org.sf.feeling.decompiler.JavaDecompilerPlugin; + +public final class CommentUtil { + + public static final String LINE_NUMBER_COMMENT = "/\\*\\s*\\d+\\s*\\*/"; + + private CommentUtil() { + } + + public static String clearComments(String input) { + ASTParser parser = ASTParser.newParser(EclipseUtils.getMaxJSLLevel()); // AST.JLS3 + CompilerOptions option = new CompilerOptions(); + Map options = option.getMap(); + options.put(CompilerOptions.OPTION_Compliance, EclipseUtils.getMaxDecompileLevel()); // $NON-NLS-1$ + options.put(CompilerOptions.OPTION_Source, EclipseUtils.getMaxDecompileLevel()); // $NON-NLS-1$ + parser.setCompilerOptions(options); + parser.setSource(input.toCharArray()); + CompilationUnit unit = (CompilationUnit) parser.createAST(null); + AST ast = unit.getAST(); + ASTRewrite rewriter = ASTRewrite.create(ast); + Document document = new Document(input); + TextEdit edits = rewriter.rewriteAST(document, null); + List textEdits = new ArrayList<>(); + List commentList = unit.getCommentList(); + for (Comment comment : commentList) { + if (comment.isBlockComment()) { + BlockComment blockComment = (BlockComment) comment; + int commentStart = blockComment.getStartPosition(); + int commentLength = blockComment.getLength(); + int commentEnd = commentStart + commentLength; + String commentText = input.substring(commentStart, commentEnd); + if (!commentText.trim().matches(LINE_NUMBER_COMMENT)) { + textEdits.add(new DeleteEdit(commentStart, commentLength)); + } + } + } + edits.addChildren(textEdits.toArray(new TextEdit[textEdits.size()])); + try { + edits.apply(document); + } catch (MalformedTreeException | BadLocationException e) { + JavaDecompilerPlugin.logError(e, e.getMessage()); + } + return document.get(); + } +} diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/DecompileUtil.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/DecompileUtil.java index a8393a2d..c319a980 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/DecompileUtil.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/DecompileUtil.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.util; @@ -20,255 +17,105 @@ import java.util.regex.Pattern; import org.eclipse.core.runtime.CoreException; -import org.eclipse.jdt.core.IBuffer; import org.eclipse.jdt.core.IClassFile; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.internal.compiler.env.IBinaryType; -import org.eclipse.jdt.internal.core.BufferManager; import org.eclipse.jdt.internal.core.ClassFile; import org.eclipse.jdt.internal.core.SourceMapper; import org.eclipse.ui.ide.FileStoreEditorInput; import org.sf.feeling.decompiler.editor.DecompilerSourceMapper; -import org.sf.feeling.decompiler.editor.DecompilerType; -import org.sf.feeling.decompiler.editor.JavaDecompilerClassFileEditor; import org.sf.feeling.decompiler.editor.SourceMapperFactory; -public class DecompileUtil -{ +public class DecompileUtil { - public static String decompile( IClassFile cf, String type, boolean always, boolean reuseBuf, boolean force ) - throws CoreException - { + public static String decompile(IClassFile cf, String type, boolean always, boolean reuseBuf, boolean force) + throws CoreException { String decompilerType = type; - String origSrc = cf.getSource( ); + String origSrc = cf.getSource(); // have to check our mark since all line comments are stripped // in debug align mode - if ( origSrc == null - || always && !MarkUtil.containsMark( origSrc ) - || ( MarkUtil.containsMark( origSrc ) && ( !reuseBuf || force ) ) ) - { - DecompilerSourceMapper sourceMapper = SourceMapperFactory.getSourceMapper( decompilerType ); - char[] src = sourceMapper.findSource( cf.getType( ) ); - - if ( src == null && !DecompilerType.FernFlower.equals( decompilerType ) ) - { - src = SourceMapperFactory.getSourceMapper( DecompilerType.FernFlower ).findSource( cf.getType( ) ); - } - if ( src == null ) - { + if (origSrc == null || always || !reuseBuf || force) { + DecompilerSourceMapper sourceMapper = SourceMapperFactory.getSourceMapper(decompilerType); + char[] src = sourceMapper.findSource(cf.getType()); + if (src == null) { return origSrc; } - else - return new String( src ); + return new String(src); } return origSrc; } - public static String decompiler( FileStoreEditorInput input, String decompilerType ) - { - DecompilerSourceMapper sourceMapper = SourceMapperFactory.getSourceMapper( decompilerType ); - File file = new File( input.getURI( ) ); - return sourceMapper.decompile( decompilerType, file ); - + public static String decompileInput(FileStoreEditorInput input, String decompilerType) { + DecompilerSourceMapper sourceMapper = SourceMapperFactory.getSourceMapper(decompilerType); + File file = new File(input.getURI()); + return sourceMapper.decompileFile(decompilerType, file); } - public static String getPackageName( String source ) - { - Pattern p = Pattern.compile( "(?i)package\\s+\\S+" ); //$NON-NLS-1$ + public static String getPackageName(String source) { + Pattern p = Pattern.compile("(?i)package\\s+\\S+"); //$NON-NLS-1$ - Matcher m = p.matcher( source ); - if ( m.find( ) ) - { - return m.group( ) - .replace( "package", "" ) //$NON-NLS-1$ //$NON-NLS-2$ - .replace( ";", "" ) //$NON-NLS-1$ //$NON-NLS-2$ - .trim( ); + Matcher m = p.matcher(source); + if (m.find()) { + return m.group().replace("package", "") //$NON-NLS-1$ //$NON-NLS-2$ + .replace(";", "") //$NON-NLS-1$ //$NON-NLS-2$ + .trim(); } return null; } - public static String checkAndUpdateCopyright( JavaDecompilerClassFileEditor editor, IClassFile cf, String origSrc ) - throws JavaModelException - { - if ( MarkUtil.containsMark( new String( origSrc ) ) ) - { - editor.clearSelection( ); - } - - if ( !MarkUtil.containsSourceMark( origSrc ) && !MarkUtil.containsMark( origSrc ) ) - { - IBuffer buffer = cf.getBuffer( ); - ReflectionUtils.invokeMethod( buffer, "setReadOnly", new Class[]{ //$NON-NLS-1$ - boolean.class - }, new Object[]{ - false - } ); - - String contents = getCopyRightContent( cf, origSrc ); - - buffer.setContents( contents ); - - ReflectionUtils.invokeMethod( BufferManager.getDefaultBufferManager( ), "addBuffer", new Class[]{ //$NON-NLS-1$ - IBuffer.class - }, new Object[]{ - buffer - } ); - - updateSourceRanges( cf, contents ); - return contents; - } - else - { - updateSourceRanges( cf, origSrc ); - } + public static String updateBuffer(IClassFile cf, String origSrc) throws JavaModelException { + updateSourceRanges(cf, origSrc); return origSrc; } - public static String updateBuffer( IClassFile cf, String origSrc ) throws JavaModelException - { - if ( !MarkUtil.containsSourceMark( origSrc ) && !MarkUtil.containsMark( origSrc ) ) - { - IBuffer buffer = cf.getBuffer( ); - if ( buffer != null ) - { - ReflectionUtils.invokeMethod( buffer, "setReadOnly", new Class[]{ //$NON-NLS-1$ - boolean.class - }, new Object[]{ - false - } ); - - String contents = getCopyRightContent( cf, origSrc ); - - buffer.setContents( contents ); - - ReflectionUtils.invokeMethod( BufferManager.getDefaultBufferManager( ), "addBuffer", new Class[]{ //$NON-NLS-1$ - IBuffer.class - }, new Object[]{ - buffer - } ); - updateSourceRanges( cf, contents ); - return contents; - } - } - else - { - updateSourceRanges( cf, origSrc ); - } - return origSrc; - } - - public static void updateSourceRanges( IClassFile cf, String contents ) throws JavaModelException - { - if ( cf instanceof ClassFile ) - { + public static void updateSourceRanges(IClassFile cf, String contents) throws JavaModelException { + if (cf instanceof ClassFile) { ClassFile classFile = (ClassFile) cf; - Object info = classFile.getElementInfo( ); + Object info = EclipseCompatibilityHelper.javaElementGetElementInfo(classFile); IBinaryType typeInfo = info instanceof IBinaryType ? (IBinaryType) info : null; - SourceMapper mapper = classFile.getSourceMapper( ); - IType type = (IType) ReflectionUtils.invokeMethod( classFile, - "getOuterMostEnclosingType", //$NON-NLS-1$ - new Class[0], - new Object[0] ); - HashMap sourceRange = (HashMap) ReflectionUtils.getFieldValue( mapper, "sourceRanges" ); //$NON-NLS-1$ - sourceRange.remove( type ); - mapper.mapSource( type, contents.toCharArray( ), typeInfo ); + SourceMapper mapper = classFile.getSourceMapper(); + // private org.eclipse.jdt.internal.core.ClassFile.getOuterMostEnclosingType() + IType type = (IType) ReflectionUtils.invokeMethod(classFile, "getOuterMostEnclosingType"); - // List rootPaths = (List) ReflectionUtils.getFieldValue( mapper, - // "rootPaths" ); - // String rootPath = null; - // if ( rootPaths != null && rootPaths.size( ) > 0 ) - // { - // rootPath = (String) rootPaths.get( 0 ); - // } - // - // if ( "".equals( rootPath ) ) - // rootPath = null; - // - // ImportSourceMapper importMapper = new ImportSourceMapper( - // (IPath) ReflectionUtils.getFieldValue( mapper, - // "sourcePath" ), - // rootPath, - // (Map) ReflectionUtils.getFieldValue( mapper, "options" ) ); - // importMapper.mapSource( type, contents.toCharArray( ), typeInfo - // ); - } - } - - public static String getCopyRightContent( IClassFile classFile, String origSrc ) - { - if ( origSrc != null && !MarkUtil.containsSourceMark( origSrc ) ) - { - String src = DecompileUtil.deleteOneEmptyLine( origSrc ); - String contents = MarkUtil.getRandomSourceMark( classFile ) - + "\n" //$NON-NLS-1$ - + src; - if ( src == null ) - { - contents = MarkUtil.getRandomSourceMark( classFile ) - + "\n" //$NON-NLS-1$ - + DecompileUtil.foldOneLine( origSrc ); - } - return contents; + HashMap sourceRange = (HashMap) ReflectionUtils.getFieldValue(mapper, "sourceRanges"); //$NON-NLS-1$ + sourceRange.remove(type); + SourceMapperUtil.mapSource(mapper, type, contents.toCharArray(), typeInfo); } - return origSrc; - } - - private static String foldOneLine( String origSrc ) - { - int index = origSrc.indexOf( "\r\n" ); //$NON-NLS-1$ - if ( index != -1 ) - { - return origSrc.substring( 0, index ) + origSrc.substring( index + 2 ); - } - - index = origSrc.indexOf( "\n" ); //$NON-NLS-1$ - if ( index != -1 ) - { - return origSrc.substring( 0, index ) + origSrc.substring( index + 1 ); - } - return origSrc; } - public static String deleteOneEmptyLine( String origSrc ) - { - int index = origSrc.indexOf( "{" ); //$NON-NLS-1$ - if ( index == -1 ) - { + public static String deleteOneEmptyLine(String origSrc) { + int index = origSrc.indexOf("{"); //$NON-NLS-1$ + if (index == -1) { return origSrc; } - String prefix = origSrc.substring( 0, index + 1 ); - String suffix = origSrc.substring( index + 1 ); + String prefix = origSrc.substring(0, index + 1); + String suffix = origSrc.substring(index + 1); - List splits = new ArrayList( Arrays.asList( prefix.split( "\n" ) ) ); //$NON-NLS-1$ + List splits = new ArrayList(Arrays.asList(prefix.split("\n"))); //$NON-NLS-1$ boolean flag = false; - for ( int i = 0; i < splits.size( ); i++ ) - { - String split = splits.get( i ); - if ( split.trim( ).length( ) == 0 ) - { - splits.remove( i ); + for (int i = 0; i < splits.size(); i++) { + String split = splits.get(i); + if (split.trim().length() == 0) { + splits.remove(i); flag = true; break; } } - if ( flag ) - { - StringBuffer buffer = new StringBuffer( ); - for ( int i = 0; i < splits.size( ); i++ ) - { - String split = splits.get( i ); - buffer.append( split ); - if ( i < splits.size( ) - 1 ) - { - buffer.append( "\n" ); //$NON-NLS-1$ + if (flag) { + StringBuffer buffer = new StringBuffer(); + for (int i = 0; i < splits.size(); i++) { + String split = splits.get(i); + buffer.append(split); + if (i < splits.size() - 1) { + buffer.append("\n"); //$NON-NLS-1$ } } - buffer.append( suffix ); - return buffer.toString( ); + buffer.append(suffix); + return buffer.toString(); } return null; } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/DecompilerOutputUtil.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/DecompilerOutputUtil.java deleted file mode 100644 index c359a490..00000000 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/DecompilerOutputUtil.java +++ /dev/null @@ -1,960 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.util; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.dom.AST; -import org.eclipse.jdt.core.dom.ASTNode; -import org.eclipse.jdt.core.dom.ASTParser; -import org.eclipse.jdt.core.dom.AbstractTypeDeclaration; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jdt.core.dom.EnumConstantDeclaration; -import org.eclipse.jdt.core.dom.EnumDeclaration; -import org.eclipse.jdt.core.dom.FieldDeclaration; -import org.eclipse.jdt.core.dom.Initializer; -import org.eclipse.jdt.core.dom.MethodDeclaration; -import org.eclipse.jdt.core.dom.TypeDeclaration; -import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; -import org.sf.feeling.decompiler.editor.DecompilerType; - -public class DecompilerOutputUtil -{ - - public static final String NO_LINE_NUMBER = "// Warning: No line numbers available in class file"; //$NON-NLS-1$ - - /** - * Input string - */ - private final String input; - - /** - * Input split into lines - */ - private final List inputLines = new ArrayList( ); - - /** - * Parsed input - */ - private CompilationUnit unit; - - /** - * Output lines - */ - private final List javaSrcLines = new ArrayList( ); - - public final static String line_separator = System.getProperty( "line.separator", //$NON-NLS-1$ - "\r\n" ); //$NON-NLS-1$ - - private String decompilerType; - private Object markKey; - - private class InputLine - { - - String line; - int outputLineNum = -1; - int calculatedNumLineJavaSrc = -1; - - @Override - public String toString( ) - { - return line; - } - } - - private class JavaSrcLine - { - - List inputLines = new ArrayList( ); - - @Override - public String toString( ) - { - return inputLines.toString( ); - } - } - - public DecompilerOutputUtil( Object markKey, String decompilerType, String input ) - { - this.input = input + line_separator; - this.decompilerType = decompilerType; - this.markKey = markKey; - } - - public String realign( ) - { - // Handle special cases - if ( input.length( ) == 0 ) - return input; - if ( input == null ) - return null; - - // Compute the string offset of every source line - fillOutputList( ); - - // Parse source code into AST - javaSrcLines.add( null ); - ASTParser parser = ASTParser.newParser( DecompilerOutputUtil.getMaxJSLLevel( ) ); // AST.JLS3 - CompilerOptions option = new CompilerOptions( ); - Map options = option.getMap( ); - options.put( CompilerOptions.OPTION_Compliance, DecompilerOutputUtil.getMaxDecompileLevel( ) ); // $NON-NLS-1$ - options.put( CompilerOptions.OPTION_Source, DecompilerOutputUtil.getMaxDecompileLevel( ) ); // $NON-NLS-1$ - parser.setCompilerOptions( options ); - - if ( MarkUtil.containsMark( input ) ) - { - String content = input.replace( MarkUtil.getMark( input ), "" ); //$NON-NLS-1$ - parser.setSource( content.toCharArray( ) ); - } - else - { - parser.setSource( input.toCharArray( ) ); - - } - unit = (CompilationUnit) parser.createAST( null ); - - // Iterate over types (ignoring enums and annotations) - List types = unit.types( ); - for ( int i = 0; i < types.size( ); i++ ) - { - if ( types.get( i ) instanceof AbstractTypeDeclaration ) - { - // Recursively process the elements within this type - processElements( (AbstractTypeDeclaration) types.get( i ) ); - } - } - - // Iterate over types (ignorning enums and annotations) - int firstTypeLine = Integer.MAX_VALUE; - int lastTypeLine = Integer.MIN_VALUE; - for ( int i = 0; i < types.size( ); i++ ) - { - if ( !( types.get( i ) instanceof AbstractTypeDeclaration ) ) - continue; - AbstractTypeDeclaration type = (AbstractTypeDeclaration) types.get( i ); - - // Recursively process the types within this type - processTypes( type ); - - // Update firstTypeLine/lastTypeLine - int numLine = unit.getLineNumber( type.getStartPosition( ) ); - if ( numLine < firstTypeLine ) - firstTypeLine = numLine; - numLine = unit.getLineNumber( type.getStartPosition( ) + type.getLength( ) - 1 ); - if ( numLine > lastTypeLine ) - lastTypeLine = numLine; - } - - // Special case - no source items to handle so just return our input - if ( javaSrcLines.size( ) == 1 ) - { - String warning = "\r\n" + NO_LINE_NUMBER + "\r\n"; //$NON-NLS-1$ //$NON-NLS-2$ - return ( MarkUtil.getRandomMark( markKey ) - + "\r\n" //$NON-NLS-1$ - + warning - + replace( input, MarkUtil.getMark( input ), "" ) ); //$NON-NLS-1$ - } - - // Add all the source lines above the first type - if ( firstTypeLine != Integer.MAX_VALUE ) - addBelow( firstTypeLine - 1, 0, 0 ); - - // Add all the source lines below the last type - if ( lastTypeLine != Integer.MIN_VALUE ) - addBelow( inputLines.size( ) - 2, lastTypeLine, javaSrcLines.size( ) - 1 ); - - // Create aligned source - return toString( ); - } - - public static boolean isEmpty( String str ) - { - return str == null || str.length( ) == 0; - } - - public static String replace( String text, String searchString, String replacement ) - { - if ( isEmpty( text ) || isEmpty( searchString ) || replacement == null ) - { - return text; - } - int start = 0; - int end = text.indexOf( searchString, start ); - if ( end == -1 ) - { - return text; - } - int replLength = searchString.length( ); - int increase = replacement.length( ) - replLength; - increase = ( increase < 0 ? 0 : increase ); - increase *= 16; - StringBuffer buf = new StringBuffer( text.length( ) + increase ); - while ( end != -1 ) - { - buf.append( text.substring( start, end ) ).append( replacement ); - start = end + replLength; - end = text.indexOf( searchString, 2 ); - } - buf.append( text.substring( start ) ); - return buf.toString( ); - } - - @Override - public String toString( ) - { - String line; - int numLine; - StringBuffer realignOutput = new StringBuffer( ); - - int lineNumberWidth = String.valueOf( javaSrcLines.size( ) ).length( ); - - boolean generateEmptyString = true; - int leftTrimSpace = 0; - - Pattern pattern = Pattern.compile( "/\\*\\s+\\*/", //$NON-NLS-1$ - Pattern.CASE_INSENSITIVE ); - Matcher matcher = pattern.matcher( input ); - if ( matcher.find( ) ) - { - generateEmptyString = false; - - pattern = Pattern.compile( "([ ]+)import", //$NON-NLS-1$ - Pattern.CASE_INSENSITIVE ); - matcher = pattern.matcher( input ); - if ( matcher.find( ) ) - { - leftTrimSpace = matcher.group( ) - .replace( "import", "" ) //$NON-NLS-1$ //$NON-NLS-2$ - .length( ); - } - } - else - { - pattern = Pattern.compile( "([ ]+)import", //$NON-NLS-1$ - Pattern.CASE_INSENSITIVE ); - matcher = pattern.matcher( input ); - if ( matcher.find( ) ) - { - leftTrimSpace = matcher.group( ) - .replace( "import", "" ) //$NON-NLS-1$ //$NON-NLS-2$ - .length( ); - generateEmptyString = true; - } - } - - int lastBracketIndex = input.lastIndexOf( '}' ); - if ( lastBracketIndex != -1 ) - { - int trimSpace = getLeftPosition( input, input.lastIndexOf( '}', lastBracketIndex - 1 ) ) - - getLeftPosition( input, lastBracketIndex ); - if ( trimSpace > 4 ) - { - leftTrimSpace += trimSpace - 4; - } - } - - for ( int i = 1; i < javaSrcLines.size( ); i++ ) - { - JavaSrcLine javaSrcLine = initJavaSrcListItem( i ); - - if ( javaSrcLine.inputLines.size( ) > 0 ) - { - int outputLineNumber = getOutputLineNumber( javaSrcLine ); - - if ( outputLineNumber != -1 ) - { - List beforeLines = getBeforeLines( javaSrcLine ); - if ( beforeLines != null && !beforeLines.isEmpty( ) ) - { - - int index = realignOutput.lastIndexOf( line_separator ); - if ( index == realignOutput.length( ) - line_separator.length( ) ) - { - realignOutput.replace( index, index + line_separator.length( ), "" ); //$NON-NLS-1$ - - for ( int j = 0; j < beforeLines.size( ); j++ ) - { - numLine = beforeLines.get( j ); - line = inputLines.get( numLine ).line; - line = removeJavaLineNumber( line.replace( "\r\n", "\n" ) //$NON-NLS-1$ //$NON-NLS-2$ - .replace( "\n", "" ), //$NON-NLS-1$ //$NON-NLS-2$ - j == 0 && generateEmptyString, - leftTrimSpace ); - realignOutput.append( line ); - } - - realignOutput.append( line_separator ); - - javaSrcLine.inputLines.removeAll( beforeLines ); - } - } - } - - if ( i > 1 ) - { - realignOutput.append( "/* " //$NON-NLS-1$ - + getLineNumber( outputLineNumber, lineNumberWidth ) - + " */ " ); //$NON-NLS-1$ - } - - for ( int j = 0; j < javaSrcLine.inputLines.size( ); j++ ) - { - numLine = javaSrcLine.inputLines.get( j ); - line = inputLines.get( numLine ).line; - line = removeJavaLineNumber( line.replace( "\r\n", "\n" ).replace( "\n", "" ), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - j == 0 && generateEmptyString, - leftTrimSpace ); - realignOutput.append( line ); - } - } - else if ( i > 1 ) - { - realignOutput.append( "/* " //$NON-NLS-1$ - + getLineNumber( -1, lineNumberWidth ) - + " */ " ); //$NON-NLS-1$ - } - realignOutput.append( line_separator ); - } - return realignOutput.toString( ); - } - - private List getBeforeLines( JavaSrcLine javaSrcLine ) - { - List lineNumbers = new ArrayList( ); - for ( int i = 0; i < javaSrcLine.inputLines.size( ); i++ ) - { - int num = javaSrcLine.inputLines.get( i ); - InputLine line = inputLines.get( num ); - if ( line != null && line.outputLineNum != -1 ) - { - break; - } - else - { - lineNumbers.add( num ); - } - } - return lineNumbers; - } - - private int getOutputLineNumber( JavaSrcLine javaSrcLine ) - { - for ( int i = 0; i < javaSrcLine.inputLines.size( ); i++ ) - { - int numLine = javaSrcLine.inputLines.get( i ); - InputLine inputLine = inputLines.get( numLine ); - if ( inputLine != null && inputLine.outputLineNum != -1 ) - return inputLine.outputLineNum; - } - return -1; - } - - private int getLeftPosition( String string, int index ) - { - if ( string == null || string.length( ) < index ) - return -1; - - for ( int j = index - 1; j >= 0; j-- ) - { - if ( j < 0 ) - break; - if ( string.charAt( j ) == '\n' ) - return index - j; - } - return -1; - } - - private String getLineNumber( int i, int lineNumberWidth ) - { - String number = String.valueOf( i ); - int width = number.length( ); - if ( i == -1 ) - { - width = 0; - number = ""; //$NON-NLS-1$ - } - if ( width < lineNumberWidth ) - { - for ( int j = 0; j < lineNumberWidth - width; j++ ) - { - number = " " + number; //$NON-NLS-1$ - } - } - - return number; - } - - private String generageEmptyString( int length ) - { - char[] chs = new char[length]; - for ( int i = 0; i < chs.length; i++ ) - { - chs[i] = ' '; - } - return new String( chs ); - } - - private void fillOutputList( ) - { - int lineStart = 0; - int lineEnd = 0; - inputLines.add( null ); - while ( lineStart < input.length( ) ) - { - // Compute line end - lineEnd = input.indexOf( '\n', lineEnd ); - if ( lineEnd == -1 ) - lineEnd = input.length( ); - else - lineEnd++; - - // Build OutputLine object - InputLine outputLine = new InputLine( ); - outputLine.line = input.substring( lineStart, lineEnd ); - inputLines.add( outputLine ); - - // Next line start is current line end - lineStart = lineEnd; - } - } - - public static int parseJavaLineNumber( String decompilerType, String line ) - { - String regex = "/\\*\\s*\\d+\\s*\\*/"; //$NON-NLS-1$ - if ( DecompilerType.FernFlower.equals( decompilerType ) ) - { - regex = "//\\s+\\d+"; //$NON-NLS-1$ - } - Pattern pattern = Pattern.compile( regex, Pattern.CASE_INSENSITIVE ); - Matcher matcher = pattern.matcher( line.trim( ) ); - if ( matcher.find( ) ) - { - return Integer.parseInt( matcher.group( ).replaceAll( "[^0-9]", "" ) ); //$NON-NLS-1$ //$NON-NLS-2$ - } - return -1; - } - - public static int parseJavaLineNumber( String line ) - { - String regex = "/\\*\\s*\\d+\\s*\\*/"; //$NON-NLS-1$ - Pattern pattern = Pattern.compile( regex, Pattern.CASE_INSENSITIVE ); - Matcher matcher = pattern.matcher( line.trim( ) ); - if ( matcher.find( ) ) - { - return Integer.parseInt( matcher.group( ).replaceAll( "[^0-9]", "" ) ); //$NON-NLS-1$ //$NON-NLS-2$ - } - else - { - regex = "//\\s+\\d+"; //$NON-NLS-1$ - } - pattern = Pattern.compile( regex, Pattern.CASE_INSENSITIVE ); - matcher = pattern.matcher( line.trim( ) ); - if ( matcher.find( ) ) - { - return Integer.parseInt( matcher.group( ).replaceAll( "[^0-9]", "" ) ); //$NON-NLS-1$ //$NON-NLS-2$ - } - return -1; - } - - private String removeJavaLineNumber( String line, boolean generageEmptyString, int leftTrimSpace ) - { - String regex = "/\\*\\s*\\d+\\s*\\*/"; //$NON-NLS-1$ - if ( DecompilerType.FernFlower.equals( decompilerType ) ) - { - regex = "//\\s+\\d+(\\s*\\d*)*"; //$NON-NLS-1$ - } - Pattern pattern = Pattern.compile( regex, Pattern.CASE_INSENSITIVE ); - Matcher matcher = pattern.matcher( line.trim( ) ); - - if ( matcher.find( ) ) - { - line = line.replace( matcher.group( ), "" ); //$NON-NLS-1$ - if ( !DecompilerType.FernFlower.equals( decompilerType ) && generageEmptyString ) - { - line = generageEmptyString( matcher.group( ).length( ) ) + line; - } - } - if ( !DecompilerType.FernFlower.equals( decompilerType ) ) - { - regex = "/\\*\\s+\\*/"; //$NON-NLS-1$ - pattern = Pattern.compile( regex, Pattern.CASE_INSENSITIVE ); - matcher = pattern.matcher( line ); - - if ( matcher.find( ) ) - { - line = line.replace( matcher.group( ), "" ); //$NON-NLS-1$ - if ( generageEmptyString ) - { - line = generageEmptyString( matcher.group( ).length( ) ) + line; - } - } - } - if ( leftTrimSpace > 0 && line.startsWith( generageEmptyString( leftTrimSpace ) ) ) - { - line = line.substring( leftTrimSpace ); - } - return line; - } - - /** - * Make sure {@link #javaSrcLines} is at least outputLineNum entries long - * (adding nulls if necessary). - * - * @param outputLineNum - * @return the {@link JavaSrcLine} at index outputLineNum (creating one if - * one doesn't already exist). - */ - private JavaSrcLine initJavaSrcListItem( int outputLineNum ) - { - - // Fill in nulls for any previous output line nums which we haven't - // visited yet - if ( javaSrcLines.size( ) <= outputLineNum ) - { - for ( int a = javaSrcLines.size( ); a <= outputLineNum; a++ ) - javaSrcLines.add( null ); - } - - // Create an output entry at the outputLineNum index - JavaSrcLine javaSrcLine = javaSrcLines.get( outputLineNum ); - if ( javaSrcLine == null ) - { - javaSrcLine = new JavaSrcLine( ); - javaSrcLines.set( outputLineNum, javaSrcLine ); - } - return javaSrcLine; - } - - private void addAbove( int inputBeginLineNo, int inputLineNo, int outputLineNo ) - { - if ( outputLineNo == 1 ) - return; - - int offset = 1; - /* - * Example: - * - * 19: / / public static boolean isTranslucencySupported(Translucency - * paramTranslucency) 20: / / { 21: / 105 / switch - * (1.$SwitchMap$com$sun$awt$AWTUtilities$Translucency[paramTranslucency - * .ordinal()]) 22: / / { 23: / / case 1: 24: / 107 / return - * isWindowShapingSupported(); - * - * # addAbove(19, 21, 105) javaSrcLines[105] = [21] is already set when - * this method is called. This method creates the following entries in - * javaSrcLines: javaSrcLines[103] = [19] javaSrcLines[104] = [20] - * - * # addAbove(19, 24, 107) javaSrcLines[107] = [24] is already set when - * this method is called. This method creates the following entries in - * javaSrcLines: javaSrcLines[106] = [23] - * - * javaSrcLines[105] already has an entry so we add input line 22 to - * javaSrcLines[106]: javaSrcLines[105] = [22,23] - * - * The result is the following folding of the code: - * - * 103: / / public static boolean isTranslucencySupported(Translucency - * paramTranslucency) 104: / / { 105: / 105 / switch - * (1.$SwitchMap$com$sun$awt$AWTUtilities$Translucency[paramTranslucency - * .ordinal()]) 106: / / {/ / case 1: 107: / 107 / return - * isWindowShapingSupported(); - */ - - // Iterate backwards through the input lines towards inputBeginLineNo - while ( inputBeginLineNo <= ( inputLineNo - offset ) ) - { - - int offsetInputLine = inputLineNo - offset; - InputLine inputLine = inputLines.get( offsetInputLine ); - - if ( inputLine.outputLineNum == -1 ) - { - // Got an InputLine without a corresponding Java source line - JavaSrcLine javaSrcLine = null; - int offsetOutputLine = outputLineNo - offset; - - if ( offsetOutputLine > 0 ) - { - javaSrcLine = initJavaSrcListItem( offsetOutputLine ); - } - - if ( offsetOutputLine == 1 || javaSrcLine.inputLines.size( ) > 0 ) - { - // We have reached the start of the file OR the current - // javaSrcLine has some output lines - - int offsetOutputLineNext = offsetOutputLine + 1; - - // Get the JavaSrcLine for the output line after the current - // one - JavaSrcLine javaSrcLineNext = initJavaSrcListItem( offsetOutputLineNext ); - - // Iterate backwards through the input lines towards - // inputBeginLineNo from the output offset - for ( int innerOffset = offset; ( inputLineNo - innerOffset ) >= inputBeginLineNo; innerOffset++ ) - { - - int innerOffsetInputLine = inputLineNo - innerOffset; - inputLine = inputLines.get( innerOffsetInputLine ); - if ( inputLine.outputLineNum == -1 ) - { - // Found an input line without a source line number - // - add it to javaSrcLineNext - javaSrcLineNext.inputLines.add( 0, innerOffsetInputLine ); - inputLine.calculatedNumLineJavaSrc = offsetOutputLineNext; - } - else - { - // Got an InputLine with a corresponding Java source - // line - // we must already have handled this line and the - // ones above - // it. Time to bail out! - break; - } - } - // Run out of lines to process - bail out - break; - } - - // Add the offsetInputLine to the current javaSrcLine - javaSrcLine.inputLines.add( offsetInputLine ); - inputLine.calculatedNumLineJavaSrc = offsetOutputLine; - } - else - { - // Got an InputLine with a corresponding Java source line - // we must already have handled this line and the ones above - // it. Time to bail out! - break; - } - offset++; - } - } - - private void addBelow( int inputEndLineNo, int inputLineNo, int outputLineNo ) - { - - int offset = 1; - - // Iterate forwards through the input lines towards inputEndLineNo - while ( ( inputLineNo + offset ) < inputEndLineNo ) - { - - int offsetInputLine = inputLineNo + offset; - InputLine outputLine = inputLines.get( offsetInputLine ); - - if ( outputLine.outputLineNum == -1 ) - { - // Got an InputLine without a corresponding Java source line - int offsetOutputLine = outputLineNo + offset; - JavaSrcLine javaSrcLine = initJavaSrcListItem( offsetOutputLine ); - - if ( javaSrcLine.inputLines.size( ) > 0 ) - { - // The current javaSrcLine has some output lines - int offsetOutputLinePrev = offsetOutputLine - 1; - - // Get the JavaSrcLine for the output line after the current - // one - JavaSrcLine javaSrcLinePrev = initJavaSrcListItem( offsetOutputLinePrev ); - - // Iterate forwards through the input lines towards - // inputEndLineNo from the output offset - for ( int innerOffset = offset; ( inputLineNo + innerOffset ) <= inputEndLineNo; innerOffset++ ) - { - - int innerOffsetInputLine = inputLineNo + innerOffset; - outputLine = inputLines.get( innerOffsetInputLine ); - if ( outputLine.outputLineNum == -1 ) - { - // Found an input line without a source line number - // - add it to javaSrcLineNext - javaSrcLinePrev.inputLines.add( innerOffsetInputLine ); - outputLine.calculatedNumLineJavaSrc = offsetOutputLinePrev; - } - else - { - // Got an InputLine with a corresponding Java source - // line - // we must already have handled this line and the - // ones above - // it. Time to bail out! - break; - } - } - // Run out of lines to process - bail out - break; - } - javaSrcLine.inputLines.add( offsetInputLine ); - outputLine.calculatedNumLineJavaSrc = offsetOutputLine; - } - else - { - // Got an InputLine with a corresponding Java source line - // we must already have handled this line and the ones above - // it. Time to bail out! - break; - } - offset++; - } - - if ( inputLineNo + offset == inputEndLineNo ) - { - int offsetOutputLine = outputLineNo + offset; - - JavaSrcLine javaSrcLine = initJavaSrcListItem( offsetOutputLine ); - javaSrcLine.inputLines.add( inputEndLineNo ); - - InputLine outputLine = inputLines.get( inputEndLineNo ); - outputLine.calculatedNumLineJavaSrc = offsetOutputLine; - } - } - - private void processTypes( AbstractTypeDeclaration rootType ) - { - List declarations = rootType.bodyDeclarations( ); - for ( Object declaration : declarations ) - { - if ( declaration instanceof AbstractTypeDeclaration ) - { - AbstractTypeDeclaration typeDeclaration = (AbstractTypeDeclaration) declaration; - processTypes( typeDeclaration ); - } - } - - int beginTypeLine = Integer.MAX_VALUE; - int endTypeLine = Integer.MIN_VALUE; - int firstMethodLine = Integer.MAX_VALUE; - int lastMethodLine = Integer.MIN_VALUE; - - int beginTypeInputLineNo = unit.getLineNumber( rootType.getStartPosition( ) ); - int endTypeInputLineNo = unit.getLineNumber( rootType.getStartPosition( ) + rootType.getLength( ) - 1 ); - - // Iterate forward through the input line numbers of the type - for ( int inputLineNo = beginTypeInputLineNo; inputLineNo <= endTypeInputLineNo; inputLineNo++ ) - { - - // Get the output line number - InputLine inputLine = inputLines.get( inputLineNo ); - int numLineJavaSrc = inputLine.outputLineNum; - if ( numLineJavaSrc == -1 ) - numLineJavaSrc = inputLine.calculatedNumLineJavaSrc; - - if ( numLineJavaSrc != -1 ) - { - // Update the type begin/end output line numbers - if ( beginTypeLine > numLineJavaSrc ) - beginTypeLine = numLineJavaSrc; - if ( endTypeLine < numLineJavaSrc ) - endTypeLine = numLineJavaSrc; - - // Update the type first/last method input line numbers - if ( firstMethodLine > inputLineNo ) - firstMethodLine = inputLineNo; - if ( lastMethodLine < inputLineNo ) - lastMethodLine = inputLineNo; - } - } - - // Process the lines above and below this type - if ( beginTypeLine != Integer.MAX_VALUE ) - { - addAbove( beginTypeInputLineNo, firstMethodLine, beginTypeLine ); - addBelow( endTypeInputLineNo, lastMethodLine, endTypeLine ); - } - } - - private void processMembers( AbstractTypeDeclaration rootType ) - { - - // Iterate over the declarations in this type - List bodyDeclarations = new ArrayList( ); - if ( rootType instanceof EnumDeclaration ) - { - EnumDeclaration enumDeclaration = (EnumDeclaration) rootType; - List enumDeclarations = enumDeclaration.enumConstants( ); - - // Iterate over the enum constant declarations - int lastInputLineNo = -1; - for ( Object enumDeclObj : enumDeclarations ) - { - if ( enumDeclObj instanceof EnumConstantDeclaration ) - { - ASTNode element = (ASTNode) enumDeclObj; - int p = element.getStartPosition( ); - int inputBeginLine = unit.getLineNumber( p ); - - // If this declaration is on a new line add it to the - // bodyDeclarations - if ( inputBeginLine != lastInputLineNo ) - bodyDeclarations.add( enumDeclObj ); - - lastInputLineNo = inputBeginLine; - } - } - } - bodyDeclarations.addAll( rootType.bodyDeclarations( ) ); - - for ( Object bodyDeclaration : bodyDeclarations ) - { - if ( ( bodyDeclaration instanceof MethodDeclaration ) - || ( bodyDeclaration instanceof Initializer ) - || ( bodyDeclaration instanceof FieldDeclaration ) - || ( bodyDeclaration instanceof EnumConstantDeclaration ) ) - { - ASTNode element = (ASTNode) bodyDeclaration; - int p = element.getStartPosition( ); - int inputBeginLine = unit.getLineNumber( p ); - int inputEndLine = unit.getLineNumber( p + element.getLength( ) - 1 ); - processMember( inputBeginLine, inputEndLine ); - } - } - } - - private void processMember( int inputBeginLine, int inputEndLine ) - { - int lastOutputLine = -1; - int lastInputLine = -1; - int maxLine = -1; - // Iterate over the lines in this member - for ( int inputNumLine = inputBeginLine; inputNumLine <= inputEndLine; inputNumLine++ ) - { - - // Parse the commented line number if available - InputLine inputLine = inputLines.get( inputNumLine ); - inputLine.outputLineNum = parseJavaLineNumber( decompilerType, inputLine.line ); - - if ( inputLine.outputLineNum > 1 ) - { - - // We have a commented line number! - lastOutputLine = inputLine.outputLineNum; - lastInputLine = inputNumLine; - - // Add the input line to the output JavaSrcLine - JavaSrcLine javaSrcLine = initJavaSrcListItem( inputLine.outputLineNum ); - javaSrcLine.inputLines.add( inputNumLine ); - addAbove( inputBeginLine, inputNumLine, inputLine.outputLineNum ); - - if ( lastOutputLine > maxLine ) - { - maxLine = lastOutputLine; - } - } - } - - if ( lastInputLine != -1 && lastInputLine < inputEndLine ) - addBelow( inputEndLine, lastInputLine, maxLine ); - } - - private void processElements( AbstractTypeDeclaration rootType ) - { - if ( ( rootType instanceof TypeDeclaration ) || ( rootType instanceof EnumDeclaration ) ) - { - processMembers( rootType ); - } - - // Recurse into inner types and process their methods - List bodyDeclarations = rootType.bodyDeclarations( ); - for ( Object bodyDeclaration : bodyDeclarations ) - { - if ( bodyDeclaration instanceof AbstractTypeDeclaration ) - { - processElements( (AbstractTypeDeclaration) bodyDeclaration ); - } - } - } - - private static String level = null; - - public static String getMaxDecompileLevel( ) - { - if ( level == null ) - { - if ( ReflectionUtils.getDeclaredField( JavaCore.class, "VERSION_1_8" ) != null ) //$NON-NLS-1$ - { - level = (String) ReflectionUtils.getFieldValue( JavaCore.class, "VERSION_1_8" ); //$NON-NLS-1$ - } - else if ( ReflectionUtils.getDeclaredField( JavaCore.class, "VERSION_1_7" ) != null ) //$NON-NLS-1$ - { - level = (String) ReflectionUtils.getFieldValue( JavaCore.class, "VERSION_1_7" ); //$NON-NLS-1$ - } - else if ( ReflectionUtils.getDeclaredField( JavaCore.class, "VERSION_1_6" ) != null ) //$NON-NLS-1$ - { - level = (String) ReflectionUtils.getFieldValue( JavaCore.class, "VERSION_1_6" ); //$NON-NLS-1$ - } - else if ( ReflectionUtils.getDeclaredField( JavaCore.class, "VERSION_1_5" ) != null ) //$NON-NLS-1$ - { - level = (String) ReflectionUtils.getFieldValue( JavaCore.class, "VERSION_1_5" ); //$NON-NLS-1$ - } - else if ( ReflectionUtils.getDeclaredField( JavaCore.class, "VERSION_1_4" ) != null ) //$NON-NLS-1$ - { - level = (String) ReflectionUtils.getFieldValue( JavaCore.class, "VERSION_1_4" ); //$NON-NLS-1$ - } - else if ( ReflectionUtils.getDeclaredField( JavaCore.class, "VERSION_1_3" ) != null ) //$NON-NLS-1$ - { - level = (String) ReflectionUtils.getFieldValue( JavaCore.class, "VERSION_1_3" ); //$NON-NLS-1$ - } - else if ( ReflectionUtils.getDeclaredField( JavaCore.class, "VERSION_1_2" ) != null ) //$NON-NLS-1$ - { - level = (String) ReflectionUtils.getFieldValue( JavaCore.class, "VERSION_1_2" ); //$NON-NLS-1$ - } - else if ( ReflectionUtils.getDeclaredField( JavaCore.class, "VERSION_1_1" ) != null ) //$NON-NLS-1$ - { - level = (String) ReflectionUtils.getFieldValue( JavaCore.class, "VERSION_1_1" ); //$NON-NLS-1$ - } - else - { - level = "1.8"; //$NON-NLS-1$ - } - } - - return level; - } - - private static int jslLevel = -1; - - public static int getMaxJSLLevel( ) - { - if ( jslLevel == -1 ) - { - if ( ReflectionUtils.getDeclaredField( AST.class, "JLS8" ) != null ) //$NON-NLS-1$ - { - jslLevel = (Integer) ReflectionUtils.getFieldValue( AST.class, "JLS8" ); //$NON-NLS-1$ - } - else if ( ReflectionUtils.getDeclaredField( AST.class, "JLS4" ) != null ) //$NON-NLS-1$ - { - jslLevel = (Integer) ReflectionUtils.getFieldValue( AST.class, "JLS4" ); //$NON-NLS-1$ - } - else if ( ReflectionUtils.getDeclaredField( AST.class, "JLS3" ) != null ) //$NON-NLS-1$ - { - jslLevel = (Integer) ReflectionUtils.getFieldValue( AST.class, "JLS3" ); //$NON-NLS-1$ - } - else if ( ReflectionUtils.getDeclaredField( AST.class, "JLS2" ) != null ) //$NON-NLS-1$ - { - jslLevel = (Integer) ReflectionUtils.getFieldValue( AST.class, "JLS2" ); //$NON-NLS-1$ - } - else - { - jslLevel = 3; - } - } - return jslLevel; - } -} diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/DefaultDecompilerDescriptorComparator.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/DefaultDecompilerDescriptorComparator.java new file mode 100644 index 00000000..18689be7 --- /dev/null +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/DefaultDecompilerDescriptorComparator.java @@ -0,0 +1,22 @@ +package org.sf.feeling.decompiler.util; + +import java.util.Comparator; + +import org.sf.feeling.decompiler.editor.IDecompilerDescriptor; + +/** + * Sort available decompiler plugins by their + * {@link IDecompilerDescriptor#getDefaultPriority()}. + */ +public class DefaultDecompilerDescriptorComparator implements Comparator { + + @Override + public int compare(IDecompilerDescriptor o1, IDecompilerDescriptor o2) { + int res = Integer.compare(o2.getDefaultPriority(), o1.getDefaultPriority()); + if (res != 0) { + return res; + } + return o1.getDecompilerType().compareTo(o2.getDecompilerType()); + } + +} diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/EclipseCompatibilityHelper.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/EclipseCompatibilityHelper.java new file mode 100644 index 00000000..7d90dd88 --- /dev/null +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/EclipseCompatibilityHelper.java @@ -0,0 +1,37 @@ +package org.sf.feeling.decompiler.util; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import org.eclipse.jdt.internal.compiler.env.IBinaryType; +import org.eclipse.jdt.internal.core.BinaryType; +import org.eclipse.jdt.internal.core.JavaElement; + +public class EclipseCompatibilityHelper { + + public static IBinaryType binaryTypeGetElementInfo(BinaryType binaryType) { + // In Eclipse 2024-03 the method return type of getElementInfo() has been + // changed from Object to IBinaryType. This can cause a NoSuchMethodError. + // depending on the used Eclipse version. + // Therefore we call his method using reflection to be safe. + try { + Method getElemInfoMethod = binaryType.getClass().getMethod("getElementInfo"); + return (IBinaryType) getElemInfoMethod.invoke(binaryType); + } catch (NoSuchMethodException | SecurityException | IllegalAccessException | InvocationTargetException e) { + throw new RuntimeException(e); + } + } + + public static Object javaElementGetElementInfo(JavaElement classFile) { + // In Eclipse 2024-03 the method return type of getElementInfo() has been + // changed from Object to IElementInfo. This can cause a NoSuchMethodError + // depending on the used Eclipse version. + // Therefore we call his method using reflection to be safe. + try { + Method getElemInfoMethod = classFile.getClass().getMethod("getElementInfo"); + return getElemInfoMethod.invoke(classFile); + } catch (NoSuchMethodException | SecurityException | IllegalAccessException | InvocationTargetException e) { + throw new RuntimeException(e); + } + } +} diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/EclipseUtils.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/EclipseUtils.java new file mode 100644 index 00000000..cccce736 --- /dev/null +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/EclipseUtils.java @@ -0,0 +1,91 @@ +package org.sf.feeling.decompiler.util; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.regex.Pattern; + +import org.eclipse.jdt.core.JavaCore; +import org.eclipse.jdt.core.dom.AST; + +public class EclipseUtils { + + private static String maxDecompileLevel = null; + + /** + * @return the maximum Java version supported by the current Eclipse JDT version + */ + public static String getMaxDecompileLevel() { + if (maxDecompileLevel != null) { + return maxDecompileLevel; + } + + // replacement for newer Eclipse versions + // return JavaCore.latestSupportedJavaVersion(); + Object obj = ReflectionUtils.invokeMethod(JavaCore.class, "latestSupportedJavaVersion"); + if (obj != null) { + maxDecompileLevel = (String) obj; + return maxDecompileLevel; + } + + // filter oot all versions that are not a simple integers e.g. "9" "10" ... + Pattern p = Pattern.compile("^\\d+$"); + List allVersions = new LinkedList<>(JavaCore.getAllVersions()); + Iterator it = allVersions.iterator(); + while (it.hasNext()) { + String v = it.next(); + if (!p.matcher(v).matches()) { + it.remove(); + } + } + if (allVersions.isEmpty()) { + maxDecompileLevel = "1.8"; //$NON-NLS-1$ + return maxDecompileLevel; + } + + List allVersionsInt = new ArrayList<>(); + for (String v : allVersions) { + allVersionsInt.add(Integer.parseInt(v)); + } + maxDecompileLevel = Integer.toString(Collections.max(allVersionsInt)); + return maxDecompileLevel; + } + + private static int maxJsLevel = -1; + + public static int getMaxJSLLevel() { + if (maxJsLevel != -1) { + return maxJsLevel; + } + + // replacement for newer Eclipse versions + // return AST.getJLSLatest(); + Object obj = ReflectionUtils.invokeMethod(AST.class, "getJLSLatest"); + if (obj != null) { + maxJsLevel = (Integer) obj; + return maxJsLevel; + } + + Pattern p = Pattern.compile("^JLS\\d+$"); + int maxFieldValue = 8; // Java 8 is supported by all Eclipse versions ECD targets + for (Field f : AST.class.getFields()) { + if (f.getType() != int.class || !p.matcher(f.getName()).matches()) { + continue; + } + try { + int value = f.getInt(AST.class); + if (value > maxFieldValue) { + maxFieldValue = value; + } + } catch (Exception e) { + + } + } + maxJsLevel = maxFieldValue; + return maxJsLevel; + } + +} diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/FileUtil.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/FileUtil.java index 3ef81b5e..0f578b0f 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/FileUtil.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/FileUtil.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.util; @@ -23,6 +20,8 @@ import java.io.InputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.logging.Level; import java.util.logging.Logger; import java.util.zip.ZipEntry; @@ -33,244 +32,164 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.sf.feeling.decompiler.JavaDecompilerPlugin; -public class FileUtil -{ +public class FileUtil { - public static void writeToFile( File file, String string ) - { - try - { - if ( !file.getParentFile( ).exists( ) ) - file.getParentFile( ).mkdirs( ); + public static void writeToFile(File file, String string) { + try { + if (!file.getParentFile().exists()) + file.getParentFile().mkdirs(); String encoding = null; - try - { - encoding = JavaDecompilerPlugin.getDefault( ).getExportEncoding( ); + try { + encoding = JavaDecompilerPlugin.getDefault().getExportEncoding(); + } catch (Exception e) { } - catch ( Exception e ) - { + if (encoding == null || encoding.trim().length() == 0) { + encoding = StandardCharsets.UTF_8.name(); } - if ( encoding == null || encoding.trim( ).length( ) == 0 ) - { - encoding = "UTF-8"; //$NON-NLS-1$ + try (PrintWriter out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), encoding))) { + out.print(string); } - PrintWriter out = new PrintWriter( new OutputStreamWriter( new FileOutputStream( file ), encoding ) ); - out.print( string ); - out.close( ); - } - catch ( IOException e ) - { - e.printStackTrace( ); + } catch (IOException e) { + e.printStackTrace(); } } - public static void writeToBinarayFile( File file, InputStream source, boolean close ) - { + public static void writeToBinarayFile(File file, InputStream source, boolean close) { BufferedInputStream bis = null; - BufferedOutputStream fouts = null; - try - { - bis = new BufferedInputStream( source ); - if ( !file.exists( ) ) - { - if ( !file.getParentFile( ).exists( ) ) - { - file.getParentFile( ).mkdirs( ); + try { + bis = new BufferedInputStream(source); + if (!file.exists()) { + if (!file.getParentFile().exists()) { + file.getParentFile().mkdirs(); } - file.createNewFile( ); - } - fouts = new BufferedOutputStream( new FileOutputStream( file ) ); - byte b[] = new byte[1024]; - int i = 0; - while ( ( i = bis.read( b ) ) != -1 ) - { - fouts.write( b, 0, i ); - } - fouts.flush( ); - fouts.close( ); - if ( close ) - bis.close( ); - } - catch ( IOException e ) - { - Logger.getLogger( FileUtil.class.getName( ) ).log( Level.WARNING, - "Write binaray file failed.", //$NON-NLS-1$ - e ); - try - { - if ( fouts != null ) - fouts.close( ); - } - catch ( IOException f ) - { - Logger.getLogger( FileUtil.class.getName( ) ).log( Level.WARNING, "Close output stream failed.", f ); //$NON-NLS-1$ + file.createNewFile(); } - if ( close ) - { - try - { - if ( bis != null ) - bis.close( ); + try (BufferedOutputStream fouts = new BufferedOutputStream(new FileOutputStream(file))) { + + byte b[] = new byte[IOUtils.DEFAULT_BUFFER_SIZE]; + int i = 0; + while ((i = bis.read(b)) != -1) { + fouts.write(b, 0, i); } - catch ( IOException f ) - { - Logger.getLogger( FileUtil.class.getName( ) ).log( Level.WARNING, - "Close input stream failed.", //$NON-NLS-1$ - f ); + fouts.flush(); + } + if (close) { + bis.close(); + } + } catch (IOException e) { + Logger.getLogger(FileUtil.class.getName()).log(Level.WARNING, "Write binaray file failed.", //$NON-NLS-1$ + e); + if (close) { + try { + if (bis != null) { + bis.close(); + } + } catch (IOException f) { + Logger.getLogger(FileUtil.class.getName()).log(Level.WARNING, "Close input stream failed.", //$NON-NLS-1$ + f); } } } } - public static boolean copyFile( String src, String des ) - { - FileInputStream fis = null; - try - { - fis = new FileInputStream( src ); - writeToBinarayFile( new File( des ), fis, false ); - fis.close( ); - } - catch ( Exception e ) - { - Logger.getLogger( FileUtil.class.getName( ) ).log( Level.WARNING, - "Copy file failed.", //$NON-NLS-1$ - e ); - try - { - fis.close( ); - return true; - } - catch ( IOException f ) - { - Logger.getLogger( FileUtil.class.getName( ) ).log( Level.WARNING, "Close input stream failed.", f ); //$NON-NLS-1$ - } - + public static boolean copyFile(String src, String des) { + try (FileInputStream fis = new FileInputStream(src)) { + writeToBinarayFile(new File(des), fis, false); + } catch (Exception e) { + Logger.getLogger(FileUtil.class.getName()).log(Level.WARNING, "Copy file failed.", //$NON-NLS-1$ + e); } return false; } - public static boolean copyDirectory( File srcDirectory, File desDirectory ) - { - if ( srcDirectory == null || desDirectory == null ) - { + public static boolean copyDirectory(File srcDirectory, File desDirectory) { + if (srcDirectory == null || desDirectory == null) { return false; } - return copyDirectory( srcDirectory.getAbsolutePath( ), desDirectory.getAbsolutePath( ), null ); + return copyDirectory(srcDirectory.getAbsolutePath(), desDirectory.getAbsolutePath(), null); } - public static boolean copyDirectory( String srcDirectory, String desDirectory ) - { - return copyDirectory( srcDirectory, desDirectory, null ); + public static boolean copyDirectory(String srcDirectory, String desDirectory) { + return copyDirectory(srcDirectory, desDirectory, null); } - public static boolean copyDirectory( String srcDirectory, String desDirectory, FileFilter filter ) - { - try - { - File des = new File( desDirectory ); - if ( !des.exists( ) ) - { - des.mkdirs( ); + public static boolean copyDirectory(String srcDirectory, String desDirectory, FileFilter filter) { + try { + File des = new File(desDirectory); + if (!des.exists()) { + des.mkdirs(); } - File src = new File( srcDirectory ); - File[] allFile = src.listFiles( ); + File src = new File(srcDirectory); + File[] allFile = src.listFiles(); int totalNum = allFile.length; String srcName = ""; //$NON-NLS-1$ String desName = ""; //$NON-NLS-1$ int currentFile = 0; - for ( currentFile = 0; currentFile < totalNum; currentFile++ ) - { - if ( !allFile[currentFile].isDirectory( ) ) - { - srcName = allFile[currentFile].toString( ); - desName = desDirectory + File.separator + allFile[currentFile].getName( ); - if ( filter == null || filter.accept( new File( srcName ) ) ) - copyFile( srcName, desName ); - } - else - { - if ( !copyDirectory( allFile[currentFile].getPath( ).toString( ), - desDirectory + File.separator + allFile[currentFile].getName( ).toString( ), - filter ) ) - { - Logger.getLogger( FileUtil.class.getName( ) ).log( Level.WARNING, - "Copy sub directory " //$NON-NLS-1$ - + srcDirectory - + "failed." ); //$NON-NLS-1$ + for (currentFile = 0; currentFile < totalNum; currentFile++) { + if (!allFile[currentFile].isDirectory()) { + srcName = allFile[currentFile].toString(); + desName = desDirectory + File.separator + allFile[currentFile].getName(); + if (filter == null || filter.accept(new File(srcName))) + copyFile(srcName, desName); + } else { + if (!copyDirectory(allFile[currentFile].getPath().toString(), + desDirectory + File.separator + allFile[currentFile].getName().toString(), filter)) { + Logger.getLogger(FileUtil.class.getName()).log(Level.WARNING, "Copy sub directory " //$NON-NLS-1$ + + srcDirectory + "failed."); //$NON-NLS-1$ } } } return true; - } - catch ( Exception e ) - { - Logger.getLogger( FileUtil.class.getName( ) ).log( Level.WARNING, - "Copy directory " + srcDirectory + "failed.", //$NON-NLS-1$ //$NON-NLS-2$ - e ); + } catch (Exception e) { + Logger.getLogger(FileUtil.class.getName()).log(Level.WARNING, "Copy directory " + srcDirectory + "failed.", //$NON-NLS-1$ //$NON-NLS-2$ + e); return false; } } - public static void copyDirectoryToDirectory( File srcDir, File destDir ) throws IOException - { - copyDirectoryToDirectory( srcDir, destDir, null ); + public static void copyDirectoryToDirectory(File srcDir, File destDir) throws IOException { + copyDirectoryToDirectory(srcDir, destDir, null); } - public static void copyDirectoryToDirectory( File srcDir, File destDir, FileFilter filter ) throws IOException - { - if ( srcDir == null ) - { - throw new NullPointerException( "Source must not be null" ); //$NON-NLS-1$ - } - if ( srcDir.exists( ) && srcDir.isDirectory( ) == false ) - { - throw new IllegalArgumentException( "Source '" //$NON-NLS-1$ - + destDir - + "' is not a directory" ); //$NON-NLS-1$ - } - if ( destDir == null ) - { - throw new NullPointerException( "Destination must not be null" ); //$NON-NLS-1$ - } - if ( destDir.exists( ) && destDir.isDirectory( ) == false ) - { - throw new IllegalArgumentException( "Destination '" //$NON-NLS-1$ - + destDir - + "' is not a directory" ); //$NON-NLS-1$ - } - copyDirectory( srcDir.getAbsolutePath( ), new File( destDir, srcDir.getName( ) ).getAbsolutePath( ), filter ); + public static void copyDirectoryToDirectory(File srcDir, File destDir, FileFilter filter) throws IOException { + if (srcDir == null) { + throw new NullPointerException("Source must not be null"); //$NON-NLS-1$ + } + if (srcDir.exists() && srcDir.isDirectory() == false) { + throw new IllegalArgumentException("Source '" //$NON-NLS-1$ + + destDir + "' is not a directory"); //$NON-NLS-1$ + } + if (destDir == null) { + throw new NullPointerException("Destination must not be null"); //$NON-NLS-1$ + } + if (destDir.exists() && destDir.isDirectory() == false) { + throw new IllegalArgumentException("Destination '" //$NON-NLS-1$ + + destDir + "' is not a directory"); //$NON-NLS-1$ + } + copyDirectory(srcDir.getAbsolutePath(), new File(destDir, srcDir.getName()).getAbsolutePath(), filter); } - public static long sizeOfDirectory( File directory ) - { - if ( !directory.exists( ) ) - { + public static long sizeOfDirectory(File directory) { + if (!directory.exists()) { String message = directory + " does not exist"; //$NON-NLS-1$ - throw new IllegalArgumentException( message ); + throw new IllegalArgumentException(message); } - if ( !directory.isDirectory( ) ) - { + if (!directory.isDirectory()) { String message = directory + " is not a directory"; //$NON-NLS-1$ - throw new IllegalArgumentException( message ); + throw new IllegalArgumentException(message); } long size = 0; - File[] files = directory.listFiles( ); - if ( files == null ) - { // null if security restricted + File[] files = directory.listFiles(); + if (files == null) { // null if security restricted return 0L; } - for ( int i = 0; i < files.length; i++ ) - { + for (int i = 0; i < files.length; i++) { File file = files[i]; - if ( file.isDirectory( ) ) - { - size += sizeOfDirectory( file ); - } - else - { - size += file.length( ); + if (file.isDirectory()) { + size += sizeOfDirectory(file); + } else { + size += file.length(); } } @@ -281,420 +200,274 @@ public static long sizeOfDirectory( File directory ) /** * Recursively delete a directory. * - * @param directory - * directory to delete - * @throws IOException - * in case deletion is unsuccessful + * @param directory directory to delete + * @throws IOException in case deletion is unsuccessful */ - public static void deleteDirectory( IProgressMonitor monitor, File directory, File base, int step ) - throws IOException - { - if ( !directory.exists( ) ) - { + public static void deleteDirectory(IProgressMonitor monitor, File directory, File base, int step) + throws IOException { + if (!directory.exists()) { return; } - cleanDirectory( monitor, directory, base, step ); - if ( !directory.delete( ) ) - { + cleanDirectory(monitor, directory, base, step); + if (!directory.delete()) { String message = "Unable to delete directory " + directory + "."; //$NON-NLS-1$ //$NON-NLS-2$ - throw new IOException( message ); + throw new IOException(message); } } - public static void deleteDirectory( IProgressMonitor monitor, File directory, int step ) throws IOException - { - deleteDirectory( monitor, directory, directory, step ); + public static void deleteDirectory(IProgressMonitor monitor, File directory, int step) throws IOException { + deleteDirectory(monitor, directory, directory, step); } - public static void cleanDirectory( IProgressMonitor monitor, File directory, File base, int step ) - throws IOException - { - if ( !directory.exists( ) ) - { + public static void cleanDirectory(IProgressMonitor monitor, File directory, File base, int step) + throws IOException { + if (!directory.exists()) { String message = directory + " does not exist"; //$NON-NLS-1$ - throw new IllegalArgumentException( message ); + throw new IllegalArgumentException(message); } - if ( !directory.isDirectory( ) ) - { + if (!directory.isDirectory()) { String message = directory + " is not a directory"; //$NON-NLS-1$ - throw new IllegalArgumentException( message ); + throw new IllegalArgumentException(message); } IOException exception = null; boolean isPackage = false; - File[] files = directory.listFiles( ); - for ( int i = 0; i < files.length; i++ ) - { + File[] files = directory.listFiles(); + for (int i = 0; i < files.length; i++) { File file = files[i]; - if ( !isPackage && file.isFile( ) ) - { + if (!isPackage && file.isFile()) { isPackage = true; } - try - { - forceDelete( monitor, file, base, step ); - } - catch ( IOException ioe ) - { + try { + forceDelete(monitor, file, base, step); + } catch (IOException ioe) { exception = ioe; } } - if ( isPackage ) - { - if ( monitor != null ) - { - monitor.worked( step ); + if (isPackage) { + if (monitor != null) { + monitor.worked(step); } } - if ( null != exception ) - { + if (null != exception) { throw exception; } } - public static void forceDelete( IProgressMonitor monitor, File file, File base, int step ) throws IOException - { - if ( file.isDirectory( ) ) - { - deleteDirectory( monitor, file, base, step ); - } - else - { - if ( monitor != null ) - { - String taskName = file.getAbsolutePath( ) - .substring( base.getAbsolutePath( ).length( ) - + new Long( System.currentTimeMillis( ) ).toString( ).length( ) - + 2 ); - monitor.subTask( taskName ); + public static void forceDelete(IProgressMonitor monitor, File file, File base, int step) throws IOException { + if (file.isDirectory()) { + deleteDirectory(monitor, file, base, step); + } else { + if (monitor != null) { + String taskName = file.getAbsolutePath().substring( + base.getAbsolutePath().length() + new Long(System.currentTimeMillis()).toString().length() + 2); + monitor.subTask(taskName); } - if ( !file.exists( ) ) - { - throw new FileNotFoundException( "File does not exist: " + file ); //$NON-NLS-1$ + if (!file.exists()) { + throw new FileNotFoundException("File does not exist: " + file); //$NON-NLS-1$ } - if ( !file.delete( ) ) - { + if (!file.delete()) { String message = "Unable to delete file: " + file; //$NON-NLS-1$ - throw new IOException( message ); + throw new IOException(message); } } } - public static void recursiveZip( IProgressMonitor monitor, ZipOutputStream zos, File file, final String path, - FileFilter filter, int step ) throws FileNotFoundException, IOException - { - if ( file.isDirectory( ) ) - { - File[] files = file.listFiles( filter ); - if ( files != null ) - { - for ( int i = 0; i < files.length; i++ ) - { - recursiveZip( monitor, - zos, - files[i], - ( path.length( ) > 0 ? ( path + "/" ) : path ) //$NON-NLS-1$ - + files[i].getName( ), - filter, - step ); + public static void recursiveZip(IProgressMonitor monitor, ZipOutputStream zos, File file, final String path, + FileFilter filter, int step) throws FileNotFoundException, IOException { + if (file.isDirectory()) { + File[] files = file.listFiles(filter); + if (files != null) { + for (int i = 0; i < files.length; i++) { + recursiveZip(monitor, zos, files[i], (path.length() > 0 ? (path + "/") : path) //$NON-NLS-1$ + + files[i].getName(), filter, step); } } - if ( monitor != null ) - { - monitor.worked( step ); + if (monitor != null) { + monitor.worked(step); } } - if ( file.isFile( ) ) - { - if ( monitor != null ) - { - monitor.subTask( path ); + if (file.isFile()) { + if (monitor != null) { + monitor.subTask(path); } - byte[] bt = new byte[512]; - ZipEntry ze = new ZipEntry( path ); - ze.setSize( file.length( ) ); - zos.putNextEntry( ze ); - BufferedInputStream fis = new BufferedInputStream( new FileInputStream( file ) ); - int i = 0; - while ( ( i = fis.read( bt ) ) != -1 ) - { - zos.write( bt, 0, i ); + byte[] bt = new byte[4096]; + ZipEntry ze = new ZipEntry(path); + ze.setSize(file.length()); + zos.putNextEntry(ze); + try (BufferedInputStream fis = new BufferedInputStream(new FileInputStream(file))) { + int i = 0; + while ((i = fis.read(bt)) != -1) { + zos.write(bt, 0, i); + } } - fis.close( ); } } - public static void zipFile( File file, String zipFile ) throws Exception - { - ZipOutputStream zos = new ZipOutputStream( new FileOutputStream( zipFile ) ); - ZipEntry ze = null; - byte[] buf = new byte[1024]; - int readLen = 0; - ze = new ZipEntry( file.getName( ) ); - ze.setSize( file.length( ) ); - ze.setTime( file.lastModified( ) ); - zos.putNextEntry( ze ); - InputStream is = new BufferedInputStream( new FileInputStream( file ) ); - while ( ( readLen = is.read( buf, 0, 1024 ) ) != -1 ) - { - zos.write( buf, 0, readLen ); - } - is.close( ); - zos.close( ); + public static void zipFile(File file, String zipFile) throws Exception { + try (ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFile))) { + ZipEntry ze = null; + byte[] buf = new byte[4096]; + int readLen = 0; + ze = new ZipEntry(file.getName()); + ze.setSize(file.length()); + ze.setTime(file.lastModified()); + zos.putNextEntry(ze); + try (InputStream is = new BufferedInputStream(new FileInputStream(file))) { + while ((readLen = is.read(buf)) != -1) { + zos.write(buf, 0, readLen); + } + } + } } - public static interface Filter - { + public static interface Filter { - public boolean accept( String fileName ); + public boolean accept(String fileName); } - public static void filterZipFile( String filePath, Filter filter ) throws Exception - { - if ( isZipFile( filePath ) && filter != null ) - { - File file = new File( filePath ); - ZipFile zipFile = new ZipFile( file ); - ZipInputStream zis = new ZipInputStream( new FileInputStream( file ) ); - ZipEntry entry = null; - InputStream input = null; - - File tmpFile = new File( file + ".tmp" ); //$NON-NLS-1$ - ZipOutputStream zos = new ZipOutputStream( new FileOutputStream( tmpFile ) ); - zos.setLevel( 1 ); - while ( ( entry = zis.getNextEntry( ) ) != null ) - { - if ( filter.accept( entry.getName( ) ) ) - { - input = zipFile.getInputStream( entry ); - ZipEntry ze = new ZipEntry( entry.getName( ) ); - ze.setSize( entry.getSize( ) ); - ze.setTime( entry.getTime( ) ); - zos.putNextEntry( ze ); - IOUtils.copy( zis, zos ); - input.close( ); + public static void filterZipFile(String filePath, Filter filter) throws Exception { + if (isZipFile(filePath) && filter != null) { + File file = new File(filePath); + File tmpFile; + try (ZipFile zipFile = new ZipFile(file)) { + try (ZipInputStream zis = new ZipInputStream(new FileInputStream(file))) { + ZipEntry entry = null; + InputStream input = null; + + tmpFile = new File(file + ".tmp"); //$NON-NLS-1$ + try (ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(tmpFile))) { + zos.setLevel(1); + while ((entry = zis.getNextEntry()) != null) { + if (filter.accept(entry.getName())) { + input = zipFile.getInputStream(entry); + ZipEntry ze = new ZipEntry(entry.getName()); + ze.setSize(entry.getSize()); + ze.setTime(entry.getTime()); + zos.putNextEntry(ze); + IOUtils.copy(zis, zos); + input.close(); + } + } + } } } - zis.close( ); - zos.close( ); - zipFile.close( ); - - file.delete( ); - tmpFile.renameTo( file ); + file.delete(); + tmpFile.renameTo(file); } } - public static void zipDir( File dir, String classPackage, String zipFile ) throws Exception - { + public static void zipDir(File dir, String classPackage, String zipFile) throws Exception { File[] files = null; - if ( new File( dir, classPackage ).exists( ) ) - { - files = new File( dir, classPackage ).listFiles( ); - } - else if ( dir.exists( ) ) - { - files = dir.listFiles( ); - } - if ( files != null ) - { - ZipOutputStream zos = new ZipOutputStream( new FileOutputStream( zipFile ) ); - ZipEntry ze = null; - byte[] buf = new byte[1024]; - int readLen = 0; - for ( int i = 0; i < files.length; i++ ) - { - File file = files[i]; - if ( file.isDirectory( ) ) - continue; - ze = new ZipEntry( ( classPackage.length( ) > 0 ? ( classPackage + "/" ) //$NON-NLS-1$ - : "" ) + file.getName( ) ); //$NON-NLS-1$ - ze.setSize( file.length( ) ); - ze.setTime( file.lastModified( ) ); - zos.putNextEntry( ze ); - InputStream is = new BufferedInputStream( new FileInputStream( file ) ); - while ( ( readLen = is.read( buf, 0, 1024 ) ) != -1 ) - { - zos.write( buf, 0, readLen ); + if (new File(dir, classPackage).exists()) { + files = new File(dir, classPackage).listFiles(); + } else if (dir.exists()) { + files = dir.listFiles(); + } + if (files != null) { + try (ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFile))) { + ZipEntry ze = null; + byte[] buf = new byte[4096]; + int readLen = 0; + for (int i = 0; i < files.length; i++) { + File file = files[i]; + if (file.isDirectory()) { + continue; + } + ze = new ZipEntry((classPackage.length() > 0 ? (classPackage + "/") //$NON-NLS-1$ + : "") + file.getName()); //$NON-NLS-1$ + ze.setSize(file.length()); + ze.setTime(file.lastModified()); + zos.putNextEntry(ze); + try (InputStream is = new BufferedInputStream(new FileInputStream(file))) { + while ((readLen = is.read(buf)) != -1) { + zos.write(buf, 0, readLen); + } + } } - is.close( ); } - zos.close( ); } } - public static boolean isZipFile( String path ) - { - if ( path == null ) + public static boolean isZipFile(String path) { + if (path == null) return false; - try - { - new ZipFile( path ).close( ); - return true; - } - catch ( IOException e ) - { + try { + try (ZipFile zipFile = new ZipFile(path)) { + return true; + } + } catch (IOException e) { return false; } } - public static String getContent( File file ) - { - if ( file == null || !file.exists( ) ) - return null; - try - { - ByteArrayOutputStream out = new ByteArrayOutputStream( 4096 ); - byte[] tmp = new byte[4096]; - InputStream is = new BufferedInputStream( new FileInputStream( file ) ); - while ( true ) - { - int r = is.read( tmp ); - if ( r == -1 ) - break; - out.write( tmp, 0, r ); - } - byte[] bytes = out.toByteArray( ); - is.close( ); - out.close( ); - String content = new String( bytes ); - return content.trim( ); - } - catch ( Exception e ) - { - e.printStackTrace( ); - } - return null; + public static String getContent(File file) { + return getContent(file, Charset.defaultCharset().name()); } - public static String getContent( File file, String enconding ) - { - if ( file == null || !file.exists( ) ) + public static String getContent(File file, String enconding) { + if (file == null || !file.exists()) { return null; - try - { - ByteArrayOutputStream out = new ByteArrayOutputStream( 4096 ); - byte[] tmp = new byte[4096]; - InputStream is = new BufferedInputStream( new FileInputStream( file ) ); - while ( true ) - { - int r = is.read( tmp ); - if ( r == -1 ) - break; - out.write( tmp, 0, r ); - } - byte[] bytes = out.toByteArray( ); - is.close( ); - out.close( ); - String content = new String( bytes, enconding ); - return content.trim( ); } - catch ( Exception e ) - { - e.printStackTrace( ); + long fileLenLong = file.length(); + if (fileLenLong > Integer.MAX_VALUE) { + throw new RuntimeException("File too large: " + file); } - return null; - } - - public static String getContent( InputStream is ) - { - if ( is == null ) - return null; - try - { - ByteArrayOutputStream out = new ByteArrayOutputStream( 4096 ); + int fileLen = (int) fileLenLong; + try (InputStream is = new BufferedInputStream(new FileInputStream(file)); + ByteArrayOutputStream out = new ByteArrayOutputStream(fileLen)) { byte[] tmp = new byte[4096]; - while ( true ) - { - int r = is.read( tmp ); - if ( r == -1 ) + while (true) { + int r = is.read(tmp); + if (r == -1) break; - out.write( tmp, 0, r ); + out.write(tmp, 0, r); } - byte[] bytes = out.toByteArray( ); - is.close( ); - out.close( ); - String content = new String( bytes ); - return content.trim( ); - } - catch ( Exception e ) - { - e.printStackTrace( ); + byte[] bytes = out.toByteArray(); + String content = new String(bytes, enconding); + return content.trim(); + } catch (Exception e) { + e.printStackTrace(); } return null; } - public static byte[] getBytes( File file ) - { - if ( file == null || !file.exists( ) ) - return null; - try - { - ByteArrayOutputStream out = new ByteArrayOutputStream( 4096 ); - byte[] tmp = new byte[4096]; - InputStream is = new BufferedInputStream( new FileInputStream( file ) ); - while ( true ) - { - int r = is.read( tmp ); - if ( r == -1 ) - break; - out.write( tmp, 0, r ); + public static void writeToFile(File file, String string, String encoding) { + try { + if (!file.getParentFile().exists()) { + file.getParentFile().mkdirs(); } - byte[] bytes = out.toByteArray( ); - is.close( ); - out.close( ); - return bytes; - } - catch ( Exception e ) - { - e.printStackTrace( ); - } - return null; - } - - public static void writeToFile( File file, String string, String encoding ) - { - try - { - if ( !file.getParentFile( ).exists( ) ) - file.getParentFile( ).mkdirs( ); - PrintWriter out = new PrintWriter( new OutputStreamWriter( new FileOutputStream( file ), encoding ) ); - out.print( string ); - out.close( ); - } - catch ( IOException e ) - { - e.printStackTrace( ); + try (PrintWriter out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), encoding))) { + out.print(string); + } + } catch (IOException e) { + e.printStackTrace(); } } - public static void deltree( File root ) - { - if ( root == null || !root.exists( ) ) - { + public static void deltree(File root) { + if (root == null || !root.exists()) { return; } - if ( root.isFile( ) ) - { - root.delete( ); + if (root.isFile()) { + root.delete(); return; } - File[] children = root.listFiles( ); - if ( children != null ) - { - for ( int i = 0; i < children.length; i++ ) - { - deltree( children[i] ); + File[] children = root.listFiles(); + if (children != null) { + for (int i = 0; i < children.length; i++) { + deltree(children[i]); } } - root.delete( ); + root.delete(); } } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/HashUtils.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/HashUtils.java index dab58b14..88ae6c97 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/HashUtils.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/HashUtils.java @@ -1,139 +1,77 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.util; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; - -import org.apache.commons.codec.binary.Hex; -import org.apache.commons.codec.digest.DigestUtils; - -public class HashUtils -{ - - public static byte[] md5Digest( File file ) - { - String md5 = md5Hash( file ); - if ( md5 != null ) - { - return md5.getBytes( ); - } - return null; - } - - public static String md5Hash( File file ) - { - - if ( file != null ) - { - InputStream fis = null; - try - { - fis = new FileInputStream( file ); - String result = new String( Hex.encodeHex( DigestUtils.md5( fis ) ) ); - return result; - } - catch ( IOException e ) - { - Logger.debug( e ); - } - finally - { - if ( fis != null ) - { - try - { - fis.close( ); - } - catch ( IOException e ) - { - Logger.debug( e ); - } - } - } - } - return null; - } - - public static String sha1Hash( File file ) - { - - if ( file != null ) - { - InputStream fis = null; - try - { - fis = new FileInputStream( file ); - String result = new String( Hex.encodeHex( DigestUtils.sha( fis ) ) ); - return result; - } - catch ( IOException e ) - { - Logger.debug( e ); - } - finally - { - if ( fis != null ) - { - try - { - fis.close( ); - } - catch ( IOException e ) - { - Logger.debug( e ); - } - } - } - } - return null; - } - - public static String sha1Hash( String string ) - { - if ( string == null ) - return null; - byte[] content = string.getBytes( ); - if ( content != null ) - { - String result = new String( Hex.encodeHex( DigestUtils.sha( content ) ) ); - return result; - } - return null; - } - - public static String md5Hash( String string ) - { - if ( string == null ) - return null; - byte[] content = string.getBytes( ); - if ( content != null ) - { - String result = new String( Hex.encodeHex( DigestUtils.md5( content ) ) ); - return result; - } - return null; - } - - public static byte[] sha1Digest( File file ) - { - String md5 = sha1Hash( file ); - if ( md5 != null ) - { - return md5.getBytes( ); - } - return null; - } - -} +/******************************************************************************* + * Copyright (c) 2017 Chen Chao and other ECD project contributors. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.sf.feeling.decompiler.util; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.math.BigInteger; +import java.nio.charset.StandardCharsets; +import java.security.DigestInputStream; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +public class HashUtils { + + public static String md5Hash(File file) { + if (file != null) { + try (InputStream fis = new FileInputStream(file)) { + return hexDigestOfStream(fis, MessageDigest.getInstance("MD5")); + } catch (IOException | NoSuchAlgorithmException e) { + throw new RuntimeException(e); + } + } + return null; + } + + public static String sha1Hash(File file) { + if (file != null) { + try (InputStream fis = new FileInputStream(file)) { + return hexDigestOfStream(fis, MessageDigest.getInstance("SHA-1")); + } catch (IOException | NoSuchAlgorithmException e) { + throw new RuntimeException(e); + } + } + return null; + } + + public static String md5Hash(String string) { + if (string == null) { + return null; + } + byte[] content = string.getBytes(StandardCharsets.UTF_8); + if (content != null) { + try { + return hexDigestOfStream(new ByteArrayInputStream(content), MessageDigest.getInstance("MD5")); + } catch (NoSuchAlgorithmException | IOException e) { + throw new RuntimeException(e); + } + } + return null; + } + + public static byte[] sha1Digest(File file) { + String md5 = sha1Hash(file); + if (md5 != null) { + return md5.getBytes(); + } + return null; + } + + private static String hexDigestOfStream(InputStream in, MessageDigest digest) throws IOException { + DigestInputStream din = new DigestInputStream(in, digest); + byte[] buffer = new byte[4096 * 8]; + while (din.read(buffer) >= 0) { + + } + return new BigInteger(1, digest.digest()).toString(16); + } + +} diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/HelpUtils.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/HelpUtils.java index e9334884..d2cb524d 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/HelpUtils.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/HelpUtils.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.util; @@ -15,6 +12,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; +import java.nio.charset.StandardCharsets; import org.eclipse.core.runtime.Platform; import org.eclipse.help.internal.base.BaseHelpSystem; @@ -32,252 +30,183 @@ import com.drgarbage.bytecode.ByteCodeConstants; -public class HelpUtils -{ +public class HelpUtils { private static String styleSheet; private static final String DOC_BASE = "/" //$NON-NLS-1$ - + JavaDecompilerPlugin.getDefault( ).getBundle( ).getSymbolicName( ) - + "/doc/"; //$NON-NLS-1$ - private static RGB bg_color_rgb = new RGB( 255, 255, 255 ); - private static RGB fg_color_rgb = new RGB( 0, 0, 0 ); + + JavaDecompilerPlugin.getDefault().getBundle().getSymbolicName() + "/doc/"; //$NON-NLS-1$ + private static RGB bg_color_rgb = new RGB(255, 255, 255); + private static RGB fg_color_rgb = new RGB(0, 0, 0); - static - { - Display.getDefault( ).asyncExec( new Runnable( ) { + static { + Display.getDefault().asyncExec(new Runnable() { @Override - public void run( ) - { - bg_color_rgb = Display.getDefault( ).getSystemColor( SWT.COLOR_INFO_BACKGROUND ).getRGB( ); - fg_color_rgb = Display.getDefault( ).getSystemColor( SWT.COLOR_INFO_FOREGROUND ).getRGB( ); + public void run() { + bg_color_rgb = Display.getDefault().getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB(); + fg_color_rgb = Display.getDefault().getSystemColor(SWT.COLOR_INFO_FOREGROUND).getRGB(); } - } ); + }); } - private static String checkOpcodeName( String opcodeName ) - { - opcodeName = opcodeName.toLowerCase( ); + private static String checkOpcodeName(String opcodeName) { + opcodeName = opcodeName.toLowerCase(); /* - * we need an additional check for DCONST_1...5, FCONST_1...5 etc case - * to convert it to DCONST_D etc + * we need an additional check for DCONST_1...5, FCONST_1...5 etc case to + * convert it to DCONST_D etc */ - int sepIndex = opcodeName.indexOf( '_' ); - if ( sepIndex > 0 && Character.isDigit( opcodeName.charAt( sepIndex + 1 ) ) ) - { - opcodeName = opcodeName.substring( 0, sepIndex ); - switch ( opcodeName.charAt( 0 ) ) - { - case 'd' : - opcodeName += "_d"; //$NON-NLS-1$ - break; - case 'f' : - opcodeName += "_f"; //$NON-NLS-1$ - break; - case 'l' : - opcodeName += "_l"; //$NON-NLS-1$ - break; - default : - // ICONST uses "n" - opcodeName += "_n"; //$NON-NLS-1$ - break; + int sepIndex = opcodeName.indexOf('_'); + if (sepIndex > 0 && Character.isDigit(opcodeName.charAt(sepIndex + 1))) { + opcodeName = opcodeName.substring(0, sepIndex); + switch (opcodeName.charAt(0)) { + case 'd': + opcodeName += "_d"; //$NON-NLS-1$ + break; + case 'f': + opcodeName += "_f"; //$NON-NLS-1$ + break; + case 'l': + opcodeName += "_l"; //$NON-NLS-1$ + break; + default: + // ICONST uses "n" + opcodeName += "_n"; //$NON-NLS-1$ + break; } } return opcodeName; } - public static URL getHelpResource( int opcode ) - { - if ( opcode < 0 || opcode >= ByteCodeConstants.OPCODE_MNEMONICS.length ) - { + public static URL getHelpResource(int opcode) { + if (opcode < 0 || opcode >= ByteCodeConstants.OPCODE_MNEMONICS.length) { return null; } String opcodeName = ByteCodeConstants.OPCODE_MNEMONICS[opcode]; - if ( opcodeName != null ) - { - opcodeName = checkOpcodeName( opcodeName ); + if (opcodeName != null) { + opcodeName = checkOpcodeName(opcodeName); } - if ( opcodeName == null ) - { + if (opcodeName == null) { return null; } - return getHelpResource( opcodeName ); + return getHelpResource(opcodeName); } - private static URL getHelpResource( String name ) - { + private static URL getHelpResource(String name) { String href = DOC_BASE + "ref-" + name + ".html"; //$NON-NLS-1$ //$NON-NLS-2$ - return resolveToHelpUrl( href ); + return resolveToHelpUrl(href); } - public static URL getHelpIndex( ) - { + public static URL getHelpIndex() { String href = DOC_BASE + "opcodes.html"; //$NON-NLS-1$ - return resolveToHelpUrl( href ); + return resolveToHelpUrl(href); } - private static String getDocBase( ) - { - URL base = resolveToHelpUrl( DOC_BASE ); - if ( base != null ) - { - return base.toString( ); + private static String getDocBase() { + URL base = resolveToHelpUrl(DOC_BASE); + if (base != null) { + return base.toString(); } return null; } - private static URL resolveToHelpUrl( String path ) - { - try - { - return BaseHelpSystem.resolve( path, true ); - } - catch ( Exception e ) - { + private static URL resolveToHelpUrl(String path) { + try { + return BaseHelpSystem.resolve(path, true); + } catch (Exception e) { return null; } } - private static void appendColor( StringBuilder buffer, RGB rgb ) - { - buffer.append( '#' ); - appendAsHexString( buffer, rgb.red ); - appendAsHexString( buffer, rgb.green ); - appendAsHexString( buffer, rgb.blue ); + private static void appendColor(StringBuilder buffer, RGB rgb) { + buffer.append('#'); + appendAsHexString(buffer, rgb.red); + appendAsHexString(buffer, rgb.green); + appendAsHexString(buffer, rgb.blue); } - private static void appendAsHexString( StringBuilder buffer, int intValue ) - { - String hexValue = Integer.toHexString( intValue ); - if ( hexValue.length( ) == 1 ) - { - buffer.append( '0' ); + private static void appendAsHexString(StringBuilder buffer, int intValue) { + String hexValue = Integer.toHexString(intValue); + if (hexValue.length() == 1) { + buffer.append('0'); } - buffer.append( hexValue ); + buffer.append(hexValue); } /** - * From {@link JavadocHover} class: returns the Javadoc hover style sheet - * with the current Javadoc font from the preferences. + * From {@link JavadocHover} class: returns the Javadoc hover style sheet with + * the current Javadoc font from the preferences. * * @return the updated style sheet */ - public static String getHelpStyleSheet( ) - { - if ( styleSheet == null ) - { - styleSheet = loadStyleSheet( ); + public static String getHelpStyleSheet() { + if (styleSheet == null) { + styleSheet = loadStyleSheet(); } String css = styleSheet; - if ( css == null || css.isEmpty( ) ) - { + if (css == null || css.isEmpty()) { return ""; //$NON-NLS-1$ } - FontData fontData = JFaceResources.getFontRegistry( ) - .getFontData( PreferenceConstants.APPEARANCE_JAVADOC_FONT )[0]; - css = HTMLPrinter.convertTopLevelFont( css, fontData ); - StringBuilder sb = new StringBuilder( css ); - sb.append( "\nbody { background-color:" ); //$NON-NLS-1$ - appendColor( sb, bg_color_rgb ); - sb.append( "; color:" ); //$NON-NLS-1$ - appendColor( sb, fg_color_rgb ); - sb.append( "; }\n" ); //$NON-NLS-1$ - return sb.toString( ); + FontData fontData = JFaceResources.getFontRegistry() + .getFontData(PreferenceConstants.APPEARANCE_JAVADOC_FONT)[0]; + css = HTMLPrinter.convertTopLevelFont(css, fontData); + StringBuilder sb = new StringBuilder(css); + sb.append("\nbody { background-color:"); //$NON-NLS-1$ + appendColor(sb, bg_color_rgb); + sb.append("; color:"); //$NON-NLS-1$ + appendColor(sb, fg_color_rgb); + sb.append("; }\n"); //$NON-NLS-1$ + return sb.toString(); } /** - * From {@link JavadocHover} class: loads and returns the Javadoc hover - * style sheet. + * From {@link JavadocHover} class: loads and returns the Javadoc hover style + * sheet. * * @return the style sheet, or empty string if unable to load */ - private static String loadStyleSheet( ) - { - Bundle bundle = Platform.getBundle( JavaPlugin.getPluginId( ) ); - URL styleSheetURL = bundle.getEntry( "/JavadocHoverStyleSheet.css" ); //$NON-NLS-1$ - if ( styleSheetURL == null ) - { + private static String loadStyleSheet() { + Bundle bundle = Platform.getBundle(JavaPlugin.getPluginId()); + URL styleSheetURL = bundle.getEntry("/JavadocHoverStyleSheet.css"); //$NON-NLS-1$ + if (styleSheetURL == null) { return ""; //$NON-NLS-1$ } - BufferedReader reader = null; - try - { - reader = new BufferedReader( new InputStreamReader( styleSheetURL.openStream( ), "UTF-8" ) ); //$NON-NLS-1$ - StringBuilder sb = new StringBuilder( 1500 ); + try (BufferedReader reader = new BufferedReader( + new InputStreamReader(styleSheetURL.openStream(), StandardCharsets.UTF_8))) { + StringBuilder sb = new StringBuilder(1500); String line; - while ( ( line = reader.readLine( ) ) != null ) - { - sb.append( line ); - sb.append( '\n' ); + while ((line = reader.readLine()) != null) { + sb.append(line); + sb.append('\n'); } - return sb.toString( ); - } - catch ( IOException ex ) - { + return sb.toString(); + } catch (IOException ex) { return ""; //$NON-NLS-1$ } - finally - { - try - { - if ( reader != null ) - { - reader.close( ); - } - } - catch ( IOException e ) - { - Logger.debug( e ); - } - } } - public static StringBuilder getOpcodeHelpFor( int opcode ) - { - URL helpResource = getHelpResource( opcode ); - StringBuilder sb = new StringBuilder( ); - if ( helpResource == null ) - { + public static StringBuilder getOpcodeHelpFor(int opcode) { + URL helpResource = getHelpResource(opcode); + StringBuilder sb = new StringBuilder(); + if (helpResource == null) { return sb; } - BufferedReader in = null; - try - { - in = new BufferedReader( new InputStreamReader( helpResource.openStream( ), "UTF-8" ) ); //$NON-NLS-1$ + try (BufferedReader in = new BufferedReader( + new InputStreamReader(helpResource.openStream(), StandardCharsets.UTF_8))) { String line; - while ( ( line = in.readLine( ) ) != null ) - { - sb.append( line ); + while ((line = in.readLine()) != null) { + sb.append(line); } - } - catch ( IOException e ) - { + } catch (IOException e) { return sb; } - finally - { - if ( in != null ) - { - try - { - in.close( ); - } - catch ( IOException e ) - { - Logger.debug( e ); - } - } - } - int styleEnd = sb.indexOf( "" ); //$NON-NLS-1$ - if ( styleEnd > 0 ) - { - sb.insert( styleEnd, getHelpStyleSheet( ) ); + int styleEnd = sb.indexOf(""); //$NON-NLS-1$ + if (styleEnd > 0) { + sb.insert(styleEnd, getHelpStyleSheet()); } - int endHeadIdx = sb.indexOf( "" ); //$NON-NLS-1$ - String base = getDocBase( ); - if ( base != null ) - { - sb.insert( endHeadIdx, "\n\n" ); //$NON-NLS-1$ //$NON-NLS-2$ + int endHeadIdx = sb.indexOf(""); //$NON-NLS-1$ + String base = getDocBase(); + if (base != null) { + sb.insert(endHeadIdx, "\n\n"); //$NON-NLS-1$ //$NON-NLS-2$ } return sb; } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/IOUtils.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/IOUtils.java index afd3fbb8..8ceea112 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/IOUtils.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/IOUtils.java @@ -1,13 +1,19 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ + * https://www.apache.org/licenses/LICENSE-2.0.html + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.sf.feeling.decompiler.util; @@ -24,14 +30,9 @@ import java.io.OutputStream; import java.io.Reader; import java.io.Writer; -import java.net.HttpURLConnection; -import java.net.ServerSocket; -import java.net.Socket; import java.net.URL; -import java.net.URLConnection; import java.nio.ByteBuffer; import java.nio.channels.ReadableByteChannel; -import java.nio.channels.Selector; import java.nio.charset.Charset; /** @@ -84,8 +85,7 @@ * Origin of code: Excalibur. * */ -public class IOUtils -{ +public class IOUtils { // NOTE: This class is focused on InputStream, OutputStream, Reader and // Writer. Each method should take at least one of these as a parameter, // or return one of them. @@ -123,7 +123,7 @@ public class IOUtils * {@link #copyLarge(InputStream, OutputStream)} and * {@link #copyLarge(Reader, Writer)} */ - private static final int DEFAULT_BUFFER_SIZE = 1024 * 4; + public static final int DEFAULT_BUFFER_SIZE = 1024 * 16; /** * The default buffer size to use for the skip() methods. @@ -135,11 +135,11 @@ public class IOUtils * These buffers are static and are shared between threads. This is possible * because the buffers are write-only - the contents are never read. * - * N.B. there is no need to synchronize when creating these because: - we - * don't care if the buffer is created multiple times (the data is ignored) - * - we always use the same size buffer, so if it it is recreated it will - * still be OK (if the buffer size were variable, we would need to synch. to - * ensure some other thread did not create a smaller one) + * N.B. there is no need to synchronize when creating these because: - we don't + * care if the buffer is created multiple times (the data is ignored) - we + * always use the same size buffer, so if it it is recreated it will still be OK + * (if the buffer size were variable, we would need to synch. to ensure some + * other thread did not create a smaller one) */ private static char[] SKIP_CHAR_BUFFER; private static byte[] SKIP_BYTE_BUFFER; @@ -147,190 +147,8 @@ public class IOUtils /** * Instances should NOT be constructed in standard programming. */ - public IOUtils( ) - { - super( ); - } - - // ----------------------------------------------------------------------- - - /** - * Closes a URLConnection. - * - * @param conn - * the connection to close. - * @since 2.4 - */ - public static void close( final URLConnection conn ) - { - if ( conn instanceof HttpURLConnection ) - { - ( (HttpURLConnection) conn ).disconnect( ); - } - } - - /** - * Closes an Reader unconditionally. - *

      - * Equivalent to {@link Reader#close()}, except any exceptions will be - * ignored. This is typically used in finally blocks. - *

      - * Example code: - * - *

      -	 * char[] data = new char[1024];
      -	 * Reader in = null;
      -	 * try
      -	 * {
      -	 * 	in = new FileReader( "foo.txt" );
      -	 * 	in.read( data );
      -	 * 	in.close( ); // close errors are handled
      -	 * }
      -	 * catch ( Exception e )
      -	 * {
      -	 * 	// error handling
      -	 * }
      -	 * finally
      -	 * {
      -	 * 	IOUtils.closeQuietly( in );
      -	 * }
      -	 * 
      - * - * @param input - * the Reader to close, may be null or already closed - * - * @deprecated As of 2.6 removed without replacement. Please use the - * try-with-resources statement or handle suppressed exceptions - * manually. - * @see Throwable#addSuppressed(java.lang.Throwable) - */ - @Deprecated - public static void closeQuietly( final Reader input ) - { - closeQuietly( (Closeable) input ); - } - - /** - * Closes an Writer unconditionally. - *

      - * Equivalent to {@link Writer#close()}, except any exceptions will be - * ignored. This is typically used in finally blocks. - *

      - * Example code: - * - *

      -	 * Writer out = null;
      -	 * try
      -	 * {
      -	 * 	out = new StringWriter( );
      -	 * 	out.write( "Hello World" );
      -	 * 	out.close( ); // close errors are handled
      -	 * }
      -	 * catch ( Exception e )
      -	 * {
      -	 * 	// error handling
      -	 * }
      -	 * finally
      -	 * {
      -	 * 	IOUtils.closeQuietly( out );
      -	 * }
      -	 * 
      - * - * @param output - * the Writer to close, may be null or already closed - * - * @deprecated As of 2.6 removed without replacement. Please use the - * try-with-resources statement or handle suppressed exceptions - * manually. - * @see Throwable#addSuppressed(java.lang.Throwable) - */ - @Deprecated - public static void closeQuietly( final Writer output ) - { - closeQuietly( (Closeable) output ); - } - - /** - * Closes an InputStream unconditionally. - *

      - * Equivalent to {@link InputStream#close()}, except any exceptions will be - * ignored. This is typically used in finally blocks. - *

      - * Example code: - * - *

      -	 * byte[] data = new byte[1024];
      -	 * InputStream in = null;
      -	 * try
      -	 * {
      -	 * 	in = new FileInputStream( "foo.txt" );
      -	 * 	in.read( data );
      -	 * 	in.close( ); // close errors are handled
      -	 * }
      -	 * catch ( Exception e )
      -	 * {
      -	 * 	// error handling
      -	 * }
      -	 * finally
      -	 * {
      -	 * 	IOUtils.closeQuietly( in );
      -	 * }
      -	 * 
      - * - * @param input - * the InputStream to close, may be null or already closed - * - * @deprecated As of 2.6 removed without replacement. Please use the - * try-with-resources statement or handle suppressed exceptions - * manually. - * @see Throwable#addSuppressed(java.lang.Throwable) - */ - @Deprecated - public static void closeQuietly( final InputStream input ) - { - closeQuietly( (Closeable) input ); - } - - /** - * Closes an OutputStream unconditionally. - *

      - * Equivalent to {@link OutputStream#close()}, except any exceptions will be - * ignored. This is typically used in finally blocks. - *

      - * Example code: - * - *

      -	 * byte[] data = "Hello, World".getBytes( );
      -	 *
      -	 * OutputStream out = null;
      -	 * try
      -	 * {
      -	 * 	out = new FileOutputStream( "foo.txt" );
      -	 * 	out.write( data );
      -	 * 	out.close( ); // close errors are handled
      -	 * }
      -	 * catch ( IOException e )
      -	 * {
      -	 * 	// error handling
      -	 * }
      -	 * finally
      -	 * {
      -	 * 	IOUtils.closeQuietly( out );
      -	 * }
      -	 * 
      - * - * @param output - * the OutputStream to close, may be null or already closed - * - * @deprecated As of 2.6 removed without replacement. Please use the - * try-with-resources statement or handle suppressed exceptions - * manually. - * @see Throwable#addSuppressed(java.lang.Throwable) - */ - @Deprecated - public static void closeQuietly( final OutputStream output ) - { - closeQuietly( (Closeable) output ); + public IOUtils() { + super(); } /** @@ -344,19 +162,14 @@ public static void closeQuietly( final OutputStream output ) * *
       	 * Closeable closeable = null;
      -	 * try
      -	 * {
      -	 * 	closeable = new FileReader( "foo.txt" );
      +	 * try {
      +	 * 	closeable = new FileReader("foo.txt");
       	 * 	// process closeable
      -	 * 	closeable.close( );
      -	 * }
      -	 * catch ( Exception e )
      -	 * {
      +	 * 	closeable.close();
      +	 * } catch (Exception e) {
       	 * 	// error handling
      -	 * }
      -	 * finally
      -	 * {
      -	 * 	IOUtils.closeQuietly( closeable );
      +	 * } finally {
      +	 * 	IOUtils.closeQuietly(closeable);
       	 * }
       	 * 
      *

      @@ -364,38 +177,24 @@ public static void closeQuietly( final OutputStream output ) *

      * *
      -	 * try
      -	 * {
      -	 * 	return IOUtils.copy( inputStream, outputStream );
      -	 * }
      -	 * finally
      -	 * {
      -	 * 	IOUtils.closeQuietly( inputStream );
      -	 * 	IOUtils.closeQuietly( outputStream );
      +	 * try {
      +	 * 	return IOUtils.copy(inputStream, outputStream);
      +	 * } finally {
      +	 * 	IOUtils.closeQuietly(inputStream);
      +	 * 	IOUtils.closeQuietly(outputStream);
       	 * }
       	 * 
      * - * @param closeable - * the objects to close, may be null or already closed - * @since 2.0 + * @param closeable the objects to close, may be null or already closed * - * @deprecated As of 2.6 removed without replacement. Please use the - * try-with-resources statement or handle suppressed exceptions - * manually. * @see Throwable#addSuppressed(java.lang.Throwable) */ - @Deprecated - public static void closeQuietly( final Closeable closeable ) - { - try - { - if ( closeable != null ) - { - closeable.close( ); + public static void closeQuietly(final Closeable closeable) { + try { + if (closeable != null) { + closeable.close(); } - } - catch ( final IOException ioe ) - { + } catch (final IOException ioe) { // ignore } } @@ -407,10 +206,10 @@ public static void closeQuietly( final Closeable closeable ) * ignored. *

      * This is typically used in finally blocks to ensure that the closeable is - * closed even if an Exception was thrown before the normal close statement - * was reached.
      - * It should not be used to replace the close statement(s) which should - * be present for the non-exceptional case.
      + * closed even if an Exception was thrown before the normal close statement was + * reached.
      + * It should not be used to replace the close statement(s) which should be + * present for the non-exceptional case.
      * It is only intended to simplify tidying up where normal processing has * already failed and reporting close failure as well is not necessary or * useful. @@ -434,464 +233,240 @@ public static void closeQuietly( final Closeable closeable ) * Closing all streams:
      * *

      -	 * try
      -	 * {
      -	 * 	return IOUtils.copy( inputStream, outputStream );
      -	 * }
      -	 * finally
      -	 * {
      -	 * 	IOUtils.closeQuietly( inputStream, outputStream );
      +	 * try {
      +	 * 	return IOUtils.copy(inputStream, outputStream);
      +	 * } finally {
      +	 * 	IOUtils.closeQuietly(inputStream, outputStream);
       	 * }
       	 * 
      * - * @param closeables - * the objects to close, may be null or already closed + * @param closeables the objects to close, may be null or already closed * @see #closeQuietly(Closeable) - * @since 2.5 * - * @deprecated As of 2.6 removed without replacement. Please use the - * try-with-resources statement or handle suppressed exceptions - * manually. * @see Throwable#addSuppressed(java.lang.Throwable) */ - @Deprecated - public static void closeQuietly( final Closeable... closeables ) - { - if ( closeables == null ) - { + public static void closeQuietly(final Closeable... closeables) { + if (closeables == null) { return; } - for ( final Closeable closeable : closeables ) - { - closeQuietly( closeable ); - } - } - - /** - * Closes a Socket unconditionally. - *

      - * Equivalent to {@link Socket#close()}, except any exceptions will be - * ignored. This is typically used in finally blocks. - *

      - * Example code: - * - *

      -	 * Socket socket = null;
      -	 * try
      -	 * {
      -	 * 	socket = new Socket( "http://www.foo.com/", 80 );
      -	 * 	// process socket
      -	 * 	socket.close( );
      -	 * }
      -	 * catch ( Exception e )
      -	 * {
      -	 * 	// error handling
      -	 * }
      -	 * finally
      -	 * {
      -	 * 	IOUtils.closeQuietly( socket );
      -	 * }
      -	 * 
      - * - * @param sock - * the Socket to close, may be null or already closed - * @since 2.0 - * - * @deprecated As of 2.6 removed without replacement. Please use the - * try-with-resources statement or handle suppressed exceptions - * manually. - * @see Throwable#addSuppressed(java.lang.Throwable) - */ - @Deprecated - public static void closeQuietly( final Socket sock ) - { - if ( sock != null ) - { - try - { - sock.close( ); - } - catch ( final IOException ioe ) - { - // ignored - } - } - } - - /** - * Closes a Selector unconditionally. - *

      - * Equivalent to {@link Selector#close()}, except any exceptions will be - * ignored. This is typically used in finally blocks. - *

      - * Example code: - * - *

      -	 * Selector selector = null;
      -	 * try
      -	 * {
      -	 * 	selector = Selector.open( );
      -	 * 	// process socket
      -	 *
      -	 * }
      -	 * catch ( Exception e )
      -	 * {
      -	 * 	// error handling
      -	 * }
      -	 * finally
      -	 * {
      -	 * 	IOUtils.closeQuietly( selector );
      -	 * }
      -	 * 
      - * - * @param selector - * the Selector to close, may be null or already closed - * @since 2.2 - * - * @deprecated As of 2.6 removed without replacement. Please use the - * try-with-resources statement or handle suppressed exceptions - * manually. - * @see Throwable#addSuppressed(java.lang.Throwable) - */ - @Deprecated - public static void closeQuietly( final Selector selector ) - { - if ( selector != null ) - { - try - { - selector.close( ); - } - catch ( final IOException ioe ) - { - // ignored - } - } - } - - /** - * Closes a ServerSocket unconditionally. - *

      - * Equivalent to {@link ServerSocket#close()}, except any exceptions will be - * ignored. This is typically used in finally blocks. - *

      - * Example code: - * - *

      -	 * ServerSocket socket = null;
      -	 * try
      -	 * {
      -	 * 	socket = new ServerSocket( );
      -	 * 	// process socket
      -	 * 	socket.close( );
      -	 * }
      -	 * catch ( Exception e )
      -	 * {
      -	 * 	// error handling
      -	 * }
      -	 * finally
      -	 * {
      -	 * 	IOUtils.closeQuietly( socket );
      -	 * }
      -	 * 
      - * - * @param sock - * the ServerSocket to close, may be null or already closed - * @since 2.2 - * - * @deprecated As of 2.6 removed without replacement. Please use the - * try-with-resources statement or handle suppressed exceptions - * manually. - * @see Throwable#addSuppressed(java.lang.Throwable) - */ - @Deprecated - public static void closeQuietly( final ServerSocket sock ) - { - if ( sock != null ) - { - try - { - sock.close( ); - } - catch ( final IOException ioe ) - { - // ignored - } + for (final Closeable closeable : closeables) { + closeQuietly(closeable); } } /** - * Returns the given reader if it is a {@link BufferedReader}, otherwise - * creates a BufferedReader from the given reader. + * Returns the given reader if it is a {@link BufferedReader}, otherwise creates + * a BufferedReader from the given reader. * - * @param reader - * the reader to wrap or return (not null) - * @return the given reader or a new {@link BufferedReader} for the given - * reader - * @throws NullPointerException - * if the input parameter is null + * @param reader the reader to wrap or return (not null) + * @return the given reader or a new {@link BufferedReader} for the given reader + * @throws NullPointerException if the input parameter is null * @see #buffer(Reader) * @since 2.2 */ - public static BufferedReader toBufferedReader( final Reader reader ) - { - return reader instanceof BufferedReader ? (BufferedReader) reader : new BufferedReader( reader ); + public static BufferedReader toBufferedReader(final Reader reader) { + return reader instanceof BufferedReader ? (BufferedReader) reader : new BufferedReader(reader); } /** - * Returns the given reader if it is a {@link BufferedReader}, otherwise - * creates a BufferedReader from the given reader. + * Returns the given reader if it is a {@link BufferedReader}, otherwise creates + * a BufferedReader from the given reader. * - * @param reader - * the reader to wrap or return (not null) - * @param size - * the buffer size, if a new BufferedReader is created. - * @return the given reader or a new {@link BufferedReader} for the given - * reader - * @throws NullPointerException - * if the input parameter is null + * @param reader the reader to wrap or return (not null) + * @param size the buffer size, if a new BufferedReader is created. + * @return the given reader or a new {@link BufferedReader} for the given reader + * @throws NullPointerException if the input parameter is null * @see #buffer(Reader) * @since 2.5 */ - public static BufferedReader toBufferedReader( final Reader reader, int size ) - { - return reader instanceof BufferedReader ? (BufferedReader) reader : new BufferedReader( reader, size ); + public static BufferedReader toBufferedReader(final Reader reader, int size) { + return reader instanceof BufferedReader ? (BufferedReader) reader : new BufferedReader(reader, size); } /** - * Returns the given reader if it is already a {@link BufferedReader}, - * otherwise creates a BufferedReader from the given reader. + * Returns the given reader if it is already a {@link BufferedReader}, otherwise + * creates a BufferedReader from the given reader. * - * @param reader - * the reader to wrap or return (not null) - * @return the given reader or a new {@link BufferedReader} for the given - * reader - * @throws NullPointerException - * if the input parameter is null + * @param reader the reader to wrap or return (not null) + * @return the given reader or a new {@link BufferedReader} for the given reader + * @throws NullPointerException if the input parameter is null * @since 2.5 */ - public static BufferedReader buffer( final Reader reader ) - { - return reader instanceof BufferedReader ? (BufferedReader) reader : new BufferedReader( reader ); + public static BufferedReader buffer(final Reader reader) { + return reader instanceof BufferedReader ? (BufferedReader) reader : new BufferedReader(reader); } /** - * Returns the given reader if it is already a {@link BufferedReader}, - * otherwise creates a BufferedReader from the given reader. + * Returns the given reader if it is already a {@link BufferedReader}, otherwise + * creates a BufferedReader from the given reader. * - * @param reader - * the reader to wrap or return (not null) - * @param size - * the buffer size, if a new BufferedReader is created. - * @return the given reader or a new {@link BufferedReader} for the given - * reader - * @throws NullPointerException - * if the input parameter is null + * @param reader the reader to wrap or return (not null) + * @param size the buffer size, if a new BufferedReader is created. + * @return the given reader or a new {@link BufferedReader} for the given reader + * @throws NullPointerException if the input parameter is null * @since 2.5 */ - public static BufferedReader buffer( final Reader reader, int size ) - { - return reader instanceof BufferedReader ? (BufferedReader) reader : new BufferedReader( reader, size ); + public static BufferedReader buffer(final Reader reader, int size) { + return reader instanceof BufferedReader ? (BufferedReader) reader : new BufferedReader(reader, size); } /** - * Returns the given Writer if it is already a {@link BufferedWriter}, - * otherwise creates a BufferedWriter from the given Writer. + * Returns the given Writer if it is already a {@link BufferedWriter}, otherwise + * creates a BufferedWriter from the given Writer. * - * @param writer - * the Writer to wrap or return (not null) - * @return the given Writer or a new {@link BufferedWriter} for the given - * Writer - * @throws NullPointerException - * if the input parameter is null + * @param writer the Writer to wrap or return (not null) + * @return the given Writer or a new {@link BufferedWriter} for the given Writer + * @throws NullPointerException if the input parameter is null * @since 2.5 */ - public static BufferedWriter buffer( final Writer writer ) - { - return writer instanceof BufferedWriter ? (BufferedWriter) writer : new BufferedWriter( writer ); + public static BufferedWriter buffer(final Writer writer) { + return writer instanceof BufferedWriter ? (BufferedWriter) writer : new BufferedWriter(writer); } /** - * Returns the given Writer if it is already a {@link BufferedWriter}, - * otherwise creates a BufferedWriter from the given Writer. + * Returns the given Writer if it is already a {@link BufferedWriter}, otherwise + * creates a BufferedWriter from the given Writer. * - * @param writer - * the Writer to wrap or return (not null) - * @param size - * the buffer size, if a new BufferedWriter is created. - * @return the given Writer or a new {@link BufferedWriter} for the given - * Writer - * @throws NullPointerException - * if the input parameter is null + * @param writer the Writer to wrap or return (not null) + * @param size the buffer size, if a new BufferedWriter is created. + * @return the given Writer or a new {@link BufferedWriter} for the given Writer + * @throws NullPointerException if the input parameter is null * @since 2.5 */ - public static BufferedWriter buffer( final Writer writer, int size ) - { - return writer instanceof BufferedWriter ? (BufferedWriter) writer : new BufferedWriter( writer, size ); + public static BufferedWriter buffer(final Writer writer, int size) { + return writer instanceof BufferedWriter ? (BufferedWriter) writer : new BufferedWriter(writer, size); } /** * Returns the given OutputStream if it is already a - * {@link BufferedOutputStream}, otherwise creates a BufferedOutputStream - * from the given OutputStream. + * {@link BufferedOutputStream}, otherwise creates a BufferedOutputStream from + * the given OutputStream. * - * @param outputStream - * the OutputStream to wrap or return (not null) - * @return the given OutputStream or a new {@link BufferedOutputStream} for - * the given OutputStream - * @throws NullPointerException - * if the input parameter is null + * @param outputStream the OutputStream to wrap or return (not null) + * @return the given OutputStream or a new {@link BufferedOutputStream} for the + * given OutputStream + * @throws NullPointerException if the input parameter is null * @since 2.5 */ - public static BufferedOutputStream buffer( final OutputStream outputStream ) - { + public static BufferedOutputStream buffer(final OutputStream outputStream) { // reject null early on rather than waiting for IO operation to fail - if ( outputStream == null ) - { // not checked by BufferedOutputStream - throw new NullPointerException( ); + if (outputStream == null) { // not checked by BufferedOutputStream + throw new NullPointerException(); } return outputStream instanceof BufferedOutputStream ? (BufferedOutputStream) outputStream - : new BufferedOutputStream( outputStream ); + : new BufferedOutputStream(outputStream); } /** * Returns the given OutputStream if it is already a - * {@link BufferedOutputStream}, otherwise creates a BufferedOutputStream - * from the given OutputStream. - * - * @param outputStream - * the OutputStream to wrap or return (not null) - * @param size - * the buffer size, if a new BufferedOutputStream is created. - * @return the given OutputStream or a new {@link BufferedOutputStream} for - * the given OutputStream - * @throws NullPointerException - * if the input parameter is null + * {@link BufferedOutputStream}, otherwise creates a BufferedOutputStream from + * the given OutputStream. + * + * @param outputStream the OutputStream to wrap or return (not null) + * @param size the buffer size, if a new BufferedOutputStream is + * created. + * @return the given OutputStream or a new {@link BufferedOutputStream} for the + * given OutputStream + * @throws NullPointerException if the input parameter is null * @since 2.5 */ - public static BufferedOutputStream buffer( final OutputStream outputStream, int size ) - { + public static BufferedOutputStream buffer(final OutputStream outputStream, int size) { // reject null early on rather than waiting for IO operation to fail - if ( outputStream == null ) - { // not checked by BufferedOutputStream - throw new NullPointerException( ); + if (outputStream == null) { // not checked by BufferedOutputStream + throw new NullPointerException(); } return outputStream instanceof BufferedOutputStream ? (BufferedOutputStream) outputStream - : new BufferedOutputStream( outputStream, size ); + : new BufferedOutputStream(outputStream, size); } /** - * Returns the given InputStream if it is already a - * {@link BufferedInputStream}, otherwise creates a BufferedInputStream from - * the given InputStream. + * Returns the given InputStream if it is already a {@link BufferedInputStream}, + * otherwise creates a BufferedInputStream from the given InputStream. * - * @param inputStream - * the InputStream to wrap or return (not null) - * @return the given InputStream or a new {@link BufferedInputStream} for - * the given InputStream - * @throws NullPointerException - * if the input parameter is null + * @param inputStream the InputStream to wrap or return (not null) + * @return the given InputStream or a new {@link BufferedInputStream} for the + * given InputStream + * @throws NullPointerException if the input parameter is null * @since 2.5 */ - public static BufferedInputStream buffer( final InputStream inputStream ) - { + public static BufferedInputStream buffer(final InputStream inputStream) { // reject null early on rather than waiting for IO operation to fail - if ( inputStream == null ) - { // not checked by BufferedInputStream - throw new NullPointerException( ); + if (inputStream == null) { // not checked by BufferedInputStream + throw new NullPointerException(); } return inputStream instanceof BufferedInputStream ? (BufferedInputStream) inputStream - : new BufferedInputStream( inputStream ); + : new BufferedInputStream(inputStream); } /** - * Returns the given InputStream if it is already a - * {@link BufferedInputStream}, otherwise creates a BufferedInputStream from - * the given InputStream. + * Returns the given InputStream if it is already a {@link BufferedInputStream}, + * otherwise creates a BufferedInputStream from the given InputStream. * - * @param inputStream - * the InputStream to wrap or return (not null) - * @param size - * the buffer size, if a new BufferedInputStream is created. - * @return the given InputStream or a new {@link BufferedInputStream} for - * the given InputStream - * @throws NullPointerException - * if the input parameter is null + * @param inputStream the InputStream to wrap or return (not null) + * @param size the buffer size, if a new BufferedInputStream is created. + * @return the given InputStream or a new {@link BufferedInputStream} for the + * given InputStream + * @throws NullPointerException if the input parameter is null * @since 2.5 */ - public static BufferedInputStream buffer( final InputStream inputStream, int size ) - { + public static BufferedInputStream buffer(final InputStream inputStream, int size) { // reject null early on rather than waiting for IO operation to fail - if ( inputStream == null ) - { // not checked by BufferedInputStream - throw new NullPointerException( ); + if (inputStream == null) { // not checked by BufferedInputStream + throw new NullPointerException(); } return inputStream instanceof BufferedInputStream ? (BufferedInputStream) inputStream - : new BufferedInputStream( inputStream, size ); + : new BufferedInputStream(inputStream, size); } /** - * Gets contents of an InputStream as a byte[]. - * Use this method instead of toByteArray(InputStream) when - * InputStream size is known. NOTE: the method checks - * that the length can safely be cast to an int without truncation before - * using {@link IOUtils#toByteArray(java.io.InputStream, int)} to read into - * the byte array. (Arrays can have no more than Integer.MAX_VALUE entries - * anyway) + * Gets contents of an InputStream as a byte[]. Use + * this method instead of toByteArray(InputStream) when + * InputStream size is known. NOTE: the method checks that + * the length can safely be cast to an int without truncation before using + * {@link IOUtils#toByteArray(java.io.InputStream, int)} to read into the byte + * array. (Arrays can have no more than Integer.MAX_VALUE entries anyway) * - * @param input - * the InputStream to read from - * @param size - * the size of InputStream + * @param input the InputStream to read from + * @param size the size of InputStream * @return the requested byte array - * @throws IOException - * if an I/O error occurs or InputStream size - * differ from parameter size - * @throws IllegalArgumentException - * if size is less than zero or size is greater than - * Integer.MAX_VALUE + * @throws IOException if an I/O error occurs or + * InputStream size differ from + * parameter size + * @throws IllegalArgumentException if size is less than zero or size is greater + * than Integer.MAX_VALUE * @see IOUtils#toByteArray(java.io.InputStream, int) * @since 2.1 */ - public static byte[] toByteArray( final InputStream input, final long size ) throws IOException - { + public static byte[] toByteArray(final InputStream input, final long size) throws IOException { - if ( size > Integer.MAX_VALUE ) - { - throw new IllegalArgumentException( "Size cannot be greater than Integer max value: " + size ); //$NON-NLS-1$ + if (size > Integer.MAX_VALUE) { + throw new IllegalArgumentException("Size cannot be greater than Integer max value: " + size); //$NON-NLS-1$ } - return toByteArray( input, (int) size ); + return toByteArray(input, (int) size); } /** - * Gets the contents of an InputStream as a - * byte[]. Use this method instead of - * toByteArray(InputStream) when InputStream size - * is known + * Gets the contents of an InputStream as a byte[]. + * Use this method instead of toByteArray(InputStream) when + * InputStream size is known * - * @param input - * the InputStream to read from - * @param size - * the size of InputStream + * @param input the InputStream to read from + * @param size the size of InputStream * @return the requested byte array - * @throws IOException - * if an I/O error occurs or InputStream size - * differ from parameter size - * @throws IllegalArgumentException - * if size is less than zero + * @throws IOException if an I/O error occurs or + * InputStream size differ from + * parameter size + * @throws IllegalArgumentException if size is less than zero * @since 2.1 */ - public static byte[] toByteArray( final InputStream input, final int size ) throws IOException - { + public static byte[] toByteArray(final InputStream input, final int size) throws IOException { - if ( size < 0 ) - { - throw new IllegalArgumentException( "Size must be equal or greater than zero: " + size ); //$NON-NLS-1$ + if (size < 0) { + throw new IllegalArgumentException("Size must be equal or greater than zero: " + size); //$NON-NLS-1$ } - if ( size == 0 ) - { + if (size == 0) { return new byte[0]; } @@ -899,17 +474,14 @@ public static byte[] toByteArray( final InputStream input, final int size ) thro int offset = 0; int readed; - while ( offset < size && ( readed = input.read( data, offset, size - offset ) ) != EOF ) - { + while (offset < size && (readed = input.read(data, offset, size - offset)) != EOF) { offset += readed; } - if ( offset != size ) - { - throw new IOException( "Unexpected readed size. current: " //$NON-NLS-1$ - + offset - + ", excepted: " //$NON-NLS-1$ - + size ); + if (offset != size) { + throw new IOException("Unexpected readed size. current: " //$NON-NLS-1$ + + offset + ", excepted: " //$NON-NLS-1$ + + size); } return data; @@ -919,51 +491,43 @@ public static byte[] toByteArray( final InputStream input, final int size ) thro * Gets a URL pointing to the given classpath resource. * *

      - * It is expected the given name to be absolute. The behavior - * is not well-defined otherwise. + * It is expected the given name to be absolute. The behavior is + * not well-defined otherwise. *

      * - * @param name - * name of the desired resource + * @param name name of the desired resource * @return the requested URL - * @throws IOException - * if an I/O error occurs + * @throws IOException if an I/O error occurs * * @since 2.6 */ - public static URL resourceToURL( final String name ) throws IOException - { - return resourceToURL( name, null ); + public static URL resourceToURL(final String name) throws IOException { + return resourceToURL(name, null); } /** * Gets a URL pointing to the given classpath resource. * *

      - * It is expected the given name to be absolute. The behavior - * is not well-defined otherwise. + * It is expected the given name to be absolute. The behavior is + * not well-defined otherwise. *

      * - * @param name - * name of the desired resource - * @param classLoader - * the class loader that the resolution of the resource is - * delegated to + * @param name name of the desired resource + * @param classLoader the class loader that the resolution of the resource is + * delegated to * @return the requested URL - * @throws IOException - * if an I/O error occurs + * @throws IOException if an I/O error occurs * * @since 2.6 */ - public static URL resourceToURL( final String name, final ClassLoader classLoader ) throws IOException - { + public static URL resourceToURL(final String name, final ClassLoader classLoader) throws IOException { // What about the thread context class loader? // What about the system class loader? - final URL resource = classLoader == null ? IOUtils.class.getResource( name ) : classLoader.getResource( name ); + final URL resource = classLoader == null ? IOUtils.class.getResource(name) : classLoader.getResource(name); - if ( resource == null ) - { - throw new IOException( "Resource not found: " + name ); //$NON-NLS-1$ + if (resource == null) { + throw new IOException("Resource not found: " + name); //$NON-NLS-1$ } return resource; @@ -975,32 +539,27 @@ public static URL resourceToURL( final String name, final ClassLoader classLoade * Converts the specified CharSequence to an input stream, encoded as bytes * using the default character encoding of the platform. * - * @param input - * the CharSequence to convert + * @param input the CharSequence to convert * @return an input stream * @since 2.0 * @deprecated 2.5 use {@link #toInputStream(CharSequence, Charset)} instead */ @Deprecated - public static InputStream toInputStream( final CharSequence input ) - { - return toInputStream( input, Charset.defaultCharset( ) ); + public static InputStream toInputStream(final CharSequence input) { + return toInputStream(input, Charset.defaultCharset()); } /** * Converts the specified CharSequence to an input stream, encoded as bytes * using the specified character encoding. * - * @param input - * the CharSequence to convert - * @param encoding - * the encoding to use, null means platform default + * @param input the CharSequence to convert + * @param encoding the encoding to use, null means platform default * @return an input stream * @since 2.3 */ - public static InputStream toInputStream( final CharSequence input, final Charset encoding ) - { - return toInputStream( input.toString( ), encoding ); + public static InputStream toInputStream(final CharSequence input, final Charset encoding) { + return toInputStream(input.toString(), encoding); } // write byte[] @@ -1009,52 +568,39 @@ public static InputStream toInputStream( final CharSequence input, final Charset /** * Writes bytes from a byte[] to an OutputStream. * - * @param data - * the byte array to write, do not modify during output, null - * ignored - * @param output - * the OutputStream to write to - * @throws NullPointerException - * if output is null - * @throws IOException - * if an I/O error occurs + * @param data the byte array to write, do not modify during output, null + * ignored + * @param output the OutputStream to write to + * @throws NullPointerException if output is null + * @throws IOException if an I/O error occurs * @since 1.1 */ - public static void write( final byte[] data, final OutputStream output ) throws IOException - { - if ( data != null ) - { - output.write( data ); + public static void write(final byte[] data, final OutputStream output) throws IOException { + if (data != null) { + output.write(data); } } /** - * Writes bytes from a byte[] to an OutputStream - * using chunked writes. This is intended for writing very large byte arrays - * which might otherwise cause excessive memory usage if the native code has - * to allocate a copy. + * Writes bytes from a byte[] to an OutputStream using + * chunked writes. This is intended for writing very large byte arrays which + * might otherwise cause excessive memory usage if the native code has to + * allocate a copy. * - * @param data - * the byte array to write, do not modify during output, null - * ignored - * @param output - * the OutputStream to write to - * @throws NullPointerException - * if output is null - * @throws IOException - * if an I/O error occurs + * @param data the byte array to write, do not modify during output, null + * ignored + * @param output the OutputStream to write to + * @throws NullPointerException if output is null + * @throws IOException if an I/O error occurs * @since 2.5 */ - public static void writeChunked( final byte[] data, final OutputStream output ) throws IOException - { - if ( data != null ) - { + public static void writeChunked(final byte[] data, final OutputStream output) throws IOException { + if (data != null) { int bytes = data.length; int offset = 0; - while ( bytes > 0 ) - { - int chunk = Math.min( bytes, DEFAULT_BUFFER_SIZE ); - output.write( data, offset, chunk ); + while (bytes > 0) { + int chunk = Math.min(bytes, DEFAULT_BUFFER_SIZE); + output.write(data, offset, chunk); bytes -= chunk; offset += chunk; } @@ -1067,22 +613,16 @@ public static void writeChunked( final byte[] data, final OutputStream output ) /** * Writes chars from a char[] to a Writer * - * @param data - * the char array to write, do not modify during output, null - * ignored - * @param output - * the Writer to write to - * @throws NullPointerException - * if output is null - * @throws IOException - * if an I/O error occurs + * @param data the char array to write, do not modify during output, null + * ignored + * @param output the Writer to write to + * @throws NullPointerException if output is null + * @throws IOException if an I/O error occurs * @since 1.1 */ - public static void write( final char[] data, final Writer output ) throws IOException - { - if ( data != null ) - { - output.write( data ); + public static void write(final char[] data, final Writer output) throws IOException { + if (data != null) { + output.write(data); } } @@ -1092,27 +632,20 @@ public static void write( final char[] data, final Writer output ) throws IOExce * might otherwise cause excessive memory usage if the native code has to * allocate a copy. * - * @param data - * the char array to write, do not modify during output, null - * ignored - * @param output - * the Writer to write to - * @throws NullPointerException - * if output is null - * @throws IOException - * if an I/O error occurs + * @param data the char array to write, do not modify during output, null + * ignored + * @param output the Writer to write to + * @throws NullPointerException if output is null + * @throws IOException if an I/O error occurs * @since 2.5 */ - public static void writeChunked( final char[] data, final Writer output ) throws IOException - { - if ( data != null ) - { + public static void writeChunked(final char[] data, final Writer output) throws IOException { + if (data != null) { int bytes = data.length; int offset = 0; - while ( bytes > 0 ) - { - int chunk = Math.min( bytes, DEFAULT_BUFFER_SIZE ); - output.write( data, offset, chunk ); + while (bytes > 0) { + int chunk = Math.min(bytes, DEFAULT_BUFFER_SIZE); + output.write(data, offset, chunk); bytes -= chunk; offset += chunk; } @@ -1125,21 +658,15 @@ public static void writeChunked( final char[] data, final Writer output ) throws /** * Writes chars from a CharSequence to a Writer. * - * @param data - * the CharSequence to write, null ignored - * @param output - * the Writer to write to - * @throws NullPointerException - * if output is null - * @throws IOException - * if an I/O error occurs + * @param data the CharSequence to write, null ignored + * @param output the Writer to write to + * @throws NullPointerException if output is null + * @throws IOException if an I/O error occurs * @since 2.0 */ - public static void write( final CharSequence data, final Writer output ) throws IOException - { - if ( data != null ) - { - write( data.toString( ), output ); + public static void write(final CharSequence data, final Writer output) throws IOException { + if (data != null) { + write(data.toString(), output); } } @@ -1150,22 +677,17 @@ public static void write( final CharSequence data, final Writer output ) throws *

      * This method uses {@link String#getBytes()}. * - * @param data - * the CharSequence to write, null ignored - * @param output - * the OutputStream to write to - * @throws NullPointerException - * if output is null - * @throws IOException - * if an I/O error occurs + * @param data the CharSequence to write, null ignored + * @param output the OutputStream to write to + * @throws NullPointerException if output is null + * @throws IOException if an I/O error occurs * @since 2.0 * @deprecated 2.5 use {@link #write(CharSequence, OutputStream, Charset)} * instead */ @Deprecated - public static void write( final CharSequence data, final OutputStream output ) throws IOException - { - write( data, output, Charset.defaultCharset( ) ); + public static void write(final CharSequence data, final OutputStream output) throws IOException { + write(data, output, Charset.defaultCharset()); } /** @@ -1174,24 +696,17 @@ public static void write( final CharSequence data, final OutputStream output ) t *

      * This method uses {@link String#getBytes(String)}. * - * @param data - * the CharSequence to write, null ignored - * @param output - * the OutputStream to write to - * @param encoding - * the encoding to use, null means platform default - * @throws NullPointerException - * if output is null - * @throws IOException - * if an I/O error occurs + * @param data the CharSequence to write, null ignored + * @param output the OutputStream to write to + * @param encoding the encoding to use, null means platform default + * @throws NullPointerException if output is null + * @throws IOException if an I/O error occurs * @since 2.3 */ - public static void write( final CharSequence data, final OutputStream output, final Charset encoding ) - throws IOException - { - if ( data != null ) - { - write( data.toString( ), output, encoding ); + public static void write(final CharSequence data, final OutputStream output, final Charset encoding) + throws IOException { + if (data != null) { + write(data.toString(), output, encoding); } } @@ -1205,57 +720,45 @@ public static void write( final CharSequence data, final OutputStream output, fi * This method buffers the input internally, so there is no need to use a * BufferedInputStream. *

      - * Large streams (over 2GB) will return a bytes copied value of - * -1 after the copy has completed since the correct number of - * bytes cannot be returned as an int. For large streams use the + * Large streams (over 2GB) will return a bytes copied value of -1 + * after the copy has completed since the correct number of bytes cannot be + * returned as an int. For large streams use the * copyLarge(InputStream, OutputStream) method. * - * @param input - * the InputStream to read from - * @param output - * the OutputStream to write to + * @param input the InputStream to read from + * @param output the OutputStream to write to * @return the number of bytes copied, or -1 if > Integer.MAX_VALUE - * @throws NullPointerException - * if the input or output is null - * @throws IOException - * if an I/O error occurs + * @throws NullPointerException if the input or output is null + * @throws IOException if an I/O error occurs * @since 1.1 */ - public static int copy( final InputStream input, final OutputStream output ) throws IOException - { - final long count = copyLarge( input, output ); - if ( count > Integer.MAX_VALUE ) - { + public static int copy(final InputStream input, final OutputStream output) throws IOException { + final long count = copyLarge(input, output); + if (count > Integer.MAX_VALUE) { return -1; } return (int) count; } /** - * Copies bytes from an InputStream to an - * OutputStream using an internal buffer of the given size. + * Copies bytes from an InputStream to an OutputStream + * using an internal buffer of the given size. *

      * This method buffers the input internally, so there is no need to use a * BufferedInputStream. *

      * - * @param input - * the InputStream to read from - * @param output - * the OutputStream to write to - * @param bufferSize - * the bufferSize used to copy from the input to the output + * @param input the InputStream to read from + * @param output the OutputStream to write to + * @param bufferSize the bufferSize used to copy from the input to the output * @return the number of bytes copied - * @throws NullPointerException - * if the input or output is null - * @throws IOException - * if an I/O error occurs + * @throws NullPointerException if the input or output is null + * @throws IOException if an I/O error occurs * @since 2.5 */ - public static long copy( final InputStream input, final OutputStream output, final int bufferSize ) - throws IOException - { - return copyLarge( input, output, new byte[bufferSize] ); + public static long copy(final InputStream input, final OutputStream output, final int bufferSize) + throws IOException { + return copyLarge(input, output, new byte[bufferSize]); } /** @@ -1267,20 +770,15 @@ public static long copy( final InputStream input, final OutputStream output, fin *

      * The buffer size is given by {@link #DEFAULT_BUFFER_SIZE}. * - * @param input - * the InputStream to read from - * @param output - * the OutputStream to write to + * @param input the InputStream to read from + * @param output the OutputStream to write to * @return the number of bytes copied - * @throws NullPointerException - * if the input or output is null - * @throws IOException - * if an I/O error occurs + * @throws NullPointerException if the input or output is null + * @throws IOException if an I/O error occurs * @since 1.3 */ - public static long copyLarge( final InputStream input, final OutputStream output ) throws IOException - { - return copy( input, output, DEFAULT_BUFFER_SIZE ); + public static long copyLarge(final InputStream input, final OutputStream output) throws IOException { + return copy(input, output, DEFAULT_BUFFER_SIZE); } /** @@ -1291,35 +789,28 @@ public static long copyLarge( final InputStream input, final OutputStream output * BufferedInputStream. *

      * - * @param input - * the InputStream to read from - * @param output - * the OutputStream to write to - * @param buffer - * the buffer to use for the copy + * @param input the InputStream to read from + * @param output the OutputStream to write to + * @param buffer the buffer to use for the copy * @return the number of bytes copied - * @throws NullPointerException - * if the input or output is null - * @throws IOException - * if an I/O error occurs + * @throws NullPointerException if the input or output is null + * @throws IOException if an I/O error occurs * @since 2.2 */ - public static long copyLarge( final InputStream input, final OutputStream output, final byte[] buffer ) - throws IOException - { + public static long copyLarge(final InputStream input, final OutputStream output, final byte[] buffer) + throws IOException { long count = 0; int n; - while ( EOF != ( n = input.read( buffer ) ) ) - { - output.write( buffer, 0, n ); + while (EOF != (n = input.read(buffer))) { + output.write(buffer, 0, n); count += n; } return count; } /** - * Copies some or all bytes from a large (over 2GB) InputStream - * to an OutputStream, optionally skipping input bytes. + * Copies some or all bytes from a large (over 2GB) InputStream to + * an OutputStream, optionally skipping input bytes. *

      * This method buffers the input internally, so there is no need to use a * BufferedInputStream. @@ -1327,36 +818,29 @@ public static long copyLarge( final InputStream input, final OutputStream output *

      * Note that the implementation uses {@link #skip(InputStream, long)}. This * means that the method may be considerably less efficient than using the - * actual skip implementation, this is done to guarantee that the correct - * number of characters are skipped. + * actual skip implementation, this is done to guarantee that the correct number + * of characters are skipped. *

      * The buffer size is given by {@link #DEFAULT_BUFFER_SIZE}. * - * @param input - * the InputStream to read from - * @param output - * the OutputStream to write to - * @param inputOffset - * : number of bytes to skip from input before copying -ve values - * are ignored - * @param length - * : number of bytes to copy. -ve means all + * @param input the InputStream to read from + * @param output the OutputStream to write to + * @param inputOffset : number of bytes to skip from input before copying -ve + * values are ignored + * @param length : number of bytes to copy. -ve means all * @return the number of bytes copied - * @throws NullPointerException - * if the input or output is null - * @throws IOException - * if an I/O error occurs + * @throws NullPointerException if the input or output is null + * @throws IOException if an I/O error occurs * @since 2.2 */ - public static long copyLarge( final InputStream input, final OutputStream output, final long inputOffset, - final long length ) throws IOException - { - return copyLarge( input, output, inputOffset, length, new byte[DEFAULT_BUFFER_SIZE] ); + public static long copyLarge(final InputStream input, final OutputStream output, final long inputOffset, + final long length) throws IOException { + return copyLarge(input, output, inputOffset, length, new byte[DEFAULT_BUFFER_SIZE]); } /** - * Copies some or all bytes from a large (over 2GB) InputStream - * to an OutputStream, optionally skipping input bytes. + * Copies some or all bytes from a large (over 2GB) InputStream to + * an OutputStream, optionally skipping input bytes. *

      * This method uses the provided buffer, so there is no need to use a * BufferedInputStream. @@ -1364,55 +848,42 @@ public static long copyLarge( final InputStream input, final OutputStream output *

      * Note that the implementation uses {@link #skip(InputStream, long)}. This * means that the method may be considerably less efficient than using the - * actual skip implementation, this is done to guarantee that the correct - * number of characters are skipped. + * actual skip implementation, this is done to guarantee that the correct number + * of characters are skipped. *

      * - * @param input - * the InputStream to read from - * @param output - * the OutputStream to write to - * @param inputOffset - * : number of bytes to skip from input before copying -ve values - * are ignored - * @param length - * : number of bytes to copy. -ve means all - * @param buffer - * the buffer to use for the copy + * @param input the InputStream to read from + * @param output the OutputStream to write to + * @param inputOffset : number of bytes to skip from input before copying -ve + * values are ignored + * @param length : number of bytes to copy. -ve means all + * @param buffer the buffer to use for the copy * @return the number of bytes copied - * @throws NullPointerException - * if the input or output is null - * @throws IOException - * if an I/O error occurs + * @throws NullPointerException if the input or output is null + * @throws IOException if an I/O error occurs * @since 2.2 */ - public static long copyLarge( final InputStream input, final OutputStream output, final long inputOffset, - final long length, final byte[] buffer ) throws IOException - { - if ( inputOffset > 0 ) - { - skipFully( input, inputOffset ); + public static long copyLarge(final InputStream input, final OutputStream output, final long inputOffset, + final long length, final byte[] buffer) throws IOException { + if (inputOffset > 0) { + skipFully(input, inputOffset); } - if ( length == 0 ) - { + if (length == 0) { return 0; } final int bufferLength = buffer.length; int bytesToRead = bufferLength; - if ( length > 0 && length < bufferLength ) - { + if (length > 0 && length < bufferLength) { bytesToRead = (int) length; } int read; long totalRead = 0; - while ( bytesToRead > 0 && EOF != ( read = input.read( buffer, 0, bytesToRead ) ) ) - { - output.write( buffer, 0, read ); + while (bytesToRead > 0 && EOF != (read = input.read(buffer, 0, bytesToRead))) { + output.write(buffer, 0, read); totalRead += read; - if ( length > 0 ) - { // only adjust length if not reading to the end - // Note the cast must work because buffer.length is an integer - bytesToRead = (int) Math.min( length - totalRead, bufferLength ); + if (length > 0) { // only adjust length if not reading to the end + // Note the cast must work because buffer.length is an integer + bytesToRead = (int) Math.min(length - totalRead, bufferLength); } } return totalRead; @@ -1422,187 +893,150 @@ public static long copyLarge( final InputStream input, final OutputStream output // ----------------------------------------------------------------------- /** - * Compares the contents of two Streams to determine if they are equal or - * not. + * Compares the contents of two Streams to determine if they are equal or not. *

      * This method buffers the input internally using * BufferedInputStream if they are not already buffered. * - * @param input1 - * the first stream - * @param input2 - * the second stream + * @param input1 the first stream + * @param input2 the second stream * @return true if the content of the streams are equal or they both don't * exist, false otherwise - * @throws NullPointerException - * if either input is null - * @throws IOException - * if an I/O error occurs + * @throws NullPointerException if either input is null + * @throws IOException if an I/O error occurs */ - public static boolean contentEquals( InputStream input1, InputStream input2 ) throws IOException - { - if ( input1 == input2 ) - { + public static boolean contentEquals(InputStream input1, InputStream input2) throws IOException { + if (input1 == input2) { return true; } - if ( !( input1 instanceof BufferedInputStream ) ) - { - input1 = new BufferedInputStream( input1 ); + if (!(input1 instanceof BufferedInputStream)) { + input1 = new BufferedInputStream(input1); } - if ( !( input2 instanceof BufferedInputStream ) ) - { - input2 = new BufferedInputStream( input2 ); + if (!(input2 instanceof BufferedInputStream)) { + input2 = new BufferedInputStream(input2); } - int ch = input1.read( ); - while ( EOF != ch ) - { - final int ch2 = input2.read( ); - if ( ch != ch2 ) - { + int ch = input1.read(); + while (EOF != ch) { + final int ch2 = input2.read(); + if (ch != ch2) { return false; } - ch = input1.read( ); + ch = input1.read(); } - final int ch2 = input2.read( ); + final int ch2 = input2.read(); return ch2 == EOF; } /** - * Compares the contents of two Readers to determine if they are equal or - * not. + * Compares the contents of two Readers to determine if they are equal or not. *

      - * This method buffers the input internally using - * BufferedReader if they are not already buffered. + * This method buffers the input internally using BufferedReader if + * they are not already buffered. * - * @param input1 - * the first reader - * @param input2 - * the second reader + * @param input1 the first reader + * @param input2 the second reader * @return true if the content of the readers are equal or they both don't * exist, false otherwise - * @throws NullPointerException - * if either input is null - * @throws IOException - * if an I/O error occurs + * @throws NullPointerException if either input is null + * @throws IOException if an I/O error occurs * @since 1.1 */ - public static boolean contentEquals( Reader input1, Reader input2 ) throws IOException - { - if ( input1 == input2 ) - { + public static boolean contentEquals(Reader input1, Reader input2) throws IOException { + if (input1 == input2) { return true; } - input1 = toBufferedReader( input1 ); - input2 = toBufferedReader( input2 ); + input1 = toBufferedReader(input1); + input2 = toBufferedReader(input2); - int ch = input1.read( ); - while ( EOF != ch ) - { - final int ch2 = input2.read( ); - if ( ch != ch2 ) - { + int ch = input1.read(); + while (EOF != ch) { + final int ch2 = input2.read(); + if (ch != ch2) { return false; } - ch = input1.read( ); + ch = input1.read(); } - final int ch2 = input2.read( ); + final int ch2 = input2.read(); return ch2 == EOF; } /** - * Compares the contents of two Readers to determine if they are equal or - * not, ignoring EOL characters. + * Compares the contents of two Readers to determine if they are equal or not, + * ignoring EOL characters. *

      - * This method buffers the input internally using - * BufferedReader if they are not already buffered. + * This method buffers the input internally using BufferedReader if + * they are not already buffered. * - * @param input1 - * the first reader - * @param input2 - * the second reader + * @param input1 the first reader + * @param input2 the second reader * @return true if the content of the readers are equal (ignoring EOL * differences), false otherwise - * @throws NullPointerException - * if either input is null - * @throws IOException - * if an I/O error occurs + * @throws NullPointerException if either input is null + * @throws IOException if an I/O error occurs * @since 2.2 */ - public static boolean contentEqualsIgnoreEOL( final Reader input1, final Reader input2 ) throws IOException - { - if ( input1 == input2 ) - { + public static boolean contentEqualsIgnoreEOL(final Reader input1, final Reader input2) throws IOException { + if (input1 == input2) { return true; } - final BufferedReader br1 = toBufferedReader( input1 ); - final BufferedReader br2 = toBufferedReader( input2 ); - - String line1 = br1.readLine( ); - String line2 = br2.readLine( ); - while ( line1 != null && line2 != null && line1.equals( line2 ) ) - { - line1 = br1.readLine( ); - line2 = br2.readLine( ); + final BufferedReader br1 = toBufferedReader(input1); + final BufferedReader br2 = toBufferedReader(input2); + + String line1 = br1.readLine(); + String line2 = br2.readLine(); + while (line1 != null && line2 != null && line1.equals(line2)) { + line1 = br1.readLine(); + line2 = br2.readLine(); } - return line1 == null ? line2 == null ? true : false : line1.equals( line2 ); + return line1 == null ? line2 == null ? true : false : line1.equals(line2); } /** - * Skips bytes from an input byte stream. This implementation guarantees - * that it will read as many bytes as possible before giving up; this may - * not always be the case for skip() implementations in subclasses of - * {@link InputStream}. + * Skips bytes from an input byte stream. This implementation guarantees that it + * will read as many bytes as possible before giving up; this may not always be + * the case for skip() implementations in subclasses of {@link InputStream}. *

      - * Note that the implementation uses - * {@link InputStream#read(byte[], int, int)} rather than delegating to - * {@link InputStream#skip(long)}. This means that the method may be - * considerably less efficient than using the actual skip implementation, - * this is done to guarantee that the correct number of bytes are skipped. + * Note that the implementation uses {@link InputStream#read(byte[], int, int)} + * rather than delegating to {@link InputStream#skip(long)}. This means that the + * method may be considerably less efficient than using the actual skip + * implementation, this is done to guarantee that the correct number of bytes + * are skipped. *

      * - * @param input - * byte stream to skip - * @param toSkip - * number of bytes to skip. + * @param input byte stream to skip + * @param toSkip number of bytes to skip. * @return number of bytes actually skipped. - * @throws IOException - * if there is a problem reading the file - * @throws IllegalArgumentException - * if toSkip is negative + * @throws IOException if there is a problem reading the file + * @throws IllegalArgumentException if toSkip is negative * @see InputStream#skip(long) * @see IO-203 - Add * skipFully() method for InputStreams * @since 2.0 */ - public static long skip( final InputStream input, final long toSkip ) throws IOException - { - if ( toSkip < 0 ) - { - throw new IllegalArgumentException( "Skip count must be non-negative, actual: " + toSkip ); //$NON-NLS-1$ + public static long skip(final InputStream input, final long toSkip) throws IOException { + if (toSkip < 0) { + throw new IllegalArgumentException("Skip count must be non-negative, actual: " + toSkip); //$NON-NLS-1$ } /* - * N.B. no need to synchronize this because: - we don't care if the - * buffer is created multiple times (the data is ignored) - we always - * use the same size buffer, so if it it is recreated it will still be - * OK (if the buffer size were variable, we would need to synch. to - * ensure some other thread did not create a smaller one) + * N.B. no need to synchronize this because: - we don't care if the buffer is + * created multiple times (the data is ignored) - we always use the same size + * buffer, so if it it is recreated it will still be OK (if the buffer size were + * variable, we would need to synch. to ensure some other thread did not create + * a smaller one) */ - if ( SKIP_BYTE_BUFFER == null ) - { + if (SKIP_BYTE_BUFFER == null) { SKIP_BYTE_BUFFER = new byte[SKIP_BUFFER_SIZE]; } long remain = toSkip; - while ( remain > 0 ) - { + while (remain > 0) { // See https://issues.apache.org/jira/browse/IO-203 for why we use // read() rather than delegating to skip() - final long n = input.read( SKIP_BYTE_BUFFER, 0, (int) Math.min( remain, SKIP_BUFFER_SIZE ) ); - if ( n < 0 ) - { // EOF + final long n = input.read(SKIP_BYTE_BUFFER, 0, (int) Math.min(remain, SKIP_BUFFER_SIZE)); + if (n < 0) { // EOF break; } remain -= n; @@ -1611,35 +1045,28 @@ public static long skip( final InputStream input, final long toSkip ) throws IOE } /** - * Skips bytes from a ReadableByteChannel. This implementation guarantees - * that it will read as many bytes as possible before giving up. + * Skips bytes from a ReadableByteChannel. This implementation guarantees that + * it will read as many bytes as possible before giving up. * - * @param input - * ReadableByteChannel to skip - * @param toSkip - * number of bytes to skip. + * @param input ReadableByteChannel to skip + * @param toSkip number of bytes to skip. * @return number of bytes actually skipped. - * @throws IOException - * if there is a problem reading the ReadableByteChannel - * @throws IllegalArgumentException - * if toSkip is negative + * @throws IOException if there is a problem reading the + * ReadableByteChannel + * @throws IllegalArgumentException if toSkip is negative * @since 2.5 */ - public static long skip( final ReadableByteChannel input, final long toSkip ) throws IOException - { - if ( toSkip < 0 ) - { - throw new IllegalArgumentException( "Skip count must be non-negative, actual: " + toSkip ); //$NON-NLS-1$ + public static long skip(final ReadableByteChannel input, final long toSkip) throws IOException { + if (toSkip < 0) { + throw new IllegalArgumentException("Skip count must be non-negative, actual: " + toSkip); //$NON-NLS-1$ } - final ByteBuffer skipByteBuffer = ByteBuffer.allocate( (int) Math.min( toSkip, SKIP_BUFFER_SIZE ) ); + final ByteBuffer skipByteBuffer = ByteBuffer.allocate((int) Math.min(toSkip, SKIP_BUFFER_SIZE)); long remain = toSkip; - while ( remain > 0 ) - { - skipByteBuffer.position( 0 ); - skipByteBuffer.limit( (int) Math.min( remain, SKIP_BUFFER_SIZE ) ); - final int n = input.read( skipByteBuffer ); - if ( n == EOF ) - { + while (remain > 0) { + skipByteBuffer.position(0); + skipByteBuffer.limit((int) Math.min(remain, SKIP_BUFFER_SIZE)); + final int n = input.read(skipByteBuffer); + if (n == EOF) { break; } remain -= n; @@ -1649,9 +1076,9 @@ public static long skip( final ReadableByteChannel input, final long toSkip ) th /** * Skips characters from an input character stream. This implementation - * guarantees that it will read as many characters as possible before giving - * up; this may not always be the case for skip() implementations in - * subclasses of {@link Reader}. + * guarantees that it will read as many characters as possible before giving up; + * this may not always be the case for skip() implementations in subclasses of + * {@link Reader}. *

      * Note that the implementation uses {@link Reader#read(char[], int, int)} * rather than delegating to {@link Reader#skip(long)}. This means that the @@ -1660,45 +1087,36 @@ public static long skip( final ReadableByteChannel input, final long toSkip ) th * characters are skipped. *

      * - * @param input - * character stream to skip - * @param toSkip - * number of characters to skip. + * @param input character stream to skip + * @param toSkip number of characters to skip. * @return number of characters actually skipped. - * @throws IOException - * if there is a problem reading the file - * @throws IllegalArgumentException - * if toSkip is negative + * @throws IOException if there is a problem reading the file + * @throws IllegalArgumentException if toSkip is negative * @see Reader#skip(long) * @see IO-203 - Add * skipFully() method for InputStreams * @since 2.0 */ - public static long skip( final Reader input, final long toSkip ) throws IOException - { - if ( toSkip < 0 ) - { - throw new IllegalArgumentException( "Skip count must be non-negative, actual: " + toSkip ); //$NON-NLS-1$ + public static long skip(final Reader input, final long toSkip) throws IOException { + if (toSkip < 0) { + throw new IllegalArgumentException("Skip count must be non-negative, actual: " + toSkip); //$NON-NLS-1$ } /* - * N.B. no need to synchronize this because: - we don't care if the - * buffer is created multiple times (the data is ignored) - we always - * use the same size buffer, so if it it is recreated it will still be - * OK (if the buffer size were variable, we would need to synch. to - * ensure some other thread did not create a smaller one) + * N.B. no need to synchronize this because: - we don't care if the buffer is + * created multiple times (the data is ignored) - we always use the same size + * buffer, so if it it is recreated it will still be OK (if the buffer size were + * variable, we would need to synch. to ensure some other thread did not create + * a smaller one) */ - if ( SKIP_CHAR_BUFFER == null ) - { + if (SKIP_CHAR_BUFFER == null) { SKIP_CHAR_BUFFER = new char[SKIP_BUFFER_SIZE]; } long remain = toSkip; - while ( remain > 0 ) - { + while (remain > 0) { // See https://issues.apache.org/jira/browse/IO-203 for why we use // read() rather than delegating to skip() - final long n = input.read( SKIP_CHAR_BUFFER, 0, (int) Math.min( remain, SKIP_BUFFER_SIZE ) ); - if ( n < 0 ) - { // EOF + final long n = input.read(SKIP_CHAR_BUFFER, 0, (int) Math.min(remain, SKIP_BUFFER_SIZE)); + if (n < 0) { // EOF break; } remain -= n; @@ -1709,67 +1127,51 @@ public static long skip( final Reader input, final long toSkip ) throws IOExcept /** * Skips the requested number of bytes or fail if there are not enough left. *

      - * This allows for the possibility that {@link InputStream#skip(long)} may - * not skip as many bytes as requested (most likely because of reaching - * EOF). + * This allows for the possibility that {@link InputStream#skip(long)} may not + * skip as many bytes as requested (most likely because of reaching EOF). *

      * Note that the implementation uses {@link #skip(InputStream, long)}. This * means that the method may be considerably less efficient than using the - * actual skip implementation, this is done to guarantee that the correct - * number of characters are skipped. + * actual skip implementation, this is done to guarantee that the correct number + * of characters are skipped. *

      * - * @param input - * stream to skip - * @param toSkip - * the number of bytes to skip - * @throws IOException - * if there is a problem reading the file - * @throws IllegalArgumentException - * if toSkip is negative - * @throws EOFException - * if the number of bytes skipped was incorrect + * @param input stream to skip + * @param toSkip the number of bytes to skip + * @throws IOException if there is a problem reading the file + * @throws IllegalArgumentException if toSkip is negative + * @throws EOFException if the number of bytes skipped was incorrect * @see InputStream#skip(long) * @since 2.0 */ - public static void skipFully( final InputStream input, final long toSkip ) throws IOException - { - if ( toSkip < 0 ) - { - throw new IllegalArgumentException( "Bytes to skip must not be negative: " + toSkip ); //$NON-NLS-1$ + public static void skipFully(final InputStream input, final long toSkip) throws IOException { + if (toSkip < 0) { + throw new IllegalArgumentException("Bytes to skip must not be negative: " + toSkip); //$NON-NLS-1$ } - final long skipped = skip( input, toSkip ); - if ( skipped != toSkip ) - { - throw new EOFException( "Bytes to skip: " + toSkip + " actual: " + skipped ); //$NON-NLS-1$ //$NON-NLS-2$ + final long skipped = skip(input, toSkip); + if (skipped != toSkip) { + throw new EOFException("Bytes to skip: " + toSkip + " actual: " + skipped); //$NON-NLS-1$ //$NON-NLS-2$ } } /** * Skips the requested number of bytes or fail if there are not enough left. * - * @param input - * ReadableByteChannel to skip - * @param toSkip - * the number of bytes to skip - * @throws IOException - * if there is a problem reading the ReadableByteChannel - * @throws IllegalArgumentException - * if toSkip is negative - * @throws EOFException - * if the number of bytes skipped was incorrect + * @param input ReadableByteChannel to skip + * @param toSkip the number of bytes to skip + * @throws IOException if there is a problem reading the + * ReadableByteChannel + * @throws IllegalArgumentException if toSkip is negative + * @throws EOFException if the number of bytes skipped was incorrect * @since 2.5 */ - public static void skipFully( final ReadableByteChannel input, final long toSkip ) throws IOException - { - if ( toSkip < 0 ) - { - throw new IllegalArgumentException( "Bytes to skip must not be negative: " + toSkip ); //$NON-NLS-1$ + public static void skipFully(final ReadableByteChannel input, final long toSkip) throws IOException { + if (toSkip < 0) { + throw new IllegalArgumentException("Bytes to skip must not be negative: " + toSkip); //$NON-NLS-1$ } - final long skipped = skip( input, toSkip ); - if ( skipped != toSkip ) - { - throw new EOFException( "Bytes to skip: " + toSkip + " actual: " + skipped ); //$NON-NLS-1$ //$NON-NLS-2$ + final long skipped = skip(input, toSkip); + if (skipped != toSkip) { + throw new EOFException("Bytes to skip: " + toSkip + " actual: " + skipped); //$NON-NLS-1$ //$NON-NLS-2$ } } @@ -1777,70 +1179,54 @@ public static void skipFully( final ReadableByteChannel input, final long toSkip * Skips the requested number of characters or fail if there are not enough * left. *

      - * This allows for the possibility that {@link Reader#skip(long)} may not - * skip as many characters as requested (most likely because of reaching - * EOF). + * This allows for the possibility that {@link Reader#skip(long)} may not skip + * as many characters as requested (most likely because of reaching EOF). *

      * Note that the implementation uses {@link #skip(Reader, long)}. This means - * that the method may be considerably less efficient than using the actual - * skip implementation, this is done to guarantee that the correct number of + * that the method may be considerably less efficient than using the actual skip + * implementation, this is done to guarantee that the correct number of * characters are skipped. *

      * - * @param input - * stream to skip - * @param toSkip - * the number of characters to skip - * @throws IOException - * if there is a problem reading the file - * @throws IllegalArgumentException - * if toSkip is negative - * @throws EOFException - * if the number of characters skipped was incorrect + * @param input stream to skip + * @param toSkip the number of characters to skip + * @throws IOException if there is a problem reading the file + * @throws IllegalArgumentException if toSkip is negative + * @throws EOFException if the number of characters skipped was + * incorrect * @see Reader#skip(long) * @since 2.0 */ - public static void skipFully( final Reader input, final long toSkip ) throws IOException - { - final long skipped = skip( input, toSkip ); - if ( skipped != toSkip ) - { - throw new EOFException( "Chars to skip: " + toSkip + " actual: " + skipped ); //$NON-NLS-1$ //$NON-NLS-2$ + public static void skipFully(final Reader input, final long toSkip) throws IOException { + final long skipped = skip(input, toSkip); + if (skipped != toSkip) { + throw new EOFException("Chars to skip: " + toSkip + " actual: " + skipped); //$NON-NLS-1$ //$NON-NLS-2$ } } /** * Reads characters from an input character stream. This implementation - * guarantees that it will read as many characters as possible before giving - * up; this may not always be the case for subclasses of {@link Reader}. + * guarantees that it will read as many characters as possible before giving up; + * this may not always be the case for subclasses of {@link Reader}. * - * @param input - * where to read input from - * @param buffer - * destination - * @param offset - * initial offset into buffer - * @param length - * length to read, must be >= 0 + * @param input where to read input from + * @param buffer destination + * @param offset initial offset into buffer + * @param length length to read, must be >= 0 * @return actual length read; may be less than requested if EOF was reached - * @throws IOException - * if a read error occurs + * @throws IOException if a read error occurs * @since 2.2 */ - public static int read( final Reader input, final char[] buffer, final int offset, final int length ) - throws IOException - { - if ( length < 0 ) - { - throw new IllegalArgumentException( "Length must not be negative: " + length ); //$NON-NLS-1$ + public static int read(final Reader input, final char[] buffer, final int offset, final int length) + throws IOException { + if (length < 0) { + throw new IllegalArgumentException("Length must not be negative: " + length); //$NON-NLS-1$ } int remaining = length; - while ( remaining > 0 ) - { + while (remaining > 0) { final int location = length - remaining; - final int count = input.read( buffer, offset + location, remaining ); - if ( EOF == count ) - { // EOF + final int count = input.read(buffer, offset + location, remaining); + if (EOF == count) { // EOF break; } remaining -= count; @@ -1850,55 +1236,42 @@ public static int read( final Reader input, final char[] buffer, final int offse /** * Reads characters from an input character stream. This implementation - * guarantees that it will read as many characters as possible before giving - * up; this may not always be the case for subclasses of {@link Reader}. + * guarantees that it will read as many characters as possible before giving up; + * this may not always be the case for subclasses of {@link Reader}. * - * @param input - * where to read input from - * @param buffer - * destination + * @param input where to read input from + * @param buffer destination * @return actual length read; may be less than requested if EOF was reached - * @throws IOException - * if a read error occurs + * @throws IOException if a read error occurs * @since 2.2 */ - public static int read( final Reader input, final char[] buffer ) throws IOException - { - return read( input, buffer, 0, buffer.length ); + public static int read(final Reader input, final char[] buffer) throws IOException { + return read(input, buffer, 0, buffer.length); } /** - * Reads bytes from an input stream. This implementation guarantees that it - * will read as many bytes as possible before giving up; this may not always - * be the case for subclasses of {@link InputStream}. + * Reads bytes from an input stream. This implementation guarantees that it will + * read as many bytes as possible before giving up; this may not always be the + * case for subclasses of {@link InputStream}. * - * @param input - * where to read input from - * @param buffer - * destination - * @param offset - * initial offset into buffer - * @param length - * length to read, must be >= 0 + * @param input where to read input from + * @param buffer destination + * @param offset initial offset into buffer + * @param length length to read, must be >= 0 * @return actual length read; may be less than requested if EOF was reached - * @throws IOException - * if a read error occurs + * @throws IOException if a read error occurs * @since 2.2 */ - public static int read( final InputStream input, final byte[] buffer, final int offset, final int length ) - throws IOException - { - if ( length < 0 ) - { - throw new IllegalArgumentException( "Length must not be negative: " + length ); //$NON-NLS-1$ + public static int read(final InputStream input, final byte[] buffer, final int offset, final int length) + throws IOException { + if (length < 0) { + throw new IllegalArgumentException("Length must not be negative: " + length); //$NON-NLS-1$ } int remaining = length; - while ( remaining > 0 ) - { + while (remaining > 0) { final int location = length - remaining; - final int count = input.read( buffer, offset + location, remaining ); - if ( EOF == count ) - { // EOF + final int count = input.read(buffer, offset + location, remaining); + if (EOF == count) { // EOF break; } remaining -= count; @@ -1907,86 +1280,67 @@ public static int read( final InputStream input, final byte[] buffer, final int } /** - * Reads bytes from an input stream. This implementation guarantees that it - * will read as many bytes as possible before giving up; this may not always - * be the case for subclasses of {@link InputStream}. + * Reads bytes from an input stream. This implementation guarantees that it will + * read as many bytes as possible before giving up; this may not always be the + * case for subclasses of {@link InputStream}. * - * @param input - * where to read input from - * @param buffer - * destination + * @param input where to read input from + * @param buffer destination * @return actual length read; may be less than requested if EOF was reached - * @throws IOException - * if a read error occurs + * @throws IOException if a read error occurs * @since 2.2 */ - public static int read( final InputStream input, final byte[] buffer ) throws IOException - { - return read( input, buffer, 0, buffer.length ); + public static int read(final InputStream input, final byte[] buffer) throws IOException { + return read(input, buffer, 0, buffer.length); } /** * Reads bytes from a ReadableByteChannel. *

      - * This implementation guarantees that it will read as many bytes as - * possible before giving up; this may not always be the case for subclasses - * of {@link ReadableByteChannel}. - * - * @param input - * the byte channel to read - * @param buffer - * byte buffer destination - * @return the actual length read; may be less than requested if EOF was - * reached - * @throws IOException - * if a read error occurs + * This implementation guarantees that it will read as many bytes as possible + * before giving up; this may not always be the case for subclasses of + * {@link ReadableByteChannel}. + * + * @param input the byte channel to read + * @param buffer byte buffer destination + * @return the actual length read; may be less than requested if EOF was reached + * @throws IOException if a read error occurs * @since 2.5 */ - public static int read( final ReadableByteChannel input, final ByteBuffer buffer ) throws IOException - { - final int length = buffer.remaining( ); - while ( buffer.remaining( ) > 0 ) - { - final int count = input.read( buffer ); - if ( EOF == count ) - { // EOF + public static int read(final ReadableByteChannel input, final ByteBuffer buffer) throws IOException { + final int length = buffer.remaining(); + while (buffer.remaining() > 0) { + final int count = input.read(buffer); + if (EOF == count) { // EOF break; } } - return length - buffer.remaining( ); + return length - buffer.remaining(); } /** * Reads the requested number of characters or fail if there are not enough * left. *

      - * This allows for the possibility that - * {@link Reader#read(char[], int, int)} may not read as many characters as - * requested (most likely because of reaching EOF). + * This allows for the possibility that {@link Reader#read(char[], int, int)} + * may not read as many characters as requested (most likely because of reaching + * EOF). * - * @param input - * where to read input from - * @param buffer - * destination - * @param offset - * initial offset into buffer - * @param length - * length to read, must be >= 0 - * @throws IOException - * if there is a problem reading the file - * @throws IllegalArgumentException - * if length is negative - * @throws EOFException - * if the number of characters read was incorrect + * @param input where to read input from + * @param buffer destination + * @param offset initial offset into buffer + * @param length length to read, must be >= 0 + * @throws IOException if there is a problem reading the file + * @throws IllegalArgumentException if length is negative + * @throws EOFException if the number of characters read was + * incorrect * @since 2.2 */ - public static void readFully( final Reader input, final char[] buffer, final int offset, final int length ) - throws IOException - { - final int actual = read( input, buffer, offset, length ); - if ( actual != length ) - { - throw new EOFException( "Length to read: " + length + " actual: " + actual ); //$NON-NLS-1$ //$NON-NLS-2$ + public static void readFully(final Reader input, final char[] buffer, final int offset, final int length) + throws IOException { + final int actual = read(input, buffer, offset, length); + if (actual != length) { + throw new EOFException("Length to read: " + length + " actual: " + actual); //$NON-NLS-1$ //$NON-NLS-2$ } } @@ -1994,25 +1348,20 @@ public static void readFully( final Reader input, final char[] buffer, final int * Reads the requested number of characters or fail if there are not enough * left. *

      - * This allows for the possibility that - * {@link Reader#read(char[], int, int)} may not read as many characters as - * requested (most likely because of reaching EOF). + * This allows for the possibility that {@link Reader#read(char[], int, int)} + * may not read as many characters as requested (most likely because of reaching + * EOF). * - * @param input - * where to read input from - * @param buffer - * destination - * @throws IOException - * if there is a problem reading the file - * @throws IllegalArgumentException - * if length is negative - * @throws EOFException - * if the number of characters read was incorrect + * @param input where to read input from + * @param buffer destination + * @throws IOException if there is a problem reading the file + * @throws IllegalArgumentException if length is negative + * @throws EOFException if the number of characters read was + * incorrect * @since 2.2 */ - public static void readFully( final Reader input, final char[] buffer ) throws IOException - { - readFully( input, buffer, 0, buffer.length ); + public static void readFully(final Reader input, final char[] buffer) throws IOException { + readFully(input, buffer, 0, buffer.length); } /** @@ -2022,29 +1371,20 @@ public static void readFully( final Reader input, final char[] buffer ) throws I * {@link InputStream#read(byte[], int, int)} may not read as many bytes as * requested (most likely because of reaching EOF). * - * @param input - * where to read input from - * @param buffer - * destination - * @param offset - * initial offset into buffer - * @param length - * length to read, must be >= 0 - * @throws IOException - * if there is a problem reading the file - * @throws IllegalArgumentException - * if length is negative - * @throws EOFException - * if the number of bytes read was incorrect + * @param input where to read input from + * @param buffer destination + * @param offset initial offset into buffer + * @param length length to read, must be >= 0 + * @throws IOException if there is a problem reading the file + * @throws IllegalArgumentException if length is negative + * @throws EOFException if the number of bytes read was incorrect * @since 2.2 */ - public static void readFully( final InputStream input, final byte[] buffer, final int offset, final int length ) - throws IOException - { - final int actual = read( input, buffer, offset, length ); - if ( actual != length ) - { - throw new EOFException( "Length to read: " + length + " actual: " + actual ); //$NON-NLS-1$ //$NON-NLS-2$ + public static void readFully(final InputStream input, final byte[] buffer, final int offset, final int length) + throws IOException { + final int actual = read(input, buffer, offset, length); + if (actual != length) { + throw new EOFException("Length to read: " + length + " actual: " + actual); //$NON-NLS-1$ //$NON-NLS-2$ } } @@ -2055,21 +1395,15 @@ public static void readFully( final InputStream input, final byte[] buffer, fina * {@link InputStream#read(byte[], int, int)} may not read as many bytes as * requested (most likely because of reaching EOF). * - * @param input - * where to read input from - * @param buffer - * destination - * @throws IOException - * if there is a problem reading the file - * @throws IllegalArgumentException - * if length is negative - * @throws EOFException - * if the number of bytes read was incorrect + * @param input where to read input from + * @param buffer destination + * @throws IOException if there is a problem reading the file + * @throws IllegalArgumentException if length is negative + * @throws EOFException if the number of bytes read was incorrect * @since 2.2 */ - public static void readFully( final InputStream input, final byte[] buffer ) throws IOException - { - readFully( input, buffer, 0, buffer.length ); + public static void readFully(final InputStream input, final byte[] buffer) throws IOException { + readFully(input, buffer, 0, buffer.length); } /** @@ -2079,23 +1413,17 @@ public static void readFully( final InputStream input, final byte[] buffer ) thr * {@link InputStream#read(byte[], int, int)} may not read as many bytes as * requested (most likely because of reaching EOF). * - * @param input - * where to read input from - * @param length - * length to read, must be >= 0 + * @param input where to read input from + * @param length length to read, must be >= 0 * @return the bytes read from input - * @throws IOException - * if there is a problem reading the file - * @throws IllegalArgumentException - * if length is negative - * @throws EOFException - * if the number of bytes read was incorrect + * @throws IOException if there is a problem reading the file + * @throws IllegalArgumentException if length is negative + * @throws EOFException if the number of bytes read was incorrect * @since 2.5 */ - public static byte[] readFully( final InputStream input, final int length ) throws IOException - { + public static byte[] readFully(final InputStream input, final int length) throws IOException { final byte[] buffer = new byte[length]; - readFully( input, buffer, 0, buffer.length ); + readFully(input, buffer, 0, buffer.length); return buffer; } @@ -2103,42 +1431,33 @@ public static byte[] readFully( final InputStream input, final int length ) thro * Reads the requested number of bytes or fail if there are not enough left. *

      * This allows for the possibility that - * {@link ReadableByteChannel#read(ByteBuffer)} may not read as many bytes - * as requested (most likely because of reaching EOF). + * {@link ReadableByteChannel#read(ByteBuffer)} may not read as many bytes as + * requested (most likely because of reaching EOF). * - * @param input - * the byte channel to read - * @param buffer - * byte buffer destination - * @throws IOException - * if there is a problem reading the file - * @throws EOFException - * if the number of bytes read was incorrect + * @param input the byte channel to read + * @param buffer byte buffer destination + * @throws IOException if there is a problem reading the file + * @throws EOFException if the number of bytes read was incorrect * @since 2.5 */ - public static void readFully( final ReadableByteChannel input, final ByteBuffer buffer ) throws IOException - { - final int expected = buffer.remaining( ); - final int actual = read( input, buffer ); - if ( actual != expected ) - { - throw new EOFException( "Length to read: " + expected + " actual: " + actual ); //$NON-NLS-1$ //$NON-NLS-2$ + public static void readFully(final ReadableByteChannel input, final ByteBuffer buffer) throws IOException { + final int expected = buffer.remaining(); + final int actual = read(input, buffer); + if (actual != expected) { + throw new EOFException("Length to read: " + expected + " actual: " + actual); //$NON-NLS-1$ //$NON-NLS-2$ } } - public static byte[] readInputStream( InputStream inStream ) throws Exception - { - ByteArrayOutputStream outStream = new ByteArrayOutputStream( ); - byte[] buffer = new byte[1024]; - int len = 0; - while ( ( len = inStream.read( buffer ) ) != -1 ) - { - outStream.write( buffer, 0, len ); + public static byte[] readInputStream(InputStream inStream) throws Exception { + try (InputStream in = inStream; ByteArrayOutputStream out = new ByteArrayOutputStream()) { + byte[] buffer = new byte[1024]; + int len = 0; + while ((len = inStream.read(buffer)) != -1) { + out.write(buffer, 0, len); + } + byte[] data = out.toByteArray(); + return data; } - byte[] data = outStream.toByteArray( ); - outStream.close( ); - inStream.close( ); - return data; } } \ No newline at end of file diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/JarClassExtractor.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/JarClassExtractor.java index 32c27ba3..f2d99a46 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/JarClassExtractor.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/JarClassExtractor.java @@ -1,95 +1,79 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.util; import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; -public class JarClassExtractor -{ +public class JarClassExtractor { /** * extracts class files from jar/zip archive to specified path. See - * IDecompiler documentation for the format of pareameters. + * IDecompiler documentation for the format of parameters. */ - public static void extract( String archivePath, String packege, String className, boolean inner, String to ) - throws IOException - { - ZipFile archive = new ZipFile( archivePath ); - List entries = findRelevant( archive, packege, className, inner ); - InputStream in = null; - OutputStream out = null; - byte[] buffer = new byte[2048]; - ZipEntry entry; - String outFile; - int lastSep, amountRead; - - for ( int i = 0; i < entries.size( ); i++ ) - { - entry = (ZipEntry) entries.get( i ); - outFile = entry.getName( ); - if ( ( lastSep = outFile.lastIndexOf( '/' ) ) != -1 ) - outFile = outFile.substring( lastSep ); + public static void extract(String archivePath, String packege, String className, boolean inner, String to) + throws IOException { + try (ZipFile archive = new ZipFile(archivePath)) { + List entries = findRelevant(archive, packege, className, inner); + byte[] buffer = new byte[1024 * 16]; + String outFile; + int lastSep, amountRead; - try - { - in = archive.getInputStream( entry ); - if ( in == null ) - throw new IOException( "Zip file entry <" //$NON-NLS-1$ - + entry.getName( ) - + "> not found" ); //$NON-NLS-1$ - out = new FileOutputStream( to + File.separator + outFile ); + for (ZipEntry entry : entries) { + outFile = entry.getName(); + if ((lastSep = outFile.lastIndexOf('/')) != -1) { + outFile = outFile.substring(lastSep); + } - while ( ( amountRead = in.read( buffer ) ) != -1 ) - out.write( buffer, 0, amountRead ); - } - finally - { - if ( in != null ) - in.close( ); - if ( out != null ) - out.close( ); + try (InputStream in = archive.getInputStream(entry)) { + if (in == null) { + throw new IOException("Zip file entry <" //$NON-NLS-1$ + + entry.getName() + "> not found"); //$NON-NLS-1$ + } + Path outPath = Paths.get(to + File.separator + outFile); + try (OutputStream out = Files.newOutputStream(outPath)) { + while ((amountRead = in.read(buffer)) != -1) { + out.write(buffer, 0, amountRead); + } + } + } } } - } - private static List findRelevant( ZipFile archive, String packege, String className, boolean inner ) - { - String entryName = ( packege.length( ) == 0 ) ? className - : packege - + "/" //$NON-NLS-1$ + private static List findRelevant(ZipFile archive, String packege, String className, boolean inner) { + String entryName = (packege.length() == 0) ? className + : packege + "/" //$NON-NLS-1$ + className; - String innerPrefix = entryName.substring( 0, entryName.length( ) - 6 ) + "$"; //$NON-NLS-1$ + String innerPrefix = entryName.substring(0, entryName.length() - 6) + "$"; //$NON-NLS-1$ // strip .class + $ - Enumeration entries = archive.entries( ); + Enumeration entries = archive.entries(); ZipEntry entry; String name; - ArrayList relevant = new ArrayList( ); + List relevant = new ArrayList(); - while ( entries.hasMoreElements( ) ) - { - entry = (ZipEntry) entries.nextElement( ); - name = entry.getName( ); - if ( name.equals( entryName ) || ( name.startsWith( innerPrefix ) && inner ) ) - relevant.add( entry ); + while (entries.hasMoreElements()) { + entry = entries.nextElement(); + name = entry.getName(); + if (name.equals(entryName) || (name.startsWith(innerPrefix) && inner)) { + relevant.add(entry); + } } return relevant; } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/Logger.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/Logger.java index 9ecd2c5a..a52167dc 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/Logger.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/Logger.java @@ -1,69 +1,60 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.util; import org.sf.feeling.decompiler.JavaDecompilerPlugin; -public class Logger -{ +public class Logger { - public static void debug( String message, Throwable throwable ) - { - try - { - if ( message != null ) - { - System.err.println( message ); + public static void debug(String message, Throwable throwable) { + try { + if (message != null) { + System.err.println(message); } - if ( throwable != null ) - { - throwable.printStackTrace( ); + if (throwable != null) { + throwable.printStackTrace(); + } + } catch (Exception localException) { + if (message != null) { + System.err.println(message); + } + if (throwable != null) { + throwable.printStackTrace(); } } - catch ( Exception localException ) - { - if ( message != null ) - System.err.println( message ); - if ( throwable != null ) - throwable.printStackTrace( ); + } + + public static void info(String message) { + if (message != null) { + JavaDecompilerPlugin.logInfo(message); } } - public static void info( String message ) - { - if ( message != null ) - { - JavaDecompilerPlugin.logInfo( message ); + public static void error(String message) { + if (message != null) { + JavaDecompilerPlugin.logError(null, message); } } - public static void error( String message, Throwable t ) - { - if ( message != null ) - { - JavaDecompilerPlugin.logError( t, message ); + public static void error(String message, Throwable t) { + if (message != null) { + JavaDecompilerPlugin.logError(t, message); } } - public static void debug( Throwable throwable ) - { - throwable.printStackTrace( ); + public static void debug(Throwable throwable) { + throwable.printStackTrace(); } - public static void error( Throwable t ) - { - if ( t != null ) - { - JavaDecompilerPlugin.logError( t, t.getMessage( ) ); + public static void error(Throwable t) { + if (t != null) { + JavaDecompilerPlugin.logError(t, t.getMessage()); } } } \ No newline at end of file diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/MarkUtil.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/MarkUtil.java deleted file mode 100644 index fe479ce0..00000000 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/MarkUtil.java +++ /dev/null @@ -1,214 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.util; - -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Random; -import java.util.concurrent.ConcurrentHashMap; - -import org.eclipse.jdt.internal.core.ClassFile; - -public class MarkUtil -{ - - private final static String MARK = "/** Eclipse Class Decompiler plugin, Copyright (c) 2017 Chen Chao. **/"; //$NON-NLS-1$ - private final static String SOURCE_MARK = "/** Eclipse Class Decompiler plugin, Copyright (c) 2017 Chen Chao. */"; //$NON-NLS-1$ - - private final static Map MARKS = new LinkedHashMap( ); - private final static Map SOURCE_MARKS = new LinkedHashMap( ); - private static int MARK_WEIGHT = 0; - private static int SOURCE_MARK_WEIGHT = 0; - static - { - MARKS.put( MARK, 1 ); - SOURCE_MARKS.put( SOURCE_MARK, 1 ); - } - - public static boolean containsMark( String source ) - { - if ( source == null ) - { - return false; - } - int index = source.indexOf( "\n" ); //$NON-NLS-1$ - if ( index != -1 ) - { - source = source.substring( 0, index ); - } - - Iterator marks = MARKS.keySet( ).iterator( ); - while ( marks.hasNext( ) ) - { - String mark = marks.next( ); - if ( source.startsWith( mark ) ) - return true; - } - return false; - } - - public static boolean containsSourceMark( String source ) - { - if ( source == null ) - { - return false; - } - int index = source.indexOf( "\n" ); //$NON-NLS-1$ - if ( index != -1 ) - { - source = source.substring( 0, index ); - } - - Iterator marks = SOURCE_MARKS.keySet( ).iterator( ); - while ( marks.hasNext( ) ) - { - String mark = marks.next( ); - if ( source.startsWith( mark ) ) - return true; - } - return false; - } - - public static String getMark( String source ) - { - if ( source == null ) - { - return ""; //$NON-NLS-1$ - } - int index = source.indexOf( "\n" ); //$NON-NLS-1$ - if ( index != -1 ) - { - source = source.substring( 0, index ); - } - - Iterator marks = SOURCE_MARKS.keySet( ).iterator( ); - while ( marks.hasNext( ) ) - { - String mark = marks.next( ); - if ( source.startsWith( mark ) ) - return mark; - } - - marks = MARKS.keySet( ).iterator( ); - while ( marks.hasNext( ) ) - { - String mark = marks.next( ); - if ( source.startsWith( mark ) ) - return mark; - } - - return ""; //$NON-NLS-1$ - } - - private static ConcurrentHashMap sourceMarkMap = new ConcurrentHashMap( ); - - public static String getRandomSourceMark( Object cf ) - { - if ( cf instanceof ClassFile ) - { - if ( ( (ClassFile) cf ).getParent( ) != null ) - { - cf = ( (ClassFile) cf ).getParent( ).getElementName( ) + "." + ( (ClassFile) cf ).getElementName( ); //$NON-NLS-1$ - } - else - { - cf = ( (ClassFile) cf ).getElementName( ); - } - } - if ( SOURCE_MARKS.size( ) == 1 ) - { - return SOURCE_MARKS.keySet( ).iterator( ).next( ); - } - else - { - if ( sourceMarkMap.containsKey( cf ) ) - return sourceMarkMap.get( cf ); - int weight = new Random( new Random( System.currentTimeMillis( ) ).nextLong( ) ) - .nextInt( SOURCE_MARK_WEIGHT * 100 ) / 100; - Iterator marks = SOURCE_MARKS.keySet( ).iterator( ); - marks.next( ); - int totalWeigth = 0; - while ( marks.hasNext( ) ) - { - String mark = marks.next( ); - totalWeigth += SOURCE_MARKS.get( mark ); - if ( weight < totalWeigth ) - { - sourceMarkMap.put( cf, mark ); - return mark; - } - } - return SOURCE_MARKS.keySet( ).iterator( ).next( ); - } - } - - private static ConcurrentHashMap markMap = new ConcurrentHashMap( ); - - public static String getRandomMark( Object cf ) - { - if ( cf instanceof ClassFile ) - { - if ( ( (ClassFile) cf ).getParent( ) != null ) - { - cf = ( (ClassFile) cf ).getParent( ).getElementName( ) + "." + ( (ClassFile) cf ).getElementName( ); //$NON-NLS-1$ - } - else - { - cf = ( (ClassFile) cf ).getElementName( ); - } - } - if ( MARKS.size( ) == 1 ) - { - return MARKS.keySet( ).iterator( ).next( ); - } - else - { - if ( markMap.containsKey( cf ) ) - return markMap.get( cf ); - int weight = new Random( new Random( System.currentTimeMillis( ) ).nextLong( ) ) - .nextInt( MARK_WEIGHT * 100 ) / 100; - Iterator marks = MARKS.keySet( ).iterator( ); - marks.next( ); - int totalWeigth = 0; - while ( marks.hasNext( ) ) - { - String mark = marks.next( ); - totalWeigth += MARKS.get( mark ); - if ( weight < totalWeigth ) - { - markMap.put( cf, mark ); - return mark; - } - } - return MARKS.keySet( ).iterator( ).next( ); - } - } - - public static void addMark( String mark, int weight ) - { - if ( mark != null && !MARKS.containsKey( mark ) ) - { - MARKS.put( mark, weight ); - MARK_WEIGHT += weight; - } - } - - public static void addSourceMark( String mark, int weight ) - { - if ( mark != null && !SOURCE_MARKS.containsKey( mark ) ) - { - SOURCE_MARKS.put( mark, weight ); - SOURCE_MARK_WEIGHT += weight; - } - } -} diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/ReflectionUtils.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/ReflectionUtils.java index 16c45f0f..ad1b5858 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/ReflectionUtils.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/ReflectionUtils.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.util; @@ -16,22 +13,16 @@ import org.sf.feeling.decompiler.JavaDecompilerPlugin; -public class ReflectionUtils -{ +public class ReflectionUtils { - public static Method getDeclaredMethod( Class clazz, String methodName, Class[] parameterTypes ) - { - if ( clazz == null || methodName == null ) + public static Method getDeclaredMethod(Class clazz, String methodName, Class[] parameterTypes) { + if (clazz == null || methodName == null) return null; - for ( ; clazz != Object.class; clazz = clazz.getSuperclass( ) ) - { - try - { - return clazz.getDeclaredMethod( methodName, parameterTypes ); - } - catch ( Exception e ) - { + for (; clazz != Object.class; clazz = clazz.getSuperclass()) { + try { + return clazz.getDeclaredMethod(methodName, parameterTypes); + } catch (Exception e) { } } @@ -39,107 +30,94 @@ public static Method getDeclaredMethod( Class clazz, String methodName, Class[] return null; } - public static Method getDeclaredMethod( Object object, String methodName, Class[] parameterTypes ) - { - if ( object == null || methodName == null ) + public static Method getDeclaredMethod(Object object, String methodName, Class[] parameterTypes) { + if (object == null || methodName == null) { return null; + } - for ( Class clazz = object.getClass( ); clazz != Object.class; clazz = clazz.getSuperclass( ) ) - { - try - { - return clazz.getDeclaredMethod( methodName, parameterTypes ); - } - catch ( Exception e ) - { - - } + Class clazz; + if ((object instanceof Class)) { + clazz = (Class) object; + } else { + clazz = object.getClass(); } + do { + try { + return clazz.getDeclaredMethod(methodName, parameterTypes); + } catch (Exception e) { + } + clazz = clazz.getSuperclass(); + } while (clazz != Object.class); return null; } - public static Object invokeMethod( Object object, String methodName, Class[] parameterTypes, Object[] parameters ) - { - if ( object == null || methodName == null ) + public static Object invokeMethod(Object object, String methodName, Class[] parameterTypes, Object[] parameters) { + if (object == null || methodName == null) { return null; + } + + Method method = getDeclaredMethod(object, methodName, parameterTypes); + return invokeMethod(method, object, parameters); + } - Method method = getDeclaredMethod( object, methodName, parameterTypes ); - try - { - if ( null != method ) - { - method.setAccessible( true ); - return method.invoke( object, parameters ); + public static Object invokeMethod(Method method, Object object, Object[] parameters) { + try { + if (null != method) { + method.setAccessible(true); + return method.invoke(object, parameters); } - } - catch ( Exception e ) - { - JavaDecompilerPlugin.logError( e, "" ); //$NON-NLS-1$ + } catch (Exception e) { + JavaDecompilerPlugin.logError(e, ""); //$NON-NLS-1$ } return null; } - public static Object invokeMethod( Object object, String methodName ) - { - if ( object == null || methodName == null ) + public static Object invokeMethod(Object object, String methodName) { + if (object == null || methodName == null) return null; - Method method = getDeclaredMethod( object, methodName, new Class[0] ); - try - { - if ( null != method ) - { - method.setAccessible( true ); - return method.invoke( object, new Object[0] ); + Method method = getDeclaredMethod(object, methodName, new Class[0]); + try { + if (null != method) { + method.setAccessible(true); + return method.invoke(object, new Object[0]); } - } - catch ( Exception e ) - { - JavaDecompilerPlugin.logError( e, "" ); //$NON-NLS-1$ + } catch (Exception e) { + JavaDecompilerPlugin.logError(e, ""); //$NON-NLS-1$ } return null; } - public static Object invokeMethod( Class clazz, String methodName, Class[] parameterTypes, Object[] parameters ) - { - if ( clazz == null || methodName == null ) + public static Object invokeMethod(Class clazz, String methodName, Class[] parameterTypes, Object[] parameters) { + if (clazz == null || methodName == null) return null; - Method method = getDeclaredMethod( clazz, methodName, parameterTypes ); - try - { - if ( null != method ) - { - method.setAccessible( true ); - return method.invoke( null, parameters ); + Method method = getDeclaredMethod(clazz, methodName, parameterTypes); + try { + if (null != method) { + method.setAccessible(true); + return method.invoke(null, parameters); } - } - catch ( Exception e ) - { - JavaDecompilerPlugin.logError( e, "" ); //$NON-NLS-1$ + } catch (Exception e) { + JavaDecompilerPlugin.logError(e, ""); //$NON-NLS-1$ } return null; } - public static Field getDeclaredField( Object object, String fieldName ) - { - if ( object == null || fieldName == null ) + public static Field getDeclaredField(Object object, String fieldName) { + if (object == null || fieldName == null) return null; - Class clazz = object.getClass( ); + Class clazz = object.getClass(); - for ( ; clazz != Object.class; clazz = clazz.getSuperclass( ) ) - { - try - { - return clazz.getDeclaredField( fieldName ); - } - catch ( Exception e ) - { + for (; clazz != Object.class; clazz = clazz.getSuperclass()) { + try { + return clazz.getDeclaredField(fieldName); + } catch (Exception e) { } } @@ -147,19 +125,14 @@ public static Field getDeclaredField( Object object, String fieldName ) return null; } - public static Field getDeclaredField( Class clazz, String fieldName ) - { - if ( clazz == null || fieldName == null ) + public static Field getDeclaredField(Class clazz, String fieldName) { + if (clazz == null || fieldName == null) return null; - for ( ; clazz != Object.class; clazz = clazz.getSuperclass( ) ) - { - try - { - return clazz.getDeclaredField( fieldName ); - } - catch ( Exception e ) - { + for (; clazz != Object.class; clazz = clazz.getSuperclass()) { + try { + return clazz.getDeclaredField(fieldName); + } catch (Exception e) { } } @@ -167,97 +140,73 @@ public static Field getDeclaredField( Class clazz, String fieldName ) return null; } - public static void setFieldValue( Object object, String fieldName, Object value ) - { - if ( object == null || fieldName == null ) + public static void setFieldValue(Object object, String fieldName, Object value) { + if (object == null || fieldName == null) return; - Field field = getDeclaredField( object, fieldName ); + Field field = getDeclaredField(object, fieldName); - try - { - if ( field != null ) - { - field.setAccessible( true ); - field.set( object, value ); + try { + if (field != null) { + field.setAccessible(true); + field.set(object, value); } - } - catch ( Exception e ) - { - JavaDecompilerPlugin.logError( e, "" ); //$NON-NLS-1$ + } catch (Exception e) { + JavaDecompilerPlugin.logError(e, ""); //$NON-NLS-1$ } } - public static Object getFieldValue( Object object, String fieldName ) - { - if ( object == null || fieldName == null ) + public static Object getFieldValue(Object object, String fieldName) { + if (object == null || fieldName == null) return null; - Field field = getDeclaredField( object, fieldName ); + Field field = getDeclaredField(object, fieldName); - try - { - if ( field != null ) - { - field.setAccessible( true ); - return field.get( object ); + try { + if (field != null) { + field.setAccessible(true); + return field.get(object); } - } - catch ( Exception e ) - { - JavaDecompilerPlugin.logError( e, "" ); //$NON-NLS-1$ + } catch (Exception e) { + JavaDecompilerPlugin.logError(e, ""); //$NON-NLS-1$ } return null; } - public static Object getFieldValue( Class clazz, String fieldName ) - { - if ( clazz == null || fieldName == null ) + public static Object getFieldValue(Class clazz, String fieldName) { + if (clazz == null || fieldName == null) return null; - Field field = getDeclaredField( clazz, fieldName ); + Field field = getDeclaredField(clazz, fieldName); - try - { - if ( field != null ) - { - field.setAccessible( true ); - return field.get( null ); + try { + if (field != null) { + field.setAccessible(true); + return field.get(null); } - } - catch ( Exception e ) - { - JavaDecompilerPlugin.logError( e, "" ); //$NON-NLS-1$ + } catch (Exception e) { + JavaDecompilerPlugin.logError(e, ""); //$NON-NLS-1$ } return null; } - public static Object invokeMethod( Object object, String methodName, Class clazz, Object value ) - { - if ( object == null || methodName == null ) + public static Object invokeMethod(Object object, String methodName, Class clazz, Object value) { + if (object == null || methodName == null) return null; - Method method = getDeclaredMethod( object, methodName, new Class[]{ - clazz - } ); - try - { - if ( null != method ) - { - method.setAccessible( true ); - return method.invoke( object, new Object[]{ - value - } ); + Method method = getDeclaredMethod(object, methodName, new Class[] { clazz }); + try { + if (null != method) { + method.setAccessible(true); + return method.invoke(object, new Object[] { value }); } - } - catch ( Exception e ) - { - JavaDecompilerPlugin.logError( e, "" ); //$NON-NLS-1$ + } catch (Exception e) { + JavaDecompilerPlugin.logError(e, ""); //$NON-NLS-1$ } return null; diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/SortMemberUtil.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/SortMemberUtil.java index 58a71791..c87b0953 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/SortMemberUtil.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/SortMemberUtil.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.util; @@ -39,172 +36,143 @@ import org.eclipse.jdt.launching.LibraryLocation; import org.sf.feeling.decompiler.JavaDecompilerPlugin; -public class SortMemberUtil -{ +public class SortMemberUtil { private static IPackageFragmentRoot decompilerSourceFolder = null; - public static String sortMember( String packageName, String className, String code ) - { + public static String sortMember(String packageName, String className, String code) { - IPackageFragmentRoot sourceRootFragment = getDecompilerSourceFolder( ); - if ( sourceRootFragment == null ) + IPackageFragmentRoot sourceRootFragment = getDecompilerSourceFolder(); + if (sourceRootFragment == null) { return code; - - try - { - if ( !sourceRootFragment.getJavaProject( ).isOpen( ) ) - { - sourceRootFragment.getJavaProject( ).open( null ); + } + try { + if (!sourceRootFragment.getJavaProject().isOpen()) { + sourceRootFragment.getJavaProject().open(null); } - if ( !sourceRootFragment.getPackageFragment( packageName ).exists( ) ) - { - sourceRootFragment.createPackageFragment( packageName, false, null ); + if (!sourceRootFragment.getPackageFragment(packageName).exists()) { + sourceRootFragment.createPackageFragment(packageName, false, null); } - IPackageFragment packageFragment = sourceRootFragment.getPackageFragment( packageName ); - IProject project = sourceRootFragment.getJavaProject( ).getProject( ); - IFolder sourceFolder = project.getFolder( "src" ); //$NON-NLS-1$ + IPackageFragment packageFragment = sourceRootFragment.getPackageFragment(packageName); + IProject project = sourceRootFragment.getJavaProject().getProject(); + IFolder sourceFolder = project.getFolder("src"); //$NON-NLS-1$ - long time = System.currentTimeMillis( ); + long time = System.currentTimeMillis(); - String javaName = className.replaceAll( "(?i)\\.class", //$NON-NLS-1$ - time + ".java" ); //$NON-NLS-1$ - File locationFile = new File( sourceFolder.getFile( javaName ).getLocation( ).toString( ) ); + String javaName = className.replaceAll("(?i)\\.class", //$NON-NLS-1$ + time + ".java"); //$NON-NLS-1$ + File locationFile = new File(sourceFolder.getFile(javaName).getLocation().toString()); - IFile javaFile = sourceFolder.getFile( javaName ); + IFile javaFile = sourceFolder.getFile(javaName); + + if (!locationFile.getParentFile().exists()) { + locationFile.getParentFile().mkdirs(); + } - if ( !locationFile.getParentFile( ).exists( ) ) - { - locationFile.getParentFile( ).mkdirs( ); + try (PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(locationFile, false)))) { + writer.println(code); } - PrintWriter writer = new PrintWriter( new BufferedWriter( new FileWriter( locationFile, false ) ) ); - writer.println( code ); - writer.close( ); - - javaFile.refreshLocal( 0, null ); - - ICompilationUnit iCompilationUnit = packageFragment.getCompilationUnit( locationFile.getName( ) ); - iCompilationUnit.makeConsistent( null ); - iCompilationUnit.getResource( ).setLocalTimeStamp( new Date( ).getTime( ) ); - iCompilationUnit.becomeWorkingCopy( null ); - new SortMembersOperation( iCompilationUnit, null, true ).run( null ); - iCompilationUnit.commitWorkingCopy( true, null ); - iCompilationUnit.save( null, true ); - String content = iCompilationUnit.getSource( ); - iCompilationUnit.delete( true, null ); - iCompilationUnit.destroy( ); - if ( content != null ) + javaFile.refreshLocal(0, null); + + ICompilationUnit iCompilationUnit = packageFragment.getCompilationUnit(locationFile.getName()); + iCompilationUnit.makeConsistent(null); + iCompilationUnit.getResource().setLocalTimeStamp(new Date().getTime()); + iCompilationUnit.becomeWorkingCopy(null); + new SortMembersOperation(iCompilationUnit, null, true).run(null); + iCompilationUnit.commitWorkingCopy(true, null); + iCompilationUnit.save(null, true); + String content = iCompilationUnit.getSource(); + iCompilationUnit.delete(true, null); + iCompilationUnit.destroy(); + if (content != null) { code = content; - packageFragment.getJavaProject( ).close( ); - } - catch ( IOException e ) - { - JavaDecompilerPlugin.logError( e, "" ); //$NON-NLS-1$ - } - catch ( CoreException e ) - { - JavaDecompilerPlugin.logError( e, "" ); //$NON-NLS-1$ + } + packageFragment.getJavaProject().close(); + } catch (IOException | CoreException e) { + JavaDecompilerPlugin.logError(e, ""); //$NON-NLS-1$ } return code; } - public static void deleteDecompilerProject( ) - { - IWorkspaceRoot root = ResourcesPlugin.getWorkspace( ).getRoot( ); - IProject project = root.getProject( ".decompiler" ); //$NON-NLS-1$ - if ( project != null && project.exists( ) ) - { - try - { - project.delete( true, true, null ); - } - catch ( CoreException e ) - { - JavaDecompilerPlugin.logError( e, "" ); //$NON-NLS-1$ + public static void deleteDecompilerProject() { + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + IProject project = root.getProject(".decompiler"); //$NON-NLS-1$ + if (project != null && project.exists()) { + try { + project.delete(true, true, null); + } catch (CoreException e) { + JavaDecompilerPlugin.logError(e, ""); //$NON-NLS-1$ } } } - public static IPackageFragmentRoot getDecompilerSourceFolder( ) - { - IWorkspaceRoot root = ResourcesPlugin.getWorkspace( ).getRoot( ); - IProject project = root.getProject( ".decompiler" ); //$NON-NLS-1$ - if ( project == null ) + public static IPackageFragmentRoot getDecompilerSourceFolder() { + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + IProject project = root.getProject(".decompiler"); //$NON-NLS-1$ + if (project == null) { return null; - if ( !project.exists( ) ) - { - try - { - project.create( null ); - project.open( null ); - IProjectDescription description = project.getDescription( ); - String[] natures = description.getNatureIds( ); + } + if (!project.exists()) { + try { + project.create(null); + project.open(null); + IProjectDescription description = project.getDescription(); + String[] natures = description.getNatureIds(); String[] newNatures = new String[natures.length + 1]; - System.arraycopy( natures, 0, newNatures, 0, natures.length ); + System.arraycopy(natures, 0, newNatures, 0, natures.length); newNatures[natures.length] = JavaCore.NATURE_ID; - description.setNatureIds( newNatures ); - project.setDescription( description, null ); - } - catch ( CoreException e1 ) - { - JavaDecompilerPlugin.logError( e1, "" ); //$NON-NLS-1$ + description.setNatureIds(newNatures); + project.setDescription(description, null); + } catch (CoreException e1) { + JavaDecompilerPlugin.logError(e1, ""); //$NON-NLS-1$ return null; } - if ( !project.isOpen( ) ) + if (!project.isOpen()) { return null; - } - else if ( !project.isOpen( ) ) - { - try - { - project.open( null ); } - catch ( CoreException e ) - { - JavaDecompilerPlugin.logError( e, "" ); //$NON-NLS-1$ + } else if (!project.isOpen()) { + try { + project.open(null); + } catch (CoreException e) { + JavaDecompilerPlugin.logError(e, ""); //$NON-NLS-1$ return null; } } - if ( decompilerSourceFolder != null ) + if (decompilerSourceFolder != null) { return decompilerSourceFolder; + } + + IJavaProject javaProject = JavaCore.create(project); - IJavaProject javaProject = JavaCore.create( project ); - - try - { - List entries = new ArrayList( ); - IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall( ); - LibraryLocation[] locations = JavaRuntime.getLibraryLocations( vmInstall ); - for ( int i = 0; i < locations.length; i++ ) - { - LibraryLocation element = locations[i]; - entries.add( JavaCore.newLibraryEntry( element.getSystemLibraryPath( ), null, null ) ); + try { + List entries = new ArrayList<>(); + IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall(); + LibraryLocation[] locations = JavaRuntime.getLibraryLocations(vmInstall); + for (LibraryLocation element : locations) { + entries.add(JavaCore.newLibraryEntry(element.getSystemLibraryPath(), null, null)); } // add libs to project class path - javaProject.setRawClasspath( (IClasspathEntry[]) entries.toArray( new IClasspathEntry[entries.size( )] ), - null ); + javaProject.setRawClasspath(entries.toArray(new IClasspathEntry[entries.size()]), null); - IFolder sourceFolder = project.getFolder( "src" ); //$NON-NLS-1$ - sourceFolder.create( false, true, null ); + IFolder sourceFolder = project.getFolder("src"); //$NON-NLS-1$ + sourceFolder.create(false, true, null); - IPackageFragmentRoot codeGenFolder = javaProject.getPackageFragmentRoot( sourceFolder ); - IClasspathEntry[] oldEntries = javaProject.getRawClasspath( ); + IPackageFragmentRoot codeGenFolder = javaProject.getPackageFragmentRoot(sourceFolder); + IClasspathEntry[] oldEntries = javaProject.getRawClasspath(); IClasspathEntry[] newEntries = new IClasspathEntry[oldEntries.length + 1]; - System.arraycopy( oldEntries, 0, newEntries, 0, oldEntries.length ); - newEntries[oldEntries.length] = JavaCore.newSourceEntry( codeGenFolder.getPath( ) ); - javaProject.setRawClasspath( newEntries, null ); - javaProject.open( null ); - decompilerSourceFolder = javaProject.getPackageFragmentRoot( sourceFolder ); + System.arraycopy(oldEntries, 0, newEntries, 0, oldEntries.length); + newEntries[oldEntries.length] = JavaCore.newSourceEntry(codeGenFolder.getPath()); + javaProject.setRawClasspath(newEntries, null); + javaProject.open(null); + decompilerSourceFolder = javaProject.getPackageFragmentRoot(sourceFolder); return decompilerSourceFolder; - } - catch ( CoreException e ) - { - JavaDecompilerPlugin.logError( e, "" ); //$NON-NLS-1$ + } catch (CoreException e) { + JavaDecompilerPlugin.logError(e, ""); //$NON-NLS-1$ } return null; } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/SourceMapperUtil.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/SourceMapperUtil.java new file mode 100644 index 00000000..54f59b8a --- /dev/null +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/SourceMapperUtil.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2019 ECD project contributors. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ + +package org.sf.feeling.decompiler.util; + +import java.lang.reflect.Method; + +import org.eclipse.jdt.core.IJavaElement; +import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.internal.compiler.env.IBinaryType; +import org.eclipse.jdt.internal.core.NamedMember; +import org.eclipse.jdt.internal.core.SourceMapper; + +public class SourceMapperUtil { + private static final String MAP_SOURCE_METHOD_NAME = "mapSource"; //$NON-NLS-1$ + + public static void mapSource(SourceMapper sourceMapper, IType type, char[] source, IBinaryType info) { + mapSource(sourceMapper, type, source, info, null); + } + + public static void mapSource(SourceMapper sourceMapper, IType type, char[] source, IBinaryType info, + IJavaElement elementToFind) { + Method mapSourceMethod = getMapSourceMethod(sourceMapper); + + // API changed with Java 9 support (#daa227e4f5b7af888572a286c4f973b7a167ff2e) + if (mapSourceMethod == null) { + mapSourceMethod = getLegacyMapSourceMethod(sourceMapper); + } + + if (mapSourceMethod == null) { + throw new IllegalStateException("Unable to invoke mapSource method on sourceMapper"); //$NON-NLS-1$ + } + + Object[] parameters = new Object[] { type, source, info, elementToFind }; + ReflectionUtils.invokeMethod(mapSourceMethod, sourceMapper, parameters); + } + + private static Method getMapSourceMethod(SourceMapper sourceMapper) { + // Available in Eclipse Photon / jdt 3.14.0 + return ReflectionUtils.getDeclaredMethod(sourceMapper, MAP_SOURCE_METHOD_NAME, + new Class[] { NamedMember.class, char[].class, IBinaryType.class, IJavaElement.class }); + } + + private static Method getLegacyMapSourceMethod(SourceMapper sourceMapper) { + return ReflectionUtils.getDeclaredMethod(sourceMapper, MAP_SOURCE_METHOD_NAME, + new Class[] { IType.class, char[].class, IBinaryType.class, IJavaElement.class }); + } +} 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 4a4ed112..4d491a0d 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 @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.util; @@ -16,6 +13,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.concurrent.atomic.AtomicReference; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspace; @@ -26,22 +24,12 @@ import org.eclipse.jdt.core.IClassFile; import org.eclipse.jdt.core.IPackageFragment; import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.navigator.IExtensionStateConstants.Values; import org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart; -import org.eclipse.jdt.ui.text.IJavaColorConstants; -import org.eclipse.jdt.ui.text.JavaTextTools; import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.StyleRange; -import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IEditorPart; @@ -57,254 +45,174 @@ import org.eclipse.ui.navigator.CommonNavigatorManager; import org.eclipse.ui.navigator.IExtensionStateModel; import org.eclipse.ui.navigator.INavigatorContentService; -import org.eclipse.ui.themes.ColorUtil; 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; -import com.eclipsesource.json.Json; -import com.eclipsesource.json.JsonObject; -import com.eclipsesource.json.JsonValue; - -public class UIUtil -{ - - public static void openBrowser( String url ) - { - try - { - final URL urlToOpen = new URL( appendUUID( url ) ); - IWebBrowser browser = PlatformUI.getWorkbench( ).getBrowserSupport( ).getExternalBrowser( ); - if ( browser != null ) - { - browser.openURL( urlToOpen ); - JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ).setValue( JavaDecompilerPlugin.ADCLICK_COUNT, - JavaDecompilerPlugin.getDefault( ).getAdClickCount( ).getAndIncrement( ) ); - } - } - catch ( Exception e ) - { - Logger.debug( e ); - } - } +public class UIUtil { - private static String appendUUID( String url ) - { - if ( url.indexOf( "cpupk.com" ) != -1 && url.indexOf( "uuid" ) == -1 ) //$NON-NLS-1$ //$NON-NLS-2$ - { - String uuid = UserUtil.getUserUUID( ); - if ( uuid != null ) - { - if ( url.indexOf( "?" ) != -1 ) //$NON-NLS-1$ - { - url += ( "&uuid=" + uuid ); //$NON-NLS-1$ - } - else - { - url += ( "?uuid=" + uuid ); //$NON-NLS-1$ - } + public static void openBrowser(String url) { + try { + final URL urlToOpen = new URL(url); + IWebBrowser browser = PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser(); + if (browser != null) { + browser.openURL(urlToOpen); } + } catch (Exception e) { + Logger.debug(e); } - return url; } - public static JavaDecompilerClassFileEditor getActiveEditor( ) - { + public static JavaDecompilerClassFileEditor getActiveEditor() { final JavaDecompilerClassFileEditor[] editors = new JavaDecompilerClassFileEditor[1]; - Display.getDefault( ).syncExec( new Runnable( ) { + Display.getDefault().syncExec(new Runnable() { @Override - public void run( ) - { - IWorkbenchPart editor = getActiveEditor( true ); - if ( editor instanceof JavaDecompilerClassFileEditor ) - { + public void run() { + IWorkbenchPart editor = getActiveEditor(true); + if (editor instanceof JavaDecompilerClassFileEditor) { editors[0] = (JavaDecompilerClassFileEditor) editor; - } - else - { - IWorkbenchWindow window = PlatformUI.getWorkbench( ).getActiveWorkbenchWindow( ); + } else { + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if ( window != null ) - { - IWorkbenchPage pg = window.getActivePage( ); + if (window != null) { + IWorkbenchPage pg = window.getActivePage(); - if ( pg != null ) - { - IEditorPart editorPart = pg.getActiveEditor( ); - if ( editorPart instanceof JavaDecompilerClassFileEditor ) - { + if (pg != null) { + IEditorPart editorPart = pg.getActiveEditor(); + if (editorPart instanceof JavaDecompilerClassFileEditor) { editors[0] = (JavaDecompilerClassFileEditor) editorPart; } } } } } - } ); + }); return editors[0]; } - public static JavaDecompilerClassFileEditor getActiveDecompilerEditor( ) - { - final JavaDecompilerClassFileEditor[] editors = new JavaDecompilerClassFileEditor[1]; - Display.getDefault( ).syncExec( new Runnable( ) { + public static JavaDecompilerClassFileEditor getActiveDecompilerEditor() { + final AtomicReference editors = new AtomicReference<>(); + Display.getDefault().syncExec(new Runnable() { @Override - public void run( ) - { - IWorkbenchPart editor = getActiveEditor( true ); - if ( editor instanceof JavaDecompilerClassFileEditor ) - { - editors[0] = (JavaDecompilerClassFileEditor) editor; + public void run() { + IWorkbenchPart editor = getActiveEditor(true); + if (editor instanceof JavaDecompilerClassFileEditor) { + editors.set((JavaDecompilerClassFileEditor) editor); } } - } ); - return editors[0]; + }); + return editors.get(); } - public static List getActiveSelection( ) - { - IWorkbenchWindow window = PlatformUI.getWorkbench( ).getActiveWorkbenchWindow( ); - final List classes = getSelectedElements( window.getSelectionService( ), IClassFile.class ); - if ( classes != null && !classes.isEmpty( ) ) - { + public static List getActiveSelection() { + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + final List classes = getSelectedElements(window.getSelectionService(), IClassFile.class); + if (classes != null && !classes.isEmpty()) { return classes; } return null; } - public static String getActivePerspectiveId( ) - { - final String[] ids = new String[1]; - Display.getDefault( ).syncExec( new Runnable( ) { + public static String getActivePerspectiveId() { + final AtomicReference ids = new AtomicReference<>(); + Display.getDefault().syncExec(new Runnable() { @Override - public void run( ) - { - IWorkbench wb = PlatformUI.getWorkbench( ); - if ( wb == null ) - { - ids[0] = null; + public void run() { + IWorkbench wb = PlatformUI.getWorkbench(); + if (wb == null) { return; } - IWorkbenchWindow win = wb.getActiveWorkbenchWindow( ); - if ( win == null ) - { - ids[0] = null; + IWorkbenchWindow win = wb.getActiveWorkbenchWindow(); + if (win == null) { return; } - IWorkbenchPage page = win.getActivePage( ); - if ( page == null ) - { - ids[0] = null; + IWorkbenchPage page = win.getActivePage(); + if (page == null) { return; } - IPerspectiveDescriptor perspective = page.getPerspective( ); - if ( perspective == null ) - { - ids[0] = null; + IPerspectiveDescriptor perspective = page.getPerspective(); + if (perspective == null) { return; } - ids[0] = perspective.getId( ); - + ids.set(perspective.getId()); } - } ); - return ids[0]; + }); + return ids.get(); } - 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 debug = ( showLineNumber && align ) - || UIUtil.isDebugPerspective( ) - || JavaDecompilerPlugin.getDefault( ).isDebugMode( ); + public static boolean isDebug() { + IPreferenceStore prefs = JavaDecompilerPlugin.getDefault().getPreferenceStore(); + 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; } - public static boolean isDebugPerspective( ) - { + public static boolean isDebugPerspective() { return "org.eclipse.debug.ui.DebugPerspective" //$NON-NLS-1$ - .equals( getActivePerspectiveId( ) ); + .equals(getActivePerspectiveId()); } - public static List getSelectedElements( ISelectionService selService, Class eleClass ) - { + public static List getSelectedElements(ISelectionService selService, Class eleClass) { - Iterator selections = getSelections( selService ); - List elements = new ArrayList( ); + Iterator selections = getSelections(selService); + List elements = new ArrayList(); - while ( ( selections != null ) && selections.hasNext( ) ) - { - Object select = selections.next( ); + while ((selections != null) && selections.hasNext()) { + Object select = selections.next(); - if ( eleClass.isInstance( select ) ) - elements.add( select ); + if (eleClass.isInstance(select)) { + elements.add(select); + } } return elements; } - public static Iterator getSelections( ISelectionService selService ) - { - ISelection selection = selService.getSelection( ); + public static Iterator getSelections(ISelectionService selService) { + ISelection selection = selService.getSelection(); - if ( selection != null ) - { - if ( selection instanceof IStructuredSelection ) - { + if (selection != null) { + if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; - return structuredSelection.iterator( ); + return structuredSelection.iterator(); } } return null; } - public static IWorkbenchPart getActiveEditor( boolean activePageOnly ) - { - IWorkbenchWindow window = PlatformUI.getWorkbench( ).getActiveWorkbenchWindow( ); + public static IWorkbenchPart getActiveEditor(boolean activePageOnly) { + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if ( window != null ) - { - if ( activePageOnly ) - { - IWorkbenchPage pg = window.getActivePage( ); + if (window != null) { + if (activePageOnly) { + IWorkbenchPage pg = window.getActivePage(); - if ( pg != null ) - { - IWorkbenchPart activePart = pg.getActivePart( ); - if ( activePart instanceof ContentOutline ) - { + if (pg != null) { + IWorkbenchPart activePart = pg.getActivePart(); + if (activePart instanceof ContentOutline) { ContentOutline outline = (ContentOutline) activePart; - IWorkbenchPart part = (IWorkbenchPart) ReflectionUtils.invokeMethod( outline, - "getCurrentContributingPart" ); //$NON-NLS-1$ - if ( part == null ) - { - return (IWorkbenchPart) ReflectionUtils.getFieldValue( outline, "hiddenPart" ); //$NON-NLS-1$ + IWorkbenchPart part = (IWorkbenchPart) ReflectionUtils.invokeMethod(outline, + "getCurrentContributingPart"); //$NON-NLS-1$ + if (part == null) { + return (IWorkbenchPart) ReflectionUtils.getFieldValue(outline, "hiddenPart"); //$NON-NLS-1$ } - } - else + } else return activePart; } - } - else - { - IWorkbenchPage[] pgs = window.getPages( ); - - for ( int i = 0; i < pgs.length; i++ ) - { - IWorkbenchPage pg = pgs[i]; - - if ( pg != null ) - { - IWorkbenchPart part = pg.getActivePart( ); - - if ( part != null ) - { + } else { + for (IWorkbenchPage pg : window.getPages()) { + if (pg != null) { + IWorkbenchPart part = pg.getActivePart(); + if (part != null) { return part; } } @@ -315,29 +223,23 @@ public static IWorkbenchPart getActiveEditor( boolean activePageOnly ) return null; } - public static boolean isOpenClassEditor( ) - { - IWorkbenchWindow[] windows = PlatformUI.getWorkbench( ).getWorkbenchWindows( ); - - if ( windows != null ) - { - for ( int i = 0; i < windows.length; i++ ) - { - IWorkbenchWindow window = windows[i]; - IWorkbenchPage[] pgs = window.getPages( ); - for ( int j = 0; j < pgs.length; j++ ) - { - IWorkbenchPage pg = pgs[j]; - if ( pg != null ) - { - IEditorPart[] parts = pg.getEditors( ); - if ( parts != null ) - { - for ( int k = 0; k < parts.length; k++ ) - { - if ( parts[i] instanceof JavaDecompilerClassFileEditor ) - return true; - } + public static boolean isOpenClassEditor() { + IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows(); + + if (windows != null) { + for (IWorkbenchWindow window : windows) { + for (IWorkbenchPage pg : window.getPages()) { + if (pg == null) { + continue; + } + // Deprecated since ?? use getEditorReferences() instead + IEditorPart[] editorParts = pg.getEditors(); + if (editorParts == null) { + continue; + } + for (IEditorPart part : editorParts) { + if (part instanceof JavaDecompilerClassFileEditor) { + return true; } } } @@ -346,138 +248,127 @@ public static boolean isOpenClassEditor( ) return false; } - public static List getExportSelections( ) - { - IWorkbenchWindow window = PlatformUI.getWorkbench( ).getActiveWorkbenchWindow( ); - final List selectedJars = getSelectedElements( window.getSelectionService( ), IPackageFragmentRoot.class ); - if ( selectedJars.size( ) == 1 ) - { + public static List getExportSelections() { + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + final List selectedJars = getSelectedElements(window.getSelectionService(), IPackageFragmentRoot.class); + if (selectedJars.size() == 1) { return selectedJars; } - if ( selectedJars.size( ) > 1 ) + if (selectedJars.size() > 1) { return null; + } - final List selectedPackages = getSelectedElements( window.getSelectionService( ), IPackageFragment.class ); - final List selectedClasses = getSelectedElements( window.getSelectionService( ), IClassFile.class ); - selectedClasses.addAll( selectedPackages ); - if ( !selectedClasses.isEmpty( ) ) - { + final List selectedPackages = getSelectedElements(window.getSelectionService(), IPackageFragment.class); + final List selectedClasses = getSelectedElements(window.getSelectionService(), IClassFile.class); + selectedClasses.addAll(selectedPackages); + if (!selectedClasses.isEmpty()) { return selectedClasses; } return null; } - public static boolean isPackageFlat( ) - { + public static boolean isPackageFlat() { boolean isFlat = false; - try - { - IWorkbenchPart view = getActiveEditor( true ); - if ( view != null ) - { - if ( view.getSite( ).getId( ).equals( "org.eclipse.ui.navigator.ProjectExplorer" ) ) //$NON-NLS-1$ + try { + IWorkbenchPart view = getActiveEditor(true); + if (view != null) { + String id = view.getSite().getId(); + if (id.equals("org.eclipse.ui.navigator.ProjectExplorer")) //$NON-NLS-1$ { CommonNavigator explorer = (CommonNavigator) view; - Field field = CommonNavigator.class.getDeclaredField( "commonManager" ); //$NON-NLS-1$ - if ( field != null ) - { - field.setAccessible( true ); - CommonNavigatorManager manager = (CommonNavigatorManager) field.get( explorer ); - - field = CommonNavigatorManager.class.getDeclaredField( "contentService" ); //$NON-NLS-1$ - if ( field != null ) - { - field.setAccessible( true ); - INavigatorContentService service = (INavigatorContentService) field.get( manager ); - IExtensionStateModel model = service - .findStateModel( "org.eclipse.jdt.java.ui.javaContent" ); //$NON-NLS-1$ - isFlat = model.getBooleanProperty( Values.IS_LAYOUT_FLAT ); + Field field = CommonNavigator.class.getDeclaredField("commonManager"); //$NON-NLS-1$ + if (field != null) { + field.setAccessible(true); + CommonNavigatorManager manager = (CommonNavigatorManager) field.get(explorer); + + field = CommonNavigatorManager.class.getDeclaredField("contentService"); //$NON-NLS-1$ + if (field != null) { + field.setAccessible(true); + INavigatorContentService service = (INavigatorContentService) field.get(manager); + IExtensionStateModel model = service.findStateModel("org.eclipse.jdt.java.ui.javaContent"); //$NON-NLS-1$ + isFlat = model.getBooleanProperty(Values.IS_LAYOUT_FLAT); } } - } - else if ( view.getSite( ).getId( ).equals( "org.eclipse.jdt.ui.PackageExplorer" ) ) //$NON-NLS-1$ + } else if (id.equals("org.eclipse.jdt.ui.PackageExplorer")) //$NON-NLS-1$ { PackageExplorerPart explorer = (PackageExplorerPart) view; - isFlat = explorer.isFlatLayout( ); + isFlat = explorer.isFlatLayout(); + } else { + JavaDecompilerPlugin.logWarn(null, "isPackageFlat: unsupported view: " + id); } } - } - catch ( Exception e ) - { + } catch (Exception e) { } return isFlat; } - public static boolean isWin32( ) - { - return Platform.OS_WIN32.equalsIgnoreCase( Platform.getOS( ) ); + public static boolean isWin32() { + return Platform.OS_WIN32.equalsIgnoreCase(Platform.getOS()); } - public static boolean isMacOS( ) - { - return Platform.OS_MACOSX.equalsIgnoreCase( Platform.getOS( ) ); + public static boolean isMacOS() { + return Platform.OS_MACOSX.equalsIgnoreCase(Platform.getOS()); } - public static String getPathLocation( IPath path ) - { - IWorkspace workspace = ResourcesPlugin.getWorkspace( ); - IWorkspaceRoot root = workspace.getRoot( ); - IResource resource = root.findMember( path ); - if ( resource != null ) - { - return resource.getLocation( ).toOSString( ); + public static String getPathLocation(IPath path) { + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + IWorkspaceRoot root = workspace.getRoot(); + IResource resource = root.findMember(path); + if (resource == null) { + JavaDecompilerPlugin.logWarn(null, "Failed to find member of path " + path); + } else { + IPath location = resource.getLocation(); + if (location == null) { + JavaDecompilerPlugin.logWarn(null, "Failed to get location of path " + resource); + } else { + return location.toOSString(); + } } return null; } - public static boolean requestFromJavadocHover( ) - { - StackTraceElement[] stacks = Thread.currentThread( ).getStackTrace( ); - for ( int i = 0; i < stacks.length && i < 12; i++ ) - { - if ( stacks[i].getClassName( ).indexOf( "BinaryType" ) != -1 //$NON-NLS-1$ - && stacks[i].getMethodName( ).equals( "getJavadocRange" ) ) //$NON-NLS-1$ + public static boolean requestFromJavadocHover() { + StackTraceElement[] stacks = Thread.currentThread().getStackTrace(); + for (int i = 0; i < stacks.length && i < 12; i++) { + if (stacks[i].getClassName().indexOf("BinaryType") != -1 //$NON-NLS-1$ + && stacks[i].getMethodName().equals("getJavadocRange")) //$NON-NLS-1$ return false; - if ( stacks[i].getClassName( ).indexOf( "JavadocHover" ) != -1 //$NON-NLS-1$ - && stacks[i].getMethodName( ).equals( "getHoverInfo" ) ) //$NON-NLS-1$ + if (stacks[i].getClassName().indexOf("JavadocHover") != -1 //$NON-NLS-1$ + && stacks[i].getMethodName().equals("getHoverInfo")) //$NON-NLS-1$ return true; } return false; } - public static boolean requestFromDisassemblerSelection( ) - { - StackTraceElement[] stacks = Thread.currentThread( ).getStackTrace( ); - for ( int i = 0; i < stacks.length && i < 10; i++ ) - { - if ( stacks[i].getMethodName( ).equals( "doHandleCursorPositionChanged" ) ) //$NON-NLS-1$ + public static boolean requestFromDisassemblerSelection() { + StackTraceElement[] stacks = Thread.currentThread().getStackTrace(); + for (int i = 0; i < stacks.length && i < 10; i++) { + if (stacks[i].getMethodName().equals("doHandleCursorPositionChanged")) //$NON-NLS-1$ return true; } return false; } - public static boolean requestCreateBuffer( ) - { - StackTraceElement[] stacks = Thread.currentThread( ).getStackTrace( ); - for ( int i = 0; i < stacks.length && i < 12; i++ ) - { - if ( stacks[i].getClassName( ).indexOf( "BinaryType" ) != -1 //$NON-NLS-1$ - && stacks[i].getMethodName( ).equals( "getJavadocRange" ) ) //$NON-NLS-1$ + public static boolean requestCreateBuffer() { + StackTraceElement[] stacks = Thread.currentThread().getStackTrace(); + for (int i = 0; i < stacks.length && i < 12; i++) { + if (stacks[i].getClassName().indexOf("BinaryType") != -1 //$NON-NLS-1$ + && stacks[i].getMethodName().equals("getJavadocRange")) //$NON-NLS-1$ return false; - if ( stacks[i].getClassName( ).indexOf( "JavadocHover" ) != -1 //$NON-NLS-1$ - && stacks[i].getMethodName( ).equals( "getHoverInfo2" ) ) //$NON-NLS-1$ + if (stacks[i].getClassName().indexOf("JavadocHover") != -1 //$NON-NLS-1$ + && stacks[i].getMethodName().equals("getHoverInfo2")) //$NON-NLS-1$ return true; - if ( stacks[i].getClassName( ).indexOf( "JavaSourceHover" ) != -1 //$NON-NLS-1$ - && stacks[i].getMethodName( ).equals( "getHoverInfo" ) ) //$NON-NLS-1$ + if (stacks[i].getClassName().indexOf("JavaSourceHover") != -1 //$NON-NLS-1$ + && stacks[i].getMethodName().equals("getHoverInfo")) //$NON-NLS-1$ return true; - if ( stacks[i].getClassName( ).indexOf( "FindOccurrencesInFileAction" ) != -1 //$NON-NLS-1$ - && stacks[i].getMethodName( ).equals( "getMember" ) ) //$NON-NLS-1$ + if (stacks[i].getClassName().indexOf("FindOccurrencesInFileAction") != -1 //$NON-NLS-1$ + && stacks[i].getMethodName().equals("getMember")) //$NON-NLS-1$ return true; // if ( stacks[i].getClassName( ).indexOf( "HyperlinkManager" ) != @@ -496,293 +387,41 @@ public static boolean requestCreateBuffer( ) return false; } - public static boolean requestFromShowMatch( ) - { - StackTraceElement[] stacks = Thread.currentThread( ).getStackTrace( ); - for ( int i = 0; i < stacks.length; i++ ) - { - if ( stacks[i].getClassName( ).indexOf( "JavaSearchResultPage" ) != -1 //$NON-NLS-1$ - && stacks[i].getMethodName( ).equals( "showMatch" ) ) //$NON-NLS-1$ + public static boolean requestFromShowMatch() { + StackTraceElement[] stacks = Thread.currentThread().getStackTrace(); + for (int i = 0; i < stacks.length; i++) { + if (stacks[i].getClassName().indexOf("JavaSearchResultPage") != -1 //$NON-NLS-1$ + && stacks[i].getMethodName().equals("showMatch")) //$NON-NLS-1$ return true; } return false; } - public static StyleRange getAdTextStyleRange( StyledText textWidget, int offset, int length ) - { - JavaTextTools textTools = JavaPlugin.getDefault( ).getJavaTextTools( ); - IPreferenceStore preferences = (IPreferenceStore) ReflectionUtils.getFieldValue( textTools, - "fPreferenceStore" ); //$NON-NLS-1$ - String textColor = preferences.getString( IJavaColorConstants.JAVADOC_LINK ); - - StyleRange styleRange = null; - if ( isDark( textWidget ) ) - { - String darkStyleValue = JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ).getString( "darkStyle" ); //$NON-NLS-1$ - if ( darkStyleValue != null && darkStyleValue.trim( ).length( ) > 0 ) - { - styleRange = handleStyleValue( textWidget, offset, length, darkStyleValue, "text", textColor, false ); //$NON-NLS-1$ - } - } - else - { - String brightStyleValue = JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ).getString( - "brightStyle" ); //$NON-NLS-1$ - if ( brightStyleValue != null && brightStyleValue.trim( ).length( ) > 0 ) - { - styleRange = handleStyleValue( textWidget, offset, length, brightStyleValue, "text", textColor, false ); //$NON-NLS-1$ - } - - } - - if ( styleRange == null ) - { - styleRange = getDefaultCommonRange( textWidget, offset, length ); - } - return styleRange; - } - - private static StyleRange handleStyleValue( StyledText textWidget, int offset, int length, String brightStyleValue, - String property, String defaultColor, boolean isLink ) - { - JsonValue styleValue = null; - try - { - styleValue = Json.parse( brightStyleValue ); - } - catch ( Exception e ) - { - Logger.debug( e ); - } - - if ( styleValue != null && styleValue.isObject( ) ) - { - JsonObject style = styleValue.asObject( ); - if ( style.get( property ) != null && style.get( property ).isObject( ) ) - { - return getStyleRange( textWidget, - offset, - length, - style.get( property ).asObject( ), - defaultColor, - isLink ); - } - } - - return null; - } - - private static StyleRange getStyleRange( StyledText textWidget, int offset, int length, JsonObject style, - String defaultColor, boolean isLink ) - { - int contentLength = textWidget.getCharCount( ); - if ( contentLength - offset < 0 ) - return null; - StyleRange range = new StyleRange( offset, - offset + length < contentLength ? length : contentLength - offset, - defaultColor == null ? null - : JFaceResources.getResources( ).createColor( ColorUtil.getColorValue( defaultColor ) ), - null ); - JsonValue fontStyleValue = style.get( "fontStyle" ); //$NON-NLS-1$ - if ( fontStyleValue != null && fontStyleValue.isNumber( ) ) - { - range.fontStyle = fontStyleValue.asInt( ); - } - - JsonValue fontFamilyValue = style.get( "fontFamily" ); //$NON-NLS-1$ - if ( fontFamilyValue != null && fontFamilyValue.isString( ) ) - { - if ( range.font == null ) - { - FontData fontData = textWidget.getFont( ).getFontData( )[0]; - fontData.setName( fontFamilyValue.asString( ) ); - Font font = new Font( textWidget.getDisplay( ), fontData ); - range.font = font; - } - else - { - FontData fontData = range.font.getFontData( )[0]; - fontData.setName( fontFamilyValue.asString( ) ); - } - } - - JsonValue fontSizeValue = style.get( "fontSize" ); //$NON-NLS-1$ - if ( fontSizeValue != null && fontSizeValue.isNumber( ) ) - { - FontData textFontData = textWidget.getFont( ).getFontData( )[0]; - if ( fontSizeValue.asInt( ) > textFontData.getHeight( ) ) - { - if ( range.font == null ) - { - FontData fontData = textFontData; - fontData.setHeight( fontSizeValue.asInt( ) ); - Font font = new Font( textWidget.getDisplay( ), fontData ); - range.font = font; - } - else - { - FontData fontData = range.font.getFontData( )[0]; - fontData.setHeight( fontSizeValue.asInt( ) ); - } - } - } - - if ( isLink ) - { - range.underline = true; - range.underlineStyle = SWT.UNDERLINE_LINK; - } - - JsonValue underlineValue = style.get( "underline" ); //$NON-NLS-1$ - if ( underlineValue != null && underlineValue.isBoolean( ) ) - { - range.underline = underlineValue.asBoolean( ); - if ( range.underline ) - { - range.underlineStyle = SWT.UNDERLINE_LINK; - } - } - - JsonValue underlineStyleValue = style.get( "underlineStyle" ); //$NON-NLS-1$ - if ( underlineStyleValue != null && underlineStyleValue.isNumber( ) ) - { - range.underlineStyle = underlineStyleValue.asInt( ); - } - - JsonValue hideUnderlineValue = style.get( "hideUnderline" ); //$NON-NLS-1$ - if ( hideUnderlineValue != null && hideUnderlineValue.isBoolean( ) ) - { - if ( hideUnderlineValue.asBoolean( ) ) - { - range.underlineColor = textWidget.getBackground( ); - } - } - - JsonValue backgroundValue = style.get( "background" ); //$NON-NLS-1$ - if ( backgroundValue != null && backgroundValue.isString( ) ) - { - String backgroundString = backgroundValue.asString( ); - RGB rgb = ColorUtil.getColorValue( backgroundString ); - if ( rgb != null ) - { - range.background = new Color( textWidget.getDisplay( ), rgb ); - } - } - - JsonValue foregroundValue = style.get( "foreground" ); //$NON-NLS-1$ - if ( foregroundValue != null && foregroundValue.isString( ) ) - { - String foregroundString = foregroundValue.asString( ); - RGB rgb = ColorUtil.getColorValue( foregroundString ); - if ( rgb != null ) - { - range.foreground = new Color( textWidget.getDisplay( ), rgb ); - if ( range.underlineColor == null ) - { - range.underlineColor = range.foreground; - } - } - } - - return range; - } - - public static boolean isDark( Control textWidget ) - { - if ( textWidget != null && !textWidget.isDisposed( ) ) - { - Color color = textWidget.getBackground( ); - int red = color.getRed( ); - int blue = color.getBlue( ); - int green = color.getGreen( ); + public static boolean isDark(Control textWidget) { + if (textWidget != null && !textWidget.isDisposed()) { + Color color = textWidget.getBackground(); + int red = color.getRed(); + int blue = color.getBlue(); + int green = color.getGreen(); return red < 127 || blue < 127 || green < 127; } return false; } - public static StyleRange getAdLinkStyleRange( StyledText textWidget, int offset, int length ) - { - JavaTextTools textTools = JavaPlugin.getDefault( ).getJavaTextTools( ); - IPreferenceStore preferences = (IPreferenceStore) ReflectionUtils.getFieldValue( textTools, - "fPreferenceStore" ); //$NON-NLS-1$ - String linkColor = preferences.getString( IJavaColorConstants.JAVADOC_DEFAULT ); - - StyleRange styleRange = null; - if ( isDark( textWidget ) ) - { - String darkStyleValue = JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ).getString( "darkStyle" ); //$NON-NLS-1$ - if ( darkStyleValue != null && darkStyleValue.trim( ).length( ) > 0 ) - { - styleRange = handleStyleValue( textWidget, offset, length, darkStyleValue, "link", linkColor, true ); //$NON-NLS-1$ - } - } - else - { - String brightStyleValue = JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ).getString( - "brightStyle" ); //$NON-NLS-1$ - if ( brightStyleValue != null && brightStyleValue.trim( ).length( ) > 0 ) - { - styleRange = handleStyleValue( textWidget, offset, length, brightStyleValue, "link", linkColor, true ); //$NON-NLS-1$ - } - } - - if ( styleRange == null ) - { - styleRange = getDefaultLinkRange( textWidget, offset, length ); - } - return styleRange; - } - - private static StyleRange getDefaultLinkRange( StyledText textWidget, int offset, int length ) - { - JavaTextTools textTools = JavaPlugin.getDefault( ).getJavaTextTools( ); - IPreferenceStore preferences = (IPreferenceStore) ReflectionUtils.getFieldValue( textTools, - "fPreferenceStore" ); //$NON-NLS-1$ - String linkColor = preferences.getString( IJavaColorConstants.JAVADOC_LINK ); - - StyleRange range = new StyleRange( offset, - length, - JFaceResources.getResources( ).createColor( ColorUtil.getColorValue( linkColor ) ), - null ); - range.font = textWidget.getFont( ); - range.underline = true; - range.underlineStyle = SWT.UNDERLINE_LINK; - return range; - } - - private static StyleRange getDefaultCommonRange( StyledText textWidget, int offset, int length ) - { - JavaTextTools textTools = JavaPlugin.getDefault( ).getJavaTextTools( ); - IPreferenceStore preferences = (IPreferenceStore) ReflectionUtils.getFieldValue( textTools, - "fPreferenceStore" ); //$NON-NLS-1$ - String commentColor = preferences.getString( IJavaColorConstants.JAVADOC_DEFAULT ); - - StyleRange range = new StyleRange( offset, - length, - new Color( textWidget.getDisplay( ), ColorUtil.getColorValue( commentColor ) ), - null ); - range.font = textWidget.getFont( ); - return range; - } - - public static boolean requestFromLinkToSelection( ) - { - StackTraceElement[] stacks = Thread.currentThread( ).getStackTrace( ); - for ( int i = 0; i < stacks.length && i < 10; i++ ) - { - if ( stacks[i].getMethodName( ).equals( "linkToEditor" ) //$NON-NLS-1$ - || stacks[i].getMethodName( ).equals( "showSource" ) ) //$NON-NLS-1$ + public static boolean requestFromLinkToSelection() { + StackTraceElement[] stacks = Thread.currentThread().getStackTrace(); + for (int i = 0; i < stacks.length && i < 10; i++) { + if (stacks[i].getMethodName().equals("linkToEditor") //$NON-NLS-1$ + || stacks[i].getMethodName().equals("showSource")) //$NON-NLS-1$ return true; } return false; } - public static boolean requestFromCopyOperation( ) - { - StackTraceElement[] stacks = Thread.currentThread( ).getStackTrace( ); - for ( int i = 0; i < stacks.length && i < 10; i++ ) - { - if ( stacks[i].getMethodName( ).equals( "doCutCopyWithImportsOperation" ) ) //$NON-NLS-1$ + public static boolean requestFromCopyOperation() { + StackTraceElement[] stacks = Thread.currentThread().getStackTrace(); + for (int i = 0; i < stacks.length && i < 10; i++) { + if (stacks[i].getMethodName().equals("doCutCopyWithImportsOperation")) //$NON-NLS-1$ return true; } return false; diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/UnicodeUtil.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/UnicodeUtil.java index 10b51c3a..9176006d 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/UnicodeUtil.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/UnicodeUtil.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.util; @@ -14,20 +11,17 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -public class UnicodeUtil -{ +public class UnicodeUtil { - static final Pattern unicodePattern = Pattern.compile( "\\\\u([0-9a-zA-Z]{4})" ); //$NON-NLS-1$ + static final Pattern unicodePattern = Pattern.compile("\\\\u([0-9a-zA-Z]{4})"); //$NON-NLS-1$ - public static String decode( String s ) - { - Matcher m = unicodePattern.matcher( s ); - StringBuffer sb = new StringBuffer( s.length( ) ); - while ( m.find( ) ) - { - m.appendReplacement( sb, Character.toString( (char) Integer.parseInt( m.group( 1 ), 16 ) ) ); + public static String decode(String s) { + Matcher m = unicodePattern.matcher(s); + StringBuffer sb = new StringBuffer(s.length()); + while (m.find()) { + m.appendReplacement(sb, Character.toString((char) Integer.parseInt(m.group(1), 16))); } - m.appendTail( sb ); - return sb.toString( ); + m.appendTail(sb); + return sb.toString(); } } diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/UserUtil.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/UserUtil.java deleted file mode 100644 index 2cc0ae95..00000000 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/UserUtil.java +++ /dev/null @@ -1,505 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation - *******************************************************************************/ - -package org.sf.feeling.decompiler.util; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.StringWriter; -import java.net.NetworkInterface; -import java.net.URL; -import java.net.URLConnection; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.Date; -import java.util.Enumeration; -import java.util.List; -import java.util.UUID; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.sf.feeling.decompiler.JavaDecompilerPlugin; - -import com.eclipsesource.json.Json; -import com.eclipsesource.json.JsonObject; -import com.eclipsesource.json.JsonValue; - -public class UserUtil -{ - - public static final File DecompilerCacheDir = new File( String.valueOf( System.getProperty( "user.home" ) ) //$NON-NLS-1$ - + File.separatorChar - + ".decompiler" ); //$NON-NLS-1$ - private static final File UserJsonFile = new File( DecompilerCacheDir, "user.json" ); //$NON-NLS-1$ - - public static String unicodeToString( String str ) - { - Pattern pattern = Pattern.compile( "(\\\\u(\\p{XDigit}{4}))" ); //$NON-NLS-1$ - Matcher matcher = pattern.matcher( str ); - char ch; - while ( matcher.find( ) ) - { - ch = (char) Integer.parseInt( matcher.group( 2 ), 16 ); - str = str.replace( matcher.group( 1 ), ch + "" ); //$NON-NLS-1$ - } - return str; - } - - public static JsonObject collectUserIp( ) - { - InputStream is = null; - try - { - URLConnection connection = new URL( "http://pv.sohu.com/cityjson" ) //$NON-NLS-1$ - .openConnection( ); - connection.setConnectTimeout( 30000 ); - connection.setReadTimeout( 30000 ); - is = connection.getInputStream( ); - String content = FileUtil.getContent( is ); - content = unicodeToString( content.substring( content.indexOf( "=" ) + 1, //$NON-NLS-1$ - content.length( ) - 1 ) ); - JsonObject json = Json.parse( content ).asObject( ); - String ip = json.get( "cip" ).asString( ); //$NON-NLS-1$ - - is.close( ); - - connection = new URL( "http://ip.taobao.com/service/getIpInfo.php?ip=" + ip ) //$NON-NLS-1$ - .openConnection( ); - connection.setConnectTimeout( 30000 ); - connection.setReadTimeout( 30000 ); - is = connection.getInputStream( ); - content = unicodeToString( FileUtil.getContent( is ) ); - json = Json.parse( content ).asObject( ); - if ( json.getInt( "code", -1 ) == 0 && json.get( "data" ).isObject( ) ) //$NON-NLS-1$ //$NON-NLS-2$ - { - return json.get( "data" ).asObject( ); //$NON-NLS-1$ - } - } - catch ( Exception e ) - { - Logger.debug( e ); - } - finally - { - if ( is != null ) - { - try - { - is.close( ); - } - catch ( IOException e ) - { - Logger.debug( e ); - } - } - } - return null; - } - - private static synchronized String generateUserMacAddress( ) - { - List macList = new ArrayList( ); - try - { - Enumeration ni = NetworkInterface.getNetworkInterfaces( ); - while ( ni.hasMoreElements( ) ) - { - NetworkInterface netI = ni.nextElement( ); - byte[] bytes = (byte[]) ReflectionUtils.invokeMethod( netI, - "getHardwareAddress", //$NON-NLS-1$ - new Class[0], - new Object[0] ); - Boolean isUp = (Boolean) ReflectionUtils.invokeMethod( netI, - "isUp", //$NON-NLS-1$ - new Class[0], - new Object[0] ); - if ( Boolean.TRUE.equals( isUp ) && netI != null && bytes != null && bytes.length == 6 ) - { - StringBuffer sb = new StringBuffer( ); - for ( byte b : bytes ) - { - sb.append( Integer.toHexString( ( b & 240 ) >> 4 ) ); - sb.append( Integer.toHexString( b & 15 ) ); - sb.append( "-" ); //$NON-NLS-1$ - } - sb.deleteCharAt( sb.length( ) - 1 ); - macList.add( sb.toString( ).toUpperCase( ) ); - } - } - } - catch ( Exception e ) - { - Logger.debug( e ); - } - - if ( macList.isEmpty( ) ) - { - return null; - } - else - { - Collections.sort( macList, new Comparator( ) { - - @Override - public int compare( String o1, String o2 ) - { - return o1.split( "00" ).length - o2.split( "00" ).length; //$NON-NLS-1$ //$NON-NLS-2$ - } - } ); - - String mac = macList.get( 0 ); - if ( mac.split( "00" ).length > 2 ) //$NON-NLS-1$ - { - return null; - } - return mac; - } - } - - private static synchronized JsonObject loadSourceBindingJson( ) - { - if ( UserJsonFile.exists( ) ) - { - try - { - return Json.parse( FileUtil.getContent( UserJsonFile, "utf-8" ) ) //$NON-NLS-1$ - .asObject( ); - } - catch ( Exception e ) - { - Logger.error( "Load source attach binding configuration failed.", //$NON-NLS-1$ - e ); - } - } - return saveUser( generateUserMacAddress( ) ); - } - - private static synchronized JsonObject saveUser( String user ) - { - if ( user == null ) - { - user = generateUUID( ); - } - - JsonObject userObject = new JsonObject( ); - userObject.set( "user", user ); //$NON-NLS-1$ - - if ( user.split( "-" ).length == 6 ) //$NON-NLS-1$ - { - userObject.set( "uuid", generateUUID( ) ); //$NON-NLS-1$ - } - else - { - userObject.set( "uuid", user ); //$NON-NLS-1$ - } - - userObject.set( "version", VersionUtil.getDecompilerVersion( ) ); //$NON-NLS-1$ - userObject.set( "date", //$NON-NLS-1$ - new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ) //$NON-NLS-1$ - .format( new Date( System.currentTimeMillis( ) ) ) ); - userObject.set( "count", 0 ); //$NON-NLS-1$ - userObject.set( "adclick", 0 ); //$NON-NLS-1$ - saveSourceBindingJson( userObject ); - - return userObject; - } - - private static String generateUUID( ) - { - if ( JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ).contains( "uuid" ) ) //$NON-NLS-1$ - { - return JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ).getString( "uuid" ); //$NON-NLS-1$ - } - else - { - String uuid = UUID.randomUUID( ).toString( ); - JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ).setValue( "uuid", uuid ); //$NON-NLS-1$ - return uuid; - } - } - - private static synchronized void saveSourceBindingJson( JsonObject json ) - { - StringWriter sw = new StringWriter( ); - try - { - json.writeTo( sw ); - String jsonString = sw.toString( ); - FileUtil.writeToFile( UserJsonFile, jsonString, "utf-8" ); //$NON-NLS-1$ - } - catch ( IOException e ) - { - Logger.debug( e ); - } - finally - { - try - { - sw.close( ); - } - catch ( IOException e ) - { - Logger.debug( e ); - } - } - } - - public static synchronized String[] getUserIds( ) - { - JsonObject userObject = loadSourceBindingJson( ); - if ( userObject != null ) - { - String uuid = userObject.getString( "uuid", null ); //$NON-NLS-1$ - if ( uuid != null && uuid.trim( ).length( ) > 0 ) - { - JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ).setValue( "uuid", uuid ); //$NON-NLS-1$ - } - return new String[]{ - userObject.getString( "user", null ), uuid //$NON-NLS-1$ - }; - } - return null; - } - - public static synchronized String getUserUUID( ) - { - JsonObject userObject = loadSourceBindingJson( ); - if ( userObject != null ) - { - String uuid = userObject.getString( "uuid", null ); //$NON-NLS-1$ - if ( uuid != null && uuid.trim( ).length( ) > 0 ) - { - JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ).setValue( "uuid", uuid ); //$NON-NLS-1$ - } - return uuid; - } - return null; - } - - public static synchronized JsonObject updateCount( ) - { - JsonObject userObject = loadSourceBindingJson( ); - if ( userObject != null ) - { - long count = userObject.getLong( "count", 0 ); //$NON-NLS-1$ - count += JavaDecompilerPlugin.getDefault( ).getDecompileCount( ).get( ); - userObject.set( "count", count ); //$NON-NLS-1$ - - long adclick = userObject.getLong( "adclick", 0 ); //$NON-NLS-1$ - adclick += JavaDecompilerPlugin.getDefault( ).getAdClickCount( ).get( ); - userObject.set( "adclick", adclick ); //$NON-NLS-1$ - - saveSourceBindingJson( userObject ); - } - return userObject; - } - - public static JsonObject setUserIpInfo( JsonObject userIpInfo ) - { - JsonObject userObject = loadSourceBindingJson( ); - if ( userObject != null && userIpInfo != null ) - { - JsonValue ip = userIpInfo.get( "ip" ); //$NON-NLS-1$ - if ( ip != null && ip.isString( ) ) - { - if ( "".equals( ip.asString( ) ) ) //$NON-NLS-1$ - { - userObject.remove( "ip" ); //$NON-NLS-1$ - } - else - { - userObject.set( "ip", ip.asString( ) ); //$NON-NLS-1$ - } - } - JsonValue country = userIpInfo.get( "country" ); //$NON-NLS-1$ - if ( country != null && country.isString( ) ) - { - if ( "".equals( country.asString( ) ) ) //$NON-NLS-1$ - { - userObject.remove( "country" ); //$NON-NLS-1$ - } - else - { - userObject.set( "country", country.asString( ) ); //$NON-NLS-1$ - } - } - JsonValue country_code = userIpInfo.get( "country_id" ); //$NON-NLS-1$ - if ( country != null && country.isString( ) ) - { - if ( "".equals( country.asString( ) ) ) //$NON-NLS-1$ - { - userObject.remove( "country_code" ); //$NON-NLS-1$ - } - else - { - userObject.set( "country_code", country_code.asString( ) ); //$NON-NLS-1$ - } - } - JsonValue province = userIpInfo.get( "region" ); //$NON-NLS-1$ - if ( province != null && province.isString( ) ) - { - if ( "".equals( province.asString( ) ) ) //$NON-NLS-1$ - { - userObject.remove( "province" ); //$NON-NLS-1$ - } - else - { - userObject.set( "province", province.asString( ) ); //$NON-NLS-1$ - } - } - JsonValue city = userIpInfo.get( "city" ); //$NON-NLS-1$ - if ( province != null && city.isString( ) ) - { - if ( "".equals( city.asString( ) ) ) //$NON-NLS-1$ - { - userObject.remove( "city" ); //$NON-NLS-1$ - } - else - { - userObject.set( "city", city.asString( ) ); //$NON-NLS-1$ - } - } - saveSourceBindingJson( userObject ); - } - return userObject; - } - - public static String getUserIp( ) - { - JsonObject userObject = loadSourceBindingJson( ); - if ( userObject == null ) - return null; - - JsonValue ipValue = userObject.get( "ip" ); //$NON-NLS-1$ - if ( ipValue != null && ipValue.isString( ) ) - { - return ipValue.asString( ); - } - return null; - } - - public static String getUserProvince( ) - { - JsonObject userObject = loadSourceBindingJson( ); - - if ( userObject == null ) - return null; - - JsonValue provinceValue = userObject.get( "province" ); //$NON-NLS-1$ - if ( provinceValue != null && provinceValue.isString( ) ) - { - return provinceValue.asString( ); - } - - return null; - } - - public static String getUserCity( ) - { - JsonObject userObject = loadSourceBindingJson( ); - - if ( userObject == null ) - return null; - - JsonValue cityValue = userObject.get( "city" ); //$NON-NLS-1$ - if ( cityValue != null && cityValue.isString( ) ) - { - return cityValue.asString( ); - } - - return null; - } - - public static String getUserCountry( ) - { - JsonObject userObject = loadSourceBindingJson( ); - - if ( userObject == null ) - return null; - - JsonValue countryValue = userObject.get( "country" ); //$NON-NLS-1$ - if ( countryValue != null && countryValue.isString( ) ) - { - return countryValue.asString( ); - } - - return null; - } - - public static String getUserCountryCode( ) - { - JsonObject userObject = loadSourceBindingJson( ); - - if ( userObject == null ) - return null; - - JsonValue countryValue = userObject.get( "country_code" ); //$NON-NLS-1$ - if ( countryValue != null && countryValue.isString( ) ) - { - return countryValue.asString( ); - } - - return null; - } - - public static Long getUserCount( ) - { - JsonObject userObject = loadSourceBindingJson( ); - - if ( userObject == null ) - return null; - - JsonValue countValue = userObject.get( "count" ); //$NON-NLS-1$ - if ( countValue != null && countValue.isNumber( ) ) - { - return countValue.asLong( ); - } - - return 0L; - } - - public static Long getAdClickCount( ) - { - JsonObject userObject = loadSourceBindingJson( ); - - if ( userObject == null ) - return null; - - JsonValue adclickValue = userObject.get( "adclick" ); //$NON-NLS-1$ - if ( adclickValue != null && adclickValue.isNumber( ) ) - { - return adclickValue.asLong( ); - } - - return 0L; - } - - public static boolean matchAdCondition( ) - { - int adCondition = 100; - if ( JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ).contains( "adCondition" ) ) //$NON-NLS-1$ - { - adCondition = JavaDecompilerPlugin.getDefault( ).getPreferenceStore( ).getInt( "adCondition" ); //$NON-NLS-1$ - } - if ( UserUtil.getUserCount( ) < 0 ) - return true; - return UserUtil.getUserCount( ) > adCondition; - } - - public static void main( String[] args ) - { - System.out.println( setUserIpInfo( collectUserIp( ) ) ); - } - -} diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/VersionUtil.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/VersionUtil.java index 03b6a821..eea3b721 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/VersionUtil.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/VersionUtil.java @@ -1,12 +1,9 @@ /******************************************************************************* - * Copyright (c) 2017 Chen Chao(cnfree2000@hotmail.com). + * Copyright (c) 2017 Chen Chao and other ECD project contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Chen Chao - initial API and implementation + * https://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.sf.feeling.decompiler.util; @@ -16,28 +13,22 @@ import org.eclipse.core.runtime.Platform; import org.eclipse.equinox.p2.metadata.Version; -public class VersionUtil -{ +public class VersionUtil { - public static Version getFeatureVersion( String featureId ) - { - for ( IBundleGroupProvider provider : Platform.getBundleGroupProviders( ) ) - { - for ( IBundleGroup feature : provider.getBundleGroups( ) ) - { - if ( feature.getIdentifier( ).equals( featureId ) ) - return Version.create( feature.getVersion( ) ); + public static Version getFeatureVersion(String featureId) { + for (IBundleGroupProvider provider : Platform.getBundleGroupProviders()) { + for (IBundleGroup feature : provider.getBundleGroups()) { + if (feature.getIdentifier().equals(featureId)) + return Version.create(feature.getVersion()); } } return null; } - public static String getDecompilerVersion( ) - { - Version installVersion = VersionUtil.getFeatureVersion( "org.sf.feeling.decompiler" ); //$NON-NLS-1$ - if ( installVersion != null ) - { - return installVersion.toString( ); + public static String getDecompilerVersion() { + Version installVersion = VersionUtil.getFeatureVersion("org.sf.feeling.decompiler"); //$NON-NLS-1$ + if (installVersion != null) { + return installVersion.toString(); } return null; } diff --git a/pom.xml b/pom.xml new file mode 100644 index 00000000..74804a8d --- /dev/null +++ b/pom.xml @@ -0,0 +1,144 @@ + + 4.0.0 + com.github.ecd-plugin + com.github.ecd-plugin.ecd + 3.5.1 + pom + com.github.ecd-plugin.ecd + https://github.com/ecd-plugin/ecd + + UTF-8 + 2.7.5 + 3.5.0 + true + + + org.sf.feeling.decompiler + org.sf.feeling.decompiler.feature + org.sf.feeling.decompiler.cfr + org.sf.feeling.decompiler.cfr.feature + org.sf.feeling.decompiler.jd + org.sf.feeling.decompiler.jd.feature + org.sf.feeling.decompiler.procyon + org.sf.feeling.decompiler.procyon.feature + org.sf.feeling.decompiler.fernflower + org.sf.feeling.decompiler.fernflower.feature + org.sf.feeling.decompiler.vineflower + org.sf.feeling.decompiler.vineflower.feature + update_site + + + + + + org.eclipse.tycho + tycho-p2-director-plugin + ${tycho.version} + + + + + + maven-compiler-plugin + 3.11.0 + + 1.8 + 1.8 + + + + org.eclipse.tycho + tycho-compiler-plugin + ${tycho.version} + + + org.eclipse.tycho + tycho-maven-plugin + ${tycho.version} + true + + + org.eclipse.tycho + target-platform-configuration + ${tycho.version} + + + + + win32 + win32 + x86 + + + win32 + win32 + x86_64 + + + + linux + gtk + x86 + + + linux + gtk + x86_64 + + + + macosx + cocoa + x86 + + + macosx + cocoa + x86_64 + + + macosx + cocoa + arm64 + + + + + + org.apache.maven.plugins + maven-jarsigner-plugin + 3.0.0 + + ${signing.keystore} + ecd + ${signing.password} + ${signing.password} + true + true + + + + sign + + sign + + + ${signing.disabled} + + + + + + + + + eclipse-photon + p2 + https://download.eclipse.org/releases/photon/ + + + intellij + https://www.jetbrains.com/intellij-repository/releases/ + + + diff --git a/update-version.cmd b/update-version.cmd new file mode 100644 index 00000000..d7e3f0c3 --- /dev/null +++ b/update-version.cmd @@ -0,0 +1,22 @@ +@Echo off +REM This script is used for updating the version of the whole plugin. +REM +REM Usage: ./update-version.sh VERSION +REM Example: ./update-version.sh 3.1.0-SNAPSHOT + +REM Note that automatically updating the version only works when the versions +REM in the files have not been manually edited and actually match the current +REM version. + +SET VERSION="%*" + +if "%~1"=="" goto blank + +call mvn org.eclipse.tycho:tycho-versions-plugin:4.0.6:set-version -DnewVersion="%VERSION%" -Dtycho.mode=maven +call mvn org.eclipse.tycho:tycho-versions-plugin:4.0.6:update-eclipse-metadata -DnewVersion="%VERSION%" -Dtycho.mode=maven +goto end + +:blank +echo "update-version.cmd VERSION" + +:end \ No newline at end of file diff --git a/update-version.sh b/update-version.sh new file mode 100755 index 00000000..9ec39cf0 --- /dev/null +++ b/update-version.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env sh + +# This script is used for updating the version of the whole plugin. +# +# Usage: ./update-version.sh VERSION +# Example: ./update-version.sh 3.1.0-SNAPSHOT + +# Note that automatically updating the version only works when the versions +# in the files have not been manually edited and actually match the current +# version. + + +VERSION="$*" + +if [ -z "$VERSION" ]; then + echo "update-version.sh VERSION" + exit 1 +fi + +mvn org.eclipse.tycho:tycho-versions-plugin:4.0.6:set-version -DnewVersion="$VERSION" -Dtycho.mode=maven +mvn org.eclipse.tycho:tycho-versions-plugin:4.0.6:update-eclipse-metadata -DnewVersion="$VERSION" -Dtycho.mode=maven diff --git a/org.sf.feeling.decompiler.updatesite/.project b/update_site/.project similarity index 95% rename from org.sf.feeling.decompiler.updatesite/.project rename to update_site/.project index 712a305d..e87b530e 100644 --- a/org.sf.feeling.decompiler.updatesite/.project +++ b/update_site/.project @@ -1,17 +1,17 @@ - - - org.sf.feeling.decompiler.updatesite - - - - - - org.eclipse.pde.UpdateSiteBuilder - - - - - - org.eclipse.pde.UpdateSiteNature - - + + + org.sf.feeling.decompiler.updatesite + + + + + + org.eclipse.pde.UpdateSiteBuilder + + + + + + org.eclipse.pde.UpdateSiteNature + + diff --git a/update_site/category.xml b/update_site/category.xml new file mode 100644 index 00000000..48e11f35 --- /dev/null +++ b/update_site/category.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/update_site/pom.xml b/update_site/pom.xml new file mode 100644 index 00000000..1f743541 --- /dev/null +++ b/update_site/pom.xml @@ -0,0 +1,14 @@ + + 4.0.0 + + + com.github.ecd-plugin + com.github.ecd-plugin.ecd + 3.5.1 + ../pom.xml + + + com.github.ecd-plugin.update + eclipse-repository +