String concatenation formatting
Prettier-Java 1.6.1
Related to https://github.com/jhipster/prettier-java/issues/77. In this case we're getting compilable code, it's just sub-ideal.
# Options (if any):
--print-width 140
Input:
PreparedStatement statement =
connection.prepareStatement(
"INSERT INTO noneofyourbusiness(" +
"field1," +
"field2," +
"field3," +
"field4) " +
"VALUES (?, ?, ?, ?)");
Output:
PreparedStatement statement = connection.prepareStatement(
"INSERT INTO noneofyourbusiness(" + "field1," + "field2," + "field3," + "field4) " + "VALUES (?, ?, ?, ?)"
);
Expected behavior: I see two options:
- do not join the lines if they contain string concatenation like this
- join, but make sure to get rid of all the concatenation
Hi @JanecekPetr,
I understand that this might be a little annoying.
However, I do not to get rid of the concatenation as it would change the AST, which we want to avoid. And I don't think we want to introduce specificity for printing string concatenation either, as it would introduce some complexity for a limited (and maybe controversial) value.
That's fair. So we do not want to make a single concatenated String, I'm fine with that.
Would it be better in those cases to not join the lines, but rather follow the human flow, and keep the strings on separate lines as a human put them there originally?