Search in sources :

Example 6 with Operation_Altguard

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

the class Call_Statement method checkCallBody.

/**
 * Checks the response and exception handling part of a call operation.
 *
 * @param timestamp
 *                the timestamp of the actual build cycle.
 * @param portType
 *                the port type of the actual call statement.
 * @param signature
 *                the signature type of the actual call statement.
 */
private void checkCallBody(final CompilationTimeStamp timestamp, final Port_Type portType, final IType signature) {
    boolean hasCatchTimeout = false;
    for (int i = 0; i < altGuards.getNofAltguards(); i++) {
        final AltGuard altGuard = altGuards.getAltguardByIndex(i);
        if (!altguard_type.AG_OP.equals(altGuard.getType())) {
            continue;
        }
        final Statement statement = ((Operation_Altguard) altGuard).getGuardStatement();
        if (Statement_type.S_CATCH.equals(statement.getType())) {
            ((Catch_Statement) statement).setCallSettings(true, timerValue != null);
            hasCatchTimeout |= ((Catch_Statement) statement).hasTimeout();
        }
    }
    altGuards.setMyLaicStmt(altGuards, null);
    altGuards.setMyAltguards(altGuards);
    altGuards.check(timestamp);
    if (portType != null) {
        // operation.
        for (int i = 0; i < altGuards.getNofAltguards(); i++) {
            final AltGuard altguard = altGuards.getAltguardByIndex(i);
            if (!altguard_type.AG_OP.equals(altguard.getType())) {
                continue;
            }
            final Statement statement = ((Operation_Altguard) altguard).getGuardStatement();
            if (statement.getIsErroneous()) {
                continue;
            }
            switch(statement.getType()) {
                case S_GETREPLY:
                    {
                        final Reference tempPortReference = ((Getreply_Statement) statement).getPortReference();
                        if (tempPortReference == null) {
                            final String message = MessageFormat.format("The `{0}'' operation must refer to the same port as the previous `call'' statement: `{1}'' was expected instead of `any port''", statement.getStatementName(), portReference.getId().getDisplayName());
                            statement.getLocation().reportSemanticError(message);
                        } else if (!portReference.getId().equals(tempPortReference.getId())) {
                            final String message = MessageFormat.format("The `{0}'' operation refers to a different port than the previous `call'' statement: `{1}'' was expected instead of `{2}''", statement.getStatementName(), portReference.getId().getDisplayName(), tempPortReference.getId().getDisplayName());
                            tempPortReference.getLocation().reportSemanticError(message);
                        }
                        final TemplateInstance instance = ((Getreply_Statement) statement).getReceiveParameter();
                        if (instance != null) {
                            final IType tempSignature = instance.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
                            if (tempSignature != null && signature != null && !signature.isCompatible(timestamp, tempSignature, null, null, null)) {
                                final String message = MessageFormat.format(GETRPELYTOWRONGSIGNATURE, signature.getTypename(), tempSignature.getTypename());
                                instance.getLocation().reportSemanticError(message);
                            }
                        }
                        break;
                    }
                case S_CATCH:
                    final Reference tempPortReference = ((Catch_Statement) statement).getPortReference();
                    if (tempPortReference == null) {
                        final String message = MessageFormat.format("The `{0}'' operation must refer to the same port as the previous `call'' statement: `{1}'' was expected instead of `any port''", statement.getStatementName(), portReference.getId().getDisplayName());
                        statement.getLocation().reportSemanticError(message);
                    } else if (!portReference.getId().equals(tempPortReference.getId())) {
                        final String message = MessageFormat.format("The `{0}'' operation refers to a different port than the previous `call'' statement: `{1}'' was expected instead of `{2}''", statement.getStatementName(), portReference.getId().getDisplayName(), tempPortReference.getId().getDisplayName());
                        tempPortReference.getLocation().reportSemanticError(message);
                    }
                    final Signature_Type tempSignature = ((Catch_Statement) statement).getSignatureType();
                    if (tempSignature != null && signature != null && !signature.isCompatible(timestamp, tempSignature, null, null, null)) {
                        final String message = MessageFormat.format("The `catch'' operation refers to a different signature than the previous `call'' statement: `{0}'' was expected instead of `{1}''", signature.getTypename(), tempSignature.getTypename());
                        statement.getLocation().reportSemanticError(message);
                    }
                    break;
                default:
                    break;
            }
        }
    }
    if (timerValue != null && !hasCatchTimeout) {
        location.reportSemanticWarning("The call operation has a timer, but the timeout expection is not cought");
    }
}
Also used : Reference(org.eclipse.titan.designer.AST.Reference) Signature_Type(org.eclipse.titan.designer.AST.TTCN3.types.Signature_Type) TemplateInstance(org.eclipse.titan.designer.AST.TTCN3.templates.TemplateInstance) IType(org.eclipse.titan.designer.AST.IType)

