use of org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.OpenBracketToken in project scout.rt by eclipse.
the class SqlFormatter method formatBracketExpr.
private void formatBracketExpr(BracketExpr stm, FormatContext ctx) {
boolean multiline = isMultiline(stm);
for (IToken t : stm.getChildren()) {
if (t instanceof OpenBracketToken) {
formatDefault(t, ctx);
if (multiline) {
ctx.println();
ctx.in();
}
} else if (t instanceof CloseBracketToken) {
if (multiline) {
ctx.out();
}
formatDefault(t, ctx);
} else if (t instanceof Statement) {
formatStatement((Statement) t, ctx);
} else if (t instanceof SingleStatement) {
formatSingleStatement((SingleStatement) t, ctx);
} else if (t instanceof ListExpr) {
formatListExpr((ListExpr) t, multiline, ctx);
} else {
formatDefault(t, ctx);
}
}
}
use of org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.OpenBracketToken in project scout.rt by eclipse.
the class SqlParser method parseBracketExpr.
@SuppressWarnings("squid:S2583")
private BracketExpr parseBracketExpr(List<IToken> list, ParseContext ctx) {
// BracketExpr = OpenBracketToken (Statement | ListExpr) CloseBracketToken
ParseStep lock = ctx.checkAndAdd("BracketExpr", list);
if (lock == null) {
return null;
}
try {
IToken open = null;
IToken t = null;
IToken close = null;
ArrayList<IToken> backup = new ArrayList<IToken>(list);
if ((open = removeToken(list, OpenBracketToken.class)) != null && ((t = parseStatement(list, ctx)) != null || (t = parseListExpr(list, ctx)) != null || t == null) && (close = removeToken(list, CloseBracketToken.class)) != null) {
// NOSONAR
// ok
} else {
// restore incomplete
list.clear();
list.addAll(backup);
return null;
}
BracketExpr e = new BracketExpr();
e.addChild(open);
if (t != null) {
e.addChild(t);
}
e.addChild(close);
return e;
} finally {
ctx.remove(lock);
}
}
Aggregations