diff options
Diffstat (limited to 'org.jacoco.report/src/org/jacoco/report/internal/html/page')
13 files changed, 83 insertions, 33 deletions
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/page/BundlePage.java b/org.jacoco.report/src/org/jacoco/report/internal/html/page/BundlePage.java index 3189faa1..4caeb67e 100644 --- a/org.jacoco.report/src/org/jacoco/report/internal/html/page/BundlePage.java +++ b/org.jacoco.report/src/org/jacoco/report/internal/html/page/BundlePage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -18,6 +18,7 @@ import org.jacoco.core.analysis.ICoverageNode; import org.jacoco.core.analysis.IPackageCoverage; import org.jacoco.report.ISourceFileLocator; import org.jacoco.report.internal.ReportOutputFolder; +import org.jacoco.report.internal.html.HTMLElement; import org.jacoco.report.internal.html.IHTMLReportContext; /** @@ -62,6 +63,9 @@ public class BundlePage extends TablePage<ICoverageNode> { private void renderPackages() throws IOException { for (final IPackageCoverage p : bundle.getPackages()) { + if (!p.containsCode()) { + continue; + } final String packagename = p.getName(); final String foldername = packagename.length() == 0 ? "default" : packagename.replace('/', '.'); @@ -82,4 +86,16 @@ public class BundlePage extends TablePage<ICoverageNode> { return "index.html"; } + @Override + protected void content(HTMLElement body) throws IOException { + if (bundle.getPackages().isEmpty()) { + body.p().text("No class files specified."); + } else if (!bundle.containsCode()) { + body.p().text( + "None of the analyzed classes contain code relevant for code coverage."); + } else { + super.content(body); + } + } + } diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/page/ClassPage.java b/org.jacoco.report/src/org/jacoco/report/internal/html/page/ClassPage.java index 2fab2c21..8a759a31 100644 --- a/org.jacoco.report/src/org/jacoco/report/internal/html/page/ClassPage.java +++ b/org.jacoco.report/src/org/jacoco/report/internal/html/page/ClassPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -16,6 +16,7 @@ import java.io.IOException; import org.jacoco.core.analysis.IClassCoverage; import org.jacoco.core.analysis.IMethodCoverage; import org.jacoco.report.internal.ReportOutputFolder; +import org.jacoco.report.internal.html.HTMLElement; import org.jacoco.report.internal.html.IHTMLReportContext; import org.jacoco.report.internal.html.ILinkable; @@ -80,4 +81,35 @@ public class ClassPage extends TablePage<IClassCoverage> { getNode().getInterfaceNames()); } + @Override + protected void content(HTMLElement body) throws IOException { + if (getNode().isNoMatch()) { + body.p().text( + "A different version of class was executed at runtime."); + } + + if (getNode().getLineCounter().getTotalCount() == 0) { + body.p().text( + "Class files must be compiled with debug information to show line coverage."); + } + + final String sourceFileName = getNode().getSourceFileName(); + if (sourceFileName == null) { + body.p().text( + "Class files must be compiled with debug information to link with source files."); + + } else if (sourcePage == null) { + final String sourcePath; + if (getNode().getPackageName().length() != 0) { + sourcePath = getNode().getPackageName() + "/" + sourceFileName; + } else { + sourcePath = sourceFileName; + } + body.p().text("Source file \"" + sourcePath + + "\" was not found during generation of report."); + } + + super.content(body); + } + } diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/page/GroupPage.java b/org.jacoco.report/src/org/jacoco/report/internal/html/page/GroupPage.java index 8ecb5de1..9e646058 100644 --- a/org.jacoco.report/src/org/jacoco/report/internal/html/page/GroupPage.java +++ b/org.jacoco.report/src/org/jacoco/report/internal/html/page/GroupPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/page/MethodItem.java b/org.jacoco.report/src/org/jacoco/report/internal/html/page/MethodItem.java index ecdf02ad..601c7112 100644 --- a/org.jacoco.report/src/org/jacoco/report/internal/html/page/MethodItem.java +++ b/org.jacoco.report/src/org/jacoco/report/internal/html/page/MethodItem.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/page/NodePage.java b/org.jacoco.report/src/org/jacoco/report/internal/html/page/NodePage.java index 8f1dbdda..6dbb37f4 100644 --- a/org.jacoco.report/src/org/jacoco/report/internal/html/page/NodePage.java +++ b/org.jacoco.report/src/org/jacoco/report/internal/html/page/NodePage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/page/PackagePage.java b/org.jacoco.report/src/org/jacoco/report/internal/html/page/PackagePage.java index f473850a..3d5e24dc 100644 --- a/org.jacoco.report/src/org/jacoco/report/internal/html/page/PackagePage.java +++ b/org.jacoco.report/src/org/jacoco/report/internal/html/page/PackagePage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -65,6 +65,9 @@ public class PackagePage extends TablePage<IPackageCoverage> { private void renderClasses() throws IOException { for (final IClassCoverage c : getNode().getClasses()) { + if (!c.containsCode()) { + continue; + } final ILinkable sourceFilePage = packageSourcePage .getSourceFilePage(c.getSourceFileName()); final ClassPage page = new ClassPage(c, this, sourceFilePage, diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/page/PackageSourcePage.java b/org.jacoco.report/src/org/jacoco/report/internal/html/page/PackageSourcePage.java index cfe7f792..988033d0 100644 --- a/org.jacoco.report/src/org/jacoco/report/internal/html/page/PackageSourcePage.java +++ b/org.jacoco.report/src/org/jacoco/report/internal/html/page/PackageSourcePage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -79,6 +79,9 @@ public class PackageSourcePage extends TablePage<IPackageCoverage> { private final void renderSourceFilePages() throws IOException { final String packagename = getNode().getName(); for (final ISourceFileCoverage s : getNode().getSourceFiles()) { + if (!s.containsCode()) { + continue; + } final String sourcename = s.getName(); final Reader reader = locator .getSourceFile(packagename, sourcename); diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/page/ReportPage.java b/org.jacoco.report/src/org/jacoco/report/internal/html/page/ReportPage.java index 7dfec534..9660bdf8 100644 --- a/org.jacoco.report/src/org/jacoco/report/internal/html/page/ReportPage.java +++ b/org.jacoco.report/src/org/jacoco/report/internal/html/page/ReportPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -15,7 +15,6 @@ import java.io.IOException; import org.jacoco.core.JaCoCo; import org.jacoco.report.internal.ReportOutputFolder; -import org.jacoco.report.internal.html.HTMLDocument; import org.jacoco.report.internal.html.HTMLElement; import org.jacoco.report.internal.html.IHTMLReportContext; import org.jacoco.report.internal.html.ILinkable; @@ -71,12 +70,12 @@ public abstract class ReportPage implements ILinkable { * if the page can't be written */ public void render() throws IOException { - final HTMLDocument doc = new HTMLDocument( + final HTMLElement html = new HTMLElement( folder.createFile(getFileName()), context.getOutputEncoding()); - doc.attr("lang", context.getLocale().getLanguage()); - head(doc.head()); - body(doc.body()); - doc.close(); + html.attr("lang", context.getLocale().getLanguage()); + head(html.head()); + body(html.body()); + html.close(); } /** @@ -130,8 +129,8 @@ public abstract class ReportPage implements ILinkable { span.a(context.getSessionsPage(), folder); } - private void breadcrumb(final HTMLElement div, final ReportOutputFolder base) - throws IOException { + private void breadcrumb(final HTMLElement div, + final ReportOutputFolder base) throws IOException { breadcrumbParent(parent, div, base); div.span(getLinkStyle()).text(getLinkLabel()); } @@ -151,7 +150,8 @@ public abstract class ReportPage implements ILinkable { final HTMLElement versioninfo = footer.span(Styles.RIGHT); versioninfo.text("Created with "); versioninfo.a(JaCoCo.HOMEURL).text("JaCoCo"); - versioninfo.text(" ").text(JaCoCo.VERSION); + versioninfo.text(" "); + versioninfo.text(JaCoCo.VERSION); footer.text(context.getFooterText()); } diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/page/SessionsPage.java b/org.jacoco.report/src/org/jacoco/report/internal/html/page/SessionsPage.java index d01d5895..67de4941 100644 --- a/org.jacoco.report/src/org/jacoco/report/internal/html/page/SessionsPage.java +++ b/org.jacoco.report/src/org/jacoco/report/internal/html/page/SessionsPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/page/SourceFileItem.java b/org.jacoco.report/src/org/jacoco/report/internal/html/page/SourceFileItem.java index 27df8bbc..70628ae2 100644 --- a/org.jacoco.report/src/org/jacoco/report/internal/html/page/SourceFileItem.java +++ b/org.jacoco.report/src/org/jacoco/report/internal/html/page/SourceFileItem.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/page/SourceFilePage.java b/org.jacoco.report/src/org/jacoco/report/internal/html/page/SourceFilePage.java index 8658d602..d4fe243c 100644 --- a/org.jacoco.report/src/org/jacoco/report/internal/html/page/SourceFilePage.java +++ b/org.jacoco.report/src/org/jacoco/report/internal/html/page/SourceFilePage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -67,14 +67,10 @@ public class SourceFilePage extends NodePage<ISourceNode> { @Override protected void head(final HTMLElement head) throws IOException { super.head(head); - head.link( - "stylesheet", - context.getResources().getLink(folder, - Resources.PRETTIFY_STYLESHEET), "text/css"); - head.script( - "text/javascript", - context.getResources().getLink(folder, - Resources.PRETTIFY_SCRIPT)); + head.link("stylesheet", context.getResources().getLink(folder, + Resources.PRETTIFY_STYLESHEET), "text/css"); + head.script(context.getResources().getLink(folder, + Resources.PRETTIFY_SCRIPT)); } @Override diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/page/SourceHighlighter.java b/org.jacoco.report/src/org/jacoco/report/internal/html/page/SourceHighlighter.java index fea5b611..5cb8eb04 100644 --- a/org.jacoco.report/src/org/jacoco/report/internal/html/page/SourceHighlighter.java +++ b/org.jacoco.report/src/org/jacoco/report/internal/html/page/SourceHighlighter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/page/TablePage.java b/org.jacoco.report/src/org/jacoco/report/internal/html/page/TablePage.java index 30c4cdcc..c8cd0c1d 100644 --- a/org.jacoco.report/src/org/jacoco/report/internal/html/page/TablePage.java +++ b/org.jacoco.report/src/org/jacoco/report/internal/html/page/TablePage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors + * Copyright (c) 2009, 2019 Mountainminds GmbH & Co. KG and Contributors * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -28,8 +28,8 @@ import org.jacoco.report.internal.html.table.ITableItem; * @param <NodeType> * type of the node represented by this page */ -public abstract class TablePage<NodeType extends ICoverageNode> extends - NodePage<NodeType> { +public abstract class TablePage<NodeType extends ICoverageNode> + extends NodePage<NodeType> { private final List<ITableItem> items = new ArrayList<ITableItem>(); @@ -64,7 +64,7 @@ public abstract class TablePage<NodeType extends ICoverageNode> extends @Override protected void head(final HTMLElement head) throws IOException { super.head(head); - head.script("text/javascript", + head.script( context.getResources().getLink(folder, Resources.SORT_SCRIPT)); } |