pep8analysis: short format of CFG contains code only
authorAlexis Laferrière <alexis.laf@xymus.net>
Thu, 26 Jun 2014 18:40:39 +0000 (14:40 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Fri, 27 Jun 2014 13:41:51 +0000 (09:41 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

contrib/pep8analysis/src/cfg/dot_printer.nit
contrib/pep8analysis/src/pep8analysis_web.nit

index 9c2fe38..8fec16b 100644 (file)
@@ -15,16 +15,11 @@ end
 redef class BasicBlock
        fun print_dot_nodes( f: OStream, long: Bool )
        do
-               var lbl
-               if long then
-                       lbl = "\"{name}:\\n{dot_node_text}\""
-               else
-                       lbl = name
-               end
+               var lbl = "\"{name}:\\n{dot_node_text(long)}\""
                f.write( "{name} [label={lbl}]\n" )
        end
 
-       fun dot_node_text : String
+       fun dot_node_text(long: Bool): String
        do
                var code_lines = new Array[String]
                for line in lines do code_lines.add(line.text)
@@ -32,7 +27,10 @@ redef class BasicBlock
 
                code = code.replace("\n","\\l").replace("\"","\\\"").replace("\\n","|n").replace("/","\\/").replace("\r","")
                # the last one is a hack
-               return "{dot_node_header}{code}{dot_node_footer}"
+
+               if long then
+                       return "{dot_node_header}{code}{dot_node_footer}"
+               else return code
        end
 
        fun dot_node_header: String do return ""
index 1227b99..7e72e89 100644 (file)
@@ -81,7 +81,7 @@ redef class AnalysisManager
                if notes.is_empty then print "Success: Nothing wrong detected"
 
                var of = new StringOStream
-               cfg.print_dot(of, true)
+               cfg.print_dot(of, false)
                of.close
                show_graph(of.to_s)