Search in sources :

Example 1 with LargeLocation

use of org.eclipse.titan.designer.AST.LargeLocation 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)

Example 2 with LargeLocation

use of org.eclipse.titan.designer.AST.LargeLocation in project titan.EclipsePlug-ins by eclipse.

the class AMLinesOfCode method measure.

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

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

Aggregations

IVisitableNode (org.eclipse.titan.designer.AST.IVisitableNode)2 LargeLocation (org.eclipse.titan.designer.AST.LargeLocation)2 StatementBlock (org.eclipse.titan.designer.AST.TTCN3.statements.StatementBlock)2 Counter (org.eclipse.titanium.metrics.visitors.Counter)2 CounterVisitor (org.eclipse.titanium.metrics.visitors.CounterVisitor)2 Def_Altstep (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Altstep)1 Def_Testcase (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Testcase)1