use of com.intellij.rt.coverage.data.ClassData in project intellij-plugins by JetBrains.
the class JstdCoverageEngine method generateReport.
@Override
public void generateReport(@NotNull Project project, @NotNull DataContext dataContext, @NotNull CoverageSuitesBundle currentSuiteBundle) {
CoverageReport coverageReport = new CoverageReport();
for (CoverageSuite suite : currentSuiteBundle.getSuites()) {
ProjectData projectData = suite.getCoverageData(CoverageDataManager.getInstance(project));
if (projectData != null) {
@SuppressWarnings("unchecked") Map<String, ClassData> classDataMap = projectData.getClasses();
for (Map.Entry<String, ClassData> classDataEntry : classDataMap.entrySet()) {
String fileName = classDataEntry.getKey();
ClassData classData = classDataEntry.getValue();
List<CoverageReport.LineHits> lineHitsList = convertClassDataToLineHits(classData);
coverageReport.mergeFileReport(fileName, lineHitsList);
}
}
}
final ExportToHTMLSettings settings = ExportToHTMLSettings.getInstance(project);
final File outputDir = new File(settings.OUTPUT_DIRECTORY);
FileUtil.createDirectory(outputDir);
String outputFileName = getOutputFileName(currentSuiteBundle);
String title = "Coverage Report Generation";
try {
File output = new File(outputDir, outputFileName);
CoverageSerializationUtils.writeLCOV(coverageReport, output);
refresh(output);
String url = "http://ltp.sourceforge.net/coverage/lcov.php";
Messages.showInfoMessage("<html>Coverage report has been successfully saved as '" + outputFileName + "' file.<br>Use <a href='" + url + "'>" + url + "</a>" + " to generate HTML output." + "</html>", title);
} catch (IOException e) {
LOG.warn("Can not export coverage data", e);
Messages.showErrorDialog("Can not generate coverage report: " + e.getMessage(), title);
}
}
use of com.intellij.rt.coverage.data.ClassData in project intellij-plugins by JetBrains.
the class JstdCoverageRunner method readProjectData.
@NotNull
private static ProjectData readProjectData(@NotNull File dataFile) throws IOException {
CoverageReport report = CoverageSerializationUtils.readLCOV(dataFile);
ProjectData projectData = new ProjectData();
for (Map.Entry<String, List<CoverageReport.LineHits>> entry : report.getInfo().entrySet()) {
String filePath = SimpleCoverageAnnotator.getFilePath(entry.getKey());
ClassData classData = projectData.getOrCreateClassData(filePath);
int max = 0;
List<CoverageReport.LineHits> lineHitsList = entry.getValue();
if (lineHitsList.size() > 0) {
CoverageReport.LineHits lastLineHits = lineHitsList.get(lineHitsList.size() - 1);
max = lastLineHits.getLineNumber();
}
LineData[] lines = new LineData[max + 1];
for (CoverageReport.LineHits lineHits : lineHitsList) {
LineData lineData = new LineData(lineHits.getLineNumber(), null);
lineData.setHits(lineHits.getHits());
lines[lineHits.getLineNumber()] = lineData;
}
classData.setLines(lines);
}
return projectData;
}
use of com.intellij.rt.coverage.data.ClassData 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;
}
Aggregations