Class MethodCoverageCalculator
- java.lang.Object
-
- org.jacoco.core.internal.analysis.MethodCoverageCalculator
-
- All Implemented Interfaces:
IFilterOutput
class MethodCoverageCalculator extends java.lang.Object implements IFilterOutput
Calculates the filtered coverage of a single method. A instance of this class can be first used asIFilterOutputbefore the coverage result is calculated.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Set<org.objectweb.asm.tree.AbstractInsnNode>ignoredprivate java.util.Map<org.objectweb.asm.tree.AbstractInsnNode,Instruction>instructionsprivate java.util.Map<org.objectweb.asm.tree.AbstractInsnNode,org.objectweb.asm.tree.AbstractInsnNode>mergedInstructions that should be merged form disjoint sets.private java.util.Map<org.objectweb.asm.tree.AbstractInsnNode,java.util.Set<org.objectweb.asm.tree.AbstractInsnNode>>replacements
-
Constructor Summary
Constructors Constructor Description MethodCoverageCalculator(java.util.Map<org.objectweb.asm.tree.AbstractInsnNode,Instruction> instructions)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidapplyMerges()private voidapplyReplacements()(package private) voidcalculate(MethodCoverageImpl coverage)Applies all specified filtering commands and calculates the resulting coverage.private voidensureCapacity(MethodCoverageImpl coverage)private org.objectweb.asm.tree.AbstractInsnNodefindRepresentative(org.objectweb.asm.tree.AbstractInsnNode i)voidignore(org.objectweb.asm.tree.AbstractInsnNode fromInclusive, org.objectweb.asm.tree.AbstractInsnNode toInclusive)Marks sequence of instructions that should be ignored during computation of coverage.voidmerge(org.objectweb.asm.tree.AbstractInsnNode i1, org.objectweb.asm.tree.AbstractInsnNode i2)Marks two instructions that should be merged during computation of coverage.voidreplaceBranches(org.objectweb.asm.tree.AbstractInsnNode source, java.util.Set<org.objectweb.asm.tree.AbstractInsnNode> newTargets)Marks instruction whose outgoing branches should be replaced during computation of coverage.
-
-
-
Field Detail
-
instructions
private final java.util.Map<org.objectweb.asm.tree.AbstractInsnNode,Instruction> instructions
-
ignored
private final java.util.Set<org.objectweb.asm.tree.AbstractInsnNode> ignored
-
merged
private final java.util.Map<org.objectweb.asm.tree.AbstractInsnNode,org.objectweb.asm.tree.AbstractInsnNode> merged
Instructions that should be merged form disjoint sets. Coverage information from instructions of one set will be merged into representative instruction of set. Each such set is represented as a singly linked list: each element except one references another element from the same set, element without reference - is a representative of this set. This map stores reference (value) for elements of sets (key).
-
replacements
private final java.util.Map<org.objectweb.asm.tree.AbstractInsnNode,java.util.Set<org.objectweb.asm.tree.AbstractInsnNode>> replacements
-
-
Constructor Detail
-
MethodCoverageCalculator
MethodCoverageCalculator(java.util.Map<org.objectweb.asm.tree.AbstractInsnNode,Instruction> instructions)
-
-
Method Detail
-
calculate
void calculate(MethodCoverageImpl coverage)
Applies all specified filtering commands and calculates the resulting coverage.- Parameters:
coverage- the result is added to this coverage node
-
applyMerges
private void applyMerges()
-
applyReplacements
private void applyReplacements()
-
ensureCapacity
private void ensureCapacity(MethodCoverageImpl coverage)
-
findRepresentative
private org.objectweb.asm.tree.AbstractInsnNode findRepresentative(org.objectweb.asm.tree.AbstractInsnNode i)
-
ignore
public void ignore(org.objectweb.asm.tree.AbstractInsnNode fromInclusive, org.objectweb.asm.tree.AbstractInsnNode toInclusive)Description copied from interface:IFilterOutputMarks sequence of instructions that should be ignored during computation of coverage.- Specified by:
ignorein interfaceIFilterOutput- Parameters:
fromInclusive- first instruction that should be ignored, inclusivetoInclusive- last instruction coming afterfromInclusivethat should be ignored, inclusive
-
merge
public void merge(org.objectweb.asm.tree.AbstractInsnNode i1, org.objectweb.asm.tree.AbstractInsnNode i2)Description copied from interface:IFilterOutputMarks two instructions that should be merged during computation of coverage.- Specified by:
mergein interfaceIFilterOutput- Parameters:
i1- first instructioni2- second instruction
-
replaceBranches
public void replaceBranches(org.objectweb.asm.tree.AbstractInsnNode source, java.util.Set<org.objectweb.asm.tree.AbstractInsnNode> newTargets)Description copied from interface:IFilterOutputMarks instruction whose outgoing branches should be replaced during computation of coverage.- Specified by:
replaceBranchesin interfaceIFilterOutput- Parameters:
source- instruction which branches should be replacednewTargets- new targets of branches
-
-