Search in sources :

Example 1 with AnalyzerAdapter

use of org.objectweb.asm.commons.AnalyzerAdapter in project jacoco by jacoco.

the class ClassProbesAdapter method visitMethod.

@Override
public final MethodVisitor visitMethod(final int access, final String name, final String desc, final String signature, final String[] exceptions) {
    final MethodProbesVisitor methodProbes;
    final MethodProbesVisitor mv = cv.visitMethod(access, name, desc, signature, exceptions);
    if (mv == null) {
        // We need to visit the method in any case, otherwise probe ids
        // are not reproducible
        methodProbes = EMPTY_METHOD_PROBES_VISITOR;
    } else {
        methodProbes = mv;
    }
    return new MethodSanitizer(null, access, name, desc, signature, exceptions) {

        @Override
        public void visitEnd() {
            super.visitEnd();
            LabelFlowAnalyzer.markLabels(this);
            final MethodProbesAdapter probesAdapter = new MethodProbesAdapter(methodProbes, ClassProbesAdapter.this);
            if (trackFrames) {
                final AnalyzerAdapter analyzer = new AnalyzerAdapter(ClassProbesAdapter.this.name, access, name, desc, probesAdapter);
                probesAdapter.setAnalyzer(analyzer);
                methodProbes.accept(this, analyzer);
            } else {
                methodProbes.accept(this, probesAdapter);
            }
        }
    };
}
Also used : AnalyzerAdapter(org.objectweb.asm.commons.AnalyzerAdapter)

Example 2 with AnalyzerAdapter

use of org.objectweb.asm.commons.AnalyzerAdapter in project jacoco by jacoco.

the class MethodProbesAdapterTest method setup.

@Before
public void setup() {
    label = new Label();
    id = 1000;
    expected = new MethodRecorder();
    expectedVisitor = new TraceAdapter(expected);
    actual = new MethodRecorder();
    MethodProbesVisitor actualVisitor = new TraceAdapter(actual);
    MethodProbesAdapter probesAdapter = new MethodProbesAdapter(actualVisitor, this);
    final AnalyzerAdapter analyzer = new AnalyzerAdapter("Foo", 0, "doit", "()V", probesAdapter);
    probesAdapter.setAnalyzer(analyzer);
    adapter = analyzer;
    frame = new IFrame() {

        public void accept(MethodVisitor mv) {
        }
    };
}
Also used : AnalyzerAdapter(org.objectweb.asm.commons.AnalyzerAdapter) MethodRecorder(org.jacoco.core.instr.MethodRecorder) Label(org.objectweb.asm.Label) MethodVisitor(org.objectweb.asm.MethodVisitor) Before(org.junit.Before)

Example 3 with AnalyzerAdapter

use of org.objectweb.asm.commons.AnalyzerAdapter in project jacoco by jacoco.

the class FrameSnapshotTest method setup.

@Before
public void setup() {
    analyzer = new AnalyzerAdapter("Foo", 0, "doit", "()V", null);
    expected = new MethodRecorder();
    expectedVisitor = expected.getVisitor();
}
Also used : AnalyzerAdapter(org.objectweb.asm.commons.AnalyzerAdapter) MethodRecorder(org.jacoco.core.instr.MethodRecorder) Before(org.junit.Before)

Aggregations

AnalyzerAdapter (org.objectweb.asm.commons.AnalyzerAdapter)3 MethodRecorder (org.jacoco.core.instr.MethodRecorder)2 Before (org.junit.Before)2 Label (org.objectweb.asm.Label)1 MethodVisitor (org.objectweb.asm.MethodVisitor)1