92 tracing_pri -> Color.tracing_message, |
95 tracing_pri -> Color.tracing_message, |
93 warning_pri -> Color.warning_message, |
96 warning_pri -> Color.warning_message, |
94 legacy_pri -> Color.legacy_message, |
97 legacy_pri -> Color.legacy_message, |
95 error_pri -> Color.error_message) |
98 error_pri -> Color.error_message) |
96 |
99 |
97 def output_messages(results: Command.Results): List[XML.Tree] = |
100 def output_messages(results: Command.Results): List[XML.Elem] = |
98 { |
101 { |
99 val (states, other) = |
102 val (states, other) = |
100 results.iterator.map(_._2).filterNot(Protocol.is_result).toList |
103 results.iterator.map(_._2).filterNot(Protocol.is_result).toList |
101 .partition(Protocol.is_state) |
104 .partition(Protocol.is_state) |
102 states ::: other |
105 states ::: other |
535 Text.Info(r, pri) <- results |
538 Text.Info(r, pri) <- results |
536 color <- Rendering.message_underline_color.get(pri) |
539 color <- Rendering.message_underline_color.get(pri) |
537 } yield Text.Info(r, color) |
540 } yield Text.Info(r, color) |
538 } |
541 } |
539 |
542 |
540 def text_messages(range: Text.Range): List[Text.Info[XML.Tree]] = |
543 def text_messages(range: Text.Range): List[Text.Info[XML.Elem]] = |
541 { |
544 { |
542 val results = |
545 val results = |
543 snapshot.cumulate[Vector[XML.Tree]](range, Vector.empty, Rendering.message_elements, |
546 snapshot.cumulate[Vector[XML.Elem]](range, Vector.empty, Rendering.message_elements, |
544 states => |
547 states => |
545 { |
548 { |
546 case (res, Text.Info(_, elem)) => |
549 case (res, Text.Info(_, elem)) => |
547 elem.markup.properties match { |
550 elem.markup.properties match { |
548 case Markup.Serial(i) => |
551 case Markup.Serial(i) => |
555 } |
558 } |
556 case _ => None |
559 case _ => None |
557 }) |
560 }) |
558 |
561 |
559 var seen_serials = Set.empty[Long] |
562 var seen_serials = Set.empty[Long] |
560 val seen: XML.Tree => Boolean = |
563 def seen(elem: XML.Elem): Boolean = |
561 { |
564 elem.markup.properties match { |
562 case XML.Elem(Markup(_, Markup.Serial(i)), _) => |
565 case Markup.Serial(i) => val b = seen_serials(i); seen_serials += i; b |
563 val b = seen_serials(i); seen_serials += i; b |
566 case _ => false |
564 case _ => false |
567 } |
565 } |
|
566 for { |
568 for { |
567 Text.Info(range, trees) <- results |
569 Text.Info(range, elems) <- results |
568 tree <- trees |
570 elem <- elems |
569 if !seen(tree) |
571 if !seen(elem) |
570 } yield Text.Info(range, tree) |
572 } yield Text.Info(range, elem) |
571 } |
573 } |
572 |
574 |
573 |
575 |
574 /* tooltips */ |
576 /* tooltips */ |
575 |
577 |
576 def timing_threshold: Double = 0.0 |
578 def timing_threshold: Double = 0.0 |
577 |
579 |
578 private sealed case class Tooltip_Info( |
580 private sealed case class Tooltip_Info( |
579 range: Text.Range, |
581 range: Text.Range, |
580 timing: Timing = Timing.zero, |
582 timing: Timing = Timing.zero, |
581 messages: List[Command.Results.Entry] = Nil, |
583 messages: List[(Long, XML.Tree)] = Nil, |
582 rev_infos: List[(Boolean, XML.Tree)] = Nil) |
584 rev_infos: List[(Boolean, XML.Tree)] = Nil) |
583 { |
585 { |
584 def + (t: Timing): Tooltip_Info = copy(timing = timing + t) |
586 def + (t: Timing): Tooltip_Info = copy(timing = timing + t) |
585 def + (r0: Text.Range, serial: Long, tree: XML.Tree): Tooltip_Info = |
587 def + (r0: Text.Range, serial: Long, tree: XML.Tree): Tooltip_Info = |
586 { |
588 { |
686 |
688 |
687 if (results.isEmpty) None |
689 if (results.isEmpty) None |
688 else { |
690 else { |
689 val r = Text.Range(results.head.range.start, results.last.range.stop) |
691 val r = Text.Range(results.head.range.start, results.last.range.stop) |
690 val all_tips = |
692 val all_tips = |
691 Command.Results.make(results.flatMap(_.messages)).iterator.map(_._2).toList ::: |
693 (SortedMap.empty[Long, XML.Tree] /: results.flatMap(_.messages))(_ + _) |
|
694 .iterator.map(_._2).toList ::: |
692 results.flatMap(res => res.infos(true)) ::: |
695 results.flatMap(res => res.infos(true)) ::: |
693 results.flatMap(res => res.infos(false)).lastOption.toList |
696 results.flatMap(res => res.infos(false)).lastOption.toList |
694 if (all_tips.isEmpty) None else Some(Text.Info(r, all_tips)) |
697 if (all_tips.isEmpty) None else Some(Text.Info(r, all_tips)) |
695 } |
698 } |
696 } |
699 } |