diff --git a/pmd/src/net/sourceforge/pmd/PMD.java b/pmd/src/net/sourceforge/pmd/PMD.java index 008952926f..c6279280a1 100644 --- a/pmd/src/net/sourceforge/pmd/PMD.java +++ b/pmd/src/net/sourceforge/pmd/PMD.java @@ -15,6 +15,7 @@ import net.sourceforge.pmd.renderers.IDEAJRenderer; import net.sourceforge.pmd.renderers.Renderer; import net.sourceforge.pmd.renderers.TextRenderer; import net.sourceforge.pmd.renderers.XMLRenderer; +import net.sourceforge.pmd.renderers.EmacsRenderer; import net.sourceforge.pmd.swingui.PMDViewer; import net.sourceforge.pmd.symboltable.SymbolFacade; @@ -142,6 +143,9 @@ public class PMD { } else if (reportFormat.equals("text")) { Renderer rend = new TextRenderer(); System.out.println(rend.render(ctx.getReport())); + } else if (reportFormat.equals("emacs")) { + Renderer rend = new EmacsRenderer(); + System.out.println(rend.render(ctx.getReport())); } else { Renderer rend = new HTMLRenderer(); System.out.println(rend.render(ctx.getReport())); diff --git a/pmd/src/net/sourceforge/pmd/renderers/EmacsRenderer.java b/pmd/src/net/sourceforge/pmd/renderers/EmacsRenderer.java new file mode 100644 index 0000000000..6d8edb5084 --- /dev/null +++ b/pmd/src/net/sourceforge/pmd/renderers/EmacsRenderer.java @@ -0,0 +1,22 @@ +package net.sourceforge.pmd.renderers; + +import net.sourceforge.pmd.Report; +import net.sourceforge.pmd.RuleViolation; + +import java.util.Iterator; + +public class EmacsRenderer implements Renderer { + + protected String EOL = System.getProperty("line.separator", "\n"); + + public String render(Report report) { + StringBuffer buf = new StringBuffer(); + for (Iterator i = report.iterator(); i.hasNext();) { + RuleViolation rv = (RuleViolation) i.next(); + buf.append(EOL).append(rv.getFilename()); + buf.append(":").append(Integer.toString(rv.getLine())); + buf.append(": ").append(rv.getDescription()); + } + return buf.toString(); + } +}