New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SymbolSolver is unable to .resolve() #1943
Comments
So apparently The old fashioned way works:
It is still weird that it works when checking raw source files and it does not work when checking a JAR file. Is this intended behaviour? |
Maybe @ftomassetti knows. |
I am using the |
Are you setting the symbol solver before parsing? |
the problem seems to be that typesolver is not injected in the nodes |
Yes, since my file is ruff spaghetti code, I am very confident that I setup the SymbolSolver before reading any of the source code file. The file looks like this:
|
I should really get into streams. The code is embarrassing :D |
I probably should explain it a little bit, so that it might be more helpful when it comes to help figure out what went wrong. The input is a path to a folder containing source files or a JAR file. |
I know this is a complex issue (and I probably could have made a better job at preseting it), but did you have the time to read into it yet? @ftomassetti |
Sorry, I'm busy trying to get JDK12 support in, and @ftomassetti is drowning in work. Can it be that SourceZip gets a configuration where you don't set the symbol solver? |
No problem. Ah, indeed. SourceZip has its own ParserConfiguration and requires the TypeSolver to be set. I thought it would always just take the statically set TypeSolver, but I guess SourceZip is older than the newest
|
Nah, the static configuration is for the static methods. Every instance gets its own configuration. It's kind of confusing, so the plan is to remove all the static methods soon. |
I have the same problem, except I am not using
and here is the calling code:
I get the following exception:
|
@TheeNinja the crucial part is how you do the parsing, which is not in your report. The error simply means that the solver is not set in the configuration the parser is using. |
I am getting my "generic" compilation unit through |
I do think it does not clone all |
Oh yeah! Let's fix this one. |
Hi everybody, I am having the same problem to solve symbols with sources that are in jar file. I am using the javaparser/symbolsolver v.3.13.3 and the problem still continues. When the program executes the ".resolve()", it yelds a UnsolvedSymbolException, even loading the sources previously using JarTypeSolver. Does anybody already have a solution? |
Well, the solution for me was to set the SymbolSolver on the ParserConfiguration and pass it on to SourceZip (or another instance that consumes ParserConfiguration). Did you set it? |
Sorry, but I think that I did not understand exactly how the SourceZip works.
Where should I put the mentioned SourceZip code snippet in this code and how I use it later to ".resolve()"? |
SourceZip is a class that allows you to read in all the source files from a JAR or ZIP file. I used it in my program to read in the source code. You probably use another class to help you parse the source code. So you have to provide the Configuration to that instead, not As far as I understood: The ParserConfiguration object gets passed into each Node, which then gets used by |
I have use the JarTypeSolver class to read source codes inside jar files. If I am not mistaken, I have worked with this class and it has worked fine - using also a static parser - but it is not working now. The code below shows the part that I need use the ".resolve()" to solve the method called to get information about its package, class, etc.
|
Are you using |
Sorry, I forgot to tell you how I call the parser in the code. See it now.
|
Did you try |
Yes. Unfortunately it did not work.
|
Hm, then I have no idea. Maybe the developers can help you with this one. Maybe create a new issue since this seems to be a bit different from mine. And mine got already solved. Since then they changed some stuff, so maybe something broke along the way. |
Ok, thank you very much.
|
No Problem :) |
I also meet this error。I resolved this problem finally。 because code has a complie error, when i fix this error, is work well。 if anyone meet this problem,review that |
Hello,
i am trying to find the fully qualified name of interface
main.MyInterface<E>
that is being implemented in classmain.MyClass<E>
.Sadly, this yields me an exception:
I am setting a SymbolSolver before I start running
.resolve()
:I also double checked without the generic types and it always yields the same exception. Same issue with extending from classes.
Am I doing something wrong or why does this not work as intended?
I just updated to the 3.7.1 (from 3.6.23) and now the exception is now this:
Since this did work before and only started to fail recently, I double checked what I did differently. And it turns out that I previously was using a path to a source folder (
JavaParserTypeSolver
). Now I am trying to read a JAR file and therefore use theJarTypeSolver
, but it does not seem to work with that one. Whats going on here?The text was updated successfully, but these errors were encountered: