Search in sources :

Example 1 with MetricMemoizer

use of net.sourceforge.pmd.lang.metrics.MetricMemoizer in project pmd by pmd.

the class ProjectMemoizerTest method visitWith.

private List<Integer> visitWith(ASTCompilationUnit acu, final boolean force) {
    final JavaProjectMemoizer toplevel = JavaMetrics.getFacade().getLanguageSpecificProjectMemoizer();
    final List<Integer> result = new ArrayList<>();
    acu.jjtAccept(new JavaParserVisitorReducedAdapter() {

        @Override
        public Object visit(ASTMethodOrConstructorDeclaration node, Object data) {
            MetricMemoizer<MethodLikeNode> op = toplevel.getOperationMemoizer(node.getQualifiedName());
            result.add((int) JavaMetricsComputer.INSTANCE.computeForOperation(opMetricKey, node, force, MetricOptions.emptyOptions(), op));
            return super.visit(node, data);
        }

        @Override
        public Object visit(ASTAnyTypeDeclaration node, Object data) {
            MetricMemoizer<ASTAnyTypeDeclaration> clazz = toplevel.getClassMemoizer(node.getQualifiedName());
            result.add((int) JavaMetricsComputer.INSTANCE.computeForType(classMetricKey, node, force, MetricOptions.emptyOptions(), clazz));
            return super.visit(node, data);
        }
    }, null);
    return result;
}
Also used : ArrayList(java.util.ArrayList) JavaParserVisitorReducedAdapter(net.sourceforge.pmd.lang.java.ast.JavaParserVisitorReducedAdapter) MetricMemoizer(net.sourceforge.pmd.lang.metrics.MetricMemoizer) ASTAnyTypeDeclaration(net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration) ASTMethodOrConstructorDeclaration(net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration)

Example 2 with MetricMemoizer

use of net.sourceforge.pmd.lang.metrics.MetricMemoizer in project pmd by pmd.

the class ApexProjectMirrorTest method visitWith.

private List<Integer> visitWith(ApexNode<Compilation> acu, final boolean force) {
    final ApexProjectMemoizer toplevel = ApexMetrics.getFacade().getLanguageSpecificProjectMemoizer();
    final List<Integer> result = new ArrayList<>();
    acu.jjtAccept(new ApexParserVisitorAdapter() {

        @Override
        public Object visit(ASTMethod node, Object data) {
            MetricMemoizer<ASTMethod> op = toplevel.getOperationMemoizer(node.getQualifiedName());
            result.add((int) ApexMetricsComputer.INSTANCE.computeForOperation(opMetricKey, node, force, MetricOptions.emptyOptions(), op));
            return super.visit(node, data);
        }

        @Override
        public Object visit(ASTUserClass node, Object data) {
            MetricMemoizer<ASTUserClassOrInterface<?>> clazz = toplevel.getClassMemoizer(node.getQualifiedName());
            result.add((int) ApexMetricsComputer.INSTANCE.computeForType(classMetricKey, node, force, MetricOptions.emptyOptions(), clazz));
            return super.visit(node, data);
        }
    }, null);
    return result;
}
Also used : ASTUserClass(net.sourceforge.pmd.lang.apex.ast.ASTUserClass) ASTMethod(net.sourceforge.pmd.lang.apex.ast.ASTMethod) ArrayList(java.util.ArrayList) MetricMemoizer(net.sourceforge.pmd.lang.metrics.MetricMemoizer) ApexParserVisitorAdapter(net.sourceforge.pmd.lang.apex.ast.ApexParserVisitorAdapter)

Aggregations

ArrayList (java.util.ArrayList)2 MetricMemoizer (net.sourceforge.pmd.lang.metrics.MetricMemoizer)2 ASTMethod (net.sourceforge.pmd.lang.apex.ast.ASTMethod)1 ASTUserClass (net.sourceforge.pmd.lang.apex.ast.ASTUserClass)1 ApexParserVisitorAdapter (net.sourceforge.pmd.lang.apex.ast.ApexParserVisitorAdapter)1 ASTAnyTypeDeclaration (net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration)1 ASTMethodOrConstructorDeclaration (net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration)1 JavaParserVisitorReducedAdapter (net.sourceforge.pmd.lang.java.ast.JavaParserVisitorReducedAdapter)1