use of org.jacoco.report.internal.html.HTMLGroupVisitor in project jacoco by jacoco.
the class HTMLFormatter method createVisitor.
/**
* Creates a new visitor to write a report to the given output.
*
* @param output
* output to write the report to
* @return visitor to emit the report data to
* @throws IOException
* in case of problems with the output stream
*/
public IReportVisitor createVisitor(final IMultiReportOutput output) throws IOException {
final ReportOutputFolder root = new ReportOutputFolder(output);
resources = new Resources(root);
resources.copyResources();
index = new ElementIndex(root);
return new IReportVisitor() {
private List<SessionInfo> sessionInfos;
private Collection<ExecutionData> executionData;
private HTMLGroupVisitor groupHandler;
public void visitInfo(final List<SessionInfo> sessionInfos, final Collection<ExecutionData> executionData) throws IOException {
this.sessionInfos = sessionInfos;
this.executionData = executionData;
}
public void visitBundle(final IBundleCoverage bundle, final ISourceFileLocator locator) throws IOException {
final BundlePage page = new BundlePage(bundle, null, locator, root, HTMLFormatter.this);
createSessionsPage(page);
page.render();
}
public IReportGroupVisitor visitGroup(final String name) throws IOException {
groupHandler = new HTMLGroupVisitor(null, root, HTMLFormatter.this, name);
createSessionsPage(groupHandler.getPage());
return groupHandler;
}
private void createSessionsPage(final ReportPage rootpage) {
sessionsPage = new SessionsPage(sessionInfos, executionData, index, rootpage, root, HTMLFormatter.this);
}
public void visitEnd() throws IOException {
if (groupHandler != null) {
groupHandler.visitEnd();
}
sessionsPage.render();
output.close();
}
};
}
Aggregations