Search in sources :

Example 1 with Def_Testcase

use of org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Testcase 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 Def_Testcase

use of org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Testcase in project titan.EclipsePlug-ins by eclipse.

the class ActivateDereferedExpression method generateCodeExpressionExpression.

@Override
public /**
 * {@inheritDoc}
 */
void generateCodeExpressionExpression(final JavaGenData aData, final ExpressionStruct expression) {
    final IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
    final IValue last = value.getValueRefdLast(CompilationTimeStamp.getBaseTimestamp(), chain);
    chain.release();
    if (last.getValuetype() == Value_type.ALTSTEP_REFERENCE_VALUE) {
        // the referred testcase is known
        final Def_Testcase testcase = ((Testcase_Reference_Value) last).getReferredTestcase();
        expression.expression.append(MessageFormat.format("{0}(", testcase.getGenNameFromScope(aData, expression.expression, myScope, "activate_")));
    } else {
        // the referred testcase is unknown
        value.generateCodeExpressionMandatory(aData, expression, true);
        expression.expression.append(".activate(");
    }
    actualParameters.generateCodeAlias(aData, expression);
    expression.expression.append(')');
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Def_Testcase(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Testcase) Testcase_Reference_Value(org.eclipse.titan.designer.AST.TTCN3.values.Testcase_Reference_Value) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain)

Example 3 with Def_Testcase

use of org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Testcase in project titan.EclipsePlug-ins by eclipse.

the class Scope method checkRunsOnScope.

/**
 * Checks that operations that can only be executed in definitions that
 * have a runs on scope, are really executed in such a definition. And
 * that the required runs on component is compatible with the runs on
 * component of the definition.
 *
 * @param timestamp
 *                the timestamp of the actual semantic check cycle.
 * @param assignment
 *                the assignment to check (used or referred to by the
 *                statement).
 * @param errorLocation
 *                the location to report the error to.
 * @param operation
 *                the name of the operation.
 */
public void checkRunsOnScope(final CompilationTimeStamp timestamp, final Assignment assignment, final ILocateableNode errorLocation, final String operation) {
    Component_Type referencedComponent;
    switch(assignment.getAssignmentType()) {
        case A_ALTSTEP:
            referencedComponent = ((Def_Altstep) assignment).getRunsOnType(timestamp);
            break;
        case A_FUNCTION:
        case A_FUNCTION_RVAL:
        case A_FUNCTION_RTEMP:
            referencedComponent = ((Def_Function) assignment).getRunsOnType(timestamp);
            break;
        case A_TESTCASE:
            referencedComponent = ((Def_Testcase) assignment).getRunsOnType(timestamp);
            break;
        default:
            return;
    }
    if (referencedComponent == null) {
        return;
    }
    final RunsOnScope runsOnScope = getScopeRunsOn();
    if (runsOnScope == null) {
        errorLocation.getLocation().reportSemanticError(MessageFormat.format(RUNSONREQUIRED, operation, assignment.getDescription(), referencedComponent.getTypename()));
    } else {
        final Component_Type localType = runsOnScope.getComponentType();
        if (!referencedComponent.isCompatible(timestamp, localType, null, null, null)) {
            errorLocation.getLocation().reportSemanticError(MessageFormat.format(RUNSONMISSMATCH, localType.getTypename(), operation, assignment.getDescription(), referencedComponent.getTypename()));
        }
    }
}
Also used : Component_Type(org.eclipse.titan.designer.AST.TTCN3.types.Component_Type) RunsOnScope(org.eclipse.titan.designer.AST.TTCN3.definitions.RunsOnScope)

Example 4 with Def_Testcase

use of org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Testcase in project titan.EclipsePlug-ins by eclipse.

the class Shorthand method check.

protected void check(final Statement s, final Problems problems) {
    if (s == null) {
        return;
    }
    // shorthand statements are ignored inside alt statements
    INamedNode curr = s;
    while (curr != null) {
        if (curr instanceof Alt_Statement || curr instanceof Call_Statement) {
            return;
        }
        curr = curr.getNameParent();
    }
    final StatementBlock sb = s.getMyStatementBlock();
    if (sb == null) {
        return;
    }
    final Definition d = sb.getMyDefinition();
    if (d == null) {
        return;
    }
    // shorthand statements are marked in functions, test cases and altsteps that have a 'runs on' clause
    if (d instanceof Def_Function && ((Def_Function) d).getRunsOnType(timestamp) != null) {
        problems.report(s.getLocation(), ERROR_MESSAGE_PREFIX + typename + ERROR_MESSAGE_SUFFIX);
        return;
    }
    if (d instanceof Def_Altstep || d instanceof Def_Testcase) {
        problems.report(s.getLocation(), ERROR_MESSAGE_PREFIX + typename + ERROR_MESSAGE_SUFFIX);
    }
}
Also used : Def_Testcase(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Testcase) INamedNode(org.eclipse.titan.designer.AST.INamedNode) Call_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Call_Statement) Alt_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Alt_Statement) Definition(org.eclipse.titan.designer.AST.TTCN3.definitions.Definition) Def_Altstep(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Altstep) StatementBlock(org.eclipse.titan.designer.AST.TTCN3.statements.StatementBlock) Def_Function(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Function)

Example 5 with Def_Testcase

use of org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Testcase in project titan.EclipsePlug-ins by eclipse.

the class ChangeCreator method analyzeFunction.

/**
 * Analyze a function or testcase
 */
private List<Edit> analyzeFunction(final Definition def) {
    if (!(def instanceof Def_Function || def instanceof Def_Testcase)) {
        ErrorReporter.logError("ChangeCreator.analyzeFunction(): def must be a Def_Function or a Def_Testcase! def type: " + def.getClass());
        return null;
    }
    final FunctionAnalyzer vis = new FunctionAnalyzer();
    def.accept(vis);
    final Environment env = vis.getResult();
    final List<Edit> eds = env.refactor();
    return eds;
}
Also used : Def_Testcase(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Testcase) Environment(org.eclipse.titanium.refactoring.scope.nodes.Environment) Edit(org.eclipse.titanium.refactoring.scope.nodes.Edit) InsertEdit(org.eclipse.text.edits.InsertEdit) MultiTextEdit(org.eclipse.text.edits.MultiTextEdit) TextEdit(org.eclipse.text.edits.TextEdit) DeleteEdit(org.eclipse.text.edits.DeleteEdit) Def_Function(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Function)

Aggregations

Def_Testcase (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Testcase)12 Def_Function (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Function)8 Def_Altstep (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Altstep)5 ArrayList (java.util.ArrayList)4 IValue (org.eclipse.titan.designer.AST.IValue)3 Testcase_Reference_Value (org.eclipse.titan.designer.AST.TTCN3.values.Testcase_Reference_Value)3 HashMap (java.util.HashMap)2 DeleteEdit (org.eclipse.text.edits.DeleteEdit)2 InsertEdit (org.eclipse.text.edits.InsertEdit)2 MultiTextEdit (org.eclipse.text.edits.MultiTextEdit)2 TextEdit (org.eclipse.text.edits.TextEdit)2 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)2 Identifier (org.eclipse.titan.designer.AST.Identifier)2 Module (org.eclipse.titan.designer.AST.Module)2 Definition (org.eclipse.titan.designer.AST.TTCN3.definitions.Definition)2 StatementBlock (org.eclipse.titan.designer.AST.TTCN3.statements.StatementBlock)2 Component_Type (org.eclipse.titan.designer.AST.TTCN3.types.Component_Type)2 Edit (org.eclipse.titanium.refactoring.scope.nodes.Edit)2 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1