Search in sources :

Example 11 with Def_Testcase

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

the class Testcase_Type method checkThisValue.

@Override
public /**
 * {@inheritDoc}
 */
boolean checkThisValue(final CompilationTimeStamp timestamp, final IValue value, final Assignment lhs, final ValueCheckingOptions valueCheckingOptions) {
    final boolean selfReference = super.checkThisValue(timestamp, value, lhs, valueCheckingOptions);
    final IValue last = value.getValueRefdLast(timestamp, valueCheckingOptions.expected_value, null);
    if (last == null || last.getIsErroneous(timestamp)) {
        return selfReference;
    }
    last.setMyGovernor(this);
    // already handled ones
    switch(value.getValuetype()) {
        case OMIT_VALUE:
        case REFERENCED_VALUE:
            return selfReference;
        case UNDEFINED_LOWERIDENTIFIER_VALUE:
            if (Value_type.REFERENCED_VALUE.equals(last.getValuetype())) {
                return selfReference;
            }
            break;
        default:
            break;
    }
    Def_Testcase testcase = null;
    switch(last.getValuetype()) {
        case TESTCASE_REFERENCE_VALUE:
            testcase = ((Testcase_Reference_Value) last).getReferredTestcase();
            if (testcase == null) {
                setIsErroneous(true);
                return selfReference;
            }
            testcase.check(timestamp);
            break;
        case TTCN3_NULL_VALUE:
            value.setValuetype(timestamp, Value_type.FAT_NULL_VALUE);
            return selfReference;
        case EXPRESSION_VALUE:
        case MACRO_VALUE:
            // already checked
            return selfReference;
        default:
            value.getLocation().reportSemanticError(TESTCASEREFERENCEVALUEEXPECTED);
            value.setIsErroneous(true);
            return selfReference;
    }
    final Component_Type temporalRunsOnType = testcase.getRunsOnType(timestamp);
    if (temporalRunsOnType != null) {
        if (runsOnType != null && !temporalRunsOnType.isCompatible(timestamp, runsOnType, null, null, null)) {
            value.getLocation().reportSemanticError(MessageFormat.format(INCOMPATIBLERUNSONTYPESERROR, getTypename(), runsOnType.getTypename(), testcase.getAssignmentName(), temporalRunsOnType.getTypename()));
            value.setIsErroneous(true);
        }
    }
    formalParList.checkCompatibility(timestamp, testcase.getFormalParameterList(), value.getLocation());
    Component_Type temporalSystemType = testcase.getSystemType(timestamp);
    if (temporalSystemType == null) {
        temporalSystemType = temporalRunsOnType;
    }
    if (systemRef == null) {
        if (temporalSystemType != null && runsOnType != null && !temporalSystemType.isCompatible(timestamp, runsOnType, null, null, null)) {
            value.getLocation().reportSemanticError(MessageFormat.format(SYSTEMCLAUSEMISMATCHERROR, getTypename(), runsOnType.getTypename(), testcase.getAssignmentName(), temporalSystemType.getTypename()));
            value.setIsErroneous(true);
        }
    } else {
        if (temporalSystemType != null && systemType != null && !temporalSystemType.isCompatible(timestamp, systemType, null, null, null)) {
            value.getLocation().reportSemanticError(MessageFormat.format(SYSTEMCLAUSEMISMATCHERROR, getTypename(), systemType.getTypename(), testcase.getAssignmentName(), temporalSystemType.getTypename()));
            value.setIsErroneous(true);
        }
    }
    if (valueCheckingOptions.sub_check) {
        // there is no parent type to check
        if (subType != null) {
            subType.checkThisValue(timestamp, value);
        }
    }
    value.setLastTimeChecked(timestamp);
    return selfReference;
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Def_Testcase(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Testcase)

Example 12 with Def_Testcase

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

the class ModuleStatNode method getChildren.

@Override
public Object[] getChildren(final MetricData data) {
    if (initialized) {
        return children;
    }
    final List<? super IContentNode> c = new ArrayList<IContentNode>();
    if (metric instanceof FunctionMetric) {
        for (final Def_Function f : data.getFunctions().get(module)) {
            c.add(new FunctionNode((FunctionMetric) metric, f));
        }
    } else if (metric instanceof TestcaseMetric) {
        for (final Def_Testcase t : data.getTestcases().get(module)) {
            c.add(new TestcaseNode((TestcaseMetric) metric, t));
        }
    } else if (metric instanceof AltstepMetric) {
        for (final Def_Altstep a : data.getAltsteps().get(module)) {
            c.add(new AltstepNode((AltstepMetric) metric, a));
        }
    } else {
        throw new AssertionError("ModuleStatNode should have a subModule-metric");
    }
    children = c.toArray();
    initialized = true;
    return children;
}
Also used : TestcaseMetric(org.eclipse.titanium.metrics.TestcaseMetric) Def_Testcase(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Testcase) AltstepMetric(org.eclipse.titanium.metrics.AltstepMetric) ArrayList(java.util.ArrayList) FunctionMetric(org.eclipse.titanium.metrics.FunctionMetric) Def_Altstep(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Altstep) Def_Function(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Function)

Example 13 with Def_Testcase

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

the class TMLinesOfCode method measure.

@Override
public Number measure(final MetricData data, final Def_Testcase testcase) {
    final Counter count = new Counter(0);
    testcase.accept(new CounterVisitor(count) {

        @Override
        public int visit(final IVisitableNode node) {
            if (node instanceof Def_Testcase) {
                return V_CONTINUE;
            }
            if (node instanceof StatementBlock) {
                count.set(((LargeLocation) ((StatementBlock) node).getLocation()).getEndLine());
            }
            return V_SKIP;
        }
    });
    return count.val() - testcase.getLocation().getLine() + 1;
}
Also used : Counter(org.eclipse.titanium.metrics.visitors.Counter) LargeLocation(org.eclipse.titan.designer.AST.LargeLocation) Def_Testcase(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Testcase) CounterVisitor(org.eclipse.titanium.metrics.visitors.CounterVisitor) StatementBlock(org.eclipse.titan.designer.AST.TTCN3.statements.StatementBlock) IVisitableNode(org.eclipse.titan.designer.AST.IVisitableNode)

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