void (final ConfigurationContext context, final PsiClass psiClass, final Consumer<? super List<PsiClass>> onClassesChosen) { InheritorChooser inheritorChooser = new InheritorChooser() { @Override protected void runForClasses(List<PsiClass> classes, PsiMethod method, ConfigurationContext context, Runnable performRunnable) { onClassesChosen.accept(classes); } @Override protected void runForClass(PsiClass aClass, PsiMethod psiMethod, ConfigurationContext context, Runnable performRunnable) { onClassesChosen.accept(List.of(aClass)); } }; if (!inheritorChooser.runMethodInAbstractClass(context, () -> {}, null, psiClass)) { onClassesChosen.accept(List.of(psiClass)); } }