-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
49 additions
and
60 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<idea-plugin> | ||
<id>com.i5mc.idea.decompiler.cfr</id> | ||
<name>CFR Decompiler</name> | ||
<version>1.4</version> | ||
<version>1.4.4</version> | ||
<vendor email="[email protected]" url="http://www.i5mc.com">i5mc</vendor> | ||
|
||
<description> | ||
|
@@ -10,6 +10,7 @@ | |
</description> | ||
|
||
<change-notes> | ||
- 2019-05-16 UPDATE CFR-0.144. YOU ARE (NOT) HAPPY. | ||
- 2019-03-21 UPDATE CFR-0.140. LIFE IS ALWAYS SO HARD. | ||
- 2018-07-26 UPDATE CFR_132. LIFE IS GETTING WORSE:( | ||
- 2017-10-14 UPDATE CFR_123. HAPPY BIRTHDAY TO MYSELF:) | ||
|
@@ -22,6 +23,6 @@ | |
<idea-version since-build="145.0"/> | ||
|
||
<extensions defaultExtensionNs="com.intellij"> | ||
<psi.classFileDecompiler implementation="com.i5mc.idea.decompiler.MyDecompiler"/> | ||
<psi.classFileDecompiler implementation="com.i5mc.idea.decompiler.CFRDecompiler"/> | ||
</extensions> | ||
</idea-plugin> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.i5mc.idea.decompiler; | ||
|
||
import org.benf.cfr.reader.PluginRunner; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class CFR { | ||
|
||
private static final Map<String, String> OPTIONS = new HashMap<>(); | ||
|
||
static { | ||
OPTIONS.put("comments", "false"); | ||
OPTIONS.put("hideutf", "false"); | ||
} | ||
|
||
private static String decompile(String path) { | ||
PluginRunner r = new PluginRunner(OPTIONS); | ||
r.addJarPath(path); | ||
return r.getDecompilationFor(path); | ||
} | ||
|
||
private static String decompileWithJar(String path) { | ||
int i = path.lastIndexOf("!/");// filesystem path can contain ! but java can not | ||
if (i == -1) throw new IllegalArgumentException(); | ||
PluginRunner r = new PluginRunner(OPTIONS); | ||
String head = path.substring(0, i); | ||
r.addJarPath(head); | ||
String tail = path.substring(i + 2, path.length() - 6); | ||
return r.getDecompilationFor(tail); | ||
} | ||
|
||
public static String decompile(String protocol, String path) { | ||
switch (protocol) { | ||
case "jar": | ||
return decompileWithJar(path); | ||
case "file": | ||
return decompile(path); | ||
default: | ||
throw new IllegalStateException(String.format("Unknown protocol %s", protocol)); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.