Search in sources :

Example 1 with StaticJavaParser.parseStatement

use of com.github.javaparser.StaticJavaParser.parseStatement in project drools by kiegroup.

the class PropagatorCompilerHandler method emitCode.

public String emitCode() {
    MethodDeclaration propagateMethod = new MethodDeclaration().setModifiers(Modifier.Keyword.PUBLIC, Modifier.Keyword.FINAL).setType(new VoidType()).setName(propagateMethodName()).setParameters(methodParameters());
    BlockStmt body = new BlockStmt();
    propagateMethod.setBody(body);
    body.addStatement(StaticJavaParser.parseStatement(String.format("if(logger.isDebugEnabled()) {\n" + "            logger.debug(\"%s on compiled alpha network {} {} {}\", handle, context, wm);\n" + "        }\n", propagateMethodName())));
    postProcessAllStatements();
    for (Statement s : allStatements.getStatements()) {
        body.addStatement(s);
    }
    StringBuilder allCodeGenerated = new StringBuilder();
    allCodeGenerated.append(propagateMethod.toString());
    allCodeGenerated.append(NEWLINE);
    for (MethodDeclaration md : extractedMethods) {
        allCodeGenerated.append(md.toString());
        allCodeGenerated.append(NEWLINE);
        allCodeGenerated.append(NEWLINE);
    }
    return allCodeGenerated.toString();
}
Also used : VoidType(com.github.javaparser.ast.type.VoidType) MethodDeclaration(com.github.javaparser.ast.body.MethodDeclaration) StaticJavaParser.parseStatement(com.github.javaparser.StaticJavaParser.parseStatement) Statement(com.github.javaparser.ast.stmt.Statement) BlockStmt(com.github.javaparser.ast.stmt.BlockStmt)

Aggregations

StaticJavaParser.parseStatement (com.github.javaparser.StaticJavaParser.parseStatement)1 MethodDeclaration (com.github.javaparser.ast.body.MethodDeclaration)1 BlockStmt (com.github.javaparser.ast.stmt.BlockStmt)1 Statement (com.github.javaparser.ast.stmt.Statement)1 VoidType (com.github.javaparser.ast.type.VoidType)1