Example usage for org.eclipse.jdt.core.dom Block statements

List of usage examples for org.eclipse.jdt.core.dom Block statements

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom Block statements.

Prototype

ASTNode.NodeList statements

To view the source code for org.eclipse.jdt.core.dom Block statements.

Click Source Link

Document

The list of statements (element type: Statement ).

Usage

From source file:org.smartfrog.tools.eclipse.ui.project.document.BaseComponentCreationWizardPage.java

License:Open Source License

/**
 * add smartFrog methods to template (memory only)
 * @param cu//ww w. java2 s  .  c  om
 * @param unit
 * @param typeDeclaration
 * @param methodName
 * @param needToThrow
 * @param needParam
 * @throws CoreException
 * @throws InterruptedException
 */
private void addSfDeployMethod(ICompilationUnit cu, CompilationUnit unit, TypeDeclaration typeDeclaration,
        String methodName, boolean needToThrow, boolean needParam) throws CoreException, InterruptedException {
    AST localAst = typeDeclaration.getAST();
    MethodDeclaration methodDeclaration = localAst.newMethodDeclaration();
    methodDeclaration.setConstructor(false);
    methodDeclaration.setModifiers(Modifier.PUBLIC | Modifier.SYNCHRONIZED);
    methodDeclaration.setName(localAst.newSimpleName(methodName));
    methodDeclaration.setReturnType(localAst.newPrimitiveType(PrimitiveType.VOID));

    if (needParam) {
        SingleVariableDeclaration variableDeclaration = localAst.newSingleVariableDeclaration();
        variableDeclaration.setModifiers(Modifier.NONE);
        variableDeclaration.setType(localAst.newSimpleType(localAst.newSimpleName(TERMINATIONRECORD_VAR)));
        variableDeclaration.setName(localAst.newSimpleName(SFTERMINATE_STATUS_ARGUMENT_NAME));
        methodDeclaration.parameters().add(variableDeclaration);
    }

    Block block = localAst.newBlock();
    methodDeclaration.setBody(block);

    SuperMethodInvocation superMethodInvocation = localAst.newSuperMethodInvocation();
    superMethodInvocation.setName(localAst.newSimpleName(methodName));

    if (needParam) {
        List list = superMethodInvocation.arguments();
        list.add(localAst.newSimpleName(SFTERMINATE_STATUS_ARGUMENT_NAME));
    }

    ExpressionStatement expressionStatement = localAst.newExpressionStatement(superMethodInvocation);
    block.statements().add(expressionStatement);

    if (needToThrow) {
        List throwsExceptions = methodDeclaration.thrownExceptions();
        throwsExceptions.add(localAst.newSimpleName(SMARTFROGEXCEPTION_NAME));
        throwsExceptions.add(localAst.newSimpleName(REMOTEEXCEPTION_NAME));
    }

    typeDeclaration.bodyDeclarations().add(methodDeclaration);
}

From source file:org.smeup.sys.dk.compiler.rpj.writer.JDTCallableUnitWriter.java

License:Open Source License

@SuppressWarnings("unchecked")
public void writePrototype(QPrototype prototype) {

    MethodDeclaration methodDeclaration = getAST().newMethodDeclaration();
    getTarget().bodyDeclarations().add(methodDeclaration);

    methodDeclaration//from  w  w  w.j  a v  a 2s  . c  om
            .setName(getAST().newSimpleName(getCompilationUnit().normalizeTermName(prototype.getName())));
    methodDeclaration.modifiers().add(getAST().newModifier(ModifierKeyword.PUBLIC_KEYWORD));

    Block block = getAST().newBlock();
    methodDeclaration.setBody(block);

    if (prototype.getDefinition() != null) {
        Type type = getJavaType(prototype);
        methodDeclaration.setReturnType2(type);
    }

    // TODO QExternalProgram
    QExternalFile externalFile = prototype.getFacet(QExternalFile.class);
    if (externalFile != null) {
        writePrototypeCall(prototype, externalFile.getName(), methodDeclaration, block);

        if (prototype.getDefinition() != null) {
            ReturnStatement returnStatement = getAST().newReturnStatement();
            returnStatement.setExpression(getAST().newNullLiteral());
            block.statements().add(returnStatement);
        }

    } else {
        QProcedure procedure = getCompilationUnit().getProcedure(prototype.getName(), false);
        if (procedure == null)
            throw new DevelopmentKitCompilerRuntimeException("Invalid procedure bind: " + prototype);

        if (procedure.getEntry() != null)
            writeEntry(methodDeclaration, procedure.getEntry());

        writeLazyLoading(procedure, block);

        writeSetEntryParams(procedure, block);

        String namePrototype = getCompilationUnit().normalizeTermName(prototype.getName());
        MethodInvocation methodInvocation = getAST().newMethodInvocation();
        methodInvocation.setExpression(getAST().newName(namePrototype));
        methodInvocation.setName(getAST().newSimpleName("qExec"));

        for (Object entryParameter : methodDeclaration.parameters()) {
            SingleVariableDeclaration singleVariableDeclaration = (SingleVariableDeclaration) entryParameter;
            methodInvocation.arguments()
                    .add(getAST().newSimpleName(singleVariableDeclaration.getName().toString()));
        }

        if (prototype.getDefinition() != null) {
            ReturnStatement returnStatement = getAST().newReturnStatement();
            returnStatement.setExpression(methodInvocation);
            block.statements().add(returnStatement);
        } else {
            ExpressionStatement expressionStatement = getAST().newExpressionStatement(methodInvocation);
            block.statements().add(expressionStatement);
        }
    }
}

