Search in sources :

Example 11 with IVisitableNode

use of org.eclipse.titan.designer.AST.IVisitableNode 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 12 with IVisitableNode

use of org.eclipse.titan.designer.AST.IVisitableNode 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 13 with IVisitableNode

use of org.eclipse.titan.designer.AST.IVisitableNode 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)13 StatementBlock (org.eclipse.titan.designer.AST.TTCN3.statements.StatementBlock)6 Identifier (org.eclipse.titan.designer.AST.Identifier)5 Reference (org.eclipse.titan.designer.AST.Reference)4 Counter (org.eclipse.titanium.metrics.visitors.Counter)4 CounterVisitor (org.eclipse.titanium.metrics.visitors.CounterVisitor)4 Map (java.util.Map)2 Scope (org.eclipse.titan.codegenerator.Scope)2 org.eclipse.titan.codegenerator.myASTVisitor (org.eclipse.titan.codegenerator.myASTVisitor)2 ASTVisitor (org.eclipse.titan.designer.AST.ASTVisitor)2 Assignment (org.eclipse.titan.designer.AST.Assignment)2 LargeLocation (org.eclipse.titan.designer.AST.LargeLocation)2 Definition (org.eclipse.titan.designer.AST.TTCN3.definitions.Definition)2 Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Statement)2 ComponentTypeBody (org.eclipse.titan.designer.AST.TTCN3.types.ComponentTypeBody)2 Type (org.eclipse.titan.designer.AST.Type)2 ArrayDeque (java.util.ArrayDeque)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1