Custom Inspection for missing annotation


We have some classes that require a specific custom annotation, based on their class name. I wanted to add a custom inspections that triggers a warning, whenever this annotation is missing from such a class. Is this possible with the Structural search approach? I couldn't find any examples that search for missinb attributes, only for existing ones and then doing some validation on them. Or would this require the approach with a custom plugin?

1 comment
Comment actions Permalink

Hi, you could use Structural search for this.
There is a Count filter that can specify the number of occurrences:

You could also click the wrench icon in this dialog, check the Existing Templates -> Not annotation methods to know how to use it.

An example for your use cases


Please sign in to leave a comment.