From source file:org.smeup.sys.dk.compiler.rpj.writer.JDTCallableUnitWriter.java

License:Open Source License

@SuppressWarnings("unchecked")
private void writePrototypeCall(QPrototype prototype, String programName, MethodDeclaration methodDeclaration,
        Block block) {

    MethodInvocation methodInvocation = getAST().newMethodInvocation();
    methodInvocation.setExpression(getAST().newSimpleName("qRPJ"));
    methodInvocation.setName(getAST().newSimpleName("qCall"));

    // program name
    QTermExpression expression = expressionParser.parseTerm(programName);
    Expression jdtExpression = JDTStatementHelper.buildExpression(getAST(), getCompilationUnit(), expression,
            String.class);
    methodInvocation.arguments().add(jdtExpression);

    // array of parameter
    ArrayInitializer arrayInitializer = getAST().newArrayInitializer();
    if (prototype.getEntry() != null) {
        writeEntry(methodDeclaration, prototype.getEntry());

        for (QEntryParameter<?> entryParameter : prototype.getEntry().getParameters()) {

            if (!(entryParameter.getDelegate() instanceof QDataTerm<?>))
                throw new DevelopmentKitCompilerRuntimeException("Invalid parameter: " + entryParameter);

            QDataTerm<?> parameterDelegate = (QDataTerm<?>) entryParameter.getDelegate();
            String parameterName = parameterDelegate.getName();
            parameterName = getCompilationUnit().normalizeTermName(parameterName);

            // call parameter
            if (parameterDelegate.isConstant() && !parameterDelegate.getDataTermType().isMultiple()
                    && !(parameterDelegate.getDefinition() instanceof QPointerDef)) {
                ASTParser parser = ASTParser.newParser(AST.JLS8);
                parser.setKind(ASTParser.K_EXPRESSION);
                parser.setSource(("qRPJ.qBox(" + parameterName + ")").toCharArray());
                ASTNode node = parser.createAST(new NullProgressMonitor());
                arrayInitializer.expressions()
                        .add((Expression) ASTNode.copySubtree(getAST(), (Expression) node));
            } else
                arrayInitializer.expressions().add(getAST().newName(parameterName));
        }//from w  ww .j a  v  a2 s . co  m
    }

    ArrayCreation arrayCreation = getAST().newArrayCreation();
    arrayCreation.setType(
            getAST().newArrayType(getAST().newSimpleType(getAST().newSimpleName(QData.class.getSimpleName()))));
    arrayCreation.setInitializer(arrayInitializer);
    methodInvocation.arguments().add(arrayCreation);

    ExpressionStatement expressionStatement = getAST().newExpressionStatement(methodInvocation);
    block.statements().add(expressionStatement);
}

From source file:org.smeup.sys.dk.compiler.rpj.writer.JDTCallableUnitWriter.java

License:Open Source License

@SuppressWarnings("unchecked")
private void writeLazyLoading(QProcedure procedure, Block block) {

    IfStatement ifStatement = getAST().newIfStatement();
    String expression = getCompilationUnit().normalizeTermName(procedure.getName()) + " == null";
    ifStatement.setExpression(buildExpression(expression));

    Assignment assignment = getAST().newAssignment();
    assignment.setLeftHandSide(buildExpression(getCompilationUnit().normalizeTermName(procedure.getName())));
    assignment.setRightHandSide(buildExpression("qRPJ.bindProcedure(this, "
            + getCompilationUnit().normalizeTypeName(procedure.getName()) + ".class)"));
    assignment.setOperator(Operator.ASSIGN);
    ifStatement.setThenStatement(getAST().newExpressionStatement(assignment));

    block.statements().add(ifStatement);
}

