@Test public void testIf2() throws Exception { String sql = "select where 1=1 #if(!:1) and id>:1 #end"; ASTRootNode n = new Parser(sql).parse().init(); ParameterContext ctx = getParameterContext(Lists.newArrayList((Type) Integer.class)); n.checkAndBind(ctx); InvocationContext context = DefaultInvocationContext.create(); context.addParameter("1", 100); n.render(context); BoundSql boundSql = context.getBoundSql(); assertThat(boundSql.getSql().toString(), equalTo("select where 1=1 ")); assertThat(boundSql.getArgs().size(), equalTo(0)); }
final public ASTRootNode parse() throws ParseException { ASTRootNode jjtn000 = new ASTRootNode(JJTROOTNODE); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); jjtn000.jjtSetFirstToken(getToken(1)); try { DML(); ASTBlock jjtn001 = new ASTBlock(JJTBLOCK); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); jjtn001.jjtSetFirstToken(getToken(1)); try { label_1: while (true) { Statement(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case BLANK: case QUOTE_TEXT: case JDBC_ITERABLE_PARAMETER: case JDBC_PARAMETER: case GLOBAL_TABLE: case JOIN_PARAMETER: case IF_DIRECTIVE: case INSERT: case DELETE: case UPDATE: case SELECT: case REPLACE: case MERGE: case TRUNCATE: case TEXT: ; break; default: jj_la1[0] = jj_gen; break label_1; } } } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte001;} } if (jjte001 instanceof ParseException) { {if (true) throw (ParseException)jjte001;} } {if (true) throw (Error)jjte001;} } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, true); jjtn001.jjtSetLastToken(getToken(0)); } } jj_consume_token(0); jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; jjtn000.jjtSetLastToken(getToken(0)); {if (true) return jjtn000;} } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte000;} } if (jjte000 instanceof ParseException) { {if (true) throw (ParseException)jjte000;} } {if (true) throw (Error)jjte000;} } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); jjtn000.jjtSetLastToken(getToken(0)); } } throw new Error("Missing return statement in function"); }
Parser implements ParserTreeConstants, ParserConstants { final public ASTRootNode parse() throws ParseException { ASTRootNode jjtn000 = new ASTRootNode(JJTROOTNODE); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); jjtn000.jjtSetFirstToken(getToken(1)); try { DML(); ASTBlock jjtn001 = new ASTBlock(JJTBLOCK); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); jjtn001.jjtSetFirstToken(getToken(1)); try { label_1: while (true) { Statement(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case BLANK: case QUOTE_TEXT: case JDBC_ITERABLE_PARAMETER: case JDBC_PARAMETER: case GLOBAL_TABLE: case JOIN_PARAMETER: case IF_DIRECTIVE: case INSERT: case DELETE: case UPDATE: case SELECT: case REPLACE: case MERGE: case TRUNCATE: case TEXT: ; break; default: jj_la1[0] = jj_gen; break label_1; } } } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte001;} } if (jjte001 instanceof ParseException) { {if (true) throw (ParseException)jjte001;} } {if (true) throw (Error)jjte001;} } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, true); jjtn001.jjtSetLastToken(getToken(0)); } } jj_consume_token(0); jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; jjtn000.jjtSetLastToken(getToken(0)); {if (true) return jjtn000;} } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte000;} } if (jjte000 instanceof ParseException) { {if (true) throw (ParseException)jjte000;} } {if (true) throw (Error)jjte000;} } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); jjtn000.jjtSetLastToken(getToken(0)); } } throw new Error("Missing return statement in function"); } }
Parser implements ParserTreeConstants, ParserConstants { final public ASTRootNode parse() throws ParseException { ASTRootNode jjtn000 = new ASTRootNode(JJTROOTNODE); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); jjtn000.jjtSetFirstToken(getToken(1)); try { DML(); ASTBlock jjtn001 = new ASTBlock(JJTBLOCK); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); jjtn001.jjtSetFirstToken(getToken(1)); try { label_1: while (true) { Statement(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case BLANK: case QUOTE_TEXT: case JDBC_ITERABLE_PARAMETER: case JDBC_PARAMETER: case GLOBAL_TABLE: case JOIN_PARAMETER: case IF_DIRECTIVE: case INSERT: case DELETE: case UPDATE: case SELECT: case REPLACE: case MERGE: case TRUNCATE: case TEXT: ; break; default: jj_la1[0] = jj_gen; break label_1; } } } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte001;} } if (jjte001 instanceof ParseException) { {if (true) throw (ParseException)jjte001;} } {if (true) throw (Error)jjte001;} } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, true); jjtn001.jjtSetLastToken(getToken(0)); } } jj_consume_token(0); jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; jjtn000.jjtSetLastToken(getToken(0)); {if (true) return jjtn000;} } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte000;} } if (jjte000 instanceof ParseException) { {if (true) throw (ParseException)jjte000;} } {if (true) throw (Error)jjte000;} } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); jjtn000.jjtSetLastToken(getToken(0)); } } throw new Error("Missing return statement in function"); } Parser(String s);  Parser(java.io.InputStream stream);  Parser(java.io.InputStream stream, String encoding);  Parser(Reader stream);  Parser(ParserTokenManager tm); }
Parser implements ParserTreeConstants, ParserConstants { final public ASTRootNode parse() throws ParseException { ASTRootNode jjtn000 = new ASTRootNode(JJTROOTNODE); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); jjtn000.jjtSetFirstToken(getToken(1)); try { DML(); ASTBlock jjtn001 = new ASTBlock(JJTBLOCK); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); jjtn001.jjtSetFirstToken(getToken(1)); try { label_1: while (true) { Statement(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case BLANK: case QUOTE_TEXT: case JDBC_ITERABLE_PARAMETER: case JDBC_PARAMETER: case GLOBAL_TABLE: case JOIN_PARAMETER: case IF_DIRECTIVE: case INSERT: case DELETE: case UPDATE: case SELECT: case REPLACE: case MERGE: case TRUNCATE: case TEXT: ; break; default: jj_la1[0] = jj_gen; break label_1; } } } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte001;} } if (jjte001 instanceof ParseException) { {if (true) throw (ParseException)jjte001;} } {if (true) throw (Error)jjte001;} } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, true); jjtn001.jjtSetLastToken(getToken(0)); } } jj_consume_token(0); jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; jjtn000.jjtSetLastToken(getToken(0)); {if (true) return jjtn000;} } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte000;} } if (jjte000 instanceof ParseException) { {if (true) throw (ParseException)jjte000;} } {if (true) throw (Error)jjte000;} } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); jjtn000.jjtSetLastToken(getToken(0)); } } throw new Error("Missing return statement in function"); } Parser(String s);  Parser(java.io.InputStream stream);  Parser(java.io.InputStream stream, String encoding);  Parser(Reader stream);  Parser(ParserTokenManager tm); final ASTRootNode parse(); final void DML(); final void Insert(); final void Delete(); final void Update(); final void Select(); final void Replace(); final void Merge(); final void Truncate(); final void Statement(); final void JDBCParameter(); final void JDBCIterableParameter(); final void GlobalTable(); final void JoinParameter(); final void QuoteText(); final void Text(); final void Blank(); final void IfStatement(); final void ElseStatement(); final void ElseIfStatement(); final void Expression(); final void ConditionalOrExpression(); final void ConditionalAndExpression(); final void RelationalExpression(); final void UnaryExpression(); final void PrimaryExpression(); final void ExpressionParameter(); final void IntegerLiteral(); final void StringLiteral(); final void True(); final void False(); final void Null(); void ReInit(java.io.InputStream stream); void ReInit(java.io.InputStream stream, String encoding); void ReInit(Reader stream); void ReInit(ParserTokenManager tm); final Token getNextToken(); final Token getToken(int index); ParseException generateParseException(); final void enable_tracing(); final void disable_tracing(); }
Parser implements ParserTreeConstants, ParserConstants { final public ASTRootNode parse() throws ParseException { ASTRootNode jjtn000 = new ASTRootNode(JJTROOTNODE); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); jjtn000.jjtSetFirstToken(getToken(1)); try { DML(); ASTBlock jjtn001 = new ASTBlock(JJTBLOCK); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); jjtn001.jjtSetFirstToken(getToken(1)); try { label_1: while (true) { Statement(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case BLANK: case QUOTE_TEXT: case JDBC_ITERABLE_PARAMETER: case JDBC_PARAMETER: case GLOBAL_TABLE: case JOIN_PARAMETER: case IF_DIRECTIVE: case INSERT: case DELETE: case UPDATE: case SELECT: case REPLACE: case MERGE: case TRUNCATE: case TEXT: ; break; default: jj_la1[0] = jj_gen; break label_1; } } } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte001;} } if (jjte001 instanceof ParseException) { {if (true) throw (ParseException)jjte001;} } {if (true) throw (Error)jjte001;} } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, true); jjtn001.jjtSetLastToken(getToken(0)); } } jj_consume_token(0); jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; jjtn000.jjtSetLastToken(getToken(0)); {if (true) return jjtn000;} } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte000;} } if (jjte000 instanceof ParseException) { {if (true) throw (ParseException)jjte000;} } {if (true) throw (Error)jjte000;} } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); jjtn000.jjtSetLastToken(getToken(0)); } } throw new Error("Missing return statement in function"); } Parser(String s);  Parser(java.io.InputStream stream);  Parser(java.io.InputStream stream, String encoding);  Parser(Reader stream);  Parser(ParserTokenManager tm); final ASTRootNode parse(); final void DML(); final void Insert(); final void Delete(); final void Update(); final void Select(); final void Replace(); final void Merge(); final void Truncate(); final void Statement(); final void JDBCParameter(); final void JDBCIterableParameter(); final void GlobalTable(); final void JoinParameter(); final void QuoteText(); final void Text(); final void Blank(); final void IfStatement(); final void ElseStatement(); final void ElseIfStatement(); final void Expression(); final void ConditionalOrExpression(); final void ConditionalAndExpression(); final void RelationalExpression(); final void UnaryExpression(); final void PrimaryExpression(); final void ExpressionParameter(); final void IntegerLiteral(); final void StringLiteral(); final void True(); final void False(); final void Null(); void ReInit(java.io.InputStream stream); void ReInit(java.io.InputStream stream, String encoding); void ReInit(Reader stream); void ReInit(ParserTokenManager tm); final Token getNextToken(); final Token getToken(int index); ParseException generateParseException(); final void enable_tracing(); final void disable_tracing(); public ParserTokenManager token_source; public Token token; public Token jj_nt; }