Class SourceNodeImpl
- java.lang.Object
-
- org.jacoco.core.analysis.CoverageNodeImpl
-
- org.jacoco.core.internal.analysis.SourceNodeImpl
-
- All Implemented Interfaces:
ICoverageNode
,ISourceNode
- Direct Known Subclasses:
ClassCoverageImpl
,MethodCoverageImpl
,SourceFileCoverageImpl
public class SourceNodeImpl extends CoverageNodeImpl implements ISourceNode
Implementation ofISourceNode
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.jacoco.core.analysis.ICoverageNode
ICoverageNode.CounterEntity, ICoverageNode.ElementType
-
-
Field Summary
Fields Modifier and Type Field Description private LineImpl[]
lines
private int
offset
first line number inlines
-
Fields inherited from class org.jacoco.core.analysis.CoverageNodeImpl
branchCounter, classCounter, complexityCounter, instructionCounter, lineCounter, methodCounter
-
Fields inherited from interface org.jacoco.core.analysis.ISourceNode
UNKNOWN_LINE
-
-
Constructor Summary
Constructors Constructor Description SourceNodeImpl(ICoverageNode.ElementType elementType, java.lang.String name)
Create a new source node implementation instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
ensureCapacity(int first, int last)
Make sure that the internal buffer can keep lines from first to last.int
getFirstLine()
The number of the first line coverage information is available for.int
getLastLine()
The number of the last line coverage information is available for.LineImpl
getLine(int nr)
Returns the line information for given line.void
increment(ICounter instructions, ICounter branches, int line)
Increments instructions and branches by the given counter values.void
increment(ISourceNode child)
Increments all counters by the values of the given child.private void
incrementLine(ICounter instructions, ICounter branches, int line)
-
Methods inherited from class org.jacoco.core.analysis.CoverageNodeImpl
containsCode, getBranchCounter, getClassCounter, getComplexityCounter, getCounter, getElementType, getInstructionCounter, getLineCounter, getMethodCounter, getName, getPlainCopy, increment, increment, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.jacoco.core.analysis.ICoverageNode
containsCode, getBranchCounter, getClassCounter, getComplexityCounter, getCounter, getElementType, getInstructionCounter, getLineCounter, getMethodCounter, getName, getPlainCopy
-
-
-
-
Constructor Detail
-
SourceNodeImpl
public SourceNodeImpl(ICoverageNode.ElementType elementType, java.lang.String name)
Create a new source node implementation instance.- Parameters:
elementType
- element typename
- name of the element
-
-
Method Detail
-
ensureCapacity
public void ensureCapacity(int first, int last)
Make sure that the internal buffer can keep lines from first to last. While the buffer is also incremented automatically, this method allows optimization in case the total range is known in advance.- Parameters:
first
- first line number orISourceNode.UNKNOWN_LINE
last
- last line number orISourceNode.UNKNOWN_LINE
-
increment
public void increment(ISourceNode child)
Increments all counters by the values of the given child. When incrementing the line counter it is assumed that the child refers to the same source file.- Parameters:
child
- child node to add
-
increment
public void increment(ICounter instructions, ICounter branches, int line)
Increments instructions and branches by the given counter values. If a optional line number is specified the instructions and branches are added to the given line. The line counter is incremented accordingly.- Parameters:
instructions
- instructions to addbranches
- branches to addline
- optional line number orISourceNode.UNKNOWN_LINE
-
getFirstLine
public int getFirstLine()
Description copied from interface:ISourceNode
The number of the first line coverage information is available for. If no line is contained, the method returns -1.- Specified by:
getFirstLine
in interfaceISourceNode
- Returns:
- number of the first line or
ISourceNode.UNKNOWN_LINE
-
getLastLine
public int getLastLine()
Description copied from interface:ISourceNode
The number of the last line coverage information is available for. If no line is contained, the method returns -1.- Specified by:
getLastLine
in interfaceISourceNode
- Returns:
- number of the last line or
ISourceNode.UNKNOWN_LINE
-
getLine
public LineImpl getLine(int nr)
Description copied from interface:ISourceNode
Returns the line information for given line.- Specified by:
getLine
in interfaceISourceNode
- Parameters:
nr
- line number of interest- Returns:
- line information
-
-