Java Code Examples for com.google.googlejavaformat.Newlines#lineIterator()
The following examples show how to use
com.google.googlejavaformat.Newlines#lineIterator() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavaCommentsHelper.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
@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); } }
Example 2
Source File: JavaCommentsHelper.java From javaide with GNU General Public License v3.0 | 6 votes |
@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); } }
Example 3
Source File: JavaCommentsHelper.java From google-java-format with Apache License 2.0 | 6 votes |
@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); } }
Example 4
Source File: StringWrapper.java From google-java-format with Apache License 2.0 | 5 votes |
/** Returns true if any lines in the given Java source exceed the column limit. */ private static boolean longLines(int columnLimit, String input) { // TODO(cushon): consider adding Newlines.lineIterable? Iterator<String> it = Newlines.lineIterator(input); while (it.hasNext()) { String line = it.next(); if (line.length() > columnLimit) { return true; } } return false; }