PsiClass () { final PsiClass psiClass = myConstructors[0].getContainingClass(); assert psiClass != null; final PsiTypeParameterList typeParameterList = psiClass.getTypeParameterList(); final String text = "public class " + myClassName + (typeParameterList != null ? typeParameterList.getText() : "") + "{}"; final PsiFileFactory factory = PsiFileFactory.getInstance(myProject); final PsiJavaFile newFile = (PsiJavaFile)factory.createFileFromText(myClassName + ".java", JavaFileType.INSTANCE, text); final PsiFile containingFile = myConstructors[0].getContainingFile(); final PsiDirectory containingDirectory = containingFile.getContainingDirectory(); final PsiDirectory directory; if (myMoveDestination != null) { directory = myMoveDestination.getTargetDirectory(containingDirectory); } else { final Module module = ModuleUtilCore.findModuleForPsiElement(containingFile); assert module != null; directory = PackageUtil.findOrCreateDirectoryForPackage(module, myPackageName, containingDirectory, true, true); } if (directory != null) { final CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(PsiManager.getInstance(myProject).getProject()); final PsiJavaFile reformattedFile = (PsiJavaFile)codeStyleManager.reformat(JavaCodeStyleManager.getInstance(newFile.getProject()).shortenClassReferences(newFile)); if (directory.findFile(reformattedFile.getName()) != null) return reformattedFile.getClasses()[0]; return ((PsiJavaFile)directory.add(reformattedFile)).getClasses()[0]; } return null; }