private static void moveDocCommentToDeclaration(@NotNull Project project, @NotNull PsiDocComment docComment, @NotNull PsiElement declaration) { final StringBuilder buf = new StringBuilder(); for (PsiElement psiElement : docComment.getDescriptionElements()) { buf.append(psiElement.getText()); } if (buf.length() > 0) { final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project); final JavaCommenter commenter = new JavaCommenter(); final PsiComment comment = elementFactory.createCommentFromText(commenter.getBlockCommentPrefix() + buf.toString() + commenter.getBlockCommentSuffix(), declaration); declaration.getParent().addBefore(comment, declaration); } }