Search code examples
javaintellij-ideaannotations

How to find Processor class of an annotation in Intellij IDEA?


Given a Java annotation, how can I jump to its Processor class (class extending the AbstractProcessor interface) in Intellij IDEA?

I tried full text search and find usage in project and libraries in Intellij IDEA, that is not working.


Solution

  • Intellij Idea doesn't have something like find AnnotationProcessor for Annotation.

    But you can do a two stage search.

    First go to AbstractProcessor class, put the cursor on the classname and open Find usage setting dialog (don't know the default keyboard shortcut). Just use Ctrl+Shift+a and type find usage setting.

    Select Derived classes only and Project and Libraries: enter image description here

    The search result should find every annotation processor in your project and project libraries.

    After that, you open the processed annotation and put your cursor on the class name and open the file usage dialog again.

    But this time you want to find every usages and you want to restrict the search on your previous search result: enter image description here

    The result should contain every annotation processor that uses your annotation candidate. It's very likely, that it's only one.

    This pattern can be used for every use case where you have a starting collection of files and want to refine/reduce the search result.