Search in sources :

Example 1 with PartToken

use of org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.PartToken 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 2 with PartToken

use of org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.PartToken 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)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 IToken (org.eclipse.scout.rt.server.jdbc.parsers.sql.SqlParserToken.IToken)1