Search in sources :

Example 1 with HTMLGroupVisitor

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();
        }
    };
}
Also used : ReportOutputFolder(org.jacoco.report.internal.ReportOutputFolder) SessionsPage(org.jacoco.report.internal.html.page.SessionsPage) ISourceFileLocator(org.jacoco.report.ISourceFileLocator) ReportPage(org.jacoco.report.internal.html.page.ReportPage) IReportVisitor(org.jacoco.report.IReportVisitor) HTMLGroupVisitor(org.jacoco.report.internal.html.HTMLGroupVisitor) BundlePage(org.jacoco.report.internal.html.page.BundlePage) Collection(java.util.Collection) IBundleCoverage(org.jacoco.core.analysis.IBundleCoverage) List(java.util.List) Resources(org.jacoco.report.internal.html.resources.Resources) ElementIndex(org.jacoco.report.internal.html.index.ElementIndex)

Aggregations

Collection (java.util.Collection)1 List (java.util.List)1 IBundleCoverage (org.jacoco.core.analysis.IBundleCoverage)1 IReportVisitor (org.jacoco.report.IReportVisitor)1 ISourceFileLocator (org.jacoco.report.ISourceFileLocator)1 ReportOutputFolder (org.jacoco.report.internal.ReportOutputFolder)1 HTMLGroupVisitor (org.jacoco.report.internal.html.HTMLGroupVisitor)1 ElementIndex (org.jacoco.report.internal.html.index.ElementIndex)1 BundlePage (org.jacoco.report.internal.html.page.BundlePage)1 ReportPage (org.jacoco.report.internal.html.page.ReportPage)1 SessionsPage (org.jacoco.report.internal.html.page.SessionsPage)1 Resources (org.jacoco.report.internal.html.resources.Resources)1