Java源码示例:com.google.googlejavaformat.java.javadoc.JavadocFormatter

示例1
@Override
public String rewrite(Tok tok, int maxWidth, int column0) {
    if (!tok.isComment()) {
        return tok.getOriginalText();
    }
    String text = tok.getOriginalText();
    if (tok.isJavadocComment()) {
        text = JavadocFormatter.formatJavadoc(text, column0, options);
    }
    List<String> lines = new ArrayList<>();
    Iterator<String> it = Newlines.lineIterator(text);
    while (it.hasNext()) {
        lines.add(CharMatcher.whitespace().trimTrailingFrom(it.next()));
    }
    if (tok.isSlashSlashComment()) {
        return indentLineComments(lines, column0);
    } else if (javadocShaped(lines)) {
        return indentJavadoc(lines, column0);
    } else {
        return preserveIndentation(lines, column0);
    }
}
 
示例2
@Override
public String rewrite(Tok tok, int maxWidth, int column0) {
    if (!tok.isComment()) {
        return tok.getOriginalText();
    }
    String text = tok.getOriginalText();
    if (tok.isJavadocComment()) {
        text = JavadocFormatter.formatJavadoc(text, column0, options);
    }
    List<String> lines = new ArrayList<>();
    Iterator<String> it = Newlines.lineIterator(text);
    while (it.hasNext()) {
        lines.add(CharMatcher.whitespace().trimTrailingFrom(it.next()));
    }
    if (tok.isSlashSlashComment()) {
        return indentLineComments(lines, column0);
    } else if (javadocShaped(lines)) {
        return indentJavadoc(lines, column0);
    } else {
        return preserveIndentation(lines, column0);
    }
}
 
示例3
@Override
public String rewrite(Tok tok, int maxWidth, int column0) {
  if (!tok.isComment()) {
    return tok.getOriginalText();
  }
  String text = tok.getOriginalText();
  if (tok.isJavadocComment() && options.formatJavadoc()) {
    text = JavadocFormatter.formatJavadoc(text, column0);
  }
  List<String> lines = new ArrayList<>();
  Iterator<String> it = Newlines.lineIterator(text);
  while (it.hasNext()) {
    lines.add(CharMatcher.whitespace().trimTrailingFrom(it.next()));
  }
  if (tok.isSlashSlashComment()) {
    return indentLineComments(lines, column0);
  } else if (javadocShaped(lines)) {
    return indentJavadoc(lines, column0);
  } else {
    return preserveIndentation(lines, column0);
  }
}