提交 380820ad 编写于 作者: S serge-rider

#3631 SQL formatter: brackets formatting fix


Former-commit-id: b458e2dc
上级 0d708a5a
...@@ -161,6 +161,7 @@ public class SQLFormatterTokenized implements SQLFormatter { ...@@ -161,6 +161,7 @@ public class SQLFormatterTokenized implements SQLFormatter {
final List<Integer> bracketIndent = new ArrayList<>(); final List<Integer> bracketIndent = new ArrayList<>();
FormatterToken prev = new FormatterToken(TokenType.SPACE, " "); //$NON-NLS-1$ FormatterToken prev = new FormatterToken(TokenType.SPACE, " "); //$NON-NLS-1$
boolean encounterBetween = false; boolean encounterBetween = false;
int bracketsDepth = 0;
for (int index = 0; index < argList.size(); index++) { for (int index = 0; index < argList.size(); index++) {
token = argList.get(index); token = argList.get(index);
String tokenString = token.getString().toUpperCase(Locale.ENGLISH); String tokenString = token.getString().toUpperCase(Locale.ENGLISH);
...@@ -168,6 +169,7 @@ public class SQLFormatterTokenized implements SQLFormatter { ...@@ -168,6 +169,7 @@ public class SQLFormatterTokenized implements SQLFormatter {
if (tokenString.equals("(")) { //$NON-NLS-1$ if (tokenString.equals("(")) { //$NON-NLS-1$
functionBracket.add(formatterCfg.isFunction(prev.getString()) ? Boolean.TRUE : Boolean.FALSE); functionBracket.add(formatterCfg.isFunction(prev.getString()) ? Boolean.TRUE : Boolean.FALSE);
bracketIndent.add(indent); bracketIndent.add(indent);
bracketsDepth++;
// Adding indent after ( makes result too verbose and too multiline // Adding indent after ( makes result too verbose and too multiline
// if (!isCompact) { // if (!isCompact) {
// indent++; // indent++;
...@@ -179,9 +181,12 @@ public class SQLFormatterTokenized implements SQLFormatter { ...@@ -179,9 +181,12 @@ public class SQLFormatterTokenized implements SQLFormatter {
// index += insertReturnAndIndent(argList, index, indent); // index += insertReturnAndIndent(argList, index, indent);
// } // }
functionBracket.remove(functionBracket.size() - 1); functionBracket.remove(functionBracket.size() - 1);
bracketsDepth--;
} else if (tokenString.equals(",")) { //$NON-NLS-1$ } else if (tokenString.equals(",")) { //$NON-NLS-1$
if (!isCompact) { if (!isCompact) {
index += insertReturnAndIndent(argList, index + 1, indent); if (bracketsDepth <= 0) {
index += insertReturnAndIndent(argList, index + 1, indent);
}
} }
} else if (statementDelimiters.contains(tokenString)) { //$NON-NLS-1$ } else if (statementDelimiters.contains(tokenString)) { //$NON-NLS-1$
indent = 0; indent = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册