Search in sources :

Example 1 with LcovCoverageReport

use of com.intellij.javascript.testFramework.coverage.LcovCoverageReport in project intellij-plugins by JetBrains.

the class KarmaCoverageRunner method readProjectData.

@NotNull
private static ProjectData readProjectData(@NotNull File dataFile, @NotNull File basePath) throws IOException {
    ProjectData projectData = new ProjectData();
    LcovCoverageReport report = CoverageSerializationUtils.readLCOV(basePath, dataFile);
    for (Map.Entry<String, List<LcovCoverageReport.LineHits>> entry : report.getInfo().entrySet()) {
        String filePath = entry.getKey();
        ClassData classData = projectData.getOrCreateClassData(filePath);
        int max = 0;
        List<LcovCoverageReport.LineHits> lineHitsList = entry.getValue();
        if (lineHitsList.size() > 0) {
            LcovCoverageReport.LineHits lastLineHits = lineHitsList.get(lineHitsList.size() - 1);
            max = lastLineHits.getLineNumber();
        }
        LineData[] lines = new LineData[max + 1];
        for (LcovCoverageReport.LineHits lineHits : lineHitsList) {
            LineData lineData = new LineData(lineHits.getLineNumber(), null);
            lineData.setHits(lineHits.getHits());
            lines[lineHits.getLineNumber()] = lineData;
        }
        classData.setLines(lines);
    }
    return projectData;
}
Also used : LcovCoverageReport(com.intellij.javascript.testFramework.coverage.LcovCoverageReport) LineData(com.intellij.rt.coverage.data.LineData) ClassData(com.intellij.rt.coverage.data.ClassData) List(java.util.List) Map(java.util.Map) ProjectData(com.intellij.rt.coverage.data.ProjectData) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

LcovCoverageReport (com.intellij.javascript.testFramework.coverage.LcovCoverageReport)1 ClassData (com.intellij.rt.coverage.data.ClassData)1 LineData (com.intellij.rt.coverage.data.LineData)1 ProjectData (com.intellij.rt.coverage.data.ProjectData)1 List (java.util.List)1 Map (java.util.Map)1 NotNull (org.jetbrains.annotations.NotNull)1