11package the .bytecode .club .bytecodeviewer .resources .classcontainer ;
22
3- import com .github .javaparser .StaticJavaParser ;
3+ import com .github .javaparser .* ;
44import com .github .javaparser .ast .CompilationUnit ;
55import com .github .javaparser .resolution .TypeSolver ;
66import com .github .javaparser .symbolsolver .JavaSymbolSolver ;
1010import the .bytecode .club .bytecodeviewer .decompilers .Decompiler ;
1111import the .bytecode .club .bytecodeviewer .resources .ResourceContainer ;
1212import 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
1515import java .io .IOException ;
1616import 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