15 |
15 |
16 object VSCode_Rendering |
16 object VSCode_Rendering |
17 { |
17 { |
18 /* decorations */ |
18 /* decorations */ |
19 |
19 |
20 def color_decorations(prefix: String, types: Rendering.Color.ValueSet, |
20 private def color_decorations(prefix: String, types: Rendering.Color.ValueSet, |
21 colors: List[Text.Info[Rendering.Color.Value]]): List[Document_Model.Decoration] = |
21 colors: List[Text.Info[Rendering.Color.Value]]): List[Document_Model.Decoration] = |
22 { |
22 { |
23 val color_ranges = |
23 val color_ranges = |
24 (Map.empty[Rendering.Color.Value, List[Text.Range]] /: colors) { |
24 (Map.empty[Rendering.Color.Value, List[Text.Range]] /: colors) { |
25 case (m, Text.Info(range, c)) => m + (c -> (range :: m.getOrElse(c, Nil))) |
25 case (m, Text.Info(range, c)) => m + (c -> (range :: m.getOrElse(c, Nil))) |
26 } |
26 } |
27 for (c <- types.toList) |
27 types.toList.map(c => |
28 yield { |
28 Document_Model.Decoration(prefix + c.toString, |
29 val typ = prefix + c.toString |
29 color_ranges.getOrElse(c, Nil).reverse.map(r => Text.Info(r, Nil: List[XML.Body])))) |
30 val content = |
|
31 color_ranges.getOrElse(c, Nil).reverse.map(r => Text.Info(r, Nil: XML.Body)) |
|
32 Document_Model.Decoration(typ, content) |
|
33 } |
|
34 } |
30 } |
35 |
31 |
36 |
32 |
37 /* diagnostic messages */ |
33 /* diagnostic messages */ |
38 |
34 |
125 def decorations_bad: List[Document_Model.Decoration] = |
121 def decorations_bad: List[Document_Model.Decoration] = |
126 { |
122 { |
127 val content = |
123 val content = |
128 snapshot.select(model.content.text_range, VSCode_Rendering.bad_elements, _ => |
124 snapshot.select(model.content.text_range, VSCode_Rendering.bad_elements, _ => |
129 { |
125 { |
130 case Text.Info(_, XML.Elem(_, body)) => Some(body) |
126 case Text.Info(_, XML.Elem(_, body)) => Some(List(body)) |
131 }) |
127 }) |
132 List(Document_Model.Decoration(Protocol.Decorations.bad, content)) |
128 List(Document_Model.Decoration(Protocol.Decorations.bad, content)) |
133 } |
129 } |
134 |
130 |
135 def decoration_output(decoration: Document_Model.Decoration): Protocol.Decoration = |
131 def decoration_output(decoration: Document_Model.Decoration): Protocol.Decoration = |
136 { |
132 { |
137 val content = |
133 val content = |
138 for (Text.Info(text_range, body) <- decoration.content) |
134 for (Text.Info(text_range, msgs) <- decoration.content) |
139 yield { |
135 yield { |
140 val range = model.content.doc.range(text_range) |
136 val range = model.content.doc.range(text_range) |
141 val msg = resources.output_pretty(body, diagnostics_margin) |
137 Protocol.DecorationOptions(range, |
142 Protocol.DecorationOptions(range, if (msg == "") Nil else List(Protocol.MarkedString(msg))) |
138 msgs.map(msg => |
|
139 Protocol.MarkedString(resources.output_pretty(msg, diagnostics_margin)))) |
143 } |
140 } |
144 Protocol.Decoration(decoration.typ, content) |
141 Protocol.Decoration(decoration.typ, content) |
145 } |
142 } |
146 |
143 |
147 |
144 |