Locate PsiClass elements in project scope

How do I locate all PsiElement(PsiClass) elements of classes that annotate @Component and implement or inherit from java.util.function.Consumer<org.springframework.messaging.Message<?>> within the project scope?

You probably need Java plugin APIs such as:

  • AnnotatedElementsSearch
  • ClassInheritorsSearch
  • DirectClassInheritorsSearch

And if you know exact FQN of a class and need its PsiClass then JavaPsiFacade.findClass should do it.

There are many usage examples on intellij-community sources in Java plugin