Ignore inspection on @FXML annotated fields (and how to find inspection)
I'm using IntelliJ 2016.3.1, and all private fields annotated with @FXML are marked by an inspection saying "Private field 'fieldName' is never assigned". Of course, the @FXML annotation means it will be injected, so I want to disable this. The context menu has an option "Suppress for fields annotated with java.fxml.FXML", but clicking it does nothing.
I have tried looking for the inspection in the settings, but I can't seen to find it - searching for "Private field never assigned" gives no results.
So my questions are:
1. How can I disable this inspection for fields with this annotation?
2. Will IntelliJ have default option to ignore fields with this annotation? Seems reasonable.
3. In general, how can I find the inspection in the settings given its message? It seems reasonable there should be a way, but I couldn't find any. Maybe have an option in the context-menu to go to the inspection in the settings window?
Thanks,
Itai.
Please sign in to leave a comment.
You can open the inspection settings from the inspection configuration sub-menu:
there, please add FXML annotation as an entry point for the inspection by clicking Annotations... button:
>2. Will IntelliJ have default option to ignore fields with this annotation? Seems reasonable.
Could you please file a request at https://youtrack.jetbrains.com/issues/IDEA with the sample code. Thanks.
Thanks for replying Andrey,
the options I'm getting are different:
Adding the annotation there does solve the problem. Should I file a bug about the context-menu option not working?
I will file a request for making this default, thanks for the link.
Looks like this is bug: https://youtrack.jetbrains.com/issue/IDEA-164948 Fixed in IDEA 2017.1 version. Please as a workaround try adding this annotation in configuration of Unused declaration inspection.