Example 7 with Operation_Altguard

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

the class ContainsRef method process.

@Override
public void process(final IVisitableNode node, final Problems problems) {
    if (node instanceof Operation_Altguard) {
        final Operation_Altguard ag = (Operation_Altguard) node;
        final Statement action = ag.getGuardStatement();
        if (action instanceof Receive_Port_Statement) {
            final Receive_Port_Statement receive = (Receive_Port_Statement) action;
            final SuspiciouslyUsedIf susp = new SuspiciouslyUsedIf(receive);
            ag.accept(susp);
            if (susp.doesSmell()) {
                problems.report(susp.getSuspicious().getLocation(), SHOULD_BRANCH);
            }
        }
    }
}
Also used : Receive_Port_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Receive_Port_Statement) Receive_Port_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Receive_Port_Statement) Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Statement) If_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.If_Statement) Operation_Altguard(org.eclipse.titan.designer.AST.TTCN3.statements.Operation_Altguard)

Example 8 with Operation_Altguard

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

the class SuperfluousTemplate method process.

@Override
public void process(final IVisitableNode node, final Problems problems) {
    if (node instanceof Operation_Altguard) {
        final Operation_Altguard ag = (Operation_Altguard) node;
        final Statement action = ag.getGuardStatement();
        if (action instanceof Receive_Port_Statement) {
            final Receive_Port_Statement receive = (Receive_Port_Statement) action;
            final SuperfluousTemplate st = new SuperfluousTemplate(receive);
            receive.accept(st);
            if (st.canReceiveAny() && st.hasValueRedirect()) {
                if (st.getReceivable() == null) {
                    problems.report(receive.getLocation(), CAN_RECEIVE_ANY_OF_MULTIPLE);
                } else {
                    problems.report(receive.getLocation(), CAN_RECEIVE_ANY_OF_ONE);
                }
            }
        }
    }
}
Also used : Receive_Port_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Receive_Port_Statement) Receive_Port_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Receive_Port_Statement) Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Statement) Operation_Altguard(org.eclipse.titan.designer.AST.TTCN3.statements.Operation_Altguard)

Aggregations

Operation_Altguard (org.eclipse.titan.designer.AST.TTCN3.statements.Operation_Altguard)4 Receive_Port_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Receive_Port_Statement)4 IValue (org.eclipse.titan.designer.AST.IValue)3 Reference (org.eclipse.titan.designer.AST.Reference)3 Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Statement)3 ExpressionStruct (org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct)3 Assignment (org.eclipse.titan.designer.AST.Assignment)2 ISubReference (org.eclipse.titan.designer.AST.ISubReference)2 ParameterisedSubReference (org.eclipse.titan.designer.AST.ParameterisedSubReference)2 AltGuard.altguard_type (org.eclipse.titan.designer.AST.TTCN3.statements.AltGuard.altguard_type)2 Assignment_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Assignment_Statement)2 Send_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Send_Statement)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 ArraySubReference (org.eclipse.titan.designer.AST.ArraySubReference)1 IType (org.eclipse.titan.designer.AST.IType)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 AltGuard (org.eclipse.titan.designer.AST.TTCN3.statements.AltGuard)1 AltGuards (org.eclipse.titan.designer.AST.TTCN3.statements.AltGuards)1