private void createExecFile(IProgressMonitor monitor) throws IOException, CoreException { monitor.beginTask(NLS.bind(CoreMessages.ExportingSession_task, session.getDescription()), 1); final OutputStream out = new BufferedOutputStream(new FileOutputStream(destination)); final ExecutionDataWriter writer = new ExecutionDataWriter(out); session.accept(writer, writer); out.close(); monitor.done(); }
private void createReport(IProgressMonitor monitor) throws CoreException, IOException { final int work = session.getScope().size(); monitor.beginTask( NLS.bind(CoreMessages.ExportingSession_task, session.getDescription()), work * 2); final SessionAnalyzer analyzer = new SessionAnalyzer(); final IJavaModelCoverage modelCoverage = analyzer.processSession(session, new SubProgressMonitor(monitor, work)); final IReportVisitor formatter = createFormatter(); formatter.visitInfo(analyzer.getSessionInfos(), analyzer.getExecutionData()); final IReportGroupVisitor modelgroup = formatter.visitGroup(session.getDescription()); for (IJavaProject project : modelCoverage.getProjects()) { final IReportGroupVisitor projectgroup = modelgroup.visitGroup(project.getElementName()); for (IPackageFragmentRoot root : project.getPackageFragmentRoots()) { final IBundleCoverage coverage = (IBundleCoverage) modelCoverage.getCoverageFor(root); if (coverage != null) { projectgroup.visitBundle(coverage, createSourceFileLocator(root)); monitor.worked(1); } } } formatter.visitEnd(); monitor.done(); }
private IReportVisitor createFormatter() throws IOException { final File file = new File(destination); if (HTML.equals(format)) { HTMLFormatter htmlFormatter = new HTMLFormatter(); htmlFormatter.setFooterText(session.getDescription()); return htmlFormatter.createVisitor(new FileMultiReportOutput(file)); } final OutputStream out = new BufferedOutputStream(new FileOutputStream(file)); switch (format) { case HTMLZIP: final HTMLFormatter htmlFormatter = new HTMLFormatter(); htmlFormatter.setFooterText(session.getDescription()); return htmlFormatter.createVisitor(new ZipMultiReportOutput(out)); case XML: final XMLFormatter xmlFormatter = new XMLFormatter(); return xmlFormatter.createVisitor(out); case CSV: final CSVFormatter csvFormatter = new CSVFormatter(); return csvFormatter.createVisitor(out); default: out.close(); throw new AssertionError("Unexpected format " + format); // $NON-NLS-1$ } }