void (@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) { if (!(element instanceof XmlFile xmlFile)) { return; } final PsiDirectory directory = updater.getWritable(xmlFile.getOriginalFile().getContainingDirectory()); if (directory == null) { return; } final PsiFile file = directory.findFile(PsiPackage.PACKAGE_INFO_FILE); if (file != null) { return; } final String packageInfoText = getPackageInfoText(xmlFile); final PsiJavaFile packageInfoFile = (PsiJavaFile)directory.createFile(PsiPackage.PACKAGE_INFO_FILE); final String commentText = buildCommentText(packageInfoText); final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project); final PsiDocComment comment = elementFactory.createDocCommentFromText(commentText); if (!aPackage.isEmpty()) { final PsiPackageStatement packageStatement = elementFactory.createPackageStatement(aPackage); final PsiElement addedElement = packageInfoFile.add(packageStatement); packageInfoFile.addBefore(comment, addedElement); } else { packageInfoFile.add(comment); } CodeStyleManager.getInstance(project).reformat(packageInfoFile); xmlFile.delete(); updater.moveTo(packageInfoFile); }