author | wenzelm |
Mon, 03 Mar 2014 12:54:12 +0100 | |
changeset 55884 | f2c0eaedd579 |
parent 55822 | ccf2d784be97 |
child 56295 | a40e67ce4f84 |
permissions | -rw-r--r-- |
45709
87017fcbad83
clarified modules (again) -- NB: both Document and Protocol are specific to this particular prover;
wenzelm
parents:
45672
diff
changeset
|
1 |
/* Title: Pure/PIDE/protocol.scala |
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
2 |
Author: Makarius |
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
3 |
|
45709
87017fcbad83
clarified modules (again) -- NB: both Document and Protocol are specific to this particular prover;
wenzelm
parents:
45672
diff
changeset
|
4 |
Protocol message formats for interactive proof documents. |
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
5 |
*/ |
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
6 |
|
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
7 |
package isabelle |
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
8 |
|
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
9 |
|
45709
87017fcbad83
clarified modules (again) -- NB: both Document and Protocol are specific to this particular prover;
wenzelm
parents:
45672
diff
changeset
|
10 |
object Protocol |
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
11 |
{ |
38567
b670faa807c9
concentrate protocol message formats in Isar_Document;
wenzelm
parents:
38483
diff
changeset
|
12 |
/* document editing */ |
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
13 |
|
52563 | 14 |
object Assign_Update |
44476
e8a87398f35d
propagate information about last command with exec state assignment through document model;
wenzelm
parents:
44474
diff
changeset
|
15 |
{ |
52563 | 16 |
def unapply(text: String): Option[(Document_ID.Version, Document.Assign_Update)] = |
44661
383c9d758a56
raw message function "assign_execs" avoids full overhead of decoding and caching message body;
wenzelm
parents:
44644
diff
changeset
|
17 |
try { |
383c9d758a56
raw message function "assign_execs" avoids full overhead of decoding and caching message body;
wenzelm
parents:
44644
diff
changeset
|
18 |
import XML.Decode._ |
383c9d758a56
raw message function "assign_execs" avoids full overhead of decoding and caching message body;
wenzelm
parents:
44644
diff
changeset
|
19 |
val body = YXML.parse_body(text) |
52527
dbac84eab3bc
separate exec_id assignment for Command.print states, without affecting result of eval;
wenzelm
parents:
52111
diff
changeset
|
20 |
Some(pair(long, list(pair(long, list(long))))(body)) |
44661
383c9d758a56
raw message function "assign_execs" avoids full overhead of decoding and caching message body;
wenzelm
parents:
44644
diff
changeset
|
21 |
} |
383c9d758a56
raw message function "assign_execs" avoids full overhead of decoding and caching message body;
wenzelm
parents:
44644
diff
changeset
|
22 |
catch { |
383c9d758a56
raw message function "assign_execs" avoids full overhead of decoding and caching message body;
wenzelm
parents:
44644
diff
changeset
|
23 |
case ERROR(_) => None |
51987 | 24 |
case _: XML.Error => None |
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
25 |
} |
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
26 |
} |
38567
b670faa807c9
concentrate protocol message formats in Isar_Document;
wenzelm
parents:
38483
diff
changeset
|
27 |
|
44676 | 28 |
object Removed |
29 |
{ |
|
52530
99dd8b4ef3fe
explicit module Document_ID as source of globally unique identifiers across ML/Scala;
wenzelm
parents:
52527
diff
changeset
|
30 |
def unapply(text: String): Option[List[Document_ID.Version]] = |
44676 | 31 |
try { |
32 |
import XML.Decode._ |
|
33 |
Some(list(long)(YXML.parse_body(text))) |
|
34 |
} |
|
35 |
catch { |
|
36 |
case ERROR(_) => None |
|
51987 | 37 |
case _: XML.Error => None |
44676 | 38 |
} |
39 |
} |
|
40 |
||
38567
b670faa807c9
concentrate protocol message formats in Isar_Document;
wenzelm
parents:
38483
diff
changeset
|
41 |
|
46209 | 42 |
/* command status */ |
38567
b670faa807c9
concentrate protocol message formats in Isar_Document;
wenzelm
parents:
38483
diff
changeset
|
43 |
|
46227
4aa84f84d5e8
more precise rendering of overview_color/gutter_message/squiggly_underline based on cumulation of command status and warning/error messages;
wenzelm
parents:
46209
diff
changeset
|
44 |
object Status |
4aa84f84d5e8
more precise rendering of overview_color/gutter_message/squiggly_underline based on cumulation of command status and warning/error messages;
wenzelm
parents:
46209
diff
changeset
|
45 |
{ |
4aa84f84d5e8
more precise rendering of overview_color/gutter_message/squiggly_underline based on cumulation of command status and warning/error messages;
wenzelm
parents:
46209
diff
changeset
|
46 |
val init = Status() |
4aa84f84d5e8
more precise rendering of overview_color/gutter_message/squiggly_underline based on cumulation of command status and warning/error messages;
wenzelm
parents:
46209
diff
changeset
|
47 |
} |
4aa84f84d5e8
more precise rendering of overview_color/gutter_message/squiggly_underline based on cumulation of command status and warning/error messages;
wenzelm
parents:
46209
diff
changeset
|
48 |
|
46166 | 49 |
sealed case class Status( |
49036
4680c4046814
further refinement of command status, to accomodate forked proofs;
wenzelm
parents:
49009
diff
changeset
|
50 |
private val touched: Boolean = false, |
47395
e6261a493f04
added static command status markup, to emphasize accepted but unassigned/unparsed commands (notably in overview panel);
wenzelm
parents:
47388
diff
changeset
|
51 |
private val accepted: Boolean = false, |
46166 | 52 |
private val failed: Boolean = false, |
49036
4680c4046814
further refinement of command status, to accomodate forked proofs;
wenzelm
parents:
49009
diff
changeset
|
53 |
forks: Int = 0, |
4680c4046814
further refinement of command status, to accomodate forked proofs;
wenzelm
parents:
49009
diff
changeset
|
54 |
runs: Int = 0) |
38567
b670faa807c9
concentrate protocol message formats in Isar_Document;
wenzelm
parents:
38483
diff
changeset
|
55 |
{ |
46227
4aa84f84d5e8
more precise rendering of overview_color/gutter_message/squiggly_underline based on cumulation of command status and warning/error messages;
wenzelm
parents:
46209
diff
changeset
|
56 |
def + (that: Status): Status = |
49036
4680c4046814
further refinement of command status, to accomodate forked proofs;
wenzelm
parents:
49009
diff
changeset
|
57 |
Status(touched || that.touched, accepted || that.accepted, failed || that.failed, |
4680c4046814
further refinement of command status, to accomodate forked proofs;
wenzelm
parents:
49009
diff
changeset
|
58 |
forks + that.forks, runs + that.runs) |
4680c4046814
further refinement of command status, to accomodate forked proofs;
wenzelm
parents:
49009
diff
changeset
|
59 |
|
4680c4046814
further refinement of command status, to accomodate forked proofs;
wenzelm
parents:
49009
diff
changeset
|
60 |
def is_unprocessed: Boolean = accepted && !failed && (!touched || (forks != 0 && runs == 0)) |
4680c4046814
further refinement of command status, to accomodate forked proofs;
wenzelm
parents:
49009
diff
changeset
|
61 |
def is_running: Boolean = runs != 0 |
49039 | 62 |
def is_finished: Boolean = !failed && touched && forks == 0 && runs == 0 |
49036
4680c4046814
further refinement of command status, to accomodate forked proofs;
wenzelm
parents:
49009
diff
changeset
|
63 |
def is_failed: Boolean = failed |
46166 | 64 |
} |
65 |
||
66 |
def command_status(status: Status, markup: Markup): Status = |
|
67 |
markup match { |
|
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50157
diff
changeset
|
68 |
case Markup(Markup.ACCEPTED, _) => status.copy(accepted = true) |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50157
diff
changeset
|
69 |
case Markup(Markup.FORKED, _) => status.copy(touched = true, forks = status.forks + 1) |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50157
diff
changeset
|
70 |
case Markup(Markup.JOINED, _) => status.copy(forks = status.forks - 1) |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50157
diff
changeset
|
71 |
case Markup(Markup.RUNNING, _) => status.copy(touched = true, runs = status.runs + 1) |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50157
diff
changeset
|
72 |
case Markup(Markup.FINISHED, _) => status.copy(runs = status.runs - 1) |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50157
diff
changeset
|
73 |
case Markup(Markup.FAILED, _) => status.copy(failed = true) |
46166 | 74 |
case _ => status |
38567
b670faa807c9
concentrate protocol message formats in Isar_Document;
wenzelm
parents:
38483
diff
changeset
|
75 |
} |
46166 | 76 |
|
77 |
def command_status(markups: List[Markup]): Status = |
|
46227
4aa84f84d5e8
more precise rendering of overview_color/gutter_message/squiggly_underline based on cumulation of command status and warning/error messages;
wenzelm
parents:
46209
diff
changeset
|
78 |
(Status.init /: markups)(command_status(_, _)) |
38887
1261481ef5e5
Command.State: add reported positions to markup tree, according main message position or Markup.binding/entity/report occurrences in body;
wenzelm
parents:
38581
diff
changeset
|
79 |
|
55820
61869776ce1f
tuned signature -- more explicit Document.Elements;
wenzelm
parents:
55783
diff
changeset
|
80 |
val command_status_elements = |
61869776ce1f
tuned signature -- more explicit Document.Elements;
wenzelm
parents:
55783
diff
changeset
|
81 |
Document.Elements(Markup.ACCEPTED, Markup.FORKED, Markup.JOINED, Markup.RUNNING, |
55646 | 82 |
Markup.FINISHED, Markup.FAILED) |
83 |
||
55820
61869776ce1f
tuned signature -- more explicit Document.Elements;
wenzelm
parents:
55783
diff
changeset
|
84 |
val status_elements = |
55646 | 85 |
command_status_elements + Markup.WARNING + Markup.ERROR |
86 |
||
46209 | 87 |
|
51818
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
88 |
/* command timing */ |
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
89 |
|
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
90 |
object Command_Timing |
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
91 |
{ |
52531 | 92 |
def unapply(props: Properties.T): Option[(Document_ID.Generic, isabelle.Timing)] = |
51818
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
93 |
props match { |
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
94 |
case (Markup.FUNCTION, Markup.COMMAND_TIMING) :: args => |
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
95 |
(args, args) match { |
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
96 |
case (Position.Id(id), Markup.Timing_Properties(timing)) => Some((id, timing)) |
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
97 |
case _ => None |
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
98 |
} |
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
99 |
case _ => None |
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
100 |
} |
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
101 |
} |
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
102 |
|
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
103 |
|
46209 | 104 |
/* node status */ |
105 |
||
46688 | 106 |
sealed case class Node_Status( |
107 |
unprocessed: Int, running: Int, finished: Int, warned: Int, failed: Int) |
|
44866 | 108 |
{ |
46688 | 109 |
def total: Int = unprocessed + running + finished + warned + failed |
44866 | 110 |
} |
44613 | 111 |
|
112 |
def node_status( |
|
113 |
state: Document.State, version: Document.Version, node: Document.Node): Node_Status = |
|
114 |
{ |
|
115 |
var unprocessed = 0 |
|
116 |
var running = 0 |
|
117 |
var finished = 0 |
|
46688 | 118 |
var warned = 0 |
44613 | 119 |
var failed = 0 |
120 |
node.commands.foreach(command => |
|
46166 | 121 |
{ |
46688 | 122 |
val st = state.command_state(version, command) |
123 |
val status = command_status(st.status) |
|
46166 | 124 |
if (status.is_running) running += 1 |
46688 | 125 |
else if (status.is_finished) { |
50507 | 126 |
if (st.results.entries.exists(p => is_warning(p._2))) warned += 1 |
46688 | 127 |
else finished += 1 |
128 |
} |
|
46166 | 129 |
else if (status.is_failed) failed += 1 |
130 |
else unprocessed += 1 |
|
44613 | 131 |
}) |
46688 | 132 |
Node_Status(unprocessed, running, finished, warned, failed) |
44613 | 133 |
} |
134 |
||
38887
1261481ef5e5
Command.State: add reported positions to markup tree, according main message position or Markup.binding/entity/report occurrences in body;
wenzelm
parents:
38581
diff
changeset
|
135 |
|
51533 | 136 |
/* node timing */ |
137 |
||
138 |
sealed case class Node_Timing(total: Double, commands: Map[Command, Double]) |
|
139 |
||
140 |
val empty_node_timing = Node_Timing(0.0, Map.empty) |
|
141 |
||
142 |
def node_timing( |
|
143 |
state: Document.State, |
|
144 |
version: Document.Version, |
|
145 |
node: Document.Node, |
|
146 |
threshold: Double): Node_Timing = |
|
147 |
{ |
|
148 |
var total = 0.0 |
|
149 |
var commands = Map.empty[Command, Double] |
|
150 |
for { |
|
151 |
command <- node.commands.iterator |
|
152 |
st = state.command_state(version, command) |
|
153 |
command_timing = |
|
154 |
(0.0 /: st.status)({ |
|
155 |
case (timing, Markup.Timing(t)) => timing + t.elapsed.seconds |
|
156 |
case (timing, _) => timing |
|
157 |
}) |
|
158 |
} { |
|
159 |
total += command_timing |
|
160 |
if (command_timing >= threshold) commands += (command -> command_timing) |
|
161 |
} |
|
162 |
Node_Timing(total, commands) |
|
163 |
} |
|
164 |
||
165 |
||
39441
4110cc1b8f9f
allow embedded reports in regular prover messages, to avoid side-effects for errors for example;
wenzelm
parents:
39439
diff
changeset
|
166 |
/* result messages */ |
39439
1c294d150ded
eliminated markup "location" in favour of more explicit "no_report", which is actually deleted from messages;
wenzelm
parents:
39181
diff
changeset
|
167 |
|
55820
61869776ce1f
tuned signature -- more explicit Document.Elements;
wenzelm
parents:
55783
diff
changeset
|
168 |
private val clean_elements = |
61869776ce1f
tuned signature -- more explicit Document.Elements;
wenzelm
parents:
55783
diff
changeset
|
169 |
Document.Elements(Markup.REPORT, Markup.NO_REPORT) |
50450
358b6020f8b6
generalized notion of active area, where sendback is just one application;
wenzelm
parents:
50201
diff
changeset
|
170 |
|
39439
1c294d150ded
eliminated markup "location" in favour of more explicit "no_report", which is actually deleted from messages;
wenzelm
parents:
39181
diff
changeset
|
171 |
def clean_message(body: XML.Body): XML.Body = |
49445
638cefe3ee99
earlier treatment of embedded report/no_report messages (see also 4110cc1b8f9f);
wenzelm
parents:
49418
diff
changeset
|
172 |
body filter { |
55646 | 173 |
case XML.Wrapped_Elem(Markup(name, _), _, _) => !clean_elements(name) |
174 |
case XML.Elem(Markup(name, _), _) => !clean_elements(name) |
|
49445
638cefe3ee99
earlier treatment of embedded report/no_report messages (see also 4110cc1b8f9f);
wenzelm
parents:
49418
diff
changeset
|
175 |
case _ => true |
49650
9fad6480300d
support for wrapped XML elements, which allows to preserve full markup tree information in to_XML/from_XML conversion;
wenzelm
parents:
49648
diff
changeset
|
176 |
} map { |
9fad6480300d
support for wrapped XML elements, which allows to preserve full markup tree information in to_XML/from_XML conversion;
wenzelm
parents:
49648
diff
changeset
|
177 |
case XML.Wrapped_Elem(markup, body, ts) => XML.Wrapped_Elem(markup, body, clean_message(ts)) |
9fad6480300d
support for wrapped XML elements, which allows to preserve full markup tree information in to_XML/from_XML conversion;
wenzelm
parents:
49648
diff
changeset
|
178 |
case XML.Elem(markup, ts) => XML.Elem(markup, clean_message(ts)) |
9fad6480300d
support for wrapped XML elements, which allows to preserve full markup tree information in to_XML/from_XML conversion;
wenzelm
parents:
49648
diff
changeset
|
179 |
case t => t |
9fad6480300d
support for wrapped XML elements, which allows to preserve full markup tree information in to_XML/from_XML conversion;
wenzelm
parents:
49648
diff
changeset
|
180 |
} |
39439
1c294d150ded
eliminated markup "location" in favour of more explicit "no_report", which is actually deleted from messages;
wenzelm
parents:
39181
diff
changeset
|
181 |
|
49445
638cefe3ee99
earlier treatment of embedded report/no_report messages (see also 4110cc1b8f9f);
wenzelm
parents:
49418
diff
changeset
|
182 |
def message_reports(props: Properties.T, body: XML.Body): List[XML.Elem] = |
638cefe3ee99
earlier treatment of embedded report/no_report messages (see also 4110cc1b8f9f);
wenzelm
parents:
49418
diff
changeset
|
183 |
body flatMap { |
50450
358b6020f8b6
generalized notion of active area, where sendback is just one application;
wenzelm
parents:
50201
diff
changeset
|
184 |
case XML.Wrapped_Elem(Markup(Markup.REPORT, ps), body, ts) => |
358b6020f8b6
generalized notion of active area, where sendback is just one application;
wenzelm
parents:
50201
diff
changeset
|
185 |
List(XML.Wrapped_Elem(Markup(Markup.REPORT, props ::: ps), body, ts)) |
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50157
diff
changeset
|
186 |
case XML.Elem(Markup(Markup.REPORT, ps), ts) => |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50157
diff
changeset
|
187 |
List(XML.Elem(Markup(Markup.REPORT, props ::: ps), ts)) |
49650
9fad6480300d
support for wrapped XML elements, which allows to preserve full markup tree information in to_XML/from_XML conversion;
wenzelm
parents:
49648
diff
changeset
|
188 |
case XML.Wrapped_Elem(_, _, ts) => message_reports(props, ts) |
49445
638cefe3ee99
earlier treatment of embedded report/no_report messages (see also 4110cc1b8f9f);
wenzelm
parents:
49418
diff
changeset
|
189 |
case XML.Elem(_, ts) => message_reports(props, ts) |
39441
4110cc1b8f9f
allow embedded reports in regular prover messages, to avoid side-effects for errors for example;
wenzelm
parents:
39439
diff
changeset
|
190 |
case XML.Text(_) => Nil |
4110cc1b8f9f
allow embedded reports in regular prover messages, to avoid side-effects for errors for example;
wenzelm
parents:
39439
diff
changeset
|
191 |
} |
4110cc1b8f9f
allow embedded reports in regular prover messages, to avoid side-effects for errors for example;
wenzelm
parents:
39439
diff
changeset
|
192 |
|
39439
1c294d150ded
eliminated markup "location" in favour of more explicit "no_report", which is actually deleted from messages;
wenzelm
parents:
39181
diff
changeset
|
193 |
|
39511 | 194 |
/* specific messages */ |
195 |
||
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
196 |
def is_inlined(msg: XML.Tree): Boolean = |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
197 |
!(is_result(msg) || is_tracing(msg) || is_state(msg)) |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
198 |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
199 |
def is_result(msg: XML.Tree): Boolean = |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
200 |
msg match { |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
201 |
case XML.Elem(Markup(Markup.RESULT, _), _) => true |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
202 |
case _ => false |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
203 |
} |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
204 |
|
50157 | 205 |
def is_tracing(msg: XML.Tree): Boolean = |
39622
53365ba766ac
Command.accumulate: refrain from adding tracing messages to markup tree -- potential scalability problem;
wenzelm
parents:
39511
diff
changeset
|
206 |
msg match { |
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50157
diff
changeset
|
207 |
case XML.Elem(Markup(Markup.TRACING, _), _) => true |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50157
diff
changeset
|
208 |
case XML.Elem(Markup(Markup.TRACING_MESSAGE, _), _) => true |
39622
53365ba766ac
Command.accumulate: refrain from adding tracing messages to markup tree -- potential scalability problem;
wenzelm
parents:
39511
diff
changeset
|
209 |
case _ => false |
53365ba766ac
Command.accumulate: refrain from adding tracing messages to markup tree -- potential scalability problem;
wenzelm
parents:
39511
diff
changeset
|
210 |
} |
53365ba766ac
Command.accumulate: refrain from adding tracing messages to markup tree -- potential scalability problem;
wenzelm
parents:
39511
diff
changeset
|
211 |
|
52650 | 212 |
def is_writeln_markup(msg: XML.Tree, name: String): Boolean = |
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
213 |
msg match { |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
214 |
case XML.Elem(Markup(Markup.WRITELN, _), |
52650 | 215 |
List(XML.Elem(markup, _))) => markup.name == name |
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
216 |
case XML.Elem(Markup(Markup.WRITELN_MESSAGE, _), |
52650 | 217 |
List(XML.Elem(markup, _))) => markup.name == name |
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
218 |
case _ => false |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
219 |
} |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
220 |
|
52650 | 221 |
def is_state(msg: XML.Tree): Boolean = is_writeln_markup(msg, Markup.STATE) |
222 |
def is_information(msg: XML.Tree): Boolean = is_writeln_markup(msg, Markup.INFORMATION) |
|
223 |
||
39511 | 224 |
def is_warning(msg: XML.Tree): Boolean = |
225 |
msg match { |
|
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50157
diff
changeset
|
226 |
case XML.Elem(Markup(Markup.WARNING, _), _) => true |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50157
diff
changeset
|
227 |
case XML.Elem(Markup(Markup.WARNING_MESSAGE, _), _) => true |
39511 | 228 |
case _ => false |
229 |
} |
|
230 |
||
231 |
def is_error(msg: XML.Tree): Boolean = |
|
232 |
msg match { |
|
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50157
diff
changeset
|
233 |
case XML.Elem(Markup(Markup.ERROR, _), _) => true |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50157
diff
changeset
|
234 |
case XML.Elem(Markup(Markup.ERROR_MESSAGE, _), _) => true |
39511 | 235 |
case _ => false |
236 |
} |
|
38887
1261481ef5e5
Command.State: add reported positions to markup tree, according main message position or Markup.binding/entity/report occurrences in body;
wenzelm
parents:
38581
diff
changeset
|
237 |
|
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
238 |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
239 |
/* dialogs */ |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
240 |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
241 |
object Dialog_Args |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
242 |
{ |
52531 | 243 |
def unapply(props: Properties.T): Option[(Document_ID.Generic, Long, String)] = |
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
244 |
(props, props, props) match { |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
245 |
case (Position.Id(id), Markup.Serial(serial), Markup.Result(result)) => |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
246 |
Some((id, serial, result)) |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
247 |
case _ => None |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
248 |
} |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
249 |
} |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
250 |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
251 |
object Dialog |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
252 |
{ |
52531 | 253 |
def unapply(tree: XML.Tree): Option[(Document_ID.Generic, Long, String)] = |
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
254 |
tree match { |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
255 |
case XML.Elem(Markup(Markup.DIALOG, Dialog_Args(id, serial, result)), _) => |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
256 |
Some((id, serial, result)) |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
257 |
case _ => None |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
258 |
} |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
259 |
} |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
260 |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
261 |
object Dialog_Result |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
262 |
{ |
52531 | 263 |
def apply(id: Document_ID.Generic, serial: Long, result: String): XML.Elem = |
50501
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50500
diff
changeset
|
264 |
{ |
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50500
diff
changeset
|
265 |
val props = Position.Id(id) ::: Markup.Serial(serial) |
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50500
diff
changeset
|
266 |
XML.Elem(Markup(Markup.RESULT, props), List(XML.Text(result))) |
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50500
diff
changeset
|
267 |
} |
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
268 |
|
50501
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50500
diff
changeset
|
269 |
def unapply(tree: XML.Tree): Option[String] = |
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
270 |
tree match { |
50501
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50500
diff
changeset
|
271 |
case XML.Elem(Markup(Markup.RESULT, _), List(XML.Text(result))) => Some(result) |
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
272 |
case _ => None |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
273 |
} |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
274 |
} |
39170
04ad0fed81f5
Isar_Document.reported_positions: exclude proof state output;
wenzelm
parents:
39042
diff
changeset
|
275 |
|
39511 | 276 |
|
277 |
/* reported positions */ |
|
278 |
||
55646 | 279 |
private val position_elements = |
55820
61869776ce1f
tuned signature -- more explicit Document.Elements;
wenzelm
parents:
55783
diff
changeset
|
280 |
Document.Elements(Markup.BINDING, Markup.ENTITY, Markup.REPORT, Markup.POSITION) |
39441
4110cc1b8f9f
allow embedded reports in regular prover messages, to avoid side-effects for errors for example;
wenzelm
parents:
39439
diff
changeset
|
281 |
|
55433
d2960d67f163
clarified message_positions: cover alt_id as well;
wenzelm
parents:
55432
diff
changeset
|
282 |
def message_positions( |
d2960d67f163
clarified message_positions: cover alt_id as well;
wenzelm
parents:
55432
diff
changeset
|
283 |
command_id: Document_ID.Command, |
d2960d67f163
clarified message_positions: cover alt_id as well;
wenzelm
parents:
55432
diff
changeset
|
284 |
alt_id: Document_ID.Generic, |
d2960d67f163
clarified message_positions: cover alt_id as well;
wenzelm
parents:
55432
diff
changeset
|
285 |
chunk: Command.Chunk, |
d2960d67f163
clarified message_positions: cover alt_id as well;
wenzelm
parents:
55432
diff
changeset
|
286 |
message: XML.Elem): Set[Text.Range] = |
38887
1261481ef5e5
Command.State: add reported positions to markup tree, according main message position or Markup.binding/entity/report occurrences in body;
wenzelm
parents:
38581
diff
changeset
|
287 |
{ |
55433
d2960d67f163
clarified message_positions: cover alt_id as well;
wenzelm
parents:
55432
diff
changeset
|
288 |
def elem_positions(props: Properties.T, set: Set[Text.Range]): Set[Text.Range] = |
d2960d67f163
clarified message_positions: cover alt_id as well;
wenzelm
parents:
55432
diff
changeset
|
289 |
props match { |
55884
f2c0eaedd579
tuned signature -- emphasize symbol positions (prover) vs. decoded text offsets (editor);
wenzelm
parents:
55822
diff
changeset
|
290 |
case Position.Reported(id, file_name, symbol_range) |
55433
d2960d67f163
clarified message_positions: cover alt_id as well;
wenzelm
parents:
55432
diff
changeset
|
291 |
if (id == command_id || id == alt_id) && file_name == chunk.file_name => |
55884
f2c0eaedd579
tuned signature -- emphasize symbol positions (prover) vs. decoded text offsets (editor);
wenzelm
parents:
55822
diff
changeset
|
292 |
chunk.incorporate(symbol_range) match { |
55822
ccf2d784be97
incorporate chunk range that is 1 off end-of-input, for improved error positions (NB: command spans are tight, without trailing whitespace);
wenzelm
parents:
55820
diff
changeset
|
293 |
case Some(range) => set + range |
55548
a645277885cf
more uniform/robust restriction of reported positions, e.g. relevant for "bad" markup due to unclosed comment in ML file;
wenzelm
parents:
55433
diff
changeset
|
294 |
case _ => set |
a645277885cf
more uniform/robust restriction of reported positions, e.g. relevant for "bad" markup due to unclosed comment in ML file;
wenzelm
parents:
55433
diff
changeset
|
295 |
} |
55433
d2960d67f163
clarified message_positions: cover alt_id as well;
wenzelm
parents:
55432
diff
changeset
|
296 |
case _ => set |
d2960d67f163
clarified message_positions: cover alt_id as well;
wenzelm
parents:
55432
diff
changeset
|
297 |
} |
50157 | 298 |
|
39441
4110cc1b8f9f
allow embedded reports in regular prover messages, to avoid side-effects for errors for example;
wenzelm
parents:
39439
diff
changeset
|
299 |
def positions(set: Set[Text.Range], tree: XML.Tree): Set[Text.Range] = |
38887
1261481ef5e5
Command.State: add reported positions to markup tree, according main message position or Markup.binding/entity/report occurrences in body;
wenzelm
parents:
38581
diff
changeset
|
300 |
tree match { |
55433
d2960d67f163
clarified message_positions: cover alt_id as well;
wenzelm
parents:
55432
diff
changeset
|
301 |
case XML.Wrapped_Elem(Markup(name, props), _, body) => |
55646 | 302 |
body.foldLeft(if (position_elements(name)) elem_positions(props, set) else set)(positions) |
55433
d2960d67f163
clarified message_positions: cover alt_id as well;
wenzelm
parents:
55432
diff
changeset
|
303 |
case XML.Elem(Markup(name, props), body) => |
55646 | 304 |
body.foldLeft(if (position_elements(name)) elem_positions(props, set) else set)(positions) |
55433
d2960d67f163
clarified message_positions: cover alt_id as well;
wenzelm
parents:
55432
diff
changeset
|
305 |
case XML.Text(_) => set |
38887
1261481ef5e5
Command.State: add reported positions to markup tree, according main message position or Markup.binding/entity/report occurrences in body;
wenzelm
parents:
38581
diff
changeset
|
306 |
} |
50157 | 307 |
|
39441
4110cc1b8f9f
allow embedded reports in regular prover messages, to avoid side-effects for errors for example;
wenzelm
parents:
39439
diff
changeset
|
308 |
val set = positions(Set.empty, message) |
55433
d2960d67f163
clarified message_positions: cover alt_id as well;
wenzelm
parents:
55432
diff
changeset
|
309 |
if (set.isEmpty) elem_positions(message.markup.properties, set) |
39042
470fd769ae53
Isar_Document.reported_positions: more precise include/exclude, include root as last resort only;
wenzelm
parents:
38887
diff
changeset
|
310 |
else set |
38887
1261481ef5e5
Command.State: add reported positions to markup tree, according main message position or Markup.binding/entity/report occurrences in body;
wenzelm
parents:
38581
diff
changeset
|
311 |
} |
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
312 |
} |
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
313 |
|
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
314 |
|
45709
87017fcbad83
clarified modules (again) -- NB: both Document and Protocol are specific to this particular prover;
wenzelm
parents:
45672
diff
changeset
|
315 |
trait Protocol extends Isabelle_Process |
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
316 |
{ |
54519
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
317 |
/* inlined files */ |
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
318 |
|
55783 | 319 |
def define_blob(blob: Document.Blob): Unit = |
320 |
protocol_command_raw( |
|
321 |
"Document.define_blob", Bytes(blob.bytes.sha1_digest.toString), blob.bytes) |
|
54519
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
322 |
|
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
323 |
|
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
324 |
/* commands */ |
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
325 |
|
44644
317e4962dd0f
clarified define_command: store name as structural information;
wenzelm
parents:
44615
diff
changeset
|
326 |
def define_command(command: Command): Unit = |
54519
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
327 |
{ |
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
328 |
val blobs_yxml = |
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
329 |
{ import XML.Encode._ |
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
330 |
val encode_blob: T[Command.Blob] = |
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
331 |
variant(List( |
54526 | 332 |
{ case Exn.Res((a, b)) => |
55431
e0f20a44ff9d
common Command.Chunk for command source and auxiliary files (static Symbol.Index without actual String content);
wenzelm
parents:
55429
diff
changeset
|
333 |
(Nil, pair(string, option(string))((a.node, b.map(p => p._1.toString)))) }, |
54526 | 334 |
{ case Exn.Exn(e) => (Nil, string(Exn.message(e))) })) |
54519
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
335 |
YXML.string_of_body(list(encode_blob)(command.blobs)) |
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
336 |
} |
52582 | 337 |
protocol_command("Document.define_command", |
54519
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
338 |
Document_ID(command.id), encode(command.name), blobs_yxml, encode(command.source)) |
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
339 |
} |
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
340 |
|
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
341 |
|
52931
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
342 |
/* execution */ |
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
343 |
|
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
344 |
def discontinue_execution(): Unit = |
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
345 |
protocol_command("Document.discontinue_execution") |
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
346 |
|
52931
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
347 |
def cancel_exec(id: Document_ID.Exec): Unit = |
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
348 |
protocol_command("Document.cancel_exec", Document_ID(id)) |
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
349 |
|
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
350 |
|
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
351 |
/* document versions */ |
47343
b8aeab386414
less aggressive discontinue_execution before document update, to avoid unstable execs that need to be re-assigned;
wenzelm
parents:
46938
diff
changeset
|
352 |
|
52530
99dd8b4ef3fe
explicit module Document_ID as source of globally unique identifiers across ML/Scala;
wenzelm
parents:
52527
diff
changeset
|
353 |
def update(old_id: Document_ID.Version, new_id: Document_ID.Version, |
44383 | 354 |
edits: List[Document.Edit_Command]) |
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
355 |
{ |
44157
a21d3e1e64fd
uniform treatment of header edits as document edits;
wenzelm
parents:
44156
diff
changeset
|
356 |
val edits_yxml = |
43767 | 357 |
{ import XML.Encode._ |
44383 | 358 |
def id: T[Command] = (cmd => long(cmd.id)) |
46737 | 359 |
def encode_edit(name: Document.Node.Name) |
52849 | 360 |
: T[Document.Node.Edit[Command.Edit, Command.Perspective]] = |
44979
68b990e950b1
explicit master_dir as part of header -- still required (for Cygwin) since Scala layer does not pass file content yet;
wenzelm
parents:
44866
diff
changeset
|
361 |
variant(List( |
68b990e950b1
explicit master_dir as part of header -- still required (for Cygwin) since Scala layer does not pass file content yet;
wenzelm
parents:
44866
diff
changeset
|
362 |
{ case Document.Node.Edits(a) => (Nil, list(pair(option(id), option(id)))(a)) }, |
48707
ba531af91148
simplified Document.Node.Header -- internalized errors;
wenzelm
parents:
48705
diff
changeset
|
363 |
{ case Document.Node.Deps(header) => |
54515 | 364 |
val master_dir = Isabelle_System.posix_path(name.master_dir) |
48707
ba531af91148
simplified Document.Node.Header -- internalized errors;
wenzelm
parents:
48705
diff
changeset
|
365 |
val imports = header.imports.map(_.node) |
50128
599c935aac82
alternative completion for outer syntax keywords;
wenzelm
parents:
49650
diff
changeset
|
366 |
val keywords = header.keywords.map({ case (a, b, _) => (a, b) }) |
44979
68b990e950b1
explicit master_dir as part of header -- still required (for Cygwin) since Scala layer does not pass file content yet;
wenzelm
parents:
44866
diff
changeset
|
367 |
(Nil, |
48707
ba531af91148
simplified Document.Node.Header -- internalized errors;
wenzelm
parents:
48705
diff
changeset
|
368 |
pair(Encode.string, pair(Encode.string, pair(list(Encode.string), |
48864
3ee314ae1e0a
added keyword kind "thy_load" (with optional list of file extensions);
wenzelm
parents:
48755
diff
changeset
|
369 |
pair(list(pair(Encode.string, |
3ee314ae1e0a
added keyword kind "thy_load" (with optional list of file extensions);
wenzelm
parents:
48755
diff
changeset
|
370 |
option(pair(pair(Encode.string, list(Encode.string)), list(Encode.string))))), |
51294
0850d43cb355
discontinued obsolete header "files" -- these are loaded explicitly after exploring dependencies;
wenzelm
parents:
51293
diff
changeset
|
371 |
list(Encode.string)))))( |
54515 | 372 |
(master_dir, (name.theory, (imports, (keywords, header.errors)))))) }, |
52849 | 373 |
{ case Document.Node.Perspective(a, b, c) => |
374 |
(bool_atom(a) :: b.commands.map(cmd => long_atom(cmd.id)), |
|
52862
930ce8eacb87
tuned signature -- more uniform treatment of overlays as command mapping;
wenzelm
parents:
52849
diff
changeset
|
375 |
list(pair(id, pair(Encode.string, list(Encode.string))))(c.dest)) })) |
48705
dd32321d6eef
tuned signature -- slightly more abstract text representation of prover process;
wenzelm
parents:
47542
diff
changeset
|
376 |
def encode_edits: T[List[Document.Edit_Command]] = list((node_edit: Document.Edit_Command) => |
44979
68b990e950b1
explicit master_dir as part of header -- still required (for Cygwin) since Scala layer does not pass file content yet;
wenzelm
parents:
44866
diff
changeset
|
377 |
{ |
68b990e950b1
explicit master_dir as part of header -- still required (for Cygwin) since Scala layer does not pass file content yet;
wenzelm
parents:
44866
diff
changeset
|
378 |
val (name, edit) = node_edit |
46737 | 379 |
pair(string, encode_edit(name))(name.node, edit) |
44979
68b990e950b1
explicit master_dir as part of header -- still required (for Cygwin) since Scala layer does not pass file content yet;
wenzelm
parents:
44866
diff
changeset
|
380 |
}) |
48705
dd32321d6eef
tuned signature -- slightly more abstract text representation of prover process;
wenzelm
parents:
47542
diff
changeset
|
381 |
YXML.string_of_body(encode_edits(edits)) } |
52582 | 382 |
protocol_command("Document.update", Document_ID(old_id), Document_ID(new_id), edits_yxml) |
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
383 |
} |
43748 | 384 |
|
44673 | 385 |
def remove_versions(versions: List[Document.Version]) |
386 |
{ |
|
387 |
val versions_yxml = |
|
388 |
{ import XML.Encode._ |
|
389 |
YXML.string_of_body(list(long)(versions.map(_.id))) } |
|
52582 | 390 |
protocol_command("Document.remove_versions", versions_yxml) |
44673 | 391 |
} |
392 |
||
43748 | 393 |
|
50498 | 394 |
/* dialog via document content */ |
395 |
||
52931
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
396 |
def dialog_result(serial: Long, result: String): Unit = |
52582 | 397 |
protocol_command("Document.dialog_result", Properties.Value.Long(serial), result) |
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
398 |
} |