Search in sources :

Example 1 with ListExpr

use of org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.ListExpr 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);
        }
    }
}
Also used : CloseBracketToken(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.CloseBracketToken) IToken(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.IToken) Statement(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.Statement) SingleStatement(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.SingleStatement) SingleStatement(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.SingleStatement) ListExpr(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.ListExpr) OpenBracketToken(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.OpenBracketToken)

Example 2 with ListExpr

use of org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.ListExpr in project scout.rt by eclipse.

the class SqlParser method parseListExpr.

private ListExpr parseListExpr(List<IToken> list, ParseContext ctx) {
    // OrExpr (ListSeparator OrExpr)*
    ParseStep lock = ctx.checkAndAdd("ListExpr", list);
    if (lock == null) {
        return null;
    }
    try {
        OrExpr oe = parseOrExpr(list, ctx);
        if (oe == null) {
            return null;
        }
        ListExpr le = new ListExpr();
        le.addChild(oe);
        ListSeparator ls = null;
        while ((ls = removeToken(list, ListSeparator.class)) != null && (oe = parseOrExpr(list, ctx)) != null) {
            le.addChild(ls);
            le.addChild(oe);
        }
        // restore incomplete
        if (ls != null) {
            list.add(0, ls);
        }
        return le;
    } finally {
        ctx.remove(lock);
    }
}
Also used : ListSeparator(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.ListSeparator) ListExpr(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.ListExpr) OrExpr(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.OrExpr)

Example 3 with ListExpr

use of org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.ListExpr in project scout.rt by eclipse.

the class SqlFormatter method formatPart.

private void formatPart(Part stm, FormatContext ctx) {
    boolean hasList = false;
    for (IToken t : stm.getChildren()) {
        if (t instanceof PartToken) {
            formatDefault(t, ctx);
        } else if (t instanceof Part) {
            ctx.in();
            formatPart((Part) t, ctx);
            ctx.out();
        } else if (t instanceof ListExpr) {
            hasList = true;
            ctx.in();
            formatListExpr((ListExpr) t, true, ctx);
            ctx.out();
        } else {
            formatDefault(t, ctx);
        }
    }
    if (!hasList) {
        ctx.in();
        ctx.print(" ");
        ctx.out();
    }
}
Also used : IToken(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.IToken) Part(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.Part) PartToken(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.PartToken) ListExpr(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.ListExpr)

Example 4 with ListExpr

use of org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.ListExpr in project scout.rt by eclipse.

the class SqlParser method parsePart.

private Part parsePart(List<IToken> list, ParseContext ctx, boolean rootPart) {
    // PartToken ListExpr
    ParseStep lock = ctx.checkAndAdd("Part", list);
    if (lock == null) {
        return null;
    }
    try {
        PartToken pt;
        ListExpr le;
        if ((pt = removeToken(list, PartToken.class)) != null && (!rootPart || isRootPartToken(pt))) {
            // ok
            le = parseListExpr(list, ctx);
        } else {
            // restore incomplete
            if (pt != null) {
                list.add(0, pt);
            }
            return null;
        }
        Part p = new Part();
        p.addChild(pt);
        if (le != null) {
            p.addChild(le);
        }
        return p;
    } finally {
        ctx.remove(lock);
    }
}
Also used : Part(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.Part) PartToken(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.PartToken) ListExpr(org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.ListExpr)

Aggregations

ListExpr (org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.ListExpr)4 IToken (org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.IToken)2 Part (org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.Part)2 PartToken (org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.PartToken)2 CloseBracketToken (org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.CloseBracketToken)1 ListSeparator (org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.ListSeparator)1 OpenBracketToken (org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.OpenBracketToken)1 OrExpr (org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.OrExpr)1 SingleStatement (org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.SingleStatement)1 Statement (org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.Statement)1