diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/ResourceListPane.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/ResourceListPane.java index 6944252d9..c466b2204 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/ResourceListPane.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/ResourceListPane.java @@ -356,7 +356,7 @@ public void openPath(TreePath path) } //display via name - BytecodeViewer.viewer.workPane.addClassResource(container, name); + BytecodeViewer.viewer.workPane.addClassResource(container, name.substring(0, name.length() - ".class".length())); } catch (Exception e) { diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/util/BytecodeViewPanelUpdater.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/util/BytecodeViewPanelUpdater.java index 3e39cd938..ab5b272eb 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/util/BytecodeViewPanelUpdater.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/util/BytecodeViewPanelUpdater.java @@ -110,12 +110,18 @@ public void processDisplay() else { final Decompiler decompiler = bytecodeViewPanel.decompiler; - final String workingDecompilerName = viewer.resource.workingName + "-" + decompiler.getDecompilerName(); + String decompilerName = decompiler.getDecompilerName(); + final String workingDecompilerName = viewer.resource.workingName + "-" + decompilerName; //perform decompiling inside of this thread final String decompiledSource = decompiler.getDecompiler().decompileClassNode(viewer.resource.getResourceClassNode(), classBytes); - ClassFileContainer container = new ClassFileContainer(workingDecompilerName, decompiledSource, viewer.resource.container); + ClassFileContainer container = new ClassFileContainer( + viewer.resource.workingName, + decompilerName, + decompiledSource, + viewer.resource.container + ); if (!BytecodeViewer.viewer.workPane.classFiles.containsKey(workingDecompilerName)) { diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/resources/classcontainer/ClassFileContainer.java b/src/main/java/the/bytecode/club/bytecodeviewer/resources/classcontainer/ClassFileContainer.java index f70beeebd..0eed4c577 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/classcontainer/ClassFileContainer.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/resources/classcontainer/ClassFileContainer.java @@ -1,6 +1,7 @@ package the.bytecode.club.bytecodeviewer.resources.classcontainer; -import com.github.javaparser.*; +import com.github.javaparser.JavaParser; +import com.github.javaparser.ParseResult; import com.github.javaparser.ast.CompilationUnit; import com.github.javaparser.resolution.TypeSolver; import com.github.javaparser.symbolsolver.JavaSymbolSolver; @@ -12,7 +13,6 @@ import the.bytecode.club.bytecodeviewer.resources.classcontainer.locations.*; import the.bytecode.club.bytecodeviewer.resources.classcontainer.parser.visitors.MyVoidVisitor; -import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.NavigableMap; @@ -27,6 +27,7 @@ */ public class ClassFileContainer { + public transient NavigableMap> fieldMembers = new TreeMap<>(); public transient NavigableMap> methodParameterMembers = new TreeMap<>(); public transient NavigableMap> methodLocalMembers = new TreeMap<>(); @@ -35,13 +36,15 @@ public class ClassFileContainer public boolean hasBeenParsed = false; public final String className; + public final String decompiler; private final String content; private final String parentContainer; private final String path; - public ClassFileContainer(String className, String content, ResourceContainer resourceContainer) + public ClassFileContainer(String className, String decompiler, String content, ResourceContainer resourceContainer) { this.className = className; + this.decompiler = decompiler; this.content = content; this.parentContainer = resourceContainer.name; this.path = resourceContainer.file.getAbsolutePath(); @@ -95,15 +98,19 @@ public boolean shouldParse() public String getName() { - if (this.className.contains("/")) - return this.className.substring(this.className.lastIndexOf('/') + 1, this.className.lastIndexOf('.')); - else - return this.className.substring(0, this.className.lastIndexOf('.')); + int from = className.lastIndexOf('/') + 1; + + int until = className.lastIndexOf('.'); + if (until == -1 || until < from) { + until = className.length(); + } + + return className.substring(from, until); } public String getDecompiler() { - return this.className.substring(this.className.lastIndexOf('-') + 1); + return decompiler; } public String getParentContainer() diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/MethodCallSearch.java b/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/MethodCallSearch.java index d57bd78e5..2f79b6e9c 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/MethodCallSearch.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/searching/impl/MethodCallSearch.java @@ -91,8 +91,6 @@ public JPanel getPanel() @Override public void search(ResourceContainer container, String resourceWorkingName, ClassNode node, boolean exact) { - final Iterator methods = node.methods.iterator(); - String searchOwner = mOwner.getText(); if (searchOwner.isEmpty()) searchOwner = null; @@ -105,6 +103,11 @@ public void search(ResourceContainer container, String resourceWorkingName, Clas if (searchDesc.isEmpty()) searchDesc = null; + if (searchName == null && searchOwner == null && searchDesc == null) + return; + + final Iterator methods = node.methods.iterator(); + while (methods.hasNext()) { final MethodNode method = methods.next(); @@ -116,9 +119,6 @@ public void search(ResourceContainer container, String resourceWorkingName, Clas { final MethodInsnNode min = (MethodInsnNode) insnNode; - if (searchName == null && searchOwner == null && searchDesc == null) - continue; - if (exact) { if (searchName != null && !searchName.equals(min.name))