parse = parser.parse(this.content);
+ if (!parse.isSuccessful())
+ {
+ System.err.println("Failed to parse: " + this.getName());
+ parse.getProblems().forEach(System.out::println);
+ return false;
+ }
+
+ CompilationUnit compilationUnit = parse.getResult().orElse(null);
+ if (compilationUnit == null)
+ return false;
+
compilationUnit.accept(new MyVoidVisitor(this, compilationUnit), null);
return true;
}
@@ -67,11 +79,6 @@ public class ClassFileContainer
{
throw new RuntimeException(e);
}
- catch (Exception e)
- {
- System.err.println("Parsing error: " + className);
- e.printStackTrace();
- }
return false;
}
@@ -88,7 +95,10 @@ public class ClassFileContainer
public String getName()
{
- return this.className.substring(this.className.lastIndexOf('/') + 1, this.className.lastIndexOf('.'));
+ if (this.className.contains("/"))
+ return this.className.substring(this.className.lastIndexOf('/') + 1, this.className.lastIndexOf('.'));
+ else
+ return this.className.substring(0, this.className.lastIndexOf('.'));
}
public String getDecompiler()
diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/resources/classcontainer/parser/MyVoidVisitor.java b/src/main/java/the/bytecode/club/bytecodeviewer/resources/classcontainer/parser/MyVoidVisitor.java
deleted file mode 100644
index b5b25283..00000000
--- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/classcontainer/parser/MyVoidVisitor.java
+++ /dev/null
@@ -1,1719 +0,0 @@
-package the.bytecode.club.bytecodeviewer.resources.classcontainer.parser;
-
-import com.github.javaparser.Range;
-import com.github.javaparser.ast.CompilationUnit;
-import com.github.javaparser.ast.NodeList;
-import com.github.javaparser.ast.body.*;
-import com.github.javaparser.ast.expr.*;
-import com.github.javaparser.ast.stmt.*;
-import com.github.javaparser.ast.type.ClassOrInterfaceType;
-import com.github.javaparser.ast.visitor.VoidVisitorAdapter;
-import com.github.javaparser.resolution.UnsolvedSymbolException;
-import com.github.javaparser.resolution.declarations.ResolvedConstructorDeclaration;
-import com.github.javaparser.resolution.declarations.ResolvedMethodDeclaration;
-import com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration;
-import com.github.javaparser.resolution.declarations.ResolvedValueDeclaration;
-import com.github.javaparser.resolution.types.ResolvedType;
-import the.bytecode.club.bytecodeviewer.resources.classcontainer.ClassFileContainer;
-import the.bytecode.club.bytecodeviewer.resources.classcontainer.locations.*;
-
-/**
- * Our custom visitor that allows us to get the information from JavaParser we need.
- *
- * Created by Bl3nd.
- * Date: 9/5/2024
- */
-@SuppressWarnings("OptionalGetWithoutIsPresent")
-public class MyVoidVisitor extends VoidVisitorAdapter