Added code to support new Emacs plugin; thanks to Nascif A. Abousalh-Neto for the contribution

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@1395 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Tom Copeland
2003-02-04 18:47:47 +00:00
parent e44b6b03f1
commit 7305851055
2 changed files with 26 additions and 0 deletions

View File

@ -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()));

View File

@ -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();
}
}