Java 类com.intellij.lang.java.JavaCommenter 实例源码

项目:intellij-ce-playground    文件:FieldCanBeLocalInspection.java   
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);
  }
}
项目:tools-idea    文件:FieldCanBeLocalInspection.java   
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);
  }
}
项目:consulo-java    文件:FieldCanBeLocalInspection.java   
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);
  }
}