void (PsiClass psiClass) { final CreateClassDialog dlg = chooseSubclassToCreate(psiClass); if (dlg != null) { PsiDirectory targetDirectory = dlg.getTargetDirectory(); PsiJavaFile containingFile = ObjectUtils.tryCast(psiClass.getContainingFile(), PsiJavaFile.class); boolean inSamePackage = containingFile != null && containingFile.getPackageName().equals(targetDirectory.getName()); if (inSamePackage && hasOnlySameFileInheritors(psiClass)) { createSameFileClass(dlg.getClassName(), psiClass); } else { createSubclass(psiClass, targetDirectory, dlg.getClassName()); } } }