google-java-format
google-java-format copied to clipboard
google-java-format fails on text blocks with too long lines
If you happen to have a source file with a text block that has individual rows that are too long, like in the following example class:
public class Example {
private final String test = """
Something that really definitely is regarded to be too long to fit on one row according to google-java-format
Something else that really definitely is regarded to be too long to fit on one row according to google-java-format""";
}
, then google-java-format 1.9 outputs:
Example.java:error: Something has gone terribly wrong. Please file a bug: https://github.com/google/google-java-format/issues/new
=== Actual: ===
public class Example {
private final String test = "Something that really definitely is regarded to be too long to fit on one row\"\n + \" according to google-java-format\nSomething else that really definitely is\"\n + \" regarded to be too long to fit on one row according to google-java-format";
}
=== Expected: ===
public class Example {
private final String test = "Something that really definitely is regarded to be too long to fit on one row according to google-java-format\nSomething else that really definitely is regarded to be too long to fit on one row according to google-java-format";
}
Any workarounds? Or fix coming? 🤞🏼
@nhoughto A simple workaround seems to be to end the last line with a \ and then close the multiline comment on the next line:
public class Example {
private final String test = """
Something that really definitely is regarded to be too long to fit on one row according to google-java-format
Something else that really definitely is regarded to be too long to fit on one row according to google-java-format\
""";
}