Ignore inspection on @FXML annotated fields (and how to find inspection)

Answered

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.

0
3 comments

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.

0
Avatar
Permanently deleted user

Thanks for replying Andrey, 

the options I'm getting are different: 

Still, the inspections link was available under "Create setter" - not too intuitive but it's good to know this options exists!  

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. 

0

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.

0

Please sign in to leave a comment.