Private field is never assigned....... but it is!!

with intellij idea community
I have a class where I do define:

@Inject @Any private Event<BootstrapData> bootstrapDataEvent;

and I use it.
But at the definition line the variable is marked as never assigned "Private field bootstrapDataEvent is never assigned".

I notice that the same happens with other @Inject variables.

How can I make those variables marked as used, please?


Comment actions Permalink

nikolaus wrote:
How can I make those variables marked as used, please?

With your cursor on the field name (i.e. bootstrapDataEvent), type Alt + Enter (Windows) or   (Mac)  . From the popup, select the "Suppress for fields annotated by ''".

If that option does not show, arrow down to the "Create Setter" option and hit the right arrow. On the side menu select "Edit inspection profile setting". That will open the Inspections Configuration dialog, with the "Unused  symbol" inspection selected. Click the "Configure annotations..." button and add your annotation.

Comment actions Permalink

This works but it seems like something that IntelliJ should do automatically for things like CDI and JPA.


Please sign in to leave a comment.