Try to wrap long strings regardless of whether they'd provoke lint errors
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=246532151
diff --git a/core/src/main/java/com/google/googlejavaformat/java/StringWrapper.java b/core/src/main/java/com/google/googlejavaformat/java/StringWrapper.java
index ff76dc6..c371a8a 100644
--- a/core/src/main/java/com/google/googlejavaformat/java/StringWrapper.java
+++ b/core/src/main/java/com/google/googlejavaformat/java/StringWrapper.java
@@ -36,7 +36,6 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.regex.Pattern;
import java.util.stream.Stream;
import org.openjdk.javax.tools.Diagnostic;
import org.openjdk.javax.tools.DiagnosticCollector;
@@ -93,9 +92,7 @@
&& ((MemberSelectTree) parent).getExpression().equals(literalTree)) {
return null;
}
- int startPosition = getStartPosition(literalTree);
int endPosition = getEndPosition(unit, literalTree);
- int lineStart = startPosition - lineMap.getColumnNumber(startPosition);
int lineEnd = endPosition;
while (Newlines.hasNewlineAt(input, lineEnd) == -1) {
lineEnd++;
@@ -103,9 +100,6 @@
if (lineMap.getColumnNumber(lineEnd) - 1 <= columnLimit) {
return null;
}
- if (!lintable(input.substring(lineStart, lineEnd))) {
- return null;
- }
toFix.add(getCurrentPath());
return null;
}
@@ -343,23 +337,13 @@
return ((JCTree) tree).getStartPosition();
}
- /**
- * Match the heuristic in the Google Style checkstyle config which suppresses line length warnings
- * if the given line contains a run of >80 non-whitespace characters, to allow e.g. URLs.
- */
- private static boolean lintable(String line) {
- return !UNLINTABLE.matcher(line).matches();
- }
-
- private static final Pattern UNLINTABLE = Pattern.compile(".*[^ ]{80,}.*");
-
/** 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 && lintable(line)) {
+ if (line.length() > columnLimit) {
return true;
}
}