Class MethodCoverageCalculator

java.lang.Object
org.jacoco.core.internal.analysis.MethodCoverageCalculator
All Implemented Interfaces:
IFilterOutput

class MethodCoverageCalculator extends Object implements IFilterOutput
Calculates the filtered coverage of a single method. A instance of this class can be first used as IFilterOutput before the coverage result is calculated.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Set<org.objectweb.asm.tree.AbstractInsnNode>
     
    private final Map<org.objectweb.asm.tree.AbstractInsnNode,Instruction>
     
    private final Map<org.objectweb.asm.tree.AbstractInsnNode,org.objectweb.asm.tree.AbstractInsnNode>
    Instructions that should be merged form disjoint sets.
    private final Map<org.objectweb.asm.tree.AbstractInsnNode,Set<org.objectweb.asm.tree.AbstractInsnNode>>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    MethodCoverageCalculator(Map<org.objectweb.asm.tree.AbstractInsnNode,Instruction> instructions)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private void
     
    private void
     
    (package private) void
    Applies all specified filtering commands and calculates the resulting coverage.
    private void
     
    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, Set<org.objectweb.asm.tree.AbstractInsnNode> newTargets)
    Marks instruction whose outgoing branches should be replaced during computation of coverage.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • instructions

      private final Map<org.objectweb.asm.tree.AbstractInsnNode,Instruction> instructions
    • ignored

      private final Set<org.objectweb.asm.tree.AbstractInsnNode> ignored
    • merged

      private final 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 Map<org.objectweb.asm.tree.AbstractInsnNode,Set<org.objectweb.asm.tree.AbstractInsnNode>> replacements
  • Constructor Details

    • MethodCoverageCalculator

      MethodCoverageCalculator(Map<org.objectweb.asm.tree.AbstractInsnNode,Instruction> instructions)
  • Method Details

    • 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 interface IFilterOutput
      Parameters:
      fromInclusive - first instruction that should be ignored, inclusive
      toInclusive - last instruction coming after fromInclusive 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 interface IFilterOutput
      Parameters:
      i1 - first instruction
      i2 - second instruction
    • replaceBranches

      public void replaceBranches(org.objectweb.asm.tree.AbstractInsnNode source, 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 interface IFilterOutput
      Parameters:
      source - instruction which branches should be replaced
      newTargets - new targets of branches