Skip to content

Commit

Permalink
cfr-0.144
Browse files Browse the repository at this point in the history
  • Loading branch information
caoli5288 committed May 16, 2019
1 parent 2fd1164 commit eca71cd
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 60 deletions.
Binary file renamed lib/cfr-0.140.jar → lib/cfr-0.144.jar
Binary file not shown.
5 changes: 3 additions & 2 deletions resources/META-INF/plugin.xml
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>
Expand All @@ -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:)
Expand All @@ -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>
44 changes: 44 additions & 0 deletions src/com/i5mc/idea/decompiler/CFR.java
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));
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import com.intellij.psi.PsiPackage
import com.intellij.psi.compiled.ClassFileDecompilers
import com.intellij.psi.impl.compiled.ClsFileImpl

class MyDecompiler : ClassFileDecompilers.Light() {
class CFRDecompiler : ClassFileDecompilers.Light() {

override fun accepts(input: VirtualFile): Boolean = true

override fun getText(input: VirtualFile): CharSequence {
if (PsiPackage.PACKAGE_INFO_CLS_FILE == input.name || PsiJavaModule.MODULE_INFO_CLS_FILE == input.name) {
return ClsFileImpl.decompile(input)
}
return Impl.decompile(input.fileSystem.protocol, input.path)
return CFR.decompile(input.fileSystem.protocol, input.path)
}

}
56 changes: 0 additions & 56 deletions src/com/i5mc/idea/decompiler/Impl.java

This file was deleted.

0 comments on commit eca71cd

Please sign in to comment.