void (@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) { final PsiClass psiClass = PsiTreeUtil.getParentOfType(descriptor.getPsiElement(), PsiClass.class); final VirtualFile file = FileChooser.chooseFile(FileChooserDescriptorFactory.createSingleFolderDescriptor(), project, null); if (file != null) { final PsiManager psiManager = PsiManager.getInstance(project); final PsiDirectory directory = psiManager.findDirectory(file); LOG.assertTrue(directory != null); WriteCommandAction.writeCommandAction(project, PsiFile.EMPTY_ARRAY).withName(getName()).run(() -> { XmlFile testngXml = (XmlFile)PsiFileFactory.getInstance(psiManager.getProject()) .createFileFromText("testng.xml", "<!DOCTYPE suite SYSTEM \"http://testng.org/testng-1.0.dtd\">\n<suite></suite>"); try { testngXml = (XmlFile)directory.add(testngXml); } catch (IncorrectOperationException e) { //todo suggest new name return; } patchTestngXml(testngXml, psiClass); }); } }