@Override
 public SqlNode transform(SqlNode sqlNode) {
   AnonymousNode result = new AnonymousNode();
   for (SqlNode child : sqlNode.getChildren()) {
     result.appendNode(child.accept(this, null));
   }
   return result;
 }
Пример #2
0
  public void testIfSuppressed() throws Exception {
    Class<?> target = BatchSqlValidationDao.class;
    addCompilationUnit(target);
    compile();

    ExecutableElement methodElement = createMethodElement(target, "testIfSuppressed");
    Map<String, TypeMirror> parameterTypeMap = createParameterTypeMap(methodElement);
    BatchSqlValidator validator =
        new BatchSqlValidator(
            getProcessingEnvironment(), methodElement, parameterTypeMap, "aaa/bbbDao/ccc.sql");
    SqlParser parser = new SqlParser("select * from emp where /*%if true*/ id = 1 /*%end */");
    SqlNode sqlNode = parser.parse();
    sqlNode.accept(validator, null);
    assertNoMessage();
  }
Пример #3
0
  public void testEmbeddedVariable() throws Exception {
    Class<?> target = BatchSqlValidationDao.class;
    addCompilationUnit(target);
    compile();

    ExecutableElement methodElement =
        createMethodElement(target, "testEmbeddedVariable", String.class);
    Map<String, TypeMirror> parameterTypeMap = createParameterTypeMap(methodElement);
    BatchSqlValidator validator =
        new BatchSqlValidator(
            getProcessingEnvironment(), methodElement, parameterTypeMap, "aaa/bbbDao/ccc.sql");
    SqlParser parser = new SqlParser("select * from emp /*# orderBy */");
    SqlNode sqlNode = parser.parse();
    sqlNode.accept(validator, null);
    assertMessage(Message.DOMA4181);
  }
Пример #4
0
  public void testIfAndEmbeddedVariable() throws Exception {
    Class<?> target = BatchSqlValidationDao.class;
    addCompilationUnit(target);
    compile();

    ExecutableElement methodElement =
        createMethodElement(target, "testIfAndEmbeddedVariable", String.class);
    Map<String, TypeMirror> parameterTypeMap = createParameterTypeMap(methodElement);
    BatchSqlValidator validator =
        new BatchSqlValidator(
            getProcessingEnvironment(), methodElement, parameterTypeMap, "aaa/bbbDao/ccc.sql");
    SqlParser parser =
        new SqlParser("select * from emp where /*%if true*/ id = 1 /*%end */ /*# orderBy */");
    SqlNode sqlNode = parser.parse();
    sqlNode.accept(validator, null);
    assertEquals(2, getDiagnostics().size());
  }