184 { |
184 { |
185 val result = |
185 val result = |
186 session.use_theories(args.theories, qualifier = args.qualifier, |
186 session.use_theories(args.theories, qualifier = args.qualifier, |
187 master_dir = args.master_dir, id = id, progress = progress) |
187 master_dir = args.master_dir, id = id, progress = progress) |
188 |
188 |
189 def output_text(s: String): JSON.Object.Entry = |
189 def output_text(s: String): String = |
190 Server.Reply.message(if (args.unicode_symbols) Symbol.decode(s) else Symbol.encode(s)) |
190 if (args.unicode_symbols) Symbol.decode(s) else Symbol.encode(s) |
191 |
191 |
192 def output_message(tree: XML.Tree, pos: Position.T): JSON.Object.T = |
192 def output_message(tree: XML.Tree, pos: Position.T): JSON.Object.T = |
193 { |
193 { |
194 val position = "pos" -> Position.JSON(pos) |
194 val position = "pos" -> Position.JSON(pos) |
195 tree match { |
195 tree match { |
196 case XML.Text(msg) => JSON.Object(output_text(msg), position) |
196 case XML.Text(msg) => Server.Reply.message(output_text(msg)) + position |
197 case elem: XML.Elem => |
197 case elem: XML.Elem => |
198 val msg = XML.content(Pretty.formatted(List(elem), margin = args.pretty_margin)) |
198 val msg = XML.content(Pretty.formatted(List(elem), margin = args.pretty_margin)) |
199 Markup.messages.collectFirst({ case (a, b) if b == elem.name => a }) match { |
199 val kind = Markup.messages.collectFirst({ case (a, b) if b == elem.name => a }) |
200 case None => JSON.Object(output_text(msg), position) |
200 Server.Reply.message(output_text(msg), kind = kind getOrElse "") + position |
201 case Some(kind) => JSON.Object(Markup.KIND -> kind, output_text(msg), position) |
|
202 } |
|
203 } |
201 } |
204 } |
202 } |
205 |
203 |
206 val result_json = |
204 val result_json = |
207 JSON.Object( |
205 JSON.Object( |