void (UsageInfo @NotNull [] usages) { final GeneratorClassNameProvider classNameProvider = new GeneratorClassNameProvider(); ExpressionContext context = new ExpressionContext(myProject, myFiles); final ClassGenerator classGenerator = new ClassGenerator(classNameProvider, new ClassItemGeneratorImpl(context)); for (GroovyFile file : myFiles) { final PsiClass[] classes = file.getClasses(); StringBuilder builder = new StringBuilder(); boolean first = true; for (PsiClass aClass : classes) { classGenerator.writeTypeDefinition(builder, aClass, true, first); first = false; builder.append('\n'); } final Document document = PsiDocumentManager.getInstance(myProject).getDocument(file); LOG.assertTrue(document != null); document.setText(builder.toString()); PsiDocumentManager.getInstance(myProject).commitDocument(document); String fileName = getNewFileName(file); PsiElement newFile; try { String filePathBeforeConvert = file.getVirtualFile().getPath(); file.getVirtualFile().putUserData(RenameTrackingKt.getPathBeforeGroovyToJavaConversion(), filePathBeforeConvert); newFile = file.setName(fileName); } catch (final IncorrectOperationException e) { ApplicationManager.getApplication().invokeLater( () -> Messages.showMessageDialog(myProject, e.getMessage(), RefactoringBundle.message("error.title"), Messages.getErrorIcon())); return; } doPostProcessing(newFile); } }