My latest "wow" moment

I developed an annotation for use in Struts2 the other day that basically performed EJB3-like dependency injection (it looks up objects in JNDI and injects them into the action).


I opened my action after everything was done, and sadly realized that IDEA was now going to show warnings for every field I used this annotation on ("Private field 'loginEjb' is never assigned"). However, I saw there was an intention available. I was amazed to find an "Add annotion to list of dependency injection annotations" intention. Sure enough, I ran the inspection and the warning disappeared. It was awesome!

However, since then, I renamed (through refactoring, of course), my annotation (went from Jndi to JndiLookup). I'm now getting the warnings again, and this time the inspection is not available. And, I was never able to find the actual intention or inspection to see what the values were. Does anyone know where I can add my "new" annotation to get rid of this warning again?

Thanks,
Tobin

6 comments

Ok, allow me to answer my own question.

It's the Unused Symbol inspection, under the General section (found by searching all the preference files, don't know why I didn't do this before posting my question).

The reason I couldn't get the inspection to pop up was that I was trying to run it on the annotation name, I needed to be on the actual variable name.

However, it does appear that renaming or moving classes does not update the inspection settings. It's a small thing, really, but here's the JIRA: http://www.jetbrains.net/jira/browse/IDEA-12202

Tobin

0

I requested this inspection setting when working with JBoss Seam for the @In annotation.
Glad, that it helps you, too ;)

Probably it's much more common to have the annotation in some external jar, so your situation is quite rare. Still of course it should be handled correctly.

Now if I could have the same setting for "outjection" using Seam's @Out...

0

Well thank you for a fantastic feature suggestion (and to the JetBrains guys/girls for implementing it).

0

Neat. It looks like the list of standard annotations is actually programmatically modifiable, so that someone looking to write a injection container support plugin (e.g. for Seam, Tapestry, Guice), could simply make that work automatically. Shiny.

--Dave Griffith

0

Hello Dave,

Neat. It looks like the list of standard annotations is actually
programmatically modifiable, so that someone looking to write a
injection container support plugin (e.g. for Seam, Tapestry, Guice),
could simply make that work automatically. Shiny.

--Dave Griffith


Dave, do you perhaps have a reference to some API/class for this?

Regards,
-tt


0

com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection.INJECTED_ANNOS and STANDARD_INJECTION_ANNOS.

Caveats: I haven't tried it. It looks way flimsier than most of the OpenAPI, and I sincerely doubt the JetBrains would support it. If anyone tries it, please let me know if it works.

--Dave Griffith

0

Please sign in to leave a comment.