From source file:org.smeup.sys.dk.compiler.rpj.writer.JDTCallableUnitWriter.java

License:Open Source License

@SuppressWarnings("unchecked")
private void writeSetEntryParams(QProcedure procedure, Block block) {
    List<QEntryParameter<?>> entryParameters = new ArrayList<QEntryParameter<?>>();
    if (procedure.getEntry() != null) {
        entryParameters.addAll(procedure.getEntry().getParameters());
        Collections.reverse(entryParameters);
    }/*from  w ww.  ja  va2 s .  c o  m*/

    int p = entryParameters.size();

    IfStatement baseIf = null;
    IfStatement lastIf = null;
    for (QEntryParameter<?> entryParameter : entryParameters) {

        if (!entryParameter.isNullable())
            break;

        // first
        if (entryParameters.size() == p) {

            IfStatement ifStatement = getAST().newIfStatement();
            ifStatement.setExpression(buildExpression(
                    getCompilationUnit().normalizeTermName(entryParameter.getName()) + " != null"));
            Expression expression = buildExpression(getCompilationUnit().normalizeTermName(procedure.getName())
                    + ".qPRO.qParms().eval(" + p + ")");
            ExpressionStatement expressionStatement = getAST().newExpressionStatement(expression);
            ifStatement.setThenStatement(expressionStatement);

            Expression expressionElse = buildExpression(
                    getCompilationUnit().normalizeTermName(procedure.getName()) + ".qPRO.qParms().eval("
                            + (p - 1) + ")");
            ExpressionStatement expressionElseStatement = getAST().newExpressionStatement(expressionElse);
            ifStatement.setElseStatement(expressionElseStatement);

            baseIf = ifStatement;
            lastIf = ifStatement;
        } else {
            IfStatement ifStatement = getAST().newIfStatement();
            ifStatement.setExpression(buildExpression(
                    getCompilationUnit().normalizeTermName(entryParameter.getName()) + " != null"));

            Expression expression = buildExpression(getCompilationUnit().normalizeTermName(procedure.getName())
                    + ".qPRO.qParms().eval(" + p + ")");
            ExpressionStatement expressionStatement = getAST().newExpressionStatement(expression);
            ifStatement.setThenStatement(expressionStatement);

            Expression expressionElse = buildExpression(
                    getCompilationUnit().normalizeTermName(procedure.getName()) + ".qPRO.qParms().eval("
                            + (p - 1) + ")");
            ExpressionStatement expressionElseStatement = getAST().newExpressionStatement(expressionElse);
            ifStatement.setElseStatement(expressionElseStatement);

            lastIf.setElseStatement(ifStatement);
            lastIf = ifStatement;
        }
        p--;
    }

    if (baseIf != null)
        block.statements().add(baseIf);
}

From source file:org.smeup.sys.dk.compiler.rpj.writer.JDTCallableUnitWriter.java

License:Open Source License

@SuppressWarnings("unchecked")
public void writeInit() {

    writeImport(QBufferedElement.class);

    MethodDeclaration methodDeclaration = getAST().newMethodDeclaration();

    methodDeclaration.setName(getAST().newSimpleName("_init"));

    MarkerAnnotation entryAnnotation = getAST().newMarkerAnnotation();
    entryAnnotation.setTypeName(getAST().newSimpleName(PostConstruct.class.getSimpleName()));
    writeImport(PostConstruct.class);
    methodDeclaration.modifiers().add(entryAnnotation);

    methodDeclaration.modifiers().add(getAST().newModifier(ModifierKeyword.PUBLIC_KEYWORD));

    if (!(getCompilationUnit().getNode() instanceof QCallableUnit))
        return;/*from w w  w .j  a v a 2 s.  c o m*/

    Block block = getAST().newBlock();
    methodDeclaration.setBody(block);

    QCallableUnit callableUnit = (QCallableUnit) getCompilationUnit().getNode();
    if (callableUnit.getFileSection() != null) {

        // redefined record dataSet
        for (QDataSetTerm dataSetTerm : callableUnit.getFileSection().getDataSets()) {

            // remap
            if (dataSetTerm.getFormat() != null) {
                for (QDataTerm<?> element : dataSetTerm.getFormat().getDefinition().getElements()) {
                    QRemap remap = element.getFacet(QRemap.class);
                    if (remap == null)
                        continue;

                    QDataTerm<?> remapDataTerm = getCompilationUnit().getDataTerm(remap.getName(), true);
                    if (remapDataTerm == null)
                        throw new IntegratedLanguageExpressionRuntimeException("Invalid term: " + remap);

                    if (getCompilationUnit().equalsTermName(element.getName(), remapDataTerm.getName()))
                        continue;

                    MethodInvocation methodInvocation = getAST().newMethodInvocation();
                    methodInvocation.setName(getAST().newSimpleName("assign"));

                    if (remap.getIndex() == null || remap.getIndex().isEmpty())
                        methodInvocation.setExpression(
                                buildExpression(getCompilationUnit().getQualifiedName(remapDataTerm)));
                    else
                        methodInvocation.setExpression(
                                buildExpression(getCompilationUnit().getQualifiedName(remapDataTerm) + ".get("
                                        + Integer.parseInt(remap.getIndex()) + ")"));

                    methodInvocation.arguments()
                            .add(buildExpression(getCompilationUnit().getQualifiedName(element)));
                    ExpressionStatement expressionStatement = getAST().newExpressionStatement(methodInvocation);
                    block.statements().add(expressionStatement);

                }
            }
        }

        // assign statement parameters
        for (QCursorTerm cursorTerm : callableUnit.getFileSection().getCursors()) {
            if (cursorTerm.getSql() == null)
                continue;

            try {
                QueryStatement queryStatement = queryParser.parseQuery(cursorTerm.getSql()).getQueryStatement();

                List<ValueExpressionVariable> variables = StatementHelper
                        .getAllVariablesInQueryStatement(queryStatement);
                if (variables.isEmpty())
                    continue;

                // array of bufferedData
                ArrayCreation arrayCreation = getAST().newArrayCreation();
                arrayCreation.setType(getAST().newArrayType(getAST()
                        .newSimpleType(getAST().newSimpleName(QBufferedElement.class.getSimpleName()))));
                ArrayInitializer arrayInitializer = getAST().newArrayInitializer();
                for (ValueExpressionVariable variable : variables) {
                    QExpression expression = expressionParser
                            .parseExpression(getCompilationUnit().normalizeTermName(variable.getName()));
                    Expression jdtExpression = JDTStatementHelper.buildExpression(getAST(),
                            getCompilationUnit(), expression, null);
                    arrayInitializer.expressions().add(jdtExpression);
                }
                arrayCreation.setInitializer(arrayInitializer);

                DBLQuerySelectWriter querySelectWriter = new DBLQuerySelectWriter();
                QuerySelectStatement selectStatement = (QuerySelectStatement) queryStatement;
                QueryExpressionBody query = selectStatement.getQueryExpr().getQuery();
                queryStatement = queryParser.parseQuery(cursorTerm.getSql()).getQueryStatement();
                String newSQLString = querySelectWriter.normalizeQuerySelect((QuerySelect) query);

                StringLiteral stringLiteral = getAST().newStringLiteral();
                stringLiteral.setLiteralValue(newSQLString);

                MethodInvocation methodInvocation = getAST().newMethodInvocation();
                methodInvocation.setName(getAST().newSimpleName("qCreateCursor"));
                methodInvocation.setExpression(getAST().newSimpleName("qSQL"));

                Name labelName = getAST()
                        .newName(new String[] { cursorTerm.getCursorType().getClass().getSimpleName(),
                                cursorTerm.getCursorType().name() });
                methodInvocation.arguments().add(labelName);

                methodInvocation.arguments().add(getAST().newBooleanLiteral(cursorTerm.isHold()));

                methodInvocation.arguments().add(stringLiteral);

                methodInvocation.arguments().add(arrayCreation);

                Assignment assignment = getAST().newAssignment();
                assignment.setLeftHandSide(buildExpression(getCompilationUnit().getQualifiedName(cursorTerm)));
                assignment.setOperator(Operator.ASSIGN);
                assignment.setRightHandSide(methodInvocation);

                block.statements().add(getAST().newExpressionStatement(assignment));

            } catch (SQLException e) {
                throw new DevelopmentKitCompilerRuntimeException("Invalid statement: " + cursorTerm);
            }
        }
    }

    if (!methodDeclaration.getBody().statements().isEmpty())
        getTarget().bodyDeclarations().add(methodDeclaration);
}

From source file:org.smeup.sys.dk.compiler.rpj.writer.JDTCallableUnitWriter.java

License:Open Source License

@SuppressWarnings("unchecked")
public void writeEntry(QParameterList parameterList, String name) {

    MethodDeclaration methodDeclaration = getAST().newMethodDeclaration();
    getTarget().bodyDeclarations().add(methodDeclaration);

    methodDeclaration.setName(getAST().newSimpleName(name));

    MarkerAnnotation entryAnnotation = getAST().newMarkerAnnotation();
    entryAnnotation.setTypeName(getAST().newSimpleName(Entry.class.getSimpleName()));
    writeImport(Entry.class);
    methodDeclaration.modifiers().add(entryAnnotation);

    methodDeclaration.modifiers().add(getAST().newModifier(ModifierKeyword.PUBLIC_KEYWORD));
    Type returnType = getAST()/* w  w w .  j  a va2 s .  c  o  m*/
            .newArrayType(getAST().newSimpleType(getAST().newSimpleName(QData.class.getSimpleName())));
    methodDeclaration.setReturnType2(returnType);

    Block block = getAST().newBlock();
    methodDeclaration.setBody(block);

    ArrayCreation arrayCreation = getAST().newArrayCreation();
    arrayCreation.setType(
            getAST().newArrayType(getAST().newSimpleType(getAST().newSimpleName(QData.class.getSimpleName()))));

    ArrayInitializer arrayInitializer = getAST().newArrayInitializer();
    arrayCreation.setInitializer(arrayInitializer);
    for (String parameterName : parameterList.getParameters()) {
        QExpression expression = expressionParser.parseExpression(parameterName);
        Expression jdtExpression = JDTStatementHelper.buildExpression(getAST(), getCompilationUnit(),
                expression, null);
        arrayInitializer.expressions().add(jdtExpression);
    }

    ReturnStatement returnStatement = getAST().newReturnStatement();
    returnStatement.setExpression(arrayCreation);
    block.statements().add(returnStatement);
}

From source file:org.smeup.sys.dk.compiler.rpj.writer.JDTCallableUnitWriter.java

License:Open Source License

@SuppressWarnings("unchecked")
private void writeRoutineTestMain(MethodDeclaration methodDeclaration, QCallableUnit program) {

    QLists listUtil = getCompilationUnit().getContext().get(QLists.class);

    MarkerAnnotation entryAnnotation = getAST().newMarkerAnnotation();
    entryAnnotation.setTypeName(getAST().newSimpleName(TestStarted.class.getSimpleName()));
    writeImport(TestStarted.class);

    listUtil.addFirst(methodDeclaration.modifiers(), entryAnnotation);

    Block assertionBlock = getAST().newBlock();

    JDTStatementWriter statementWriter = getCompilationUnit().getContext().make(JDTStatementWriter.class);
    statementWriter.setAST(getAST());/*  w  w w.  j av a2  s .c o m*/
    statementWriter.getBlocks().push(assertionBlock);

    // test annotations
    for (QDataTerm<?> dataTerm : program.getDataSection().getDatas()) {
        for (QAnnotationTest annotationTest : dataTerm.getFacets(QAnnotationTest.class))
            statementWriter.writeAssertion(annotationTest, dataTerm.toString());
    }

    if (!assertionBlock.statements().isEmpty())
        listUtil.addFirst(methodDeclaration.getBody().statements(), assertionBlock);

    statementWriter.getBlocks().pop();
}

From source file:org.smeup.sys.dk.compiler.rpj.writer.JDTExpressionStringBuilder.java

License:Open Source License

private boolean writeMethod(QPrototype prototype, List<QExpression> elements) {

    QExpression expressionObject = elements.get(0);
    switch (expressionObject.getExpressionType()) {
    case ARRAY:/*w  ww .j  ava  2  s .  com*/
    case ATOMIC:
    case FUNCTION:
    case QUALIFIED:
    case ARITHMETIC:
    case BLOCK:
    case BOOLEAN:

        QMethodExec methodExec = QIntegratedLanguageFlowFactory.eINSTANCE.createMethodExec();
        methodExec.setObject(expressionWriter.writeExpression(expressionObject));
        methodExec.setMethod(prototype.getName());
        for (QExpression elementExpression : elements) {
            if (elementExpression == expressionObject)
                continue;
            methodExec.getParameters().add(expressionWriter.writeExpression(elementExpression));
        }

        JDTStatementWriter statementWriter = compilationUnit.getContext().make(JDTStatementWriter.class);
        statementWriter.setAST(getAST());
        Block block = getAST().newBlock();
        statementWriter.getBlocks().push(block);

        methodExec.accept(statementWriter);
        if (!block.statements().isEmpty()) {
            String content = block.statements().get(0).toString().trim();
            writeValue(prototype.getDefinition().getDataClass(), this.target, strings.removeLastChar(content));
        }

        statementWriter.getBlocks().pop();
        return false;
    case ASSIGNMENT:
    case LOGICAL:
    case RELATIONAL:
        break;
    }

    return true;
}

From source file:org.smeup.sys.dk.compiler.rpj.writer.JDTProcedureWriter.java

License:Open Source License

@SuppressWarnings("unchecked")
private void writeProcedureEntry(final QProcedure procedure) {

    MethodDeclaration methodDeclaration = getAST().newMethodDeclaration();
    getTarget().bodyDeclarations().add(methodDeclaration);

    methodDeclaration.setName(getAST().newSimpleName("qExec"));

    methodDeclaration.modifiers().add(getAST().newModifier(ModifierKeyword.PUBLIC_KEYWORD));

    if (procedure.getReturnType() != null) {
        QPrototype prototype = getCompilationUnit().getPrototype(procedure.getName(), true);
        if (prototype == null)
            throw new DevelopmentKitCompilerRuntimeException("Unexpected condition: wiuervy87e6x87rwe8vr");

        Type type = getJavaType(prototype);
        methodDeclaration.setReturnType2(type);
    }//from  w  w w.j  a  v  a2 s  .c  om

    Block block = getAST().newBlock();
    methodDeclaration.setBody(block);

    if (procedure.getEntry() != null) {
        writeEntry(methodDeclaration, procedure.getEntry());

        if (procedure.hasRoutines()) {
            for (QEntryParameter<?> entryParameter : procedure.getEntry().getParameters()) {

                QDataTerm<?> delegateTerm = (QDataTerm<?>) entryParameter.getDelegate();

                FieldAccess thisAccess = getAST().newFieldAccess();
                thisAccess.setExpression(getAST().newThisExpression());
                thisAccess.setName(getAST()
                        .newSimpleName(getCompilationUnit().normalizeTermName(entryParameter.getName())));

                if (delegateTerm.isConstant() && !delegateTerm.getDataTermType().isMultiple()) {
                    Assignment assignment = getAST().newAssignment();

                    assignment.setLeftHandSide(thisAccess);
                    assignment.setOperator(Operator.ASSIGN);
                    assignment.setRightHandSide(getAST()
                            .newSimpleName(getCompilationUnit().normalizeTermName(entryParameter.getName())));

                    ExpressionStatement expressionStatement = getAST().newExpressionStatement(assignment);
                    block.statements().add(expressionStatement);

                } else {

                    MethodInvocation methodInvocation = getAST().newMethodInvocation();
                    methodInvocation.setName(getAST().newSimpleName("assign"));
                    methodInvocation.setExpression(getAST()
                            .newSimpleName(getCompilationUnit().normalizeTermName(entryParameter.getName())));
                    methodInvocation.arguments().add(thisAccess);
                    ExpressionStatement expressionStatement = getAST().newExpressionStatement(methodInvocation);
                    if (entryParameter.isNullable()) {
                        IfStatement ifStatement = getAST().newIfStatement();
                        String expression = getCompilationUnit().normalizeTermName(entryParameter.getName())
                                + " != null";
                        ifStatement.setExpression(buildExpression(expression));

                        ifStatement.setThenStatement(expressionStatement);
                        block.statements().add(ifStatement);

                    } else {
                        block.statements().add(expressionStatement);
                    }
                }
            }
        }
    }

    if (procedure.getMain() != null) {
        JDTStatementWriter statementWriter = getCompilationUnit().getContext().make(JDTStatementWriter.class);
        statementWriter.setAST(getAST());

        statementWriter.getBlocks().push(block);

        if (procedure.getMain() instanceof QBlock) {
            QBlock qBlock = (QBlock) procedure.getMain();
            for (org.smeup.sys.il.flow.QStatement qStatement : qBlock.getStatements())
                qStatement.accept(statementWriter);
        } else
            procedure.getMain().accept(statementWriter);

        statementWriter.getBlocks().pop();
    }
}