author | wenzelm |
Mon, 14 Oct 2019 21:00:04 +0200 | |
changeset 70867 | 4c8e28dabbc4 |
parent 70715 | fb94d68314fa |
child 71165 | 03afc8252225 |
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 |
|
70665
94442fce40a5
prefer commands_accepted: fewer protocol messages;
wenzelm
parents:
70664
diff
changeset
|
14 |
object Commands_Accepted |
94442fce40a5
prefer commands_accepted: fewer protocol messages;
wenzelm
parents:
70664
diff
changeset
|
15 |
{ |
94442fce40a5
prefer commands_accepted: fewer protocol messages;
wenzelm
parents:
70664
diff
changeset
|
16 |
def unapply(text: String): Option[List[Document_ID.Command]] = |
94442fce40a5
prefer commands_accepted: fewer protocol messages;
wenzelm
parents:
70664
diff
changeset
|
17 |
try { Some(space_explode(',', text).map(Value.Long.parse)) } |
94442fce40a5
prefer commands_accepted: fewer protocol messages;
wenzelm
parents:
70664
diff
changeset
|
18 |
catch { case ERROR(_) => None } |
94442fce40a5
prefer commands_accepted: fewer protocol messages;
wenzelm
parents:
70664
diff
changeset
|
19 |
|
94442fce40a5
prefer commands_accepted: fewer protocol messages;
wenzelm
parents:
70664
diff
changeset
|
20 |
val message: XML.Elem = XML.elem(Markup.STATUS, List(XML.elem(Markup.ACCEPTED))) |
94442fce40a5
prefer commands_accepted: fewer protocol messages;
wenzelm
parents:
70664
diff
changeset
|
21 |
} |
94442fce40a5
prefer commands_accepted: fewer protocol messages;
wenzelm
parents:
70664
diff
changeset
|
22 |
|
52563 | 23 |
object Assign_Update |
44476
e8a87398f35d
propagate information about last command with exec state assignment through document model;
wenzelm
parents:
44474
diff
changeset
|
24 |
{ |
70284
3e17c3a5fd39
more thorough assignment, e.g. when "purge" removes commands that were not assigned;
wenzelm
parents:
69849
diff
changeset
|
25 |
def unapply(text: String) |
3e17c3a5fd39
more thorough assignment, e.g. when "purge" removes commands that were not assigned;
wenzelm
parents:
69849
diff
changeset
|
26 |
: Option[(Document_ID.Version, List[String], Document.Assign_Update)] = |
3e17c3a5fd39
more thorough assignment, e.g. when "purge" removes commands that were not assigned;
wenzelm
parents:
69849
diff
changeset
|
27 |
{ |
44661
383c9d758a56
raw message function "assign_execs" avoids full overhead of decoding and caching message body;
wenzelm
parents:
44644
diff
changeset
|
28 |
try { |
383c9d758a56
raw message function "assign_execs" avoids full overhead of decoding and caching message body;
wenzelm
parents:
44644
diff
changeset
|
29 |
import XML.Decode._ |
69846 | 30 |
def decode_upd(body: XML.Body): (Long, List[Long]) = |
31 |
space_explode(',', string(body)).map(Value.Long.parse) match { |
|
32 |
case a :: bs => (a, bs) |
|
33 |
case _ => throw new XML.XML_Body(body) |
|
34 |
} |
|
70284
3e17c3a5fd39
more thorough assignment, e.g. when "purge" removes commands that were not assigned;
wenzelm
parents:
69849
diff
changeset
|
35 |
Some(triple(long, list(string), list(decode_upd _))(Symbol.decode_yxml(text))) |
44661
383c9d758a56
raw message function "assign_execs" avoids full overhead of decoding and caching message body;
wenzelm
parents:
44644
diff
changeset
|
36 |
} |
383c9d758a56
raw message function "assign_execs" avoids full overhead of decoding and caching message body;
wenzelm
parents:
44644
diff
changeset
|
37 |
catch { |
383c9d758a56
raw message function "assign_execs" avoids full overhead of decoding and caching message body;
wenzelm
parents:
44644
diff
changeset
|
38 |
case ERROR(_) => None |
51987 | 39 |
case _: XML.Error => None |
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
40 |
} |
70284
3e17c3a5fd39
more thorough assignment, e.g. when "purge" removes commands that were not assigned;
wenzelm
parents:
69849
diff
changeset
|
41 |
} |
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
42 |
} |
38567
b670faa807c9
concentrate protocol message formats in Isar_Document;
wenzelm
parents:
38483
diff
changeset
|
43 |
|
44676 | 44 |
object Removed |
45 |
{ |
|
52530
99dd8b4ef3fe
explicit module Document_ID as source of globally unique identifiers across ML/Scala;
wenzelm
parents:
52527
diff
changeset
|
46 |
def unapply(text: String): Option[List[Document_ID.Version]] = |
44676 | 47 |
try { |
48 |
import XML.Decode._ |
|
65345
2fdd4431b30e
clarified YXML vs. symbol encoding: operate on whole message;
wenzelm
parents:
65313
diff
changeset
|
49 |
Some(list(long)(Symbol.decode_yxml(text))) |
44676 | 50 |
} |
51 |
catch { |
|
52 |
case ERROR(_) => None |
|
51987 | 53 |
case _: XML.Error => None |
44676 | 54 |
} |
55 |
} |
|
56 |
||
38567
b670faa807c9
concentrate protocol message formats in Isar_Document;
wenzelm
parents:
38483
diff
changeset
|
57 |
|
51818
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
58 |
/* command timing */ |
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
59 |
|
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
60 |
object Command_Timing |
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
61 |
{ |
52531 | 62 |
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
|
63 |
props match { |
66873
9953ae603a23
provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents:
66717
diff
changeset
|
64 |
case Markup.COMMAND_TIMING :: args => |
51818
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
65 |
(args, args) match { |
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
66 |
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
|
67 |
case _ => None |
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
68 |
} |
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
69 |
case _ => None |
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
70 |
} |
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
71 |
} |
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
72 |
|
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
73 |
|
66873
9953ae603a23
provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents:
66717
diff
changeset
|
74 |
/* theory timing */ |
9953ae603a23
provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents:
66717
diff
changeset
|
75 |
|
9953ae603a23
provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents:
66717
diff
changeset
|
76 |
object Theory_Timing |
9953ae603a23
provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents:
66717
diff
changeset
|
77 |
{ |
9953ae603a23
provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents:
66717
diff
changeset
|
78 |
def unapply(props: Properties.T): Option[(String, isabelle.Timing)] = |
9953ae603a23
provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents:
66717
diff
changeset
|
79 |
props match { |
9953ae603a23
provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents:
66717
diff
changeset
|
80 |
case Markup.THEORY_TIMING :: args => |
9953ae603a23
provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents:
66717
diff
changeset
|
81 |
(args, args) match { |
9953ae603a23
provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents:
66717
diff
changeset
|
82 |
case (Markup.Name(name), Markup.Timing_Properties(timing)) => Some((name, timing)) |
9953ae603a23
provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents:
66717
diff
changeset
|
83 |
case _ => None |
9953ae603a23
provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents:
66717
diff
changeset
|
84 |
} |
9953ae603a23
provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents:
66717
diff
changeset
|
85 |
case _ => None |
9953ae603a23
provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents:
66717
diff
changeset
|
86 |
} |
9953ae603a23
provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents:
66717
diff
changeset
|
87 |
} |
9953ae603a23
provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents:
66717
diff
changeset
|
88 |
|
9953ae603a23
provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents:
66717
diff
changeset
|
89 |
|
39441
4110cc1b8f9f
allow embedded reports in regular prover messages, to avoid side-effects for errors for example;
wenzelm
parents:
39439
diff
changeset
|
90 |
/* 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
|
91 |
|
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
92 |
def is_result(msg: XML.Tree): Boolean = |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
93 |
msg match { |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
94 |
case XML.Elem(Markup(Markup.RESULT, _), _) => true |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
95 |
case _ => false |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
96 |
} |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
97 |
|
50157 | 98 |
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
|
99 |
msg match { |
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50157
diff
changeset
|
100 |
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
|
101 |
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
|
102 |
case _ => false |
53365ba766ac
Command.accumulate: refrain from adding tracing messages to markup tree -- potential scalability problem;
wenzelm
parents:
39511
diff
changeset
|
103 |
} |
53365ba766ac
Command.accumulate: refrain from adding tracing messages to markup tree -- potential scalability problem;
wenzelm
parents:
39511
diff
changeset
|
104 |
|
59184
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59085
diff
changeset
|
105 |
def is_state(msg: XML.Tree): Boolean = |
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
106 |
msg match { |
59184
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59085
diff
changeset
|
107 |
case XML.Elem(Markup(Markup.STATE, _), _) => true |
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59085
diff
changeset
|
108 |
case XML.Elem(Markup(Markup.STATE_MESSAGE, _), _) => true |
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59085
diff
changeset
|
109 |
case _ => false |
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59085
diff
changeset
|
110 |
} |
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59085
diff
changeset
|
111 |
|
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59085
diff
changeset
|
112 |
def is_information(msg: XML.Tree): Boolean = |
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59085
diff
changeset
|
113 |
msg match { |
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59085
diff
changeset
|
114 |
case XML.Elem(Markup(Markup.INFORMATION, _), _) => true |
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59085
diff
changeset
|
115 |
case XML.Elem(Markup(Markup.INFORMATION_MESSAGE, _), _) => true |
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
116 |
case _ => false |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
117 |
} |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
118 |
|
67923
3e072441c96a
clarified exported messages, e.g. suppress "information", "tracing";
wenzelm
parents:
67915
diff
changeset
|
119 |
def is_writeln(msg: XML.Tree): Boolean = |
3e072441c96a
clarified exported messages, e.g. suppress "information", "tracing";
wenzelm
parents:
67915
diff
changeset
|
120 |
msg match { |
3e072441c96a
clarified exported messages, e.g. suppress "information", "tracing";
wenzelm
parents:
67915
diff
changeset
|
121 |
case XML.Elem(Markup(Markup.WRITELN, _), _) => true |
3e072441c96a
clarified exported messages, e.g. suppress "information", "tracing";
wenzelm
parents:
67915
diff
changeset
|
122 |
case XML.Elem(Markup(Markup.WRITELN_MESSAGE, _), _) => true |
3e072441c96a
clarified exported messages, e.g. suppress "information", "tracing";
wenzelm
parents:
67915
diff
changeset
|
123 |
case _ => false |
3e072441c96a
clarified exported messages, e.g. suppress "information", "tracing";
wenzelm
parents:
67915
diff
changeset
|
124 |
} |
3e072441c96a
clarified exported messages, e.g. suppress "information", "tracing";
wenzelm
parents:
67915
diff
changeset
|
125 |
|
39511 | 126 |
def is_warning(msg: XML.Tree): Boolean = |
127 |
msg match { |
|
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50157
diff
changeset
|
128 |
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
|
129 |
case XML.Elem(Markup(Markup.WARNING_MESSAGE, _), _) => true |
39511 | 130 |
case _ => false |
131 |
} |
|
132 |
||
59203
5f0bd5afc16d
explicit message channel for "legacy", which is nonetheless a variant of "warning";
wenzelm
parents:
59184
diff
changeset
|
133 |
def is_legacy(msg: XML.Tree): Boolean = |
5f0bd5afc16d
explicit message channel for "legacy", which is nonetheless a variant of "warning";
wenzelm
parents:
59184
diff
changeset
|
134 |
msg match { |
5f0bd5afc16d
explicit message channel for "legacy", which is nonetheless a variant of "warning";
wenzelm
parents:
59184
diff
changeset
|
135 |
case XML.Elem(Markup(Markup.LEGACY, _), _) => true |
5f0bd5afc16d
explicit message channel for "legacy", which is nonetheless a variant of "warning";
wenzelm
parents:
59184
diff
changeset
|
136 |
case XML.Elem(Markup(Markup.LEGACY_MESSAGE, _), _) => true |
5f0bd5afc16d
explicit message channel for "legacy", which is nonetheless a variant of "warning";
wenzelm
parents:
59184
diff
changeset
|
137 |
case _ => false |
5f0bd5afc16d
explicit message channel for "legacy", which is nonetheless a variant of "warning";
wenzelm
parents:
59184
diff
changeset
|
138 |
} |
5f0bd5afc16d
explicit message channel for "legacy", which is nonetheless a variant of "warning";
wenzelm
parents:
59184
diff
changeset
|
139 |
|
39511 | 140 |
def is_error(msg: XML.Tree): Boolean = |
141 |
msg match { |
|
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50157
diff
changeset
|
142 |
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
|
143 |
case XML.Elem(Markup(Markup.ERROR_MESSAGE, _), _) => true |
39511 | 144 |
case _ => false |
145 |
} |
|
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
|
146 |
|
56495 | 147 |
def is_inlined(msg: XML.Tree): Boolean = |
148 |
!(is_result(msg) || is_tracing(msg) || is_state(msg)) |
|
149 |
||
67923
3e072441c96a
clarified exported messages, e.g. suppress "information", "tracing";
wenzelm
parents:
67915
diff
changeset
|
150 |
def is_exported(msg: XML.Tree): Boolean = |
3e072441c96a
clarified exported messages, e.g. suppress "information", "tracing";
wenzelm
parents:
67915
diff
changeset
|
151 |
is_writeln(msg) || is_warning(msg) || is_legacy(msg) || is_error(msg) |
3e072441c96a
clarified exported messages, e.g. suppress "information", "tracing";
wenzelm
parents:
67915
diff
changeset
|
152 |
|
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
153 |
|
60882 | 154 |
/* breakpoints */ |
155 |
||
156 |
object ML_Breakpoint |
|
157 |
{ |
|
158 |
def unapply(tree: XML.Tree): Option[Long] = |
|
159 |
tree match { |
|
160 |
case XML.Elem(Markup(Markup.ML_BREAKPOINT, Markup.Serial(breakpoint)), _) => Some(breakpoint) |
|
161 |
case _ => None |
|
162 |
} |
|
163 |
} |
|
164 |
||
165 |
||
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
166 |
/* dialogs */ |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
167 |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
168 |
object Dialog_Args |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
169 |
{ |
52531 | 170 |
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
|
171 |
(props, props, props) match { |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
172 |
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
|
173 |
Some((id, serial, result)) |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
174 |
case _ => None |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
175 |
} |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
176 |
} |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
177 |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
178 |
object Dialog |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
179 |
{ |
52531 | 180 |
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
|
181 |
tree match { |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
182 |
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
|
183 |
Some((id, serial, result)) |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
184 |
case _ => None |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
185 |
} |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
186 |
} |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
187 |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
188 |
object Dialog_Result |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
189 |
{ |
52531 | 190 |
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
|
191 |
{ |
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50500
diff
changeset
|
192 |
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
|
193 |
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
|
194 |
} |
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
195 |
|
50501
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50500
diff
changeset
|
196 |
def unapply(tree: XML.Tree): Option[String] = |
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
197 |
tree match { |
50501
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50500
diff
changeset
|
198 |
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
|
199 |
case _ => None |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
200 |
} |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
201 |
} |
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
202 |
} |
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
203 |
|
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
204 |
|
57916 | 205 |
trait Protocol |
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
206 |
{ |
57916 | 207 |
/* protocol commands */ |
208 |
||
70661 | 209 |
def protocol_command_raw(name: String, args: List[Bytes]): Unit |
210 |
def protocol_command_args(name: String, args: List[String]) |
|
57916 | 211 |
def protocol_command(name: String, args: String*): Unit |
212 |
||
213 |
||
56387 | 214 |
/* options */ |
215 |
||
216 |
def options(opts: Options): Unit = |
|
65345
2fdd4431b30e
clarified YXML vs. symbol encoding: operate on whole message;
wenzelm
parents:
65313
diff
changeset
|
217 |
protocol_command("Prover.options", Symbol.encode_yxml(opts.encode)) |
56387 | 218 |
|
219 |
||
65470 | 220 |
/* session base */ |
221 |
||
222 |
private def encode_table(table: List[(String, String)]): String = |
|
223 |
{ |
|
224 |
import XML.Encode._ |
|
225 |
Symbol.encode_yxml(list(pair(string, string))(table)) |
|
226 |
} |
|
227 |
||
66712 | 228 |
private def encode_list(lst: List[String]): String = |
229 |
{ |
|
230 |
import XML.Encode._ |
|
231 |
Symbol.encode_yxml(list(string)(lst)) |
|
232 |
} |
|
233 |
||
67493
c4e9e0c50487
treat sessions as entities with defining position;
wenzelm
parents:
67471
diff
changeset
|
234 |
private def encode_sessions(lst: List[(String, Position.T)]): String = |
c4e9e0c50487
treat sessions as entities with defining position;
wenzelm
parents:
67471
diff
changeset
|
235 |
{ |
c4e9e0c50487
treat sessions as entities with defining position;
wenzelm
parents:
67471
diff
changeset
|
236 |
import XML.Encode._ |
c4e9e0c50487
treat sessions as entities with defining position;
wenzelm
parents:
67471
diff
changeset
|
237 |
Symbol.encode_yxml(list(pair(string, properties))(lst)) |
c4e9e0c50487
treat sessions as entities with defining position;
wenzelm
parents:
67471
diff
changeset
|
238 |
} |
c4e9e0c50487
treat sessions as entities with defining position;
wenzelm
parents:
67471
diff
changeset
|
239 |
|
66668
6019cfb8256c
proper standard_path to revert platform_path in JEdit_Sessions.session_base;
wenzelm
parents:
66411
diff
changeset
|
240 |
def session_base(resources: Resources) |
6019cfb8256c
proper standard_path to revert platform_path in JEdit_Sessions.session_base;
wenzelm
parents:
66411
diff
changeset
|
241 |
{ |
67219 | 242 |
protocol_command("Prover.init_session_base", |
70683
8c7706b053c7
find theory files via session structure: much faster Prover IDE startup;
wenzelm
parents:
70665
diff
changeset
|
243 |
encode_sessions(resources.sessions_structure.session_positions), |
8c7706b053c7
find theory files via session structure: much faster Prover IDE startup;
wenzelm
parents:
70665
diff
changeset
|
244 |
encode_table(resources.sessions_structure.dest_session_directories), |
70715
fb94d68314fa
clarified signature -- removed pointless operations;
wenzelm
parents:
70712
diff
changeset
|
245 |
encode_list(resources.session_base.doc_names), |
fb94d68314fa
clarified signature -- removed pointless operations;
wenzelm
parents:
70712
diff
changeset
|
246 |
encode_table(resources.session_base.global_theories.toList), |
fb94d68314fa
clarified signature -- removed pointless operations;
wenzelm
parents:
70712
diff
changeset
|
247 |
encode_list(resources.session_base.loaded_theories.keys)) |
66668
6019cfb8256c
proper standard_path to revert platform_path in JEdit_Sessions.session_base;
wenzelm
parents:
66411
diff
changeset
|
248 |
} |
65470 | 249 |
|
250 |
||
56387 | 251 |
/* interned items */ |
54519
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
252 |
|
56335
8953d4cc060a
store blob content within document node: aux. files that were once open are made persistent;
wenzelm
parents:
56306
diff
changeset
|
253 |
def define_blob(digest: SHA1.Digest, bytes: Bytes): Unit = |
70661 | 254 |
protocol_command_raw("Document.define_blob", List(Bytes(digest.toString), bytes)) |
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
255 |
|
70664
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
256 |
private def encode_command(command: Command): (String, String, String, String, List[String]) = |
54519
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
257 |
{ |
70664
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
258 |
import XML.Encode._ |
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
259 |
|
54519
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
260 |
val blobs_yxml = |
61376
93224745477f
output HTML text according to Isabelle/Scala Symbol.Interpretation;
wenzelm
parents:
60992
diff
changeset
|
261 |
{ |
54519
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
262 |
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
|
263 |
variant(List( |
54526 | 264 |
{ case Exn.Res((a, b)) => |
65345
2fdd4431b30e
clarified YXML vs. symbol encoding: operate on whole message;
wenzelm
parents:
65313
diff
changeset
|
265 |
(Nil, pair(string, option(string))((a.node, b.map(p => p._1.toString)))) }, |
2fdd4431b30e
clarified YXML vs. symbol encoding: operate on whole message;
wenzelm
parents:
65313
diff
changeset
|
266 |
{ case Exn.Exn(e) => (Nil, string(Exn.message(e))) })) |
59085
08a6901eb035
clarified define_command: send tokens more directly, without requiring keywords in ML;
wenzelm
parents:
58015
diff
changeset
|
267 |
|
65345
2fdd4431b30e
clarified YXML vs. symbol encoding: operate on whole message;
wenzelm
parents:
65313
diff
changeset
|
268 |
Symbol.encode_yxml(pair(list(encode_blob), int)(command.blobs, command.blobs_index)) |
54519
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
269 |
} |
59085
08a6901eb035
clarified define_command: send tokens more directly, without requiring keywords in ML;
wenzelm
parents:
58015
diff
changeset
|
270 |
|
08a6901eb035
clarified define_command: send tokens more directly, without requiring keywords in ML;
wenzelm
parents:
58015
diff
changeset
|
271 |
val toks_yxml = |
61376
93224745477f
output HTML text according to Isabelle/Scala Symbol.Interpretation;
wenzelm
parents:
60992
diff
changeset
|
272 |
{ |
64616 | 273 |
val encode_tok: T[Token] = (tok => pair(int, int)((tok.kind.id, Symbol.length(tok.source)))) |
70664
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
274 |
Symbol.encode_yxml(list(encode_tok)(command.span.content)) |
59085
08a6901eb035
clarified define_command: send tokens more directly, without requiring keywords in ML;
wenzelm
parents:
58015
diff
changeset
|
275 |
} |
70664
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
276 |
val toks_sources = command.span.content.map(tok => Symbol.encode(tok.source)) |
59085
08a6901eb035
clarified define_command: send tokens more directly, without requiring keywords in ML;
wenzelm
parents:
58015
diff
changeset
|
277 |
|
70664
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
278 |
(Document_ID(command.id), Symbol.encode(command.span.name), blobs_yxml, toks_yxml, toks_sources) |
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
279 |
} |
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
280 |
|
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
281 |
def define_command(command: Command) |
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
282 |
{ |
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
283 |
val (command_id, name, blobs_yxml, toks_yxml, toks_sources) = encode_command(command) |
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
284 |
protocol_command_args( |
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
285 |
"Document.define_command", command_id :: name :: blobs_yxml :: toks_yxml :: toks_sources) |
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
286 |
} |
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
287 |
|
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
288 |
def define_commands(commands: List[Command]) |
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
289 |
{ |
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
290 |
protocol_command_args("Document.define_commands", |
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
291 |
commands.map(command => |
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
292 |
{ |
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
293 |
import XML.Encode._ |
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
294 |
val (command_id, name, blobs_yxml, toks_yxml, toks_sources) = encode_command(command) |
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
295 |
val body = |
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
296 |
pair(string, pair(string, pair(string, pair(string, list(string)))))( |
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
297 |
command_id, (name, (blobs_yxml, (toks_yxml, toks_sources)))) |
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
298 |
YXML.string_of_body(body) |
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
299 |
})) |
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
300 |
} |
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
301 |
|
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
302 |
def define_commands_bulk(commands: List[Command]) |
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
303 |
{ |
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
304 |
val (irregular, regular) = commands.partition(command => YXML.detect(command.source)) |
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
305 |
irregular.foreach(define_command(_)) |
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
306 |
regular match { |
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
307 |
case Nil => |
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
308 |
case List(command) => define_command(command) |
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
309 |
case _ => define_commands(regular) |
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
310 |
} |
54519
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
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 |
|
52931
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
314 |
/* execution */ |
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
315 |
|
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
316 |
def discontinue_execution(): Unit = |
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
317 |
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
|
318 |
|
52931
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
319 |
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
|
320 |
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
|
321 |
|
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
322 |
|
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
323 |
/* 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
|
324 |
|
52530
99dd8b4ef3fe
explicit module Document_ID as source of globally unique identifiers across ML/Scala;
wenzelm
parents:
52527
diff
changeset
|
325 |
def update(old_id: Document_ID.Version, new_id: Document_ID.Version, |
68381
2fd3a6d6ba2e
less wasteful consolidation, based on PIDE front-end state and recent changes;
wenzelm
parents:
68336
diff
changeset
|
326 |
edits: List[Document.Edit_Command], consolidate: List[Document.Node.Name]) |
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
327 |
{ |
69849 | 328 |
val consolidate_yxml = |
329 |
{ |
|
330 |
import XML.Encode._ |
|
331 |
Symbol.encode_yxml(list(string)(consolidate.map(_.node))) |
|
332 |
} |
|
44157
a21d3e1e64fd
uniform treatment of header edits as document edits;
wenzelm
parents:
44156
diff
changeset
|
333 |
val edits_yxml = |
61376
93224745477f
output HTML text according to Isabelle/Scala Symbol.Interpretation;
wenzelm
parents:
60992
diff
changeset
|
334 |
{ |
93224745477f
output HTML text according to Isabelle/Scala Symbol.Interpretation;
wenzelm
parents:
60992
diff
changeset
|
335 |
import XML.Encode._ |
44383 | 336 |
def id: T[Command] = (cmd => long(cmd.id)) |
46737 | 337 |
def encode_edit(name: Document.Node.Name) |
52849 | 338 |
: 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
|
339 |
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
|
340 |
{ 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
|
341 |
{ case Document.Node.Deps(header) => |
60992 | 342 |
val master_dir = File.standard_url(name.master_dir) |
70638
f164cec7ac22
clarified signature: prefer operations without position;
wenzelm
parents:
70284
diff
changeset
|
343 |
val imports = header.imports.map(_.node) |
65384 | 344 |
val keywords = |
345 |
header.keywords.map({ case (a, Keyword.Spec(b, c, d)) => (a, ((b, c), d)) }) |
|
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
|
346 |
(Nil, |
65345
2fdd4431b30e
clarified YXML vs. symbol encoding: operate on whole message;
wenzelm
parents:
65313
diff
changeset
|
347 |
pair(string, pair(string, pair(list(string), pair(list(pair(string, |
2fdd4431b30e
clarified YXML vs. symbol encoding: operate on whole message;
wenzelm
parents:
65313
diff
changeset
|
348 |
pair(pair(string, list(string)), list(string)))), list(string)))))( |
65445
e9e7f5f5794c
more qualifier treatment, but in the end it is still ignored;
wenzelm
parents:
65439
diff
changeset
|
349 |
(master_dir, (name.theory, (imports, (keywords, header.errors)))))) }, |
52849 | 350 |
{ case Document.Node.Perspective(a, b, c) => |
351 |
(bool_atom(a) :: b.commands.map(cmd => long_atom(cmd.id)), |
|
65345
2fdd4431b30e
clarified YXML vs. symbol encoding: operate on whole message;
wenzelm
parents:
65313
diff
changeset
|
352 |
list(pair(id, pair(string, list(string))))(c.dest)) })) |
69849 | 353 |
edits.map({ case (name, edit) => |
354 |
Symbol.encode_yxml(pair(string, encode_edit(name))(name.node, edit)) }) |
|
68381
2fd3a6d6ba2e
less wasteful consolidation, based on PIDE front-end state and recent changes;
wenzelm
parents:
68336
diff
changeset
|
355 |
} |
70661 | 356 |
protocol_command_args("Document.update", |
357 |
Document_ID(old_id) :: Document_ID(new_id) :: consolidate_yxml :: edits_yxml) |
|
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
358 |
} |
43748 | 359 |
|
44673 | 360 |
def remove_versions(versions: List[Document.Version]) |
361 |
{ |
|
362 |
val versions_yxml = |
|
59364 | 363 |
{ import XML.Encode._ |
65345
2fdd4431b30e
clarified YXML vs. symbol encoding: operate on whole message;
wenzelm
parents:
65313
diff
changeset
|
364 |
Symbol.encode_yxml(list(long)(versions.map(_.id))) } |
52582 | 365 |
protocol_command("Document.remove_versions", versions_yxml) |
44673 | 366 |
} |
367 |
||
43748 | 368 |
|
50498 | 369 |
/* dialog via document content */ |
370 |
||
52931
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
371 |
def dialog_result(serial: Long, result: String): Unit = |
63805 | 372 |
protocol_command("Document.dialog_result", Value.Long(serial), result) |
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
373 |
} |