void (@NotNull PsiClass aClass) { // no call to super, so that it doesn't drill down to inner classes PsiElement parent = aClass.getParent(); if (!(parent instanceof PsiJavaFile file)) { return; } int numClasses = 0; final PsiElement[] children = file.getChildren(); for (final PsiElement child : children) { if (child instanceof PsiClass) { numClasses++; } } if (numClasses <= 1) { return; } registerClassError(aClass); }