Display LocalVariables along with Locations in the html report.
[cfb.git] / prod / net / jaekl / cfb / analyze / HtmlReport.java
index 166a140886ee824d3c429ac467077867c0f069c7..7ff69629e5d2994c45718378f1ea8ffee648cebf 100644 (file)
@@ -7,11 +7,15 @@ import java.io.PrintWriter;
 import net.jaekl.cfb.CfbBundle;
 import net.jaekl.cfb.store.Location;
 import net.jaekl.cfb.util.Command;
+import net.jaekl.cfb.util.XmlEscape;
 import net.jaekl.cfb.xml.BugInstance;
+import net.jaekl.cfb.xml.LocalVariable;
 import net.jaekl.cfb.xml.messages.BugPattern;
 import net.jaekl.cfb.xml.messages.MessageCollection;
 
 public class HtmlReport {
+       private static final String NBSP = " ";    // " " isn't valid XML, but " " is.
+       
        CfbBundle m_bundle;
        Delta m_delta;
        MessageCollection m_msgColl;
@@ -86,7 +90,9 @@ public class HtmlReport {
                                }
                        }
                        
-                       pw.println("        <TR><TD COLSPAN=\"2\" CLASS=\"Loc\">" + sb.toString() + "</TD></TR>");                                      
+                       String displayText = XmlEscape.toEscaped(sb.toString());
+                       
+                       pw.println("        <TR><TD COLSPAN=\"2\" CLASS=\"Loc\">" + displayText + "</TD></TR>");                                        
                }
        }
        
@@ -108,6 +114,7 @@ public class HtmlReport {
                        pw.println("          <TD>" + bug.getType() + "</TD>");
                        pw.println("        </TR>");
                        writeBugLocations(pw, bug);
+                       writeBugVariables(pw, bug);
                        pw.println("        <TR><TD COLSPAN=\"2\"><B>" + pattern.getShort() + "</B></TD></TR>");
                        pw.println("        <TR>");
                        pw.println("          <TD COLSPAN=\"2\">" + pattern.getDetails() + "</TD>");
@@ -118,6 +125,24 @@ public class HtmlReport {
                }
        }
        
+       void writeBugVariables(PrintWriter pw, BugInstance bug)
+       {
+               for (LocalVariable var : bug.getVariables()) {
+                       StringBuffer sb = new StringBuffer();
+                       
+                       if (null != var) {
+                               String name = var.getName();
+                               String role = var.getRole();
+                               sb.append(name);
+                               if (null != role) {
+                                       sb.append(" (").append(role).append(")");
+                               }
+                       }
+                       
+                       pw.println("        <TR><TD COLSPAN=\"2\" CLASS=\"Var\">" + sb.toString() + "</TD></TR>");                                      
+               }
+       }
+       
        void writeHeader(PrintWriter pw)
        {
                String title = trans(CfbBundle.CFB_REPORT);
@@ -139,7 +164,7 @@ public class HtmlReport {
        
        void writeSummary(PrintWriter pw)
        {
-               final String SEP = ":&nbsp;&nbsp;";
+               final String SEP = ":" + NBSP + NBSP;
                
                String earlierVersion = "";
                if (null != m_delta.getEarlier()) {
@@ -157,7 +182,7 @@ public class HtmlReport {
                pw.println("          <TD CLASS=\"CategoryName\">" + trans(CfbBundle.OLD_VERSION) + SEP + "</TD>");
                pw.println("          <TD CLASS=\"CategoryValue\">" + earlierVersion + "</TD>");
                pw.println("        </TR>");
-               pw.println("        <TR><TD>&nbsp;</TD></TR>");
+               pw.println("        <TR><TD>" + NBSP + "</TD></TR>");
                pw.println("        <TR>");
                pw.println("          <TD CLASS=\"CategoryName\">" + trans(CfbBundle.NEW_BUGS) + SEP + "</TD>");
                pw.println("          <TD CLASS=\"CategoryValue\">" + trans(CfbBundle.NUM_BUGS, m_delta.getNumNew()) + "</TD>");
@@ -182,6 +207,7 @@ public class HtmlReport {
            pw.println("    .CategoryValue { text-align: left; }");
                pw.println("    .Loc           { font-family: monospace; }");
            pw.println("    .SectionHead   td { background-color: #0000FF; color: #FFFFFF; font-size: 1.25em; font-weight: bold; }");
+               pw.println("    .Var           { font-family: monospace; }");
                pw.println("    </STYLE>");
        }
 }