Search in sources :

Example 1 with If_Clause

use of org.eclipse.titan.designer.AST.TTCN3.statements.If_Clause in project titan.EclipsePlug-ins by eclipse.

the class TestCase_Function_Visit_Handler method leave.

public void leave(IVisitableNode node) {
    if (waitForTC || waitForFunction) {
        if (node instanceof Definition_Statement) {
            if (!waitForRecord) {
                nodeVarIsRecord.add(false);
            }
            waitForRecord = false;
            waitForValue = false;
            evaluateExpression();
        }
        if (node instanceof Undefined_LowerIdentifier_Value) {
            blockReferenceListing = false;
        }
        if ((node instanceof Assignment_Statement) || ((node instanceof If_Clause))) {
            waitForValue = false;
            // if assignment is a createExpression
            if (node instanceof Assignment_Statement) {
                if (((Assignment_Statement) node).getTemplate() instanceof SpecificValue_Template) {
                    SpecificValue_Template specValTemplate = (SpecificValue_Template) ((Assignment_Statement) node).getTemplate();
                    if (specValTemplate.getSpecificValue() instanceof ComponentCreateExpression) {
                        isCreate = true;
                    }
                }
            }
            evaluateExpression();
        }
        if (node instanceof SequenceOf_Value) {
            evaluateExpression();
        }
        if ((waitForFunction && (node instanceof Return_Statement)) || (waitForTC && (node instanceof ComponentCreateExpression)) || (node instanceof Send_Statement) || (node instanceof Receive_Port_Statement)) {
            evaluateExpression();
        }
        if (waitForTcStartValues && (node instanceof Identifier) && myASTVisitor.blockIdListing) {
            myASTVisitor.blockIdListing = false;
        }
        if (waitForTcStopValues && (node instanceof Identifier) && myASTVisitor.blockIdListing) {
            myASTVisitor.blockIdListing = false;
        }
        if (node instanceof Connect_Statement) {
            waitForTcConnectValues = false;
        }
        if (node instanceof Disconnect_Statement) {
            waitForTcDisconnectValues = false;
        }
        if (node instanceof Unknown_Start_Statement) {
            waitForTcStartValues = false;
        }
        if (node instanceof Unknown_Stop_Statement) {
            waitForTcStopValues = false;
        }
        if (node instanceof Definition_Statement) {
            waitForDefStatement = false;
            if (waitForValue) {
                nodeVarValues.add(null);
                nodeVarIsAValueReference.add(false);
                waitForValue = false;
            }
        }
        if (node instanceof Map_Statement) {
            waitForMapIdentifiers = false;
        }
        if (node instanceof ComponentCreateExpression) {
            // switch first two values
            testCaseCreateValues.add(testCaseCreateCharValues.get(0));
            testCaseCreateValues.add(testCaseCreateRefValues.get(0));
            for (int i = 1; i < testCaseCreateCharValues.size(); i++) {
                testCaseCreateValues.add(testCaseCreateCharValues.get(i));
            }
            testCaseCreateCharValues.clear();
            testCaseCreateRefValues.clear();
            waitForTcCreateValues = false;
        }
        if (node instanceof Assignment_Statement) {
            waitForAssignmentIdentifiers = false;
            waitForValue = true;
        }
        if (waitForTcIfCondition && (node instanceof If_Clause)) {
            waitForTcIfCondition = false;
        }
        if (waitForTcStartParameter && (node instanceof Unknown_Start_Statement)) {
            testCaseStartValueParameters.add(null);
        }
        if (waitForTcStopParameter && (node instanceof Unknown_Stop_Statement)) {
            testCaseStopValueParameters.add(null);
        }
        if (isAltGuards && (node instanceof Operation_Altguard)) {
            altGuardConditions.add(null);
        }
        if (node instanceof Operation_Altguard) {
            waitForAltStatements = false;
            isAltGuards = false;
            isReceiveValue = false;
        }
        handleAltCases(node);
        if (node instanceof Unknown_Start_Statement) {
            waitForUnknownStartStatement = false;
        }
        if (node instanceof Unknown_Stop_Statement) {
            waitForUnknownStopStatement = false;
        }
        if (node instanceof Receive_Port_Statement) {
            if (waitForReceiveParameter) {
                altGuardReceiveType.add("noparam");
            }
        // TODO checkAnyport = true;
        }
    }
    if (node instanceof Def_Testcase) {
        handleTestcase(node);
        waitForTC = false;
    }
    if (node instanceof Def_Function) {
        handleFunction(node);
        waitForTC = false;
    }
    if (waitForAssignmentIdentifiers && (node instanceof ArraySubReference)) {
        waitForAssignmentIdentifiers = false;
    }
}
Also used : Connect_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Connect_Statement) Definition_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Definition_Statement) Def_Testcase(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Testcase) SequenceOf_Value(org.eclipse.titan.designer.AST.TTCN3.values.SequenceOf_Value) ComponentCreateExpression(org.eclipse.titan.designer.AST.TTCN3.values.expressions.ComponentCreateExpression) If_Clause(org.eclipse.titan.designer.AST.TTCN3.statements.If_Clause) Def_Function(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Function) Operation_Altguard(org.eclipse.titan.designer.AST.TTCN3.statements.Operation_Altguard) ArraySubReference(org.eclipse.titan.designer.AST.ArraySubReference) Receive_Port_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Receive_Port_Statement) Assignment_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Assignment_Statement) SpecificValue_Template(org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template) Identifier(org.eclipse.titan.designer.AST.Identifier) Unknown_Stop_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Unknown_Stop_Statement) Return_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Return_Statement) Send_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Send_Statement) Disconnect_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Disconnect_Statement) Unknown_Start_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Unknown_Start_Statement) Map_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Map_Statement) Undefined_LowerIdentifier_Value(org.eclipse.titan.designer.AST.TTCN3.values.Undefined_LowerIdentifier_Value)

Example 2 with If_Clause

use of org.eclipse.titan.designer.AST.TTCN3.statements.If_Clause in project titan.EclipsePlug-ins by eclipse.

the class IsBoundWithoutElse method process.

@Override
protected void process(final IVisitableNode node, final Problems problems) {
    if (!(node instanceof If_Statement)) {
        return;
    }
    final If_Statement ifs = (If_Statement) node;
    final StatementBlock elseClause = ifs.getStatementBlock();
    if (elseClause != null) {
        return;
    }
    // there is no else clause present
    final If_Clauses ifcs = ifs.getIfClauses();
    if (ifcs == null) {
        return;
    }
    final List<If_Clause> ifcL = ifcs.getClauses();
    if (ifcL == null || ifcL.isEmpty()) {
        return;
    }
    for (final If_Clause ifc : ifcL) {
        final IfConditionVisitor visitor = new IfConditionVisitor(problems);
        ifc.accept(visitor);
    }
}
Also used : If_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.If_Statement) If_Clauses(org.eclipse.titan.designer.AST.TTCN3.statements.If_Clauses) StatementBlock(org.eclipse.titan.designer.AST.TTCN3.statements.StatementBlock) If_Clause(org.eclipse.titan.designer.AST.TTCN3.statements.If_Clause)

Example 3 with If_Clause

use of org.eclipse.titan.designer.AST.TTCN3.statements.If_Clause in project titan.EclipsePlug-ins by eclipse.

the class LogicInversion method process.

@Override
public void process(final IVisitableNode node, final Problems problems) {
    if (node instanceof If_Statement) {
        final If_Statement s = (If_Statement) node;
        if (s.getStatementBlock() == null) {
            return;
        }
        final If_Clauses ifClauses = s.getIfClauses();
        if (ifClauses == null) {
            return;
        }
        final List<If_Clause> clauses = ifClauses.getClauses();
        if (clauses.size() != 1) {
            return;
        }
        final Value expression = clauses.get(0).getExpression();
        if (expression != null && Value_type.EXPRESSION_VALUE.equals(expression.getValuetype()) && Operation_type.NOT_OPERATION.equals(((Expression_Value) expression).getOperationType())) {
            problems.report(s.getLocation(), ERROR_MESSAGE);
        }
    }
}
Also used : Value(org.eclipse.titan.designer.AST.Value) Expression_Value(org.eclipse.titan.designer.AST.TTCN3.values.Expression_Value) Expression_Value(org.eclipse.titan.designer.AST.TTCN3.values.Expression_Value) If_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.If_Statement) If_Clauses(org.eclipse.titan.designer.AST.TTCN3.statements.If_Clauses) If_Clause(org.eclipse.titan.designer.AST.TTCN3.statements.If_Clause)

Example 4 with If_Clause

use of org.eclipse.titan.designer.AST.TTCN3.statements.If_Clause in project titan.EclipsePlug-ins by eclipse.

the class IfContext method process_internal.

protected void process_internal() {
    final If_Statement st = getNode();
    final If_Clauses ics = st.getIfClauses();
    final Context child = getChild();
    if (child != null && child.getNode().equals(ics)) {
        // the log statement is in one of the conditional clauses
        final List<If_Clause> icl = ics.getClauses();
        final Context clauseContext = child.getChild();
        if (clauseContext != null && icl.contains(clauseContext.getNode())) {
            final IVisitableNode ic = clauseContext.getNode();
            final ClauseVisitor vis = new ClauseVisitor();
            ic.accept(vis);
            final List<Reference> refs = vis.getResult();
            for (Reference ref : refs) {
                varNamesInConditions.add(ref.getDisplayName());
            }
        }
    } else {
        // the log statement is in the else block
        final List<Reference> refs = extractAllIdsFromClauses(ics);
        for (Reference ref : refs) {
            varNamesInConditions.add(ref.getDisplayName());
        }
    }
}
Also used : Reference(org.eclipse.titan.designer.AST.Reference) If_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.If_Statement) If_Clauses(org.eclipse.titan.designer.AST.TTCN3.statements.If_Clauses) If_Clause(org.eclipse.titan.designer.AST.TTCN3.statements.If_Clause) IVisitableNode(org.eclipse.titan.designer.AST.IVisitableNode)

Example 5 with If_Clause

use of org.eclipse.titan.designer.AST.TTCN3.statements.If_Clause in project titan.EclipsePlug-ins by eclipse.

the class IfContext method extractAllIdsFromClauses.

private static List<Reference> extractAllIdsFromClauses(final If_Clauses ics) {
    final List<If_Clause> icl = ics.getClauses();
    final List<Reference> ret = new ArrayList<Reference>();
    for (If_Clause ic : icl) {
        final ClauseVisitor vis = new ClauseVisitor();
        ic.accept(vis);
        ret.addAll(vis.getResult());
    }
    return ret;
}
Also used : Reference(org.eclipse.titan.designer.AST.Reference) ArrayList(java.util.ArrayList) If_Clause(org.eclipse.titan.designer.AST.TTCN3.statements.If_Clause)

Aggregations

If_Clause (org.eclipse.titan.designer.AST.TTCN3.statements.If_Clause)6 If_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.If_Statement)4 If_Clauses (org.eclipse.titan.designer.AST.TTCN3.statements.If_Clauses)3 Reference (org.eclipse.titan.designer.AST.Reference)2 Value (org.eclipse.titan.designer.AST.Value)2 ArrayList (java.util.ArrayList)1 ArraySubReference (org.eclipse.titan.designer.AST.ArraySubReference)1 IVisitableNode (org.eclipse.titan.designer.AST.IVisitableNode)1 Identifier (org.eclipse.titan.designer.AST.Identifier)1 Def_Function (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Function)1 Def_Testcase (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Testcase)1 Assignment_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Assignment_Statement)1 Connect_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Connect_Statement)1 Definition_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Definition_Statement)1 Disconnect_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Disconnect_Statement)1 Map_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Map_Statement)1 Operation_Altguard (org.eclipse.titan.designer.AST.TTCN3.statements.Operation_Altguard)1 Receive_Port_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Receive_Port_Statement)1 Return_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Return_Statement)1 Send_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Send_Statement)1