String (final @NotNull PsiFile file, @NotNull String templateText) { final PsiFile copy = PsiFileFactory.getInstance(file.getProject()).createFileFromText(file.getName(), file.getFileType(), templateText); CodeStyleManager.getInstance(file.getProject()).reformat(copy); return copy.getText(); }