Search in sources :

Example 1 with CounterVisitor

use of org.eclipse.titanium.metrics.visitors.CounterVisitor in project titan.EclipsePlug-ins by eclipse.

the class FMLinesOfCode method measure.

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

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

Example 2 with CounterVisitor

use of org.eclipse.titanium.metrics.visitors.CounterVisitor in project titan.EclipsePlug-ins by eclipse.

the class FMDefaultActivations method measure.

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

        @Override
        public int visit(final IVisitableNode node) {
            if (node instanceof Activate_Statement) {
                count.inc();
            } else if (node instanceof Activate_Referenced_Statement) {
                count.inc();
            } else if (node instanceof ActivateDereferedExpression) {
                count.inc();
            } else if (node instanceof ActivateExpression) {
                count.inc();
            }
            return V_CONTINUE;
        }
    });
    return count.val();
}
Also used : ActivateExpression(org.eclipse.titan.designer.AST.TTCN3.values.expressions.ActivateExpression) Counter(org.eclipse.titanium.metrics.visitors.Counter) Activate_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Activate_Statement) CounterVisitor(org.eclipse.titanium.metrics.visitors.CounterVisitor) Activate_Referenced_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Activate_Referenced_Statement) ActivateDereferedExpression(org.eclipse.titan.designer.AST.TTCN3.values.expressions.ActivateDereferedExpression) IVisitableNode(org.eclipse.titan.designer.AST.IVisitableNode)

Example 3 with CounterVisitor

use of org.eclipse.titanium.metrics.visitors.CounterVisitor 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 4 with CounterVisitor

use of org.eclipse.titanium.metrics.visitors.CounterVisitor 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)4 Counter (org.eclipse.titanium.metrics.visitors.Counter)4 CounterVisitor (org.eclipse.titanium.metrics.visitors.CounterVisitor)4 StatementBlock (org.eclipse.titan.designer.AST.TTCN3.statements.StatementBlock)3 LargeLocation (org.eclipse.titan.designer.AST.LargeLocation)2 Def_Altstep (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Altstep)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 Activate_Referenced_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Activate_Referenced_Statement)1 Activate_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Activate_Statement)1 ActivateDereferedExpression (org.eclipse.titan.designer.AST.TTCN3.values.expressions.ActivateDereferedExpression)1 ActivateExpression (org.eclipse.titan.designer.AST.TTCN3.values.expressions.ActivateExpression)1