-
Notifications
You must be signed in to change notification settings - Fork 917
Avoid exception when tree parameter is null #2865
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
Conversation
|
This is not the correct solution. I will re-work it. |
|
Would it be possible to also write a test for the change ? |
|
There is one already actually, it's in org.netbeans.modules.java.source.save.FormatingTest in the "Java Source Base" module. At the moment it crashes and with my incorrect solution in this PR is doesn't crash but it fails(!). But I have got it to pass now. |
|
I've re-done it now so the individual test passes. However there are some other tests in the same 'FormatingTest' file which fail (they did before and still do). I haven't studied each one thoroughly but for example one is the formatting for switch expressions (using arrow syntax). Here the syntax tree passed to the reformatter contains elements described as "(ERROR)" - I assume these are because I am using JDK 11 which doesn't have switch expressions. Is there a way to skip tests based on the JDK used (or another way to fix, or actually do you want them to stay as failures)? Thanks! |
|
It is possible, though, to run it without nb-javac and I believe it does make sense to test the code without as the users might be running NB without nb-javac. |
|
I don't think But it should rather do something like: As |
|
@jlahoda is your recommendation to drop this PR altogether and modify TreeShims.java instead? That looks straightforward for me to do. |
|
I've implemented it the way that @jlahoda suggested, please see master...pedro-w:ALT-NETBEANS-4569 . Is that a better fix than this one? |
This can happen when parsing the default: branch of a switch. Previous code caused a NPE when reformatting code in the editor.
|
since NetBeans 13 uses javac 17 as new baseline, this fix is no longer needed as far as I see. Most of TreesShims is now a comment (which should be probably removed some time in future). If any of the participants here think otherwise, feel free to reopen. |
This will happen when scanning the default: clause of a switch block.
This PR is intended to fix NETBEANS-4569