Search in sources :

Example 6 with SourceFileCoverageImpl

use of org.jacoco.core.internal.analysis.SourceFileCoverageImpl in project jacoco by jacoco.

the class CoverageBuilder method visitCoverage.

// === IStructureVisitor ===
public void visitCoverage(final IClassCoverage coverage) {
    // Only consider classes that actually contain code:
    if (coverage.getInstructionCounter().getTotalCount() > 0) {
        final String name = coverage.getName();
        final IClassCoverage dup = classes.put(name, coverage);
        if (dup != null) {
            if (dup.getId() != coverage.getId()) {
                throw new IllegalStateException("Can't add different class with same name: " + name);
            }
        } else {
            final String source = coverage.getSourceFileName();
            if (source != null) {
                final SourceFileCoverageImpl sourceFile = getSourceFile(source, coverage.getPackageName());
                sourceFile.increment(coverage);
            }
        }
    }
}
Also used : SourceFileCoverageImpl(org.jacoco.core.internal.analysis.SourceFileCoverageImpl)

Aggregations

SourceFileCoverageImpl (org.jacoco.core.internal.analysis.SourceFileCoverageImpl)6 IClassCoverage (org.jacoco.core.analysis.IClassCoverage)3 ISourceFileCoverage (org.jacoco.core.analysis.ISourceFileCoverage)3 PackageCoverageImpl (org.jacoco.core.internal.analysis.PackageCoverageImpl)3 ClassCoverageImpl (org.jacoco.core.internal.analysis.ClassCoverageImpl)2 Test (org.junit.Test)2 Document (org.w3c.dom.Document)2 IOException (java.io.IOException)1 Reader (java.io.Reader)1 StringReader (java.io.StringReader)1 IPackageCoverage (org.jacoco.core.analysis.IPackageCoverage)1 BundleCoverageImpl (org.jacoco.core.internal.analysis.BundleCoverageImpl)1 MethodCoverageImpl (org.jacoco.core.internal.analysis.MethodCoverageImpl)1 ISourceFileLocator (org.jacoco.report.ISourceFileLocator)1 ReportOutputFolder (org.jacoco.report.internal.ReportOutputFolder)1 ILinkable (org.jacoco.report.internal.html.ILinkable)1 Before (org.junit.Before)1