Skip to content

Commit 3f1fd5a

Browse files
committed
2 parents 879b5e6 + 14c7ed2 commit 3f1fd5a

File tree

12 files changed

+2296
-1733
lines changed

12 files changed

+2296
-1733
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<treelayout.version>1.0.3</treelayout.version>
5252
<webp-imageio.version>a8f700b</webp-imageio.version>
5353
<xpp3.version>1.1.4c</xpp3.version>
54-
<java-parser.version>3.26.1</java-parser.version>
54+
<java-parser.version>3.26.2</java-parser.version>
5555
<taskmanager.version>1.0.1</taskmanager.version>
5656
<google-java-format.version>1.7</google-java-format.version> <!-- Newer versions require Java 11+ -->
5757
<disk-lib.version>1.2.0</disk-lib.version>

src/main/java/the/bytecode/club/bytecodeviewer/gui/components/actions/GoToAction.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public void actionPerformed(ActionEvent e)
127127
}
128128
else
129129
{
130-
methods.stream().filter(classMethodLocation -> classMethodLocation.owner.equals(method.owner)).forEach(classMethodLocation ->
130+
methods.stream().filter(classMethodLocation -> classMethodLocation.signature.equals(method.signature)).forEach(classMethodLocation ->
131131
{
132132
if (classMethodLocation.decRef.equalsIgnoreCase("declaration"))
133133
{
@@ -211,7 +211,9 @@ else if (method)
211211
if (packagePath.startsWith("java") || packagePath.startsWith("javax") || packagePath.startsWith("com.sun"))
212212
return null;
213213

214-
String resourceName = packagePath + "/" + classMethodLocation.owner;
214+
String resourceName = classMethodLocation.owner;
215+
if (!packagePath.isEmpty())
216+
resourceName = packagePath + "/" + classMethodLocation.owner;
215217

216218
if (resourceContainer.resourceClasses.containsKey(resourceName))
217219
{
@@ -229,7 +231,11 @@ else if (method)
229231
if (packagePath.startsWith("java") || packagePath.startsWith("javax") || packagePath.startsWith("com.sun"))
230232
return null;
231233

232-
String resourceName = packagePath + "/" + lexeme;
234+
String resourceName = lexeme;
235+
if (!packagePath.isEmpty())
236+
{
237+
resourceName = packagePath + "/" + lexeme;
238+
}
233239

234240
if (resourceContainer.resourceClasses.containsKey(resourceName))
235241
{

src/main/java/the/bytecode/club/bytecodeviewer/resources/classcontainer/ClassFileContainer.java

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package the.bytecode.club.bytecodeviewer.resources.classcontainer;
22

3-
import com.github.javaparser.StaticJavaParser;
3+
import com.github.javaparser.*;
44
import com.github.javaparser.ast.CompilationUnit;
55
import com.github.javaparser.resolution.TypeSolver;
66
import com.github.javaparser.symbolsolver.JavaSymbolSolver;
@@ -10,7 +10,7 @@
1010
import the.bytecode.club.bytecodeviewer.decompilers.Decompiler;
1111
import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
1212
import the.bytecode.club.bytecodeviewer.resources.classcontainer.locations.*;
13-
import the.bytecode.club.bytecodeviewer.resources.classcontainer.parser.MyVoidVisitor;
13+
import the.bytecode.club.bytecodeviewer.resources.classcontainer.parser.visitors.MyVoidVisitor;
1414

1515
import java.io.IOException;
1616
import java.util.ArrayList;
@@ -57,8 +57,20 @@ public boolean parse()
5757
if (shouldParse())
5858
{
5959
TypeSolver typeSolver = new CombinedTypeSolver(new ReflectionTypeSolver(false), new JarTypeSolver(path));
60-
StaticJavaParser.getParserConfiguration().setSymbolResolver(new JavaSymbolSolver(typeSolver));
61-
CompilationUnit compilationUnit = StaticJavaParser.parse(this.content);
60+
JavaParser parser = new JavaParser();
61+
parser.getParserConfiguration().setSymbolResolver(new JavaSymbolSolver(typeSolver));
62+
ParseResult<CompilationUnit> parse = parser.parse(this.content);
63+
if (!parse.isSuccessful())
64+
{
65+
System.err.println("Failed to parse: " + this.getName());
66+
parse.getProblems().forEach(System.out::println);
67+
return false;
68+
}
69+
70+
CompilationUnit compilationUnit = parse.getResult().orElse(null);
71+
if (compilationUnit == null)
72+
return false;
73+
6274
compilationUnit.accept(new MyVoidVisitor(this, compilationUnit), null);
6375
return true;
6476
}
@@ -67,11 +79,6 @@ public boolean parse()
6779
{
6880
throw new RuntimeException(e);
6981
}
70-
catch (Exception e)
71-
{
72-
System.err.println("Parsing error: " + className);
73-
e.printStackTrace();
74-
}
7582

7683
return false;
7784
}
@@ -88,7 +95,10 @@ public boolean shouldParse()
8895

8996
public String getName()
9097
{
91-
return this.className.substring(this.className.lastIndexOf('/') + 1, this.className.lastIndexOf('.'));
98+
if (this.className.contains("/"))
99+
return this.className.substring(this.className.lastIndexOf('/') + 1, this.className.lastIndexOf('.'));
100+
else
101+
return this.className.substring(0, this.className.lastIndexOf('.'));
92102
}
93103

94104
public String getDecompiler()

0 commit comments

Comments
 (0)