clarified signature;
authorwenzelm
Wed, 01 Apr 2020 18:22:19 +0200
changeset 71647 7b0656fa783b
parent 71646 86f064893dac
child 71648 12c3fe42b2a8
clarified signature;
src/Pure/General/output.scala
src/Pure/PIDE/protocol.scala
--- a/src/Pure/General/output.scala	Wed Apr 01 18:19:46 2020 +0200
+++ b/src/Pure/General/output.scala	Wed Apr 01 18:22:19 2020 +0200
@@ -15,11 +15,11 @@
 
   def writeln_text(msg: String): String = clean_yxml(msg)
 
-  def warning_text(msg: String): String =
-    Library.prefix_lines("### ", clean_yxml(msg))
+  def warning_prefix(s: String): String = Library.prefix_lines("### ", s)
+  def warning_text(msg: String): String = warning_prefix(clean_yxml(msg))
 
-  def error_message_text(msg: String): String =
-    Library.prefix_lines("*** ", clean_yxml(msg))
+  def error_prefix(s: String): String = Library.prefix_lines("*** ", s)
+  def error_message_text(msg: String): String = error_prefix(clean_yxml(msg))
 
   def writeln(msg: String, stdout: Boolean = false, include_empty: Boolean = false)
   {
--- a/src/Pure/PIDE/protocol.scala	Wed Apr 01 18:19:46 2020 +0200
+++ b/src/Pure/PIDE/protocol.scala	Wed Apr 01 18:22:19 2020 +0200
@@ -102,6 +102,12 @@
 
   /* result messages */
 
+  def is_message(pred: XML.Elem => Boolean, body: XML.Body): Boolean =
+    body match {
+      case List(elem: XML.Elem) => pred(elem)
+      case _ => false
+    }
+
   def is_result(msg: XML.Tree): Boolean =
     msg match {
       case XML.Elem(Markup(Markup.RESULT, _), _) => true
@@ -163,11 +169,11 @@
   def is_exported(msg: XML.Tree): Boolean =
     is_writeln(msg) || is_warning(msg) || is_legacy(msg) || is_error(msg)
 
-  def message_text(msg: XML.Tree): String =
+  def message_text(body: XML.Body, margin: Double = Pretty.default_margin): String =
   {
-    val text = Pretty.string_of(List(msg))
-    if (is_warning(msg) || is_legacy(msg)) Library.prefix_lines("### ", text)
-    else if (is_error(msg)) Library.prefix_lines("*** ", text)
+    val text = Pretty.string_of(Protocol_Message.expose_no_reports(body), margin = margin)
+    if (is_message(is_warning, body) || is_message(is_legacy, body)) Output.warning_prefix(text)
+    else if (is_message(is_error, body)) Output.error_prefix(text)
     else text
   }