protected void addComment(JavaElement field, String comment) {
   StringBuilder sb = new StringBuilder();
   field.addJavaDocLine("/**");
   sb.append(" * ");
   comment =
       comment.replaceAll(
           OutputUtilities.lineSeparator, "<br>" + OutputUtilities.lineSeparator + "\t * ");
   sb.append(comment);
   field.addJavaDocLine(sb.toString());
   field.addJavaDocLine(" */");
 }
 /**
  * This method adds the custom javadoc tag for. You may do nothing if you do not wish to include
  * the Javadoc tag - however, if you do not include the Javadoc tag then the Java merge capability
  * of the eclipse plugin will break.
  *
  * @param javaElement the java element
  */
 protected void addJavadocTag(JavaElement javaElement, boolean markAsDoNotDelete) {
   javaElement.addJavaDocLine(" *"); // $NON-NLS-1$
   StringBuilder sb = new StringBuilder();
   sb.append(" * "); // $NON-NLS-1$
   sb.append(MergeConstants.NEW_ELEMENT_TAG);
   if (markAsDoNotDelete) {
     sb.append(" do_not_delete_during_merge"); // $NON-NLS-1$
   }
   String s = getDateString();
   if (s != null) {
     sb.append(' ');
     sb.append(s);
   }
   javaElement.addJavaDocLine(sb.toString());
 }
 /**
  * 删除标记
  *
  * @param javaElement
  * @param markAsDoNotDelete
  */
 protected void addJavadocTag(JavaElement javaElement, boolean markAsDoNotDelete) {
   StringBuilder sb = new StringBuilder();
   sb.append(" * ");
   sb.append(MergeConstants.NEW_ELEMENT_TAG);
   if (markAsDoNotDelete) {
     sb.append(" do_not_delete_during_merge");
   }
   javaElement.addJavaDocLine(sb.toString());
 }
示例#4
0
  public String getFormattedContent(CompilationUnit compilationUnit) {
    StringBuilder sb = new StringBuilder();

    for (String annotation : annotations) {
      sb.append(annotation);
      sb.append(' ');
    }

    JavaElement.addTypeName(sb, compilationUnit, type);

    sb.append(' ');
    if (isVarargs) {
      sb.append("... "); // $NON-NLS-1$
    }
    sb.append(name);

    return sb.toString();
  }
  protected void annotateJavaElement(
      TopLevelClass topLevelClass, JavaElement javaElement, String tildSeparatedAnnotations) {
    List<String> lstUserAnnotations = new ArrayList<String>();
    StringBuilder sb = new StringBuilder();
    String annot = null, bracketFragment = null;

    if (javaElement instanceof TopLevelClass
        && !tildSeparatedAnnotations.contains(getXmlAccessTypeConstant()))
      tildSeparatedAnnotations += '~' + getXmlAccessTypeConstant();

    for (String annotation : tildSeparatedAnnotations.split("~")) {
      javaElement.addAnnotation(annotation);

      sb.append(annotation);
      sb.deleteCharAt(0); // remove the leading @ sign from the annotation.

      int ind = sb.indexOf("(");
      if (ind != -1) {
        annot = sb.substring(0, ind);
        bracketFragment = sb.substring(ind + 1);

        if (bracketFragment.startsWith("XmlAccessType."))
          lstUserAnnotations.add(
              "XmlAccessType"); // Add the import for XmlAccessType annotation that is inside the
        // parenthesis of XmlAccessorType: (XmlAccessType.FIELD) or
        // (XmlAccessType.PROPERTY). Example:
        // @XmlAccessorType(XmlAccessType.FIELD)
        else if (bracketFragment.startsWith("XmlAccessOrder."))
          lstUserAnnotations.add(
              "XmlAccessOrder"); // Add the import for XmlAccessOrder annotation that is inside the
        // parenthesis of XmlAccessorOrder: (XmlAccessorOrder.ALPHABETICAL)
        // or (XmlAccessorOrder.UNDEFINED). Example:
        // @XmlAccessorOrder(XmlAccessorOrder.ALPHABETICAL)
      } else annot = sb.toString();

      sb.delete(0, sb.length());

      if (!lstUserAnnotations.contains(annot)) lstUserAnnotations.add(annot);
    }

    addImportsForAnnotations(topLevelClass, lstUserAnnotations.toArray(new String[0]));
  }