/******************************************************************************* * Copyright (c) 2009, 2017 Mountainminds GmbH & Co. KG and Contributors * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Marc R. Hoffmann - initial API and implementation * *******************************************************************************/ package org.jacoco.core.internal.analysis; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; import org.jacoco.core.analysis.ICounter; import org.jacoco.core.analysis.IMethodCoverage; import org.jacoco.core.analysis.ISourceNode; import org.jacoco.core.internal.analysis.filter.EnumFilter; import org.jacoco.core.internal.analysis.filter.IFilter; import org.jacoco.core.internal.analysis.filter.IFilterOutput; import org.jacoco.core.internal.analysis.filter.LombokGeneratedFilter; import org.jacoco.core.internal.analysis.filter.SynchronizedFilter; import org.jacoco.core.internal.analysis.filter.SyntheticFilter; import org.jacoco.core.internal.flow.IFrame; import org.jacoco.core.internal.flow.Instruction; import org.jacoco.core.internal.flow.LabelInfo; import org.jacoco.core.internal.flow.MethodProbesVisitor; import org.objectweb.asm.Handle; import org.objectweb.asm.Label; import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.tree.AbstractInsnNode; import org.objectweb.asm.tree.MethodNode; import org.objectweb.asm.tree.TryCatchBlockNode; /** * A {@link MethodProbesVisitor} that analyzes which statements and branches of * a method have been executed based on given probe data. */ public class MethodAnalyzer extends MethodProbesVisitor implements IFilterOutput { private static final IFilter[] FILTERS = new IFilter[] { new EnumFilter(), new SyntheticFilter(), new SynchronizedFilter(), new LombokGeneratedFilter() }; private final String className; private final String superClassName; private final boolean[] probes; private final MethodCoverageImpl coverage; private int currentLine = ISourceNode.UNKNOWN_LINE; private int firstLine = ISourceNode.UNKNOWN_LINE; private int lastLine = ISourceNode.UNKNOWN_LINE; // Due to ASM issue #315745 there can be more than one label per instruction private final List