aboutsummaryrefslogtreecommitdiffstats
path: root/org.jacoco.report/src
diff options
context:
space:
mode:
authorMarc R. Hoffmann <hoffmann@mountainminds.com>2011-03-27 12:53:52 +0000
committerMarc R. Hoffmann <hoffmann@mountainminds.com>2011-03-27 12:53:52 +0000
commit5625ff67708fb53682d6574d4360ac2a9ca00b71 (patch)
tree213977626604d1f3816e9adede1f2ef975eb6133 /org.jacoco.report/src
parentf795a4454cae16494c3299b5a1c35b02d144f202 (diff)
downloadplatform_external_jacoco-5625ff67708fb53682d6574d4360ac2a9ca00b71.tar.gz
platform_external_jacoco-5625ff67708fb53682d6574d4360ac2a9ca00b71.tar.bz2
platform_external_jacoco-5625ff67708fb53682d6574d4360ac2a9ca00b71.zip
Trac #152: expose tab width of html report in ant task
Diffstat (limited to 'org.jacoco.report/src')
-rw-r--r--org.jacoco.report/src/org/jacoco/report/DirectorySourceFileLocator.java12
-rw-r--r--org.jacoco.report/src/org/jacoco/report/ISourceFileLocator.java7
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/html/IHTMLReportContext.java7
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/html/page/PackagePage.java2
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/html/page/SourceFilePage.java11
5 files changed, 27 insertions, 12 deletions
diff --git a/org.jacoco.report/src/org/jacoco/report/DirectorySourceFileLocator.java b/org.jacoco.report/src/org/jacoco/report/DirectorySourceFileLocator.java
index 04277598..b1b81179 100644
--- a/org.jacoco.report/src/org/jacoco/report/DirectorySourceFileLocator.java
+++ b/org.jacoco.report/src/org/jacoco/report/DirectorySourceFileLocator.java
@@ -27,6 +27,8 @@ public class DirectorySourceFileLocator implements ISourceFileLocator {
private final String encoding;
+ private final int tabWidth;
+
/**
* Creates a new locator that searches for source files in the given
* directory.
@@ -35,11 +37,15 @@ public class DirectorySourceFileLocator implements ISourceFileLocator {
* directory to search for source file
* @param encoding
* encoding of the source files
+ * @param tabWidth
+ * tab width in source files as number of blanks
+ *
*/
public DirectorySourceFileLocator(final File directory,
- final String encoding) {
+ final String encoding, final int tabWidth) {
this.directory = directory;
this.encoding = encoding;
+ this.tabWidth = tabWidth;
}
public Reader getSourceFile(final String packageName, final String fileName)
@@ -52,4 +58,8 @@ public class DirectorySourceFileLocator implements ISourceFileLocator {
return null;
}
+ public int getTabWidth() {
+ return tabWidth;
+ }
+
}
diff --git a/org.jacoco.report/src/org/jacoco/report/ISourceFileLocator.java b/org.jacoco.report/src/org/jacoco/report/ISourceFileLocator.java
index 7fb81e80..28d087bc 100644
--- a/org.jacoco.report/src/org/jacoco/report/ISourceFileLocator.java
+++ b/org.jacoco.report/src/org/jacoco/report/ISourceFileLocator.java
@@ -34,4 +34,11 @@ public interface ISourceFileLocator {
public Reader getSourceFile(String packageName, String fileName)
throws IOException;
+ /**
+ * Returns number of blank characters that represent a tab in source code.
+ *
+ * @return tab width as number of blanks
+ */
+ public int getTabWidth();
+
}
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/IHTMLReportContext.java b/org.jacoco.report/src/org/jacoco/report/internal/html/IHTMLReportContext.java
index a1a56912..44379970 100644
--- a/org.jacoco.report/src/org/jacoco/report/internal/html/IHTMLReportContext.java
+++ b/org.jacoco.report/src/org/jacoco/report/internal/html/IHTMLReportContext.java
@@ -79,11 +79,4 @@ public interface IHTMLReportContext {
*/
public Locale getLocale();
- /**
- * Returns number of blank characters that represent a tab in source code.
- *
- * @return tab width as number of blanks
- */
- public int getTabWidth();
-
} \ No newline at end of file
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 18e11cf4..15716d65 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
@@ -64,7 +64,7 @@ public class PackagePage extends TablePage<IPackageCoverage> {
.getSourceFile(packagename, sourcename);
if (reader != null) {
final SourceFilePage sourcePage = new SourceFilePage(s, reader,
- this, folder, context);
+ locator.getTabWidth(), this, folder, context);
sourcePage.render();
sourceFiles.put(sourcename, sourcePage);
}
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 d70fd912..5fd86da2 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
@@ -30,20 +30,25 @@ public class SourceFilePage extends NodePage<ISourceFileCoverage> {
private final Reader sourceReader;
+ private final int tabWidth;
+
/**
* Creates a new page with given information.
*
* @param sourceFileNode
* @param sourceReader
+ * @param tabWidth
* @param parent
* @param folder
* @param context
*/
public SourceFilePage(final ISourceFileCoverage sourceFileNode,
- final Reader sourceReader, final ReportPage parent,
- final ReportOutputFolder folder, final IHTMLReportContext context) {
+ final Reader sourceReader, final int tabWidth,
+ final ReportPage parent, final ReportOutputFolder folder,
+ final IHTMLReportContext context) {
super(sourceFileNode, parent, folder, context);
this.sourceReader = sourceReader;
+ this.tabWidth = tabWidth;
}
@Override
@@ -69,7 +74,7 @@ public class SourceFilePage extends NodePage<ISourceFileCoverage> {
@Override
protected String getOnload() {
return format("window['PR_TAB_WIDTH']=%d;prettyPrint()",
- Integer.valueOf(context.getTabWidth()));
+ Integer.valueOf(tabWidth));
}
@Override