Skip to content

Commit 2ca859a

Browse files
author
Vincent Potucek
committed
remove obsoletes found in SortPomCfg and PomExtension
1 parent bf7c651 commit 2ca859a

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

lib/src/main/java/com/diffplug/spotless/sql/dbeaver/SQLTokenizedFormatter.java

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
import com.diffplug.spotless.annotations.Internal;
2424

25+
import static java.lang.System.lineSeparator;
26+
2527
/**
2628
* **Warning:** Use this class at your own risk. It is an implementation detail and is not
2729
* guaranteed to exist in future versions.
@@ -67,7 +69,7 @@ public String format(final String argSql) {
6769
}
6870

6971
if (isSqlEndsWithNewLine) {
70-
after.append(getDefaultLineSeparator());
72+
after.append(lineSeparator());
7173
}
7274

7375
return after.toString();
@@ -388,19 +390,12 @@ private boolean isFunction(String name) {
388390
return sqlDialect.getKeywordType(name) == DBPKeywordType.FUNCTION;
389391
}
390392

391-
private static String getDefaultLineSeparator() {
392-
return System.getProperty("line.separator", "\n");
393-
}
394-
395393
private int insertReturnAndIndent(final List<FormatterToken> argList, final int argIndex, final int argIndent) {
396394
if (functionBracket.contains(Boolean.TRUE))
397395
return 0;
398396
try {
399-
final String defaultLineSeparator = getDefaultLineSeparator();
400-
StringBuilder s = new StringBuilder(defaultLineSeparator);
401-
for (int index = 0; index < argIndent; index++) {
402-
s.append(formatterCfg.getIndentString());
403-
}
397+
StringBuilder s = new StringBuilder(lineSeparator());
398+
s.append(String.valueOf(formatterCfg.getIndentString()).repeat(Math.max(0, argIndent)));
404399
if (argIndex > 0) {
405400
final FormatterToken token = argList.get(argIndex);
406401
final FormatterToken prevToken = argList.get(argIndex - 1);
@@ -409,10 +404,7 @@ private int insertReturnAndIndent(final List<FormatterToken> argList, final int
409404
prevToken.getType() != TokenType.END) {
410405
s.setCharAt(0, ' ');
411406
s.setLength(1);
412-
413-
final String comment = token.getString();
414-
final String withoutTrailingWhitespace = comment.replaceFirst("\\s*$", "");
415-
token.setString(withoutTrailingWhitespace);
407+
token.setString(token.getString().replaceFirst("\\s*$", ""));
416408
}
417409
}
418410

0 commit comments

Comments
 (0)