-
-
Notifications
You must be signed in to change notification settings - Fork 352
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
refactor: add support for malformed files through inheritance #3668
Conversation
…he whole analysis for one malformed file
Not sure we want to silence so many errors. What we can do instead is wrapping this call in a method that can be overridden, such that you create your own SilencingJDTCompiler (see extension point in Launcher). |
That sounds like a good option. I tried to look on how to provide to a Launcher your own Another one would be to add an option (e.g. "silenceParseErrors", or something like that) that silences the error only if the user explicitly asks for it: try {
consumer.accept(unit);
} catch (Exception e) {
if(!silenceParseErrors){
throw e;
}
// log the error and continue parsing files.
} Thanks for the help. |
In Spoon, for rare use cases, we avoid binary switches, because they are are hard to test and maintain. |
Ok thanks for the info. I'll try to implement the solution you mentioned. |
I made the modifications we discussed and also added an overridable method in Launcher that creates the compiler object which should allow users to instatiate their own compiler that overrides the visiting the of CUDs. |
Thanks a lot, this refactoring is good, will merge. |
Thanks a lot @darius-sas |
Thank you! |
A common issue that I get while analysing big projects is that the analysis fails just because a few files contain issues, or special characters that are not allowed by the Java compiler: like for example archetype resource files:
This very simple modification ensures that Spoon provides a best-effort attempt at parsing a certain project without failing just because of one malformed file. In case an error occurs, a message is printed on the console, so the user is notified.
I am not very practical of Spoon's internals, so there might be better solutions to this. If that's the case, pointers on how to implement a better one are welcome :)