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 asIFilterOutput
before the coverage result is calculated.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Set<org.objectweb.asm.tree.AbstractInsnNode>
ignored
private java.util.Map<org.objectweb.asm.tree.AbstractInsnNode,Instruction>
instructions
private java.util.Map<org.objectweb.asm.tree.AbstractInsnNode,org.objectweb.asm.tree.AbstractInsnNode>
merged
Instructions 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 void
applyMerges()
private void
applyReplacements()
(package private) void
calculate(MethodCoverageImpl coverage)
Applies all specified filtering commands and calculates the resulting coverage.private void
ensureCapacity(MethodCoverageImpl coverage)
private org.objectweb.asm.tree.AbstractInsnNode
findRepresentative(org.objectweb.asm.tree.AbstractInsnNode i)
void
ignore(org.objectweb.asm.tree.AbstractInsnNode fromInclusive, org.objectweb.asm.tree.AbstractInsnNode toInclusive)
Marks sequence of instructions that should be ignored during computation of coverage.void
merge(org.objectweb.asm.tree.AbstractInsnNode i1, org.objectweb.asm.tree.AbstractInsnNode i2)
Marks two instructions that should be merged during computation of coverage.void
replaceBranches(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:IFilterOutput
Marks sequence of instructions that should be ignored during computation of coverage.- Specified by:
ignore
in interfaceIFilterOutput
- Parameters:
fromInclusive
- first instruction that should be ignored, inclusivetoInclusive
- last instruction coming afterfromInclusive
that should be ignored, inclusive
-
merge
public void merge(org.objectweb.asm.tree.AbstractInsnNode i1, org.objectweb.asm.tree.AbstractInsnNode i2)
Description copied from interface:IFilterOutput
Marks two instructions that should be merged during computation of coverage.- Specified by:
merge
in 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:IFilterOutput
Marks instruction whose outgoing branches should be replaced during computation of coverage.- Specified by:
replaceBranches
in interfaceIFilterOutput
- Parameters:
source
- instruction which branches should be replacednewTargets
- new targets of branches
-
-